]> git.lizzy.rs Git - minetest.git/blobdiff - builtin/mainmenu/tab_settings.lua
Disable dynamic shadows for the 5.5.0 release
[minetest.git] / builtin / mainmenu / tab_settings.lua
index d39030b1d02d378d4e4cc247c73b180645871219..700b7390fa226ded3bba94c90c340be38f958095 100644 (file)
 
 --------------------------------------------------------------------------------
 
-local leaves_style_labels = {
-       fgettext("Opaque Leaves"),
-       fgettext("Simple Leaves"),
-       fgettext("Fancy Leaves")
+local labels = {
+       leaves = {
+               fgettext("Opaque Leaves"),
+               fgettext("Simple Leaves"),
+               fgettext("Fancy Leaves")
+       },
+       node_highlighting = {
+               fgettext("Node Outlining"),
+               fgettext("Node Highlighting"),
+               fgettext("None")
+       },
+       filters = {
+               fgettext("No Filter"),
+               fgettext("Bilinear Filter"),
+               fgettext("Trilinear Filter")
+       },
+       mipmap = {
+               fgettext("No Mipmap"),
+               fgettext("Mipmap"),
+               fgettext("Mipmap + Aniso. Filter")
+       },
+       antialiasing = {
+               fgettext("None"),
+               fgettext("2x"),
+               fgettext("4x"),
+               fgettext("8x")
+       },
+       shadow_levels = {
+               fgettext("Disabled"),
+               fgettext("Very Low"),
+               fgettext("Low"),
+               fgettext("Medium"),
+               fgettext("High"),
+               fgettext("Ultra High")
+       }
 }
 
-local leaves_style = {
-       {leaves_style_labels[1]..","..leaves_style_labels[2]..","..leaves_style_labels[3]},
-       {"opaque", "simple", "fancy"},
+local dd_options = {
+       leaves = {
+               table.concat(labels.leaves, ","),
+               {"opaque", "simple", "fancy"}
+       },
+       node_highlighting = {
+               table.concat(labels.node_highlighting, ","),
+               {"box", "halo", "none"}
+       },
+       filters = {
+               table.concat(labels.filters, ","),
+               {"", "bilinear_filter", "trilinear_filter"}
+       },
+       mipmap = {
+               table.concat(labels.mipmap, ","),
+               {"", "mip_map", "anisotropic_filter"}
+       },
+       antialiasing = {
+               table.concat(labels.antialiasing, ","),
+               {"0", "2", "4", "8"}
+       },
+       shadow_levels = {
+               table.concat(labels.shadow_levels, ","),
+               { "0", "1", "2", "3", "4", "5" }
+       }
 }
 
-local dd_filter_labels = {
-       fgettext("No Filter"),
-       fgettext("Bilinear Filter"),
-       fgettext("Trilinear Filter")
-}
-
-local filters = {
-       {dd_filter_labels[1]..","..dd_filter_labels[2]..","..dd_filter_labels[3]},
-       {"", "bilinear_filter", "trilinear_filter"},
-}
-
-local dd_mipmap_labels = {
-       fgettext("No Mipmap"),
-       fgettext("Mipmap"),
-       fgettext("Mipmap + Aniso. Filter")
-}
-
-local mipmap = {
-       {dd_mipmap_labels[1]..","..dd_mipmap_labels[2]..","..dd_mipmap_labels[3]},
-       {"", "mip_map", "anisotropic_filter"},
-}
-
-local function getLeavesStyleSettingIndex()
-       local style = core.setting_get("leaves_style")
-       if (style == leaves_style[2][3]) then
-               return 3
-       elseif (style == leaves_style[2][2]) then
-               return 2
-       end
-       return 1
-end
-
-local dd_antialiasing_labels = {
-       fgettext("None"),
-       fgettext("2x"),
-       fgettext("4x"),
-       fgettext("8x"),
-}
-
-local antialiasing = {
-       {dd_antialiasing_labels[1]..","..dd_antialiasing_labels[2]..","..
-               dd_antialiasing_labels[3]..","..dd_antialiasing_labels[4]},
-       {"0", "2", "4", "8"}
-}
-
-local function getFilterSettingIndex()
-       if (core.setting_get(filters[2][3]) == "true") then
-               return 3
-       end
-       if (core.setting_get(filters[2][3]) == "false" and core.setting_get(filters[2][2]) == "true") then
-               return 2
-       end
-       return 1
-end
-
-local function getMipmapSettingIndex()
-       if (core.setting_get(mipmap[2][3]) == "true") then
-               return 3
-       end
-       if (core.setting_get(mipmap[2][3]) == "false" and core.setting_get(mipmap[2][2]) == "true") then
-               return 2
-       end
-       return 1
-end
-
-local function getAntialiasingSettingIndex()
-       local antialiasing_setting = core.setting_get("fsaa")
-       for i = 1, #(antialiasing[2]) do
-               if antialiasing_setting == antialiasing[2][i] then
-                       return i
+local getSettingIndex = {
+       Leaves = function()
+               local style = core.settings:get("leaves_style")
+               for idx, name in pairs(dd_options.leaves[2]) do
+                       if style == name then return idx end
                end
-       end
-       return 1
-end
-
-local function antialiasing_fname_to_name(fname)
-       for i = 1, #(dd_antialiasing_labels) do
-               if fname == dd_antialiasing_labels[i] then
-                       return antialiasing[2][i]
+               return 1
+       end,
+       NodeHighlighting = function()
+               local style = core.settings:get("node_highlighting")
+               for idx, name in pairs(dd_options.node_highlighting[2]) do
+                       if style == name then return idx end
                end
-       end
-       return 0
-end
-
-local function dlg_confirm_reset_formspec(data)
-       local retval =
-               "size[8,3]" ..
-               "label[1,1;".. fgettext("Are you sure to reset your singleplayer world?") .. "]"..
-               "button[1,2;2.6,0.5;dlg_reset_singleplayer_confirm;"..
-                               fgettext("Yes") .. "]" ..
-               "button[4,2;2.8,0.5;dlg_reset_singleplayer_cancel;"..
-                               fgettext("No!!!") .. "]"
-       return retval
-end
-
-local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
-
-       if fields["dlg_reset_singleplayer_confirm"] ~= nil then
-               local worldlist = core.get_worlds()
-               local found_singleplayerworld = false
-
-               for i=1,#worldlist,1 do
-                       if worldlist[i].name == "singleplayerworld" then
-                               found_singleplayerworld = true
-                               gamedata.worldindex = i
-                       end
+               return 1
+       end,
+       Filter = function()
+               if core.settings:get(dd_options.filters[2][3]) == "true" then
+                       return 3
+               elseif core.settings:get(dd_options.filters[2][3]) == "false" and
+                               core.settings:get(dd_options.filters[2][2]) == "true" then
+                       return 2
                end
-
-               if found_singleplayerworld then
-                       core.delete_world(gamedata.worldindex)
+               return 1
+       end,
+       Mipmap = function()
+               if core.settings:get(dd_options.mipmap[2][3]) == "true" then
+                       return 3
+               elseif core.settings:get(dd_options.mipmap[2][3]) == "false" and
+                               core.settings:get(dd_options.mipmap[2][2]) == "true" then
+                       return 2
                end
-
-               core.create_world("singleplayerworld", 1)
-
-               worldlist = core.get_worlds()
-
-               found_singleplayerworld = false
-
-               for i=1,#worldlist,1 do
-                       if worldlist[i].name == "singleplayerworld" then
-                               found_singleplayerworld = true
-                               gamedata.worldindex = i
+               return 1
+       end,
+       Antialiasing = function()
+               local antialiasing_setting = core.settings:get("fsaa")
+               for i = 1, #dd_options.antialiasing[2] do
+                       if antialiasing_setting == dd_options.antialiasing[2][i] then
+                               return i
                        end
                end
+               return 1
+       end,
+       ShadowMapping = function()
+               local shadow_setting = core.settings:get("shadow_levels")
+               for i = 1, #dd_options.shadow_levels[2] do
+                       if shadow_setting == dd_options.shadow_levels[2][i] then
+                               return i
+                       end
+               end
+               return 1
        end
+}
 
-       this.parent:show()
-       this:hide()
-       this:delete()
-       return true
-end
-
-local function showconfirm_reset(tabview)
-       local new_dlg = dialog_create("reset_spworld",
-               dlg_confirm_reset_formspec,
-               dlg_confirm_reset_btnhandler,
-               nil)
-       new_dlg:set_parent(tabview)
-       tabview:hide()
-       new_dlg:show()
-end
-
-local function gui_scale_to_scrollbar()
-       local current_value = tonumber(core.setting_get("gui_scaling"))
-
-       if (current_value == nil) or current_value < 0.25 then
-               return 0
-       end
-       if current_value <= 1.25 then
-               return ((current_value - 0.25)/ 1.0) * 700
-       end
-       if current_value <= 6 then
-               return ((current_value -1.25) * 100) + 700
-       end
-
-       return 1000
-end
-
-local function scrollbar_to_gui_scale(value)
-       value = tonumber(value)
-
-       if (value <= 700) then
-               return ((value / 700) * 1.0) + 0.25
-       end
-       if (value <= 1000) then
-               return ((value - 700) / 100) + 1.25
-       end
-
-       return 1
-end
-
-local function viewing_range_min_to_scrollbar()
-       local current_value_min = tonumber(core.setting_get("viewing_range_nodes_min"))
-
-       if (current_value_min == nil) then
-               return 0
-       end
-       return current_value_min * 2
-end
-
-local function viewing_range_max_to_scrollbar()
-       local current_value_max = tonumber(core.setting_get("viewing_range_nodes_max"))
-
-       if (current_value_max == nil) then
-               return 0
-       end
-       return current_value_max * 2
-end
-
-local function scrollbar_to_viewing_range(value)
-       value = tonumber(value)
-
-       if (value <= 1000) then
-               return value / 2
+local function antialiasing_fname_to_name(fname)
+       for i = 1, #labels.antialiasing do
+               if fname == labels.antialiasing[i] then
+                       return dd_options.antialiasing[2][i]
+               end
        end
-       return 35
+       return 0
 end
 
 local function formspec(tabview, name, tabdata)
        local tab_string =
-               "box[0,0;3.5,4.0;#999999]" ..
-               "checkbox[0.25,0;cb_smooth_lighting;".. fgettext("Smooth Lighting")
-                               .. ";".. dump(core.setting_getbool("smooth_lighting")) .. "]"..
-               "checkbox[0.25,0.5;cb_particles;".. fgettext("Enable Particles") .. ";"
-                               .. dump(core.setting_getbool("enable_particles"))       .. "]"..
-               "checkbox[0.25,1;cb_3d_clouds;".. fgettext("3D Clouds") .. ";"
-                               .. dump(core.setting_getbool("enable_3d_clouds")) .. "]"..
-               "checkbox[0.25,1.5;cb_opaque_water;".. fgettext("Opaque Water") .. ";"
-                               .. dump(core.setting_getbool("opaque_water")) .. "]"..
-               "checkbox[0.25,2.0;cb_connected_glass;".. fgettext("Connected Glass") .. ";"
-                               .. dump(core.setting_getbool("connected_glass"))        .. "]"..
-               "checkbox[0.25,2.5;cb_node_highlighting;".. fgettext("Node Highlighting") .. ";"
-                               .. dump(core.setting_getbool("enable_node_highlighting")) .. "]"..
-               "dropdown[0.25,3.2;3.3;dd_leaves_style;" .. leaves_style[1][1] .. ";"
-                               .. getLeavesStyleSettingIndex() .. "]" ..
-               "box[3.75,0;3.75,3.45;#999999]" ..
-               "label[3.85,0.1;".. fgettext("Texturing:") .. "]"..
-               "dropdown[3.85,0.55;3.85;dd_filters;" .. filters[1][1] .. ";"
-                               .. getFilterSettingIndex() .. "]" ..
-               "dropdown[3.85,1.35;3.85;dd_mipmap;" .. mipmap[1][1] .. ";"
-                               .. getMipmapSettingIndex() .. "]" ..
-               "label[3.85,2.15;".. fgettext("Antialiasing:") .. "]"..
-               "dropdown[3.85,2.6;3.85;dd_antialiasing;" .. antialiasing[1][1] .. ";"
-                               .. getAntialiasingSettingIndex() .. "]" ..
-               "box[7.75,0;4,4;#999999]" ..
-               "checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";"
-                               .. dump(core.setting_getbool("enable_shaders")) .. "]"
-
-       if PLATFORM ~= "Android" then
+               "box[0,0;3.75,4.5;#999999]" ..
+               "checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
+                               .. dump(core.settings:get_bool("smooth_lighting")) .. "]" ..
+               "checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";"
+                               .. dump(core.settings:get_bool("enable_particles")) .. "]" ..
+               "checkbox[0.25,1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";"
+                               .. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" ..
+               "checkbox[0.25,1.5;cb_opaque_water;" .. fgettext("Opaque Water") .. ";"
+                               .. dump(core.settings:get_bool("opaque_water")) .. "]" ..
+               "checkbox[0.25,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";"
+                               .. dump(core.settings:get_bool("connected_glass")) .. "]" ..
+               "dropdown[0.25,2.8;3.5;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
+                               .. getSettingIndex.NodeHighlighting() .. "]" ..
+               "dropdown[0.25,3.6;3.5;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
+                               .. getSettingIndex.Leaves() .. "]" ..
+               "box[4,0;3.75,4.5;#999999]" ..
+               "label[4.25,0.1;" .. fgettext("Texturing:") .. "]" ..
+               "dropdown[4.25,0.55;3.5;dd_filters;" .. dd_options.filters[1] .. ";"
+                               .. getSettingIndex.Filter() .. "]" ..
+               "dropdown[4.25,1.35;3.5;dd_mipmap;" .. dd_options.mipmap[1] .. ";"
+                               .. getSettingIndex.Mipmap() .. "]" ..
+               "label[4.25,2.15;" .. fgettext("Antialiasing:") .. "]" ..
+               "dropdown[4.25,2.6;3.5;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";"
+                               .. getSettingIndex.Antialiasing() .. "]" ..
+               "label[4.25,3.45;" .. fgettext("Screen:") .. "]" ..
+               "checkbox[4.25,3.6;cb_autosave_screensize;" .. fgettext("Autosave Screen Size") .. ";"
+                               .. dump(core.settings:get_bool("autosave_screensize")) .. "]" ..
+               "box[8,0;3.75,4.5;#999999]"
+
+       local video_driver = core.settings:get("video_driver")
+       local shaders_enabled = core.settings:get_bool("enable_shaders")
+       if video_driver == "opengl" then
+               tab_string = tab_string ..
+                       "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders") .. ";"
+                                       .. tostring(shaders_enabled) .. "]"
+       elseif video_driver == "ogles2" then
                tab_string = tab_string ..
-               "button[8,4.75;3.75,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
+                       "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders (experimental)") .. ";"
+                                       .. tostring(shaders_enabled) .. "]"
        else
+               core.settings:set_bool("enable_shaders", false)
+               shaders_enabled = false
                tab_string = tab_string ..
-               "button[8,4.75;3.75,0.5;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]"
+                       "label[8.38,0.2;" .. core.colorize("#888888",
+                                       fgettext("Shaders (unavailable)")) .. "]"
        end
+
        tab_string = tab_string ..
-               "box[0,4.25;3.5,1.1;#999999]" ..
-               "label[0.25,4.25;" .. fgettext("GUI scale factor") .. "]" ..
-               "scrollbar[0.25,4.75;3,0.4;sb_gui_scaling;horizontal;" ..
-                               gui_scale_to_scrollbar() .. "]" ..
-               "tooltip[sb_gui_scaling;" ..
-                       fgettext("Scaling factor applied to menu elements: ") ..
-                       dump(core.setting_get("gui_scaling")) .. "]"
+               "button[8,4.75;3.95,1;btn_change_keys;"
+               .. fgettext("Change Keys") .. "]"
 
-       if PLATFORM == "Android" then
-               tab_string = tab_string ..
-               "box[3.75,3.55;3.75,1.8;#999999]" ..
-               "checkbox[3.9,3.45;cb_touchscreen_target;".. fgettext("Touch free target") .. ";"
-                               .. dump(core.setting_getbool("touchtarget")) .. "]"
-       end
+       tab_string = tab_string ..
+               "button[0,4.75;3.95,1;btn_advanced_settings;"
+               .. fgettext("All Settings") .. "]"
 
-       if core.setting_get("touchscreen_threshold") ~= nil then
-               tab_string = tab_string ..
-                               "label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" ..
-                               "dropdown[3.85,4.55;3.85;dd_touchthreshold;0,10,20,30,40,50;" ..
-                               ((tonumber(core.setting_get("touchscreen_threshold"))/10)+1) .. "]"
-       end
 
-       if core.setting_getbool("enable_shaders") then
-               tab_string = tab_string ..
-                               "checkbox[8,0.5;cb_bumpmapping;".. fgettext("Bumpmapping") .. ";"
-                                               .. dump(core.setting_getbool("enable_bumpmapping")) .. "]"..
-                               "checkbox[8,1.0;cb_generate_normalmaps;".. fgettext("Generate Normalmaps") .. ";"
-                                               .. dump(core.setting_getbool("generate_normalmaps")) .. "]"..
-                               "checkbox[8,1.5;cb_parallax;".. fgettext("Parallax Occlusion") .. ";"
-                                               .. dump(core.setting_getbool("enable_parallax_occlusion")) .. "]"..
-                               "checkbox[8,2.0;cb_waving_water;".. fgettext("Waving Water") .. ";"
-                                               .. dump(core.setting_getbool("enable_waving_water")) .. "]"..
-                               "checkbox[8,2.5;cb_waving_leaves;".. fgettext("Waving Leaves") .. ";"
-                                               .. dump(core.setting_getbool("enable_waving_leaves")) .. "]"..
-                               "checkbox[8,3.0;cb_waving_plants;".. fgettext("Waving Plants") .. ";"
-                                               .. dump(core.setting_getbool("enable_waving_plants")) .. "]"
-       else
+       if core.settings:get("touchscreen_threshold") ~= nil then
                tab_string = tab_string ..
-                               "textlist[8.33,0.7;4,1;;#888888" .. fgettext("Bumpmapping") .. ";0;true]" ..
-                               "textlist[8.33,1.2;4,1;;#888888" .. fgettext("Generate Normalmaps") .. ";0;true]" ..
-                               "textlist[8.33,1.7;4,1;;#888888" .. fgettext("Parallax Occlusion") .. ";0;true]" ..
-                               "textlist[8.33,2.2;4,1;;#888888" .. fgettext("Waving Water") .. ";0;true]" ..
-                               "textlist[8.33,2.7;4,1;;#888888" .. fgettext("Waving Leaves") .. ";0;true]" ..
-                               "textlist[8.33,3.2;4,1;;#888888" .. fgettext("Waving Plants") .. ";0;true]"
+                       "label[4.3,4.2;" .. fgettext("Touchthreshold: (px)") .. "]" ..
+                       "dropdown[4.25,4.65;3.5;dd_touchthreshold;0,10,20,30,40,50;" ..
+                       ((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) ..
+                       "]box[4.0,4.5;3.75,1.0;#999999]"
        end
 
-       local get_vrange_min = core.setting_get("viewing_range_nodes_min")
-       local get_vrange_max = core.setting_get("viewing_range_nodes_max")
-
-       if core.setting_getbool("viewing_range_auto") then
+       if shaders_enabled then
                tab_string = tab_string ..
-                       "box[3.75,3.5;3.75,2;#999999]" ..
-                       "label[3.85,3.5;" .. fgettext("Viewing Range :") .. "]" ..
-                       "label[3.85,4;" .. fgettext("Min.") .. "]" ..
-                       "scrollbar[4.65,4.05;2.75,0.4;sb_viewing_range_min;horizontal;" ..
-                               viewing_range_min_to_scrollbar() .. "]" ..
-                       "tooltip[sb_viewing_range_min;" .. fgettext("Minimal Viewing Range: $1 nodes",
-                               get_vrange_min) .. "]" ..
-                       "checkbox[3.85,4.8;cb_vrange_auto_adjust;" .. fgettext("Auto-adjust") .. ";" ..
-                               dump(core.setting_getbool("viewing_range_auto")) .. "]"..
-                       "label[3.85,4.5;" .. fgettext("Max.") .. "]" ..
-                       "scrollbar[4.65,4.55;2.75,0.4;sb_viewing_range_max;horizontal;" ..
-                               viewing_range_max_to_scrollbar() .. "]" ..
-                       "tooltip[sb_viewing_range_max;" .. fgettext("Maximal Viewing Range: $1 nodes",
-                               get_vrange_max) .. "]"
-
-               if (get_vrange_min == nil and get_vrange_min > get_vrange_max) then
-                       core.setting_set("viewing_range_nodes_min", get_vrange_max)
-               end
-       elseif (core.setting_getbool("viewing_range_auto") == nil or
-                       core.setting_getbool("viewing_range_auto") == false) then
+                       "checkbox[8.25,0.5;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
+                                       .. dump(core.settings:get_bool("tone_mapping")) .. "]" ..
+                       "checkbox[8.25,1;cb_waving_water;" .. fgettext("Waving Liquids") .. ";"
+                                       .. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
+                       "checkbox[8.25,1.5;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
+                                       .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
+                       "checkbox[8.25,2;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
+                                       .. dump(core.settings:get_bool("enable_waving_plants")) .. "]"
+                       --"label[8.25,3.0;" .. fgettext("Dynamic shadows: ") .. "]" ..
+                       --"dropdown[8.25,3.5;3.5;dd_shadows;" .. dd_options.shadow_levels[1] .. ";"
+                       --              .. getSettingIndex.ShadowMapping() .. "]"
+       else
                tab_string = tab_string ..
-                       "box[3.75,3.5;3.75,1.5;#999999]" ..
-                       "label[3.85,3.5;" .. fgettext("Viewing Range :") .. "]" ..
-                       "label[3.85,4;" .. fgettext("Fixed") .. "]" ..
-                       "scrollbar[4.65,4.05;2.75,0.4;sb_viewing_range_fixed;horizontal;" ..
-                               viewing_range_min_to_scrollbar() .. "]" ..
-                       "tooltip[sb_viewing_range_fixed;" .. fgettext("Fixed Viewing Range: $1 nodes",
-                               get_vrange_min) .. "]" ..
-                       "checkbox[3.85,4.3;cb_vrange_auto_adjust;" .. fgettext("Auto-adjust") .. ";" ..
-                               dump(core.setting_getbool("viewing_range_auto")) .. "]"
+                       "label[8.38,0.7;" .. core.colorize("#888888",
+                                       fgettext("Tone Mapping")) .. "]" ..
+                       "label[8.38,1.2;" .. core.colorize("#888888",
+                                       fgettext("Waving Liquids")) .. "]" ..
+                       "label[8.38,1.7;" .. core.colorize("#888888",
+                                       fgettext("Waving Leaves")) .. "]" ..
+                       "label[8.38,2.2;" .. core.colorize("#888888",
+                                       fgettext("Waving Plants")) .. "]"
+                       --"label[8.38,2.7;" .. core.colorize("#888888",
+                       --              fgettext("Dynamic shadows")) .. "]"
        end
 
        return tab_string
@@ -352,158 +241,150 @@ end
 
 --------------------------------------------------------------------------------
 local function handle_settings_buttons(this, fields, tabname, tabdata)
+
+       if fields["btn_advanced_settings"] ~= nil then
+               local adv_settings_dlg = create_adv_settings_dlg()
+               adv_settings_dlg:set_parent(this)
+               this:hide()
+               adv_settings_dlg:show()
+               --mm_game_theme.update("singleplayer", current_game())
+               return true
+       end
        if fields["cb_smooth_lighting"] then
-               core.setting_set("smooth_lighting", fields["cb_smooth_lighting"])
+               core.settings:set("smooth_lighting", fields["cb_smooth_lighting"])
                return true
        end
        if fields["cb_particles"] then
-               core.setting_set("enable_particles", fields["cb_particles"])
+               core.settings:set("enable_particles", fields["cb_particles"])
                return true
        end
        if fields["cb_3d_clouds"] then
-               core.setting_set("enable_3d_clouds", fields["cb_3d_clouds"])
+               core.settings:set("enable_3d_clouds", fields["cb_3d_clouds"])
                return true
        end
        if fields["cb_opaque_water"] then
-               core.setting_set("opaque_water", fields["cb_opaque_water"])
+               core.settings:set("opaque_water", fields["cb_opaque_water"])
                return true
        end
        if fields["cb_connected_glass"] then
-               core.setting_set("connected_glass", fields["cb_connected_glass"])
+               core.settings:set("connected_glass", fields["cb_connected_glass"])
                return true
        end
-       if fields["cb_node_highlighting"] then
-               core.setting_set("enable_node_highlighting", fields["cb_node_highlighting"])
-               return true
-       end
-       if fields["cb_vrange_auto_adjust"] then
-               core.setting_set("viewing_range_auto", fields["cb_vrange_auto_adjust"])
+       if fields["cb_autosave_screensize"] then
+               core.settings:set("autosave_screensize", fields["cb_autosave_screensize"])
                return true
        end
        if fields["cb_shaders"] then
-               if (core.setting_get("video_driver") == "direct3d8"
-                               or core.setting_get("video_driver") == "direct3d9") then
-                       core.setting_set("enable_shaders", "false")
-                       gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
-               else
-                       core.setting_set("enable_shaders", fields["cb_shaders"])
-               end
+               core.settings:set("enable_shaders", fields["cb_shaders"])
                return true
        end
-       if fields["cb_bumpmapping"] then
-               core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
-       end
-       if fields["cb_generate_normalmaps"] then
-               core.setting_set("generate_normalmaps", fields["cb_generate_normalmaps"])
-       end
-       if fields["cb_parallax"] then
-               core.setting_set("enable_parallax_occlusion", fields["cb_parallax"])
+       if fields["cb_tonemapping"] then
+               core.settings:set("tone_mapping", fields["cb_tonemapping"])
                return true
        end
        if fields["cb_waving_water"] then
-               core.setting_set("enable_waving_water", fields["cb_waving_water"])
+               core.settings:set("enable_waving_water", fields["cb_waving_water"])
                return true
        end
        if fields["cb_waving_leaves"] then
-               core.setting_set("enable_waving_leaves", fields["cb_waving_leaves"])
+               core.settings:set("enable_waving_leaves", fields["cb_waving_leaves"])
        end
        if fields["cb_waving_plants"] then
-               core.setting_set("enable_waving_plants", fields["cb_waving_plants"])
+               core.settings:set("enable_waving_plants", fields["cb_waving_plants"])
                return true
        end
-
-       if fields["sb_gui_scaling"] then
-               local event = core.explode_scrollbar_event(fields["sb_gui_scaling"])
-
-               if event.type == "CHG" then
-                       local tosave = string.format("%.2f",scrollbar_to_gui_scale(event.value))
-                       core.setting_set("gui_scaling",tosave)
-                       return true
-               end
-       end
-
-       for k, range in pairs({"min", "max", "fixed"}) do
-               if fields["sb_viewing_range_"..range] then
-                       local event = core.explode_scrollbar_event(fields["sb_viewing_range_"..range])
-                       local tosave = string.format("%d", scrollbar_to_viewing_range(event.value))
-
-                       if event.type == "CHG" and k < 3 then
-                               core.setting_set("viewing_range_nodes_"..range, tosave)
-                               return true
-                       elseif event.type == "CHG" and k == 3 then
-                               core.setting_set("viewing_range_nodes_min", tosave)
-                               core.setting_set("viewing_range_nodes_max", tosave)
-                               return true
-                       end
-               end
-       end
-
        if fields["btn_change_keys"] then
                core.show_keys_menu()
                return true
        end
        if fields["cb_touchscreen_target"] then
-               core.setting_set("touchtarget", fields["cb_touchscreen_target"])
-               return true
-       end
-       if fields["btn_reset_singleplayer"] then
-               showconfirm_reset(this)
+               core.settings:set("touchtarget", fields["cb_touchscreen_target"])
                return true
        end
 
        --Note dropdowns have to be handled LAST!
        local ddhandled = false
 
-       if fields["dd_leaves_style"] == leaves_style_labels[1] then
-               core.setting_set("leaves_style", leaves_style[2][1])
-               ddhandled = true
-       elseif fields["dd_leaves_style"] == leaves_style_labels[2] then
-               core.setting_set("leaves_style", leaves_style[2][2])
-               ddhandled = true
-       elseif fields["dd_leaves_style"] == leaves_style_labels[3] then
-               core.setting_set("leaves_style", leaves_style[2][3])
-               ddhandled = true
+       for i = 1, #labels.leaves do
+               if fields["dd_leaves_style"] == labels.leaves[i] then
+                       core.settings:set("leaves_style", dd_options.leaves[2][i])
+                       ddhandled = true
+               end
+       end
+       for i = 1, #labels.node_highlighting do
+               if fields["dd_node_highlighting"] == labels.node_highlighting[i] then
+                       core.settings:set("node_highlighting", dd_options.node_highlighting[2][i])
+                       ddhandled = true
+               end
        end
-       if fields["dd_filters"] == dd_filter_labels[1] then
-               core.setting_set("bilinear_filter", "false")
-               core.setting_set("trilinear_filter", "false")
+       if fields["dd_filters"] == labels.filters[1] then
+               core.settings:set("bilinear_filter", "false")
+               core.settings:set("trilinear_filter", "false")
                ddhandled = true
-       elseif fields["dd_filters"] == dd_filter_labels[2] then
-               core.setting_set("bilinear_filter", "true")
-               core.setting_set("trilinear_filter", "false")
+       elseif fields["dd_filters"] == labels.filters[2] then
+               core.settings:set("bilinear_filter", "true")
+               core.settings:set("trilinear_filter", "false")
                ddhandled = true
-       elseif fields["dd_filters"] == dd_filter_labels[3] then
-               core.setting_set("bilinear_filter", "false")
-               core.setting_set("trilinear_filter", "true")
+       elseif fields["dd_filters"] == labels.filters[3] then
+               core.settings:set("bilinear_filter", "false")
+               core.settings:set("trilinear_filter", "true")
                ddhandled = true
        end
-       if fields["dd_mipmap"] == dd_mipmap_labels[1] then
-               core.setting_set("mip_map", "false")
-               core.setting_set("anisotropic_filter", "false")
+       if fields["dd_mipmap"] == labels.mipmap[1] then
+               core.settings:set("mip_map", "false")
+               core.settings:set("anisotropic_filter", "false")
                ddhandled = true
-       elseif fields["dd_mipmap"] == dd_mipmap_labels[2] then
-               core.setting_set("mip_map", "true")
-               core.setting_set("anisotropic_filter", "false")
+       elseif fields["dd_mipmap"] == labels.mipmap[2] then
+               core.settings:set("mip_map", "true")
+               core.settings:set("anisotropic_filter", "false")
                ddhandled = true
-       elseif fields["dd_mipmap"] == dd_mipmap_labels[3] then
-               core.setting_set("mip_map", "true")
-               core.setting_set("anisotropic_filter", "true")
+       elseif fields["dd_mipmap"] == labels.mipmap[3] then
+               core.settings:set("mip_map", "true")
+               core.settings:set("anisotropic_filter", "true")
                ddhandled = true
        end
        if fields["dd_antialiasing"] then
-               core.setting_set("fsaa",
+               core.settings:set("fsaa",
                        antialiasing_fname_to_name(fields["dd_antialiasing"]))
                ddhandled = true
        end
        if fields["dd_touchthreshold"] then
-               core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"])
+               core.settings:set("touchscreen_threshold", fields["dd_touchthreshold"])
                ddhandled = true
        end
 
+       for i = 1, #labels.shadow_levels do
+               if fields["dd_shadows"] == labels.shadow_levels[i] then
+                       core.settings:set("shadow_levels", dd_options.shadow_levels[2][i])
+                       ddhandled = true
+               end
+       end
+
+       if fields["dd_shadows"] == labels.shadow_levels[1] then
+               core.settings:set("enable_dynamic_shadows", "false")
+       else
+               local shadow_presets = {
+                       [2] = { 80,  512,  "true", 0, "false" },
+                       [3] = { 120, 1024, "true", 1, "false" },
+                       [4] = { 350, 2048, "true", 1, "false" },
+                       [5] = { 350, 2048, "true", 2,  "true" },
+                       [6] = { 450, 4096, "true", 2,  "true" },
+               }
+               local s = shadow_presets[table.indexof(labels.shadow_levels, fields["dd_shadows"])]
+               if s then
+                       core.settings:set("enable_dynamic_shadows", "true")
+                       core.settings:set("shadow_map_max_distance", s[1])
+                       core.settings:set("shadow_map_texture_size", s[2])
+                       core.settings:set("shadow_map_texture_32bit", s[3])
+                       core.settings:set("shadow_filters", s[4])
+                       core.settings:set("shadow_map_color", s[5])
+               end
+       end
+
        return ddhandled
 end
 
-tab_settings = {
+return {
        name = "settings",
        caption = fgettext("Settings"),
        cbf_formspec = formspec,