From f9e1fa85bbe38ccf9aa17ec0c855d0c3aff54bc9 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 14 Sep 2019 18:21:48 +0000 Subject: [PATCH] Allow totally incompatible modules in changeset --- GUI/GUIMod.cs | 29 ++++++++++++++--------------- GUI/MainModList.cs | 1 - 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/GUI/GUIMod.cs b/GUI/GUIMod.cs index 08a28a12f5..1226238280 100644 --- a/GUI/GUIMod.cs +++ b/GUI/GUIMod.cs @@ -288,16 +288,11 @@ public CkanModule ToModule() public IEnumerable> GetRequestedChanges() { - if (IsInstalled && !IsInstallChecked) - { - // Uninstall the version we have installed - yield return new KeyValuePair(InstalledMod.Module, GUIModChangeType.Remove); - } - else if (!IsInstalled && IsInstallChecked) - { - yield return new KeyValuePair(SelectedMod ?? Mod, GUIModChangeType.Install); - } - else if (IsInstalled && (IsInstallChecked && HasUpdate && IsUpgradeChecked)) + bool selectedIsInstalled = SelectedMod?.Equals(InstalledMod?.Module) + ?? InstalledMod?.Module.Equals(SelectedMod) + // Both null + ?? true; + if (IsInstalled && (IsInstallChecked && HasUpdate && IsUpgradeChecked)) { yield return new KeyValuePair(Mod, GUIModChangeType.Update); } @@ -305,12 +300,16 @@ public IEnumerable> GetRequestedChang { yield return new KeyValuePair(Mod, GUIModChangeType.Replace); } - else if (IsInstalled - && SelectedMod != null - && !InstalledMod.Module.Equals(SelectedMod)) + else if (!selectedIsInstalled) { - yield return new KeyValuePair(InstalledMod.Module, GUIModChangeType.Remove); - yield return new KeyValuePair(SelectedMod, GUIModChangeType.Install); + if (InstalledMod != null) + { + yield return new KeyValuePair(InstalledMod.Module, GUIModChangeType.Remove); + } + if (SelectedMod != null) + { + yield return new KeyValuePair(SelectedMod, GUIModChangeType.Install); + } } } diff --git a/GUI/MainModList.cs b/GUI/MainModList.cs index 492f842435..729a0ea95c 100644 --- a/GUI/MainModList.cs +++ b/GUI/MainModList.cs @@ -1076,7 +1076,6 @@ public HashSet ComputeUserChangeSet(IRegistryQuerier registry) ?? new InstalledModule[] {}; return new HashSet( Modules - .Where(mod => mod.IsInstallable()) .SelectMany(mod => mod.GetRequestedChanges()) .Select(change => new ModChange(change.Key, change.Value, null)) .Union(removableAuto.Select(im => new ModChange(