From 3b2d95ea63d3b526b6a48f56e80dd5dd210ddbab Mon Sep 17 00:00:00 2001 From: Nanako <00sh.chiha+github@gmail.com> Date: Thu, 4 Aug 2022 21:51:39 +0900 Subject: [PATCH] Update Settings.cpp --- .../src/cheat-base/cheat/misc/Settings.cpp | 27 ++++++++++++++----- .../src/cheat-base/cheat/misc/Settings.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index 0e9d407..036bdfe 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -35,6 +35,7 @@ namespace cheat::feature NF(f_FastExitEnable, "Fast Exit", "General::FastExit", false), NF(f_HotkeyExit, "Hotkeys", "General::FastExit", Hotkey(VK_F12)), + NFS(f_DefaultTheme, "Theme", "General::Colors", "Default"), themesDir(util::GetCurrentPath() / "themes") { @@ -43,6 +44,7 @@ namespace cheat::feature if (!std::filesystem::exists(themesDir)) std::filesystem::create_directory(themesDir); } + bool themeLoaded = false; const FeatureGUIInfo& Settings::GetGUIInfo() const { @@ -164,14 +166,27 @@ namespace cheat::feature ImGui::BeginGroupPanel("Colors"); { static std::string nameBuffer_; + if (this->f_DefaultTheme.value() != "Default" && !themeLoaded) + { + Colors_Import(f_DefaultTheme.value()); + themeLoaded = true; + } + ImGui::InputText("Name", &nameBuffer_); - if (ImGui::Button("Export")) + if (std::filesystem::exists(themesDir / (nameBuffer_ + ".json"))) + { + 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.");} + } + if (ImGui::Button("Save")) Colors_Export(nameBuffer_); - if (ImGui::Button("Import")) - Colors_Import(nameBuffer_); - if (ImGui::Button("Open themes folder")) - ShellExecute(nullptr, "open", themesDir.c_str(), nullptr, nullptr, SW_SHOW); - } ImGui::EndGroupPanel(); } diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.h b/cheat-base/src/cheat-base/cheat/misc/Settings.h index 51eadca..69a8fe6 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.h +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.h @@ -32,6 +32,7 @@ namespace cheat::feature config::Field f_HotkeyExit; std::filesystem::path themesDir; + config::Field f_DefaultTheme; static Settings& GetInstance();