2 --Copyright (C) 2013 sapier
4 --This program is free software; you can redistribute it and/or modify
5 --it under the terms of the GNU Lesser General Public License as published by
6 --the Free Software Foundation; either version 2.1 of the License, or
7 --(at your option) any later version.
9 --This program is distributed in the hope that it will be useful,
10 --but WITHOUT ANY WARRANTY; without even the implied warranty of
11 --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 --GNU Lesser General Public License for more details.
14 --You should have received a copy of the GNU Lesser General Public License along
15 --with this program; if not, write to the Free Software Foundation, Inc.,
16 --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 --------------------------------------------------------------------------------
22 fgettext("Opaque Leaves"),
23 fgettext("Simple Leaves"),
24 fgettext("Fancy Leaves")
27 fgettext("Node Outlining"),
28 fgettext("Node Highlighting"),
32 fgettext("No Filter"),
33 fgettext("Bilinear Filter"),
34 fgettext("Trilinear Filter")
37 fgettext("No Mipmap"),
39 fgettext("Mipmap + Aniso. Filter")
59 table.concat(labels.leaves, ","),
60 {"opaque", "simple", "fancy"}
63 table.concat(labels.node_highlighting, ","),
64 {"box", "halo", "none"}
67 table.concat(labels.filters, ","),
68 {"", "bilinear_filter", "trilinear_filter"}
71 table.concat(labels.mipmap, ","),
72 {"", "mip_map", "anisotropic_filter"}
75 table.concat(labels.antialiasing, ","),
79 table.concat(labels.shadow_levels, ","),
80 { "0", "1", "2", "3", "4", "5" }
84 local getSettingIndex = {
86 local style = core.settings:get("leaves_style")
87 for idx, name in pairs(dd_options.leaves[2]) do
88 if style == name then return idx end
92 NodeHighlighting = function()
93 local style = core.settings:get("node_highlighting")
94 for idx, name in pairs(dd_options.node_highlighting[2]) do
95 if style == name then return idx end
100 if core.settings:get(dd_options.filters[2][3]) == "true" then
102 elseif core.settings:get(dd_options.filters[2][3]) == "false" and
103 core.settings:get(dd_options.filters[2][2]) == "true" then
109 if core.settings:get(dd_options.mipmap[2][3]) == "true" then
111 elseif core.settings:get(dd_options.mipmap[2][3]) == "false" and
112 core.settings:get(dd_options.mipmap[2][2]) == "true" then
117 Antialiasing = function()
118 local antialiasing_setting = core.settings:get("fsaa")
119 for i = 1, #dd_options.antialiasing[2] do
120 if antialiasing_setting == dd_options.antialiasing[2][i] then
126 ShadowMapping = function()
127 local shadow_setting = core.settings:get("shadow_levels")
128 for i = 1, #dd_options.shadow_levels[2] do
129 if shadow_setting == dd_options.shadow_levels[2][i] then
137 local function antialiasing_fname_to_name(fname)
138 for i = 1, #labels.antialiasing do
139 if fname == labels.antialiasing[i] then
140 return dd_options.antialiasing[2][i]
146 local function formspec(tabview, name, tabdata)
148 "box[0,0;3.75,4.5;#999999]" ..
149 "checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
150 .. dump(core.settings:get_bool("smooth_lighting")) .. "]" ..
151 "checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";"
152 .. dump(core.settings:get_bool("enable_particles")) .. "]" ..
153 "checkbox[0.25,1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";"
154 .. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" ..
155 "checkbox[0.25,1.5;cb_opaque_water;" .. fgettext("Opaque Water") .. ";"
156 .. dump(core.settings:get_bool("opaque_water")) .. "]" ..
157 "checkbox[0.25,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";"
158 .. dump(core.settings:get_bool("connected_glass")) .. "]" ..
159 "dropdown[0.25,2.8;3.5;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
160 .. getSettingIndex.NodeHighlighting() .. "]" ..
161 "dropdown[0.25,3.6;3.5;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
162 .. getSettingIndex.Leaves() .. "]" ..
163 "box[4,0;3.75,4.5;#999999]" ..
164 "label[4.25,0.1;" .. fgettext("Texturing:") .. "]" ..
165 "dropdown[4.25,0.55;3.5;dd_filters;" .. dd_options.filters[1] .. ";"
166 .. getSettingIndex.Filter() .. "]" ..
167 "dropdown[4.25,1.35;3.5;dd_mipmap;" .. dd_options.mipmap[1] .. ";"
168 .. getSettingIndex.Mipmap() .. "]" ..
169 "label[4.25,2.15;" .. fgettext("Antialiasing:") .. "]" ..
170 "dropdown[4.25,2.6;3.5;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";"
171 .. getSettingIndex.Antialiasing() .. "]" ..
172 "label[4.25,3.45;" .. fgettext("Screen:") .. "]" ..
173 "checkbox[4.25,3.6;cb_autosave_screensize;" .. fgettext("Autosave Screen Size") .. ";"
174 .. dump(core.settings:get_bool("autosave_screensize")) .. "]" ..
175 "box[8,0;3.75,4.5;#999999]"
177 local video_driver = core.settings:get("video_driver")
178 local shaders_enabled = core.settings:get_bool("enable_shaders")
179 if video_driver == "opengl" then
180 tab_string = tab_string ..
181 "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders") .. ";"
182 .. tostring(shaders_enabled) .. "]"
183 elseif video_driver == "ogles2" then
184 tab_string = tab_string ..
185 "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders (experimental)") .. ";"
186 .. tostring(shaders_enabled) .. "]"
188 core.settings:set_bool("enable_shaders", false)
189 shaders_enabled = false
190 tab_string = tab_string ..
191 "label[8.38,0.2;" .. core.colorize("#888888",
192 fgettext("Shaders (unavailable)")) .. "]"
195 tab_string = tab_string ..
196 "button[8,4.75;3.95,1;btn_change_keys;"
197 .. fgettext("Change Keys") .. "]"
199 tab_string = tab_string ..
200 "button[0,4.75;3.95,1;btn_advanced_settings;"
201 .. fgettext("All Settings") .. "]"
204 if core.settings:get("touchscreen_threshold") ~= nil then
205 tab_string = tab_string ..
206 "label[4.3,4.2;" .. fgettext("Touchthreshold: (px)") .. "]" ..
207 "dropdown[4.25,4.65;3.5;dd_touchthreshold;0,10,20,30,40,50;" ..
208 ((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) ..
209 "]box[4.0,4.5;3.75,1.0;#999999]"
212 if shaders_enabled then
213 tab_string = tab_string ..
214 "checkbox[8.25,0.5;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
215 .. dump(core.settings:get_bool("tone_mapping")) .. "]" ..
216 "checkbox[8.25,1;cb_waving_water;" .. fgettext("Waving Liquids") .. ";"
217 .. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
218 "checkbox[8.25,1.5;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
219 .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
220 "checkbox[8.25,2;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
221 .. dump(core.settings:get_bool("enable_waving_plants")) .. "]"..
222 "label[8.25,2.8;" .. fgettext("Dynamic shadows:") .. "]" ..
223 "label[8.25,3.2;" .. fgettext("(game support required)") .. "]" ..
224 "dropdown[8.25,3.7;3.5;dd_shadows;" .. dd_options.shadow_levels[1] .. ";"
225 .. getSettingIndex.ShadowMapping() .. "]"
227 tab_string = tab_string ..
228 "label[8.38,0.7;" .. core.colorize("#888888",
229 fgettext("Tone Mapping")) .. "]" ..
230 "label[8.38,1.2;" .. core.colorize("#888888",
231 fgettext("Waving Liquids")) .. "]" ..
232 "label[8.38,1.7;" .. core.colorize("#888888",
233 fgettext("Waving Leaves")) .. "]" ..
234 "label[8.38,2.2;" .. core.colorize("#888888",
235 fgettext("Waving Plants")) .. "]"..
236 "label[8.38,2.7;" .. core.colorize("#888888",
237 fgettext("Dynamic shadows")) .. "]"
243 --------------------------------------------------------------------------------
244 local function handle_settings_buttons(this, fields, tabname, tabdata)
246 if fields["btn_advanced_settings"] ~= nil then
247 local adv_settings_dlg = create_adv_settings_dlg()
248 adv_settings_dlg:set_parent(this)
250 adv_settings_dlg:show()
251 --mm_game_theme.update("singleplayer", current_game())
254 if fields["cb_smooth_lighting"] then
255 core.settings:set("smooth_lighting", fields["cb_smooth_lighting"])
258 if fields["cb_particles"] then
259 core.settings:set("enable_particles", fields["cb_particles"])
262 if fields["cb_3d_clouds"] then
263 core.settings:set("enable_3d_clouds", fields["cb_3d_clouds"])
266 if fields["cb_opaque_water"] then
267 core.settings:set("opaque_water", fields["cb_opaque_water"])
270 if fields["cb_connected_glass"] then
271 core.settings:set("connected_glass", fields["cb_connected_glass"])
274 if fields["cb_autosave_screensize"] then
275 core.settings:set("autosave_screensize", fields["cb_autosave_screensize"])
278 if fields["cb_shaders"] then
279 core.settings:set("enable_shaders", fields["cb_shaders"])
282 if fields["cb_tonemapping"] then
283 core.settings:set("tone_mapping", fields["cb_tonemapping"])
286 if fields["cb_waving_water"] then
287 core.settings:set("enable_waving_water", fields["cb_waving_water"])
290 if fields["cb_waving_leaves"] then
291 core.settings:set("enable_waving_leaves", fields["cb_waving_leaves"])
293 if fields["cb_waving_plants"] then
294 core.settings:set("enable_waving_plants", fields["cb_waving_plants"])
297 if fields["btn_change_keys"] then
298 core.show_keys_menu()
301 if fields["cb_touchscreen_target"] then
302 core.settings:set("touchtarget", fields["cb_touchscreen_target"])
306 --Note dropdowns have to be handled LAST!
307 local ddhandled = false
309 for i = 1, #labels.leaves do
310 if fields["dd_leaves_style"] == labels.leaves[i] then
311 core.settings:set("leaves_style", dd_options.leaves[2][i])
315 for i = 1, #labels.node_highlighting do
316 if fields["dd_node_highlighting"] == labels.node_highlighting[i] then
317 core.settings:set("node_highlighting", dd_options.node_highlighting[2][i])
321 if fields["dd_filters"] == labels.filters[1] then
322 core.settings:set("bilinear_filter", "false")
323 core.settings:set("trilinear_filter", "false")
325 elseif fields["dd_filters"] == labels.filters[2] then
326 core.settings:set("bilinear_filter", "true")
327 core.settings:set("trilinear_filter", "false")
329 elseif fields["dd_filters"] == labels.filters[3] then
330 core.settings:set("bilinear_filter", "false")
331 core.settings:set("trilinear_filter", "true")
334 if fields["dd_mipmap"] == labels.mipmap[1] then
335 core.settings:set("mip_map", "false")
336 core.settings:set("anisotropic_filter", "false")
338 elseif fields["dd_mipmap"] == labels.mipmap[2] then
339 core.settings:set("mip_map", "true")
340 core.settings:set("anisotropic_filter", "false")
342 elseif fields["dd_mipmap"] == labels.mipmap[3] then
343 core.settings:set("mip_map", "true")
344 core.settings:set("anisotropic_filter", "true")
347 if fields["dd_antialiasing"] then
348 core.settings:set("fsaa",
349 antialiasing_fname_to_name(fields["dd_antialiasing"]))
352 if fields["dd_touchthreshold"] then
353 core.settings:set("touchscreen_threshold", fields["dd_touchthreshold"])
357 for i = 1, #labels.shadow_levels do
358 if fields["dd_shadows"] == labels.shadow_levels[i] then
359 core.settings:set("shadow_levels", dd_options.shadow_levels[2][i])
364 if fields["dd_shadows"] == labels.shadow_levels[1] then
365 core.settings:set("enable_dynamic_shadows", "false")
367 local shadow_presets = {
368 [2] = { 62, 512, "true", 0, "false" },
369 [3] = { 93, 1024, "true", 0, "false" },
370 [4] = { 140, 2048, "true", 1, "false" },
371 [5] = { 210, 4096, "true", 2, "true" },
372 [6] = { 300, 8192, "true", 2, "true" },
374 local s = shadow_presets[table.indexof(labels.shadow_levels, fields["dd_shadows"])]
376 core.settings:set("enable_dynamic_shadows", "true")
377 core.settings:set("shadow_map_max_distance", s[1])
378 core.settings:set("shadow_map_texture_size", s[2])
379 core.settings:set("shadow_map_texture_32bit", s[3])
380 core.settings:set("shadow_filters", s[4])
381 core.settings:set("shadow_map_color", s[5])
390 caption = fgettext("Settings"),
391 cbf_formspec = formspec,
392 cbf_button_handler = handle_settings_buttons