void SendNormalText(int i, bool partial) { string text = parts[i]; char lastCol = GetLastColour(0, i); if (!IDrawer2D.IsWhiteColour(lastCol)) { text = "&" + lastCol + text; } game.Chat.Send(text, partial); }
void SendNormalText(int i, bool partial) { string text = lines[i]; char lastCol = i == 0 ? 'f' : GetLastColour(0, i); // no previous colour on first line // TODO: this needs to be better, in case second/third line starts with a colour code if (!IDrawer2D.IsWhiteColour(lastCol)) { text = "&" + lastCol + text; } game.Chat.Send(text, partial); }
/// <summary> Remakes the raw texture containg all the chat lines. </summary> /// <remarks> Also updates the dimensions of the widget. </remarks> public virtual void RemakeTexture() { int totalHeight = 0, maxWidth = 0; for (int i = 0; i < MaxLines; i++) { totalHeight += lineSizes[i].Height; maxWidth = Math.Max(maxWidth, lineSizes[i].Width); } Size size = new Size(maxWidth, totalHeight); caretAccumulator = 0; int realHeight = 0; using (Bitmap bmp = IDrawer2D.CreatePow2Bitmap(size)) using (IDrawer2D drawer = game.Drawer2D) { drawer.SetBitmap(bmp); DrawTextArgs args = new DrawTextArgs(null, font, true); if (Prefix != null) { args.Text = Prefix; drawer.DrawText(ref args, 0, 0); } for (int i = 0; i < lines.Length; i++) { if (lines[i] == null) { break; } args.Text = lines[i]; char lastCol = GetLastColour(0, i); if (!IDrawer2D.IsWhiteColour(lastCol)) { args.Text = "&" + lastCol + args.Text; } int offset = i == 0 ? prefixWidth : 0; drawer.DrawText(ref args, offset, realHeight); realHeight += lineSizes[i].Height; } inputTex = drawer.Make2DTexture(bmp, size, 0, 0); } Width = size.Width; Height = realHeight == 0 ? prefixHeight : realHeight; CalculatePosition(); inputTex.X1 = X + Padding; inputTex.Y1 = Y; }
void AddChat(string text) { text = text.TrimEnd().Replace('%', '&'); if (!IDrawer2D.IsWhiteColour(lastCol)) { text = "&" + lastCol + text; } char col = game.Drawer2D.LastColour(text, text.Length); if (col != '\0') { lastCol = col; } game.Chat.Add(text, MessageType.Normal); }
void DrawString() { int totalHeight = 0; for (int i = 0; i < lines; i++) { totalHeight += sizes[i].Height; } Size size = new Size(maxWidth, totalHeight); int realHeight = 0; using (Bitmap bmp = IDrawer2D.CreatePow2Bitmap(size)) using (IDrawer2D drawer = game.Drawer2D) { drawer.SetBitmap(bmp); DrawTextArgs args = new DrawTextArgs("> ", font, true); drawer.DrawChatText(ref args, 0, 0); for (int i = 0; i < parts.Length; i++) { if (parts[i] == null) { break; } args.Text = parts[i]; char lastCol = GetLastColour(0, i); if (!IDrawer2D.IsWhiteColour(lastCol)) { args.Text = "&" + lastCol + args.Text; } int offset = i == 0 ? defaultWidth : 0; drawer.DrawChatText(ref args, offset, realHeight); realHeight += sizes[i].Height; } inputTex = drawer.Make2DTexture(bmp, size, 10, 0); } Height = realHeight == 0 ? defaultHeight : realHeight; Y = game.Height - Height - YOffset; inputTex.Y1 = Y; Width = size.Width; }