improvemtns again, to the archetype builder, and playback

This commit is contained in:
2026-02-22 15:03:23 +02:00
parent 99c7004ac2
commit c5ef4406f6
9 changed files with 179 additions and 29 deletions

View File

@@ -115,7 +115,7 @@ const DELAY_MAX = 3000;
function delayToSlider(ms) { return DELAY_MIN + DELAY_MAX - ms; }
function sliderToDelay(val) { return DELAY_MIN + DELAY_MAX - val; }
export default function SpeedCalculatorModal({ open, melody, builtMelody, onClose, onSaved }) {
export default function SpeedCalculatorModal({ open, melody, builtMelody, archetypeCsv, onClose, onSaved }) {
const info = melody?.information || {};
// Raw steps input
@@ -164,19 +164,28 @@ export default function SpeedCalculatorModal({ open, melody, builtMelody, onClos
const maxWarning = capturedMax !== null && capturedMax < 100;
const orderWarning = capturedMax !== null && capturedNormal !== null && capturedNormal < capturedMax;
// Reset on open
// Reset on open — auto-load archetype CSV if available
useEffect(() => {
if (open) {
setCapturedMax(info.maxSpeed > 0 ? info.maxSpeed : null);
setCapturedNormal(null);
setStepsInput("");
setSteps([]);
setBinaryLoadError("");
setCurrentStep(-1);
setPlaying(false);
setPaused(false);
setSaveError("");
setSaveSuccess(false);
const csv = archetypeCsv || info.archetype_csv || null;
if (csv) {
const parsed = parseStepsString(csv);
setStepsInput(csv);
setSteps(parsed);
stepsRef.current = parsed;
} else {
setStepsInput("");
setSteps([]);
}
}
}, [open]); // eslint-disable-line react-hooks/exhaustive-deps