Enhance InputHandler to allow using NumPad#3317
Enhance InputHandler to allow using NumPad#3317wozniakpl wants to merge 2 commits intoopenfrontio:mainfrom
Conversation
…press when a ghost structure is set. Refactor event handling for build keybinds to use a helper function for improved readability. Update tests to cover new functionality and ensure proper event emissions.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
WalkthroughThis change introduces keyboard-based confirmation for ghost structures and enables numeric keybinds for build actions. A new ConfirmGhostStructureEvent fires when Enter or NumpadEnter is pressed with an active ghost structure, while a helper method allows digit keys to map to build actions through numeric extraction. Changes
Sequence DiagramsequenceDiagram
participant User as User/Keyboard
participant IH as InputHandler
participant SIL as StructureIconsLayer
participant Game as Game Logic
User->>IH: Press Enter/NumpadEnter<br/>(ghost structure active)
activate IH
IH->>IH: Detect Enter key +<br/>ghostStructure set
IH->>SIL: Emit ConfirmGhostStructureEvent
deactivate IH
activate SIL
SIL->>SIL: Listen to event
SIL->>SIL: confirmGhostStructure()
SIL->>Game: createStructure(MouseUpEvent<br/>at current position)
deactivate SIL
activate Game
Game->>Game: Place structure<br/>at ghost position
Game->>User: Structure confirmed
deactivate Game
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@wozniakpl If you want (in this PR or a follow-up) could you also add the existing Esc and the new Enter key actions to the Help modal? Some hotkeys are displayed there with an icon, an Esc and Enter icon of the same style could be added. The help text could say something like "Closes menu. Cancels unit build preview." (for Esc) and "Confirms input. Confirms unit build preview." (for Enter). Also if you want i can assign the issue #3064 to you, if you comment on it. |
Sure, I'd be happy to. This can be done in scope of another PR. I'll comment in that issue. |
Description:
Adds Enter and Numpad Enter as confirmation for placing a ghost structure after selecting a building with hotkeys (1–0 or numpad). Players can cancel with Esc but previously had to click to confirm; they can now confirm with Enter or Numpad Enter at the current cursor position. This supports keyboard-only or mouse + numpad workflows (e.g. one hand on numpad for select + confirm, one on mouse for aiming).
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
.wozniakpl