//----------------------------------------------------------------------------- // Description //----------------------------------------------------------------------------- public void ResetDescription() { ISlotItem item = currentSlotGroup.CurrentSlot.SlotItem; description = FormatCodes.FormatString(item != null ? item.Name : ""); textPosition = 0; textTimer = 0; textStart = 0; if (!description.IsEmpty) { if (description.Length % 2 == 1) { description.Add(' '); } if (description.Length == 16) { description.Add(' '); textStart = 0; } else { for (int i = (8 - description.Length / 2); i > 0; i--) { description.Add(' '); } textStart = (16 - description.Length) * 8; } description.AddRange(FormatCodes.FormatString(item.Description)); } }
public void RemoveCodes(int index) { if (!((index > -1) & (index < FormatCode.Length))) { return; } var formatCodesArray = new FormatCodes[FormatCode.Length - 1]; var index1 = 0; for (var index2 = 0; index2 < FormatCode.Length; ++index2) { if (index2 == index) { continue; } formatCodesArray[index1].Assign(FormatCode[index2]); ++index1; } FormatCode = new FormatCodes[formatCodesArray.Length]; for (var index2 = 0; index2 < formatCodesArray.Length; ++index2) { FormatCode[index2].Assign(formatCodesArray[index2]); } }
public void Assign(FormatCodes iFc) { Name = iFc.Name; Notes = iFc.Notes; ColorOn = iFc.ColorOn; ColorOff = iFc.ColorOff; SizeOn = iFc.SizeOn; SizeOff = iFc.SizeOff; BoldOn = iFc.BoldOn; BoldOff = iFc.BoldOff; ItalicOn = iFc.ItalicOn; ItalicOff = iFc.ItalicOff; UnderlineOn = iFc.UnderlineOn; UnderlineOff = iFc.UnderlineOff; Space = iFc.Space; }
// Initializes the game manager. public void Initialize(GameBase gameBase) { this.gameBase = gameBase; elapsedTicks = 0; FormatCodes.Initialize(); Controls.Initialize(); ScreenResized(); AudioSystem.MasterVolume = 0.1f; // Begin the game state stack with a RoomControl. gameStateStack = new GameStateStack(new StateDummy()); gameStateStack.Begin(this); gameControl = new GameControl(this); gameControl.StartGame(); }
public void LoadCodes(string fName) { if (!File.Exists(fName)) { return; } var flag = false; StreamReader reader; try { reader = new StreamReader(fName); } catch (Exception ex) { var num = (int)MessageBox.Show(ex.Message); return; } var num1 = 0; try { var str = reader.ReadLine(); do { ++num1; if (str == "#END#" || str != "#CODE#") { continue; } var index1 = -1; var iFc = new FormatCodes(); flag = GrabString(out iFc.Name, ref reader) | GrabString(out iFc.Notes, ref reader) | GrabString(out iFc.ColorOn, ref reader) | GrabString(out iFc.ColorOff, ref reader) | GrabString(out iFc.SizeOn, ref reader) | GrabString(out iFc.SizeOff, ref reader) | GrabString(out iFc.BoldOn, ref reader) | GrabString(out iFc.BoldOff, ref reader) | GrabString(out iFc.ItalicOn, ref reader) | GrabString(out iFc.ItalicOff, ref reader) | GrabString(out iFc.UnderlineOn, ref reader) | GrabString(out iFc.UnderlineOff, ref reader) | GrabString(out var dest, ref reader); iFc.Space = dest.IndexOf(" ", StringComparison.Ordinal) > -1 ? WhiteSpace.Space : WhiteSpace.Tab; if (!flag) { for (var index2 = 0; index2 < FormatCode.Length; ++index2) { if (FormatCode[index2].Name == iFc.Name) { index1 = index2; } } if (index1 == -1) { Array.Resize(ref FormatCode, FormatCode.Length + 1); index1 = FormatCode.Length - 1; } FormatCode[index1].Assign(iFc); str = reader.ReadLine(); } else { break; } } while (!((str == "#END#") | (num1 > 1024))); if ((num1 > 1024) & !flag) { var num2 = (int)MessageBox.Show( "Nonfatal error reading Forum Code Update. Couldn't find end of file!"); } else if (flag) { var num3 = (int)MessageBox.Show("Nonfatal error reading Forum Code Update."); } } catch (Exception ex) { var num2 = (int)MessageBox.Show(ex.Message); } finally { reader.Close(); } }
// Draws a game string at the specified position public void DrawString(GameFont font, string text, Point2I position, Color color, float depth = 0.0f) { DrawLetterString(font, FormatCodes.FormatString(text), position, color, depth); }
//----------------------------------------------------------------------------- // Strings //----------------------------------------------------------------------------- // Returns the wrapped and formatted string of the text. public WrappedLetterString WrapString(string text, int width) { List <LetterString> lines = new List <LetterString>(); List <int> lineLengths = new List <int>(); int currentLine = 0; int currentCharacter = 0; LetterString word = new LetterString(); int wordStart = 0; int wordLength = 0; int wordLineCount = 0; bool firstChar = true; LetterString letterString = FormatCodes.FormatString(text); while (currentCharacter < letterString.Length) { lines.Add(new LetterString()); lineLengths.Add(0); // Remove starting spaces in the line. while (letterString[currentCharacter].Char == ' ') { currentCharacter++; } wordStart = currentCharacter; word.Clear(); wordLength = 0; wordLineCount = 0; firstChar = true; do { if (currentCharacter >= letterString.Length || letterString[currentCharacter].Char == ' ' || letterString[currentCharacter].Char == FormatCodes.ParagraphCharacter || letterString[currentCharacter].Char == '\n') { if (wordLineCount > 0) { lines[currentLine].Add(' '); } lines[currentLine].AddRange(word); lineLengths[currentLine] += (wordLineCount > 0 ? (characterSpacing + spriteSheet.CellSize.X) : 0) + wordLength; wordLineCount++; wordLength = 0; wordStart = currentCharacter + 1; word.Clear(); if (currentCharacter < letterString.Length && (letterString[currentCharacter].Char == FormatCodes.ParagraphCharacter || letterString[currentCharacter].Char == '\n')) { if (letterString[currentCharacter].Char == FormatCodes.ParagraphCharacter) { lines[currentLine].Add(letterString[currentCharacter]); } currentCharacter++; break; } } else { word.Add(letterString[currentCharacter]); wordLength += (firstChar ? 0 : characterSpacing) + spriteSheet.CellSize.X; firstChar = false; } currentCharacter++; } while (lineLengths[currentLine] + wordLength + characterSpacing + spriteSheet.CellSize.X <= width); currentCharacter = wordStart; currentLine++; } WrappedLetterString wrappedString = new WrappedLetterString(); wrappedString.Lines = lines.ToArray(); wrappedString.LineLengths = lineLengths.ToArray(); wrappedString.Bounds = new Rectangle2I(width, (lines.Count - 1) * lineSpacing + spriteSheet.CellSize.Y); return(wrappedString); }