Force style vars so erroring window renders at least partially sanely

This commit is contained in:
MidoriKami 2025-11-27 15:52:18 -08:00
parent 02e0f1d36c
commit 2a60bc61a7

View file

@ -57,6 +57,7 @@ public abstract class Window
private bool hasError = false; private bool hasError = false;
private Exception? lastError; private Exception? lastError;
private bool isErrorStylePushed;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Window"/> class. /// Initializes a new instance of the <see cref="Window"/> class.
@ -425,8 +426,16 @@ public abstract class Window
UIGlobals.PlaySoundEffect(this.OnOpenSfxId); UIGlobals.PlaySoundEffect(this.OnOpenSfxId);
} }
if (!this.hasError)
{
this.PreDraw(); this.PreDraw();
this.ApplyConditionals(); this.ApplyConditionals();
}
else
{
Style.StyleModelV1.DalamudStandard.Push();
this.isErrorStylePushed = true;
}
if (this.ForceMainWindow) if (this.ForceMainWindow)
ImGuiHelpers.ForceNextWindowMainViewport(); ImGuiHelpers.ForceNextWindowMainViewport();
@ -448,10 +457,28 @@ public abstract class Window
var flags = this.Flags; var flags = this.Flags;
if (this.internalIsPinned || this.internalIsClickthrough) if (this.internalIsPinned || this.internalIsClickthrough)
{
if (!this.hasError)
{
flags |= ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize; flags |= ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize;
}
else
{
flags &= ~(ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize);
}
}
if (this.internalIsClickthrough) if (this.internalIsClickthrough)
{
if (!this.hasError)
{
flags |= ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoMouseInputs; flags |= ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoMouseInputs;
}
else
{
flags &= ~(ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoMouseInputs);
}
}
if (this.CanShowCloseButton ? ImGui.Begin(this.WindowName, ref this.internalIsOpen, flags) : ImGui.Begin(this.WindowName, flags)) if (this.CanShowCloseButton ? ImGui.Begin(this.WindowName, ref this.internalIsOpen, flags) : ImGui.Begin(this.WindowName, flags))
{ {
@ -670,7 +697,17 @@ public abstract class Window
Task.FromResult<IDalamudTextureWrap>(tex)); Task.FromResult<IDalamudTextureWrap>(tex));
} }
if (!this.hasError)
{
this.PostDraw(); this.PostDraw();
}
else
{
if (this.isErrorStylePushed)
{
Style.StyleModelV1.DalamudStandard.Pop();
}
}
this.PostHandlePreset(persistence); this.PostHandlePreset(persistence);