public override void Init() { X = 5; chatInputText.WordWrap(game.Drawer2D, ref parts, ref partLens, 64); maxWidth = 0; DrawTextArgs args = new DrawTextArgs(null, font, true); for (int i = 0; i < lines; i++) { args.Text = parts[i]; sizes[i] = game.Drawer2D.MeasureChatSize(ref args); maxWidth = Math.Max(maxWidth, sizes[i].Width); } bool supports = game.Network.ServerSupportsPartialMessages; if (chatInputText.Length > 64 && !shownWarning && !supports) { game.Chat.Add("&eNote: Each line will be sent as a separate packet.", MessageType.ClientStatus6); shownWarning = true; } else if (chatInputText.Length <= 64 && shownWarning) { game.Chat.Add(null, MessageType.ClientStatus6); shownWarning = false; } DrawString(); altText.texture.Y1 = game.Height - (YOffset + Height + altText.texture.Height); altText.Y = altText.texture.Y1; CalculateCaretData(); }
public override void Init() { X = 5; chatInputText.WordWrap(ref parts, ref partLens, 64); maxWidth = 0; DrawTextArgs args = new DrawTextArgs(null, font, true); for (int i = 0; i < lines; i++) { args.Text = parts[i]; sizes[i] = game.Drawer2D.MeasureChatSize(ref args); maxWidth = Math.Max(maxWidth, sizes[i].Width); } int realIndex = caretPos; if (chatInputText.Empty || caretPos == -1 || caretPos >= chatInputText.Length) { caretPos = -1; realIndex = 500000; } int sum = 0; indexX = -1; indexY = 0; for (int i = 0; i < lines; i++) { if (partLens[i] == 0) { break; } indexY = i; if (realIndex < sum + partLens[i]) { indexX = realIndex - sum; break; } sum += partLens[i]; } if (indexX == -1) { indexX = partLens[indexY]; } if (indexX == 64) { caretTex.X1 = 10 + sizes[indexY].Width; sizes[indexY].Width += caretTex.Width; maxWidth = Math.Max(maxWidth, sizes[indexY].Width); caretTex.Y1 = sizes[0].Height * indexY; caretCol = FastColour.Yellow; } else { args.Text = parts[indexY].Substring(0, indexX); Size trimmedSize = game.Drawer2D.MeasureChatSize(ref args); caretTex.X1 = 10 + trimmedSize.Width; string line = parts[indexY]; args.Text = indexX < line.Length ? new String(line[indexX], 1) : " "; Size charSize = game.Drawer2D.MeasureChatSize(ref args); caretTex.Width = charSize.Width; caretTex.Y1 = sizes[0].Height * indexY; caretCol = FastColour.White; CalculateCaretCol(); } DrawString(); altText.texture.Y1 = game.Height - (YOffset + Height + altText.texture.Height); altText.Y = altText.texture.Y1; CalculateCaretCol(); }