mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 04:44:18 +01:00
The Windows starter gets a Language box (English/Deutsch) that relabels the window at once and saves the choice in settings.json for the game. Crew, lookout and admin pages open in the host's saved language (named by the server in a meta tag) and the crew page has a visible English/Deutsch button. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ybp8UvaVnj6zwuseaMHD73
132 lines
3.8 KiB
JavaScript
132 lines
3.8 KiB
JavaScript
import { defaultSonarPage } from "./shared.js";
|
|
|
|
// Mutable client state shared by several modules. Transient: never sent to
|
|
// the host, stored or placed in the DOM.
|
|
// Pages open in the host's saved language (the server names it in a meta
|
|
// tag); without one, in the browser's.
|
|
export function initialLanguage() {
|
|
const host = document.querySelector('meta[name="u-jagd-host-language"]')?.getAttribute("content");
|
|
if (host === "en" || host === "de") return host;
|
|
return (navigator.language || "en").toLowerCase().startsWith("de") ? "de" : "en";
|
|
}
|
|
|
|
export const S = {
|
|
language: initialLanguage(),
|
|
catalog: {},
|
|
// Session metadata stays closure-local: no URL, DOM or persistence.
|
|
session: null,
|
|
pairingAvailable: false,
|
|
generation: 0,
|
|
snapshot: null,
|
|
chart: null,
|
|
chartSession: null,
|
|
chartEpoch: null,
|
|
chartRole: null,
|
|
selected: null,
|
|
connected: false,
|
|
linkState: "unpaired",
|
|
lastSuccess: 0,
|
|
lastSessionFetch: 0,
|
|
failures: 0,
|
|
pollTimer: null,
|
|
polling: false,
|
|
pending: null,
|
|
v2State: null,
|
|
roleStale: false,
|
|
// Solo host surface: the published host view and the one host command in flight.
|
|
hostView: null,
|
|
hostPending: null,
|
|
hostMessage: null,
|
|
hostMessageTimer: null,
|
|
stationRenderSignature: null,
|
|
nextCommandSeq: 0,
|
|
stationMutation: false,
|
|
activatingStation: null,
|
|
queuedSonarFocus: null,
|
|
// Focus this client last sent, until the state shows it or it is rejected.
|
|
requestedSonarFocus: null,
|
|
stationPickerOpen: false,
|
|
lobbyMessage: null,
|
|
// Unit chosen in the lobby ("frigate" | "opfor"); held stations decide otherwise.
|
|
lobbySide: "frigate",
|
|
commandMessage: null,
|
|
lastToastedMessage: null,
|
|
opzMarked: new Set(),
|
|
opzSuppressed: new Set(),
|
|
opzManage: false,
|
|
stationDrafts: new Set(),
|
|
// Emitter the mast station has selected in the boat's ESM list (by number).
|
|
ubootEsmSelected: null,
|
|
// Bridge route mode: a chart click adds an autopilot waypoint.
|
|
bridgeRouteMode: false,
|
|
requestQueue: Promise.resolve(),
|
|
activeRequest: null,
|
|
languageRequest: 0,
|
|
audio: null,
|
|
soundEnabled: false,
|
|
speechEnabled: false,
|
|
speechQueued: 0,
|
|
calloutContext: null,
|
|
calloutHighWater: 0,
|
|
sonarAudioEnabled: false,
|
|
sonarAudioController: null,
|
|
sonarAudioTimer: null,
|
|
sonarAudioSequence: null,
|
|
sonarAudioNextTime: 0,
|
|
helicopterAudioSource: null,
|
|
sonarAudioSources: [],
|
|
sonarAudioGain: null,
|
|
sonarAudioHighpass: null,
|
|
sonarAudioLowpass: null,
|
|
sonarAudioWorklet: null,
|
|
sonarAudioSocket: null,
|
|
sonarAudioReconnect: null,
|
|
sonarAudioMetrics: {buffered: 0, gaps: 0, concealed: 0, rate: 1, stale: false},
|
|
gameSoundContext: null,
|
|
gameSoundHighWater: 0,
|
|
chartHits: [],
|
|
drag: null,
|
|
activeTab: "operations",
|
|
contactAnalysis: null,
|
|
analysisSelected: null,
|
|
analysisImageKey: null,
|
|
lastSimlogFetch: 0,
|
|
proposals: null,
|
|
eventContext: null,
|
|
eventBaselinePending: false,
|
|
eventHighWater: 0,
|
|
eventHistory: [],
|
|
analysisError: false,
|
|
latestSimlogState: null,
|
|
simlogMapData: null,
|
|
simlogMapSeq: null,
|
|
simlogMapLatest: false,
|
|
simlogMapFit: "world",
|
|
roleMapHits: [],
|
|
// Hover information for the maps (tracks, own ship, assets, chart items);
|
|
// separate from the click hit lists so selection semantics are unchanged.
|
|
roleMapInfo: [],
|
|
chartInfo: [],
|
|
damageHits: [],
|
|
sonarVisualPage: defaultSonarPage(),
|
|
helicopterVisualPage: "acoustic",
|
|
helicopterPlot: "lofar",
|
|
weatherFrame: null,
|
|
weatherTimer: null,
|
|
weatherLastDraw: 0,
|
|
roleMapDrag: null,
|
|
plotAnchor: null,
|
|
plotListKey: "",
|
|
sonarBroadbandDrag: null,
|
|
opzSweepFrame: null,
|
|
opzSweepSample: null,
|
|
fireConfirmation: null,
|
|
fireConfirmationTimer: null,
|
|
sonarAudioGeneration: 0,
|
|
// World session/epoch the live audio last saw; a change resumes the stream.
|
|
sonarAudioWorld: null,
|
|
// Pointer position over the weather profile (CSS px), or null.
|
|
weatherCursor: null,
|
|
webHostAvailable: false,
|
|
};
|