aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/tab_singleplayer.lua
diff options
context:
space:
mode:
authorjeanpatrick.guerrero@gmail.com <jeanpatrick.guerrero@gmail.com>2015-06-29 15:41:05 +0200
committerest31 <MTest31@outlook.com>2015-06-30 18:11:38 +0200
commit85f3d575ec3d99ef2ce680d4a2546e4d31327d83 (patch)
treedd67dd7c312cc05351e31082534efb204325e7d5 /builtin/mainmenu/tab_singleplayer.lua
parent91f95fd4df82645e23a9734795d11ec9b8e522f8 (diff)
downloadminetest-85f3d575ec3d99ef2ce680d4a2546e4d31327d83.tar.gz
minetest-85f3d575ec3d99ef2ce680d4a2546e4d31327d83.tar.bz2
minetest-85f3d575ec3d99ef2ce680d4a2546e4d31327d83.zip
Fix bugs in mainmenu
Diffstat (limited to 'builtin/mainmenu/tab_singleplayer.lua')
-rw-r--r--builtin/mainmenu/tab_singleplayer.lua47
1 files changed, 6 insertions, 41 deletions
diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua
index c2b850e44..916b0c188 100644
--- a/builtin/mainmenu/tab_singleplayer.lua
+++ b/builtin/mainmenu/tab_singleplayer.lua
@@ -23,9 +23,9 @@ local function current_game()
end
local function singleplayer_refresh_gamebar()
-
+
local old_bar = ui.find_by_name("game_button_bar")
-
+
if old_bar ~= nil then
old_bar:delete()
end
@@ -76,7 +76,7 @@ end
local function get_formspec(tabview, name, tabdata)
local retval = ""
-
+
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.setting_get("mainmenu_last_selected_world"))
)
@@ -105,32 +105,9 @@ local function main_button_handler(this, fields, name, tabdata)
if fields["sp_worlds"] ~= nil then
local event = core.explode_textlist_event(fields["sp_worlds"])
-
local selected = core.get_textlist_index("sp_worlds")
- if selected ~= nil then
- local filename = menudata.worldlist:get_list()[selected].path
- local worldconfig = modmgr.get_worldconfig(filename)
- filename = filename .. DIR_DELIM .. "world.mt"
- if worldconfig.creative_mode ~= nil then
- core.setting_set("creative_mode", worldconfig.creative_mode)
- else
- local worldfile = Settings(filename)
- worldfile:set("creative_mode", core.setting_get("creative_mode"))
- if not worldfile:write() then
- core.log("error", "Failed to write world config file")
- end
- end
- if worldconfig.enable_damage ~= nil then
- core.setting_set("enable_damage", worldconfig.enable_damage)
- else
- local worldfile = Settings(filename)
- worldfile:set("enable_damage", core.setting_get("enable_damage"))
- if not worldfile:write() then
- core.log("error", "Failed to write world config file")
- end
- end
- end
+ menu_worldmt_legacy()
if event.type == "DCL" then
world_doubleclick = true
@@ -150,28 +127,16 @@ local function main_button_handler(this, fields, name, tabdata)
if fields["cb_creative_mode"] then
core.setting_set("creative_mode", fields["cb_creative_mode"])
local selected = core.get_textlist_index("sp_worlds")
- local filename = menudata.worldlist:get_list()[selected].path ..
- DIR_DELIM .. "world.mt"
+ menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
- local worldfile = Settings(filename)
- worldfile:set("creative_mode", fields["cb_creative_mode"])
- if not worldfile:write() then
- core.log("error", "Failed to write world config file")
- end
return true
end
if fields["cb_enable_damage"] then
core.setting_set("enable_damage", fields["cb_enable_damage"])
local selected = core.get_textlist_index("sp_worlds")
- local filename = menudata.worldlist:get_list()[selected].path ..
- DIR_DELIM .. "world.mt"
+ menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
- local worldfile = Settings(filename)
- worldfile:set("enable_damage", fields["cb_enable_damage"])
- if not worldfile:write() then
- core.log("error", "Failed to write world config file")
- end
return true
end