mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 23:30:09 -05:00
Merge pull request #893 from fsih/nameName
Unique sprite and backdrop names
This commit is contained in:
commit
c6c01e7c93
1 changed files with 4 additions and 2 deletions
|
@ -268,6 +268,8 @@ class VirtualMachine extends EventEmitter {
|
||||||
targets.forEach(target => {
|
targets.forEach(target => {
|
||||||
this.runtime.targets.push(target);
|
this.runtime.targets.push(target);
|
||||||
(/** @type RenderedTarget */ target).updateAllDrawableProperties();
|
(/** @type RenderedTarget */ target).updateAllDrawableProperties();
|
||||||
|
// Ensure unique sprite name
|
||||||
|
if (target.isSprite()) this.renameSprite(target.id, target.getName());
|
||||||
});
|
});
|
||||||
// Select the first target for editing, e.g., the first sprite.
|
// Select the first target for editing, e.g., the first sprite.
|
||||||
if (wholeProject && (targets.length > 1)) {
|
if (wholeProject && (targets.length > 1)) {
|
||||||
|
@ -448,7 +450,7 @@ class VirtualMachine extends EventEmitter {
|
||||||
addBackdrop (md5ext, backdropObject) {
|
addBackdrop (md5ext, backdropObject) {
|
||||||
return loadCostume(md5ext, backdropObject, this.runtime).then(() => {
|
return loadCostume(md5ext, backdropObject, this.runtime).then(() => {
|
||||||
const stage = this.runtime.getTargetForStage();
|
const stage = this.runtime.getTargetForStage();
|
||||||
stage.sprite.costumes.push(backdropObject);
|
stage.addCostume(backdropObject);
|
||||||
stage.setCostume(stage.sprite.costumes.length - 1);
|
stage.setCostume(stage.sprite.costumes.length - 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -629,7 +631,7 @@ class VirtualMachine extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
setEditingTarget (targetId) {
|
setEditingTarget (targetId) {
|
||||||
// Has the target id changed? If not, exit.
|
// Has the target id changed? If not, exit.
|
||||||
if (targetId === this.editingTarget.id) {
|
if (this.editingTarget && targetId === this.editingTarget.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const target = this.runtime.getTargetById(targetId);
|
const target = this.runtime.getTargetById(targetId);
|
||||||
|
|
Loading…
Reference in a new issue