This commit is contained in:
2025-12-19 16:48:26 +01:00
parent 989b98002c
commit fe0cd289e2
3 changed files with 34 additions and 20 deletions

View File

@ -849,7 +849,9 @@ int main(int, char **)
Settings::instance().setSoundEnabled(SoundEffectManager::instance().isEnabled());
}
// Help overlay toggle: F1 (keep it disabled on Loading/Menu)
if (e.key.scancode == SDL_SCANCODE_F1 && state != AppState::Loading && state != AppState::Menu)
const bool helpToggleKey =
(e.key.scancode == SDL_SCANCODE_F1 && state != AppState::Loading && state != AppState::Menu);
if (helpToggleKey)
{
showHelpOverlay = !showHelpOverlay;
if (state == AppState::Playing) {
@ -868,24 +870,14 @@ int main(int, char **)
helpOverlayPausedGame = false;
}
}
// If help overlay is visible and the user presses ESC, close help and return to Menu
// If help overlay is visible and the user presses ESC, close help.
if (e.key.scancode == SDL_SCANCODE_ESCAPE && showHelpOverlay) {
showHelpOverlay = false;
// Unpause only if the overlay paused the game.
if (state == AppState::Playing && helpOverlayPausedGame) {
game.setPaused(false);
}
helpOverlayPausedGame = false;
// Unpause game if we paused it for the overlay
if (state == AppState::Playing) {
if (game.isPaused() && !helpOverlayPausedGame) {
// If paused for other reasons, avoid overriding; otherwise ensure unpaused
// (The flag helps detect pause because of help overlay.)
}
}
if (state != AppState::Menu && ctx.requestFadeTransition) {
// Request a transition back to the Menu state
ctx.requestFadeTransition(AppState::Menu);
} else if (state != AppState::Menu && ctx.stateManager) {
state = AppState::Menu;
ctx.stateManager->setState(state);
}
}
if (e.key.key == SDLK_F11 || (e.key.key == SDLK_RETURN && (e.key.mod & SDL_KMOD_ALT)))
{