/// <summary> /// Puts the specified hud on top of all other Huds. This function does /// nothing if the hud is not managed by this manager or has been /// disposed. /// </summary> /// <param name="hud">The hud to move to the top.</param> /// <param name="forceRecreateHud">Whether to force a recreate of the /// given HUD, even if it is already at the front.</param> public void BringToFront(IManagedHud hud, bool forceRecreateHud) { // Check if the hud is already on top if (mHudsList.Count > 0 && mHudsList.First.Value == hud || mHudsOnTopList.Count > 0 && mHudsOnTopList.First.Value == hud) { if (forceRecreateHud) { RecreateHud(hud); } return; } if (mHudsList.Remove(hud)) { mHudsList.AddFirst(hud); hud.RecreateHud(); // Recreate the AlwaysOnTop huds to keep them on top of this one RecreateInReverseOrder(mHudsOnTopList, false); } else if (mHudsOnTopList.Remove(hud)) { mHudsOnTopList.AddFirst(hud); hud.RecreateHud(); } mHudsListChanged = true; }
/// <summary> /// Sets a Hud's always on top status. When a hud is always on top, it /// will be painted above all other non-always-on-top huds. /// </summary> /// <param name="hud">The hud to set.</param> /// <param name="alwaysOnTop">Whether the given hud should be always on /// top of other huds.</param> public void SetAlwaysOnTop(IManagedHud hud, bool alwaysOnTop) { if (alwaysOnTop) { if (mHudsList.Remove(hud)) { mHudsOnTopList.AddFirst(hud); hud.RecreateHud(); } } else if (mHudsOnTopList.Remove(hud)) { mHudsList.AddFirst(hud); hud.RecreateHud(); RecreateInReverseOrder(mHudsOnTopList, false); } }
/// <summary> /// Adds a new hud to the HudManager, on top of all other huds. If the /// Hud has been registered with another HudManager, it will be /// unregistered from that manager. The hud will receive GraphicsReset, /// WindowMessage, and RepaintHeartbeat events. /// <para>Calls RecreateHud() on the given hud to make sure that it /// is on top.</para> /// </summary> /// <param name="hud">The hud to add.</param> /// <param name="alwaysOnTop">Indicates if the hud is always on top of /// other huds.</param> public void RegisterHud(IManagedHud hud, bool alwaysOnTop) { if (hud.Manager != null) { hud.Manager.UnregisterHud(hud); } if (alwaysOnTop) { mHudsOnTopList.AddFirst(hud); hud.RecreateHud(); } else { mHudsList.AddFirst(hud); hud.RecreateHud(); RecreateInReverseOrder(mHudsOnTopList, false); } mHudsListChanged = true; }