// Selected-planet marker. When the SelectionStore holds a planet, the // map draws one accent ring tight around it so the current selection is // visible on the canvas itself (the inspector/sheet show the detail). // Ship-group selection is intentionally not ringed here — groups are // addressed by report index and have no single stable map coordinate. import { DARK_THEME, type CirclePrim, type Theme } from "./world"; /** Planet marker radius in world units; mirrors `battle-markers.ts`. */ const PLANET_RADIUS_WORLD = 6; /** The ring sits just outside the marker (and the bombing ring at +3). */ const SELECTION_RING_RADIUS = PLANET_RADIUS_WORLD + 4; /** High-bit prefix so the ring id never collides with planet numbers, * route lines, reach rings (`0xb…`), or battle markers. */ export const SELECTION_RING_ID = 0xc0000000; /** Below interactive primitives so it never wins a click. */ const SELECTION_RING_PRIORITY = 0; /** * computeSelectionRing returns one ring primitive centred on the selected * planet, or `null` when nothing (or a non-planet) is selected or the * planet is absent from the current report. `theme` supplies the ring * colour and defaults to `DARK_THEME`. */ export function computeSelectionRing( planets: ReadonlyArray<{ number: number; x: number; y: number }>, selectedPlanetId: number | null, theme: Theme = DARK_THEME, ): CirclePrim | null { if (selectedPlanetId === null) return null; const planet = planets.find((p) => p.number === selectedPlanetId); if (planet === undefined) return null; return { kind: "circle", id: SELECTION_RING_ID, priority: SELECTION_RING_PRIORITY, hitSlopPx: 0, x: planet.x, y: planet.y, radius: SELECTION_RING_RADIUS, style: { strokeColor: theme.selectionRing, strokeAlpha: 0.95, strokeWidthPx: 1.5, }, }; }