Revert "Respect fadein/out for Window.DrawConditions() and Window.IsOpen"

This reverts commit c33a5346b1.
This commit is contained in:
goaaats 2025-05-10 19:31:06 +02:00
parent c33a5346b1
commit 421d8cee3b

View file

@ -41,10 +41,6 @@ public abstract class Window
private bool internalLastIsOpen = false; private bool internalLastIsOpen = false;
private bool internalIsOpen = false; private bool internalIsOpen = false;
private bool internalWantsToClose = false;
private bool internalLastDrawConditions = true;
private bool internalDrawConditions = true;
private bool internalIsPinned = false; private bool internalIsPinned = false;
private bool internalIsClickthrough = false; private bool internalIsClickthrough = false;
private bool didPushInternalAlpha = false; private bool didPushInternalAlpha = false;
@ -233,18 +229,7 @@ public abstract class Window
public bool IsOpen public bool IsOpen
{ {
get => this.internalIsOpen; get => this.internalIsOpen;
set set => this.internalIsOpen = value;
{
if (!value && this.internalIsOpen)
{
this.internalWantsToClose = true;
}
else if (value && !this.internalIsOpen)
{
this.internalWantsToClose = false;
this.internalIsOpen = true;
}
}
} }
private bool CanShowCloseButton => this.ShowCloseButton && !this.internalIsClickthrough; private bool CanShowCloseButton => this.ShowCloseButton && !this.internalIsClickthrough;
@ -375,7 +360,22 @@ public abstract class Window
UIGlobals.PlaySoundEffect(this.OnCloseSfxId); UIGlobals.PlaySoundEffect(this.OnCloseSfxId);
} }
DrawFadeOut(); if (this.fadeOutTexture != null)
{
this.fadeOutTimer -= ImGui.GetIO().DeltaTime;
if (this.fadeOutTimer <= 0f)
{
this.fadeOutTexture.Dispose();
this.fadeOutTexture = null;
this.OnSafeToRemove();
}
else
{
this.DrawFakeFadeOutWindow();
}
}
this.fadeInTimer = doFades ? 0f : FadeInOutTime;
return; return;
} }
@ -384,15 +384,8 @@ public abstract class Window
this.fadeInTimer = FadeInOutTime; this.fadeInTimer = FadeInOutTime;
this.Update(); this.Update();
this.internalDrawConditions = this.DrawConditions(); if (!this.DrawConditions())
if (this.internalDrawConditions == this.internalLastDrawConditions && !this.internalDrawConditions)
{
DrawFadeOut();
return; return;
}
if (this.internalDrawConditions)
this.internalLastDrawConditions = this.internalDrawConditions;
var hasNamespace = !string.IsNullOrEmpty(this.Namespace); var hasNamespace = !string.IsNullOrEmpty(this.Namespace);
@ -614,21 +607,12 @@ public abstract class Window
this.pushedFadeInAlpha = false; this.pushedFadeInAlpha = false;
} }
if (this.internalDrawConditions != this.internalLastDrawConditions && !this.internalDrawConditions) if (!this.internalIsOpen && this.fadeOutTexture == null && doFades)
{ {
this.internalLastDrawConditions = this.internalDrawConditions; this.fadeOutTexture = Service<TextureManager>.Get().CreateDrawListTexture(
SetupFadeOut(); "WindowFadeOutTexture");
} this.fadeOutTexture.ResizeAndDrawWindow(this.WindowName, Vector2.One);
this.fadeOutTimer = FadeInOutTime;
if (this.internalWantsToClose)
{
this.internalIsOpen = false;
this.internalWantsToClose = false;
}
if (!this.internalIsOpen)
{
SetupFadeOut();
} }
if (printWindow) if (printWindow)
@ -648,38 +632,6 @@ public abstract class Window
if (hasNamespace) if (hasNamespace)
ImGui.PopID(); ImGui.PopID();
return;
void SetupFadeOut()
{
if (this.fadeOutTexture == null && doFades)
{
this.fadeOutTexture = Service<TextureManager>.Get().CreateDrawListTexture(
"WindowFadeOutTexture");
this.fadeOutTexture.ResizeAndDrawWindow(this.WindowName, Vector2.One);
this.fadeOutTimer = FadeInOutTime;
}
}
void DrawFadeOut()
{
if (this.fadeOutTexture != null)
{
this.fadeOutTimer -= ImGui.GetIO().DeltaTime;
if (this.fadeOutTimer <= 0f)
{
this.fadeOutTexture.Dispose();
this.fadeOutTexture = null;
this.OnSafeToRemove();
}
else
{
this.DrawFakeFadeOutWindow();
}
}
this.fadeInTimer = doFades ? 0f : FadeInOutTime;
}
} }
private unsafe void ApplyConditionals() private unsafe void ApplyConditionals()