Various more changes to the Archetype Builder

This commit is contained in:
2026-02-22 14:44:27 +02:00
parent bdddc304ee
commit 99c7004ac2
7 changed files with 550 additions and 22 deletions

View File

@@ -87,6 +87,7 @@ export default function MelodyForm() {
const [showBuildOnTheFly, setShowBuildOnTheFly] = useState(false);
const [showSpeedCalc, setShowSpeedCalc] = useState(false);
const [builtMelody, setBuiltMelody] = useState(null);
const [assignedBinaryName, setAssignedBinaryName] = useState(null);
useEffect(() => {
api.get("/settings/melody").then((ms) => {
@@ -131,6 +132,7 @@ export default function MelodyForm() {
try {
const bm = await api.get(`/builder/melodies/for-melody/${id}`);
setBuiltMelody(bm || null);
setAssignedBinaryName(bm?.name || null);
} catch {
setBuiltMelody(null);
}
@@ -498,10 +500,6 @@ export default function MelodyForm() {
<label className="block text-sm font-medium mb-1" style={labelStyle}>PID (Playback ID)</label>
<input type="text" value={pid} onChange={(e) => setPid(e.target.value)} placeholder="eg. builtin_festive_vesper" className={inputClass} />
</div>
<div>
<label className="block text-sm font-medium mb-1" style={labelStyle}>UID (leave empty for now)</label>
<input type="text" value={uid} onChange={(e) => setUid(e.target.value)} className={inputClass} />
</div>
{isEdit && url && (
<div className="md:col-span-2">
<label className="block text-sm font-medium mb-1" style={labelStyle}>URL (auto-set from binary upload)</label>
@@ -579,7 +577,13 @@ export default function MelodyForm() {
<div className="space-y-4">
<div>
<label className="block text-sm font-medium mb-1" style={labelStyle}>Binary File (.bsm / .bin)</label>
{existingFiles.binary_url && (<p className="text-xs mb-1" style={{ color: "var(--success)" }}>Current file uploaded. Selecting a new file will replace it.</p>)}
{existingFiles.binary_url && (
<p className="text-xs mb-1" style={{ color: "var(--success)" }}>
{assignedBinaryName
? <><strong>{assignedBinaryName}.bsm</strong> is set. Selecting a new file will replace it.</>
: "Current file uploaded. Selecting a new file will replace it."}
</p>
)}
<input type="file" accept=".bin,.bsm" onChange={(e) => setBinaryFile(e.target.files[0] || null)} className="w-full text-sm" style={mutedStyle} />
{isEdit && (
<div className="flex gap-2 mt-2">
@@ -641,8 +645,10 @@ export default function MelodyForm() {
open={showSelectBuilt}
melodyId={id}
onClose={() => setShowSelectBuilt(false)}
onSuccess={() => {
onSuccess={(archetype) => {
setShowSelectBuilt(false);
setAssignedBinaryName(archetype.name);
if (!pid.trim() && archetype.pid) setPid(archetype.pid);
loadMelody();
}}
/>
@@ -652,8 +658,10 @@ export default function MelodyForm() {
defaultName={getLocalizedValue(information.name, "en", "") || getLocalizedValue(information.name, editLang, "")}
defaultPid={pid}
onClose={() => setShowBuildOnTheFly(false)}
onSuccess={() => {
onSuccess={(archetype) => {
setShowBuildOnTheFly(false);
setAssignedBinaryName(archetype.name);
if (!pid.trim() && archetype.pid) setPid(archetype.pid);
loadMelody();
}}
/>