public GameItemInfoScreen() { while (_selIndex != -1) { DeleteSelections(); Clear(); AddSelection("This screen allows the editting of the properties of items that affect the items system.", 0, false); _valueStructs = new List <InputStruct> { GameStructs.BuildInputStruct("Money", "The name of the game's currency.", "Enter the new name.", false, new List <string> { }, InputChecker.OneLineStringCheck), GameStructs.BuildInputStruct("Categories", "All the possible types of items in the game. Every item will fall into one of these categories.", "Enter the new categories. The max length for each is the width of the game minus 2. Use the '|' character to separate categories.", false, new List <string> { }, InputChecker.CategoriesPropertyCheck), GameStructs.BuildInputStruct("Max Stack", "The largest number of one item that can exist in one stack.", "Enter the new max stack. Minimum is 1.", false, new List <string> { }, InputChecker.Min1Max999Check), GameStructs.BuildInputStruct("No Items Text", "Text for when the player tries to the items screen from the game menu when he/she has no items.", "Enter the new text.", false, new List <string> { }, InputChecker.WrappedStringCheck) }; foreach (InputStruct vs in _valueStructs) { AddSelection(Helper.BuildProperty(vs.name, vs.desc, GameFile.ItemInfo [vs.name]), 1, true); } DrawSelections(); GetSelection(true, _selIndex); if (_selIndex != -1) { InputStruct currentStruct = _valueStructs [_selIndex - 1]; int currentLine = _selectionLines [_selIndex] + _selections [_selIndex].Count(); InputGetter.GetInput(currentStruct, GameFile.ItemInfo, currentLine); } } }
public static InputStruct BuildInputStruct(string name, string desc, string instruction, bool canBeEmpty, List <string> selections, InputCheck inputCheck) { InputStruct vs = new InputStruct(); vs.name = name; vs.desc = desc; vs.instruction = instruction; vs.canBeEmpty = canBeEmpty; vs.selections = selections; vs.inputCheck = inputCheck; return(vs); }
public GameGeneralScreen() { while (_selIndex != -1) { DeleteSelections(); Clear(); AddSelection("This screen allows the editting of the overall visuals of the game, they do not affect the actual gameplay.", 0, false); _valueStructs = new List <InputStruct> { GameStructs.BuildInputStruct("Title", "The title of the game", "Enter the new title. Player files are based on the title, meaning a file for \"Mario\" will not work for \"Mario 2\".", false, new List <string> { }, InputChecker.OneLineStringCheck), GameStructs.BuildInputStruct("Description", "The description that will appear when the user is selecting an RPG.", "Enter the new description. It has to be short.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Width", "The width of the window.", "Enter the new width. Minimum width is 30. Maximum width is 76.", false, new List <string> { }, InputChecker.WidthPropertyCheck), GameStructs.BuildInputStruct("Above Height", "The height of the space from the third line to the line above the dialog divider.", "Enter the new height. Minimum height is 10. Maximum height is 16.", false, new List <string> { }, InputChecker.AbovePropertyCheck), GameStructs.BuildInputStruct("Dialog Height", "The height of the space after the dialog divider.", "Enter the new height. Minimum height is 3. Maximum height is 5.", false, new List <string> { }, InputChecker.DialogPropertyCheck), GameStructs.BuildInputStruct("Selection Color", "The color of an enabled selection.", "Enter the new color.", false, Enum.GetNames(typeof(ConsoleColor)).ToList(), InputChecker.ColorPropertyCheck), GameStructs.BuildInputStruct("Current Selection Color", "The color of the current selection.", "Enter the new color.", false, Enum.GetNames(typeof(ConsoleColor)).ToList(), InputChecker.ColorPropertyCheck), GameStructs.BuildInputStruct("Disabled Selection Color", "The color of a disabled selection.", "Enter the new color.", false, Enum.GetNames(typeof(ConsoleColor)).ToList(), InputChecker.ColorPropertyCheck), GameStructs.BuildInputStruct("About", "Text that show up in the About screen", "Enter the new text. Use the '|' character to indicate a new line", false, new List <string> { }, InputChecker.AboutPropertyCheck), }; foreach (InputStruct vs in _valueStructs) { AddSelection(Helper.BuildProperty(vs.name, vs.desc, GameFile.General [vs.name]), 1, true); } DrawSelections(); GetSelection(true, _selIndex); if (_selIndex != -1) { InputStruct currentStruct = _valueStructs [_selIndex - 1]; int currentLine = _selectionLines [_selIndex] + _selections [_selIndex].Count(); InputGetter.GetInput(currentStruct, GameFile.General, currentLine); } } }
public GameUnitInfoScreen() { while (_selIndex != -1) { DeleteSelections(); Clear(); AddSelection("This screen allows the editting of the text and properties that affect the units system.", 0, false); _valueStructs = new List <InputStruct> { GameStructs.BuildInputStruct("Stat Names", "The names of all the stats of a unit.", "Enter the new stat names (Name|Level|HP|Ailment|EXP|Attack|S.Attack|Defense|S.Defense|Speed). Use the '|' character to separate stat names.", false, new List <string> { }, InputChecker.StatNamesPropertyCheck), GameStructs.BuildInputStruct("Stat Descriptions", "The descriptions of all the stats of a unit.", "Enter the new stat descriptions (Level|HP|Ailment|EXP|Attack|S.Attack|Defense|S.Defense|Speed). Use the '|' character to separate stat descriptions.", false, new List <string> { }, InputChecker.StatDescriptionsPropertyCheck), GameStructs.BuildInputStruct("HP Short Name", "The label for HP shown in battles and menus.", "Enter the new name. 3 characters max.", false, new List <string> { }, InputChecker.ShortNameCheck), GameStructs.BuildInputStruct("Level Short Name", "The label for Level shown in battles and menus", "Enter the new name. 3 characters max.", false, new List <string> { }, InputChecker.ShortNameCheck), GameStructs.BuildInputStruct("EXP Short Name", "The label for EXP shown in battles.", "Enter the new name. 3 characters max.", false, new List <string> { }, InputChecker.ShortNameCheck), GameStructs.BuildInputStruct("Max Length of Name", "The maximum length of the name a unit can have.", "Enter the new maximum name length.", false, new List <string> { }, InputChecker.NameLengthPropertyCheck), GameStructs.BuildInputStruct("Minimum Units Required", "The minimum number of units the player must have at all times (currently has no use).", "Enter the new minimum.", false, new List <string> { }, InputChecker.Min0Max999Check), GameStructs.BuildInputStruct("Maximum Possible Units", "The maximum number of units the player can have at a time.", "Enter the new maximum.", false, new List <string> { }, InputChecker.Min1Max999Check), GameStructs.BuildInputStruct("Max Level", "The maximum level a unit can reach.", "Enter the new maximum level.", false, new List <string> { }, InputChecker.Min1Max999Check), GameStructs.BuildInputStruct("Cannot Level Up Text", "Text for when a unit receives exp but cannot level up.", "Enter the new text. The '@' character will be replaced by the unit's name.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Too Few Units Text", "Text for when the player tries to get rid of a unit but doing so would go under the minimum units required (currently has no use).", "Enter the new text (currently has no use).", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Caught Unit Text", "Text for when the player catches a unit.", "Enter the new text. The '@' character will be replaced by the unit's name.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("No Space Text", "Text for when the player catches a unit but already have the maximum number of units possible.", "Enter the new text.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Rename Question", "Text for when the player is asked if he/she wants to rename the newly caught unit.", "Enter the new question. The '@' character will be replaced by the unit's name.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("New Name Before Text", "Text for when the player is renaming the newly caught unit.", "Enter the new text. The '@' character will be replaced by the unit's name.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("New Name After Text", "Text for after the player renamed the newly caught unit.", "Enter the new text. The '@' and '#' characters will be replaced by the unit's old and new name.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("No Units Text", "Text for when the player tries to enter the units screen from the game menu when he/she has no units.", "Enter the new text.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Gain EXP Text", "Text for when a unit gains EXP.", "Enter the new text. The '@' and '#' characters will be replaced by the unit's name and the EXP amount.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Level Up Text", "Text for when a unit levels up.", "Enter the new text. The '@' character will be replaced by the unit's name.", false, new List <string> { }, InputChecker.WrappedStringCheck), GameStructs.BuildInputStruct("Max Moves", "The maximum number of moves a unit can know at a time.", "Enter the new maximum.", false, new List <string> { }, InputChecker.Min1Max999Check), GameStructs.BuildInputStruct("EXP Next Base", "The EXP required for a unit to reach Level 2.", "Enter the new EXP base.", false, new List <string> { }, InputChecker.ExpNextBasePropertyCheck), GameStructs.BuildInputStruct("EXP Next Multiplier", "The multiplier for the EXP required for each level.", "Enter the new EXP multiplier.", false, new List <string> { }, InputChecker.ExpMultiplierCheck), GameStructs.BuildInputStruct("Enemy EXP Multiplier", "The multiplier for the EXP that enemy units give.", "Enter the new EXP multiplier.", false, new List <string> { }, InputChecker.ExpMultiplierCheck), }; foreach (InputStruct vs in _valueStructs) { AddSelection(Helper.BuildProperty(vs.name, vs.desc, GameFile.UnitInfo [vs.name]), 1, true); } DrawSelections(); GetSelection(true, _selIndex); if (_selIndex != -1) { InputStruct currentStruct = _valueStructs [_selIndex - 1]; int currentLine = _selectionLines [_selIndex] + _selections [_selIndex].Count(); InputGetter.GetInput(currentStruct, GameFile.General, currentLine); } } }
public static void GetInput(InputStruct iv, Dictionary <string, string> dict, int firstLine) { List <string> nameDescValue = Helper.BuildProperty(iv.name, iv.desc, dict [iv.name], Data.Width - 2); List <string> instList = Helper.WrapText(iv.instruction, Data.Width - 2, false); DrawBox(nameDescValue, instList, iv.selections, ref firstLine); _errorLine = firstLine + 1 + nameDescValue.Count() + 1 + instList.Count() + 1 + 1 + 1; _newValueLine = firstLine + 1 + nameDescValue.Count() + 1 + instList.Count() + 1; ConsoleKey key = ConsoleKey.Applications; string input = dict [iv.name]; int caretPosition = 0; //The current position of the caret within the input int cursorLeft = 14; //The current column position of the cursor int firstVisibleIndex = 0; //The index of the first visible char of the input DisplayInput(input, firstVisibleIndex, cursorLeft); Console.CursorVisible = true; while (true) { ConsoleKeyInfo keyInfo = Console.ReadKey(true); ClearError(); Console.SetCursorPosition(cursorLeft, _newValueLine); key = keyInfo.Key; List <ConsoleKey> specialKeys = new List <ConsoleKey> { ConsoleKey.Backspace, ConsoleKey.Enter, ConsoleKey.LeftArrow, ConsoleKey.RightArrow, ConsoleKey.Escape, ConsoleKey.Delete }; if (specialKeys.IndexOf(key) == -1) //If the key is one of the allowed characters { input = input.Insert(caretPosition, keyInfo.KeyChar.ToString()); caretPosition++; if (input.Length > Data.Width - 14) //If new input is longer than display { if (Console.CursorLeft == Console.WindowWidth - 4) //If cursor is at end of display { cursorLeft = 15; firstVisibleIndex += Data.Width - 14; } else //If cursor is not at end of display { cursorLeft++; } } else //If new input isn't longer than display { cursorLeft++; } } else if (key == ConsoleKey.Backspace) { if (keyInfo.Modifiers == ConsoleModifiers.Shift) //If shift is pressed { input = ""; //Clear entire input caretPosition = 0; firstVisibleIndex = 0; cursorLeft = 14; } else { if (input.Length > 0 && caretPosition > 0) { input = input.Remove(caretPosition - 1, 1); caretPosition--; if (caretPosition > 1 && cursorLeft == 15) { cursorLeft = Console.WindowWidth - 4; firstVisibleIndex -= Data.Width - 14; firstVisibleIndex = (firstVisibleIndex < 0) ? 0 : firstVisibleIndex; } else { cursorLeft--; } } } } else if (key == ConsoleKey.Delete) { if (input.Length > 0 && caretPosition < input.Length) { input = input.Remove(caretPosition, 1); } } else if (key == ConsoleKey.LeftArrow) { if (caretPosition > 0) //If the caret is not at the start of the input { if (caretPosition > 1 && cursorLeft == 15) //If the caret is at the start of the display { caretPosition--; cursorLeft = Console.WindowWidth - 4; firstVisibleIndex -= Data.Width - 14; firstVisibleIndex = (firstVisibleIndex < 0) ? 0 : firstVisibleIndex; } else //If the caret is not at the start of the display { caretPosition--; cursorLeft--; } } } else if (key == ConsoleKey.RightArrow) { if (cursorLeft == Console.WindowWidth - 4) { if (input.Length > Data.Width - 14) { caretPosition++; cursorLeft = 15; firstVisibleIndex += Data.Width - 14; } } else { if (caretPosition < input.Length) { caretPosition++; cursorLeft++; } } } else if (key == ConsoleKey.Enter) { if (!iv.canBeEmpty && input.Length == 0) { DisplayError("Input cannot be empty."); } else { string inputCheckResult = iv.inputCheck(input); if (inputCheckResult != "good") { DisplayError(inputCheckResult); } else { dict [iv.name] = input; //Set dictionary value break; } } } else if (key == ConsoleKey.Escape) { break; } DisplayInput(input, firstVisibleIndex, cursorLeft); } }