rename UILayer/StructureIconsLayer to controllers, move to src/client/controllers/

UILayer → WarshipSelectionController and StructureIconsLayer →
BuildPreviewController. These are the two real Controller implementations
(state + click handling, no rendering) — the new names + location reflect
what they actually do now that all rendering lives in WebGL passes.
This commit is contained in:
evanpelle
2026-05-16 22:45:02 -07:00
parent bac29448c2
commit a708a8c984
5 changed files with 43 additions and 49 deletions
@@ -1,14 +1,8 @@
import { describe, expect, test } from "vitest";
import { shouldPreserveGhostAfterBuild } from "../../../../src/client/graphics/layers/StructureIconsLayer";
import { UnitType } from "../../../../src/core/game/Game";
import { shouldPreserveGhostAfterBuild } from "../../../src/client/controllers/BuildPreviewController";
import { UnitType } from "../../../src/core/game/Game";
/**
* Tests for StructureIconsLayer edge cases mentioned in comments:
* - Locked nuke / AtomBomb / HydrogenBomb: when confirming placement (Enter or key),
* the ghost is preserved so the user can place multiple nukes or keep the nuke
* selected. Other structure types clear the ghost after placement.
*/
describe("StructureIconsLayer ghost preservation (locked nuke / Enter confirm)", () => {
describe("BuildPreviewController ghost preservation (locked nuke / Enter confirm)", () => {
describe("shouldPreserveGhostAfterBuild", () => {
test("returns true for AtomBomb so ghost is not cleared after placement", () => {
expect(shouldPreserveGhostAfterBuild(UnitType.AtomBomb)).toBe(true);
@@ -1,7 +1,7 @@
import { UILayer } from "../../../src/client/graphics/layers/UILayer";
import { WarshipSelectionController } from "../../../src/client/controllers/WarshipSelectionController";
import { UnitSelectionEvent } from "../../../src/client/InputHandler";
describe("UILayer", () => {
describe("WarshipSelectionController", () => {
let game: any;
let eventBus: any;
let transformHandler: any;
@@ -29,7 +29,7 @@ describe("UILayer", () => {
});
it("tracks the selected unit on single-unit selection (rendering is WebGL)", () => {
const ui = new UILayer(game, eventBus, transformHandler);
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
const unit = {
type: () => "Warship",
isActive: () => true,
@@ -45,7 +45,7 @@ describe("UILayer", () => {
});
it("clears selection on deselect", () => {
const ui = new UILayer(game, eventBus, transformHandler);
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
const unit = {
type: () => "Warship",
isActive: () => true,
@@ -61,7 +61,7 @@ describe("UILayer", () => {
});
it("tracks multi-selection list", () => {
const ui = new UILayer(game, eventBus, transformHandler);
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
const units = [
{ id: () => 1, isActive: () => true },
{ id: () => 2, isActive: () => true },