diff --git a/src/client/graphics/layers/OptionsMenu.ts b/src/client/graphics/layers/OptionsMenu.ts index d399321ba..b52876518 100644 --- a/src/client/graphics/layers/OptionsMenu.ts +++ b/src/client/graphics/layers/OptionsMenu.ts @@ -106,6 +106,11 @@ export class OptionsMenu extends LitElement implements Layer { this.eventBus.emit(new RefreshGraphicsEvent()); } + private onToggleFocusLockedButtonClick() { + this.userSettings.toggleFocusLocked(); + this.requestUpdate(); + } + private onToggleLeftClickOpensMenu() { this.userSettings.toggleLeftClickOpenMenu(); } @@ -200,6 +205,15 @@ export class OptionsMenu extends LitElement implements Layer { ? "Opens menu" : "Attack"), })} + ${button({ + onClick: this.onToggleFocusLockedButtonClick, + title: "Lock Focus", + children: + "🗺: " + + (this.userSettings.focusLocked() + ? "Focus locked" + : "Hover focus"), + })} `; diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index 75efe5328..430a24cb4 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -32,6 +32,9 @@ import { } from "./GameUpdates"; import { TerraNulliusImpl } from "./TerraNulliusImpl"; import { UnitGrid } from "./UnitGrid"; +import { UserSettings } from "./UserSettings"; + +const userSettings: UserSettings = new UserSettings(); export class UnitView { public _wasUpdated = true; @@ -546,6 +549,7 @@ export class GameView implements GameMap { } focusedPlayer(): PlayerView | null { + if (userSettings.focusLocked()) return this.myPlayer(); return this._focusedPlayer; } setFocusedPlayer(player: PlayerView | null): void { diff --git a/src/core/game/UserSettings.ts b/src/core/game/UserSettings.ts index 180208693..536b908da 100644 --- a/src/core/game/UserSettings.ts +++ b/src/core/game/UserSettings.ts @@ -24,10 +24,18 @@ export class UserSettings { return this.get("settings.leftClickOpensMenu", false); } + focusLocked() { + return this.get("settings.focusLocked", false); + } + toggleLeftClickOpenMenu() { this.set("settings.leftClickOpensMenu", !this.leftClickOpensMenu()); } + toggleFocusLocked() { + this.set("settings.focusLocked", !this.focusLocked()); + } + toggleEmojis() { this.set("settings.emojis", !this.emojis()); }