public void AddPopup(Popup popup) { lock (Popups) { if (popup.Id == 0) popup.Id = popup.Message.GetHashCode(); var exist = Popups.FirstOrDefault(pop => pop.Id == popup.Id); if (exist != null) Popups.Remove(exist); Popups.Add(popup); } }
public void AddPopup(Popup popup) { lock (Popups) Popups.Add(popup); }
public void AddPopup(Popup popup) { Popups.Add(popup); }
public override void OnTick() { base.OnTick(); if (Username.Equals("gurun")) { Popup popup = new Popup { Duration = 1, MessageType = MessageType.Tip, Message = string.Format("TT: {0}ms AvgTT: {1}ms", Level.LastTickProcessingTime, Level.AvarageTickProcessingTime) }; AddPopup(popup); } bool hasDisplayedPopup = false; bool hasDisplayedTio = false; //if (Level.TickTime%3 == 0) { lock (Popups) { foreach (var popup in Popups.OrderByDescending(p => p.Priority).ThenByDescending(p => p.CurrentTick)) { if (popup.CurrentTick > popup.Duration + popup.DisplayDelay) { Popups.Remove(popup); continue; } if (popup.CurrentTick > popup.DisplayDelay) { if (popup.MessageType == MessageType.Popup && !hasDisplayedPopup) { SendMessage(popup.Message, type: popup.MessageType); hasDisplayedPopup = true; } if (popup.MessageType == MessageType.Tip && !hasDisplayedTio) { SendMessage(popup.Message, type: popup.MessageType); hasDisplayedTio = true; } } popup.CurrentTick++; } } } }