From e31178f051654f77ff08a8c49274efbf1d233277 Mon Sep 17 00:00:00 2001 From: lunatic <56441863+lunaticwhat@users.noreply.github.com> Date: Tue, 26 Jul 2022 08:48:41 +0700 Subject: [PATCH 1/6] add ImGui style editor toggle --- cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp | 3 +++ cheat-base/src/cheat-base/cheat/misc/Settings.cpp | 2 ++ cheat-base/src/cheat-base/cheat/misc/Settings.h | 1 + 3 files changed, 6 insertions(+) diff --git a/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp b/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp index cc8789f..4f6781a 100644 --- a/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp +++ b/cheat-base/src/cheat-base/cheat/CheatManagerBase.cpp @@ -431,6 +431,9 @@ namespace cheat if (settings.f_NotificationsShow) DrawNotifications(); + if (settings.f_ShowStyleEditor) + ImGui::ShowStyleEditor(); + if (settings.f_MenuKey.value().IsReleased() && !ImGui::IsAnyItemActive()) ToggleMenuShow(); } diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index f5d40ec..371650d 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -11,6 +11,7 @@ namespace cheat::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), @@ -55,6 +56,7 @@ namespace cheat::feature 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(); diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.h b/cheat-base/src/cheat-base/cheat/misc/Settings.h index 1a00653..710866b 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.h +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.h @@ -11,6 +11,7 @@ namespace cheat::feature config::Field f_MenuKey; config::Field f_HotkeysEnabled; config::Field f_FontSize; + config::Field f_ShowStyleEditor; config::Field f_StatusMove; config::Field f_StatusShow; From 0bcc672b849d1c1d6e2eb04562bb330fc17f5555 Mon Sep 17 00:00:00 2001 From: Nanako <00sh.chiha+github@gmail.com> Date: Thu, 4 Aug 2022 21:09:00 +0900 Subject: [PATCH 2/6] add theme functionality not full implementation --- .../src/cheat-base/cheat/misc/Settings.cpp | 59 +++++++++++++++++-- .../src/cheat-base/cheat/misc/Settings.h | 4 ++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index 371650d..0e9d407 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -1,9 +1,14 @@ #include #include "Settings.h" -#include -#include #include +#include +#include +#include +#include + +#include "shlwapi.h" +#pragma comment(lib, "shlwapi.lib") namespace cheat::feature { @@ -29,11 +34,14 @@ namespace cheat::feature NF(f_ConsoleLogging, "Console Logging", "General::Logging", true), NF(f_FastExitEnable, "Fast Exit", "General::FastExit", false), - NF(f_HotkeyExit, "Hotkeys", "General::FastExit", Hotkey(VK_F12)) - + NF(f_HotkeyExit, "Hotkeys", "General::FastExit", Hotkey(VK_F12)), + themesDir(util::GetCurrentPath() / "themes") + { renderer::SetGlobalFontSize(static_cast(f_FontSize)); f_HotkeyExit.value().PressedEvent += MY_METHOD_HANDLER(Settings::OnExitKeyPressed); + if (!std::filesystem::exists(themesDir)) + std::filesystem::create_directory(themesDir); } const FeatureGUIInfo& Settings::GetGUIInfo() const @@ -42,6 +50,35 @@ namespace cheat::feature return info; } + void Settings::Colors_Export(std::string name) + { + ImGuiStyle &style = ImGui::GetStyle(); + auto colors = style.Colors; + + nlohmann::json json; + for (int i = 0; i < ImGuiCol_COUNT; i++) + json[ImGui::GetStyleColorName((ImGuiCol)i)] = {colors[i].x, colors[i].y, colors[i].z, colors[i].w}; + std::ofstream file(themesDir / (name + ".json")); + file << std::setw(4) << json << std::endl; + } + + void Settings::Colors_Import(std::string name) + { + ImGuiStyle &style = ImGui::GetStyle(); + auto colors = style.Colors; + nlohmann::json json; + std::ifstream file(themesDir / (name + ".json")); + file >> json; + for (int i = 0; i < ImGuiCol_COUNT; i++) + { + auto color = json[ImGui::GetStyleColorName((ImGuiCol)i)]; + colors[i].x = color[0]; + colors[i].y = color[1]; + colors[i].z = color[2]; + colors[i].w = color[3]; + } + } + void Settings::DrawMain() { @@ -123,6 +160,20 @@ namespace cheat::feature ImGui::EndDisabled(); } ImGui::EndGroupPanel(); + + ImGui::BeginGroupPanel("Colors"); + { + static std::string nameBuffer_; + ImGui::InputText("Name", &nameBuffer_); + if (ImGui::Button("Export")) + 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(); } Settings& Settings::GetInstance() diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.h b/cheat-base/src/cheat-base/cheat/misc/Settings.h index 710866b..51eadca 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.h +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.h @@ -31,10 +31,14 @@ namespace cheat::feature config::Field f_FastExitEnable; config::Field f_HotkeyExit; + std::filesystem::path themesDir; + static Settings& GetInstance(); const FeatureGUIInfo& GetGUIInfo() const override; void DrawMain() override; + void Colors_Export(std::string name); + void Colors_Import(std::string name); private: From 9232d64a3f73b03e1e3c929b79b6ae83caab78b7 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 3/6] 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(); 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 4/6] 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); } } - From 30d55679b8e0f64e6c03ef0ced30104e51acb3e6 Mon Sep 17 00:00:00 2001 From: Nanako <00sh.chiha+github@gmail.com> Date: Sat, 6 Aug 2022 15:48:03 +0900 Subject: [PATCH 5/6] Fix Init Co-Authored-By: Taiga <67109235+Taiga74164@users.noreply.github.com> --- .../src/cheat-base/cheat/misc/Settings.cpp | 87 +++++++++---------- .../src/cheat-base/cheat/misc/Settings.h | 11 +-- cheat-base/src/cheat-base/render/renderer.cpp | 16 ++-- 3 files changed, 56 insertions(+), 58 deletions(-) diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp index f710b29..cdf4fdb 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.cpp +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.cpp @@ -10,9 +10,9 @@ #include "shlwapi.h" #pragma comment(lib, "shlwapi.lib") -namespace cheat::feature +namespace cheat::feature { - Settings::Settings() : 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), @@ -20,17 +20,17 @@ namespace cheat::feature NF(f_StatusMove, "Move Status Window", "General::StatusWindow", true), NF(f_StatusShow, "Show Status Window", "General::StatusWindow", true), - - NF(f_InfoMove, "Move Info Window", "General::InfoWindow", true), - NF(f_InfoShow, "Show Info Window", "General::InfoWindow", true), - + + NF(f_InfoMove, "Move Info Window", "General::InfoWindow", true), + NF(f_InfoShow, "Show Info Window", "General::InfoWindow", true), + NF(f_FpsMove, "Move FPS Indicator", "General::FPS", false), NF(f_FpsShow, "Show FPS Indicator", "General::FPS", true), - NF(f_NotificationsShow, "Show Notifications", "General::Notify", true), + NF(f_NotificationsShow, "Show Notifications", "General::Notify", true), NF(f_NotificationsDelay, "Notifications Delay", "General::Notify", 500), - - NF(f_FileLogging, "File Logging", "General::Logging", false), + + NF(f_FileLogging, "File Logging", "General::Logging", false), NF(f_ConsoleLogging, "Console Logging", "General::Logging", true), NF(f_FastExitEnable, "Fast Exit", "General::FastExit", false), @@ -38,35 +38,47 @@ namespace cheat::feature NFS(f_DefaultTheme, "Theme", "General::Colors", "Default"), themesDir(util::GetCurrentPath() / "themes") - { + { renderer::SetGlobalFontSize(static_cast(f_FontSize)); f_HotkeyExit.value().PressedEvent += MY_METHOD_HANDLER(Settings::OnExitKeyPressed); if (!std::filesystem::exists(themesDir)) std::filesystem::create_directory(themesDir); - } - bool themeLoaded = false; - const FeatureGUIInfo& Settings::GetGUIInfo() const - { - static const FeatureGUIInfo info{ "", "Settings", false }; - return info; - } + } + + bool inited = false; + void Settings::Init() { + if (this->f_DefaultTheme.value() != "Default" && !inited) + { + LOG_INFO("Loading theme: %s", themesDir / (f_DefaultTheme.value() + ".json").c_str()); + if (!std::filesystem::exists(themesDir / (f_DefaultTheme.value() + ".json"))) + f_DefaultTheme = "Default"; + else Colors_Import(f_DefaultTheme.value()); + inited = true; + } + } + + const FeatureGUIInfo& Settings::GetGUIInfo() const + { + static const FeatureGUIInfo info{ "", "Settings", false }; + return info; + } void Settings::Colors_Export(std::string name) { - ImGuiStyle &style = ImGui::GetStyle(); + ImGuiStyle& style = ImGui::GetStyle(); auto colors = style.Colors; nlohmann::json json; for (int i = 0; i < ImGuiCol_COUNT; i++) - json[ImGui::GetStyleColorName((ImGuiCol)i)] = {colors[i].x, colors[i].y, colors[i].z, colors[i].w}; + json[ImGui::GetStyleColorName((ImGuiCol)i)] = { colors[i].x, colors[i].y, colors[i].z, colors[i].w }; std::ofstream file(themesDir / (name + ".json")); file << std::setw(4) << json << std::endl; } - + void Settings::Colors_Import(std::string name) { - ImGuiStyle &style = ImGui::GetStyle(); + ImGuiStyle& style = ImGui::GetStyle(); auto colors = style.Colors; nlohmann::json json; std::ifstream file(themesDir / (name + ".json")); @@ -142,7 +154,7 @@ namespace cheat::feature ImGui::BeginGroupPanel("Show Notifications"); { ConfigWidget(f_NotificationsShow, "Notifications on the bottom-right corner of the window will be displayed."); - ConfigWidget(f_NotificationsDelay, 1,1,10000, "Delay in milliseconds between notifications."); + ConfigWidget(f_NotificationsDelay, 1, 1, 10000, "Delay in milliseconds between notifications."); } ImGui::EndGroupPanel(); @@ -150,7 +162,7 @@ namespace cheat::feature { ConfigWidget("Enabled", f_FastExitEnable, - "Enable Fast Exit.\n" + "Enable Fast Exit.\n" ); if (!f_FastExitEnable) ImGui::BeginDisabled(); @@ -166,24 +178,6 @@ namespace cheat::feature ImGui::BeginGroupPanel("Colors"); { static std::string nameBuffer_; - - if (this->f_DefaultTheme.value() != "Default" && !themeLoaded) - { - 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"))) { @@ -193,7 +187,6 @@ namespace cheat::feature if (ImGui::Button("Load")) { Colors_Import(nameBuffer_); - themeLoaded = true; } } else @@ -206,11 +199,11 @@ namespace cheat::feature ImGui::EndGroupPanel(); } - Settings& Settings::GetInstance() - { - static Settings instance; - return instance; - } + Settings& Settings::GetInstance() + { + static Settings instance; + return instance; + } void Settings::OnExitKeyPressed() { diff --git a/cheat-base/src/cheat-base/cheat/misc/Settings.h b/cheat-base/src/cheat-base/cheat/misc/Settings.h index 69a8fe6..2a38205 100644 --- a/cheat-base/src/cheat-base/cheat/misc/Settings.h +++ b/cheat-base/src/cheat-base/cheat/misc/Settings.h @@ -2,11 +2,11 @@ #include #include -namespace cheat::feature +namespace cheat::feature { class Settings : public Feature - { + { public: config::Field f_MenuKey; config::Field f_HotkeysEnabled; @@ -18,10 +18,10 @@ namespace cheat::feature config::Field f_InfoMove; config::Field f_InfoShow; - + config::Field f_FpsShow; config::Field f_FpsMove; - + config::Field f_NotificationsShow; config::Field f_NotificationsDelay; @@ -38,9 +38,10 @@ namespace cheat::feature const FeatureGUIInfo& GetGUIInfo() const override; void DrawMain() override; + void Init(); void Colors_Export(std::string name); void Colors_Import(std::string name); - + private: void OnExitKeyPressed(); diff --git a/cheat-base/src/cheat-base/render/renderer.cpp b/cheat-base/src/cheat-base/render/renderer.cpp index f9ba79b..17a633e 100644 --- a/cheat-base/src/cheat-base/render/renderer.cpp +++ b/cheat-base/src/cheat-base/render/renderer.cpp @@ -12,6 +12,7 @@ #include #include +#include extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -33,14 +34,14 @@ namespace renderer static constexpr int _fontsCount = _fontSizeMax / _fontSizeStep; static std::array _fonts; - static Data _customFontData {}; + static Data _customFontData{}; static WNDPROC OriginalWndProcHandler; static ID3D11RenderTargetView* mainRenderTargetView; static void OnRenderDX11(ID3D11DeviceContext* pContext); static void OnInitializeDX11(HWND window, ID3D11Device* pDevice, ID3D11DeviceContext* pContext, IDXGISwapChain* pChain); - + static void OnPreRenderDX12(); static void OnPostRenderDX12(ID3D12GraphicsCommandList* commandList); static void OnInitializeDX12(HWND window, ID3D12Device* pDevice, UINT buffersCounts, ID3D12DescriptorHeap* pDescriptorHeapImGuiRender); @@ -106,7 +107,7 @@ namespace renderer return io.FontDefault; } int fontSizeInt = static_cast(fontSize); - int fontIndex = fontSizeInt / _fontSizeStep + + int fontIndex = fontSizeInt / _fontSizeStep + (fontSizeInt % _fontSizeStep > (_fontSizeStep / 2) ? 1 : 0) - 1; fontIndex = std::clamp(fontIndex, 0, _fontsCount - 1); return _fonts[fontIndex]; @@ -122,7 +123,7 @@ namespace renderer int fontSizeInt = static_cast(fontSize); int fontIndex = fontSizeInt / _fontSizeStep; - int fontAligned = fontIndex * _fontSizeStep + + int fontAligned = fontIndex * _fontSizeStep + ((fontSizeInt % _fontSizeStep) > _fontSizeStep / 2 ? _fontSizeStep : 0); fontAligned = std::clamp(fontAligned, _fontSizeStep, _fontSizeMax); @@ -138,7 +139,7 @@ namespace renderer { return _globalFontSize; } - + static void LoadCustomFont() { if (_customFontData.data == nullptr) @@ -195,7 +196,7 @@ namespace renderer reinterpret_cast(hWndProc))); ImGui_ImplWin32_Init(window); - ImGui_ImplDX12_Init(pDevice, buffersCounts, DXGI_FORMAT_R8G8B8A8_UNORM, + ImGui_ImplDX12_Init(pDevice, buffersCounts, DXGI_FORMAT_R8G8B8A8_UNORM, pDescriptorHeapImGuiRender, pDescriptorHeapImGuiRender->GetCPUDescriptorHandleForHeapStart(), pDescriptorHeapImGuiRender->GetGPUDescriptorHandleForHeapStart()); @@ -253,6 +254,9 @@ namespace renderer pContext->OMSetRenderTargets(1, &mainRenderTargetView, nullptr); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + + auto& themes = cheat::feature::Settings::GetInstance(); + themes.Init(); } static LRESULT CALLBACK hWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 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 6/6] 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;