Fix faulty ImGui clip rect usage. (#211)

This commit is contained in:
Skyth (Asilkan) 2025-01-27 01:24:05 +03:00 committed by GitHub
parent a5db997e5d
commit a9677084ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 44 deletions

View file

@ -2098,8 +2098,9 @@ static void DrawImGui()
ButtonGuide::Draw();
Fader::Draw();
DrawProfiler();
assert(ImGui::GetForegroundDrawList()->_ClipRectStack.Size == 1 && "Some clip rects were not removed from the stack!");
DrawProfiler();
ImGui::Render();
auto drawData = ImGui::GetDrawData();

View file

@ -580,11 +580,13 @@ static void DrawContentContainer()
if (motion < 1.0f)
{
drawList->PopClipRect();
return;
}
else if (g_isClosing)
{
AchievementMenu::s_isVisible = false;
drawList->PopClipRect();
return;
}

View file

@ -67,9 +67,13 @@ static bool DrawContainer(ImVec2 min, ImVec2 max, float cornerRadius = 25)
DrawPauseContainer(g_upWindow.get(), min, max, alpha);
if (containerMotion >= 1.0f)
{
drawList->PushClipRect(min, max);
return true;
}
return containerMotion >= 1.0f;
return false;
}
void AchievementOverlay::Init()
@ -117,12 +121,8 @@ void AchievementOverlay::Draw()
if (DrawContainer(min, max))
{
if (g_isClosing)
if (!g_isClosing)
{
s_isVisible = false;
return;
}
// Draw achievement icon.
drawList->AddImage
(
@ -159,6 +159,11 @@ void AchievementOverlay::Draw()
1.0f, // radius
IM_COL32(0, 0, 0, 255) // shadowColour
);
}
else
{
s_isVisible = false;
}
// Pop clip rect from DrawContainer.
drawList->PopClipRect();

View file

@ -192,9 +192,13 @@ bool DrawContainer(float appearTime, ImVec2 centre, ImVec2 max, bool isForegroun
DrawPauseContainer(g_upWindow.get(), _min, _max, alpha);
if (containerMotion >= 1.0f && !g_isClosing)
{
drawList->PushClipRect(_min, _max);
return true;
}
return containerMotion >= 1.0f && !g_isClosing;
return false;
}
void DrawButton(int rowIndex, float yOffset, float width, float height, std::string& text)