mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 23:30:09 -05:00
Merge pull request #1850 from julescubtree/load-draggability
enable loading draggability from .sb3 file
This commit is contained in:
commit
1591c28f28
3 changed files with 15 additions and 0 deletions
|
@ -1025,6 +1025,9 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
|
||||||
// This will be deleted after we are done parsing and ordering the targets list.
|
// This will be deleted after we are done parsing and ordering the targets list.
|
||||||
target.targetPaneOrder = object.targetPaneOrder;
|
target.targetPaneOrder = object.targetPaneOrder;
|
||||||
}
|
}
|
||||||
|
if (object.hasOwnProperty('draggable')) {
|
||||||
|
target.draggable = object.draggable;
|
||||||
|
}
|
||||||
Promise.all(costumePromises).then(costumes => {
|
Promise.all(costumePromises).then(costumes => {
|
||||||
sprite.costumes = costumes;
|
sprite.costumes = costumes;
|
||||||
});
|
});
|
||||||
|
|
BIN
test/fixtures/draggable.sb3
vendored
Normal file
BIN
test/fixtures/draggable.sb3
vendored
Normal file
Binary file not shown.
|
@ -9,6 +9,7 @@ const commentsSB3ProjectPath = path.resolve(__dirname, '../fixtures/comments.sb3
|
||||||
const commentsSB3NoDupeIds = path.resolve(__dirname, '../fixtures/comments_no_duplicate_id_serialization.sb3');
|
const commentsSB3NoDupeIds = path.resolve(__dirname, '../fixtures/comments_no_duplicate_id_serialization.sb3');
|
||||||
const variableReporterSB2ProjectPath = path.resolve(__dirname, '../fixtures/top-level-variable-reporter.sb2');
|
const variableReporterSB2ProjectPath = path.resolve(__dirname, '../fixtures/top-level-variable-reporter.sb2');
|
||||||
const topLevelReportersProjectPath = path.resolve(__dirname, '../fixtures/top-level-reporters.sb3');
|
const topLevelReportersProjectPath = path.resolve(__dirname, '../fixtures/top-level-reporters.sb3');
|
||||||
|
const draggableSB3ProjectPath = path.resolve(__dirname, '../fixtures/draggable.sb3');
|
||||||
const FakeRenderer = require('../fixtures/fake-renderer');
|
const FakeRenderer = require('../fixtures/fake-renderer');
|
||||||
|
|
||||||
test('serialize', t => {
|
test('serialize', t => {
|
||||||
|
@ -288,3 +289,14 @@ test('(#1608) serializeBlocks maintains top level variable reporters', t => {
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('(#1850) sprite draggability state read when loading SB3 file', t => {
|
||||||
|
const vm = new VirtualMachine();
|
||||||
|
vm.loadProject(readFileToBuffer(draggableSB3ProjectPath))
|
||||||
|
.then(() => {
|
||||||
|
const sprite1Obj = vm.runtime.targets.find(target => target.sprite.name === 'Sprite1');
|
||||||
|
// Sprite1 in project should have draggable set to true
|
||||||
|
t.equal(sprite1Obj.draggable, true);
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue