panel: any key for the settings menu, and save on close #389

Open
github-bot wants to merge 3 commits from github-bot/gh-389 into main AGit
Owner

@⁠TuxArchi on GitHub · 2026-12-03 23:43 UTC · original
TuxArchi:menu-key-and-save → main · +135 −9 · 1 files · 3 commits · open

What

  • VICTORY_MENU_KEY chooses the key that opens the settings menu. It accepts:
    • letters A..Z and digits 0..9
    • F1..F24
    • Space, Tab, Backspace, Insert, Home, End, PageUp, PageDown
    • -, =, ,, ., /, ;, ', [, ], \, ` and their names
    • F1 when unset, invalid, or a key the menu itself uses
  • Keys the menu needs are rejected: arrows, Enter, Esc, Delete, F3 (panel) and
    F10 (save+restart).
  • Closing the menu (its key or Esc) saves explicitly. F10 still saves and
    restarts so the values apply.
  • A single-key menu binding does not fire while Ctrl, Shift or Alt is held, so
    a chord such as Ctrl+K reaches another mod instead of also opening this menu.
  • The panel hint and menu footer show the configured key.

Why

The key was hardcoded to F1. A launcher can now expose it, and closing the menu
no longer risks losing a change before F10.

Testing

  • cargo check --release -p victory and ./build.sh on the AMD port with the
    patch applied.
  • VICTORY_MENU_KEY defaults to F1 when absent or invalid.
  • No change to the settings file format: the key is read from the environment
    (run.sh exports run.conf), so it does not need a new row in
    run.conf.default and the menu preserves the unknown line.
**@⁠TuxArchi** on GitHub · 2026-12-03 23:43 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/389) `TuxArchi:menu-key-and-save` → `main` · +135 −9 · 1 files · 3 commits · open ## What - `VICTORY_MENU_KEY` chooses the key that opens the settings menu. It accepts: - letters `A`..`Z` and digits `0`..`9` - `F1`..`F24` - `Space`, `Tab`, `Backspace`, `Insert`, `Home`, `End`, `PageUp`, `PageDown` - `-`, `=`, `,`, `.`, `/`, `;`, `'`, `[`, `]`, `\`, `` ` `` and their names - `F1` when unset, invalid, or a key the menu itself uses - Keys the menu needs are rejected: arrows, Enter, Esc, Delete, F3 (panel) and F10 (save+restart). - Closing the menu (its key or Esc) saves explicitly. F10 still saves and restarts so the values apply. - A single-key menu binding does not fire while Ctrl, Shift or Alt is held, so a chord such as Ctrl+K reaches another mod instead of also opening this menu. - The panel hint and menu footer show the configured key. ## Why The key was hardcoded to F1. A launcher can now expose it, and closing the menu no longer risks losing a change before F10. ## Testing - `cargo check --release -p victory` and `./build.sh` on the AMD port with the patch applied. - `VICTORY_MENU_KEY` defaults to F1 when absent or invalid. - No change to the settings file format: the key is read from the environment (`run.sh` exports `run.conf`), so it does not need a new row in `run.conf.default` and the menu preserves the unknown line.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 23:46:49 +00:00
github-bot changed title from panel: configurable menu key and save on close to panel: any key for the settings menu, and save on close 2026-12-03 23:57:22 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 03:24 UTC · original

Built and tested this natively on Windows 11 (MSVC). The victory-gpu lib tests pass apart from the same native failures main already has. I also ran a throwaway test of parse_menu_key and rendered the panel and menu with the GDI preview. A few things came up.

  1. The modifier guard can still open the menu on the chord it is meant to protect. With the menu on K, press Ctrl+K and let go of Ctrl a moment before K. On the next poll Ctrl is up and K is still down, so bit 0 goes from 0 to 1 and that counts as a fresh press. Masking the edge would avoid this. Keep reading K into held as usual and only clear bit 0 of pressed while a modifier is down. Then a key that went down under a modifier never produces an edge. Also note that Shift+F1, Ctrl+F1 and Alt+F1 no longer open the menu with the default key, which used to work.

  2. The parser rejects the menu's own keys but still accepts 0, - and =. Those are the F3 chords for HUD size (F3+0 reset, F3+- and F3+= resize). Bound to one of them, F3+0 resets the size and toggles the menu at once, since Hotkeys and MenuKeys poll independently. Keys the title maps are accepted too, like Space, Tab, Backspace, F2 and the backtick (F2 and backtick also toggle mouse look in gameinput). GetAsyncKeyState doesn't consume anything, and the title only stops getting keys once menu::is_open() is set. So the press that opens the menu reaches the game, and so does the key still held after the close. Maybe reject F2, the backtick and the F3 chord keys, or at least document it.

  3. Save on close looks redundant. Main already saves after every Left/Right/Del (the if edited && pressed & 0b1100 == 0 block), and the menu says changes are saved at once. A close will normally find nothing to write, since Menu::save returns early when the text is unchanged. It's harmless, but the "risks losing a change before F10" reason doesn't really hold on main. "(saves)" in the footer fits fine at 1080p.

  4. The hint in the full panel is cut off with longer key names. With VICTORY_MENU_KEY=CloseBracket it renders as "F3 hide Shift+F3 compact CloseBr..." and "Config" is gone. "F1 Config" just about fits now.

  5. Smaller things. VICTORY_MENU_KEY isn't in docs/SETTINGS.md. The OEM names assume a US layout, and on other layouts -, ; and ' are different physical keys. Clippy reports two new collapsible_if warnings in the close-save block (panel.rs:490/491). rustfmt also wants changes in the new import list, the matches! and the hint format!.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 03:24 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/389#issuecomment-7400042532) Built and tested this natively on Windows 11 (MSVC). The victory-gpu lib tests pass apart from the same native failures main already has. I also ran a throwaway test of `parse_menu_key` and rendered the panel and menu with the GDI preview. A few things came up. 1. The modifier guard can still open the menu on the chord it is meant to protect. With the menu on K, press Ctrl+K and let go of Ctrl a moment before K. On the next poll Ctrl is up and K is still down, so bit 0 goes from 0 to 1 and that counts as a fresh press. Masking the edge would avoid this. Keep reading K into `held` as usual and only clear bit 0 of `pressed` while a modifier is down. Then a key that went down under a modifier never produces an edge. Also note that Shift+F1, Ctrl+F1 and Alt+F1 no longer open the menu with the default key, which used to work. 2. The parser rejects the menu's own keys but still accepts `0`, `-` and `=`. Those are the F3 chords for HUD size (F3+0 reset, F3+- and F3+= resize). Bound to one of them, F3+0 resets the size and toggles the menu at once, since `Hotkeys` and `MenuKeys` poll independently. Keys the title maps are accepted too, like Space, Tab, Backspace, F2 and the backtick (F2 and backtick also toggle mouse look in gameinput). `GetAsyncKeyState` doesn't consume anything, and the title only stops getting keys once `menu::is_open()` is set. So the press that opens the menu reaches the game, and so does the key still held after the close. Maybe reject F2, the backtick and the F3 chord keys, or at least document it. 3. Save on close looks redundant. Main already saves after every Left/Right/Del (the `if edited && pressed & 0b1100 == 0` block), and the menu says changes are saved at once. A close will normally find nothing to write, since `Menu::save` returns early when the text is unchanged. It's harmless, but the "risks losing a change before F10" reason doesn't really hold on main. "(saves)" in the footer fits fine at 1080p. 4. The hint in the full panel is cut off with longer key names. With `VICTORY_MENU_KEY=CloseBracket` it renders as "F3 hide Shift+F3 compact CloseBr..." and "Config" is gone. "F1 Config" just about fits now. 5. Smaller things. `VICTORY_MENU_KEY` isn't in docs/SETTINGS.md. The OEM names assume a US layout, and on other layouts `-`, `;` and `'` are different physical keys. Clippy reports two new `collapsible_if` warnings in the close-save block (panel.rs:490/491). rustfmt also wants changes in the new import list, the `matches!` and the hint `format!`. AI-assisted: yes
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 11:28 UTC · original

The configurable key part I would take: VK_F1 + number - 1 reaching VK_F24 is right, single characters map to their ASCII virtual-key codes, the modifier skip is scoped to the menu key's own bit, and the longest footer still fits at 660.

Two things:

  • The save-on-close hunk should go. The panel already saves after every edit — crates/victory-gpu/src/host/panel.rs:420-424 — which is why the footer says "Changes are saved at once"; the new block is a second write on every close, including when nothing changed.
  • VICTORY_MENU_KEY is undocumented, and an unusable value is indistinguishable from unset: Shift, ESC and a typo all fall through to VK_F1 silently. One row in docs/SETTINGS.md:144-151 next to VICTORY_MENU=0, plus a tracing::warn! naming the rejected value.

Minor: menu_key_label() formats a String on every paint; caching it beside the OnceLock would read better.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/389#issuecomment-7410141714) The configurable key part I would take: `VK_F1 + number - 1` reaching `VK_F24` is right, single characters map to their ASCII virtual-key codes, the modifier skip is scoped to the menu key's own bit, and the longest footer still fits at 660. Two things: - The save-on-close hunk should go. The panel already saves after every edit — `crates/victory-gpu/src/host/panel.rs:420-424` — which is why the footer says "Changes are saved at once"; the new block is a second write on every close, including when nothing changed. - `VICTORY_MENU_KEY` is undocumented, and an unusable value is indistinguishable from unset: `Shift`, `ESC` and a typo all fall through to `VK_F1` silently. One row in `docs/SETTINGS.md:144-151` next to `VICTORY_MENU=0`, plus a `tracing::warn!` naming the rejected value. Minor: `menu_key_label()` formats a `String` on every paint; caching it beside the `OnceLock` would read better.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/389/head:github-bot/gh-389'
git switch 'github-bot/gh-389'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-389'
git switch 'github-bot/gh-389'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-389'
git switch 'github-bot/gh-389'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-389'
git switch 'main'
git merge --squash 'github-bot/gh-389'
git switch 'main'
git merge --ff-only 'github-bot/gh-389'
git switch 'main'
git merge 'github-bot/gh-389'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.