minor fix

This commit is contained in:
2025-11-22 10:59:47 +01:00
parent ec2bb1bb1e
commit 0ffd801743
8 changed files with 105 additions and 32 deletions

View File

@ -33,15 +33,30 @@ void PlayingState::handleEvent(const SDL_Event& e) {
// If exit-confirm popup is visible, handle shortcuts here
if (ctx.showExitConfirmPopup && *ctx.showExitConfirmPopup) {
// Confirm with Enter (main or keypad)
if (e.key.scancode == SDL_SCANCODE_RETURN || e.key.scancode == SDL_SCANCODE_KP_ENTER) {
*ctx.showExitConfirmPopup = false;
// Reset game and return to menu
ctx.game->reset(false);
if (ctx.stateManager) ctx.stateManager->setState(AppState::Menu);
// Navigate between YES (0) and NO (1) buttons
if (e.key.scancode == SDL_SCANCODE_LEFT || e.key.scancode == SDL_SCANCODE_UP) {
exitPopupSelectedButton = 0; // YES
return;
}
// Cancel with Esc
if (e.key.scancode == SDL_SCANCODE_RIGHT || e.key.scancode == SDL_SCANCODE_DOWN) {
exitPopupSelectedButton = 1; // NO
return;
}
// Activate selected button with Enter or Space
if (e.key.scancode == SDL_SCANCODE_RETURN || e.key.scancode == SDL_SCANCODE_KP_ENTER || e.key.scancode == SDL_SCANCODE_SPACE) {
*ctx.showExitConfirmPopup = false;
if (exitPopupSelectedButton == 0) {
// YES - Reset game and return to menu
ctx.game->reset(false);
if (ctx.stateManager) ctx.stateManager->setState(AppState::Menu);
} else {
// NO - Just close popup and resume
ctx.game->setPaused(false);
}
return;
}
// Cancel with Esc (same as NO)
if (e.key.scancode == SDL_SCANCODE_ESCAPE) {
*ctx.showExitConfirmPopup = false;
ctx.game->setPaused(false);