/// <inheritdoc /> /// <summary> /// </summary> /// <param name="gametime"></param> public void Update(GameTime gametime) { // load the spriteFont in first update if (!mLoaded) { mLibSans10 = mContentManager.Load <SpriteFont>("LibSans10"); mLoaded = true; } if (mNewEvent) // a new event was added since the last update { // set to null in case there haven't been enough events yet to fill the queue EventLogIWindowItem oldEventToDelete = null; // prepare oldEven for deletion if the event queue is full if (mEventList.Count > 10) { oldEventToDelete = mEventList.Dequeue(); } // send data to UIController -> new event to add + oldest event that is thrown out of the log mUserInterfaceController.UpdateEventLog(mAddedEvent, oldEventToDelete); // reset newEvent bool mNewEvent = false; } }
/// <summary> /// Add a new Event go the GetEventLog /// </summary> /// <param name="eventType">the event's type</param> /// <param name="text">the text to show</param> /// <param name="onThis">the spatial that created this event</param> public void AddEvent(ELogEventType eventType, string text, ISpatial onThis) { // create a new EventLogItem of the event to add if (mLibSans10 == null) { return; } mAddedEvent = new EventLogIWindowItem(eventType, text, 180, mLibSans10, mDirector, onThis); // enqueue to the event's queue mEventList.Enqueue(mAddedEvent); mNewEvent = true; }
/// <summary> /// Updates the eventLog by passing the newest event and the oldest event from the GetEventLog /// </summary> /// <param name="newEvent">event to add to eventLog</param> /// <param name="oldEvent">oldest event to eventually delete</param> internal void UpdateEventLog(EventLogIWindowItem newEvent, EventLogIWindowItem oldEvent) { // if the eventLog exists -> update with new event + possible deletion of oldest event ControlledUserInterface?.UpdateEventLog(newEvent, oldEvent); }