Game UI: diegetic HUD over persistent vault scene

Space Engine-style viewport with cockpit frame, glyph rail,
console overlays for orbits/wormhole/decay/reconstitute.
This commit is contained in:
Tessera Agent
2026-11-09 10:36:21 +00:00
parent 1a67876f19
commit d358c73291
8 changed files with 481 additions and 128 deletions

View File

@@ -0,0 +1,89 @@
import type { ReactNode } from "react";
import type { VaultStatus } from "../../lib/format";
import { StatusDot } from "../ui/StatusDot";
import { formatBytes } from "../../lib/format";
import type { Snapshot } from "../../api";
export function CockpitFrame({ children }: { children: ReactNode }) {
return (
<div className="absolute inset-0 pointer-events-none z-20">
<motionBorder />
<p className="absolute top-3 left-4 text-[10px] font-mono tracking-[0.35em] text-star-400/80 uppercase">
Tessera · orbital vault
</p>
<p className="absolute top-3 right-4 text-[10px] font-mono text-star-400/60">
SYS // VAULT-01
</p>
<div className="absolute bottom-3 left-4 right-4 h-px bg-gradient-to-r from-transparent via-wormhole-violet/40 to-transparent" />
<div className="vignette" />
<div className="scanlines" />
{children}
</div>
);
}
function motionBorder() {
return (
<>
<span className="absolute top-8 left-6 w-12 h-12 border-l-2 border-t-2 border-wormhole-violet/50 rounded-tl" />
<span className="absolute top-8 right-6 w-12 h-12 border-r-2 border-t-2 border-wormhole-violet/50 rounded-tr" />
<span className="absolute bottom-16 left-6 w-16 h-10 border-l-2 border-b-2 border-star-400/25 rounded-bl" />
<span className="absolute bottom-16 right-6 w-16 h-10 border-r-2 border-b-2 border-star-400/25 rounded-br" />
</>
);
}
export function TelemetryStrip({
status,
online,
snapCount,
totalBytes,
}: {
status: VaultStatus;
online: boolean;
snapCount: number;
totalBytes: number;
}) {
return (
<div className="pointer-events-none absolute top-12 left-4 right-4 flex justify-between items-start gap-2 text-[11px] font-mono">
<div className="flex items-center gap-2 bg-space-950/50 backdrop-blur-sm border border-space-700/50 rounded px-2 py-1">
<StatusDot status={online ? status : "grey"} size="sm" />
<span className="text-star-300">{online ? "LINK OK" : "NO LINK"}</span>
</div>
<div className="text-right text-star-400/90 bg-space-950/40 px-2 py-1 rounded border border-space-800/40">
<div>TILES {snapCount}</div>
<div className="text-[10px] opacity-70">{formatBytes(totalBytes)} mass</div>
</div>
</div>
);
}
export function SnapshotsMiniList({
snapshots,
selected,
onSelect,
}: {
snapshots: Snapshot[];
selected: string | null;
onSelect: (id: string) => void;
}) {
if (!snapshots.length) return null;
return (
<div className="pointer-events-auto absolute left-4 bottom-24 max-w-[140px] space-y-1">
{snapshots.slice(0, 4).map((s, i) => (
<button
key={s.id}
type="button"
onClick={() => onSelect(s.id)}
className={`w-full text-left text-[10px] font-mono px-2 py-1 rounded border transition-colors ${
selected === s.id
? "border-orbit-green/60 bg-orbit-green/10 text-orbit-green"
: "border-space-700/50 bg-space-950/60 text-star-400 hover:border-star-400/40"
}`}
>
{String(i + 1).padStart(2, "0")} · {s.orbit_name.slice(0, 12)}
</button>
))}
</div>
);
}

View File

@@ -0,0 +1,96 @@
import { motion, AnimatePresence } from "motion/react";
import type { ReactNode } from "react";
export function HUDPanel({
open,
title,
subtitle,
onClose,
children,
side = "right",
}: {
open: boolean;
title: string;
subtitle?: string;
onClose: () => void;
children: ReactNode;
side?: "left" | "right" | "bottom";
}) {
const pos =
side === "left"
? "left-0 top-12 bottom-20 w-[min(100%,380px)] border-r"
: side === "bottom"
? "inset-x-0 bottom-20 top-auto max-h-[55dvh] border-t"
: "right-0 top-12 bottom-20 w-[min(100%,400px)] border-l";
return (
<AnimatePresence>
{open && (
<>
<motion.button
type="button"
aria-label="Dismiss overlay"
className="fixed inset-0 z-40 bg-space-950/50 backdrop-blur-[2px]"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={onClose}
/>
<motion.aside
className={`fixed z-50 ${pos} border-wormhole-violet/20 bg-space-900/92 backdrop-blur-xl overflow-y-auto scrollbar-none`}
initial={{ opacity: 0, x: side === "right" ? 40 : side === "left" ? -40 : 0, y: side === "bottom" ? 40 : 0 }}
animate={{ opacity: 1, x: 0, y: 0 }}
exit={{ opacity: 0, x: side === "right" ? 20 : 0, y: side === "bottom" ? 20 : 0 }}
transition={{ type: "spring", damping: 26, stiffness: 280 }}
>
<header className="sticky top-0 bg-space-900/95 border-b border-space-700/60 px-4 py-3 flex items-start justify-between gap-3">
<div>
<p className="text-[10px] font-mono text-wormhole-violet tracking-widest uppercase">
Console
</p>
<h2 className="text-lg font-semibold text-star-100">{title}</h2>
{subtitle && <p className="text-xs text-star-400 mt-0.5">{subtitle}</p>}
</div>
<button
type="button"
onClick={onClose}
className="font-mono text-xs text-star-400 border border-space-700 rounded px-2 py-1 hover:text-star-200"
>
ESC
</button>
</header>
<div className="p-4 pb-8">{children}</div>
</motion.aside>
</>
)}
</AnimatePresence>
);
}
export function SceneAction({
label,
onClick,
disabled,
variant = "primary",
}: {
label: string;
onClick: () => void;
disabled?: boolean;
variant?: "primary" | "ghost";
}) {
return (
<motion.button
type="button"
disabled={disabled}
onClick={onClick}
className={`pointer-events-auto font-mono text-xs tracking-wide px-5 py-2.5 rounded border ${
variant === "primary"
? "border-orbit-green/50 text-orbit-green bg-orbit-green/10 hover:bg-orbit-green/20"
: "border-star-400/30 text-star-300 bg-space-950/60"
} disabled:opacity-40`}
whileTap={{ scale: 0.97 }}
>
{label}
</motion.button>
);
}

View File

@@ -0,0 +1,60 @@
import { motion } from "motion/react";
export type HUDMode = "scene" | "orbits" | "wormhole" | "decay" | "reconstitute";
const items: { id: HUDMode; label: string; glyph: string; hint: string }[] = [
{ id: "scene", label: "Viewport", glyph: "◎", hint: "Vault ring" },
{ id: "orbits", label: "Orbits", glyph: "⟳", hint: "Flight paths" },
{ id: "wormhole", label: "Wormhole", glyph: "◉", hint: "Outpost link" },
{ id: "decay", label: "Decay", glyph: "◇", hint: "Fade policy" },
{ id: "reconstitute", label: "Restore", glyph: "↩", hint: "Reconstitute" },
];
export function HUDRail({
active,
onSelect,
capturing,
}: {
active: HUDMode;
onSelect: (m: HUDMode) => void;
capturing?: boolean;
}) {
return (
<nav
className="pointer-events-auto absolute bottom-6 left-1/2 -translate-x-1/2 z-30 flex gap-1 px-2 py-1.5 rounded-full border border-wormhole-violet/25 bg-space-950/75 backdrop-blur-xl shadow-[0_0_40px_rgba(5,6,15,0.8)]"
aria-label="Ship systems"
>
{items.map((item) => {
const on = active === item.id;
return (
<motion.button
key={item.id}
type="button"
title={item.hint}
onClick={() => onSelect(item.id)}
className={`relative px-3 py-2 rounded-full text-xs font-mono transition-colors ${
on
? "text-wormhole-violet bg-wormhole-violet/15"
: "text-star-400 hover:text-star-200"
}`}
whileTap={{ scale: 0.94 }}
>
<span className="sr-only">{item.label}</span>
<span aria-hidden className="text-sm">
{item.glyph}
</span>
{on && (
<motion.span
layoutId="hud-pip"
className="absolute -bottom-1 left-1/2 w-1 h-1 -translate-x-1/2 rounded-full bg-orbit-green"
/>
)}
{item.id === "orbits" && capturing && (
<span className="absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orbit-amber animate-pulse" />
)}
</motion.button>
);
})}
</nav>
);
}

View File

@@ -0,0 +1,36 @@
import { motion } from "motion/react";
import type { Snapshot } from "../../api";
import { VaultRing } from "../vault/VaultRing";
import { Starfield } from "./Starfield";
export function VaultScene({
snapshots,
onSelect,
onCapture,
capturing,
}: {
snapshots: Snapshot[];
onSelect: (id: string) => void;
onCapture?: () => void;
capturing?: boolean;
}) {
return (
<div className="absolute inset-0 overflow-hidden">
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(30,38,71,0.45)_0%,rgba(4,5,12,0.95)_65%)]" />
<Starfield />
<motion.div
className="absolute top-1/4 left-1/2 -translate-x-1/2 w-[80vmin] h-[40vmin] rounded-full bg-wormhole-violet/5 blur-3xl"
animate={{ opacity: [0.3, 0.55, 0.3], scale: [1, 1.05, 1] }}
transition={{ duration: 8, repeat: Infinity }}
/>
<div className="relative z-10 h-full w-full pb-28">
<VaultRing
snapshots={snapshots}
onSelect={onSelect}
onCapture={onCapture}
capturing={capturing}
/>
</div>
</div>
);
}

View File

@@ -109,8 +109,8 @@ export function VaultRing({
{capturing ? "Orbit in progress…" : "Capture now"}
</motion.button>
)}
<p className="mt-2 text-xs text-star-400 max-w-xs text-center">
Tap a tile for snapshot detail. Only stardust that changed.
<p className="mt-2 text-[10px] font-mono text-star-400/80 max-w-xs text-center uppercase tracking-wider">
Select tile · stardust delta only
</p>
</div>
);