Leave match results with the Menu key, as browsers keep Escape

The results prompt shows the Menu key instead of Esc, which a browser
uses to leave fullscreen. Escape still works on desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-08 17:19:38 -05:00
1 parent 6951e16520
commit cdb0845da2
4 files changed
+19 -14

No files matched your search

+2 -2
View File
@@ -57,8 +57,8 @@ void game_tick(Game& game)
Input& input = game.input; Input& input = game.input;
match.isOnline = game.session.isActive; match.isOnline = game.session.isActive;
match.isPlayRequested = input.isPlayRequested; match.isPlayRequested = input.isPlayRequested;
match.isSandboxRequested = !game.menu.isOpen && !game.menu.isEscapeTaken && match.isSandboxRequested =
(input.is_pressed(SDL_SCANCODE_ESCAPE) || input.is_pad_tapped(SDL_GAMEPAD_BUTTON_EAST)); game.menu.isLeaving || (!game.menu.isOpen && input.is_pad_tapped(SDL_GAMEPAD_BUTTON_EAST));
match.colorWanted = game.settings.color_get(); match.colorWanted = game.settings.color_get();
game.sim.tick(); game.sim.tick();
input.tick_end(); input.tick_end();
+8 -8
View File
@@ -72,20 +72,20 @@ void Menu::update(Game& game)
if (isReady && !wasReady && (match.isWeaponPick || match.isTrinketPick)) if (isReady && !wasReady && (match.isWeaponPick || match.isTrinketPick))
isOpen = false; isOpen = false;
wasReady = isReady; wasReady = isReady;
// Escape works as the menu control too, except on a match's results, where it goes back to the sandbox (unless // Escape works as the menu control too. On a match's results (with the menu closed), either goes back to the
// it's closing the menu over them); online, that's leaving the queued game. Watching one, Escape or the menu // sandbox instead, the menu control so there's a way that browsers don't keep for leaving fullscreen. Online,
// control goes back to the lobby instead. // that's leaving the queued game. Watching one, Escape or the menu control goes back to the lobby instead.
Session& session = game.session; Session& session = game.session;
bool isEscapePressed = input.is_pressed(SDL_SCANCODE_ESCAPE); bool isEscapePressed = input.is_pressed(SDL_SCANCODE_ESCAPE);
bool isEscape = isEscapePressed && (isOpen || match.state != MATCH_OVER); bool isMenuPressed = input.is_control_pressed(CONTROL_MENU);
isEscapeTaken = isEscape; isLeaving = (isEscapePressed || isMenuPressed) && !isOpen && match.state == MATCH_OVER;
if (isEscapePressed && !isOpen && match.state == MATCH_OVER && session.is_playing_arena(game)) if (isLeaving && session.is_playing_arena(game))
{ {
session.arena_leave(game); session.arena_leave(game);
isEscapeTaken = true; isLeaving = false;
return; return;
} }
if (input.is_control_pressed(CONTROL_MENU) || isEscape) if (!isLeaving && (isMenuPressed || isEscapePressed))
{ {
isOpen = !isOpen; isOpen = !isOpen;
game.audio.play(SOUND_SWAP); game.audio.play(SOUND_SWAP);
+2 -2
View File
@@ -63,8 +63,8 @@ public:
Page pages[TAB_COUNT]; Page pages[TAB_COUNT];
int tab = TAB_WEAPONS; int tab = TAB_WEAPONS;
bool isOpen = false; bool isOpen = false;
// Whether this tick's Escape went to the menu, so nothing else takes it too. // Whether the results were left this tick (by Escape or the menu control), back to the sandbox.
bool isEscapeTaken = false; bool isLeaving = false;
void update(Game& game); void update(Game& game);
void draw(Game& game); void draw(Game& game);
+7 -2
View File
@@ -458,9 +458,14 @@ void Ui::match_draw(Game& game)
float y = BANNER_Y + game.text.line_height_get(FONT_SMALL, BANNER_SCALE); float y = BANNER_Y + game.text.line_height_get(FONT_SMALL, BANNER_SCALE);
if (isRace) if (isRace)
y = results_draw(game, y); 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) 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; break;
} }
// Online, a queued game's players each say whether to play it again (listed under), or leave. // 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]; Binding binding = input.bindings[CONTROL_READY];
char key[TOOLTIP_LENGTH]; char key[TOOLTIP_LENGTH];
input.binding_name_get(isPad ? binding.pad : binding.key, isPad, key, sizeof(key)); 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); text_center_draw(game, text, y, 1);
y += LINE_HEIGHT * 2; y += LINE_HEIGHT * 2;
} }