kopia lustrzana https://github.com/backface/turtlestitch
Tweaked loading sprites with inherited complex attributes (costumes, sounds)
rodzic
8f315ffa83
commit
36e555cd5c
|
@ -3478,6 +3478,11 @@ Fixes:
|
||||||
* Block: new musical “notes” symbol
|
* Block: new musical “notes” symbol
|
||||||
* Objects, Blocks, Threads, GUI: inheritance support for sounds
|
* Objects, Blocks, Threads, GUI: inheritance support for sounds
|
||||||
|
|
||||||
|
170627
|
||||||
|
------
|
||||||
|
* Objects: Inheritance of costumes and sounds - propagate changes
|
||||||
|
* Store: Tweaked loading sprites with inherited complex attributes (costumes, sounds)
|
||||||
|
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* polymorphic sprite-local custom blocks
|
* polymorphic sprite-local custom blocks
|
||||||
|
|
52
store.js
52
store.js
|
@ -61,7 +61,7 @@ normalizeCanvas, contains*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.store = '2017-June-26';
|
modules.store = '2017-June-27';
|
||||||
|
|
||||||
|
|
||||||
// XML_Serializer ///////////////////////////////////////////////////////
|
// XML_Serializer ///////////////////////////////////////////////////////
|
||||||
|
@ -489,15 +489,33 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
myself.project.stage.children.forEach(function (sprite) {
|
myself.project.stage.children.forEach(function (sprite) {
|
||||||
delete sprite.inheritanceInfo;
|
var costume;
|
||||||
if (sprite.nestingInfo) { // only sprites may have nesting info
|
if (sprite.nestingInfo) { // only sprites may have nesting info
|
||||||
sprite.nestingScale = +(sprite.nestingInfo.scale || sprite.scale);
|
sprite.nestingScale = +(sprite.nestingInfo.scale || sprite.scale);
|
||||||
delete sprite.nestingInfo;
|
delete sprite.nestingInfo;
|
||||||
}
|
}
|
||||||
if (sprite.inheritsAttribute('scripts')) {
|
['scripts', 'costumes', 'sounds'].forEach(function (att) {
|
||||||
sprite.refreshInheritedAttribute('scripts');
|
if (sprite.inheritsAttribute(att)) {
|
||||||
|
sprite.refreshInheritedAttribute(att);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (sprite.inheritsAttribute('costumes')) {
|
||||||
|
costume = sprite.costumes.asArray()[
|
||||||
|
sprite.inheritanceInfo.costumeNumber - 1
|
||||||
|
];
|
||||||
|
if (costume) {
|
||||||
|
if (costume.loaded) {
|
||||||
|
sprite.wearCostume(costume, true);
|
||||||
|
} else {
|
||||||
|
costume.loaded = function () {
|
||||||
|
sprite.wearCostume(costume, true);
|
||||||
|
this.loaded = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete sprite.inheritanceInfo;
|
||||||
|
});
|
||||||
|
|
||||||
/* Global Variables */
|
/* Global Variables */
|
||||||
|
|
||||||
|
@ -731,15 +749,19 @@ SnapSerializer.prototype.loadObject = function (object, model) {
|
||||||
this.loadInheritanceInfo(object, model);
|
this.loadInheritanceInfo(object, model);
|
||||||
this.loadNestingInfo(object, model);
|
this.loadNestingInfo(object, model);
|
||||||
|
|
||||||
// loads costumes unless they're inherited
|
// load costumes unless they're inherited
|
||||||
if (object.inheritanceInfo &&
|
if (!(object.inheritanceInfo &&
|
||||||
(object.inheritanceInfo.delegated instanceof Array) &&
|
(object.inheritanceInfo.delegated instanceof Array) &&
|
||||||
contains(object.inheritanceInfo.delegated, 'costumes')) {
|
contains(object.inheritanceInfo.delegated, 'costumes'))) {
|
||||||
} else {
|
|
||||||
this.loadCostumes(object, model);
|
this.loadCostumes(object, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load sounds unless they're inherited
|
||||||
|
if (!(object.inheritanceInfo &&
|
||||||
|
(object.inheritanceInfo.delegated instanceof Array) &&
|
||||||
|
contains(object.inheritanceInfo.delegated, 'sounds'))) {
|
||||||
this.loadSounds(object, model);
|
this.loadSounds(object, model);
|
||||||
|
}
|
||||||
|
|
||||||
this.loadCustomBlocks(object, blocks);
|
this.loadCustomBlocks(object, blocks);
|
||||||
if (dispatches) {
|
if (dispatches) {
|
||||||
|
@ -748,13 +770,12 @@ SnapSerializer.prototype.loadObject = function (object, model) {
|
||||||
this.populateCustomBlocks(object, blocks);
|
this.populateCustomBlocks(object, blocks);
|
||||||
this.loadVariables(object.variables, model.require('variables'), object);
|
this.loadVariables(object.variables, model.require('variables'), object);
|
||||||
|
|
||||||
// loads scripts unless they're inherited
|
// load scripts unless they're inherited
|
||||||
if (object.inheritanceInfo &&
|
if (!(object.inheritanceInfo &&
|
||||||
(object.inheritanceInfo.delegated instanceof Array) &&
|
(object.inheritanceInfo.delegated instanceof Array) &&
|
||||||
contains(object.inheritanceInfo.delegated, 'scripts')) {
|
contains(object.inheritanceInfo.delegated, 'scripts'))) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.loadScripts(object, object.scripts, model.require('scripts'));
|
this.loadScripts(object, object.scripts, model.require('scripts'));
|
||||||
|
}
|
||||||
|
|
||||||
// note: the dispatches cache isn't cleared until after
|
// note: the dispatches cache isn't cleared until after
|
||||||
// *all* objects are loaded
|
// *all* objects are loaded
|
||||||
|
@ -771,6 +792,7 @@ SnapSerializer.prototype.loadInheritanceInfo = function (object, model) {
|
||||||
object.inheritanceInfo.delegated =
|
object.inheritanceInfo.delegated =
|
||||||
this.loadValue(delegated).asArray();
|
this.loadValue(delegated).asArray();
|
||||||
}
|
}
|
||||||
|
object.inheritanceInfo.costumeNumber = model.attributes.costume;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -796,10 +818,10 @@ SnapSerializer.prototype.loadCostumes = function (object, model) {
|
||||||
costume = object.costumes.asArray()[model.attributes.costume - 1];
|
costume = object.costumes.asArray()[model.attributes.costume - 1];
|
||||||
if (costume) {
|
if (costume) {
|
||||||
if (costume.loaded) {
|
if (costume.loaded) {
|
||||||
object.wearCostume(costume);
|
object.wearCostume(costume, true);
|
||||||
} else {
|
} else {
|
||||||
costume.loaded = function () {
|
costume.loaded = function () {
|
||||||
object.wearCostume(costume);
|
object.wearCostume(costume, true);
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue