Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: KSP-CKAN/CKAN
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c49489b061f9
Choose a base ref
...
head repository: KSP-CKAN/CKAN
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 58a3bfded560
Choose a head ref
  • 2 commits
  • 9 files changed
  • 2 contributors

Commits on Jan 24, 2019

  1. Copy the full SHA
    69a8ff7 View commit details

Commits on Jan 27, 2019

  1. Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    58a3bfd View commit details
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Set focus to mod list after loading (#2657 by: HebaruSan; reviewed: politas)
- [GUI] Small text/number formatting changes to mod list (#2658 by: DasSkelett; reviewed: politas)
- [Multiple] Remove ConfirmPrompt from IUser (#2659 by: HebaruSan; reviewed: politas)
- [ConsoleUI] Handle manually installed mods in ConsoleUI (#2666 by: HebaruSan; reviewed: politas)

## v1.25.4 Kennedy

@@ -519,7 +520,7 @@ All notable changes to this project will be documented in this file.

### Features

- [GUI] The CKAN Identifer for each mod is now shown in their metadata panel. (plague006, #1476)
- [GUI] The CKAN Identifier for each mod is now shown in their metadata panel. (plague006, #1476)
- [GUI] Double-clicking on a filename in the 'Contents' panel now opens the directory containing that file. (Postremus, #1443)
- [GUI] The progress bar now shows the progress of downloading to the cache. (Postremus, #1445)
- [GUI] Mods can now be searched by their CKAN identifier in the name textbox (Postremus, #1475)
23 changes: 12 additions & 11 deletions ConsoleUI/ModInfoScreen.cs
Original file line number Diff line number Diff line change
@@ -297,9 +297,10 @@ private int addDependencies(int top = 8)
return top - 1;
}

private DateTime InstalledOn(string identifier)
private DateTime? InstalledOn(string identifier)
{
return registry.InstalledModule(identifier).InstallTime;
// This can be null for manually installed mods
return registry.InstalledModule(identifier)?.InstallTime;
}

private int addVersionDisplay()
@@ -323,13 +324,13 @@ private int addVersionDisplay()

if (installed) {

DateTime instTime = InstalledOn(mod.identifier);
DateTime? instTime = InstalledOn(mod.identifier);

if (latestIsInstalled) {

addVersionBox(
boxLeft, boxTop, boxRight, boxTop + boxH - 1,
() => $"Latest/Installed {instTime.ToString("d")}",
() => $"Latest/Installed {instTime?.ToString("d") ?? "manually"}",
() => ConsoleTheme.Current.ActiveFrameFg,
true,
new List<CkanModule>() {inst}
@@ -349,7 +350,7 @@ private int addVersionDisplay()

addVersionBox(
boxLeft, boxTop, boxRight, boxTop + boxH - 1,
() => $"Installed {instTime.ToString("d")}",
() => $"Installed {instTime?.ToString("d") ?? "manually"}",
() => ConsoleTheme.Current.ActiveFrameFg,
true,
new List<CkanModule>() {inst}
@@ -385,12 +386,12 @@ private int addVersionDisplay()

} else {

DateTime instTime = InstalledOn(mod.identifier);
DateTime? instTime = InstalledOn(mod.identifier);
// Mod is no longer indexed, but we can generate a display
// of the old info about it from when we installed it
addVersionBox(
boxLeft, boxTop, boxRight, boxTop + boxH - 1,
() => $"UNAVAILABLE/Installed {instTime.ToString("d")}",
() => $"UNAVAILABLE/Installed {instTime?.ToString("d") ?? "manually"}",
() => ConsoleTheme.Current.AlertFrameFg,
true,
new List<CkanModule>() {mod}
@@ -413,14 +414,14 @@ private void addVersionBox(int l, int t, int r, int b, Func<string> title, Func<

if (releases != null && releases.Count > 0) {

ModuleVersion minMod = null, maxMod = null;
KspVersion minKsp = null, maxKsp = null;
ModuleVersion minMod = null, maxMod = null;
KspVersion minKsp = null, maxKsp = null;
Registry.GetMinMaxVersions(releases, out minMod, out maxMod, out minKsp, out maxKsp);
AddObject(new ConsoleLabel(
l + 2, t + 1, r - 2,
() => minMod == maxMod
? $"{ModuleInstaller.WithAndWithoutEpoch(minMod.ToString())}"
: $"{ModuleInstaller.WithAndWithoutEpoch(minMod.ToString())} - {ModuleInstaller.WithAndWithoutEpoch(maxMod.ToString())}",
? $"{ModuleInstaller.WithAndWithoutEpoch(minMod?.ToString() ?? "???")}"
: $"{ModuleInstaller.WithAndWithoutEpoch(minMod?.ToString() ?? "???")} - {ModuleInstaller.WithAndWithoutEpoch(maxMod?.ToString() ?? "???")}",
null,
color
));
8 changes: 5 additions & 3 deletions ConsoleUI/ModListHelpDialog.cs
Original file line number Diff line number Diff line change
@@ -29,9 +29,10 @@ public ModListHelpDialog() : base()
AddObject(symbolTb);
symbolTb.AddLine("Status Symbols");
symbolTb.AddLine("==============");
symbolTb.AddLine($"{installed} Installed");
symbolTb.AddLine($"{upgradable} Upgradeable");
symbolTb.AddLine($"! Unavailable");
symbolTb.AddLine($"{installed} Installed");
symbolTb.AddLine($"{upgradable} Upgradeable");
symbolTb.AddLine($"{autodetected} Manually installed");
symbolTb.AddLine($"! Unavailable");
symbolTb.AddLine(" ");
symbolTb.AddLine("Basic Keys");
symbolTb.AddLine("==========");
@@ -65,6 +66,7 @@ public ModListHelpDialog() : base()

private static readonly string installed = Symbols.checkmark;
private static readonly string upgradable = Symbols.greaterEquals;
private static readonly string autodetected = Symbols.infinity;
}

}
18 changes: 15 additions & 3 deletions ConsoleUI/ModListScreen.cs
Original file line number Diff line number Diff line change
@@ -185,10 +185,13 @@ public ModListScreen(KSPManager mgr, bool dbg)

moduleList.AddTip("-", "Remove",
() => moduleList.Selection != null
&& (registry.IsInstalled(moduleList.Selection.identifier, false))
&& registry.IsInstalled(moduleList.Selection.identifier, false)
&& !registry.IsAutodetected(moduleList.Selection.identifier)
);
moduleList.AddBinding(Keys.Minus, (object sender) => {
if (moduleList.Selection != null && registry.IsInstalled(moduleList.Selection.identifier, false)) {
if (moduleList.Selection != null
&& registry.IsInstalled(moduleList.Selection.identifier, false)
&& !registry.IsAutodetected(moduleList.Selection.identifier)) {
plan.ToggleRemove(moduleList.Selection);
}
return true;
@@ -547,6 +550,7 @@ public static string StatusSymbol(InstallStatus st)
case InstallStatus.Installed: return installed;
case InstallStatus.Installing: return installing;
case InstallStatus.NotInstalled: return notinstalled;
case InstallStatus.AutoDetected: return autodetected;
default: return "";
}
}
@@ -581,6 +585,7 @@ private long totalInstalledDownloadSize()
private static readonly string upgradable = Symbols.greaterEquals;
private static readonly string upgrading = "^";
private static readonly string removing = "-";
private static readonly string autodetected = Symbols.infinity;
}

/// <summary>
@@ -659,7 +664,9 @@ public void Reset()
public InstallStatus GetModStatus(KSPManager manager, IRegistryQuerier registry, string identifier)
{
if (registry.IsInstalled(identifier, false)) {
if (Remove.Contains(identifier)) {
if (registry.IsAutodetected(identifier)) {
return InstallStatus.AutoDetected;
} else if (Remove.Contains(identifier)) {
return InstallStatus.Removing;
} else if (registry.HasUpdate(identifier, manager.CurrentInstance.VersionCriteria())) {
if (Upgrade.Contains(identifier)) {
@@ -789,5 +796,10 @@ public enum InstallStatus {
/// This mod is installed and we are planning to upgrade it
/// </summary>
Upgrading,

/// <summary>
/// This mod was installed manually
/// </summary>
AutoDetected,
};
}
4 changes: 4 additions & 0 deletions ConsoleUI/Toolkit/Symbols.cs
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ public static class Symbols {
/// >= symbol
/// </summary>
public static readonly string greaterEquals = cp437s(0xf2);
/// <summary>
/// Infinity symbol
/// </summary>
public static readonly string infinity = cp437s(0xec);

/// <summary>
/// Hashed square box for drawing scrollbars
2 changes: 1 addition & 1 deletion Core/Registry/IRegistryQuerier.cs
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ public interface IRegistryQuerier
/// Gets the installed version of a mod. Does not check for provided or autodetected mods.
/// </summary>
/// <returns>The module or null if not found</returns>
CkanModule GetInstalledVersion(string identifer);
CkanModule GetInstalledVersion(string identifier);

/// <summary>
/// Attempts to find a module with the given identifier and version.
23 changes: 14 additions & 9 deletions Core/Registry/Registry.cs
Original file line number Diff line number Diff line change
@@ -633,24 +633,29 @@ public KspVersion LatestCompatibleKSP(string identifier)
/// <param name="minKsp">Return parameter for the lowest game version</param>
/// <param name="maxKsp">Return parameter for the highest game version</param>
public static void GetMinMaxVersions(IEnumerable<CkanModule> modVersions,
out ModuleVersion minMod, out ModuleVersion maxMod,
out KspVersion minKsp, out KspVersion maxKsp)
out ModuleVersion minMod, out ModuleVersion maxMod,
out KspVersion minKsp, out KspVersion maxKsp)
{
minMod = maxMod = null;
minKsp = maxKsp = null;
foreach (CkanModule rel in modVersions) {
if (minMod == null || minMod > rel.version) {
foreach (CkanModule rel in modVersions.Where(v => v != null))
{
if (minMod == null || minMod > rel.version)
{
minMod = rel.version;
}
if (maxMod == null || maxMod < rel.version) {
if (maxMod == null || maxMod < rel.version)
{
maxMod = rel.version;
}
KspVersion relMin = rel.EarliestCompatibleKSP();
KspVersion relMax = rel.LatestCompatibleKSP();
if (minKsp == null || !minKsp.IsAny && (minKsp > relMin || relMin.IsAny)) {
if (minKsp == null || !minKsp.IsAny && (minKsp > relMin || relMin.IsAny))
{
minKsp = relMin;
}
if (maxKsp == null || !maxKsp.IsAny && (maxKsp < relMax || relMax.IsAny)) {
if (maxKsp == null || !maxKsp.IsAny && (maxKsp < relMax || relMax.IsAny))
{
maxKsp = relMax;
}
}
@@ -1010,10 +1015,10 @@ public ModuleVersion InstalledVersion(string modIdentifier, bool with_provides=t
/// <summary>
/// <see cref = "IRegistryQuerier.GetInstalledVersion" />
/// </summary>
public CkanModule GetInstalledVersion(string mod_identifer)
public CkanModule GetInstalledVersion(string mod_identifier)
{
InstalledModule installedModule;
return installed_modules.TryGetValue(mod_identifer, out installedModule)
return installed_modules.TryGetValue(mod_identifier, out installedModule)
? installedModule.Module
: null;
}
2 changes: 1 addition & 1 deletion Core/Types/ModuleInstallDescriptor.cs
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ public object Clone()
}

/// <summary>
/// Returns a default install stanza for the identifer provided.
/// Returns a default install stanza for the identifier provided.
/// </summary>
public static ModuleInstallDescriptor DefaultInstallStanza(string ident, ZipFile zipfile)
{
4 changes: 3 additions & 1 deletion Core/Versioning/KspVersionRange.cs
Original file line number Diff line number Diff line change
@@ -86,7 +86,9 @@ private static string DeriveString(KspVersionRange versionRange)

private static string SameVersionString(KspVersion v)
{
return v.IsAny ? "all versions" : v.ToString();
return v == null ? "???"
: v.IsAny ? "all versions"
: v.ToString();
}

/// <summary>