From 4d261776dfea4ac35f489bcdaa345c6b80b4fba0 Mon Sep 17 00:00:00 2001 From: lunatic <56441863+lunaticwhat@users.noreply.github.com> Date: Sat, 6 Aug 2022 23:44:36 +0700 Subject: [PATCH] re-arrange codes and color settings --- .../src/cheat-base/cheat/misc/Settings.cpp | 51 ++++++++++++------- .../src/cheat-base/cheat/misc/Settings.h | 5 +- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index cdf4fdb..fff9213 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -15,9 +15,7 @@ namespace cheat::feature Settings::Settings() : Feature(), NF(f_MenuKey, "Show Cheat Menu Key", "General", Hotkey(VK_F1)), NF(f_HotkeysEnabled, "Hotkeys Enabled", "General", true), - NF(f_FontSize, "Font size", "General", 16.0f), - NF(f_ShowStyleEditor, "Show Style Editor", "General", false), - + NF(f_StatusMove, "Move Status Window", "General::StatusWindow", true), NF(f_StatusShow, "Show Status Window", "General::StatusWindow", true), @@ -35,6 +33,9 @@ namespace cheat::feature NF(f_FastExitEnable, "Fast Exit", "General::FastExit", false), NF(f_HotkeyExit, "Hotkeys", "General::FastExit", Hotkey(VK_F12)), + + NF(f_FontSize, "Font Size", "General", 16.0f), + NF(f_ShowStyleEditor, "Show Colors Customization", "General", false), NFS(f_DefaultTheme, "Theme", "General::Colors", "Default"), themesDir(util::GetCurrentPath() / "themes") @@ -102,13 +103,7 @@ namespace cheat::feature "Key to toggle main menu visibility. Cannot be empty.\n"\ "If you forget this key, you can see or set it in your config file."); ConfigWidget(f_HotkeysEnabled, "Enable hotkeys."); - if (ConfigWidget(f_FontSize, 1, 8, 64, "Font size for cheat interface.")) - { - f_FontSize = std::clamp(f_FontSize.value(), 8, 64); - renderer::SetGlobalFontSize(static_cast(f_FontSize)); - } - ConfigWidget(f_ShowStyleEditor, "Show interface style editor window."); - } + } ImGui::EndGroupPanel(); ImGui::BeginGroupPanel("Logging"); @@ -175,26 +170,44 @@ namespace cheat::feature } ImGui::EndGroupPanel(); - ImGui::BeginGroupPanel("Colors"); + ImGui::BeginGroupPanel("Interface Customization"); { + if (ConfigWidget(f_FontSize, 1, 8, 64, "Adjust interface font size.")) + { + f_FontSize = std::clamp(f_FontSize.value(), 8, 64); + renderer::SetGlobalFontSize(static_cast(f_FontSize)); + } + ImGui::Spacing(); + + ConfigWidget(f_ShowStyleEditor, "Show colors customization window."); + ImGui::Spacing(); + + ImGui::Text("Save Customized Color"); static std::string nameBuffer_; - ImGui::InputText("Name", &nameBuffer_); + ImGui::InputText("Color Name", &nameBuffer_); + if (ImGui::Button("Save")) + Colors_Export(nameBuffer_); + ImGui::SameLine(); + if (std::filesystem::exists(themesDir / (nameBuffer_ + ".json"))) { if (this->f_DefaultTheme.value() != nameBuffer_) - if (ImGui::Button("Set as default")) - f_DefaultTheme = nameBuffer_; - if (ImGui::Button("Load")) { - Colors_Import(nameBuffer_); + if (ImGui::Button("Set as default")) + { + f_DefaultTheme = nameBuffer_; + } + ImGui::SameLine(); + if (ImGui::Button("Load")) + { + Colors_Import(nameBuffer_); + } } } else { - ImGui::Text("Theme does not exist."); + ImGui::Text("Color does not exist."); } - if (ImGui::Button("Save")) - Colors_Export(nameBuffer_); } 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 2a38205..7605b43 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.h +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.h @@ -10,8 +10,6 @@ namespace cheat::feature public: config::Field f_MenuKey; config::Field f_HotkeysEnabled; - config::Field f_FontSize; - config::Field f_ShowStyleEditor; config::Field f_StatusMove; config::Field f_StatusShow; @@ -31,9 +29,12 @@ namespace cheat::feature config::Field f_FastExitEnable; config::Field f_HotkeyExit; + config::Field f_FontSize; + config::Field f_ShowStyleEditor; std::filesystem::path themesDir; config::Field f_DefaultTheme; + static Settings& GetInstance(); const FeatureGUIInfo& GetGUIInfo() const override;