ctrl + click brings up build menu

This commit is contained in:
evanpelle
2024-12-25 18:45:26 -08:00
parent a6f75b5f82
commit 2771d3d432
2 changed files with 27 additions and 2 deletions
+12 -1
View File
@@ -1,4 +1,5 @@
import { EventBus, GameEvent } from "../core/EventBus";
import { Game } from "../core/game/Game";
export class MouseUpEvent implements GameEvent {
@@ -48,10 +49,14 @@ export class AlternateViewEvent implements GameEvent {
constructor(public readonly alternateView: boolean) { }
}
export class RefreshGraphicsEvent implements GameEvent {
export class RefreshGraphicsEvent implements GameEvent { }
export class ShowBuildMenuEvent implements GameEvent {
constructor(public readonly x: number, public readonly y: number) { }
}
export class InputHandler {
private lastPointerX: number = 0;
@@ -113,6 +118,7 @@ export class InputHandler {
return
}
this.pointerDown = true
this.pointers.set(event.pointerId, event);
@@ -136,6 +142,11 @@ export class InputHandler {
this.pointerDown = false
this.pointers.clear()
if (event.ctrlKey) {
this.eventBus.emit(new ShowBuildMenuEvent(event.clientX, event.clientY))
return
}
const dist = Math.abs(event.x - this.lastPointerDownX) + Math.abs(event.y - this.lastPointerDownY);
if (dist < 10) {
if (event.pointerType == "touch") {