feat(mods): pause menu buttons for mods, and a Longshot Options button that opens the menu #3209
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3209
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:feat/pause-menu-button"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The Insert menu can only be opened with a key (Insert, F1) or a pad chord, which a controller player may never find. The pause menu's System page now has a Longshot Options button below Title Screen that opens it.
The button is a system mod,
system/menu-button(on by default, can be switched off in the Mods tab), over a new API any mod can use:pauseMenu.addButton({ label })fromlongshot/game, permissionui.pausemenu(low risk), with apressedevent andsetLabel(the built-in button follows a change of Menu language), andsetVisible.settingsHost.open()(system mods only), over a newLS_ACTION_OPENrenderer action.This replaces #290 by @prob, which no longer fits how hooks are done on
main. The idea, the extra layout pane and the button's construction are theirs; this is a rewrite on hook sites:game/crates/game-core/src/pause_buttons/: two hidden panes are added toPaSystemMenu_00in memory, as the game reads it (a Rust port of #290'spause_layout.py, working on the loaded, relocated layout). No game file is written, and the Button prompts' archive is left alone.game/sites/sites.toml: fivepauseButtons.*sites. All five must be placed, orhas("game.pauseMenu")is false and nothing is changed on screen.host/pad_mods.c: while the cursor is on a mod's button, the game does not see A, and the host counts its presses for that button. A choice the game makes of a button it does not know leaves the page unable to close.Testing
Tested: Linux (CachyOS), NVIDIA RTX 3090, driver 620.70.06, this checkout built over a shared base, headless runs driven over the control bridge from the
kokiri-startsave, with the pad:Game-free: new tests for the layout edit (including a loaded, relocated layout), the two slots, and a press while the cursor is on a button. The tests of
host-sys,game-core,api,longshot-game,ffi-genand the Insert menu's pass.mise run test, the failures left:mainon this PC:test_present_held_image,test_present_acquire_ahead,test_present_geometry_trace,test_present_image_free,test_dlssg,test_no_map_reload,test_no_game_title,test_sync_watch_event,test_ui_renderer,test_turf_budget,test_vk_draw_overhead_lean;test_lifteralso fails on plainmainon this PC the same ways: its clippy step stops onsettings_abi.rs, andcargo test --workspacefails inbuild-driver(tools.lockagainst the table),longshot-builder(one_copy) andnet-broker(socket path too long here).With the pause menu open, turning the checkbox's setting off and on (through the control bridge) hid and showed the button at once; a page opened while it was off had no button, the cursor stopped at Title Screen, and the shown button opened the menu. The checkbox itself was not clicked in the Insert menu.
Still to test:
Measurements
Not measured: nothing is rendered or computed differently in play. The sites run when the pause menu's layout is read, its page is made and a button changes state; each frame adds one short check in the mods' services, and the pad read a flag load or two.
Risks
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Co-Authored-By: prob [email protected]
Assisted-by: Claude Code (Claude Sonnet 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2NRBuhritgQ3NpoUV
Tested in game: Linux (CachyOS), RTX 3090, driver 620.70.06, headless from the kokiri-start save, on
f359e262plus this branch: the Longshot Options button shows below Title Screen; A opens the Insert menu (twice); after closing it B closes the pause menu; reopening and the game's own buttons work.The pause menu's System page, cursor moved down as far as it goes (Linux, RTX 3090, headless).
Before: main @
ee9e1ed7(the shared base): five buttons.After: this PR @
2874e5b7: Longshot Options below Title Screen.Possibly related, for context:
@review
Recommendation: Request changes. The button works in the recorded Linux run, but input and lifecycle races can deliver the wrong action or let the game select a button it cannot handle. A failed button allocation can also leave a visible, nonfunctional button.
Adds mod buttons to the pause menu and a default-enabled system button that opens Longshot Options. It makes the menu easier to discover for controller players, at the cost of new layout hooks and input interception that need stronger synchronization and failure handling.
Blocking (2): must change before merging.
game/crates/game-core/src/pause_buttons/mod.rs:177: The frame and the worker-thread state hook can publish conflicting cursor states out of order. (more on the line) Do: Serialize cursor-state publication with the state hook, or publish a generation-tagged state so an older frame cannot overwrite a newer transition. Add a test for this interleaving.game/crates/game-core/src/pause_buttons/mod.rs:161: Presses are counted separately from their button identity, so a press can be delivered to a different button. (more on the line) Do: Record the selected button identity together with each press at input time, and drain those records in order at the service frame.Should fix (3): not blocking, but worth doing before merging.
host/pad_mods.c:92: Disarming resets the remembered A state even when A is still held. (more on the line) Do: Track the physical A edge across cursor transitions, including while the cursor is outside a mod button, and count only a new down edge.game/crates/game-core/src/pause_buttons/mod.rs:285: The pane becomes visible before allocation and initialization of its button have succeeded. (more on the line) Do: Construct and initialize the control before showing its pane, and roll back any partial construction when a later step fails.game/mods/menu-button/src/main.ts:6: The built-in button translates its label only when the mod starts. (more on the line) Do: Refresh or replace the button when the menu language changes, preserving its press handler and updating the next constructed page.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4 and L5.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the demonstrated path: the author reports opening the menu twice and returning to play on Linux with an RTX 3090 using bridge-driven pad input. Physical controller, mouse, Windows, other languages and the game-over path remain untested.
Other systems: The hooks run on game worker threads, while the mod service runs at the acquire phase and the host filters pad reads from multiple threads. The change also affects mouse-generated A presses, game menu layout loading, translated labels and renderer menu actions. The recorded run covers one Linux/NVIDIA configuration; Windows and physical input remain unverified.
Switches: No environment switches added, changed or removed. The system/menu-button mod is enabled by default and can be disabled in the Mods tab; that default fits the feature, subject to the input fixes and remaining runs.
Reviewed:
2874e5b7eaagainstf359e26213: Read the repository rules, PR template, standards, commit and diff; read the new pause-button implementation, layout editor, service, host input path, menu action, schemas, system mod and its test. Skimmed translations, generated schema, documentation changes and other small integration changes. The rest of the changed code files and their surrounding callers were not all read in full; docs/review-checklist.md is absent.; nothing run (a code review).Checked and fine:
Testing: No code, tests or scripts were run during review. All listed CI checks are still running; the author reports the game-free checks and one Linux game run described above.
Overlaps and merge order: The description says this replaces #290; no other overlap was established from the available checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +158,4 @@let mut s = state();let mut pressed = Vec::new();// (the presses are of the button the cursor was on when they were made: the last frame's)if count != s.counted {L2 (blocking): Presses are counted separately from their button identity, so a press can be delivered to a different button.
When: The player presses A on the first mod button and moves to the second before the next service frame. The host increments its global counter, then on_state replaces s.on with the second key; frame delivers the first button's press to the second mod.
Do: Record the selected button identity together with each press at input time, and drain those records in order at the service frame.
@ -0,0 +174,4 @@// (a button taken away keeps its A from the game while the page still shows it: choosing it would lock the page)s.on = slot.map_or(0, |i| page.keys[i]);drop(s);host_sys::input::pad_menu_button(slot.is_some());L1 (blocking): The frame and the worker-thread state hook can publish conflicting cursor states out of order.
When: A frame reads the old control state and decides the cursor is not on a mod button. The worker then moves onto the button and arms the host in on_state, but the frame subsequently publishes false. An A read before the next frame reaches the game, which can select the unknown button and leave the pause page unable to close.
Do: Serialize cursor-state publication with the state hook, or publish a generation-tagged state so an older frame cannot overwrite a newer transition. Add a test for this interleaving.
@ -0,0 +282,4 @@return Ok(());}let Some(button) = button else { continue };let tree = call1(c, PART_LAYOUT, "a part's layout", &[page + PART_BODY])?;L4 (should fix): The pane becomes visible before allocation and initialization of its button have succeeded.
When: If the game's button allocation returns zero, make returns after setting VISIBLE. The page shows a button with no constructed control or press handler.
Do: Construct and initialize the control before showing its pane, and roll back any partial construction when a later step fails.
@ -0,0 +3,4 @@import { t } from "longshot/i18n";import { open } from "longshot/settings-host";const button = pauseMenu.addButton({ label: t("Longshot Options") });L5 (should fix): The built-in button translates its label only when the mod starts.
When: A player changes Menu language during a session. Other menu text changes, but reopening the pause menu still shows the button in the old language because the stored label never changes.
Do: Refresh or replace the button when the menu language changes, preserving its press handler and updating the next constructed page.
@ -83,0 +89,4 @@if (on) __atomic_store_n(&button_at_ns, hos_now_ns(), __ATOMIC_RELEASE);if ((__atomic_load_n(&button_armed, __ATOMIC_RELAXED) != 0) == (on != 0)) return;/* (reads are not seen while off the button: A is taken to be up when the cursor comes back) */if (!on) __atomic_store_n(&button_down, 0u, __ATOMIC_SEQ_CST);L3 (should fix): Disarming resets the remembered A state even when A is still held.
When: A player holds A while moving from a game button onto a mod button. The next pad read sees armed and !was, counts a new press and invokes the mod even though A was not pressed again.
Do: Track the physical A edge across cursor transitions, including while the cursor is outside a mod button, and count only a new down edge.
WIP: feat(mods): pause menu buttons for mods, and a Longshot Options button that opens the menuto feat(mods): pause menu buttons for mods, and a Longshot Options button that opens the menuRecommendation: Request changes. The button can receive a press intended for another mod, and competing cursor updates can leave A incorrectly exposed to or withheld from the game. The recorded manual input and platform checks also remain outstanding.
Adds a default-enabled Longshot Options button to the pause menu and an API for mods to add buttons. The Linux bridge-driven run shows the intended flow, but cursor and press handling still have correctness defects.
Blocking (2): must change before merging.
game/crates/game-core/src/pause_buttons/mod.rs:177: The frame and the worker-thread state hook can publish conflicting cursor states out of order. When: A frame reads the old control state and decides the cursor is not on a mod button. The worker then moves onto the button and arms the host in on_state, but the frame subsequently publishes false. An A read before the next frame reaches the game, which can select the unknown button and leave the pause page unable to close. Do: Serialize cursor-state publication with the state hook, or publish a generation-tagged state so an older frame cannot overwrite a newer transition. Add a test for this interleaving.game/crates/game-core/src/pause_buttons/mod.rs:161: Presses are counted separately from their button identity, so a press can be delivered to a different button. When: The player presses A on the first mod button and moves to the second before the next service frame. The host increments its global counter, then on_state replaces s.on with the second key; frame delivers the first button's press to the second mod. Do: Record the selected button identity together with each press at input time, and drain those records in order at the service frame.Should fix (3): not blocking, but worth doing before merging.
host/pad_mods.c:92: Disarming resets the remembered A state even when A is still held. When: A player holds A while moving from a game button onto a mod button. The next pad read sees armed and !was, counts a new press and invokes the mod even though A was not pressed again. Do: Track the physical A edge across cursor transitions, including while the cursor is outside a mod button, and count only a new down edge.game/crates/game-core/src/pause_buttons/mod.rs:285: The pane becomes visible before allocation and initialization of its button have succeeded. When: If the game's button allocation returns zero, make returns after setting VISIBLE. The page shows a button with no constructed control or press handler. Do: Construct and initialize the control before showing its pane, and roll back any partial construction when a later step fails.game/mods/menu-button/src/main.ts:6: The built-in button translates its label only when the mod starts. When: A player changes Menu language during a session. Other menu text changes, but reopening the pause menu still shows the button in the old language because the stored label never changes. Do: Refresh or replace the button when the menu language changes, preserving its press handler and updating the next constructed page.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4 and L5.Since the last review (on
2874e5b7ea)Still open: L1 (The frame and the worker-thread state hook can publish conflicting cursor states out of or…); L2 (Presses are counted separately from their button identity, so a press can be delivered to…); L3 (Disarming resets the remembered A state even when A is still held.); L4 (The pane becomes visible before allocation and initialization of its button have succeeded…); L5 (The built-in button translates its label only when the mod starts.); L6 (The player-facing input paths still need the recorded manual checks.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested flow: the author reports that the button appeared and opened the menu twice on Linux with an RTX 3090 using bridge-driven pad input. Real controller, mouse, Windows and other listed manual checks remain unverified.
Other systems: The host pad path runs on Windows and Linux and can affect A outside the mod button; the recorded run covers Linux through the control bridge. Translation rendering, mouse input, Windows and the game-over path remain untested as described in the pull request.
Switches: The system mod Pause menu button is enabled by default and can be disabled in the Mods tab. Its intended default makes the menu discoverable, but the input defects must be fixed before shipping it.
Reviewed:
2874e5b7eaagainstf359e26213: Read the pause-button core module, host pad implementation, built-in mod entry point, project rules and pull request template; inspected the related API and documentation, diff excerpts, commit list and recorded runs. The full diff, remaining changed code, generated files and translations were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports game-free tests and a Linux bridge-driven game run; CI is still running.
Overlaps and merge order: The pull request says it replaces #290; no independent overlap check was available.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.
BeanBot's five findings checked against the code, all held, fixed in
7fcff12d:a_frame_never_undoes_what_the_cursor_just_did).a_press_is_its_own_buttons_though_the_cursor_moved_on).PauseMenuButton.setLabel; the built-in button calls it when Menu language changes the text. It shows from the next time the menu is opened or its cursor moves.Run again on the same PC (Linux, RTX 3090, bridge pad): the open/close steps, the tab and Plus edge cases, and a
setLabelmade while playing (a temporary line in the mod), which showed on the next opening and still opened the menu. L3 and L4 were not provoked in game.The Insert menu's own tests pass except once on a loaded PC:
the_menu_passes_its_testsmissed its 2 ms a frame script budget (search 2.28 ms); it passed on the run before.L6 (real controller, mouse, Windows, another language, game over) is still to test, as the description says.
🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2NRBuhritgQ3NpoUV
Pushed a Pause menu button checkbox (Debug tab, Developer page, on by default) that hides or shows the Longshot Options button live, over a new
PauseMenuButton.setVisible. Checked in game on Linux (RTX 3090, headless) by setting it through the control bridge with the pause menu open.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2NRBuhritgQ3NpoUV