aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/dlg_config_world.lua
diff options
context:
space:
mode:
authorfz72 <fz72@gmx.de>2014-12-27 16:13:07 +0100
committerkwolekr <kwolekr@minetest.net>2014-12-28 23:20:51 -0500
commit86cfbc21da10e9984a1b9f8f2f5bf259fba5efb9 (patch)
tree4374229511b84c03caaf79c16ef2417fdbce89b3 /builtin/mainmenu/dlg_config_world.lua
parent91c00d29a53a944d910d2adb40c25188a37749ed (diff)
downloadminetest-86cfbc21da10e9984a1b9f8f2f5bf259fba5efb9.tar.gz
minetest-86cfbc21da10e9984a1b9f8f2f5bf259fba5efb9.tar.bz2
minetest-86cfbc21da10e9984a1b9f8f2f5bf259fba5efb9.zip
MainMenu: Save 'hide gamemods' and 'hide modpack contents' checkbox state (fixes #1960)
Diffstat (limited to 'builtin/mainmenu/dlg_config_world.lua')
-rw-r--r--builtin/mainmenu/dlg_config_world.lua56
1 files changed, 36 insertions, 20 deletions
diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua
index a459f0ff1..a15e4c11f 100644
--- a/builtin/mainmenu/dlg_config_world.lua
+++ b/builtin/mainmenu/dlg_config_world.lua
@@ -118,6 +118,7 @@ local function handle_buttons(this, fields)
if fields["world_config_modlist"] ~= nil then
local event = core.explode_textlist_event(fields["world_config_modlist"])
this.data.selected_mod = event.index
+ core.setting_set("world_config_selected_mod", event.index)
if event.type == "DCL" then
enable_mod(this)
@@ -151,21 +152,29 @@ local function handle_buttons(this, fields)
if current == nil then
current = {}
end
-
- if core.is_yes(fields["cb_hide_gamemods"]) then
- current.hide_game = true
- this.data.hide_gamemods = true
- else
- current.hide_game = false
- this.data.hide_gamemods = false
- end
- if core.is_yes(fields["cb_hide_mpcontent"]) then
- current.hide_modpackcontents = true
- this.data.hide_modpackcontents = true
- else
- current.hide_modpackcontents = false
- this.data.hide_modpackcontents = false
+ if fields["cb_hide_gamemods"] ~= nil then
+ if core.is_yes(fields["cb_hide_gamemods"]) then
+ current.hide_game = true
+ this.data.hide_gamemods = true
+ core.setting_set("world_config_hide_gamemods", "true")
+ else
+ current.hide_game = false
+ this.data.hide_gamemods = false
+ core.setting_set("world_config_hide_gamemods", "false")
+ end
+ end
+
+ if fields["cb_hide_mpcontent"] ~= nil then
+ if core.is_yes(fields["cb_hide_mpcontent"]) then
+ current.hide_modpackcontents = true
+ this.data.hide_modpackcontents = true
+ core.setting_set("world_config_hide_modpackcontents", "true")
+ else
+ current.hide_modpackcontents = false
+ this.data.hide_modpackcontents = false
+ core.setting_set("world_config_hide_modpackcontents", "false")
+ end
end
this.data.list:set_filtercriteria(current)
@@ -237,10 +246,12 @@ function create_configure_world_dlg(worldidx)
handle_buttons,
nil)
- --TODO read from settings
- dlg.data.hide_gamemods = false
- dlg.data.hide_modpackcontents = false
- dlg.data.selected_mod = 0
+ dlg.data.hide_gamemods = core.setting_getbool("world_config_hide_gamemods")
+ dlg.data.hide_modpackcontents = core.setting_getbool("world_config_hide_modpackcontents")
+ dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod"))
+ if dlg.data.selected_mod == nil then
+ dlg.data.selected_mod = 0
+ end
dlg.data.worldspec = core.get_worlds()[worldidx]
if dlg.data.worldspec == nil then dlg:delete() return nil end
@@ -277,7 +288,12 @@ function create_configure_world_dlg(worldidx)
{ worldpath= dlg.data.worldspec.path,
gameid = dlg.data.worldspec.gameid }
)
-
+
+
+ if dlg.data.selected_mod > dlg.data.list:size() then
+ dlg.data.selected_mod = 0
+ end
+
dlg.data.list:set_filtercriteria(
{
hide_game=dlg.data.hide_gamemods,
@@ -285,6 +301,6 @@ function create_configure_world_dlg(worldidx)
})
dlg.data.list:add_sort_mechanism("alphabetic", sort_mod_list)
dlg.data.list:set_sortmode("alphabetic")
-
+
return dlg
end