public Hotkey(string name, KeyCode key, DebugCommandHandler.CommandInfo commandToRun = null, string[] commandArgs = null) { this.name = name; this.key = key; this.commandToRun = commandToRun; this.commandArgs = commandArgs; }
private string GetListOfCommands() { string output = string.Empty; List <DebugCommandHandler.CommandInfo> allCommands = DebugCommandHandler.Instance.allCommands; for (int i = 0; i < allCommands.Count; i++) { DebugCommandHandler.CommandInfo command = allCommands[i]; // If is dev command, only output if is dev build if (command.isDevOnly) { if (!VersionHelper.IsDevBuild) { continue; } } output += command.nameOfCommand; if (i < allCommands.Count - 1) { output += ", "; } } return(output); }
private string GetHelpForCommand(string arg) { DebugCommandHandler.CommandInfo command = DebugCommandHandler.Instance.GetCommand(arg); // Get command // If valid command if (command != null) { return(command.activationMethod.Method.DeclaringType.GetMethod("GetHelp").Invoke(null, null).ToString()); } // If invalid command return("<in>" + arg + "</in> is not a command. Use <out>help</out> to get list of commands"); }
void ParseResultString(string input) { string[] words = input.Split(new char[] { ' ' }); // Split input into separate words. Words[0] is the command, every word after is an argument // Check if command given if (words.Length > 0) { string command = words[0]; // Get command name DebugCommandHandler.CommandInfo commandToRun = DebugCommandHandler.Instance.GetCommand(command); // Get command // If command is valid if (commandToRun != null) { string[] arguments = words.Skip(1).ToArray(); // Get command arguments // Run command OutputText(DebugManager.LogToConsole(commandToRun.activationMethod(arguments))); // Debug output string output = "[Debug Console] Running command: '" + commandToRun.nameOfCommand + "' with " + arguments.Length + " argument(s)"; if (arguments.Length > 0) { output += "\n"; } for (int j = 0; j < arguments.Length; j++) { output += "Arg[" + j + "]: " + arguments[j]; if (j < arguments.Length - 1) { output += "\n"; } } DebugManager.LogToFile(output, LogType.Log, false); } // If command is not valid else { string output = "<in>" + command + "</in> is not a command. Use <out>help</out> to get list of commands"; OutputText(DebugManager.LogToConsole(output, DebugManager.MessageType.Error)); } // Format output TextMesh outputTextMesh = transform.Find("InfoValue").GetChild(0).GetComponent <TextMesh>(); outputTextMesh.text = ModStuff.UI.UIText.AddLineBreaks(outputTextMesh.text, outputTextMesh); } }