feat(client): Add KeyboardOverlay option to show hotkeys on command bar cameos - #3216
feat(client): Add KeyboardOverlay option to show hotkeys on command bar cameos#3216triatomic wants to merge 2 commits into
Conversation
…ar cameos
Draws each command bar cameo's keyboard hotkey letter over the cameo, so
the player can learn the shortcuts without hunting through tooltips. The
letter comes from what actually got registered in the hotkey manager,
not from the button's label - colliding hotkeys are dropped at
registration, and drawing those would advertise a key that does nothing.
KeyboardOverlay = Yes ; off by default
KeyboardOverlayRed / Green / Blue ; letter colour, default white
KeyboardOverlayBackdrop = Yes ; translucent plate, on when
; the overlay itself is on
KeyboardOverlayBackdropRed / Green / Blue / Opacity
Display strings are cached per letter and returned to the manager by the
W3DDisplayStringManager destructor before the manager itself is torn
down, which its base class asserts on.
Available in both Zero Hour and Generals: the drawing lives in the
shared W3D push button gadget.
Ported from the Contra mod's engine fork, collapsing its three overlay
commits into the final state.
PR Summary by QodoAdd configurable hotkey overlays to command bar cameos
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding |
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp | Adds overlay rendering and display-string caching, but the single-byte guard omits functional non-ASCII hotkeys. |
| Core/GameEngine/Source/GameClient/MessageStream/HotKey.cpp | Adds window-to-registered-hotkey reverse lookup used to avoid advertising discarded collisions. |
| Core/GameEngine/Source/Common/OptionPreferences.cpp | Parses overlay enablement and clamped foreground/backdrop color channels. |
| Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp | Releases cached overlay display strings before manager teardown for Generals. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp | Mirrors overlay display-string teardown for Zero Hour. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Label[Localized command label] --> Search[Extract mnemonic]
Search --> UTF8[Translate to UTF-8]
UTF8 --> Register[Register hotkey]
Input[Printable keyboard input] --> InputUTF8[Translate to UTF-8]
InputUTF8 --> Execute[Execute registered command]
Register --> Lookup[Overlay reverse lookup]
Lookup --> Guard{Exactly one byte?}
Guard -->|Yes| Draw[Draw overlay]
Guard -->|No| Omit[Omit valid localized overlay]
Prompt To Fix All With AI
### Issue 1
Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp:137-138
**Localized overlays disappear**
When a localized command has a functional non-ASCII mnemonic, its registered UTF-8 key occupies multiple bytes, so this guard returns without drawing it and the teaching overlay silently omits that shortcut.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (2): Last reviewed commit: "fix(client): Draw the hotkey overlay onl..." | Re-trigger Greptile
A localized mnemonic outside ASCII arrives as a multi byte sequence, and drawing its first byte showed a wrong or garbled shortcut while sharing its cache slot with other keys starting on the same byte. Draw nothing for those instead.
| if( hotKey.getLength() != 1 || !isprint( (unsigned char)hotKey.getCharAt( 0 ) ) ) | ||
| return; |
There was a problem hiding this comment.
When a localized command has a functional non-ASCII mnemonic, its registered UTF-8 key occupies multiple bytes, so this guard returns without drawing it and the teaching overlay silently omits that shortcut.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
Line: 137-138
Comment:
**Localized overlays disappear**
When a localized command has a functional non-ASCII mnemonic, its registered UTF-8 key occupies multiple bytes, so this guard returns without drawing it and the teaching overlay silently omits that shortcut.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Adds an opt-in client option drawing each command bar cameo's keyboard hotkey letter over the cameo, so the player can learn the shortcuts without hunting through tooltips. Defaults off; behavior is retail unless set in Options.ini.
KeyboardOverlay (
= Yes) — the letter comes from what actually got registered in the hotkey manager, not from the button's label: colliding hotkeys are dropped at registration, and drawing those would advertise a key that does nothing. Cosmetics are configurable:KeyboardOverlayRed / Green / Blue— letter color, 0–255 each, default whiteKeyboardOverlayBackdrop(= Yes, default on while the overlay is on) — translucent plate behind the letter so it stays readable over busy cameo artKeyboardOverlayBackdropRed / Green / Blue / Opacity— plate color, default black at 50%Display strings are cached per letter and returned to the manager by the
W3DDisplayStringManagerdestructor before teardown — the same pattern that destructor already uses for its group-numeral strings, and the same issue class Qodo flagged on #3214, fixed here preemptively.Works in both Zero Hour and Generals — the drawing lives in the shared W3D push button gadget, with per-game GlobalData plumbing.
This option ships in the Contra mod's engine fork and has been played there; this PR is the port onto current main, collapsing the fork's three overlay commits into their final state. Code was written with LLM assistance and human-reviewed, adapted and playtested by the author.
Prepared for Squash and Merge.