Merge pull request #767 from Ottermandias/WindowExtensions

This commit is contained in:
goaaats 2022-02-25 16:35:12 +01:00 committed by GitHub
commit bbeb188711
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View file

@ -10,8 +10,8 @@ namespace Dalamud
/// <summary>
/// Converts a Dalamud ClientLanguage to the corresponding Lumina variant.
/// </summary>
/// <param name="language">Langauge to convert.</param>
/// <returns>Converted langauge.</returns>
/// <param name="language">Language to convert.</param>
/// <returns>Converted language.</returns>
public static Lumina.Data.Language ToLumina(this ClientLanguage language)
{
return language switch

View file

@ -121,6 +121,28 @@ namespace Dalamud.Interface.Windowing
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>
/// Code to be executed before conditionals are applied and the window is drawn.
/// </summary>
@ -170,6 +192,8 @@ namespace Dalamud.Interface.Windowing
/// </summary>
internal void DrawInternal()
{
this.PreOpenCheck();
if (!this.IsOpen)
{
if (this.internalIsOpen != this.internalLastIsOpen)
@ -184,6 +208,8 @@ namespace Dalamud.Interface.Windowing
}
this.Update();
if (!this.DrawConditions())
return;
var hasNamespace = !string.IsNullOrEmpty(this.Namespace);