From 1d4bd31011d75b95e4a366645ed6792f2255bd85 Mon Sep 17 00:00:00 2001 From: TheRiverwoodModder <125157333+TheRiverwoodModder@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:41:32 -0800 Subject: [PATCH] fix: fix ImGui Assert --- src/Menu.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Menu.cpp b/src/Menu.cpp index 4f0cd2d29..185f8ca21 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -64,6 +64,7 @@ void SetupImGuiStyle() } bool IsEnabled = false; +ImVec4 TextColor = ImVec4{ 1.0f, 0.0f, 1.0f, 1.0f }; Menu::~Menu() { @@ -139,6 +140,7 @@ void Menu::DrawSettings() ImGui::SetNextWindowSize({ 1000, 1000 }, ImGuiCond_FirstUseEver); ImGui::SetNextWindowPos({ 0, 0 }, ImGuiCond_FirstUseEver); if (ImGui::Begin(std::format("Skyrim Community Shaders {}", Plugin::VERSION.string(".")).c_str(), &IsEnabled)) { + ImGui::PushStyleColor(ImGuiCol_Text, TextColor); auto& shaderCache = SIE::ShaderCache::Instance(); if (ImGui::BeginTable("##LeButtons", 4, ImGuiTableFlags_SizingStretchSame)) { @@ -488,6 +490,7 @@ void Menu::DrawSettings() ImGui::EndTable(); } + ImGui::PopStyleColor(1); } ImGui::End(); @@ -543,7 +546,7 @@ void Menu::DrawOverlay() ImGui::End(); } else if (failed) { - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255)); + TextColor = ImVec4{ 1.0f, 0.0f, 0.0f, 1.0f }; if (!hide) { ImGui::SetNextWindowBgAlpha(1); ImGui::SetNextWindowPos(ImVec2(10, 10)); @@ -552,12 +555,12 @@ void Menu::DrawOverlay() return; } - ImGui::Text("ERROR: %d shaders failed to compile. Check installation and CommunityShaders.log", failed, totalShaders); + ImGui::TextColored(TextColor, "ERROR: %d shaders failed to compile. Check installation and CommunityShaders.log", failed, totalShaders); ImGui::End(); } } else { // Done compiling with no failures - ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + TextColor = ImVec4{ 1.0f, 1.0f, 1.0f, 1.0f }; } if (IsEnabled) {