From f4c1c4a111df0d3c841a197d813bf139797e0866 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Tue, 7 May 2019 02:24:23 +0000 Subject: [PATCH] Show and edit auto-install flag in ConsoleUI --- ConsoleUI/ModListHelpDialog.cs | 10 +++-- ConsoleUI/ModListScreen.cs | 68 +++++++++++++++++++++++----------- ConsoleUI/Toolkit/Keys.cs | 7 ++++ ConsoleUI/Toolkit/Symbols.cs | 4 ++ 4 files changed, 64 insertions(+), 25 deletions(-) diff --git a/ConsoleUI/ModListHelpDialog.cs b/ConsoleUI/ModListHelpDialog.cs index 900386c3ed..fee27901ea 100644 --- a/ConsoleUI/ModListHelpDialog.cs +++ b/ConsoleUI/ModListHelpDialog.cs @@ -30,6 +30,7 @@ public ModListHelpDialog() : base() symbolTb.AddLine("Status Symbols"); symbolTb.AddLine("=============="); symbolTb.AddLine($"{installed} Installed"); + symbolTb.AddLine($"{autoInstalled} Auto-installed"); symbolTb.AddLine($"{upgradable} Upgradeable"); symbolTb.AddLine($"{autodetected} Manually installed"); symbolTb.AddLine($"{replaceable} Replaceable"); @@ -65,10 +66,11 @@ public ModListHelpDialog() : base() )); } - private static readonly string installed = Symbols.checkmark; - private static readonly string upgradable = Symbols.greaterEquals; - private static readonly string autodetected = Symbols.infinity; - private static readonly string replaceable = Symbols.doubleGreater; + private static readonly string installed = Symbols.checkmark; + private static readonly string autoInstalled = Symbols.feminineOrdinal; + private static readonly string upgradable = Symbols.greaterEquals; + private static readonly string autodetected = Symbols.infinity; + private static readonly string replaceable = Symbols.doubleGreater; } } diff --git a/ConsoleUI/ModListScreen.cs b/ConsoleUI/ModListScreen.cs index 42c5b19cfb..bafee9d080 100644 --- a/ConsoleUI/ModListScreen.cs +++ b/ConsoleUI/ModListScreen.cs @@ -205,6 +205,23 @@ public ModListScreen(KSPManager mgr, bool dbg) } return true; }); + + moduleList.AddTip("F8", "Mark auto-installed", + () => moduleList.Selection != null + && (!registry.InstalledModule(moduleList.Selection.identifier)?.AutoInstalled ?? false) + ); + moduleList.AddTip("F8", "Mark user-selected", + () => moduleList.Selection != null + && (registry.InstalledModule(moduleList.Selection.identifier)?.AutoInstalled ?? false) + ); + moduleList.AddBinding(Keys.F8, (object sender) => { + InstalledModule im = registry.InstalledModule(moduleList.Selection.identifier); + if (im != null) { + im.AutoInstalled = !im.AutoInstalled; + RegistryManager.Instance(manager.CurrentInstance).Save(false); + } + return true; + }); AddTip("F9", "Apply changes", plan.NonEmpty); AddBinding(Keys.F9, (object sender) => { @@ -552,17 +569,18 @@ public string StatusSymbol(CkanModule m) public static string StatusSymbol(InstallStatus st) { switch (st) { - case InstallStatus.Unavailable: return unavailable; - case InstallStatus.Removing: return removing; - case InstallStatus.Upgrading: return upgrading; - case InstallStatus.Upgradeable: return upgradable; - case InstallStatus.Installed: return installed; - case InstallStatus.Installing: return installing; - case InstallStatus.NotInstalled: return notinstalled; - case InstallStatus.AutoDetected: return autodetected; - case InstallStatus.Replaceable: return replaceable; - case InstallStatus.Replacing: return replacing; - default: return ""; + case InstallStatus.Unavailable: return unavailable; + case InstallStatus.Removing: return removing; + case InstallStatus.Upgrading: return upgrading; + case InstallStatus.Upgradeable: return upgradable; + case InstallStatus.Installed: return installed; + case InstallStatus.AutoInstalled: return autoInstalled; + case InstallStatus.Installing: return installing; + case InstallStatus.NotInstalled: return notinstalled; + case InstallStatus.AutoDetected: return autodetected; + case InstallStatus.Replaceable: return replaceable; + case InstallStatus.Replacing: return replacing; + default: return ""; } } @@ -589,16 +607,17 @@ private long totalInstalledDownloadSize() private const int daysTillStale = 7; private const int daystillVeryStale = 30; - private static readonly string unavailable = "!"; - private static readonly string notinstalled = " "; - private static readonly string installed = Symbols.checkmark; - private static readonly string installing = "+"; - private static readonly string upgradable = Symbols.greaterEquals; - private static readonly string upgrading = "^"; - private static readonly string removing = "-"; - private static readonly string autodetected = Symbols.infinity; - private static readonly string replaceable = Symbols.doubleGreater; - private static readonly string replacing = Symbols.plusMinus; + private static readonly string unavailable = "!"; + private static readonly string notinstalled = " "; + private static readonly string installed = Symbols.checkmark; + private static readonly string autoInstalled = Symbols.feminineOrdinal; + private static readonly string installing = "+"; + private static readonly string upgradable = Symbols.greaterEquals; + private static readonly string upgrading = "^"; + private static readonly string removing = "-"; + private static readonly string autodetected = Symbols.infinity; + private static readonly string replaceable = Symbols.doubleGreater; + private static readonly string replacing = Symbols.plusMinus; } /// @@ -703,6 +722,8 @@ public InstallStatus GetModStatus(KSPManager manager, IRegistryQuerier registry, return InstallStatus.Replaceable; } else if (!IsAnyAvailable(registry, identifier)) { return InstallStatus.Unavailable; + } else if (registry.InstalledModule(identifier)?.AutoInstalled ?? false) { + return InstallStatus.AutoInstalled; } else { return InstallStatus.Installed; } @@ -813,6 +834,11 @@ public enum InstallStatus { /// This mod is installed and not upgradeable or planned to be removed /// Installed, + + /// + /// Like Installed, but can be auto-removed if depending mods are removed + /// + AutoInstalled, /// /// This mod is not installed but we are planning to install it diff --git a/ConsoleUI/Toolkit/Keys.cs b/ConsoleUI/Toolkit/Keys.cs index 26076d65ee..5f39473767 100644 --- a/ConsoleUI/Toolkit/Keys.cs +++ b/ConsoleUI/Toolkit/Keys.cs @@ -53,6 +53,13 @@ public static class Keys { (System.Char)0, ConsoleKey.F5, false, false, false ); + /// + /// Representation of F8 for key bindings + /// + public static readonly ConsoleKeyInfo F8 = new ConsoleKeyInfo( + (System.Char)0, ConsoleKey.F8, false, false, false + ); + /// /// Representation of F9 for key bindings /// diff --git a/ConsoleUI/Toolkit/Symbols.cs b/ConsoleUI/Toolkit/Symbols.cs index bb877732f8..7105eda7a6 100644 --- a/ConsoleUI/Toolkit/Symbols.cs +++ b/ConsoleUI/Toolkit/Symbols.cs @@ -23,6 +23,10 @@ public static class Symbols { /// public static readonly string checkmark = cp437s(0xfb); /// + /// Double tilde + /// + public static readonly string feminineOrdinal = cp437s(0xa6); + /// /// >= symbol /// public static readonly string greaterEquals = cp437s(0xf2);