Config: Move "onButtonPressed" check out of the loop

This commit is contained in:
Maschell 2022-09-23 21:40:06 +02:00
parent 030c9b4265
commit 9dc58d389f

View File

@ -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);