mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 11:23:16 +00:00
Highlight matching structures on UnitDisplay hover
Wires the existing ToggleStructureEvent (emitted on UnitDisplay button mouseenter/leave) to view.setHighlightStructureTypes via a small StructureHighlightController. StructurePass + StructureLevelPass already implement the highlight visual — this just connects the two ends.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* StructureHighlightController — forwards UnitDisplay hover events to the
|
||||
* renderer so matching structures glow while others dim.
|
||||
*
|
||||
* UnitDisplay emits ToggleStructureEvent on @mouseenter / @mouseleave for each
|
||||
* unit-type button, with a payload of "production source" types
|
||||
* (Warship → [Port], AtomBomb → [MissileSilo, SAMLauncher], building → itself).
|
||||
* This controller just plumbs that payload to view.setHighlightStructureTypes;
|
||||
* StructurePass + StructureLevelPass already implement the visual highlight.
|
||||
*/
|
||||
|
||||
import { EventBus } from "../../core/EventBus";
|
||||
import { Controller } from "../Controller";
|
||||
import { ToggleStructureEvent } from "../InputHandler";
|
||||
import { GameView as WebGLGameView } from "../render/gl";
|
||||
|
||||
export class StructureHighlightController implements Controller {
|
||||
constructor(
|
||||
private eventBus: EventBus,
|
||||
private view: WebGLGameView,
|
||||
) {}
|
||||
|
||||
init() {
|
||||
this.eventBus.on(ToggleStructureEvent, (e) =>
|
||||
this.view.setHighlightStructureTypes(e.structureTypes),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user