From d3d1e673aef6848f4a3b685b3951513f64c34707 Mon Sep 17 00:00:00 2001 From: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sun, 6 Feb 2022 16:33:11 +0100 Subject: [PATCH] Fix IConsole assertions --- r5dev/gameui/IConsole.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/r5dev/gameui/IConsole.cpp b/r5dev/gameui/IConsole.cpp index 793eeaad..76705501 100644 --- a/r5dev/gameui/IConsole.cpp +++ b/r5dev/gameui/IConsole.cpp @@ -71,6 +71,7 @@ void CConsole::Draw(const char* pszTitle, bool* bDraw) * BASE PANEL SETUP * **************************/ { + static int nVars{}; if (!*bDraw) { m_bActivate = false; @@ -79,11 +80,13 @@ void CConsole::Draw(const char* pszTitle, bool* bDraw) if (m_bDefaultTheme) { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 8.f, 10.f }); + nVars = 1; } else { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 4.f, 6.f }); ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f); + nVars = 2; } ImGui::SetNextWindowSize(ImVec2(1000, 600), ImGuiCond_FirstUseEver); @@ -91,19 +94,21 @@ void CConsole::Draw(const char* pszTitle, bool* bDraw) BasePanel(bDraw); - ImGui::PopStyleVar(1); + ImGui::PopStyleVar(nVars); } /************************** * SUGGESTION PANEL SETUP * **************************/ { + static int nVars{}; if (CanAutoComplete()) { if (m_bDefaultTheme) { static ImGuiStyle& style = ImGui::GetStyle(); m_vecSuggestWindowPos.y = m_vecSuggestWindowPos.y + style.WindowPadding.y + 1.5f; + nVars = 2; } ImGui::SetNextWindowPos(m_vecSuggestWindowPos); @@ -114,7 +119,7 @@ void CConsole::Draw(const char* pszTitle, bool* bDraw) SuggestPanel(); - ImGui::PopStyleVar(2); + ImGui::PopStyleVar(nVars); } } }