Files
VibemakerSandbox/app/src/ui/SimulationToolbar.jsx
T
chenlin fa089d5f0c feat: release v0.2 multi-robot simulator
Add declarative robot packages, shared simulation lifecycle and Microban ONNX/PD walking with independent head control.

Unify comic UI and chase camera; default robot packages to a 4.5m arena with real collision walls. Include regression tests, asset provenance/licenses and verification evidence.
2026-10-28 14:00:26 +08:00

90 lines
2.4 KiB
React

import Box from "@mui/material/Box";
import { useGame, gameApi } from "../store.js";
export const toolbarStyle = {
position: "fixed",
top: 20,
left: 24,
zIndex: 12,
display: "flex",
alignItems: "center",
gap: 10,
background: "rgba(8,8,12,.86)",
border: "2px solid #faf8f2",
padding: "8px 12px",
color: "#faf8f2",
fontFamily: "monospace",
boxShadow: "3px 3px 0 #08080c",
"& button, & select": {
font: "inherit",
color: "inherit",
border: "1px solid #777",
background: "#202028",
padding: "6px 10px",
cursor: "pointer",
},
"& button:disabled": { opacity: 0.4, cursor: "default" },
"& button:focus-visible, & select:focus-visible": {
outline: "2px solid #ff7a2f",
outlineOffset: 2,
},
};
export default function SimulationToolbar() {
const phase = useGame((s) => s.runtimePhase),
paused = useGame((s) => s.paused),
robots = useGame((s) => s.robots),
robotId = useGame((s) => s.robotId),
neutral = useGame((s) => s.presentationTheme === "neutral");
const ready = phase === "ready",
families = [
...new Map(
robots.map((r) => [
r.family,
{ ...r, id: robots.find((e) => e.family === r.family).id },
]),
).values(),
];
const family =
robots.find((r) => r.id === robotId)?.family ?? families[0]?.family ?? "";
return (
<Box
component="nav"
aria-label="Simulation controls"
sx={{
...toolbarStyle,
border: neutral ? "1px solid #657891" : toolbarStyle.border,
}}
>
<label>
Robot{" "}
<select
aria-label="Robot"
value={family}
disabled={phase === "loading" || phase === "switching"}
onChange={(event) =>
gameApi.switchRobot?.(
families.find((r) => r.family === event.target.value).id,
)
}
>
{families.map((r) => (
<option key={r.family} value={r.family}>
{r.name}
</option>
))}
</select>
</label>
<button
type="button"
disabled={!ready}
aria-pressed={paused}
onClick={() => (paused ? gameApi.resume?.() : gameApi.pause?.())}
>
{paused ? "Continue" : "Pause"}
</button>
<button type="button" disabled={!ready} onClick={() => gameApi.reset?.()}>
Reset
</button>
</Box>
);
}