diff --git a/src/main.cpp b/src/main.cpp index cccc85c..49a4cb3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,8 +57,8 @@ void game_tick(Game& game) Input& input = game.input; match.isOnline = game.session.isActive; match.isPlayRequested = input.isPlayRequested; - match.isSandboxRequested = !game.menu.isOpen && !game.menu.isEscapeTaken && - (input.is_pressed(SDL_SCANCODE_ESCAPE) || input.is_pad_tapped(SDL_GAMEPAD_BUTTON_EAST)); + match.isSandboxRequested = + game.menu.isLeaving || (!game.menu.isOpen && input.is_pad_tapped(SDL_GAMEPAD_BUTTON_EAST)); match.colorWanted = game.settings.color_get(); game.sim.tick(); input.tick_end(); diff --git a/src/menu.cpp b/src/menu.cpp index 6b6add7..8b3bd13 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -72,20 +72,20 @@ void Menu::update(Game& game) if (isReady && !wasReady && (match.isWeaponPick || match.isTrinketPick)) isOpen = false; wasReady = isReady; - // Escape works as the menu control too, except on a match's results, where it goes back to the sandbox (unless - // it's closing the menu over them); online, that's leaving the queued game. Watching one, Escape or the menu - // control goes back to the lobby instead. + // Escape works as the menu control too. On a match's results (with the menu closed), either goes back to the + // sandbox instead, the menu control so there's a way that browsers don't keep for leaving fullscreen. Online, + // that's leaving the queued game. Watching one, Escape or the menu control goes back to the lobby instead. Session& session = game.session; bool isEscapePressed = input.is_pressed(SDL_SCANCODE_ESCAPE); - bool isEscape = isEscapePressed && (isOpen || match.state != MATCH_OVER); - isEscapeTaken = isEscape; - if (isEscapePressed && !isOpen && match.state == MATCH_OVER && session.is_playing_arena(game)) + bool isMenuPressed = input.is_control_pressed(CONTROL_MENU); + isLeaving = (isEscapePressed || isMenuPressed) && !isOpen && match.state == MATCH_OVER; + if (isLeaving && session.is_playing_arena(game)) { session.arena_leave(game); - isEscapeTaken = true; + isLeaving = false; return; } - if (input.is_control_pressed(CONTROL_MENU) || isEscape) + if (!isLeaving && (isMenuPressed || isEscapePressed)) { isOpen = !isOpen; game.audio.play(SOUND_SWAP); diff --git a/src/menu.h b/src/menu.h index 05ced7d..542158f 100644 --- a/src/menu.h +++ b/src/menu.h @@ -63,8 +63,8 @@ public: Page pages[TAB_COUNT]; int tab = TAB_WEAPONS; bool isOpen = false; - // Whether this tick's Escape went to the menu, so nothing else takes it too. - bool isEscapeTaken = false; + // Whether the results were left this tick (by Escape or the menu control), back to the sandbox. + bool isLeaving = false; void update(Game& game); void draw(Game& game); diff --git a/src/ui.cpp b/src/ui.cpp index 4f17abf..bf9bffa 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -458,9 +458,14 @@ void Ui::match_draw(Game& game) float y = BANNER_Y + game.text.line_height_get(FONT_SMALL, BANNER_SCALE); if (isRace) y = results_draw(game, y); + // The menu control leaves, as a browser keeps Escape for leaving fullscreen. + Binding menu = input.bindings[CONTROL_MENU]; + char leave[TOOLTIP_LENGTH]; + input.binding_name_get(isPad ? menu.pad : menu.key, isPad, leave, sizeof(leave)); if (!game.session.isActive) { - text_center_draw(game, isPad ? "B: Sandbox" : "Esc: Sandbox", y, 1); + SDL_snprintf(text, sizeof(text), "%s: Sandbox", leave); + text_center_draw(game, text, y, 1); break; } // Online, a queued game's players each say whether to play it again (listed under), or leave. @@ -469,7 +474,7 @@ void Ui::match_draw(Game& game) Binding binding = input.bindings[CONTROL_READY]; char key[TOOLTIP_LENGTH]; input.binding_name_get(isPad ? binding.pad : binding.key, isPad, key, sizeof(key)); - SDL_snprintf(text, sizeof(text), "%s: Play Again Esc: Leave", key); + SDL_snprintf(text, sizeof(text), "%s: Play Again %s: Leave", key, leave); text_center_draw(game, text, y, 1); y += LINE_HEIGHT * 2; }