Skip to content

menu: a Restart row in Gameplay, beside Quit - #1266

Open
bronze-ff wants to merge 5 commits into
NotRexed:mainfrom
bronze-ff:feat/menu-restart
Open

bronze-ff wants to merge 5 commits into
NotRexed:mainfrom
bronze-ff:feat/menu-restart

Conversation

@bronze-ff

Copy link
Copy Markdown
Contributor

Adds a Restart row to the Insert menu's Gameplay tab, next to Quit, as asked in #1255's review. It is a separate PR because CONTRIBUTING asks for one topic per pull request.

Depends on #1255. This branch is built on top of it, so until #1255 is merged the diff here also shows its commits. Only the last commit, 224d744, is new.

What it does

  • It uses the same confirm step as Quit. The first activation shows Confirm, and a second one restarts. B or Esc cancels, and so do leaving the row, switching tab or closing the menu.
  • It reuses the restart question's Restart now path: save() and pipeline_cache_save(true), then WM_APP + 9. On Linux the game restarts in place with execve. On Windows it starts a new process (host/hos_relaunch.c). No new message or platform code.
  • quit_pending becomes pending, a pointer to the row waiting for its second press, so the two rows share one confirm state. The comment by the table now covers all three rows that count back from its end.

Validation

On CachyOS (RTX 5060, Hyprland/Wayland), on a build of main a1c4bcd plus this branch:

  • test_menu_hit, test_menu_restart, test_rumble_menu and test_input_background pass.
  • In the game, a virtual USB Xbox Series controller (uinput) opened the menu with View + Menu, switched to Gameplay with RB and selected Restart with the D-pad. Holding A showed Confirm without restarting, and B cancelled it. A pressed twice restarted the game in the same process. The log shows menu: restart, then display: window closed for a restart, then a new start that reaches the title video.
  • Quit still passes the same controller test on this build.

Not tested: Windows, a physical controller, Steam Game Mode.

🤖 Generated with Claude Code

bronze-ff and others added 4 commits November 9, 2026 15:58
Assisted-by: OpenAI Codex
Co-Authored-By: OpenAI Codex <codex@openai.com>
…t-menu

# Conflicts:
#	gpu/vk/vk_menu.cpp
#	host/posix/display_sdl.c
Review of NotRexed#1255: the window's own close (rx_close_asked, then
hos_window_closed_exit) does not force the pipeline cache, so Quit now calls
save() and pipeline_cache_save(true) before posting WM_CLOSE, as the restart
question's Restart now does. A comment by the table says Quit and Cheats
stay its last two rows, since kQuitRow and kCheatsRow count back from its
end (rows[] is not constexpr, so a static_assert on the name cannot check it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restart starts the game again from the Insert menu, with the same confirm
step as Quit: the first press shows Confirm, a second one restarts, B or Esc
cancels. It saves first and posts WM_APP + 9, the restart question's
Restart now path (host/hos_relaunch.c: execve in place on Linux, a new
process on Windows). quit_pending becomes pending, the row waiting for its
second press, so the two rows share the confirm state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@hckrman101 hckrman101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, it's exactly the Restart option I was after. Reviewed the new commit on top of #1255 (so this should merge after it).

What I checked and it holds up:

  • One shared pending pointer means Quit and Restart can never both be armed, and a press on one can't confirm the other. Moving to another row, switching tab, closing the menu, B/Esc or right click all clear it. A click on the other row clears and then arms that row, so it still needs its own second press.
  • kRestartRow/kQuitRow/kCheatsRow still count back from the end and are right. Cheats being hidden only affects row_shown, not the indices, and the comment now says the last three rows.
  • The restart goes through the same save + pipeline_cache_save(true) + WM_APP + 9 path as the restart question's Restart now. On Linux that ends in execve in place with the original args/env, on Windows a new process with HOS_RESTART_OF, and the old one closes the window first. No host change needed.
  • Help text and the Confirm label look fine.

One small nit inline, nothing blocking.

Comment thread gpu/vk/vk_menu.cpp Outdated
if (&r == &rows[kRestartRow]) { // (the restart question's Restart now: the window closes, then the game starts again)
logf("menu: restart");
open_now = false, changed = true;
PostMessageA(app_window(), WM_APP + 9, 0, 0);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Quit guards with if (const HWND window = app_window()) but this one posts straight to app_window() (same as the existing Restart now). Harmless if the window is always there, but a null check would match Quit. The save/cache/post sequence is also now written twice (here and in the restart question), so a tiny shared helper could keep them in step. Fine to leave as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The null check is in ff0651a: the Restart row now posts WM_APP + 9 only when app_window() returns a window, the same as Quit.

I left the shared helper out on purpose. It would also change the restart question's existing Restart now, and I'd rather keep this PR to the new row. I can send the helper as its own small PR if the maintainer wants it.

Re-checked on CachyOS: the renderer builds, and test_menu_hit, test_menu_restart, test_rumble_menu and test_input_background pass.

Review of NotRexed#1266: Quit posts WM_CLOSE only when app_window() has a window;
Restart now does the same before WM_APP + 9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants