refactor(menu): each row goes where its place says; layout.ts keeps tabs, pages, headings and links #2861

Merged
HumanBean merged 1 commit from HumanBean/Longshot:cleanup/area5-menu-layout into mod-api 2026-11-30 03:46:44 +00:00
Owner

Summary

The Insert menu's layout used to be written down twice. game/mods/menu/src/layout.ts listed every row of every tab in order (200 keys). The system mods' mod.toml files also gave 245 rows a place, but the menu read a place only for a row the layout did not name. So 184 rows had two places, and the one in mod.toml was ignored.

Now there is one rule, the same one a player's mod already uses: every row goes where its declaration's place says. layout.ts keeps only the tabs, the pages, the headings, and the menu's own links and lines, down from about 300 lines to about 100. Each row is laid out by view.ts laidOut:

  • If the place names a row or link (after or before), the row goes next to it, in that row's section.
  • Otherwise it goes at the end of its section, or at the end of the tab's untitled top when it names no section.
  • Rows at the same spot go by order, then in the order they were declared.
  • An anchor that is not on the tab is ignored, and so are anchors that loop back on each other.

The layout's links and lines are placed by the same rule.

Every row stays where it was. To get there, 14 place lines changed across the graphics, interface, developer, cheats, controls and damage mods. Layout preset and Button prompts are now placed on the Controls page, which is where they were already drawn.

The settings table in docs/user/graphics-and-controls.md listed six rows in a different order from the menu. Those lines now follow the menu's order.

Removed:

  • the row lists in layout.ts and view.ts's panelKeys and LAID_OUT;
  • tests/test_system_settings_placed.py, a Python re-implementation of laidOut;
  • game/crates/longshot-game/tests/menu_places.tsv and the test that read it.

Read first: game/mods/menu/src/view.ts (panelLines), game/mods/menu/src/layout.ts, and game/mods/menu/test/menu.test.ts (PLACED and the layout tests).

Part of the mod-api cleanup (area 5).

Testing

Tested: On Linux with an RTX 3090:

  • Snapshot. Before changing anything, I ran the old laidOut on the old manifests (the recordings rows included) and the new laidOut on the new manifests. Every tab and page matches in order and in each row's section. That snapshot is now PLACED in menu.test.ts, and the menu's layout tests are held to it.
  • Menu tests. They pass on the fake game: cargo test -p modtool the_typescript_system_mods_pass_their_tests, run through the queue. That covers each tab drawn in PLACED's order and every system mod's place naming a tab, heading and anchor the menu has (these checks used to be in test_system_settings_placed.py). It also covers each section keeping a row on every PC, laidOut's rules on rows made up for the test, and the docs table in the menu's order.
  • Other checks:
    • cargo test -p longshot-game menu passes.
    • cargo clippy -p modtool -p longshot-game --all-targets is clean.
    • schema-gen --check passes.
    • run_all --exact passes for test_menu_ini_keys, test_pipeline_share, test_audio_volume, test_pad_speaker, test_upscaler_rows and test_menu_i18n.
  • Full tests/run_all.py: 732 passed and 2 failed, and neither failure is from this change. test_lifter's cargo fmt --check trips on api/services/mod.rs and game-core/src/nav.rs from #2745, which is already on mod-api. byte_compile_tracked looks for the deleted Python test because the jj workspace's git index is stale; it passes on a checkout of the commit.
  • Game run. I ran a headless game from the kokiri-start save through the queue. The Insert menu opened, hosted by system/menu, and all seven tabs were stepped through with no script error. The bridge's screenshots show the game picture without the menu, so they say nothing about the rows' order.

Still to test:

  • Any PC: open the Insert menu and look through every tab and page, expecting the same rows in the same order as on mod-api (by hand).
  • Any PC: switch the cheats mod off on the Mods tab, expecting Damage taken to stay on the Debug tab under Input recording (by hand).

Measurements

Nothing to measure: no game code or rendering changed. The menu's own cost test still passes (see Risks for its tab-switch ceiling). Measured outside the game, laidOut for the Graphics tab takes 0.32 ms against 0.50 ms before.

Risks

  • Rows in a different place. A place that does not match the old layout would move a row. PLACED fails on any such move with all of Longshot's mods on.
  • Optional mods off. Some rows sit in a slightly different place than before:
    • With the Damage mod off, Mark position goes last on the Debug tab. Before, the old algorithm put it next to Return to mark. With every mod on it is last, as it was, so order = 120 keeps it there.
    • With the Grass mod off, the shadow rows now stay under Detail. Before, they fell to the end of the tab.
  • Players' mods. A row whose place gives only tab, or names an anchor that is missing, now goes to the end of the tab's untitled top, before its first heading. Before, it went to the end of the tab. The docs already said "the tab's top"; the code now matches them. The mod API is not shipped yet.
  • Cost test. It now declares every system row, not only the rows the layout named: 58 on the Graphics tab where it was 38. So its tab-switch ceiling goes from 4.5 to 5.5 ms. It measured 4.49 ms with a quiet queue and 5.35 ms while a game ran beside it, which is close to the new ceiling on a busy PC.
  • Translation. Game queue priority was already untranslated on mod-api, which made the menu's translation test fail. It is now on UNTRANSLATED.
  • Reverting. A revert is enough. Nothing changes in players' files.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (run_all: 2 failures, both named above as not from this change.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Screenshots of the same spot on main and here, for a change that shows on screen. (The bridge's screenshots do not include the menu: a by-hand look is in Still to test.)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc

## Summary The Insert menu's layout used to be written down twice. `game/mods/menu/src/layout.ts` listed every row of every tab in order (200 keys). The system mods' `mod.toml` files also gave 245 rows a `place`, but the menu read a `place` only for a row the layout did not name. So 184 rows had two places, and the one in `mod.toml` was ignored. Now there is one rule, the same one a player's mod already uses: every row goes where its declaration's `place` says. `layout.ts` keeps only the tabs, the pages, the headings, and the menu's own links and lines, down from about 300 lines to about 100. Each row is laid out by `view.ts` `laidOut`: - If the place names a row or link (`after` or `before`), the row goes next to it, in that row's section. - Otherwise it goes at the end of its `section`, or at the end of the tab's untitled top when it names no section. - Rows at the same spot go by `order`, then in the order they were declared. - An anchor that is not on the tab is ignored, and so are anchors that loop back on each other. The layout's links and lines are placed by the same rule. Every row stays where it was. To get there, 14 place lines changed across the graphics, interface, developer, cheats, controls and damage mods. Layout preset and Button prompts are now placed on the Controls page, which is where they were already drawn. The settings table in `docs/user/graphics-and-controls.md` listed six rows in a different order from the menu. Those lines now follow the menu's order. Removed: - the row lists in `layout.ts` and `view.ts`'s `panelKeys` and `LAID_OUT`; - `tests/test_system_settings_placed.py`, a Python re-implementation of `laidOut`; - `game/crates/longshot-game/tests/menu_places.tsv` and the test that read it. Read first: `game/mods/menu/src/view.ts` (`panelLines`), `game/mods/menu/src/layout.ts`, and `game/mods/menu/test/menu.test.ts` (`PLACED` and the layout tests). Part of the mod-api cleanup (area 5). ## Testing **Tested:** On Linux with an RTX 3090: - **Snapshot.** Before changing anything, I ran the old `laidOut` on the old manifests (the recordings rows included) and the new `laidOut` on the new manifests. Every tab and page matches in order and in each row's section. That snapshot is now `PLACED` in `menu.test.ts`, and the menu's layout tests are held to it. - **Menu tests.** They pass on the fake game: `cargo test -p modtool the_typescript_system_mods_pass_their_tests`, run through the queue. That covers each tab drawn in `PLACED`'s order and every system mod's place naming a tab, heading and anchor the menu has (these checks used to be in `test_system_settings_placed.py`). It also covers each section keeping a row on every PC, `laidOut`'s rules on rows made up for the test, and the docs table in the menu's order. - **Other checks:** - `cargo test -p longshot-game menu` passes. - `cargo clippy -p modtool -p longshot-game --all-targets` is clean. - `schema-gen --check` passes. - `run_all --exact` passes for `test_menu_ini_keys`, `test_pipeline_share`, `test_audio_volume`, `test_pad_speaker`, `test_upscaler_rows` and `test_menu_i18n`. - **Full `tests/run_all.py`:** 732 passed and 2 failed, and neither failure is from this change. `test_lifter`'s `cargo fmt --check` trips on `api/services/mod.rs` and `game-core/src/nav.rs` from #2745, which is already on mod-api. `byte_compile_tracked` looks for the deleted Python test because the jj workspace's git index is stale; it passes on a checkout of the commit. - **Game run.** I ran a headless game from the kokiri-start save through the queue. The Insert menu opened, hosted by `system/menu`, and all seven tabs were stepped through with no script error. The bridge's screenshots show the game picture without the menu, so they say nothing about the rows' order. **Still to test:** - Any PC: open the Insert menu and look through every tab and page, expecting the same rows in the same order as on mod-api (by hand). - Any PC: switch the cheats mod off on the Mods tab, expecting Damage taken to stay on the Debug tab under Input recording (by hand). ## Measurements Nothing to measure: no game code or rendering changed. The menu's own cost test still passes (see Risks for its tab-switch ceiling). Measured outside the game, `laidOut` for the Graphics tab takes 0.32 ms against 0.50 ms before. ## Risks - **Rows in a different place.** A place that does not match the old layout would move a row. `PLACED` fails on any such move with all of Longshot's mods on. - **Optional mods off.** Some rows sit in a slightly different place than before: - With the Damage mod off, Mark position goes last on the Debug tab. Before, the old algorithm put it next to Return to mark. With every mod on it is last, as it was, so `order = 120` keeps it there. - With the Grass mod off, the shadow rows now stay under Detail. Before, they fell to the end of the tab. - **Players' mods.** A row whose place gives only `tab`, or names an anchor that is missing, now goes to the end of the tab's untitled top, before its first heading. Before, it went to the end of the tab. The docs already said "the tab's top"; the code now matches them. The mod API is not shipped yet. - **Cost test.** It now declares every system row, not only the rows the layout named: 58 on the Graphics tab where it was 38. So its tab-switch ceiling goes from 4.5 to 5.5 ms. It measured 4.49 ms with a quiet queue and 5.35 ms while a game ran beside it, which is close to the new ceiling on a busy PC. - **Translation.** Game queue priority was already untranslated on mod-api, which made the menu's translation test fail. It is now on `UNTRANSLATED`. - **Reverting.** A revert is enough. Nothing changes in players' files. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). (`run_all`: 2 failures, both named above as not from this change.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Screenshots of the same spot on `main` and here, for a change that shows on screen. (The bridge's screenshots do not include the menu: a by-hand look is in Still to test.) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
refactor(menu): each row goes where its place says; layout.ts keeps tabs, pages, headings and links
Some checks failed
PR description / Title and description (pull_request_target) Failing after 16s
4c27c14cba
The menu's layout named every row of every tab in order (layout.ts), and the system mods' mod.toml gave
184 of the same rows a place that was read only for a row the layout did not name. Now there is one rule
for Longshot's rows and a player's mod's: view.ts laidOut lays out the layout's headings and puts every row,
and the layout's own links and lines, where its place says (after or before a row or link, else at its
section's end, the untitled top without one, by its order, then as declared; an anchor not on the page or
in a loop is none). The menu reads a page's rows by the page alone (no panelKeys).

The places that disagreed with the layout are fixed so every row stays where it was: 13 place lines in
the graphics, interface, developer, cheats and controls mods (Layout preset and Button prompts are placed
on the Controls page they were drawn on), and Damage taken names its section, so it stays there with the
cheats mod off. The settings page's table (docs/user) had six lines in another
order than the menu's: moved to the menu's.

The menu mod's test holds each tab's and page's laid-out lines to PLACED, the order laidOut gave from the
old layout (checked on the old code), and takes over tests/test_system_settings_placed.py's checks (every
system mod's setting a row, its place naming a tab, heading and anchor the menu has). The fake game's
systemSettings gives a row's after, before and order, declare passes them on, and unplacedSettings lists
the settings with no place. The cost test's tab-switch ceiling goes from 4.5 to 5.5 ms: it now draws
every system row (the Graphics tab 58, not the 38 the layout named; 4.49 ms measured), and Game queue
priority (a developer row, untranslated on mod-api already) is on UNTRANSLATED. Removed: layout.ts's row lists, the Python copy of laidOut,
longshot-game/tests/menu_places.tsv and its test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean merged commit 12f42db5c1 into mod-api 2026-11-30 03:46:44 +00:00
HumanBean deleted branch cleanup/area5-menu-layout 2026-11-30 03:46:45 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2861
No description provided.