mirror of
https://github.com/isledecomp/isle.pizza.git
synced 2026-03-01 14:27:38 +00:00
Add reset to default button for actor editor
Compare each actor's character state against ActorInfoInit defaults and show a reset button when any field differs. Resets all 10 fields (sound, move, mood, hat, colors) in a single save round-trip by extending updateSaveSlot to accept batch character updates.
This commit is contained in:
parent
412d8a4233
commit
de984a8a28
@ -244,14 +244,16 @@ export async function updateSaveSlot(slotNumber, updates) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply character update
|
// Apply character update(s)
|
||||||
if (updates.character) {
|
if (updates.character) {
|
||||||
const { characterIndex, field, value } = updates.character;
|
const entries = Array.isArray(updates.character) ? updates.character : [updates.character];
|
||||||
const charSerializer = createSerializer(newBuffer);
|
for (const { characterIndex, field, value } of entries) {
|
||||||
const result = charSerializer.updateCharacter(characterIndex, field, value);
|
const charSerializer = createSerializer(newBuffer);
|
||||||
if (result) {
|
const result = charSerializer.updateCharacter(characterIndex, field, value);
|
||||||
newBuffer = result;
|
if (result) {
|
||||||
modified = true;
|
newBuffer = result;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
import { ActorInfoInit, ActorPart } from '../../core/savegame/actorConstants.js';
|
import { ActorInfoInit, ActorPart } from '../../core/savegame/actorConstants.js';
|
||||||
import { Actor } from '../../core/savegame/constants.js';
|
import { Actor } from '../../core/savegame/constants.js';
|
||||||
import NavButton from '../NavButton.svelte';
|
import NavButton from '../NavButton.svelte';
|
||||||
|
import ResetButton from '../ResetButton.svelte';
|
||||||
import EditorTooltip from '../EditorTooltip.svelte';
|
import EditorTooltip from '../EditorTooltip.svelte';
|
||||||
|
|
||||||
export let slot;
|
export let slot;
|
||||||
@ -26,6 +27,18 @@
|
|||||||
$: actorName = actorInfo?.name || 'Unknown';
|
$: actorName = actorInfo?.name || 'Unknown';
|
||||||
$: charState = slot?.characters?.[actorIndex];
|
$: charState = slot?.characters?.[actorIndex];
|
||||||
|
|
||||||
|
$: isDefault = actorInfo && charState &&
|
||||||
|
charState.sound === actorInfo.sound &&
|
||||||
|
charState.move === actorInfo.move &&
|
||||||
|
charState.mood === actorInfo.mood &&
|
||||||
|
charState.hatPartNameIndex === actorInfo.parts[1].partNameIndex &&
|
||||||
|
charState.hatNameIndex === actorInfo.parts[1].nameIndex &&
|
||||||
|
charState.infogronNameIndex === actorInfo.parts[2].nameIndex &&
|
||||||
|
charState.armlftNameIndex === actorInfo.parts[4].nameIndex &&
|
||||||
|
charState.armrtNameIndex === actorInfo.parts[5].nameIndex &&
|
||||||
|
charState.leglftNameIndex === actorInfo.parts[8].nameIndex &&
|
||||||
|
charState.legrtNameIndex === actorInfo.parts[9].nameIndex;
|
||||||
|
|
||||||
function actorKey(slotNumber, idx, cs) {
|
function actorKey(slotNumber, idx, cs) {
|
||||||
return `${slotNumber}-${idx}-${cs.hatPartNameIndex}-${cs.hatNameIndex}-${cs.infogronNameIndex}-${cs.armlftNameIndex}-${cs.armrtNameIndex}-${cs.leglftNameIndex}-${cs.legrtNameIndex}-${cs.move}-${cs.sound}`;
|
return `${slotNumber}-${idx}-${cs.hatPartNameIndex}-${cs.hatNameIndex}-${cs.infogronNameIndex}-${cs.armlftNameIndex}-${cs.armrtNameIndex}-${cs.leglftNameIndex}-${cs.legrtNameIndex}-${cs.move}-${cs.sound}`;
|
||||||
}
|
}
|
||||||
@ -176,6 +189,25 @@
|
|||||||
character: { characterIndex: actorIndex, field: 'mood', value: nextMood }
|
character: { characterIndex: actorIndex, field: 'mood', value: nextMood }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetActor() {
|
||||||
|
const i = actorIndex;
|
||||||
|
const p = actorInfo.parts;
|
||||||
|
onUpdate({
|
||||||
|
character: [
|
||||||
|
{ characterIndex: i, field: 'sound', value: actorInfo.sound },
|
||||||
|
{ characterIndex: i, field: 'move', value: actorInfo.move },
|
||||||
|
{ characterIndex: i, field: 'mood', value: actorInfo.mood },
|
||||||
|
{ characterIndex: i, field: 'hatPartNameIndex', value: p[1].partNameIndex },
|
||||||
|
{ characterIndex: i, field: 'hatNameIndex', value: p[1].nameIndex },
|
||||||
|
{ characterIndex: i, field: 'infogronNameIndex', value: p[2].nameIndex },
|
||||||
|
{ characterIndex: i, field: 'armlftNameIndex', value: p[4].nameIndex },
|
||||||
|
{ characterIndex: i, field: 'armrtNameIndex', value: p[5].nameIndex },
|
||||||
|
{ characterIndex: i, field: 'leglftNameIndex', value: p[8].nameIndex },
|
||||||
|
{ characterIndex: i, field: 'legrtNameIndex', value: p[9].nameIndex }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<EditorTooltip text="Click to customize based on your current character. Navigate between all 66 game actors using the arrows. Changes are automatically saved.">
|
<EditorTooltip text="Click to customize based on your current character. Navigate between all 66 game actors using the arrows. Changes are automatically saved.">
|
||||||
@ -210,6 +242,12 @@
|
|||||||
<NavButton direction="right" onclick={nextActor} />
|
<NavButton direction="right" onclick={nextActor} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="reset-container">
|
||||||
|
{#if !isDefault && !loading && !error}
|
||||||
|
<ResetButton onclick={resetActor} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</EditorTooltip>
|
</EditorTooltip>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -295,4 +333,8 @@
|
|||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
color: var(--color-text-light);
|
color: var(--color-text-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reset-container {
|
||||||
|
height: 1.6em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user