// Creates a borderless rectangle with text inside. The text size and lining are manually provided. public static List <byte[]> TextBoxSB(string[] args, long cKey) { List <byte[]> result = new List <byte[]>(); RVIVector2 pos = RVIVector2.Parse(args[0]); float w = float.Parse(args[1], CultureInfo.InvariantCulture); float h = float.Parse(args[2], CultureInfo.InvariantCulture); float charScale = float.Parse(args[3], CultureInfo.InvariantCulture); string text = args[4]; RVIVector2 arraypos = new RVIVector2(pos.x + (charScale / 2), pos.y + charScale / 2); result.AddRange(GetBytes(RVIInstructions.ArrayChar(arraypos, charScale, text), cKey)); return(result); }
// Creates a borderless rectangle with text inside.. The text font size and lines of the text are automatically adjusted to the textbox area. public static List <byte[]> TextBoxB(string[] args, long cKey) { List <byte[]> result = new List <byte[]>(); RVIVector2 pos = RVIVector2.Parse(args[0]); float w = float.Parse(args[1], CultureInfo.InvariantCulture); float h = float.Parse(args[2], CultureInfo.InvariantCulture); string text = args[3]; float charScale = 1; const int CharactersPerLineThreshold = 28; bool newLine = false; List <string> lines = new List <string>(); string currentLine = ""; int currentCounter = 0; for (int i = 0; i < text.Length; i++) { currentCounter++; if (currentCounter % CharactersPerLineThreshold == 0 && currentCounter != 0) { newLine = true; } if (text[i] == '·' && newLine) { lines.Add(currentLine); currentLine = ""; newLine = false; currentCounter = 0; } else { currentLine += text[i]; } } lines.Add(currentLine); charScale = w / ((lines.Max(o => o.Length)) + 1); text = ""; foreach (string line in lines) { text += line + "¬"; } if (charScale >= h / 1.5f) { charScale = h / 1.5f; } RVIVector2 arraypos = new RVIVector2(pos.x + (charScale / 2), pos.y + h - charScale * 2); if (lines.Count == 1) { arraypos.y = pos.y + h / 2 - charScale / 2; } result.AddRange(GetBytes(RVIInstructions.ArrayChar(arraypos, charScale, text), cKey)); return(result); }