tweaks
This commit is contained in:
@@ -82,7 +82,7 @@ function harness() {
|
||||
finishEdit(action, aspects) { Object.assign(edits.at(-1), { after: project.animationdirector_block_requirements, action, post: aspects }); },
|
||||
},
|
||||
Dialog: class { constructor(options) { dialogs.push(options); } show() {} },
|
||||
Blockbench: { export(options, callback) { exports.push(JSON.parse(options.content)); callback(); },
|
||||
Blockbench: { isWeb: false, export(options, callback) { exports.push(JSON.parse(options.content)); callback(); },
|
||||
on(names, listener) { for (const name of names.split(' ')) events.set(name, listener); },
|
||||
addCSS() { return { delete() {} }; },
|
||||
showQuickMessage() {}, showMessageBox(options) { errors.push(options.message); } },
|
||||
@@ -103,15 +103,60 @@ function importAnalysis() {
|
||||
{ stageNumber: 2, name: 'test.p2', loop: false, cycleSeconds: 2 }], warnings: [] };
|
||||
}
|
||||
|
||||
test('imported beds and fences receive their editor-only preview dimensions', () => {
|
||||
const cases = [
|
||||
['center_support', '#minecraft:beds', 0.5625],
|
||||
['center_support', 'minecraft:red_bed', 0.5625],
|
||||
['center_support', ['minecraft:white_bed', 'minecraft:blue_bed'], 0.5625],
|
||||
['wall', '#minecraft:fences', 0.25],
|
||||
['wall', 'minecraft:oak_fence', 0.25],
|
||||
['wall', 'minecraft:nether_brick_fence', 0.25],
|
||||
['wall', 'minecraft:oak_fence_gate', 1],
|
||||
['wall', ['minecraft:oak_fence', 'minecraft:stone'], 1],
|
||||
];
|
||||
for (const [type, blocks, expected] of cases) {
|
||||
const h = harness();
|
||||
const requirement = type === 'wall' ? { type, blocks, height: { min: 1 }, width: { min: 1 } }
|
||||
: { type, blocks, support: 'surface', placement: 'surface_footprint' };
|
||||
const source = { actors: [{ label: 'player' }, { label: 'wolf' }], stages: [{ stage: 1 }, { stage: 2 }],
|
||||
block_requirements: requirement };
|
||||
h.project.animationdirector_block_requirements = JSON.stringify({ test: {
|
||||
requirement: { type: 'wall', blocks: 'minecraft:stone' }, preview: { surfaceHeight: 1.5, wallThickness: 0.75 } } });
|
||||
h.applyAnimationDefinitionImport({ id: 'test' }, importAnalysis(), source);
|
||||
const entry = h.getAuthoredBlockRequirement('test');
|
||||
assert.equal(type === 'wall' ? entry.preview.wallThickness : entry.preview.surfaceHeight, expected);
|
||||
assert.equal(h.getSavedAnimdef('test').block_requirements.preview, undefined);
|
||||
if (type === 'center_support') {
|
||||
const surface = h.buildBlockRequirementGuideBoxes(entry).find((box) => box.kind === 'required');
|
||||
assert.ok(surface);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('desktop-only tools are visible in desktop Blockbench and hidden in browser Blockbench', () => {
|
||||
const h = harness(); h.context.registration.onload();
|
||||
const actions = h.menus.flatMap((menu) => menu.children).filter((action) => action && typeof action !== 'string');
|
||||
const ids = ['animationdirector_automatic_import', 'animationdirector_pack_folders', 'animationdirector_item_props',
|
||||
'animationdirector_sound_library', 'animationdirector_create_jem_model'];
|
||||
for (const id of ids) {
|
||||
const action = actions.find((entry) => entry.id === id);
|
||||
assert.ok(action, `${id} is registered`);
|
||||
assert.equal(action.condition(), true, `${id} is visible on desktop`);
|
||||
h.context.Blockbench.isWeb = true;
|
||||
assert.equal(action.condition(), false, `${id} is hidden in browsers`);
|
||||
h.context.Blockbench.isWeb = false;
|
||||
}
|
||||
});
|
||||
|
||||
test('animation menu orders import and creation actions and has no deprecated split-file tools', () => {
|
||||
const h = harness();
|
||||
h.context.registration.onload();
|
||||
const menu = h.menus.find((entry) => entry.id === 'animationdirector_anims');
|
||||
assert.deepEqual(Array.from(menu.children, (action) => action === '_' ? '_' : action.name), [
|
||||
'Automatically Import Animation', 'Import Actor', 'Import Animation', 'Import Animation Definition', 'Pack Folders',
|
||||
'Import Whole Animation', 'Import Actor', 'Import Animation', 'Import Animation Definition', 'Pack Folders',
|
||||
'_', 'Actor Preferences', 'Replace Actor Model',
|
||||
'_', 'Block Requirements', 'Item Props', 'NoN Sound Library',
|
||||
'_', 'Create Animation Definition', 'Export Animations',
|
||||
'_', 'Animation Definition', 'Export Animations',
|
||||
]);
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'AnimationDirector.js'), 'utf8');
|
||||
assert.doesNotMatch(source, /importSplitActorAnimation|buildSplitImportFile|analyzeSplitAnimationFiles|exportSelectedActorAnimation|exportAllActorAnimations|animationdirector_deprecated/);
|
||||
|
||||
Reference in New Issue
Block a user