feat: left click now opens menu (to avoid misclicks), shift+left click is attack

It happens very frequently that I misclick (meant to click on neighbor,
mean to click modal, sensitive touchpad and many others) and ruin my
game (and another player's). So by default left click opens the menu. As
the attack button is in the middle you can just double click to attack.
You can also shift+click to attack.
I have updated the Help modal to document all that + the existing (just
discovered in the code) ctrl+click to open build menu.
This commit is contained in:
ilan schemoul
2025-02-27 22:45:33 +01:00
parent bcf8ccac92
commit d6b29a655c
4 changed files with 42 additions and 8 deletions
+8 -3
View File
@@ -1,4 +1,5 @@
import { EventBus, GameEvent } from "../core/EventBus";
import { UserSettings } from "../core/game/UserSettings";
export class MouseUpEvent implements GameEvent {
constructor(
@@ -83,6 +84,8 @@ export class InputHandler {
private readonly PAN_SPEED = 5;
private readonly ZOOM_SPEED = 10;
private userSettings: UserSettings = new UserSettings();
constructor(
private canvas: HTMLCanvasElement,
private eventBus: EventBus,
@@ -265,10 +268,12 @@ export class InputHandler {
if (dist < 10) {
if (event.pointerType == "touch") {
event.preventDefault();
console.log("firing context menu event");
this.eventBus.emit(new ContextMenuEvent(event.clientX, event.clientY));
} else {
}
if (!this.userSettings.leftClickOpensMenu() || event.shiftKey) {
this.eventBus.emit(new MouseUpEvent(event.x, event.y));
} else {
this.eventBus.emit(new ContextMenuEvent(event.clientX, event.clientY));
}
}
}