Updated bottom menu

This commit is contained in:
2025-12-17 20:12:06 +01:00
parent 122de2b36f
commit fe6c5e3c8a
7 changed files with 240 additions and 83 deletions

View File

@ -45,6 +45,7 @@
#include "core/Config.h"
#include "core/Settings.h"
#include "ui/MenuLayout.h"
#include "ui/BottomMenu.h"
// Debug logging removed: no-op in this build (previously LOG_DEBUG)
@ -981,24 +982,30 @@ int main(int, char **)
showSettingsPopup = false;
} else {
ui::MenuLayoutParams params{ LOGICAL_W, LOGICAL_H, winW, winH, logicalScale };
auto buttonRects = ui::computeMenuButtonRects(params);
auto pointInRect = [&](const SDL_FRect& r) {
return lx >= r.x && lx <= r.x + r.w && ly >= r.y && ly <= r.y + r.h;
};
auto menuInput = ui::handleBottomMenuInput(params, e, lx, ly, hoveredButton, true);
hoveredButton = menuInput.hoveredIndex;
if (pointInRect(buttonRects[0])) {
startMenuPlayTransition();
} else if (pointInRect(buttonRects[1])) {
requestStateFade(AppState::LevelSelector);
} else if (pointInRect(buttonRects[2])) {
requestStateFade(AppState::Options);
} else if (pointInRect(buttonRects[3])) {
// HELP - show inline help HUD in the MenuState
if (menuState) menuState->showHelpPanel(true);
} else if (pointInRect(buttonRects[4])) {
showExitConfirmPopup = true;
exitPopupSelectedButton = 1;
if (menuInput.activated) {
switch (*menuInput.activated) {
case ui::BottomMenuItem::Play:
startMenuPlayTransition();
break;
case ui::BottomMenuItem::Level:
requestStateFade(AppState::LevelSelector);
break;
case ui::BottomMenuItem::Options:
requestStateFade(AppState::Options);
break;
case ui::BottomMenuItem::Help:
// HELP - show inline help HUD in the MenuState
if (menuState) menuState->showHelpPanel(true);
break;
case ui::BottomMenuItem::Exit:
showExitConfirmPopup = true;
exitPopupSelectedButton = 1;
break;
}
}
// Settings button (gear icon area - top right)
@ -1099,7 +1106,8 @@ int main(int, char **)
float contentOffsetX = (winW - contentW) * 0.5f / logicalScale;
float contentOffsetY = (winH - contentH) * 0.5f / logicalScale;
ui::MenuLayoutParams params{ LOGICAL_W, LOGICAL_H, winW, winH, logicalScale };
hoveredButton = ui::hitTestMenuButtons(params, lx, ly);
auto menuInput = ui::handleBottomMenuInput(params, e, lx, ly, hoveredButton, true);
hoveredButton = menuInput.hoveredIndex;
}
}
}