run “When I start as clone” scripts when manually cloning a sprite

only position clone at hand pointer if no such scripts exist
upd4.1
Jens Mönig 2017-07-07 12:28:14 +02:00
rodzic 7f5a0b8272
commit 5efc59acab
3 zmienionych plików z 22 dodań i 4 usunięć

11
gui.js
Wyświetl plik

@ -2147,10 +2147,15 @@ IDE_Morph.prototype.duplicateSprite = function (sprite) {
};
IDE_Morph.prototype.instantiateSprite = function (sprite) {
var instance = sprite.fullCopy(true);
instance.setPosition(this.world().hand.position());
var instance = sprite.fullCopy(true),
hats = instance.allHatBlocksFor('__clone__init__');
instance.appearIn(this);
instance.keepWithin(this.stage);
if (hats.length) {
instance.initClone(hats);
} else {
instance.setPosition(this.world().hand.position());
instance.keepWithin(this.stage);
}
this.selectSprite(instance);
};

Wyświetl plik

@ -3508,6 +3508,7 @@ Fixes:
170707
------
* Objects, GUI, Store: tweak naming of instantiating to “clone”, enable inheritance by default
* Objects, GUI: run “When I start as clone” scripts when manually cloning a sprite, only position at hand pointer if no such scripts exist
Features:

Wyświetl plik

@ -3207,11 +3207,23 @@ SpriteMorph.prototype.clonify = function (stage, immediately) {
null, // callback
null, // is clicked
immediately // without yielding
);
);
});
this.endWarp();
};
SpriteMorph.prototype.initClone = function (hats) {
// used when manually instantiating a sprite in the IDE
var stage = this.parentThatIsA(StageMorph),
myself = this;
if (stage) {
hats.forEach(function (block) {
stage.threads.startProcess(block, myself, stage.isThreadSafe);
});
this.endWarp();
}
};
SpriteMorph.prototype.removeClone = function () {
if (this.isTemporary) {
// this.stopTalking();