Merge pull request #1850 from julescubtree/load-draggability

enable loading draggability from .sb3 file
This commit is contained in:
Karishma Chadha 2018-12-17 14:04:18 -05:00 committed by GitHub
commit 1591c28f28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -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.
target.targetPaneOrder = object.targetPaneOrder;
}
if (object.hasOwnProperty('draggable')) {
target.draggable = object.draggable;
}
Promise.all(costumePromises).then(costumes => {
sprite.costumes = costumes;
});

BIN
test/fixtures/draggable.sb3 vendored Normal file

Binary file not shown.

View file

@ -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 variableReporterSB2ProjectPath = path.resolve(__dirname, '../fixtures/top-level-variable-reporter.sb2');
const topLevelReportersProjectPath = path.resolve(__dirname, '../fixtures/top-level-reporters.sb3');
const draggableSB3ProjectPath = path.resolve(__dirname, '../fixtures/draggable.sb3');
const FakeRenderer = require('../fixtures/fake-renderer');
test('serialize', t => {
@ -288,3 +289,14 @@ test('(#1608) serializeBlocks maintains top level variable reporters', t => {
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();
});
});