Skip to content

Commit 7967398

Browse files
authored
Merge pull request #140 from burgerhex/favorites
Fix "disable all" disabling favorites
2 parents 34fdba7 + b61e60d commit 7967398

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

changelog.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ and only contains the latest changes.
33
Its purpose is to be shown in Olympus when updating.
44

55
#changelog#
6-
∙ Added favorites to "Manage Installed Mods", with a dedicated filter
7-
∙ Suggest disabling dependencies when disabling a mod
8-
∙ Display warning symbol if an enabled mod has disabled dependencies
9-
∙ Different text colors for dependencies of enabled mods, favorites and their dependencies
10-
∙ Make sure to fall back to a mirror in case GameBanana sets up network filtering again
6+
∙ Prevent "Disable All" from disabling favorited mods

src/scenes/modlist.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ local function enableMod(mod)
338338
enableMods({["name"] = mod})
339339
end
340340

341-
-- disable mods on the UI
342-
local function disableMods(mods)
341+
-- disable mods on the UI, optionally including favorites
342+
local function disableMods(mods, alsoDisableFavorites)
343343
for _, mod in pairs(mods) do
344-
if not mod.info.IsBlacklisted then
344+
if not mod.info.IsBlacklisted and (alsoDisableFavorites or not mod.info.IsFavorite) then
345345
handleModEnabledStateChange(mod, false)
346346
end
347347
end
@@ -352,7 +352,8 @@ end
352352

353353
local function disableMod(mod)
354354
-- we could use mod.info.Name, but that might be nil for mods without everest.yaml, and disableMods() doesn't care
355-
disableMods({["name"] = mod})
355+
-- this function should only be used for explicitly disabling one mod, so we should disable it even if it's a favorite
356+
disableMods({["name"] = mod}, true)
356357
end
357358

358359
-- builds the confirmation message body for toggling mods, including a potentially-long list of mods in a scrollbox
@@ -559,7 +560,7 @@ local function checkEnabledDependenciesOfDisabledMods(newlyDisabledMods)
559560
"Yes",
560561
function(container)
561562
-- disable them all!
562-
disableMods(dependenciesThatCanBeDisabled)
563+
disableMods(dependenciesThatCanBeDisabled, false)
563564
container:close()
564565
end
565566
},
@@ -595,7 +596,7 @@ local function checkEnabledDependentsOfDisabledMod(mod)
595596
"Yes",
596597
function(container)
597598
-- disable them all!
598-
disableMods(dependentsToToggle)
599+
disableMods(dependentsToToggle, false)
599600
container:close()
600601

601602
dependentsToToggle[mod.info.Name] = mod
@@ -688,7 +689,8 @@ end
688689
-- disables all mods then enables mods from preset
689690
local function applyPreset(name, disableAll)
690691
if disableAll then
691-
disableMods(scene.modsByPath)
692+
-- still don't disable favorites
693+
disableMods(scene.modsByPath, false)
692694
end
693695
name = name:gsub("%p", "%%%1") -- escape special characters
694696
local root = config.installs[config.install].path
@@ -1031,7 +1033,8 @@ function scene.reload()
10311033
writeBlacklist()
10321034
end):with({ enabled = false }):as("enableAllButton"),
10331035
uie.button("Disable All", function()
1034-
disableMods(scene.modsByPath)
1036+
-- don't disable favorites
1037+
disableMods(scene.modsByPath, false)
10351038
writeBlacklist()
10361039
end):with({ enabled = false }):as("disableAllButton"),
10371040
}):with(uiu.rightbound)

0 commit comments

Comments
 (0)