mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-25 15:14:37 +00:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user