mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 11:23:16 +00:00
Wire view-mode toggles (alt-view + coordinate grid) via new ViewModeController
Moves the AlternateViewEvent / ToggleCoordinateGridEvent subscriptions out of ClientGameRunner into a dedicated controller in src/client/controllers/. Also wires ToggleCoordinateGridEvent (M keybind) — previously emitted with no listener — so the persistent coordinate-grid toggle works. Grid + alt-view hide names only under alt-view; M keeps names visible.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* ViewModeController — forwards map view-mode toggles to the WebGL view.
|
||||
*
|
||||
* - AlternateViewEvent: space-hold (and the settings-modal toggle) drives the
|
||||
* affiliation recolor + grid overlay + hides names.
|
||||
* - ToggleCoordinateGridEvent: persistent coordinate-grid toggle (M keybind);
|
||||
* grid shows but names stay visible.
|
||||
*/
|
||||
|
||||
import { EventBus } from "../../core/EventBus";
|
||||
import { Controller } from "../Controller";
|
||||
import { AlternateViewEvent, ToggleCoordinateGridEvent } from "../InputHandler";
|
||||
import { GameView as WebGLGameView } from "../render/gl";
|
||||
|
||||
export class ViewModeController implements Controller {
|
||||
constructor(
|
||||
private eventBus: EventBus,
|
||||
private view: WebGLGameView,
|
||||
) {}
|
||||
|
||||
init() {
|
||||
this.eventBus.on(AlternateViewEvent, (e) =>
|
||||
this.view.setAltView(e.alternateView),
|
||||
);
|
||||
this.eventBus.on(ToggleCoordinateGridEvent, (e) =>
|
||||
this.view.setGridView(e.enabled),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user