/// <summary> /// Replaces any existing list of text elements for this lineKey with the provided list. If no such list already /// exists, the new textElements list is simply added. /// </summary> /// <param name="lineKey">The line key.</param> /// <param name="textList">The text elements.</param> public void Replace(DebugHudLineKeys lineKey, IColoredTextList textList) { if (_textLine.ContainsKey(lineKey)) { _textLine.Remove(lineKey); } Add(lineKey, textList); }
/// <summary> /// Adds the specified key and text list to this DebugHudText. /// </summary> /// <param name="lineKey">The line key.</param> /// <param name="textList">The text list.</param> /// <exception cref="ArgumentException" >Attempting to add a line key that is already present.</exception> public void Add(DebugHudLineKeys lineKey, IColoredTextList textList) { _textLine.Add(lineKey, textList); D.Log("DebugHudText.Add() called. Content = {0}.", textList.List[0].TextWithEmbeddedColor); //_data[lineKey] = textList; IsDirty = true; }
public void Replace(DebugHudLineKeys lineKey, string text) { Replace(lineKey, new ColoredTextList_String(text)); }
/// <summary> /// Constructs and returns a line of text by taking the base content (determined by the lineKey) and inserting colored elements of text. /// </summary> /// <param name="lineKey">The line key.</param> /// <param name="coloredTextList">The colored text elements.</param> /// <returns></returns> private string ConstructTextLine(DebugHudLineKeys lineKey, IColoredTextList coloredTextList) { IList<string> textElements = new List<string>(); foreach (var ct in coloredTextList.List) { textElements.Add(ct.TextWithEmbeddedColor); //D.Log("ConstructTextLine called. ColoredTextElement = {0}".Inject(ct.TextWithEmbeddedColor)); } string baseText; if (_baseDisplayLineContent.TryGetValue(lineKey, out baseText)) { //D.Log("BaseText = {0}", baseText); //D.Log("Text Elements = {0}", textElements.Concatenate<string>(Constants.Comma)); string colorEmbeddedLineText = baseText.Inject(textElements.ToArray<string>()); return colorEmbeddedLineText; } string warn = "No LineKey {0} found.".Inject(lineKey.GetName()); D.Warn(warn); return warn; }