/// <summary> /// Initialize the screen /// </summary> public ModListHelpDialog() : base() { SetDimensions(9, 3, -9, -3); int btnW = 10; int btnL = (Console.WindowWidth - btnW) / 2; ConsoleTextBox symbolTb = new ConsoleTextBox( GetLeft() + 2, GetTop() + 2, Console.WindowWidth / 2 - 1, GetBottom() - 4, false, TextAlign.Center, () => ConsoleTheme.Current.PopupBg, () => ConsoleTheme.Current.PopupFg ); AddObject(symbolTb); 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"); symbolTb.AddLine($"! Unavailable"); symbolTb.AddLine(" "); symbolTb.AddLine("Basic Keys"); symbolTb.AddLine("=========="); symbolTb.AddLine("Tab Move focus"); symbolTb.AddLine("Cursor keys Select row"); symbolTb.AddLine("Escape Clear search"); ConsoleTextBox searchTb = new ConsoleTextBox( Console.WindowWidth / 2 + 1, GetTop() + 3, GetRight() - 2, GetBottom() - 4, false, TextAlign.Center, () => ConsoleTheme.Current.PopupBg, () => ConsoleTheme.Current.PopupFg ); AddObject(searchTb); searchTb.AddLine("Special Searches"); searchTb.AddLine("================"); searchTb.AddLine("@author Mods by author"); searchTb.AddLine("~i Installed mods"); searchTb.AddLine("~u Upgradeable mods"); searchTb.AddLine("~dname Depend on name"); searchTb.AddLine("~cname Conflict w/ name"); searchTb.AddLine("~n New mods"); AddObject(new ConsoleButton( btnL, GetBottom() - 2, btnL + btnW - 1, "OK", Quit )); }
private int addDependencies(int top = 8) { int numDeps = mod.depends?.Count ?? 0; int numConfs = mod.conflicts?.Count ?? 0; if (numDeps + numConfs > 0) { int midL = Console.WindowWidth / 2 - 1; int h = Math.Min(11, numDeps + numConfs + 2); const int lblW = 16; int nameW = midL - 2 - lblW - 2; AddObject(new ConsoleFrame( 1, top, midL, top + h - 1, () => "Dependencies", () => ConsoleTheme.Current.NormalFrameFg, false )); if (numDeps > 0) { AddObject(new ConsoleLabel( 3, top + 1, 3 + lblW - 1, () => $"Required ({numDeps}):", null, () => ConsoleTheme.Current.DimLabelFg )); ConsoleTextBox tb = new ConsoleTextBox( 3 + lblW, top + 1, midL - 2, top + 1 + numDeps - 1, false, TextAlign.Left, () => ConsoleTheme.Current.MainBg, () => ConsoleTheme.Current.LabelFg ); AddObject(tb); foreach (RelationshipDescriptor rd in mod.depends) { tb.AddLine(ScreenObject.FormatExactWidth( // Show install status ModListScreen.StatusSymbol(plan.GetModStatus(manager, registry, rd.ToString())) + rd.ToString(), nameW )); } } if (numConfs > 0) { AddObject(new ConsoleLabel( 3, top + 1 + numDeps, 3 + lblW - 1, () => $"Conflicts ({numConfs}):", null, () => ConsoleTheme.Current.DimLabelFg )); ConsoleTextBox tb = new ConsoleTextBox( 3 + lblW, top + 1 + numDeps, midL - 2, top + h - 2, false, TextAlign.Left, () => ConsoleTheme.Current.MainBg, () => ConsoleTheme.Current.LabelFg ); AddObject(tb); // FUTURE: Find mods that conflict with this one // See GUI/MainModList.cs::ComputeConflictsFromModList foreach (RelationshipDescriptor rd in mod.conflicts) { tb.AddLine(ScreenObject.FormatExactWidth( // Show install status ModListScreen.StatusSymbol(plan.GetModStatus(manager, registry, rd.ToString())) + rd.ToString(), nameW )); } } return(top + h - 1); } return(top - 1); }
/// <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); } } }