Skip to content

Commit

Permalink
Show and edit auto-install flag in ConsoleUI
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed May 7, 2019
1 parent 5fa1603 commit f4c1c4a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 25 deletions.
10 changes: 6 additions & 4 deletions ConsoleUI/ModListHelpDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

}
68 changes: 47 additions & 21 deletions ConsoleUI/ModListScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 "";
}
}

Expand All @@ -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;
}

/// <summary>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -813,6 +834,11 @@ public enum InstallStatus {
/// This mod is installed and not upgradeable or planned to be removed
/// </summary>
Installed,

/// <summary>
/// Like Installed, but can be auto-removed if depending mods are removed
/// </summary>
AutoInstalled,

/// <summary>
/// This mod is not installed but we are planning to install it
Expand Down
7 changes: 7 additions & 0 deletions ConsoleUI/Toolkit/Keys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public static class Keys {
(System.Char)0, ConsoleKey.F5, false, false, false
);

/// <summary>
/// Representation of F8 for key bindings
/// </summary>
public static readonly ConsoleKeyInfo F8 = new ConsoleKeyInfo(
(System.Char)0, ConsoleKey.F8, false, false, false
);

/// <summary>
/// Representation of F9 for key bindings
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions ConsoleUI/Toolkit/Symbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public static class Symbols {
/// </summary>
public static readonly string checkmark = cp437s(0xfb);
/// <summary>
/// Double tilde
/// </summary>
public static readonly string feminineOrdinal = cp437s(0xa6);
/// <summary>
/// >= symbol
/// </summary>
public static readonly string greaterEquals = cp437s(0xf2);
Expand Down

0 comments on commit f4c1c4a

Please sign in to comment.