Fix single click world select
authorest31 <MTest31@outlook.com>
Tue, 30 Jun 2015 17:58:06 +0000 (19:58 +0200)
committerest31 <MTest31@outlook.com>
Tue, 30 Jun 2015 18:09:29 +0000 (20:09 +0200)
builtin/mainmenu/common.lua
builtin/mainmenu/tab_server.lua
builtin/mainmenu/tab_singleplayer.lua

index bcb075f99842ff7765881a1f01a299f57f74b7bc..5cd16a9eab6ea9111e6307e4cf28b582bb19cfb6 100644 (file)
@@ -307,7 +307,7 @@ function menu_worldmt(selected, setting, value)
                local filename = world.path .. DIR_DELIM .. "world.mt"
                local world_conf = Settings(filename)
 
-               if value then
+               if value ~= nil then
                        if not world_conf:write() then
                                core.log("error", "Failed to write world config file")
                        end
@@ -320,14 +320,14 @@ function menu_worldmt(selected, setting, value)
        end
 end
 
-function menu_worldmt_legacy()
-       local modes = {"creative_mode", "enable_damage"}
-       for _, mode in pairs(modes) do
-               local mode = menu_worldmt(selected, ""..mode.."")
-               if mode then
-                       core.setting_set(""..mode.."", mode)
+function menu_worldmt_legacy(selected)
+       local modes_names = {"creative_mode", "enable_damage"}
+       for _, mode_name in pairs(modes_names) do
+               local mode_val = menu_worldmt(selected, mode_name)
+               if mode_val ~= nil then
+                       core.setting_set(mode_name, mode_val)
                else
-                       menu_worldmt(selected, ""..mode.."", core.setting_get(""..mode..""))
+                       menu_worldmt(selected, mode_name, core.setting_get(mode_name))
                end
        end
 end
index 2362d32a1ad7983274c601277d1dfb0654e9e74c..3459f3f2f56c11bc89a95106bd6d4773057bef1b 100644 (file)
@@ -69,7 +69,7 @@ local function main_button_handler(this, fields, name, tabdata)
                local event = core.explode_textlist_event(fields["srv_worlds"])
                local selected = core.get_textlist_index("srv_worlds")
 
-               menu_worldmt_legacy()
+               menu_worldmt_legacy(selected)
 
                if event.type == "DCL" then
                        world_doubleclick = true
index 916b0c1887b1249f85e694746f9d75d9f91aab7a..a7cf5120c2e86e1d1d6eda981808ef90190fce0d 100644 (file)
@@ -107,7 +107,7 @@ local function main_button_handler(this, fields, name, tabdata)
                local event = core.explode_textlist_event(fields["sp_worlds"])
                local selected = core.get_textlist_index("sp_worlds")
 
-               menu_worldmt_legacy()
+               menu_worldmt_legacy(selected)
 
                if event.type == "DCL" then
                        world_doubleclick = true