mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 21:04:18 +01:00
The Remote Crew "Einsatzprotokoll" only ever carried a few browser alerts (damage, threat, mission end, proposals) and so looked empty. Every station now gets its side's F11 log: the frigate's event feed for the frigate's stations, the crewed boat's log for the submarine's, numbered once by the bridge, with time stamp and category tag, up to 200 entries like F11. Unchanged logs are not re-encoded; the browser keeps rows already shown. The open log drawer has a fixed height, so a long log scrolls inside it instead of pushing the chart away. On the uConsole, F11 now opens the boat log on the submarine side too (with wheel scrolling). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018n9X2Pm9CMpZA5WVJik2Es
47 lines
2.3 KiB
JavaScript
47 lines
2.3 KiB
JavaScript
import { S } from "../state/store.js";
|
|
import { $ } from "../core/base.js";
|
|
import { t, unit } from "../core/format.js";
|
|
import { node } from "./dom.js";
|
|
|
|
export function renderProposals() {
|
|
const sonar = S.session?.station === "sonar";
|
|
const bridge = S.session?.station === "bridge";
|
|
$("target-proposal-controls").hidden = !sonar;
|
|
$("target-proposal").hidden = !sonar;
|
|
$("navigation-proposal").hidden = !bridge;
|
|
const target = sonar ? S.proposals?.target : null;
|
|
$("proposal-status").textContent = target ? t(`proposal_${target.status}`, {label: target.label}) : "";
|
|
const navigation = bridge ? S.proposals?.navigation : null;
|
|
if (navigation) {
|
|
const summary = t("navigation_summary", {
|
|
course: navigation.course === null ? t("navigation_unchanged") : unit(navigation.course, "\u00b0", 0),
|
|
speed: navigation.speed_kn === null ? t("navigation_unchanged") : unit(navigation.speed_kn, "kn"),
|
|
});
|
|
$("navigation-status").textContent = t(`proposal_${navigation.status}`, {label: summary});
|
|
} else $("navigation-status").textContent = t("navigation_none");
|
|
}
|
|
// "[08:12] FUNK", as the uConsole's F11 log tags its lines.
|
|
export const eventMeta = (event) => `[${event.stamp || "--:--"}] ${event.tag || event.kind}`;
|
|
// The mission log, newest first. Rows already shown are kept (and moved),
|
|
// so a state push neither rebuilds the list nor loses the reader's place.
|
|
export function renderEvents() {
|
|
const list = $("event-list");
|
|
const rows = [...S.eventHistory].reverse();
|
|
const signature = rows.length ? `${rows.length}/${rows[0].seq}/${rows.at(-1).seq}` : "";
|
|
if (list.dataset.signature === signature && list.childElementCount) return;
|
|
list.dataset.signature = signature;
|
|
if (!rows.length) {
|
|
list.replaceChildren(node("li", t("no_events")));
|
|
return;
|
|
}
|
|
const shown = new Map([...list.children].map((item) => [item.dataset.rowKey, item]));
|
|
list.replaceChildren(...rows.map((event) => shown.get(String(event.seq)) ?? eventItem(event)));
|
|
}
|
|
function eventItem(event) {
|
|
const item = node("li", undefined, event.severity === "warning" ? "warning" : "");
|
|
item.dataset.rowKey = String(event.seq);
|
|
item.dataset.category = event.kind;
|
|
item.append(node("span", eventMeta(event), "event-meta"), node("span", event.message, "event-text"));
|
|
return item;
|
|
}
|