Skip to content

Commit becc7f3

Browse files
committed
Refresh the mod list when it is filtered on enabled/favorite mods and a mod is enabled/favorited
1 parent f5e522a commit becc7f3

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

changelog.txt

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

55
#changelog#
6-
∙ Fixed crash of Manage Installed Mods when a mod with no everest.yaml is present
6+
∙ Fixed crash of Manage Installed Mods when a mod with no everest.yaml is present
7+
∙ Refresh the mod list when it is filtered on enabled/favorite mods and a mod is enabled/favorited

src/scenes/modlist.lua

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ local function updateWarningButtonForDependents(mod)
296296
end
297297

298298
-- enable a mod on the UI (writeBlacklist needs to be called afterwards to write the change to disk)
299-
-- usages of this function may omit the shouldRefreshVisibleMods parameter, defaulting to nil
300-
local function enableMod(mod, shouldRefreshVisibleMods)
299+
local function enableMod(mod)
301300
if mod.info.IsBlacklisted then
302301
mod.row:findChild("toggleCheckbox"):setValue(true)
303302
mod.info.IsBlacklisted = false
@@ -306,16 +305,11 @@ local function enableMod(mod, shouldRefreshVisibleMods)
306305
updateWarningButtonForMod(mod)
307306
updateWarningButtonForDependents(mod)
308307
updateEnabledModCountLabel()
309-
310-
if shouldRefreshVisibleMods and scene.onlyShowEnabledMods then
311-
refreshVisibleMods()
312-
end
313308
end
314309
end
315310

316311
-- disable a mod on the UI (writeBlacklist needs to be called afterwards to write the change to disk)
317-
-- usages of this function may omit the shouldRefreshVisibleMods parameter, defaulting to nil
318-
local function disableMod(mod, shouldRefreshVisibleMods)
312+
local function disableMod(mod)
319313
if not mod.info.IsBlacklisted then
320314
mod.row:findChild("toggleCheckbox"):setValue(false)
321315
mod.info.IsBlacklisted = true
@@ -324,10 +318,6 @@ local function disableMod(mod, shouldRefreshVisibleMods)
324318
updateWarningButtonForMod(mod)
325319
updateWarningButtonForDependents(mod)
326320
updateEnabledModCountLabel()
327-
328-
if shouldRefreshVisibleMods and scene.onlyShowEnabledMods then
329-
refreshVisibleMods()
330-
end
331321
end
332322
end
333323

@@ -399,6 +389,9 @@ local function checkDisabledDependenciesOfEnabledMod(mod)
399389
end
400390

401391
writeBlacklist()
392+
if scene.onlyShowEnabledMods then
393+
refreshVisibleMods()
394+
end
402395
container:close()
403396
end
404397
},
@@ -411,6 +404,9 @@ local function checkDisabledDependenciesOfEnabledMod(mod)
411404
-- re-disable the mod
412405
disableMod(mod)
413406
writeBlacklist()
407+
if scene.onlyShowEnabledMods then
408+
refreshVisibleMods()
409+
end
414410
container:close()
415411
end
416412
}
@@ -443,6 +439,9 @@ local function checkDisabledDependenciesOfEnabledModFromWarning(info)
443439
end
444440

445441
writeBlacklist()
442+
if scene.onlyShowEnabledMods then
443+
refreshVisibleMods()
444+
end
446445
container:close()
447446
end
448447
},
@@ -543,6 +542,9 @@ local function checkEnabledDependenciesOfDisabledMods(newlyDisabledMods)
543542
end
544543

545544
writeBlacklist()
545+
if scene.onlyShowEnabledMods then
546+
refreshVisibleMods()
547+
end
546548
container:close()
547549
end
548550
},
@@ -577,6 +579,9 @@ local function checkEnabledDependentsOfDisabledMod(mod)
577579
end
578580

579581
writeBlacklist()
582+
if scene.onlyShowEnabledMods then
583+
refreshVisibleMods()
584+
end
580585
container:close()
581586

582587
dependenciesToToggle[mod.info.Name] = mod
@@ -596,6 +601,9 @@ local function checkEnabledDependentsOfDisabledMod(mod)
596601
-- re-enable the mod
597602
enableMod(mod)
598603
writeBlacklist()
604+
if scene.onlyShowEnabledMods then
605+
refreshVisibleMods()
606+
end
599607
container:close()
600608
end
601609
}
@@ -612,12 +620,18 @@ local function toggleMod(info, newState)
612620
if newState then
613621
enableMod(mod)
614622
writeBlacklist()
623+
if scene.onlyShowEnabledMods then
624+
refreshVisibleMods()
625+
end
615626
if info.Name then
616627
checkDisabledDependenciesOfEnabledMod(mod)
617628
end
618629
else
619630
disableMod(mod)
620631
writeBlacklist()
632+
if scene.onlyShowEnabledMods then
633+
refreshVisibleMods()
634+
end
621635
if info.Name then
622636
checkEnabledDependentsOfDisabledMod(mod)
623637
end
@@ -646,17 +660,13 @@ Tip: Disabling the mod prevents Everest from loading it, and is as efficient as
646660
end
647661

648662
-- called whenever a mod is favorited or unfavorited
649-
-- usages of this function may omit the shouldRefreshVisibleMods parameter, defaulting to nil
650-
local function toggleFavorite(info, newState, shouldRefreshVisibleMods)
663+
local function toggleFavorite(info, newState)
651664
local mod = scene.modsByPath[info.Path]
652665
if mod.info.IsFavorite ~= newState then
653666
mod.info.IsFavorite = newState
654667
updateLabelTextForMod(mod)
655668
updateLabelTextForDependencies(mod)
656669
writeFavorites()
657-
if shouldRefreshVisibleMods and scene.onlyShowFavoriteMods then
658-
refreshVisibleMods()
659-
end
660670
end
661671
end
662672

@@ -682,13 +692,19 @@ local function enableAllMods()
682692
for _, mod in pairs(scene.modlist) do
683693
enableMod(mod)
684694
end
695+
if scene.onlyShowEnabledMods then
696+
refreshVisibleMods()
697+
end
685698
end
686699

687700
-- loops through modlist and calls disableMod() on every mod
688701
local function disableAllMods()
689702
for _, mod in pairs(scene.modlist) do
690703
disableMod(mod)
691704
end
705+
if scene.onlyShowEnabledMods then
706+
refreshVisibleMods()
707+
end
692708
end
693709

694710
-- disables all mods then enables mods from preset
@@ -721,6 +737,9 @@ local function applyPreset(name, disableAll)
721737
displayErrorMessage("Some mods couldn't be loaded, make sure they are installed: \n" .. missingMods)
722738
end
723739
writeBlacklist()
740+
if scene.onlyShowEnabledMods then
741+
refreshVisibleMods()
742+
end
724743
end
725744

726745
-- deletes preset from modpresets.txt
@@ -926,6 +945,9 @@ function scene.item(info)
926945

927946
uie.heart(info.IsFavorite, function(heart, newState)
928947
toggleFavorite(info, newState)
948+
if scene.onlyShowFavoriteMods then
949+
refreshVisibleMods()
950+
end
929951
end)
930952
:with(verticalCenter)
931953
:with({
@@ -1016,7 +1038,7 @@ function scene.reload()
10161038
uie.button("Open mods folder", function()
10171039
utils.openFile(fs.joinpath(root, "Mods"))
10181040
end),
1019-
uie.button("Edit blacklist.txt", function()
1041+
uie.button("Edit blacklist", function()
10201042
utils.openFile(fs.joinpath(root, "Mods", "blacklist.txt"))
10211043
end),
10221044
uie.button("Mod presets", function()

0 commit comments

Comments
 (0)