From 8df2e99f8dba13c05eb56125b98c598f87dfc806 Mon Sep 17 00:00:00 2001 From: Nanako <00sh.chiha+github@gmail.com> Date: Fri, 5 Aug 2022 18:08:29 +0900 Subject: [PATCH] Update Settings.cpp --- .../src/cheat-base/cheat/misc/Settings.cpp | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index 036bdfe..f710b29 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -166,24 +166,39 @@ namespace cheat::feature ImGui::BeginGroupPanel("Colors"); { static std::string nameBuffer_; + if (this->f_DefaultTheme.value() != "Default" && !themeLoaded) { - Colors_Import(f_DefaultTheme.value()); - themeLoaded = true; + LOG_INFO("Loading theme: %s", themesDir / (f_DefaultTheme.value() + ".json").c_str()); + if (!std::filesystem::exists(themesDir / (f_DefaultTheme.value() + ".json"))) + { + LOG_ERROR("Theme file not found: %s", themesDir / (f_DefaultTheme.value() + ".json").c_str()); + f_DefaultTheme = "Default"; + themeLoaded = true; + } + else + { + Colors_Import(f_DefaultTheme.value()); + themeLoaded = true; + LOG_INFO("Loaded theme \"%s\"", f_DefaultTheme.value().c_str()); + } } ImGui::InputText("Name", &nameBuffer_); if (std::filesystem::exists(themesDir / (nameBuffer_ + ".json"))) { - if (ImGui::Button("Set as default")) - f_DefaultTheme = nameBuffer_; + if (this->f_DefaultTheme.value() != nameBuffer_) + if (ImGui::Button("Set as default")) + f_DefaultTheme = nameBuffer_; if (ImGui::Button("Load")) { Colors_Import(nameBuffer_); themeLoaded = true; } - else { - ImGui::Text("Theme does not exist.");} + } + else + { + ImGui::Text("Theme does not exist."); } if (ImGui::Button("Save")) Colors_Export(nameBuffer_); @@ -205,4 +220,3 @@ namespace cheat::feature ExitProcess(0); } } -