diff --git a/ShiftOS.Frontend/Commands.cs b/ShiftOS.Frontend/Commands.cs index d21e8a9..61f7ed2 100644 --- a/ShiftOS.Frontend/Commands.cs +++ b/ShiftOS.Frontend/Commands.cs @@ -62,12 +62,12 @@ namespace ShiftOS.Frontend { [Command("setsfxenabled", description = "{DESC_SETSFXENABLED}")] - [RequiresArgument("value")] + [RequiresArgument("id")] public static bool SetSfxEnabled(Dictionary args) { try { - bool value = Convert.ToBoolean(args["value"].ToString()); + bool value = Convert.ToBoolean(args["id"].ToString()); SaveSystem.CurrentSave.SoundEnabled = value; SaveSystem.SaveGame(); } @@ -81,12 +81,12 @@ namespace ShiftOS.Frontend [Command("setmusicenabled", description = "{DESC_SETMUSICENABLED}")] - [RequiresArgument("value")] + [RequiresArgument("id")] public static bool SetMusicEnabled(Dictionary args) { try { - bool value = Convert.ToBoolean(args["value"].ToString()); + bool value = Convert.ToBoolean(args["id"].ToString()); SaveSystem.CurrentSave.MusicEnabled = value; SaveSystem.SaveGame(); } @@ -100,10 +100,10 @@ namespace ShiftOS.Frontend [Command("setvolume", description ="{DESC_SETVOLUME}")] - [RequiresArgument("value")] + [RequiresArgument("id")] public static bool SetSfxVolume(Dictionary args) { - int value = int.Parse(args["value"].ToString()); + int value = int.Parse(args["id"].ToString()); if(value >= 0 && value <= 100) { SaveSystem.CurrentSave.MusicVolume = value; @@ -127,14 +127,14 @@ namespace ShiftOS.Frontend } [Command("lang", description = "{DESC_LANG}")] - [RequiresArgument("language")] + [RequiresArgument("id")] public static bool SetLanguage(Dictionary userArgs) { try { string lang = ""; - lang = (string)userArgs["language"]; + lang = (string)userArgs["id"]; if (Localization.GetAllLanguages().Contains(lang)) { @@ -231,14 +231,14 @@ namespace ShiftOS.Frontend public static class ShiftoriumCommands { [Command("buy", description = "{DESC_BUY}")] - [RequiresArgument("upgrade")] + [RequiresArgument("id")] public static bool BuyUpgrade(Dictionary userArgs) { try { string upgrade = ""; - upgrade = (string)userArgs["upgrade"]; + upgrade = (string)userArgs["id"]; var upg = Shiftorium.GetAvailable().FirstOrDefault(x => x.ID == upgrade); if(upg != null) @@ -261,12 +261,12 @@ namespace ShiftOS.Frontend [RequiresUpgrade("shiftorium_bulk_buy")] [Command("bulkbuy", description = "{DESC_BULKBUY}")] - [RequiresArgument("upgrades")] + [RequiresArgument("id")] public static bool BuyBulk(Dictionary args) { - if (args.ContainsKey("upgrades")) + if (args.ContainsKey("id")) { - string[] upgrade_list = (args["upgrades"] as string).Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); + string[] upgrade_list = (args["id"] as string).Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (var upg in upgrade_list) { var dict = new Dictionary(); @@ -279,14 +279,14 @@ namespace ShiftOS.Frontend [Command("upgradeinfo", description ="{DESC_UPGRADEINFO}")] - [RequiresArgument("upgrade")] + [RequiresArgument("id")] public static bool ViewInfo(Dictionary userArgs) { try { string upgrade = ""; - upgrade = (string)userArgs["upgrade"]; + upgrade = (string)userArgs["id"]; foreach (var upg in Shiftorium.GetDefaults()) { @@ -441,14 +441,13 @@ namespace ShiftOS.Frontend } [RemoteLock] - [Command("close", usage = "{win:integer32}", description ="{DESC_CLOSE}")] - [RequiresArgument("win")] - [RequiresUpgrade("close_command")] + [Command("close", description ="{DESC_CLOSE}")] + [RequiresArgument("id")] public static bool CloseWindow(Dictionary args) { int winNum = -1; - if (args.ContainsKey("win")) - winNum = Convert.ToInt32(args["win"].ToString()); + if (args.ContainsKey("id")) + winNum = Convert.ToInt32(args["id"].ToString()); string err = null; if (winNum < 0 || winNum >= AppearanceManager.OpenForms.Count) diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index d56e7bd..bd274cd 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -12,17 +12,6 @@ using System.Windows.Forms; namespace ShiftOS.Engine { - /// - /// Static abstraction layer for the current command parser - /// - public static class CurrentCommandParser - { - /// - /// The current parser - /// - public static CommandParser parser; - } - /// /// Provides functionality for parsing a Terminal command string /// @@ -119,6 +108,8 @@ namespace ShiftOS.Engine int i = 0; string currentArgument = ""; int help = -1; + bool id_found = false; + string id_text = ""; while (position < text.Length) { @@ -131,7 +122,21 @@ namespace ShiftOS.Engine } CommandFormat part = parts[i]; - string res = part.CheckValidity(text.Substring(position)); + string inp = text.Substring(position); + string res = part.CheckValidity(inp); + if(part is CommandFormatText) + { + if(res == "+FALSE+") + { + if(id_found == false) + { + id_found = true; + id_text = inp; + res = ""; + arguments.Add("id", inp); + } + } + } // ok so: @@ -148,8 +153,17 @@ namespace ShiftOS.Engine } else if (part is CommandFormatArgument) { - currentArgument = res; - help = -1; + if (arguments.ContainsKey(res)) + { + Console.WriteLine("Duplicate command-line argument detected: " + res); + command = "+FALSE+"; + position = text.Length; + } + else + { + currentArgument = res; + help = -1; + } } else if (part is CommandFormatValue) {