mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:20:47 +00:00
controllers push to the WebGL view directly, drop ClientGameRunner relays
BuildPreviewController and WarshipSelectionController now take the WebGL view in their constructor and call view.updateGhostPreview / view.setSelectedUnits themselves instead of emitting bus events that ClientGameRunner forwarded. Splits the old mountWebGLDebugRenderer in two — createWebGLView builds the view up front so the renderer can wire controllers to it, mountWebGLDebugRenderer does the per-frame plumbing after the transformHandler exists. GhostPreviewUpdatedEvent had no remaining consumers and is removed.
This commit is contained in:
@@ -5,6 +5,7 @@ describe("WarshipSelectionController", () => {
|
||||
let game: any;
|
||||
let eventBus: any;
|
||||
let transformHandler: any;
|
||||
let view: any;
|
||||
|
||||
beforeEach(() => {
|
||||
game = {
|
||||
@@ -26,11 +27,18 @@ describe("WarshipSelectionController", () => {
|
||||
};
|
||||
eventBus = { on: vi.fn() };
|
||||
transformHandler = {};
|
||||
view = { setSelectedUnits: vi.fn() };
|
||||
});
|
||||
|
||||
it("tracks the selected unit on single-unit selection (rendering is WebGL)", () => {
|
||||
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
|
||||
const ui = new WarshipSelectionController(
|
||||
game,
|
||||
eventBus,
|
||||
transformHandler,
|
||||
view,
|
||||
);
|
||||
const unit = {
|
||||
id: () => 1,
|
||||
type: () => "Warship",
|
||||
isActive: () => true,
|
||||
tile: () => ({}),
|
||||
@@ -45,8 +53,14 @@ describe("WarshipSelectionController", () => {
|
||||
});
|
||||
|
||||
it("clears selection on deselect", () => {
|
||||
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
|
||||
const ui = new WarshipSelectionController(
|
||||
game,
|
||||
eventBus,
|
||||
transformHandler,
|
||||
view,
|
||||
);
|
||||
const unit = {
|
||||
id: () => 1,
|
||||
type: () => "Warship",
|
||||
isActive: () => true,
|
||||
tile: () => ({}),
|
||||
@@ -61,7 +75,12 @@ describe("WarshipSelectionController", () => {
|
||||
});
|
||||
|
||||
it("tracks multi-selection list", () => {
|
||||
const ui = new WarshipSelectionController(game, eventBus, transformHandler);
|
||||
const ui = new WarshipSelectionController(
|
||||
game,
|
||||
eventBus,
|
||||
transformHandler,
|
||||
view,
|
||||
);
|
||||
const units = [
|
||||
{ id: () => 1, isActive: () => true },
|
||||
{ id: () => 2, isActive: () => true },
|
||||
|
||||
Reference in New Issue
Block a user