From fa54b63f6461f0059333dc307edd26254baca687 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.cpp | 7 ++++++- source/utils/config/ConfigDisplayItem.h | 3 +++ source/utils/config/ConfigRenderer.cpp | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/utils/config/ConfigDisplayItem.cpp b/source/utils/config/ConfigDisplayItem.cpp index f9cf21f..1869f09 100644 --- a/source/utils/config/ConfigDisplayItem.cpp +++ b/source/utils/config/ConfigDisplayItem.cpp @@ -5,7 +5,8 @@ ConfigDisplayItem::ConfigDisplayItem(GeneralConfigInformation &info, std::unique_ptr config, const bool isActive) : mConfig(std::move(config)), mInfo(std::move(info)), - mIsActivePlugin(isActive) { + mIsActivePlugin(isActive), + mInitialIsActivePlugin(isActive) { assert(mConfig); } @@ -23,4 +24,8 @@ bool ConfigDisplayItem::isActivePlugin() const { void ConfigDisplayItem::toggleIsActivePlugin() { mIsActivePlugin = !mIsActivePlugin; +} + +void ConfigDisplayItem::resetIsActivePlugin() { + mIsActivePlugin = mInitialIsActivePlugin; } \ No newline at end of file diff --git a/source/utils/config/ConfigDisplayItem.h b/source/utils/config/ConfigDisplayItem.h index d714c82..28913f6 100644 --- a/source/utils/config/ConfigDisplayItem.h +++ b/source/utils/config/ConfigDisplayItem.h @@ -24,8 +24,11 @@ public: void toggleIsActivePlugin(); + void resetIsActivePlugin(); + 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 811d716..26a8d66 100644 --- a/source/utils/config/ConfigRenderer.cpp +++ b/source/utils/config/ConfigRenderer.cpp @@ -120,6 +120,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;