Skip to content

Commit 86cfbc2

Browse files
fz72kwolekr
authored andcommittedDec 29, 2014
MainMenu: Save 'hide gamemods' and 'hide modpack contents' checkbox state (fixes #1960)
1 parent 91c00d2 commit 86cfbc2

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed
 

‎builtin/mainmenu/dlg_config_world.lua

+36-20
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ local function handle_buttons(this, fields)
118118
if fields["world_config_modlist"] ~= nil then
119119
local event = core.explode_textlist_event(fields["world_config_modlist"])
120120
this.data.selected_mod = event.index
121+
core.setting_set("world_config_selected_mod", event.index)
121122

122123
if event.type == "DCL" then
123124
enable_mod(this)
@@ -151,21 +152,29 @@ local function handle_buttons(this, fields)
151152
if current == nil then
152153
current = {}
153154
end
154-
155-
if core.is_yes(fields["cb_hide_gamemods"]) then
156-
current.hide_game = true
157-
this.data.hide_gamemods = true
158-
else
159-
current.hide_game = false
160-
this.data.hide_gamemods = false
161-
end
162155

163-
if core.is_yes(fields["cb_hide_mpcontent"]) then
164-
current.hide_modpackcontents = true
165-
this.data.hide_modpackcontents = true
166-
else
167-
current.hide_modpackcontents = false
168-
this.data.hide_modpackcontents = false
156+
if fields["cb_hide_gamemods"] ~= nil then
157+
if core.is_yes(fields["cb_hide_gamemods"]) then
158+
current.hide_game = true
159+
this.data.hide_gamemods = true
160+
core.setting_set("world_config_hide_gamemods", "true")
161+
else
162+
current.hide_game = false
163+
this.data.hide_gamemods = false
164+
core.setting_set("world_config_hide_gamemods", "false")
165+
end
166+
end
167+
168+
if fields["cb_hide_mpcontent"] ~= nil then
169+
if core.is_yes(fields["cb_hide_mpcontent"]) then
170+
current.hide_modpackcontents = true
171+
this.data.hide_modpackcontents = true
172+
core.setting_set("world_config_hide_modpackcontents", "true")
173+
else
174+
current.hide_modpackcontents = false
175+
this.data.hide_modpackcontents = false
176+
core.setting_set("world_config_hide_modpackcontents", "false")
177+
end
169178
end
170179

171180
this.data.list:set_filtercriteria(current)
@@ -237,10 +246,12 @@ function create_configure_world_dlg(worldidx)
237246
handle_buttons,
238247
nil)
239248

240-
--TODO read from settings
241-
dlg.data.hide_gamemods = false
242-
dlg.data.hide_modpackcontents = false
243-
dlg.data.selected_mod = 0
249+
dlg.data.hide_gamemods = core.setting_getbool("world_config_hide_gamemods")
250+
dlg.data.hide_modpackcontents = core.setting_getbool("world_config_hide_modpackcontents")
251+
dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod"))
252+
if dlg.data.selected_mod == nil then
253+
dlg.data.selected_mod = 0
254+
end
244255

245256
dlg.data.worldspec = core.get_worlds()[worldidx]
246257
if dlg.data.worldspec == nil then dlg:delete() return nil end
@@ -277,14 +288,19 @@ function create_configure_world_dlg(worldidx)
277288
{ worldpath= dlg.data.worldspec.path,
278289
gameid = dlg.data.worldspec.gameid }
279290
)
280-
291+
292+
293+
if dlg.data.selected_mod > dlg.data.list:size() then
294+
dlg.data.selected_mod = 0
295+
end
296+
281297
dlg.data.list:set_filtercriteria(
282298
{
283299
hide_game=dlg.data.hide_gamemods,
284300
hide_modpackcontents= dlg.data.hide_modpackcontents
285301
})
286302
dlg.data.list:add_sort_mechanism("alphabetic", sort_mod_list)
287303
dlg.data.list:set_sortmode("alphabetic")
288-
304+
289305
return dlg
290306
end

0 commit comments

Comments
 (0)
Please sign in to comment.