Skip to content

Commit c401a06

Browse files
authoredMar 1, 2021
Make pkgmgr handle modpacks containing modpacks properly
fixes #10550
1 parent ccdaf5d commit c401a06

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed
 

Diff for: ‎builtin/mainmenu/pkgmgr.lua

+17-22
Original file line numberDiff line numberDiff line change
@@ -413,18 +413,7 @@ function pkgmgr.is_modpack_entirely_enabled(data, name)
413413
end
414414

415415
---------- toggles or en/disables a mod or modpack and its dependencies --------
416-
function pkgmgr.enable_mod(this, toset)
417-
local list = this.data.list:get_list()
418-
local mod = list[this.data.selected_mod]
419-
420-
-- Game mods can't be enabled or disabled
421-
if mod.is_game_content then
422-
return
423-
end
424-
425-
local toggled_mods = {}
426-
427-
local enabled_mods = {}
416+
local function toggle_mod_or_modpack(list, toggled_mods, enabled_mods, toset, mod)
428417
if not mod.is_modpack then
429418
-- Toggle or en/disable the mod
430419
if toset == nil then
@@ -443,19 +432,25 @@ function pkgmgr.enable_mod(this, toset)
443432
-- interleaved unsupported
444433
for i = 1, #list do
445434
if list[i].modpack == mod.name then
446-
if toset == nil then
447-
toset = not list[i].enabled
448-
end
449-
if list[i].enabled ~= toset then
450-
list[i].enabled = toset
451-
toggled_mods[#toggled_mods+1] = list[i].name
452-
end
453-
if toset then
454-
enabled_mods[list[i].name] = true
455-
end
435+
toggle_mod_or_modpack(list, toggled_mods, enabled_mods, toset, list[i])
456436
end
457437
end
458438
end
439+
end
440+
441+
function pkgmgr.enable_mod(this, toset)
442+
local list = this.data.list:get_list()
443+
local mod = list[this.data.selected_mod]
444+
445+
-- Game mods can't be enabled or disabled
446+
if mod.is_game_content then
447+
return
448+
end
449+
450+
local toggled_mods = {}
451+
local enabled_mods = {}
452+
toggle_mod_or_modpack(list, toggled_mods, enabled_mods, toset, mod)
453+
459454
if not toset then
460455
-- Mod(s) were disabled, so no dependencies need to be enabled
461456
table.sort(toggled_mods)

0 commit comments

Comments
 (0)
Please sign in to comment.