retire DynamicUILayer, restore warship UX on WebGL

DynamicUILayer was a canvas2D mix of: bonus-event gold/troops popups
(already duplicated by WebGL BonusPopupPass), nuke/transport telegraph
indicators (duplicated by WebGL passes), and a warship move-indicator
chevron drawn via MoveIndicatorUI. Delete the layer outright along
with its three orphan UI helpers (MoveIndicatorUI, NavalTarget,
NukeTelegraph).

That deletion uncovered a pre-existing bug from the "migrate away from
canvas" commit: warship select/move no longer worked. The deleted
UnitLayer had owned the click flow that emits MoveWarshipIntentEvent.
Re-add the flow inside UILayer (which already tracks selected /
multi-selected warships for its selection box): MouseUpEvent →
move-multi → move-single → select-nearest, plus shift+drag box
complete and select-all hotkey.

Wire MoveWarshipIntentEvent → view.showMoveIndicator(tx, ty, ownerID)
in mountWebGLDebugRenderer so the WebGL MoveIndicatorPass draws the
converging-chevron animation at the move target, colored by the
warship's owner. mountWebGLDebugRenderer now takes gameView + eventBus
to resolve the owner and subscribe.
This commit is contained in:
evanpelle
2026-05-16 18:51:34 -07:00
parent 8955be7667
commit 2fec1e994e
7 changed files with 190 additions and 493 deletions
+19
View File
@@ -47,6 +47,7 @@ import {
import { endGame, startGame, startTime } from "./LocalPersistantStats";
import { terrainMapFileLoader } from "./TerrainMapFileLoader";
import {
MoveWarshipIntentEvent,
SendAllianceExtensionIntentEvent,
SendAllianceRequestIntentEvent,
SendAttackIntentEvent,
@@ -231,6 +232,8 @@ export function joinLobby(
function mountWebGLDebugRenderer(
terrainMap: TerrainMapData,
transformHandler: import("./graphics/TransformHandler").TransformHandler,
gameView: GameView,
eventBus: EventBus,
): { builder: WebGLFrameBuilder; syncCamera: () => void } {
const gameMap = terrainMap.gameMap;
const mapWidth = gameMap.width();
@@ -332,6 +335,20 @@ function mountWebGLDebugRenderer(
(window as unknown as { __webglView?: unknown }).__webglView = view;
// Move-target chevrons: when the player issues a warship move, show the
// animated chevron pass at the target tile. The renderer needs the target's
// tile x/y and the warship's owner smallID (so the chevrons use the right
// color).
eventBus.on(MoveWarshipIntentEvent, (e) => {
const tile = e.tile;
const tx = gameView.x(tile);
const ty = gameView.y(tile);
// Resolve owner via the first unit in the move set.
const firstUnit = gameView.unit(e.unitIds[0]);
if (firstUnit === undefined) return;
view.showMoveIndicator(tx, ty, firstUnit.owner().smallID());
});
return { builder: new WebGLFrameBuilder(view), syncCamera };
}
@@ -389,6 +406,8 @@ async function createClientGame(
const { builder: webglBuilder, syncCamera } = mountWebGLDebugRenderer(
gameMap,
gameRenderer.transformHandler,
gameView,
eventBus,
);
gameRenderer.onPreRender = syncCamera;