mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-05 20:34:16 +01:00
- Remote Crew browser client rebuilt as a dark combat-information-centre layout for large desktop monitors: slim status bar (stations, mission, clocks, UTC, link state), pulsing alert band, the instrument as centrepiece and collapsible docks (contacts, station, contact detail, log drawer; keys , . L). Four columns from 2400 px, fluid type up to 4K; guide, lookout and contact library open as overlays (Esc closes). - app.js split into native ES modules under data/commander/js; the transport (net/*) no longer touches the DOM and talks to the views through synchronous topics (core/events.js, app/bindings.js); redraws share one frame scheduler. - style.css replaced by a token-based design system in data/commander/css. - Inter 4.1 and JetBrains Mono 2.304 bundled unmodified (OFL-1.1) with provenance in THIRD_PARTY_NOTICES.md; CSP allows font-src 'self'. - Server serves the css/js/fonts trees from one asset manifest (src/commander/assets.py); packaging, capture tool, help, manual and docs updated; tests share tests/commander_web.py and import modules directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import { S } from "../state/store.js";
|
|
import { $, isSonar } from "../core/base.js";
|
|
|
|
// Plots redrawn on every animation frame between publications, by canvas id.
|
|
// A frame only blits cached rasters and strokes a few hundred points.
|
|
export const animatedPlots = new Map();
|
|
let plotFrame = null;
|
|
let plotLastDraw = 0;
|
|
export function registerAnimatedPlot(id, draw) {
|
|
animatedPlots.set(id, {role: S.v2State?.role, draw});
|
|
}
|
|
function plotAnimation(now) {
|
|
plotFrame = null;
|
|
if (now - plotLastDraw >= 30) {
|
|
plotLastDraw = now;
|
|
for (const [id, plot] of animatedPlots) {
|
|
const element = $(id);
|
|
if (plot.role !== S.v2State?.role || !element || element.closest("[hidden]")) continue;
|
|
plot.draw(now);
|
|
}
|
|
}
|
|
syncPlotAnimation();
|
|
}
|
|
export function syncPlotAnimation() {
|
|
const role = S.v2State?.role;
|
|
const active = !document.hidden && S.connected && S.v2State?.phase === "live" && (isSonar(role) || role === "helicopter") &&
|
|
!$("role-visuals").hidden && [...animatedPlots.values()].some((plot) => plot.role === role);
|
|
if (active && plotFrame === null) plotFrame = requestAnimationFrame(plotAnimation);
|
|
if (!active && plotFrame !== null) { cancelAnimationFrame(plotFrame); plotFrame = null; }
|
|
}
|