Add configurable key bindings for hotbar scrolling, and for changing volume.
[oweals/minetest.git] / builtin / mainmenu / tab_settings.lua
index 0ad23062f194b565643c27ce936d57dde2c34064..8a97d8334923a0ae3e026593ddd4c8da11a273ba 100644 (file)
 
 --------------------------------------------------------------------------------
 
+local labels = {
+       leaves = {
+               fgettext("Opaque Leaves"),
+               fgettext("Simple Leaves"),
+               fgettext("Fancy Leaves")
+       },
+       node_highlighting = {
+               fgettext("Node Outlining"),
+               fgettext("Node Highlighting")
+       },
+       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")
+       }
+}
+
+local dd_options = {
+       leaves = {
+               table.concat(labels.leaves, ","),
+               {"opaque", "simple", "fancy"}
+       },
+       node_highlighting = {
+               table.concat(labels.node_highlighting, ","),
+               {"box", "halo"}
+       },
+       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"}
+       }
+}
+
+local getSettingIndex = {
+       Leaves = function()
+               local style = core.setting_get("leaves_style")
+               for idx, name in pairs(dd_options.leaves[2]) do
+                       if style == name then return idx end
+               end
+               return 1
+       end,
+       NodeHighlighting = function()
+               local style = core.setting_get("node_highlighting")
+               for idx, name in pairs(dd_options.node_highlighting[2]) do
+                       if style == name then return idx end
+               end
+               return 1
+       end,
+       Filter = function()
+               if core.setting_get(dd_options.filters[2][3]) == "true" then
+                       return 3
+               elseif core.setting_get(dd_options.filters[2][3]) == "false" and
+                               core.setting_get(dd_options.filters[2][2]) == "true" then
+                       return 2
+               end
+               return 1
+       end,
+       Mipmap = function()
+               if core.setting_get(dd_options.mipmap[2][3]) == "true" then
+                       return 3
+               elseif core.setting_get(dd_options.mipmap[2][3]) == "false" and
+                               core.setting_get(dd_options.mipmap[2][2]) == "true" then
+                       return 2
+               end
+               return 1
+       end,
+       Antialiasing = function()
+               local antialiasing_setting = core.setting_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
+}
+
+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 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
+       return  "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") .. "]"
 end
 
 local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
@@ -34,7 +134,7 @@ local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
                local worldlist = core.get_worlds()
                local found_singleplayerworld = false
 
-               for i=1,#worldlist,1 do
+               for i = 1, #worldlist do
                        if worldlist[i].name == "singleplayerworld" then
                                found_singleplayerworld = true
                                gamedata.worldindex = i
@@ -46,12 +146,10 @@ local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
                end
 
                core.create_world("singleplayerworld", 1)
-
                worldlist = core.get_worlds()
-
                found_singleplayerworld = false
 
-               for i=1,#worldlist,1 do
+               for i = 1, #worldlist do
                        if worldlist[i].name == "singleplayerworld" then
                                found_singleplayerworld = true
                                gamedata.worldindex = i
@@ -75,172 +173,90 @@ local function showconfirm_reset(tabview)
        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 formspec(tabview, name, tabdata)
-       local video_drivers = core.get_video_drivers()
-       
-       local video_driver_string = ""
-       local current_video_driver_idx = 0
-       local current_video_driver = core.setting_get("video_driver")
-       for i=1, #video_drivers, 1 do
-
-               if i ~= 1 then
-                       video_driver_string = video_driver_string .. ","
-               end
-               video_driver_string = video_driver_string .. video_drivers[i]
-
-               local video_driver = string.gsub(video_drivers[i], " ", "")
-               if current_video_driver:lower() == video_driver:lower() then
-                       current_video_driver_idx = i
-               end
-       end
-
-       local filters = {
-               {"No Filter,Bilinear Filter,Trilinear Filter"},
-               {"", "bilinear_filter", "trilinear_filter"},
-       }
-
-       local mipmap = {
-               {"No Mipmap,Mipmap,Mipmap + Aniso. Filter"},
-               {"", "mip_map", "anisotropic_filter"},
-       }
-
-       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 tab_string =
-               "box[0,0;3.5,3.9;#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_fancy_trees;".. fgettext("Fancy Trees") .. ";"
-                               .. dump(core.setting_getbool("new_style_leaves")) .. "]"..
-               "checkbox[0.25,2.0;cb_opaque_water;".. fgettext("Opaque Water") .. ";"
-                               .. dump(core.setting_getbool("opaque_water")) .. "]"..
-               "checkbox[0.25,2.5;cb_connected_glass;".. fgettext("Connected Glass") .. ";"
-                               .. dump(core.setting_getbool("connected_glass"))        .. "]"..
-               "checkbox[0.25,3.0;cb_node_highlighting;".. fgettext("Node Highlighting") .. ";"
-                               .. dump(core.setting_getbool("enable_node_highlighting")) .. "]"..
-               "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("Rendering:") .. "]"..
-               "dropdown[3.85,2.6;3.85;dd_video_driver;"
-                               .. video_driver_string .. ";" .. current_video_driver_idx .. "]" ..
-               "tooltip[dd_video_driver;" ..
-                               fgettext("Restart minetest for driver change to take effect") .. "]" ..
-               "box[7.75,0;4,4;#999999]" ..
-               "checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";"
+               "box[0,0;3.5,4.5;#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("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")) .. "]" ..
+               "dropdown[0.25,2.8;3.3;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
+                               .. getSettingIndex.NodeHighlighting() .. "]" ..
+               "dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
+                               .. getSettingIndex.Leaves() .. "]" ..
+               "box[3.75,0;3.75,4.45;#999999]" ..
+               "label[3.85,0.1;" .. fgettext("Texturing:") .. "]" ..
+               "dropdown[3.85,0.55;3.85;dd_filters;" .. dd_options.filters[1] .. ";"
+                               .. getSettingIndex.Filter() .. "]" ..
+               "dropdown[3.85,1.35;3.85;dd_mipmap;" .. dd_options.mipmap[1] .. ";"
+                               .. getSettingIndex.Mipmap() .. "]" ..
+               "label[3.85,2.15;" .. fgettext("Antialiasing:") .. "]" ..
+               "dropdown[3.85,2.6;3.85;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";"
+                               .. getSettingIndex.Antialiasing() .. "]" ..
+               "label[3.85,3.45;" .. fgettext("Screen:") .. "]" ..
+               "checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";"
+                               .. dump(core.setting_getbool("autosave_screensize")) .. "]" ..
+               "box[7.75,0;4,4.4;#999999]" ..
+               "checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";"
                                .. dump(core.setting_getbool("enable_shaders")) .. "]"
 
-       if PLATFORM ~= "Android" then
+       if PLATFORM == "Android" then
                tab_string = tab_string ..
-               "button[8,4.75;3.75,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
+                       "button[8,4.75;3.75,0.5;btn_reset_singleplayer;"
+                       .. fgettext("Reset singleplayer world") .. "]"
        else
                tab_string = tab_string ..
-               "button[8,4.75;3.75,0.5;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]"
+                       "button[8,4.85;3.75,0.5;btn_change_keys;"
+                       .. fgettext("Change keys") .. "]"
        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[0,4.85;3.75,0.5;btn_advanced_settings;"
+               .. fgettext("Advanced Settings") .. "]"
 
-       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
 
        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) .. "]"
+                       "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")) .. "]"
+                       "checkbox[8,0.5;cb_bumpmapping;" .. fgettext("Bump Mapping") .. ";"
+                                       .. dump(core.setting_getbool("enable_bumpmapping")) .. "]" ..
+                       "checkbox[8,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
+                                       .. dump(core.setting_getbool("tone_mapping")) .. "]" ..
+                       "checkbox[8,1.5;cb_generate_normalmaps;" .. fgettext("Normal Mapping") .. ";"
+                                       .. dump(core.setting_getbool("generate_normalmaps")) .. "]" ..
+                       "checkbox[8,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
+                                       .. dump(core.setting_getbool("enable_parallax_occlusion")) .. "]" ..
+                       "checkbox[8,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";"
+                                       .. dump(core.setting_getbool("enable_waving_water")) .. "]" ..
+                       "checkbox[8,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
+                                       .. dump(core.setting_getbool("enable_waving_leaves")) .. "]" ..
+                       "checkbox[8,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
+                                       .. dump(core.setting_getbool("enable_waving_plants")) .. "]"
        else
                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]"
+                       "tablecolumns[color;text]" ..
+                       "tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
+                       "table[8.33,0.7;3.5,4;shaders;" ..
+                               "#888888," .. fgettext("Bump Mapping") .. "," ..
+                               "#888888," .. fgettext("Tone Mapping") .. "," ..
+                               "#888888," .. fgettext("Normal Mapping") .. "," ..
+                               "#888888," .. fgettext("Parallax Occlusion") .. "," ..
+                               "#888888," .. fgettext("Waving Water") .. "," ..
+                               "#888888," .. fgettext("Waving Leaves") .. "," ..
+                               "#888888," .. fgettext("Waving Plants") .. "," ..
+                               ";1]"
        end
 
        return tab_string
@@ -248,14 +264,23 @@ end
 
 --------------------------------------------------------------------------------
 local function handle_settings_buttons(this, fields, tabname, tabdata)
-       if fields["cb_fancy_trees"] then
-               core.setting_set("new_style_leaves", fields["cb_fancy_trees"])
+
+       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_texture.update("singleplayer", current_game())
                return true
        end
        if fields["cb_smooth_lighting"] then
                core.setting_set("smooth_lighting", fields["cb_smooth_lighting"])
                return true
        end
+       if fields["cb_particles"] then
+               core.setting_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"])
                return true
@@ -264,8 +289,17 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
                core.setting_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"])
+               return true
+       end
+       if fields["cb_autosave_screensize"] then
+               core.setting_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
+               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
@@ -273,23 +307,17 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
                end
                return true
        end
-       if fields["cb_connected_glass"] then
-               core.setting_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"])
+       if fields["cb_bumpmapping"] then
+               core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
                return true
        end
-       if fields["cb_particles"] then
-               core.setting_set("enable_particles", fields["cb_particles"])
+       if fields["cb_tonemapping"] then
+               core.setting_set("tone_mapping", fields["cb_tonemapping"])
                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"])
+               return true
        end
        if fields["cb_parallax"] then
                core.setting_set("enable_parallax_occlusion", fields["cb_parallax"])
@@ -306,20 +334,10 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
                core.setting_set("enable_waving_plants", fields["cb_waving_plants"])
                return true
        end
-       if fields["btn_change_keys"] ~= nil then
+       if fields["btn_change_keys"] then
                core.show_keys_menu()
                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
        if fields["cb_touchscreen_target"] then
                core.setting_set("touchtarget", fields["cb_touchscreen_target"])
                return true
@@ -332,52 +350,60 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
        --Note dropdowns have to be handled LAST!
        local ddhandled = false
 
-       if fields["dd_touchthreshold"] then
-               core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"])
-               ddhandled = true
+       for i = 1, #labels.leaves do
+               if fields["dd_leaves_style"] == labels.leaves[i] then
+                       core.setting_set("leaves_style", dd_options.leaves[2][i])
+                       ddhandled = true
+               end
        end
-       if fields["dd_video_driver"] then
-               local video_driver = string.gsub(fields["dd_video_driver"], " ", "")
-               core.setting_set("video_driver",string.lower(video_driver))
-               ddhandled = true
+       for i = 1, #labels.node_highlighting do
+               if fields["dd_node_highlighting"] == labels.node_highlighting[i] then
+                       core.setting_set("node_highlighting", dd_options.node_highlighting[2][i])
+                       ddhandled = true
+               end
        end
-       if fields["dd_filters"] == "No Filter" then
+       if fields["dd_filters"] == labels.filters[1] then
                core.setting_set("bilinear_filter", "false")
                core.setting_set("trilinear_filter", "false")
                ddhandled = true
-       end
-       if fields["dd_filters"] == "Bilinear Filter" then
+       elseif fields["dd_filters"] == labels.filters[2] then
                core.setting_set("bilinear_filter", "true")
                core.setting_set("trilinear_filter", "false")
                ddhandled = true
-       end
-       if fields["dd_filters"] == "Trilinear Filter" then
+       elseif fields["dd_filters"] == labels.filters[3] then
                core.setting_set("bilinear_filter", "false")
                core.setting_set("trilinear_filter", "true")
                ddhandled = true
        end
-       if fields["dd_mipmap"] == "No Mipmap" then
+       if fields["dd_mipmap"] == labels.mipmap[1] then
                core.setting_set("mip_map", "false")
                core.setting_set("anisotropic_filter", "false")
                ddhandled = true
-       end
-       if fields["dd_mipmap"] == "Mipmap" then
+       elseif fields["dd_mipmap"] == labels.mipmap[2] then
                core.setting_set("mip_map", "true")
                core.setting_set("anisotropic_filter", "false")
                ddhandled = true
-       end
-       if fields["dd_mipmap"] == "Mipmap + Aniso. Filter" then
+       elseif fields["dd_mipmap"] == labels.mipmap[3] then
                core.setting_set("mip_map", "true")
                core.setting_set("anisotropic_filter", "true")
                ddhandled = true
        end
+       if fields["dd_antialiasing"] then
+               core.setting_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"])
+               ddhandled = true
+       end
 
        return ddhandled
 end
 
-tab_settings = {
+return {
        name = "settings",
        caption = fgettext("Settings"),
        cbf_formspec = formspec,
        cbf_button_handler = handle_settings_buttons
-       }
+}