aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorred-001 <red-001@openmailbox.org>2016-10-11 18:11:38 +0100
committerZeno- <kde.psych@gmail.com>2016-10-12 03:11:38 +1000
commit4f684b589d8227c525d877b8a695736d561ea4d5 (patch)
tree3561a18aa0c4e1ac267650d6d02ef3d9f77e8bdd /builtin
parentb6569f1c699e8bd3dfef50c64272fdb035b43b6c (diff)
downloadminetest-4f684b589d8227c525d877b8a695736d561ea4d5.tar.gz
minetest-4f684b589d8227c525d877b8a695736d561ea4d5.tar.bz2
minetest-4f684b589d8227c525d877b8a695736d561ea4d5.zip
Add a button for disabling all mods to world config. (#3900)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mainmenu/dlg_config_world.lua37
1 files changed, 28 insertions, 9 deletions
diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua
index eb0319ba0..6e6224c92 100644
--- a/builtin/mainmenu/dlg_config_world.lua
+++ b/builtin/mainmenu/dlg_config_world.lua
@@ -16,6 +16,9 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------------
+
+local enabled_all = false
+
local function modname_valid(name)
return not name:find("[^a-z0-9_]")
end
@@ -80,11 +83,15 @@ local function get_formspec(data)
end
end
end
-
- retval = retval ..
- "button[8.75,0.125;2.5,0.5;btn_all_mods;" .. fgettext("Enable all") .. "]" ..
- "textlist[5.5,0.75;5.75,5.25;world_config_modlist;"
-
+ if enabled_all then
+ retval = retval ..
+ "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;"
+ 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 .. ";" .. data.selected_mod .."]"
@@ -229,15 +236,27 @@ local function handle_buttons(this, fields)
return true
end
- if fields["btn_all_mods"] then
+ if fields.btn_enable_all_mods then
local list = this.data.list:get_raw_list()
- for i=1,#list,1 do
- if list[i].typ ~= "game_mod" and
- not list[i].is_modpack then
+ for i = 1, #list do
+ if list[i].typ ~= "game_mod" and not list[i].is_modpack then
list[i].enabled = true
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
end