allow wardrobe-less costumes to be shared among several sprites

e.g. when inheriting the "costume #" attribute
pull/89/head
jmoenig 2019-08-08 11:01:42 +02:00
rodzic 9641e5a460
commit cb1232c548
3 zmienionych plików z 23 dodań i 11 usunięć

Wyświetl plik

@ -13,6 +13,9 @@
* German * German
* Galician, thanks, Miguel! * 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 ### 2019-08-07
* new dev version * new dev version
* blocks, threads: added "r-g-b-a" option to (aspect) AT (location) reporter in the sensing category * blocks, threads: added "r-g-b-a" option to (aspect) AT (location) reporter in the sensing category

Wyświetl plik

@ -19,7 +19,7 @@
<script type="text/javascript" src="src/video.js?version=2019-06-27"></script> <script type="text/javascript" src="src/video.js?version=2019-06-27"></script>
<script type="text/javascript" src="src/maps.js?version=2019-06-27"></script> <script type="text/javascript" src="src/maps.js?version=2019-06-27"></script>
<script type="text/javascript" src="src/xml.js?version=2019-06-27"></script> <script type="text/javascript" src="src/xml.js?version=2019-06-27"></script>
<script type="text/javascript" src="src/store.js?version=2019-08-07"></script> <script type="text/javascript" src="src/store.js?version=2019-08-08"></script>
<script type="text/javascript" src="src/locale.js?version=2019-08-07"></script> <script type="text/javascript" src="src/locale.js?version=2019-08-07"></script>
<script type="text/javascript" src="src/cloud.js?version=2019-07-17"></script> <script type="text/javascript" src="src/cloud.js?version=2019-07-17"></script>
<script type="text/javascript" src="src/sha512.js?version=2019-06-27"></script> <script type="text/javascript" src="src/sha512.js?version=2019-06-27"></script>

Wyświetl plik

@ -61,7 +61,7 @@ normalizeCanvas, contains*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.store = '2019-August-07'; modules.store = '2019-August-08';
// XML_Serializer /////////////////////////////////////////////////////// // XML_Serializer ///////////////////////////////////////////////////////
@ -785,16 +785,21 @@ SnapSerializer.prototype.loadObject = function (object, model) {
this.loadNestingInfo(object, model); this.loadNestingInfo(object, model);
// load the costume that's not in the wardrobe, if any // load the costume that's not in the wardrobe, if any
node = model.childNamed('costume'); node = model.childNamed('wear');
if (node) { if (node) {
costume = this.loadValue(node, object); node = node.childNamed('costume') || node.childNamed('ref');
if (costume.loaded) { if (!node) {
object.wearCostume(costume, true); console.log(object.name + ': missing costume to wear');
} else { } else {
costume.loaded = function () { costume = this.loadValue(node, object);
if (costume.loaded) {
object.wearCostume(costume, true); 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'), normalizeCanvas(this.trailsCanvas, true).toDataURL('image/png'),
// current costume, if it's not in the wardrobe // current costume, if it's not in the wardrobe
!costumeIdx && this.costume ? serializer.store(this.costume) : '', !costumeIdx && this.costume ?
'<wear>' + serializer.store(this.costume) + '</wear>'
: '',
serializer.store(this.costumes, this.name + '_cst'), serializer.store(this.costumes, this.name + '_cst'),
serializer.store(this.sounds, this.name + '_snd'), 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 // current costume, if it's not in the wardrobe
!costumeIdx && this.costume ? serializer.store(this.costume) : '', !costumeIdx && this.costume ?
'<wear>' + serializer.store(this.costume) + '</wear>'
: '',
noCostumes ? '' : serializer.store(this.costumes, this.name + '_cst'), noCostumes ? '' : serializer.store(this.costumes, this.name + '_cst'),
noSounds ? '' : serializer.store(this.sounds, this.name + '_snd'), noSounds ? '' : serializer.store(this.sounds, this.name + '_snd'),