@@ -13,7 +13,7 @@ local scene = {
1313 name = " Mod Manager" ,
1414 -- the list of displayed mods, in the order they are displayed (mod object = { info = modinfo, row = uirow, visible = bool })
1515 modlist = {},
16- -- mod name -> mod object
16+ -- mod name -> list[ mod object]
1717 modsByName = {},
1818 -- mod path -> mod object
1919 modsByPath = {},
@@ -183,16 +183,26 @@ local function getLabelTextFor(info)
183183 if info .IsFavorite then
184184 color = themeColors .favoriteColor
185185 else
186+ local isDependencyOfFavorite = false
187+ local isDependency = false
188+
186189 for _ , dep in ipairs (scene .modDependents [info .Name ] or {}) do
187190 if scene .modsByName [dep ] then
188- if scene .modsByName [dep ].info .IsFavorite then
189- color = themeColors .dependencyOfFavoriteColor
190- break
191- elseif not scene .modsByName [dep ].info .IsBlacklisted then
192- color = themeColors .dependencyColor
191+ for _ , mod in pairs (scene .modsByName [dep ]) do
192+ if mod .info .IsFavorite then
193+ isDependencyOfFavorite = true
194+ elseif not mod .info .IsBlacklisted then
195+ isDependency = true
196+ end
193197 end
194198 end
195199 end
200+
201+ if isDependencyOfFavorite then
202+ color = themeColors .dependencyOfFavoriteColor
203+ elseif isDependency then
204+ color = themeColors .dependencyColor
205+ end
196206 end
197207
198208 color = {color [1 ], color [2 ], color [3 ], info .IsBlacklisted and 0.5 or 1 }
@@ -244,12 +254,18 @@ local function findDependenciesToEnable(mod)
244254
245255 while # queue > 0 do
246256 local depName = table.remove (queue , 1 )
247- local dep = scene .modsByName [depName ]
248- if dep then
249- if dep .info .IsBlacklisted and not dependenciesToEnable [depName ] then
250- dependenciesToEnable [depName ] = dep
257+ local depOptions = scene .modsByName [depName ]
258+ if depOptions then
259+ local disabled = true
260+ for _ , dep in pairs (depOptions ) do
261+ if not dep .info .IsBlacklisted then
262+ disabled = false
263+ end
264+ end
265+ if disabled and not dependenciesToEnable [depName ] then
266+ dependenciesToEnable [depName ] = depOptions [1 ] -- can't really take an informed decision there...
251267 end
252- for _ , subdep in ipairs (scene .modDependencies [dep . info . Name ] or {}) do
268+ for _ , subdep in ipairs (scene .modDependencies [depName ] or {}) do
253269 if not tried [subdep ] then
254270 tried [subdep ] = true
255271 table.insert (queue , subdep )
267283
268284local function updateLabelTextForDependencies (mod )
269285 for _ , depName in ipairs (scene .modDependencies [mod .info .Name ] or {}) do
270- local dep = scene .modsByName [depName ]
271- if dep then
272- updateLabelTextForMod (dep )
286+ local depOptions = scene .modsByName [depName ]
287+ if depOptions then
288+ for _ , dep in pairs (depOptions ) do
289+ updateLabelTextForMod (dep )
290+ end
273291 end
274292 end
275293end
288306
289307local function updateWarningButtonForDependents (mod )
290308 for _ , depName in ipairs (scene .modDependents [mod .info .Name ] or {}) do
291- local dep = scene .modsByName [depName ]
292- if dep then
293- updateWarningButtonForMod (dep )
309+ local depOptions = scene .modsByName [depName ]
310+ if depOptions then
311+ for _ , dep in pairs (depOptions ) do
312+ updateWarningButtonForMod (dep )
313+ end
294314 end
295315 end
296316end
411431
412432-- similar to the above checkDisabledDependenciesOfEnabledMod, but has no "Cancel" button and is meant to be called from the warning button
413433local function checkDisabledDependenciesOfEnabledModFromWarning (info )
414- local mod = scene .modsByName [info .Name ]
434+ local mod = scene .modsByPath [info .Path ]
415435 local dependenciesToToggle = findDependenciesToEnable (mod )
416436 local numDependencies = dictLength (dependenciesToToggle )
417437
@@ -460,11 +480,13 @@ local function findDependentsToDisable(mod)
460480
461481 while # queue > 0 do
462482 local depName = table.remove (queue , 1 )
463- local dep = scene .modsByName [depName ]
464- if not dep .info .IsBlacklisted and not dep .info .IsFavorite and not dependentsToDisable [depName ] then
465- dependentsToDisable [depName ] = dep
483+ local depOptions = scene .modsByName [depName ] or {}
484+ for _ , dep in pairs (depOptions ) do
485+ if not dep .info .IsBlacklisted and not dep .info .IsFavorite and not dependentsToDisable [depName ] then
486+ dependentsToDisable [depName ] = dep
487+ end
466488 end
467- for _ , subdep in ipairs (scene .modDependents [dep . info . Name ] or {}) do
489+ for _ , subdep in ipairs (scene .modDependents [depName ] or {}) do
468490 if not tried [subdep ] then
469491 tried [subdep ] = true
470492 table.insert (queue , subdep )
@@ -492,15 +514,17 @@ local function findDependenciesThatCanBeDisabled(newlyDisabledMods)
492514
493515 while # queue > 0 do
494516 local depName = table.remove (queue , 1 )
495- local dep = scene .modsByName [depName ]
496- if dep and not dep .info .IsBlacklisted and not dep .info .IsFavorite and not dependenciesThatCanBeDisabled [depName ] then
497- local enabledDependents = findDependentsToDisable (dep )
498- if not next (enabledDependents ) then
499- dependenciesThatCanBeDisabled [depName ] = dep
500- for _ , subdep in ipairs (scene .modDependencies [depName ] or {}) do
501- if not tried [subdep ] then
502- tried [subdep ] = true
503- table.insert (queue , subdep )
517+ local depOptions = scene .modsByName [depName ] or {}
518+ for _ , dep in pairs (depOptions ) do
519+ if not dep .info .IsBlacklisted and not dep .info .IsFavorite and not dependenciesThatCanBeDisabled [depName ] then
520+ local enabledDependents = findDependentsToDisable (dep )
521+ if not next (enabledDependents ) then
522+ dependenciesThatCanBeDisabled [depName ] = dep
523+ for _ , subdep in ipairs (scene .modDependencies [depName ] or {}) do
524+ if not tried [subdep ] then
525+ tried [subdep ] = true
526+ table.insert (queue , subdep )
527+ end
504528 end
505529 end
506530 end
@@ -1063,7 +1087,10 @@ function scene.reload()
10631087 scene .modsByPath [info .Path ] = mod
10641088
10651089 if info .Name then
1066- scene .modsByName [info .Name ] = mod
1090+ if not scene .modsByName [info .Name ] then
1091+ scene .modsByName [info .Name ] = {}
1092+ end
1093+ table.insert (scene .modsByName [info .Name ], mod )
10671094 if not scene .modDependencies [info .Name ] then
10681095 scene .modDependencies [info .Name ] = {}
10691096 end
0 commit comments