Files
uconsole_asw_game/data/commander/js/plot/symbols.js
T
Claude 332f897756 Operating rules: Ctrl+Enter only fires, close boxes, lamp notes, APP-6 own symbols, German key names
B1: D/A/Z/R/Shift+R at Weapons and D on OPZ page 3 choose the weapon,
Ctrl+Enter fires it; the helicopter drops its torpedo on Ctrl+Enter only.
B3: close boxes on F7, language model settings, F8, F9, F11 and the
debrief; one x style for the browser's dialog close buttons.
B4: hover notes for the helicopter's rescue and acoustic lamps, sonar
contact freshness, engine master lamp and damage-control lamps; browser
lamp strips with notes on bridge, CIC, radio room and damage control.
B5: APP-6 frames by dimension (friend circle/dome/bowl, hostile and
neutral halves) and the own frigate as its friendly surface symbol.
B6 (part): German key names Umschalt, Strg, Eingabe, Ruecktaste.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 15:16:01 +00:00

67 lines
4.2 KiB
JavaScript

import { ctx } from "../views/canvases.js";
// APP-6 frame dimension of each glyph domain (as src/ui/nato_symbols.py).
const FRAME_DIMENSION = {AIR: "air", ROTARY: "air", MISSILE: "air", SUBSURFACE: "subsurface", UNDERWATER_WEAPON: "subsurface"};
// The APP-6 frame: friend circle, hostile diamond, neutral square, cut to the
// upper half (air, open below) or the lower half (subsurface, open above);
// unknown affiliation: no frame, only the domain glyph (colour marks it).
function drawFrame(context, x, y, affiliation, dimension, half, height) {
const air = dimension === "air", sub = dimension === "subsurface";
if (affiliation === "FRIEND") {
const radius = half + 2;
if (air) context.arc(x, y, radius, Math.PI, Math.PI * 2);
else if (sub) context.arc(x, y, radius, 0, Math.PI);
else context.arc(x, y, radius, 0, Math.PI * 2);
} else if (affiliation === "HOSTILE") {
if (air) { context.moveTo(x - half, y + 2); context.lineTo(x, y - height); context.lineTo(x + half, y + 2); }
else if (sub) { context.moveTo(x - half, y - 2); context.lineTo(x, y + height); context.lineTo(x + half, y - 2); }
else { context.moveTo(x, y - height); context.lineTo(x + half, y); context.lineTo(x, y + height); context.lineTo(x - half, y); context.closePath(); }
} else if (affiliation === "NEUTRAL") {
if (air) { context.moveTo(x - half, y + 3); context.lineTo(x - half, y - height); context.lineTo(x + half, y - height); context.lineTo(x + half, y + 3); }
else if (sub) { context.moveTo(x - half, y - 3); context.lineTo(x - half, y + height); context.lineTo(x + half, y + height); context.lineTo(x + half, y - 3); }
else context.rect(x - half, y - height, half * 2, height * 2);
}
}
// NATO-style symbol, same geometry as the uConsole (src/ui/nato_symbols.py):
// the frame shows the operator's affiliation in the unit's dimension, the
// glyph the domain.
export function drawNatoSymbol(context, x, y, affiliation, domain, color, size) {
const half = Math.max(5, size), height = Math.max(6, size * 1.3), glyph = Math.max(3, size * .5);
context.strokeStyle = color; context.lineWidth = 2; context.beginPath();
drawFrame(context, x, y, affiliation, FRAME_DIMENSION[domain] || "surface", half, height);
context.stroke();
context.lineWidth = 1.6; context.beginPath();
if (domain === "AIR") {
context.moveTo(x - glyph, y + glyph * .7); context.lineTo(x, y - glyph * .7); context.lineTo(x + glyph, y + glyph * .7);
} else if (domain === "ROTARY") {
// Rotary wing (APP-6 / MIL-STD-2525 helicopter icon): a bow tie of two
// rotor blades meeting at the hub, as on the uConsole.
const g = Math.max(4, half - 2);
context.moveTo(x - g, y - g / 2); context.lineTo(x, y); context.lineTo(x - g, y + g / 2); context.closePath();
context.moveTo(x + g, y - g / 2); context.lineTo(x, y); context.lineTo(x + g, y + g / 2); context.closePath();
} else if (domain === "MISSILE") {
context.moveTo(x, y + glyph); context.lineTo(x, y - glyph); context.moveTo(x - glyph * .7, y - glyph * .2);
context.lineTo(x, y - glyph); context.lineTo(x + glyph * .7, y - glyph * .2);
} else if (domain === "SUBSURFACE") {
context.arc(x, y + glyph * .3, glyph * 1.2, Math.PI, Math.PI * 2);
context.moveTo(x - glyph * .4, y + glyph * .3); context.lineTo(x - glyph * .4, y - glyph * .4); context.lineTo(x + glyph * .4, y - glyph * .4);
} else if (domain === "UNDERWATER_WEAPON") {
context.moveTo(x - glyph, y); context.lineTo(x + glyph, y); context.moveTo(x + glyph * .4, y - glyph * .4);
context.lineTo(x + glyph, y); context.lineTo(x + glyph * .4, y + glyph * .4);
} else if (domain === "SURFACE") {
context.moveTo(x - glyph * 1.2, y + glyph * .4); context.lineTo(x + glyph * 1.2, y + glyph * .4);
context.moveTo(x + glyph * 1.2, y + glyph * .4); context.arc(x, y + glyph * .4, glyph * 1.2, 0, Math.PI, true);
} else {
context.arc(x, y, Math.max(1.5, glyph * .4), 0, Math.PI * 2);
}
context.stroke();
}
export function drawSymbolOn(context, x, y, domain, color, size, affiliation = "UNKNOWN") {
drawNatoSymbol(context, x, y, affiliation, domain, color, size);
}
export function drawSymbol(x, y, domain, color, size, affiliation = "UNKNOWN") {
drawNatoSymbol(ctx, x, y, affiliation, domain, color, size);
}