refactored IDE resource naming and removal

pull/95/head
jmoenig 2020-04-30 08:10:20 +02:00
rodzic 4a422b70ac
commit d1caf683e3
1 zmienionych plików z 14 dodań i 20 usunięć

Wyświetl plik

@ -2646,15 +2646,15 @@ IDE_Morph.prototype.instantiateSprite = function (sprite) {
}; };
IDE_Morph.prototype.removeSprite = function (sprite) { IDE_Morph.prototype.removeSprite = function (sprite) {
var idx, myself = this; var idx;
sprite.parts.slice().forEach(function (part) { sprite.parts.slice().forEach(part =>
myself.removeSprite(part); this.removeSprite(part)
}); );
idx = this.sprites.asArray().indexOf(sprite) + 1; idx = this.sprites.asArray().indexOf(sprite) + 1;
this.stage.threads.stopAllForReceiver(sprite); this.stage.threads.stopAllForReceiver(sprite);
sprite.corpsify(); sprite.corpsify();
sprite.destroy(); sprite.destroy();
this.stage.watchers().forEach(function (watcher) { this.stage.watchers().forEach(watcher => {
if (watcher.object() === sprite) { if (watcher.object() === sprite) {
watcher.destroy(); watcher.destroy();
} }
@ -2666,35 +2666,29 @@ IDE_Morph.prototype.removeSprite = function (sprite) {
this.fixLayout(); this.fixLayout();
this.currentSprite = detect( this.currentSprite = detect(
this.stage.children, this.stage.children,
function (morph) { morph => morph instanceof SpriteMorph && !morph.isTemporary
return morph instanceof SpriteMorph && !morph.isTemporary;
}
) || this.stage; ) || this.stage;
this.selectSprite(this.currentSprite); this.selectSprite(this.currentSprite);
}; };
IDE_Morph.prototype.newSoundName = function (name) { IDE_Morph.prototype.newSoundName = function (name) {
var lastSound = var lastSound = this.currentSprite.sounds.at(
this.currentSprite.sounds.at( this.currentSprite.sounds.length()
this.currentSprite.sounds.length()); );
return this.newName( return this.newName(
name || lastSound.name, name || lastSound.name,
this.currentSprite.sounds.asArray().map( this.currentSprite.sounds.asArray().map(eachSound =>
function (eachSound) { eachSound.name
return eachSound.name;
}
) )
); );
}; };
IDE_Morph.prototype.newSpriteName = function (name, ignoredSprite) { IDE_Morph.prototype.newSpriteName = function (name, ignoredSprite) {
var all = this.sprites.asArray().concat(this.stage).filter( var all = this.sprites.asArray().concat(this.stage).filter(each =>
function (each) {return each !== ignoredSprite; } each !== ignoredSprite
).map( ).map(each => each.name);
function (each) {return each.name; }
);
return this.newName(name, all); return this.newName(name, all);
}; };