ensured unique scene names

snap7
jmoenig 2021-05-18 16:24:09 +02:00
rodzic 33ff73aebd
commit 63d4932747
2 zmienionych plików z 14 dodań i 4 usunięć

Wyświetl plik

@ -12,7 +12,8 @@
* gui: fixed exporting media only for a single scene
* gui: fixed cloud file format components
* gui: "projectized" cloud file format for a single scene
* gui: fixed cloud file format for multi-scene projects
* gui: fixed cloud file format for multi-scene projects
* gui: ensured unique scene names
### 2021-05-11
* gui: add multi-scene projects

Wyświetl plik

@ -3212,6 +3212,13 @@ IDE_Morph.prototype.newSpriteName = function (name, ignoredSprite) {
return this.newName(name, all);
};
IDE_Morph.prototype.newSceneName = function (name, ignoredScene) {
var all = this.scenes.asArray().filter(each =>
each !== ignoredScene
).map(each => each.name);
return this.newName(name, all);
};
IDE_Morph.prototype.newName = function (name, elements) {
var ix = name.indexOf('('),
stem = (ix < 0) ? name : name.substring(0, ix),
@ -5445,7 +5452,10 @@ IDE_Morph.prototype.openProjectName = function (name) {
IDE_Morph.prototype.openProject = function (project) {
if (this.isAddingScenes) {
project.scenes.itemsArray().forEach(scene => this.scenes.add(scene));
project.scenes.itemsArray().forEach(scene => {
scene.name = this.newSceneName(scene.name, scene);
this.scenes.add(scene);
});
} else {
this.scenes = project.scenes;
}
@ -10371,13 +10381,12 @@ SceneIconMorph.prototype.userMenu = function () {
SceneIconMorph.prototype.renameScene = function () {
var scene = this.object,
album = this.parentThatIsA(SceneAlbumMorph),
ide = this.parentThatIsA(IDE_Morph);
new DialogBoxMorph(
null,
answer => {
if (answer && (answer !== scene.name)) {
scene.name = album.scene.newSceneName(
scene.name = ide.newSceneName(
answer,
scene
);