Reset active state in config menu when active selection is aborted (by pressing B or home)

This commit is contained in:
Maschell 2024-08-04 18:02:58 +02:00
parent 3cf0f5d9fd
commit 99987df459
3 changed files with 12 additions and 1 deletions

View File

@ -5,7 +5,8 @@ ConfigDisplayItem::ConfigDisplayItem(GeneralConfigInformation &info,
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config, std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> config,
const bool isActive) : mConfig(std::move(config)), const bool isActive) : mConfig(std::move(config)),
mInfo(std::move(info)), mInfo(std::move(info)),
mIsActivePlugin(isActive) { mIsActivePlugin(isActive),
mInitialIsActivePlugin(isActive) {
assert(mConfig); assert(mConfig);
} }
@ -24,3 +25,7 @@ bool ConfigDisplayItem::isActivePlugin() const {
void ConfigDisplayItem::toggleIsActivePlugin() { void ConfigDisplayItem::toggleIsActivePlugin() {
mIsActivePlugin = !mIsActivePlugin; mIsActivePlugin = !mIsActivePlugin;
} }
void ConfigDisplayItem::resetIsActivePlugin() {
mIsActivePlugin = mInitialIsActivePlugin;
}

View File

@ -24,8 +24,11 @@ public:
void toggleIsActivePlugin(); void toggleIsActivePlugin();
void resetIsActivePlugin();
private: private:
std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> mConfig; std::unique_ptr<WUPSConfigAPIBackend::WUPSConfig> mConfig;
GeneralConfigInformation mInfo; GeneralConfigInformation mInfo;
bool mIsActivePlugin; bool mIsActivePlugin;
bool mInitialIsActivePlugin;
}; };

View File

@ -120,6 +120,9 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
} }
} else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) { } else if (input.data.buttons_d & (Input::eButtons::BUTTON_B | Input::eButtons::BUTTON_HOME)) {
if (mSetActivePluginsMode) { if (mSetActivePluginsMode) {
for (auto &cur : mConfigs) {
cur.resetIsActivePlugin();
}
mNeedRedraw = true; mNeedRedraw = true;
mSetActivePluginsMode = false; mSetActivePluginsMode = false;
return SUB_STATE_RUNNING; return SUB_STATE_RUNNING;