summaryrefslogtreecommitdiff
path: root/store.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-03-24 18:29:54 +0100
committerGubolin <gubolin@fantasymail.de>2015-03-24 18:29:54 +0100
commitbdd780e0030507626c947f85880a9eaa36e24194 (patch)
tree070a36fee08b43b5e231b2a1e8e5fe28314a7cb8 /store.js
parentc8de6a00e38e52bfc4b9b3a095cbcad1861687de (diff)
parent457224dd620eea4f20f24ebc62391363333cd00f (diff)
downloadsnap-bdd780e0030507626c947f85880a9eaa36e24194.tar.gz
snap-bdd780e0030507626c947f85880a9eaa36e24194.zip
merge branch OOP
Diffstat (limited to 'store.js')
-rw-r--r--store.js49
1 files changed, 42 insertions, 7 deletions
diff --git a/store.js b/store.js
index 4428a72..4fe8fb0 100644
--- a/store.js
+++ b/store.js
@@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/
// Global stuff ////////////////////////////////////////////////////////
-modules.store = '2015-March-15';
+modules.store = '2015-March-24';
// XML_Serializer ///////////////////////////////////////////////////////
@@ -459,9 +459,17 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
myself.loadValue(model);
});
- // restore nesting associations
+ // restore inheritance and nesting associations
myself.project.stage.children.forEach(function (sprite) {
- var anchor;
+ var exemplar, anchor;
+ if (sprite.inheritanceInfo) { // only sprites can inherit
+ exemplar = myself.project.sprites[
+ sprite.inheritanceInfo.exemplar
+ ];
+ if (exemplar) {
+ sprite.setExemplar(exemplar);
+ }
+ }
if (sprite.nestingInfo) { // only sprites may have nesting info
anchor = myself.project.sprites[sprite.nestingInfo.anchor];
if (anchor) {
@@ -471,6 +479,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
}
});
myself.project.stage.children.forEach(function (sprite) {
+ delete sprite.inheritanceInfo;
if (sprite.nestingInfo) { // only sprites may have nesting info
sprite.nestingScale = +(sprite.nestingInfo.scale || sprite.scale);
delete sprite.nestingInfo;
@@ -531,8 +540,8 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
}
watcher.setStyle(model.attributes.style || 'normal');
if (watcher.style === 'slider') {
- watcher.setSliderMin(model.attributes.min || '1');
- watcher.setSliderMax(model.attributes.max || '100');
+ watcher.setSliderMin(model.attributes.min || '1', true);
+ watcher.setSliderMax(model.attributes.max || '100', true);
}
watcher.setPosition(
project.stage.topLeft().add(new Point(
@@ -639,9 +648,17 @@ SnapSerializer.prototype.loadSprites = function (xmlString, ide) {
myself.loadObject(sprite, model);
});
- // restore nesting associations
+ // restore inheritance and nesting associations
project.stage.children.forEach(function (sprite) {
- var anchor;
+ var exemplar, anchor;
+ if (sprite.inheritanceInfo) { // only sprites can inherit
+ exemplar = project.sprites[
+ sprite.inheritanceInfo.exemplar
+ ];
+ if (exemplar) {
+ sprite.setExemplar(exemplar);
+ }
+ }
if (sprite.nestingInfo) { // only sprites may have nesting info
anchor = project.sprites[sprite.nestingInfo.anchor];
if (anchor) {
@@ -651,6 +668,7 @@ SnapSerializer.prototype.loadSprites = function (xmlString, ide) {
}
});
project.stage.children.forEach(function (sprite) {
+ delete sprite.inheritanceInfo;
if (sprite.nestingInfo) { // only sprites may have nesting info
sprite.nestingScale = +(sprite.nestingInfo.scale || sprite.scale);
delete sprite.nestingInfo;
@@ -690,6 +708,7 @@ SnapSerializer.prototype.loadMediaModel = function (xmlNode) {
SnapSerializer.prototype.loadObject = function (object, model) {
// private
var blocks = model.require('blocks');
+ this.loadInheritanceInfo(object, model);
this.loadNestingInfo(object, model);
this.loadCostumes(object, model);
this.loadSounds(object, model);
@@ -699,6 +718,14 @@ SnapSerializer.prototype.loadObject = function (object, model) {
this.loadScripts(object.scripts, model.require('scripts'));
};
+SnapSerializer.prototype.loadInheritanceInfo = function (object, model) {
+ // private
+ var info = model.childNamed('inherit');
+ if (info) {
+ object.inheritanceInfo = info.attributes;
+ }
+};
+
SnapSerializer.prototype.loadNestingInfo = function (object, model) {
// private
var info = model.childNamed('nest');
@@ -1467,6 +1494,7 @@ SpriteMorph.prototype.toXML = function (serializer) {
' draggable="@"' +
'%' +
' costume="@" color="@,@,@" pen="@" ~>' +
+ '%' + // inheritance info
'%' + // nesting info
'<costumes>%</costumes>' +
'<sounds>%</sounds>' +
@@ -1489,6 +1517,13 @@ SpriteMorph.prototype.toXML = function (serializer) {
this.color.b,
this.penPoint,
+ // inheritance info
+ this.exemplar
+ ? '<inherit exemplar="' +
+ this.exemplar.name
+ + '"/>'
+ : '',
+
// nesting info
this.anchor
? '<nest anchor="' +