From 9dc58d389fd3a518abdf24578ec7fe14361825c3 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 23 Sep 2022 21:40:06 +0200 Subject: [PATCH] Config: Move "onButtonPressed" check out of the loop --- source/utils/ConfigUtils.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/utils/ConfigUtils.cpp b/source/utils/ConfigUtils.cpp index e873fa4..7df83d0 100644 --- a/source/utils/ConfigUtils.cpp +++ b/source/utils/ConfigUtils.cpp @@ -503,6 +503,10 @@ void ConfigUtils::displayMenu() { prevSelectedItem = (int32_t) selectedBtn; } + if (pressedButtons != WUPS_CONFIG_BUTTON_NONE) { + config_items[selectedBtn]->onButtonPressed(pressedButtons); + } + DrawUtils::beginDraw(); DrawUtils::clear(COLOR_BACKGROUND); @@ -520,9 +524,6 @@ void ConfigUtils::displayMenu() { DrawUtils::setFontSize(24); DrawUtils::print(16 * 2, index + 8 + 24, config_items[i]->getDisplayName().c_str()); if (i == selectedBtn) { - if (pressedButtons != WUPS_CONFIG_BUTTON_NONE) { - config_items[i]->onButtonPressed(pressedButtons); - } DrawUtils::print(SCREEN_WIDTH - 16 * 2, index + 8 + 24, config_items[i]->getCurrentValueSelectedDisplay().c_str(), true); } else { DrawUtils::print(SCREEN_WIDTH - 16 * 2, index + 8 + 24, config_items[i]->getCurrentValueDisplay().c_str(), true);