mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 04:23:28 +00:00
Disable build hotkeys after death (#3833)
## Description: Prevent number-key build shortcuts from opening the unit build ghost after the player has died. Keep build hotkeys available only while the player is alive and not in spawn phase. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: aotumuri
This commit is contained in:
@@ -519,10 +519,12 @@ export class InputHandler {
|
||||
}
|
||||
|
||||
// Two-phase build keybind matching: exact code match first, then digit/Numpad alias.
|
||||
const matchedBuild = this.resolveBuildKeybind(e.code, e.shiftKey);
|
||||
if (matchedBuild !== null) {
|
||||
e.preventDefault();
|
||||
this.setGhostStructure(matchedBuild);
|
||||
if (this.canUseBuildKeybinds()) {
|
||||
const matchedBuild = this.resolveBuildKeybind(e.code, e.shiftKey);
|
||||
if (matchedBuild !== null) {
|
||||
e.preventDefault();
|
||||
this.setGhostStructure(matchedBuild);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.keybindMatchesEvent(e, this.keybinds.requestAlliance)) {
|
||||
@@ -943,6 +945,11 @@ export class InputHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
private canUseBuildKeybinds(): boolean {
|
||||
const myPlayer = this.gameView.myPlayer?.();
|
||||
return !this.gameView.inSpawnPhase() && myPlayer?.isAlive() === true;
|
||||
}
|
||||
|
||||
private getPinchDistance(): number {
|
||||
const pointerEvents = Array.from(this.pointers.values());
|
||||
const dx = pointerEvents[0].clientX - pointerEvents[1].clientX;
|
||||
|
||||
Reference in New Issue
Block a user