/// <summary> /// Adds text to the tab. For multi-line text strings, does text wrapping. For text length > 415 pixels, does text wrapping /// </summary> /// <param name="who">Person that spoke</param> /// <param name="text">Message that was spoken</param> /// <param name="icon">Icon to display next to the chat</param> /// <param name="col">Rendering color (enumerated value)</param> public void AddText(string who, string text, ChatIcon icon = ChatIcon.None, ChatColor col = ChatColor.Default) { const int LINE_LEN = 380; //special case: blank line, like in the news panel between news items if (string.IsNullOrWhiteSpace(who) && string.IsNullOrWhiteSpace(text)) { lock (ChatStringsLock) chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), " "); scrollBar.UpdateDimensions(chatStrings.Count); if (chatStrings.Count > 7) { scrollBar.ScrollToEnd(); } if (!Selected) { tabLabel.ForeColor = Color.White; } if (!Visible) { Visible = true; } return; } string whoPadding = " "; //padding string for additional lines if it is a multi-line message if (!string.IsNullOrEmpty(who)) { while (EOGame.Instance.DBGFont.MeasureString(whoPadding).X < EOGame.Instance.DBGFont.MeasureString(who).X) { whoPadding += " "; } } TextSplitter ts = new TextSplitter(text, EOGame.Instance.DBGFont) { LineLength = LINE_LEN, LineEnd = "", LineIndent = whoPadding }; if (!ts.NeedsProcessing) { lock (ChatStringsLock) chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), text); } else { List <string> chatStringsToAdd = ts.SplitIntoLines(); for (int i = 0; i < chatStringsToAdd.Count; ++i) { lock (ChatStringsLock) { if (i == 0) { chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), chatStringsToAdd[0]); } else { chatStrings.Add(new ChatIndex(chatStrings.Count, ChatIcon.None, "", col), chatStringsToAdd[i]); } } } } scrollBar.UpdateDimensions(chatStrings.Count); if (chatStrings.Count > 7) { scrollBar.ScrollToEnd(); } if (!Selected) { tabLabel.ForeColor = Color.White; } if (!Visible) { Visible = true; } }