From ef1296c8dd546b4e999fd1277fc46a4601d432aa Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 4 Aug 2024 18:02:58 +0200 Subject: [PATCH] Reset active state in config menu when active selection is aborted (by pressing B or home) --- source/utils/config/ConfigDisplayItem.h | 7 ++++++- source/utils/config/ConfigRenderer.cpp | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/utils/config/ConfigDisplayItem.h b/source/utils/config/ConfigDisplayItem.h index ffa5e45..1327c6e 100644 --- a/source/utils/config/ConfigDisplayItem.h +++ b/source/utils/config/ConfigDisplayItem.h @@ -12,7 +12,7 @@ struct GeneralConfigInformation { class ConfigDisplayItem { public: - ConfigDisplayItem(GeneralConfigInformation &info, std::unique_ptr config, bool isActive) : mConfig(std::move(config)), mInfo(std::move(info)), mIsActivePlugin(isActive) { + ConfigDisplayItem(GeneralConfigInformation &info, std::unique_ptr config, bool isActive) : mConfig(std::move(config)), mInfo(std::move(info)), mIsActivePlugin(isActive), mInitialIsActivePlugin(isActive) { assert(mConfig); } [[nodiscard]] const GeneralConfigInformation &getConfigInformation() const { @@ -30,8 +30,13 @@ public: mIsActivePlugin = !mIsActivePlugin; } + void resetIsActivePlugin() { + mIsActivePlugin = mInitialIsActivePlugin; + } + private: std::unique_ptr mConfig; GeneralConfigInformation mInfo; bool mIsActivePlugin; + bool mInitialIsActivePlugin; }; \ No newline at end of file diff --git a/source/utils/config/ConfigRenderer.cpp b/source/utils/config/ConfigRenderer.cpp index c0472cf..4a78e97 100644 --- a/source/utils/config/ConfigRenderer.cpp +++ b/source/utils/config/ConfigRenderer.cpp @@ -131,6 +131,9 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) { } } else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) { if (mSetActivePluginsMode) { + for (auto &cur : mConfigs) { + cur.resetIsActivePlugin(); + } mNeedRedraw = true; mSetActivePluginsMode = false; return SUB_STATE_RUNNING;