fixed variable inheritance for traditional Scratch-like clones

upd4.1
Jens Mönig 2017-07-11 08:55:37 +02:00
rodzic b9f1f66ddc
commit dce0f5e871
2 zmienionych plików z 11 dodań i 5 usunięć

Wyświetl plik

@ -3523,6 +3523,7 @@ Fixes:
170711 170711
------ ------
* Objects: fixed an inheritance glitch for clones * Objects: fixed an inheritance glitch for clones
* Objects: fixed variable inheritance for traditional Scratch-like clones

Wyświetl plik

@ -1442,8 +1442,6 @@ SpriteMorph.prototype.fullCopy = function (forClone) {
c.color = this.color.copy(); c.color = this.color.copy();
c.blocksCache = {}; c.blocksCache = {};
c.paletteCache = {}; c.paletteCache = {};
c.variables = this.variables.copy();
c.variables.owner = c;
arr = []; arr = [];
this.inheritedAttributes.forEach(function (att) { this.inheritedAttributes.forEach(function (att) {
arr.push(att); arr.push(att);
@ -1451,6 +1449,11 @@ SpriteMorph.prototype.fullCopy = function (forClone) {
c.inheritedAttributes = arr; c.inheritedAttributes = arr;
if (forClone) { if (forClone) {
c.exemplar = this; c.exemplar = this;
c.variables = new VariableFrame(null, c);
c.variables.parentFrame = this.variables;
c.inheritedVariableNames().forEach(function (name) {
c.shadowVar(name, c.variables.getVar(name));
});
this.addSpecimen(c); this.addSpecimen(c);
this.cachedPropagation = false; this.cachedPropagation = false;
['scripts', 'costumes', 'sounds'].forEach(function (att) { ['scripts', 'costumes', 'sounds'].forEach(function (att) {
@ -1459,6 +1462,8 @@ SpriteMorph.prototype.fullCopy = function (forClone) {
} }
}); });
} else { } else {
c.variables = this.variables.copy();
c.variables.owner = c;
c.scripts = this.scripts.fullCopy(); c.scripts = this.scripts.fullCopy();
c.customBlocks = []; c.customBlocks = [];
this.customBlocks.forEach(function (def) { this.customBlocks.forEach(function (def) {
@ -5255,10 +5260,10 @@ SpriteMorph.prototype.setExemplar = function (another) {
this.emancipate(); this.emancipate();
this.exemplar = another; this.exemplar = another;
if (another) { if (another) {
this.variables.parentFrame = (another.variables); this.variables.parentFrame = another.variables;
another.addSpecimen(this); another.addSpecimen(this);
} else { } else {
this.variables.parentFrame = (this.globalVariables()); this.variables.parentFrame = this.globalVariables();
} }
if (ide) { if (ide) {
ide.flushBlocksCache('variables'); ide.flushBlocksCache('variables');
@ -8910,7 +8915,7 @@ WatcherMorph.prototype.update = function () {
xPosition: 'x position', xPosition: 'x position',
yPosition: 'y position', yPosition: 'y position',
direction: 'direction', direction: 'direction',
getCostumeIdx: 'costume #', //+++ getCostumeIdx: 'costume #',
getScale: 'size'} [this.getter]; getScale: 'size'} [this.getter];
isGhosted = att ? this.target.inheritsAttribute(att) : false; isGhosted = att ? this.target.inheritsAttribute(att) : false;
} }