Add two customization points for the window system that are executed always and that can control whether the window is drawn without toggling state.

This commit is contained in:
Ottermandias 2022-02-25 14:30:53 +01:00
parent 8fbe8dd213
commit fa4c57c886

View file

@ -121,6 +121,28 @@ namespace Dalamud.Interface.Windowing
this.IsOpen ^= true; this.IsOpen ^= true;
} }
/// <summary>
/// Code to always be executed before the open-state of the window is checked.
/// </summary>
public virtual void PreOpenCheck()
{
}
/// <summary>
/// Additional conditions for the window to be drawn, regardless of its open-state.
/// </summary>
/// <returns>
/// True if the window should be drawn, false otherwise.
/// </returns>
/// <remarks>
/// Not being drawn due to failing this condition will not change focus or trigger OnClose.
/// This is checked before PreDraw, but after Update.
/// </remarks>
public virtual bool DrawConditions()
{
return true;
}
/// <summary> /// <summary>
/// Code to be executed before conditionals are applied and the window is drawn. /// Code to be executed before conditionals are applied and the window is drawn.
/// </summary> /// </summary>
@ -170,6 +192,8 @@ namespace Dalamud.Interface.Windowing
/// </summary> /// </summary>
internal void DrawInternal() internal void DrawInternal()
{ {
this.PreOpenCheck();
if (!this.IsOpen) if (!this.IsOpen)
{ {
if (this.internalIsOpen != this.internalLastIsOpen) if (this.internalIsOpen != this.internalLastIsOpen)
@ -184,6 +208,8 @@ namespace Dalamud.Interface.Windowing
} }
this.Update(); this.Update();
if (!this.DrawConditions())
return;
var hasNamespace = !string.IsNullOrEmpty(this.Namespace); var hasNamespace = !string.IsNullOrEmpty(this.Namespace);