/// <summary> /// Initialize the Screen /// </summary> /// <param name="mgr">KSP manager containing game instances</param> /// <param name="cp">Plan of other mods to be added or removed</param> /// <param name="m">The module to display</param> /// <param name="dbg">True if debug options should be available, false otherwise</param> public ModInfoScreen(KSPManager mgr, ChangePlan cp, CkanModule m, bool dbg) { debug = dbg; mod = m; manager = mgr; plan = cp; registry = RegistryManager.Instance(manager.CurrentInstance).registry; int midL = Console.WindowWidth / 2 - 1; AddObject(new ConsoleLabel( 1, 1, -1, () => mod.name == mod.identifier ? mod.name : $"{mod.name} ({mod.identifier})", null, () => ConsoleTheme.Current.ActiveFrameFg )); AddObject(new ConsoleLabel( 1, 2, -1, () => $"By {string.Join(", ", mod.author)}" )); AddObject(new ConsoleFrame( 1, 3, midL, 7, () => "", () => ConsoleTheme.Current.NormalFrameFg, false )); AddObject(new ConsoleLabel( 3, 4, 11, () => "License:", null, () => ConsoleTheme.Current.DimLabelFg )); AddObject(new ConsoleLabel( 13, 4, midL - 2, () => string.Join(", ", Array.ConvertAll <License, string>( mod.license.ToArray(), (l => l.ToString()))) )); AddObject(new ConsoleLabel( 3, 5, 12, () => "Download:", null, () => ConsoleTheme.Current.DimLabelFg )); AddObject(new ConsoleLabel( 13, 5, midL - 2, () => CkanModule.FmtSize(mod.download_size) )); AddObject(new ConsoleLabel( 3, 6, midL - 2, HostedOn )); int depsBot = addDependencies(); int versBot = addVersionDisplay(); AddObject(new ConsoleFrame( 1, Math.Max(depsBot, versBot) + 1, -1, -1, () => "Description", () => ConsoleTheme.Current.NormalFrameFg, false )); ConsoleTextBox tb = new ConsoleTextBox( 3, Math.Max(depsBot, versBot) + 2, -3, -2, false, TextAlign.Left, () => ConsoleTheme.Current.MainBg, () => ConsoleTheme.Current.LabelFg ); tb.AddLine(mod.@abstract); if (!string.IsNullOrEmpty(mod.description) && mod.description != mod.@abstract) { tb.AddLine(mod.description); } AddObject(tb); if (!ChangePlan.IsAnyAvailable(registry, mod.identifier)) { tb.AddLine("\r\nNOTE: This mod is installed but no longer available."); tb.AddLine("If you uninstall it, CKAN will not be able to re-install it."); } tb.AddScrollBindings(this); AddTip("Esc", "Back"); AddBinding(Keys.Escape, (object sender) => false); AddTip("Ctrl+D", "Download", () => !manager.Cache.IsMaybeCachedZip(mod) ); AddBinding(Keys.CtrlD, (object sender) => { Download(); return(true); }); if (mod.resources != null) { List <ConsoleMenuOption> opts = new List <ConsoleMenuOption>(); if (mod.resources.homepage != null) { opts.Add(new ConsoleMenuOption( "Home page", "", "Open the home page URL in a browser", true, () => LaunchURL(mod.resources.homepage) )); } if (mod.resources.repository != null) { opts.Add(new ConsoleMenuOption( "Repository", "", "Open the repository URL in a browser", true, () => LaunchURL(mod.resources.repository) )); } if (mod.resources.bugtracker != null) { opts.Add(new ConsoleMenuOption( "Bugtracker", "", "Open the bug tracker URL in a browser", true, () => LaunchURL(mod.resources.bugtracker) )); } if (mod.resources.spacedock != null) { opts.Add(new ConsoleMenuOption( "SpaceDock", "", "Open the SpaceDock URL in a browser", true, () => LaunchURL(mod.resources.spacedock) )); } if (mod.resources.curse != null) { opts.Add(new ConsoleMenuOption( "Curse", "", "Open the Curse URL in a browser", true, () => LaunchURL(mod.resources.curse) )); } if (debug) { opts.Add(null); opts.Add(new ConsoleMenuOption( "DEBUG: View metadata", "", "Display the full registry data for this mod", true, ViewMetadata )); } if (opts.Count > 0) { mainMenu = new ConsolePopupMenu(opts); } } }