public Overhead AddOverhead(MessageTypes msgType, string text, int fontID, int hue, bool asUnicode) { Overhead overhead; text = string.Format("<outline style='font-family: {2}{0};'>{1}", fontID, text, asUnicode ? "uni" : "ascii"); for (var i = 0; i < _overheads.Count; i++) { overhead = _overheads[i]; // is this overhead an already active label? if (msgType == MessageTypes.Label && overhead.Text == text && overhead.MessageType == msgType && !overhead.IsDisposed) { // reset the timer for the object so it lasts longer. overhead.ResetTimer(); // update hue? overhead.Hue = hue; // insert it at the bottom of the queue so it displays closest to the player. _overheads.RemoveAt(i); InternalInsertOverhead(overhead); return(overhead); } } overhead = new Overhead(this, msgType, text); overhead.Hue = hue; InternalInsertOverhead(overhead); return(overhead); }
void InternalInsertOverhead(Overhead overhead) { if (_overheads.Count == 0 || _overheads[0].MessageType != MessageTypes.Label) { _overheads.Insert(0, overhead); } else { _overheads.Insert(1, overhead); } }