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: b5e995117de0
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: 7e7135774a94
Choose a head ref
  • 2 commits
  • 8 files changed
  • 2 contributors

Commits on May 17, 2018

  1. Copy the full SHA
    35410c5 View commit details

Commits on May 19, 2018

  1. Copy the full SHA
    7e71357 View commit details
Showing with 21 additions and 20 deletions.
  1. +1 −0 CHANGELOG.md
  2. +7 −7 Cmdline/Main.cs
  3. +1 −1 Cmdline/Options.cs
  4. +2 −2 ConsoleUI/ConsoleCKAN.cs
  5. +4 −3 ConsoleUI/Program.cs
  6. +2 −3 ConsoleUI/SplashScreen.cs
  7. +2 −2 GUI/Main.cs
  8. +2 −2 GUI/Program.cs
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Don't Force Apply button active when no update selected (#2429 by: DasSkelett; reviewed: politas)
- [Core] Improve handling of missing game version (#2444 by: HebaruSan; reviewed: politas)
- [Core] Handle zero byte registry.json file (#2435 by: HebaruSan; reviewed: politas)
- [Multiple] Pass game instance from cmdline to GUI/ConsoleUI (#2449 by: HebaruSan; reviewed: politas)

### Internal
- [Core] Test upgrading mod with conflict on its own provides (#2431 by: HebaruSan; reviewed: politas)
14 changes: 7 additions & 7 deletions Cmdline/Main.cs
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public static int Main(string[] args)
// If we're starting with no options then invoke the GUI instead.
if (args.Length == 0)
{
return Gui(new GuiOptions(), args);
return Gui(null, new GuiOptions(), args);
}

try
@@ -174,10 +174,10 @@ private static int RunSimpleAction(Options cmdline, CommonOptions options, strin
switch (cmdline.action)
{
case "gui":
return Gui((GuiOptions)options, args);
return Gui(manager, (GuiOptions)options, args);

case "consoleui":
return ConsoleUi(options, args);
return ConsoleUi(manager, options, args);

case "prompt":
return new Prompt().RunCommand(manager, cmdline.options);
@@ -243,21 +243,21 @@ private static int printMissingInstanceError(IUser user)
return Exit.ERROR;
}

private static int Gui(GuiOptions options, string[] args)
private static int Gui(KSPManager manager, GuiOptions options, string[] args)
{
// TODO: Sometimes when the GUI exits, we get a System.ArgumentException,
// but trying to catch it here doesn't seem to help. Dunno why.

GUI.Main_(args, options.ShowConsole);
GUI.Main_(args, manager, options.ShowConsole);

return Exit.OK;
}

private static int ConsoleUi(CommonOptions opts, string[] args)
private static int ConsoleUi(KSPManager manager, CommonOptions opts, string[] args)
{
// Debug/verbose output just messes up the screen
LogManager.GetRepository().Threshold = Level.Warn;
return CKAN.ConsoleUI.ConsoleUI.Main_(args, opts.Debug);
return CKAN.ConsoleUI.ConsoleUI.Main_(args, manager, opts.Debug);
}

private static int Version(IUser user)
2 changes: 1 addition & 1 deletion Cmdline/Options.cs
Original file line number Diff line number Diff line change
@@ -441,7 +441,7 @@ internal class GuiOptions : InstanceSpecificOptions
public bool ShowConsole { get; set; }
}

internal class ConsoleUIOptions : CommonOptions { }
internal class ConsoleUIOptions : InstanceSpecificOptions { }

internal class UpdateOptions : InstanceSpecificOptions
{
4 changes: 2 additions & 2 deletions ConsoleUI/ConsoleCKAN.cs
Original file line number Diff line number Diff line change
@@ -13,13 +13,13 @@ public class ConsoleCKAN {
/// Starts with a splash screen, then instance selection if no default,
/// then list of mods.
/// </summary>
public ConsoleCKAN(bool debug)
public ConsoleCKAN(KSPManager mgr, bool debug)
{
// KSPManager only uses its IUser object to construct KSP objects,
// which only use it to inform the user about the creation of the CKAN/ folder.
// These aren't really intended to be displayed, so the manager
// can keep a NullUser reference forever.
KSPManager manager = new KSPManager(new NullUser());
KSPManager manager = mgr ?? new KSPManager(new NullUser());

// The splash screen returns true when it's safe to run the rest of the app.
// This can be blocked by a lock file, for example.
7 changes: 4 additions & 3 deletions ConsoleUI/Program.cs
Original file line number Diff line number Diff line change
@@ -17,23 +17,24 @@ public static class ConsoleUI
[STAThread]
public static void Main(string[] args)
{
Main_(args);
Main_(args, null);
}

/// <summary>
/// Shared entry point for the application, used by real command line
/// and by other parts of CKAN that want to launch the console UI.
/// </summary>
/// <param name="args">Command line arguments</param>
/// <param name="manager">Game instance manager object potentially initialized by command line flags</param>
/// <param name="debug">True if debug options should be available, false otherwise</param>
/// <returns>
/// Process exit status
/// </returns>
public static int Main_(string[] args, bool debug = false)
public static int Main_(string[] args, KSPManager manager, bool debug = false)
{
Logging.Initialize();

new ConsoleCKAN(debug);
new ConsoleCKAN(manager, debug);

// Tell RegistryManager not to throw Dispose-related exceptions at exit
RegistryManager.DisposeAll();
5 changes: 2 additions & 3 deletions ConsoleUI/SplashScreen.cs
Original file line number Diff line number Diff line change
@@ -24,9 +24,8 @@ public SplashScreen(KSPManager mgr)
public bool Run()
{
// If there's a default instance, try to get the lock for it.
if (manager.GetPreferredInstance() != null
&& !KSPListScreen.TryGetInstance(manager.CurrentInstance, () => Draw(false))) {

KSP ksp = manager.CurrentInstance ?? manager.GetPreferredInstance();
if (ksp != null && !KSPListScreen.TryGetInstance(ksp, () => Draw(false))) {
Console.ResetColor();
Console.Clear();
Console.CursorVisible = true;
4 changes: 2 additions & 2 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
@@ -158,10 +158,11 @@ private void ChangeSetUpdated()
}
}

public Main(string[] cmdlineArgs, GUIUser user, bool showConsole)
public Main(string[] cmdlineArgs, KSPManager mgr, GUIUser user, bool showConsole)
{
log.Info("Starting the GUI");
commandLineArgs = cmdlineArgs;
manager = mgr ?? new KSPManager(user);
currentUser = user;

user.displayMessage = AddStatusMessage;
@@ -182,7 +183,6 @@ public Main(string[] cmdlineArgs, GUIUser user, bool showConsole)

// We want to check if our current instance is null first,
// as it may have already been set by a command-line option.
Manager = new KSPManager(user);
if (CurrentInstance == null && manager.GetPreferredInstance() == null)
{
Hide();
4 changes: 2 additions & 2 deletions GUI/Program.cs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public static void Main(string[] args)
Main_(args);
}

public static void Main_(string[] args, bool showConsole = false)
public static void Main_(string[] args, KSPManager manager = null, bool showConsole = false)
{
Logging.Initialize();

@@ -33,7 +33,7 @@ public static void Main_(string[] args, bool showConsole = false)
}
else
{
new Main(args, user, showConsole);
new Main(args, manager, user, showConsole);
}
}