Skip to content

Commit

Permalink
MainMenu: Save 'hide gamemods' and 'hide modpack contents' checkbox s…
Browse files Browse the repository at this point in the history
…tate (fixes #1960)
  • Loading branch information
fz72 authored and kwolekr committed Dec 29, 2014
1 parent 91c00d2 commit 86cfbc2
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions builtin/mainmenu/dlg_config_world.lua
Expand Up @@ -118,6 +118,7 @@ local function handle_buttons(this, fields)
if fields["world_config_modlist"] ~= nil then if fields["world_config_modlist"] ~= nil then
local event = core.explode_textlist_event(fields["world_config_modlist"]) local event = core.explode_textlist_event(fields["world_config_modlist"])
this.data.selected_mod = event.index this.data.selected_mod = event.index
core.setting_set("world_config_selected_mod", event.index)


if event.type == "DCL" then if event.type == "DCL" then
enable_mod(this) enable_mod(this)
Expand Down Expand Up @@ -151,21 +152,29 @@ local function handle_buttons(this, fields)
if current == nil then if current == nil then
current = {} current = {}
end 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 if fields["cb_hide_gamemods"] ~= nil then
current.hide_modpackcontents = true if core.is_yes(fields["cb_hide_gamemods"]) then
this.data.hide_modpackcontents = true current.hide_game = true
else this.data.hide_gamemods = true
current.hide_modpackcontents = false core.setting_set("world_config_hide_gamemods", "true")
this.data.hide_modpackcontents = false 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 end


this.data.list:set_filtercriteria(current) this.data.list:set_filtercriteria(current)
Expand Down Expand Up @@ -237,10 +246,12 @@ function create_configure_world_dlg(worldidx)
handle_buttons, handle_buttons,
nil) nil)


--TODO read from settings dlg.data.hide_gamemods = core.setting_getbool("world_config_hide_gamemods")
dlg.data.hide_gamemods = false dlg.data.hide_modpackcontents = core.setting_getbool("world_config_hide_modpackcontents")
dlg.data.hide_modpackcontents = false dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod"))
dlg.data.selected_mod = 0 if dlg.data.selected_mod == nil then
dlg.data.selected_mod = 0
end


dlg.data.worldspec = core.get_worlds()[worldidx] dlg.data.worldspec = core.get_worlds()[worldidx]
if dlg.data.worldspec == nil then dlg:delete() return nil end if dlg.data.worldspec == nil then dlg:delete() return nil end
Expand Down Expand Up @@ -277,14 +288,19 @@ function create_configure_world_dlg(worldidx)
{ worldpath= dlg.data.worldspec.path, { worldpath= dlg.data.worldspec.path,
gameid = dlg.data.worldspec.gameid } 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( dlg.data.list:set_filtercriteria(
{ {
hide_game=dlg.data.hide_gamemods, hide_game=dlg.data.hide_gamemods,
hide_modpackcontents= dlg.data.hide_modpackcontents hide_modpackcontents= dlg.data.hide_modpackcontents
}) })
dlg.data.list:add_sort_mechanism("alphabetic", sort_mod_list) dlg.data.list:add_sort_mechanism("alphabetic", sort_mod_list)
dlg.data.list:set_sortmode("alphabetic") dlg.data.list:set_sortmode("alphabetic")

return dlg return dlg
end end

0 comments on commit 86cfbc2

Please sign in to comment.