diff --git a/src/client/controllers/StructureHighlightController.ts b/src/client/controllers/StructureHighlightController.ts new file mode 100644 index 000000000..e3d8c6333 --- /dev/null +++ b/src/client/controllers/StructureHighlightController.ts @@ -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), + ); + } +} diff --git a/src/client/hud/GameRenderer.ts b/src/client/hud/GameRenderer.ts index 4ef7fbfc4..391d718ed 100644 --- a/src/client/hud/GameRenderer.ts +++ b/src/client/hud/GameRenderer.ts @@ -7,6 +7,7 @@ import { TransformHandler } from "../TransformHandler"; import { UIState } from "../UIState"; import { BuildPreviewController } from "../controllers/BuildPreviewController"; import { HoverHighlightController } from "../controllers/HoverHighlightController"; +import { StructureHighlightController } from "../controllers/StructureHighlightController"; import { WarshipSelectionController } from "../controllers/WarshipSelectionController"; import { GameView as WebGLGameView } from "../render/gl"; import { FrameProfiler } from "./FrameProfiler"; @@ -272,6 +273,7 @@ export function createRenderer( new WarshipSelectionController(game, eventBus, transformHandler, view), new BuildPreviewController(game, eventBus, uiState, transformHandler, view), new HoverHighlightController(game, eventBus, transformHandler, view), + new StructureHighlightController(eventBus, view), new AttackingTroopsOverlay(game, transformHandler, eventBus, userSettings), eventsDisplay, actionableEvents,