public ConsoleState(Atom a, int layer) : base(a, layer) { for (int i = 0; i < 20; i++) { lines[i] = ""; colors[i] = Color.Green; } AddLine("-----ATOMIC CONSOLE-----"); AddLine("Type 'help' for a list of available commands."); AddLine("Press '~' or type 'close' to close console."); AddLine(""); SetVariable("true", "1"); SetVariable("True", "1"); SetVariable("false", "0"); SetVariable("False", "0"); AddCommand("help", delegate(ConsoleState cl, string[] args) { DisplayHelp(); }, "Display this help file." ); AddCommand("close", delegate(ConsoleState cl, string[] args) { a.stateManager.DropFocus(); }, "Closes the console window." ); AddCommand("exit", delegate(ConsoleState cl, string[] args) { a.Exit(); }, "Forces an exit of the game." ); AddCommand("echo", delegate(ConsoleState cl, string[] args) { int repeat = 1; if (args[1] != null) { if (!int.TryParse(args[1], out repeat)) { AddLine("'" + args[1] + "' is not a valid integer value."); } } for (int i = 0; i < repeat; i++) { AddLine(args[0]); } }, "Prints the value of arg0 to the console window." ); AddCommand("resolution", delegate(ConsoleState cl, string[] args) { int x, y; if (int.TryParse(args[0], out x) && int.TryParse(args[1], out y)) { a.ApplyResolution(x, y, a.fullscreen); } else { AddLine("Dimensions must be integer values."); } }, "Sets the resolution of the window to (arg0, arg1)" ); AddCommand("fullscreen", delegate(ConsoleState cl, string[] args) { if (args[0] == "0" || args[0] == "1") { a.ApplyResolution((int)a.resolution.X, (int)a.resolution.Y, args[0] == "1"); } else { AddLine("Must specify a boolean value"); } }, "Sets the window to fullscreen if arg0 is true, or a window if false." ); AddCommand("clear", delegate(ConsoleState cl, string[] args) { if (args[0] == "#help" || args[0] == null) { AddLine("Usage: clear <option>"); AddLine("Options: #help Show this help text."); AddLine(" #history Clear the command history."); AddLine(" #output Clear the console output window."); } else if (args[0] == "#history") { history.Clear(); history_i = 0; } else if (args[0] == "#output") { for (int i = 0; i < 20; i++) { lines[i] = ""; colors[i] = Color.Green; } } }, "Clears a variety of things. Use clear #help for more info." ); AddCommand("sleep", delegate(ConsoleState cl, string[] args) { if (Int32.TryParse(args[0], out sleepCount)) { sleepCom = "true"; } else { AddLine("Could not sleep. Cycle count must be a valid integer.", Color.Red); } }, "Stops execution of the console window for the amount given amount of cycles in arg0." ); AddCommand("fps", delegate(ConsoleState cl, string[] args) { if (args[0] == "0") a.stateManager.EndState(fpsCount); else { fpsCount = new FPSCounterState(a, layer + 1); a.stateManager.AddState(fpsCount); } }, "Shows or hides the on-screen FPS counter." ); }
public ConsoleState(Atom a, int layer) : base(a, layer) { for (int i = 0; i < 20; i++) { lines[i] = ""; colors[i] = Color.Green; } AddLine("-----ATOMIC CONSOLE-----"); AddLine("Type 'help' for a list of available commands."); AddLine("Press '~' or type 'close' to close console."); AddLine(""); SetVariable("true", "1"); SetVariable("True", "1"); SetVariable("false", "0"); SetVariable("False", "0"); AddCommand("help", delegate(ConsoleState cl, string[] args) { DisplayHelp(); }, "Display this help file." ); AddCommand("close", delegate(ConsoleState cl, string[] args) { a.stateManager.DropFocus(); }, "Closes the console window." ); AddCommand("exit", delegate(ConsoleState cl, string[] args) { a.Exit(); }, "Forces an exit of the game." ); AddCommand("echo", delegate(ConsoleState cl, string[] args) { int repeat = 1; if (args[1] != null) { if (!int.TryParse(args[1], out repeat)) { AddLine("'" + args[1] + "' is not a valid integer value."); } } for (int i = 0; i < repeat; i++) { AddLine(args[0]); } }, "Prints the value of arg0 to the console window." ); AddCommand("resolution", delegate(ConsoleState cl, string[] args) { int x, y; if (int.TryParse(args[0], out x) && int.TryParse(args[1], out y)) { a.ApplyResolution(x, y, a.fullscreen); } else { AddLine("Dimensions must be integer values."); } }, "Sets the resolution of the window to (arg0, arg1)" ); AddCommand("fullscreen", delegate(ConsoleState cl, string[] args) { if (args[0] == "0" || args[0] == "1") { a.ApplyResolution((int)a.resolution.X, (int)a.resolution.Y, args[0] == "1"); } else { AddLine("Must specify a boolean value"); } }, "Sets the window to fullscreen if arg0 is true, or a window if false." ); AddCommand("clear", delegate(ConsoleState cl, string[] args) { if (args[0] == "#help" || args[0] == null) { AddLine("Usage: clear <option>"); AddLine("Options: #help Show this help text."); AddLine(" #history Clear the command history."); AddLine(" #output Clear the console output window."); } else if (args[0] == "#history") { history.Clear(); history_i = 0; } else if (args[0] == "#output") { for (int i = 0; i < 20; i++) { lines[i] = ""; colors[i] = Color.Green; } } }, "Clears a variety of things. Use clear #help for more info." ); AddCommand("sleep", delegate(ConsoleState cl, string[] args) { if (Int32.TryParse(args[0], out sleepCount)) { sleepCom = "true"; } else { AddLine("Could not sleep. Cycle count must be a valid integer.", Color.Red); } }, "Stops execution of the console window for the amount given amount of cycles in arg0." ); AddCommand("fps", delegate(ConsoleState cl, string[] args) { if (args[0] == "0") { a.stateManager.EndState(fpsCount); } else { fpsCount = new FPSCounterState(a, layer + 1); a.stateManager.AddState(fpsCount); } }, "Shows or hides the on-screen FPS counter." ); }