/// <summary> /// Run the console UI. /// Starts with a splash screen, then instance selection if no default, /// then list of mods. /// </summary> public ConsoleCKAN(GameInstanceManager mgr, bool debug) { // GameInstanceManager only uses its IUser object to construct game instance 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. GameInstanceManager manager = mgr ?? new GameInstanceManager(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. if (new SplashScreen(manager).Run()) { if (manager.CurrentInstance == null) { if (manager.Instances.Count == 0) { // No instances, add one new GameInstanceAddScreen(manager).Run(); // Set instance to current if they added one manager.GetPreferredInstance(); } else { // Multiple instances, no default, pick one new GameInstanceListScreen(manager).Run(); } } if (manager.CurrentInstance != null) { new ModListScreen(manager, debug).Run(); } new ExitScreen().Run(); } }
public static CKAN.GameInstance GetGameInstance(GameInstanceManager manager) { CKAN.GameInstance inst = manager.CurrentInstance ?? manager.GetPreferredInstance(); if (inst == null) { throw new NoGameInstanceKraken(); } return(inst); }
public void GetPreferredInstance_WithEmptyAutoStartAndMultipleInstances_ReturnsNull() { using (var tidy2 = new DisposableKSP()) { cfg.Instances.Add(new Tuple <string, string, string>("tidy2", tidy2.KSP.GameDir(), "KSP")); // Make a new manager with the updated config var multiMgr = new GameInstanceManager(new NullUser(), cfg); multiMgr.ClearAutoStart(); Assert.That(multiMgr.GetPreferredInstance(), Is.Null); multiMgr.Dispose(); } }
/// <summary> /// Run the console UI. /// Starts with a splash screen, then instance selection if no default, /// then list of mods. /// </summary> public ConsoleCKAN(GameInstanceManager mgr, string themeName, bool debug) { if (ConsoleTheme.Themes.TryGetValue(themeName, out ConsoleTheme theme)) { // GameInstanceManager only uses its IUser object to construct game instance 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. GameInstanceManager manager = mgr ?? new GameInstanceManager(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. if (new SplashScreen(manager).Run(theme)) { if (manager.CurrentInstance == null) { if (manager.Instances.Count == 0) { // No instances, add one new GameInstanceAddScreen(manager).Run(theme); // Set instance to current if they added one manager.GetPreferredInstance(); } else { // Multiple instances, no default, pick one new GameInstanceListScreen(manager).Run(theme); } } if (manager.CurrentInstance != null) { new ModListScreen(manager, debug).Run(theme); } new ExitScreen().Run(theme); } } else { Console.WriteLine("No such theme: {0}", themeName); Console.WriteLine("Available themes: {0}", string.Join(", ", ConsoleTheme.Themes.Keys.OrderBy(th => th))); } }
public void GetPreferredInstance_WithAutoStart_ReturnsAutoStart() { Assert.That(manager.GetPreferredInstance(), Is.EqualTo(tidy.KSP)); }