fixes
This commit is contained in:
@@ -8,7 +8,7 @@ function createHarness() {
|
||||
const file = path.join(__dirname, '..', 'AnimationDirector.js');
|
||||
const source = fs.readFileSync(file, 'utf8').replace(
|
||||
' Plugin.register(PLUGIN_ID, {',
|
||||
' globalThis.adTest = { showAnimationDefinitionReviewDialog, createInjectorGenderDefaultHandler };\n Plugin.register(PLUGIN_ID, {'
|
||||
' globalThis.adTest = { showAnimationDefinitionReviewDialog, createInjectorGenderDefaultHandler, remapActorReferences, readStageDefinitionFromForm };\n Plugin.register(PLUGIN_ID, {'
|
||||
);
|
||||
const dialogs = [];
|
||||
const exports = [];
|
||||
@@ -45,7 +45,7 @@ function createHarness() {
|
||||
context.adTest.showAnimationDefinitionReviewDialog(group, analysis);
|
||||
return dialogs.at(-1);
|
||||
}
|
||||
return { open, exports, errors, project, analysis, createInjectorGenderDefaultHandler: context.adTest.createInjectorGenderDefaultHandler,
|
||||
return { open, exports, errors, project, analysis, helpers: context.adTest, createInjectorGenderDefaultHandler: context.adTest.createInjectorGenderDefaultHandler,
|
||||
setFormResult(result) { formResult = result; } };
|
||||
}
|
||||
|
||||
@@ -55,6 +55,50 @@ function defaults(form) {
|
||||
.map(([key, field]) => [key, field.value]));
|
||||
}
|
||||
|
||||
test('actor renames remap all definitions, metadata and prop previews simultaneously', () => {
|
||||
const h = createHarness();
|
||||
const metadata = { 1: { injects_into: ['wolf'] } };
|
||||
const definition = { actors: [{ label: 'player', injects_into: 'wolf', prop_right: 'minecraft:stick' },
|
||||
{ label: 'wolf' }], position_anchor_actor: 'wolf', stages: [{ stage: 1, props: { wolf: null, player: { prop_left: null } } }] };
|
||||
h.project.animationdirector_animdef_definitions = JSON.stringify({ first: definition, second: definition });
|
||||
h.project.animationdirector_prop_previews = JSON.stringify({ old: { animation: 'first', actor: 'wolf', slot: 'right', stage: 1 } });
|
||||
h.helpers.remapActorReferences({ 1: 'player', 2: 'wolf' }, { 1: 'wolf', 2: 'player' }, [1, 2], metadata);
|
||||
assert.deepEqual(metadata[1].injects_into, ['player']);
|
||||
for (const saved of Object.values(JSON.parse(h.project.animationdirector_animdef_definitions))) {
|
||||
assert.equal(saved.actors[0].label, 'wolf');
|
||||
assert.equal(saved.actors[0].injects_into, 'player');
|
||||
assert.equal(saved.actors[0].prop_right, 'minecraft:stick');
|
||||
assert.equal(saved.position_anchor_actor, 'player');
|
||||
assert.equal(saved.stages[0].props.player, null);
|
||||
assert.deepEqual(saved.stages[0].props.wolf, { prop_left: null });
|
||||
}
|
||||
const previews = JSON.parse(h.project.animationdirector_prop_previews);
|
||||
assert.equal(previews[JSON.stringify(['first', 'player', 'right', 1])].actor, 'player');
|
||||
});
|
||||
|
||||
test('own stage remains explicit and hidden loop controls do not block non-looping stages', () => {
|
||||
const h = createHarness(), dialog = h.open(), result = defaults(dialog.form);
|
||||
assert.equal(result.stub_stage_2_use_stage, 'own');
|
||||
result.stub_stage_2_midpoint_offset = 'not applicable';
|
||||
result.stub_stage_2_duration_multiplier = 'not applicable';
|
||||
const stage = h.helpers.readStageDefinitionFromForm(result, h.analysis.stages[1], true);
|
||||
assert.equal(stage.use_stage, undefined);
|
||||
assert.equal(stage.cycle_midpoint_offset_seconds, undefined);
|
||||
assert.equal(stage.stage_duration_multiplier, undefined);
|
||||
});
|
||||
|
||||
test('obsolete injection targets and position anchors remain visible for correction', () => {
|
||||
const h = createHarness();
|
||||
h.project.animationdirector_animdef_definitions = JSON.stringify({ test_animation: {
|
||||
actors: [{ label: 'player', entity_types: ['minecraft:player'], injector: 'V', injects_into: 'removed' }],
|
||||
position_anchor_actor: 'removed', stages: [{ stage: 2, use_stage: 99 }],
|
||||
} });
|
||||
const dialog = h.open();
|
||||
assert.match(dialog.form.stub_actor_1_injects_into.options.removed, /unavailable/);
|
||||
assert.match(dialog.form.position_anchor_actor.options.removed, /unavailable/);
|
||||
assert.match(dialog.form.stub_stage_2_use_stage.options['99'], /unavailable/);
|
||||
});
|
||||
|
||||
test('selecting an injector adds an editable male tag without enforcing it on export', () => {
|
||||
for (const role of ['V', 'A', 'M']) {
|
||||
const h = createHarness(), dialog = h.open(), result = defaults(dialog.form), updates = [];
|
||||
@@ -265,7 +309,7 @@ test('groups advanced matching and offers only other actors as injection targets
|
||||
'', 'manualpeak', 'defeated', 'stuck', 'tease', 'birth', 'fillbottle', 'other',
|
||||
]);
|
||||
assert.equal(form.stub_stage_2_use_stage.type, 'select');
|
||||
assert.deepEqual(Object.keys(form.stub_stage_2_use_stage.options), ['1', '2', '']);
|
||||
assert.deepEqual(Object.keys(form.stub_stage_2_use_stage.options), ['1', '2', 'own']);
|
||||
});
|
||||
|
||||
test('keeps minimal definitions minimal and supports specialized behavior', () => {
|
||||
|
||||
Reference in New Issue
Block a user