Skip to content

Commit 2e17074

Browse files
committed
Spore ModAPI Easy Uninstaller: add support for depends/dependsVersions attributes
1 parent 4c07ded commit 2e17074

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Spore ModAPI Easy Uninstaller/EasyUninstaller.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ public static void UninstallMods(Dictionary<ModConfiguration, bool> mods)
7575

7676
try
7777
{
78+
// ensure we don't remove a mod which
79+
// is a dependency of another mod
80+
List<string> modDependencies = new List<string>();
81+
List<string> reliantMods = new List<string>();
82+
foreach (var mod in Mods.ModConfigurations)
83+
{
84+
foreach (var uninstallMod in mods)
85+
{
86+
if (mod.Dependencies != null &&
87+
mod.Dependencies.Contains(uninstallMod.Key.Unique) &&
88+
!mods.Select(x => x.Key.Unique).Contains(mod.Unique))
89+
{
90+
modDependencies.Add(uninstallMod.Key.DisplayName);
91+
if (!reliantMods.Contains(mod.DisplayName))
92+
reliantMods.Add(mod.DisplayName);
93+
}
94+
}
95+
}
96+
97+
if (modDependencies.Count() > 0)
98+
{
99+
MessageBox.Show($"Cannot uninstall {String.Join(", ", modDependencies.ToArray())} because {String.Join(", ", reliantMods.ToArray())} relies on them being installed!", CommonStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
100+
return;
101+
}
102+
78103
foreach (var mod in mods)
79104
{
80105
ResultType result = ResultType.Success;

0 commit comments

Comments
 (0)