mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:10:46 +00:00
allow closing the radial or build menu with the esc key
This commit is contained in:
@@ -48,6 +48,8 @@ export class AlternateViewEvent implements GameEvent {
|
||||
constructor(public readonly alternateView: boolean) {}
|
||||
}
|
||||
|
||||
export class CloseViewEvent implements GameEvent {}
|
||||
|
||||
export class RefreshGraphicsEvent implements GameEvent {}
|
||||
|
||||
export class ShowBuildMenuEvent implements GameEvent {
|
||||
@@ -149,6 +151,11 @@ export class InputHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (e.code === "Escape") {
|
||||
e.preventDefault();
|
||||
this.eventBus.emit(new CloseViewEvent());
|
||||
}
|
||||
|
||||
// Add all movement keys to activeKeys
|
||||
if (
|
||||
[
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "../../../core/game/Game";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import {
|
||||
CloseViewEvent,
|
||||
ContextMenuEvent,
|
||||
MouseUpEvent,
|
||||
ShowBuildMenuEvent,
|
||||
@@ -123,9 +124,22 @@ export class RadialMenu implements Layer {
|
||||
}
|
||||
this.buildMenu.showMenu(tile);
|
||||
});
|
||||
|
||||
this.eventBus.on(CloseViewEvent, () => this.closeMenu());
|
||||
|
||||
this.createMenuElement();
|
||||
}
|
||||
|
||||
private closeMenu() {
|
||||
if (this.isVisible) {
|
||||
this.hideRadialMenu();
|
||||
}
|
||||
|
||||
if (this.buildMenu.isVisible) {
|
||||
this.buildMenu.hideMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private createMenuElement() {
|
||||
this.menuElement = d3
|
||||
.select(document.body)
|
||||
|
||||
Reference in New Issue
Block a user