diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 9221bba..3e00c18 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -248,11 +248,11 @@ namespace ShiftOS.Engine var sb = new StringBuilder(); sb.AppendLine("Retrieving help data."); //print all unique namespaces. - foreach (var n in TerminalBackend.Commands.Select(x => x.CommandInfo).Distinct().OrderBy(x=>x.name)) + foreach (var n in TerminalBackend.Commands.Where(x=>!(x is TerminalBackend.WinOpenCommand) && Shiftorium.UpgradeInstalled(x.Dependencies) && x.CommandInfo.hide == false).OrderBy(x=>x.CommandInfo.name)) { - sb.Append(n.name); + sb.Append(n.CommandInfo.name); if (Shiftorium.UpgradeInstalled("help_descriptions")) - sb.Append(" - " + n.description); + sb.Append(" - " + n.CommandInfo.description); sb.AppendLine(); } @@ -411,7 +411,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); return true; } - [Command("shiftorium", description ="Lists all available Shiftorium upgrades.")] + [Command("upgrades", description ="Lists all available Shiftorium upgrades.")] public static bool ListAll(Dictionary args) { try diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 4594eb3..1ca31e0 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -180,7 +180,7 @@ namespace ShiftOS.Engine public bool RequiresElevation { get; set; } - public void Invoke(Dictionary args) + public virtual void Invoke(Dictionary args) { List errors = new List(); bool requiresAuth = false; @@ -237,6 +237,19 @@ namespace ShiftOS.Engine } } + public class WinOpenCommand : TerminalCommand + { + public Type ShiftOSWindow { get; set; } + + + public override void Invoke(Dictionary args) + { + AppearanceManager.SetupWindow((IShiftOSWindow)Activator.CreateInstance(ShiftOSWindow, null)); + } + + + } + public class MemoryTextWriter : System.IO.TextWriter { public override Encoding Encoding @@ -294,6 +307,27 @@ namespace ShiftOS.Engine Commands = new List(); foreach (var type in ReflectMan.Types) { + if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) + { + var winopenattrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is WinOpenAttribute) as WinOpenAttribute; + if(winopenattrib != null) + { + var winc = new WinOpenCommand(); + winc.CommandType = type; + var rupg = type.GetCustomAttributes().FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; + if (rupg != null) + winc.Dependencies = rupg.Upgrade; + winc.CommandInfo = new Engine.Command(winopenattrib.ID, "", "Opens the \"" + winopenattrib.ID + " program."); + winc.RequiredArguments = new List(); + winc.RequiresElevation = false; + winc.ShiftOSWindow = type; + + var ambiguity = Commands.FirstOrDefault(x => x.CommandInfo.name == winc.CommandInfo.name); + if (ambiguity != null) + throw new Exception("Ambiguity error. The program " + winc.CommandInfo.name + " collides with another program or terminal command with the same name. Please either change the already-existing program/command, or change this one's WinOpenAttribute value to compensate."); + Commands.Add(winc); + } + } foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command);