diff --git a/HISTORY.md b/HISTORY.md index 68a426f0..879897cf 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -13,6 +13,9 @@ * German * Galician, thanks, Miguel! +### 2019-08-08 +* store: allow wardrobe-less costumes to be shared among several sprites (e.g. when inheriting the "costume #" attribute) + ### 2019-08-07 * new dev version * blocks, threads: added "r-g-b-a" option to (aspect) AT (location) reporter in the sensing category diff --git a/snap.html b/snap.html index 5e199c23..b8207e9f 100755 --- a/snap.html +++ b/snap.html @@ -19,7 +19,7 @@ - + diff --git a/src/store.js b/src/store.js index 27238d4f..bf024dc0 100644 --- a/src/store.js +++ b/src/store.js @@ -61,7 +61,7 @@ normalizeCanvas, contains*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2019-August-07'; +modules.store = '2019-August-08'; // XML_Serializer /////////////////////////////////////////////////////// @@ -785,16 +785,21 @@ SnapSerializer.prototype.loadObject = function (object, model) { this.loadNestingInfo(object, model); // load the costume that's not in the wardrobe, if any - node = model.childNamed('costume'); + node = model.childNamed('wear'); if (node) { - costume = this.loadValue(node, object); - if (costume.loaded) { - object.wearCostume(costume, true); + node = node.childNamed('costume') || node.childNamed('ref'); + if (!node) { + console.log(object.name + ': missing costume to wear'); } else { - costume.loaded = function () { + costume = this.loadValue(node, object); + if (costume.loaded) { object.wearCostume(costume, true); - this.loaded = true; - }; + } else { + costume.loaded = function () { + object.wearCostume(costume, true); + this.loaded = true; + }; + } } } @@ -1769,7 +1774,9 @@ StageMorph.prototype.toXML = function (serializer) { normalizeCanvas(this.trailsCanvas, true).toDataURL('image/png'), // current costume, if it's not in the wardrobe - !costumeIdx && this.costume ? serializer.store(this.costume) : '', + !costumeIdx && this.costume ? + '' + serializer.store(this.costume) + '' + : '', serializer.store(this.costumes, this.name + '_cst'), serializer.store(this.sounds, this.name + '_snd'), @@ -1865,7 +1872,9 @@ SpriteMorph.prototype.toXML = function (serializer) { : '', // current costume, if it's not in the wardrobe - !costumeIdx && this.costume ? serializer.store(this.costume) : '', + !costumeIdx && this.costume ? + '' + serializer.store(this.costume) + '' + : '', noCostumes ? '' : serializer.store(this.costumes, this.name + '_cst'), noSounds ? '' : serializer.store(this.sounds, this.name + '_snd'),