Add a button for disabling all mods to world config. (#3900)

master
red-001 2016-10-11 18:11:38 +01:00 committed by Zeno-
parent b6569f1c69
commit 4f684b589d
1 changed files with 28 additions and 9 deletions

View File

@ -16,6 +16,9 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local enabled_all = false
local function modname_valid(name) local function modname_valid(name)
return not name:find("[^a-z0-9_]") return not name:find("[^a-z0-9_]")
end end
@ -80,11 +83,15 @@ local function get_formspec(data)
end end
end end
end end
if enabled_all then
retval = retval .. retval = retval ..
"button[8.75,0.125;2.5,0.5;btn_all_mods;" .. fgettext("Enable all") .. "]" .. "button[8.75,0.125;2.5,0.5;btn_disable_all_mods;" .. fgettext("Disable all") .. "]" ..
"textlist[5.5,0.75;5.75,5.25;world_config_modlist;" "textlist[5.5,0.75;5.75,5.25;world_config_modlist;"
else
retval = retval ..
"button[8.75,0.125;2.5,0.5;btn_enable_all_mods;" .. fgettext("Enable all") .. "]" ..
"textlist[5.5,0.75;5.75,5.25;world_config_modlist;"
end
retval = retval .. modmgr.render_modlist(data.list) retval = retval .. modmgr.render_modlist(data.list)
retval = retval .. ";" .. data.selected_mod .."]" retval = retval .. ";" .. data.selected_mod .."]"
@ -229,15 +236,27 @@ local function handle_buttons(this, fields)
return true return true
end end
if fields["btn_all_mods"] then if fields.btn_enable_all_mods then
local list = this.data.list:get_raw_list() local list = this.data.list:get_raw_list()
for i=1,#list,1 do for i = 1, #list do
if list[i].typ ~= "game_mod" and if list[i].typ ~= "game_mod" and not list[i].is_modpack then
not list[i].is_modpack then
list[i].enabled = true list[i].enabled = true
end end
end end
enabled_all = true
return true
end
if fields.btn_disable_all_mods then
local list = this.data.list:get_raw_list()
for i = 1, #list do
if list[i].typ ~= "game_mod" and not list[i].is_modpack then
list[i].enabled = false
end
end
enabled_all = false
return true return true
end end