/// <summary> /// Puts the specified hud behind all other Huds that are managed by /// this HudManager. This function does nothing if the hud is not /// managed by this manager or has been disposed. /// </summary> /// <remarks> /// This function has the side effect of moving all WindowHuds that /// are managed by this HudManager above all other HUDs in Decal, /// but only if the specified hud is not already behind all other /// windows managed by this manager. /// </remarks> /// <param name="hud">The hud to move to the back.</param> /// <param name="forceRecreateHud">Whether to force a recreate of the /// given HUD, even if it is already at the back.</param> public void SendToBack(IManagedHud hud, bool forceRecreateHud) { // Check if the hud is already at the back if (mHudsList.Count > 0 && mHudsList.Last.Value == hud || mHudsOnTopList.Count > 0 && mHudsOnTopList.Last.Value == hud) { if (forceRecreateHud) { RecreateHud(hud); } return; } if (mHudsList.Remove(hud)) { mHudsList.AddLast(hud); RecreateInReverseOrder(mHudsList, true); RecreateInReverseOrder(mHudsOnTopList, false); } else if (mHudsOnTopList.Remove(hud)) { mHudsOnTopList.AddLast(hud); RecreateInReverseOrder(mHudsOnTopList, true); } mHudsListChanged = true; }
/// <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> /// Recreates the specified hud and any huds that are on top of it, to /// maintain Z-ordering. Use this function instead of calling the HUD's /// RecreateHud() function directly. This function does nothing if the /// hud is not managed by this manager or has been disposed. /// </summary> /// <param name="hud">The HUD to recreate.</param> public void RecreateHud(IManagedHud hud) { LinkedListNode <IManagedHud> hudNode; if ((hudNode = mHudsList.Find(hud)) != null) { RecreateInReverseOrder(mHudsList, hudNode); RecreateInReverseOrder(mHudsOnTopList, false); } else if ((hudNode = mHudsOnTopList.Find(hud)) != null) { RecreateInReverseOrder(mHudsOnTopList, hudNode); } }
/// <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; }
/// <summary> /// Checks if the mouse is hovering on this hud and NOT hovering on /// any hud that's on top of the specified hud. /// </summary> /// <remarks> /// This will usually be called during WindowMessageDispatch by a /// hud during a WM_MOUSEMOVE event. Thus, not all huds will have /// been notified that the mouse has moved yet. This is okay because /// all huds on top of this hud WILL have been notified since /// they're notified in Z-order, and the huds that are on top are /// the only huds that matter. /// </remarks> /// <param name="hudToCheck">The hud to check.</param> /// <returns>True if the mouse is hovering on the specified hud and /// NOT hovering on a hud that's on top of the hud.</returns> public bool MouseHoveringOnHud(IManagedHud hudToCheck) { //UpdateHudsListCopy(); if (DefaultViewActive && DefaultView.Position.Contains(mMousePos)) { return(false); } foreach (IManagedHud hud in mHudsListCopy) { if (hud == hudToCheck) { return(hud.MouseHoveringObscuresOther); } else if (hud.MouseHoveringObscuresOther) { return(false); } } return(false); }
/// <summary> /// Removes a hud from the HudManager. It will no longer receive /// GraphicsReset, WindowMessage, or RepaintHeartbeat events. /// </summary> /// <param name="hud">The hud to remove.</param> public void UnregisterHud(IManagedHud hud) { mHudsList.Remove(hud); mHudsOnTopList.Remove(hud); mHudsListChanged = true; }
/// <summary> /// Checks if a Hud is always on top of other huds. /// </summary> /// <param name="hud">The hud to check.</param> /// <returns>True if the specified hud is set to always be on top of /// other huds. This function will return false if the hud is not /// managed by this HudManager.</returns> public bool IsAlwaysOnTop(IManagedHud hud) { return(mHudsOnTopList.Contains(hud)); }
/// <summary> /// Checks if the mouse is hovering on this hud and NOT hovering on /// any hud that's on top of the specified hud. /// </summary> /// <remarks> /// This will usually be called during WindowMessageDispatch by a /// hud during a WM_MOUSEMOVE event. Thus, not all huds will have /// been notified that the mouse has moved yet. This is okay because /// all huds on top of this hud WILL have been notified since /// they're notified in Z-order, and the huds that are on top are /// the only huds that matter. /// </remarks> /// <param name="hudToCheck">The hud to check.</param> /// <returns>True if the mouse is hovering on the specified hud and /// NOT hovering on a hud that's on top of the hud.</returns> public bool MouseHoveringOnHud(IManagedHud hudToCheck) { //UpdateHudsListCopy(); if (DefaultViewActive && DefaultView.Position.Contains(mMousePos)) { return false; } foreach (IManagedHud hud in mHudsListCopy) { if (hud == hudToCheck) { return hud.MouseHoveringObscuresOther; } else if (hud.MouseHoveringObscuresOther) { return false; } } return false; }
/// <summary> /// Recreates the specified hud and any huds that are on top of it, to /// maintain Z-ordering. Use this function instead of calling the HUD's /// RecreateHud() function directly. This function does nothing if the /// hud is not managed by this manager or has been disposed. /// </summary> /// <param name="hud">The HUD to recreate.</param> public void RecreateHud(IManagedHud hud) { LinkedListNode<IManagedHud> hudNode; if ((hudNode = mHudsList.Find(hud)) != null) { RecreateInReverseOrder(mHudsList, hudNode); RecreateInReverseOrder(mHudsOnTopList, false); } else if ((hudNode = mHudsOnTopList.Find(hud)) != null) { RecreateInReverseOrder(mHudsOnTopList, hudNode); } }
/// <summary> /// Checks if a Hud is always on top of other huds. /// </summary> /// <param name="hud">The hud to check.</param> /// <returns>True if the specified hud is set to always be on top of /// other huds. This function will return false if the hud is not /// managed by this HudManager.</returns> public bool IsAlwaysOnTop(IManagedHud hud) { return mHudsOnTopList.Contains(hud); }