glytch/fktry/src/ui/palette.ts
type-two d017e710ad [ui] HUD foundation: voice, style, chips, hotkeys, selection
Shared plumbing for the DOM HUD, no framework:

- voice.ts: every player-facing string, so the OSHA-poster deadpan
  register lives in one place instead of being re-invented per panel.
- style.ts: injected terminal-industrial stylesheet. Panels re-enable
  pointer-events; #ui itself stays transparent to the mouse.
- chips.ts: the item chip (swatch + name + count), keyed off GameData
  so new items from LANE-DATA light up with no code change.
- hotkeys.ts: the whole keymap in one file, per lane orders.
- selection.ts: pending build selection, written through to bus._sel.
- pick.ts: tile -> entity hit-testing plus the flattened roster the UI
  keeps instead of holding a snapshot across frames (CONTRACTS says sim
  may reuse those buffers, and input handlers fire between frames).
- palette.ts: machine accent colors. Stopgap — MachineDef has no color
  field; contract request filed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 16:15:38 +10:00

39 lines
1.4 KiB
TypeScript

/**
* LANE-UI — machine accent colors for build-bar icons.
*
* `ItemDef` carries a `color`; `MachineDef` does not, so the build bar has nothing
* data-driven to tint with. These are transcribed from docs/FKTRY_LORE.md §4 (each
* machine's ASSET block names its impossible element) as a stopgap.
*
* CONTRACT REQUEST filed in NOTES: add `MachineDef.color` — LANE-RENDER needs the same
* value for its placeholder box tint, and two lanes hand-maintaining the same table is
* how the build bar and the world end up disagreeing about what a quantizer looks like.
* Until then: id override, else kind fallback, else house green. Never crashes on a
* machine we've never heard of.
*/
import type { MachineDef, MachineKind } from '../contracts';
const BY_ID: Record<string, string> = {
'seam-extractor': '#c8a03f', // grimy yellow chassis
belt: '#5a7a5a',
demuxer: '#ff3fd4', // the magenta output chute
quantizer: '#e8e0ff', // HF dust leaking from the seams
'mosh-reactor': '#ff7a3f', // melt, seen through the porthole
'decode-asic': '#3fffe0', // serene LED face
shipper: '#d8ffd8', // THE SCREEN's own light
};
const BY_KIND: Record<MachineKind, string> = {
extractor: '#c8a03f',
belt: '#5a7a5a',
crafter: '#3fffe0',
splitter: '#7fb0ff',
power: '#3fffe0',
buffer: '#7fb0ff',
shipper: '#d8ffd8',
};
export function machineColor(def: MachineDef): string {
return BY_ID[def.id] ?? BY_KIND[def.kind] ?? '#d8ffd8';
}