kopia lustrzana https://github.com/backface/turtlestitch
remember last edited scene in a project
rodzic
1402d8227d
commit
19473e2a2a
|
@ -14,6 +14,7 @@
|
|||
* gui: sceneified toggling dynamic input labels and switching languages
|
||||
* gui: sceneified "zoom blocks"
|
||||
* store: moved sprite-selection attribute from stage to scenes tag
|
||||
* scenes, store, gui: remember last edited scene in a project
|
||||
|
||||
### 2021-04-22
|
||||
* store, gui: first pass at deserializing multi-scene projects
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<script src="src/blocks.js?version=2021-04-12"></script>
|
||||
<script src="src/threads.js?version=2021-04-12"></script>
|
||||
<script src="src/objects.js?version=2021-04-12"></script>
|
||||
<script src="src/scenes.js?version=2021-04-22"></script>
|
||||
<script src="src/scenes.js?version=2021-04-23"></script>
|
||||
<script src="src/gui.js?version=2021-04-23"></script>
|
||||
<script src="src/paint.js?version=2021-03-17"></script>
|
||||
<script src="src/lists.js?version=2021-03-15"></script>
|
||||
|
|
33
src/gui.js
33
src/gui.js
|
@ -2587,12 +2587,16 @@ IDE_Morph.prototype.refreshIDE = function () {
|
|||
|
||||
if (Process.prototype.isCatchingErrors) {
|
||||
try {
|
||||
projectData = this.serializer.serialize(new Project(this.scenes));
|
||||
projectData = this.serializer.serialize(
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
} catch (err) {
|
||||
this.showMessage('Serialization failed: ' + err);
|
||||
}
|
||||
} else {
|
||||
projectData = this.serializer.serialize(new Project(this.scenes));
|
||||
projectData = this.serializer.serialize(
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
}
|
||||
SpriteMorph.prototype.initBlocks();
|
||||
this.buildPanes();
|
||||
|
@ -2786,7 +2790,7 @@ IDE_Morph.prototype.backupAndDo = function (callback) {
|
|||
var username = this.cloud.username;
|
||||
try {
|
||||
localStorage['-snap-backup-'] = this.serializer.serialize(
|
||||
new Project(this.scenes)
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
delete localStorage['-snap-bakflag-'];
|
||||
if (username) {
|
||||
|
@ -4716,7 +4720,9 @@ IDE_Morph.prototype.exportProject = function (name, plain) {
|
|||
dataPrefix = 'data:text/' + plain ? 'plain,' : 'xml,';
|
||||
try {
|
||||
menu = this.showMessage('Exporting');
|
||||
str = this.serializer.serialize(new Project(this.scenes));
|
||||
str = this.serializer.serialize(
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
this.setURL('#open:' + dataPrefix + encodeURIComponent(str));
|
||||
this.saveXMLAs(str, name);
|
||||
menu.destroy();
|
||||
|
@ -5397,7 +5403,10 @@ IDE_Morph.prototype.openProject = function (project) {
|
|||
} else {
|
||||
this.scenes = project.scenes;
|
||||
}
|
||||
this.switchToScene(project.scenes.at(1), true); // refresh album
|
||||
this.switchToScene(
|
||||
project.currentScene || project.scenes.at(1),
|
||||
true // refresh album
|
||||
);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.switchToScene = function (scene, refreshAlbum) {
|
||||
|
@ -6010,13 +6019,15 @@ IDE_Morph.prototype.reflectLanguage = function (lang, callback, noSave) {
|
|||
if (Process.prototype.isCatchingErrors) {
|
||||
try {
|
||||
projectData = this.serializer.serialize(
|
||||
new Project(this.scenes)
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
} catch (err) {
|
||||
this.showMessage('Serialization failed: ' + err);
|
||||
}
|
||||
} else {
|
||||
projectData = this.serializer.serialize(new Project(this.scenes));
|
||||
projectData = this.serializer.serialize(
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
}
|
||||
}
|
||||
SpriteMorph.prototype.initBlocks();
|
||||
|
@ -6119,12 +6130,16 @@ IDE_Morph.prototype.setBlocksScale = function (num) {
|
|||
var projectData;
|
||||
if (Process.prototype.isCatchingErrors) {
|
||||
try {
|
||||
projectData = this.serializer.serialize(new Project(this.scenes));
|
||||
projectData = this.serializer.serialize(
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
} catch (err) {
|
||||
this.showMessage('Serialization failed: ' + err);
|
||||
}
|
||||
} else {
|
||||
projectData = this.serializer.serialize(new Project(this.scenes));
|
||||
projectData = this.serializer.serialize(
|
||||
new Project(this.scenes, this.scene)
|
||||
);
|
||||
}
|
||||
SyntaxElementMorph.prototype.setScale(num);
|
||||
CommentMorph.prototype.refreshScale();
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
/*global modules, VariableFrame, StageMorph, SpriteMorph, Process, List*/
|
||||
|
||||
modules.scenes = '2021-April-22';
|
||||
modules.scenes = '2021-April-23';
|
||||
|
||||
|
||||
// Projecct /////////////////////////////////////////////////////////
|
||||
|
@ -60,16 +60,27 @@ modules.scenes = '2021-April-22';
|
|||
|
||||
// Project instance creation:
|
||||
|
||||
function Project(scenes) {
|
||||
function Project(scenes, current) {
|
||||
this.name = 'Test';
|
||||
this.notes = 'some notes';
|
||||
this.thumbnail = null;
|
||||
this.scenes = scenes || new List();
|
||||
this.currentScene = current;
|
||||
|
||||
// for deserializing - do not persist
|
||||
this.sceneIdx = null;
|
||||
|
||||
// for undeleting scenes - do not persist
|
||||
this.trash = [];
|
||||
}
|
||||
|
||||
Project.prototype.initialize = function () {
|
||||
// initialize after deserializing
|
||||
// only to be called by store
|
||||
this.currentScene = this.scenes.at(+this.sceneIdx || 1);
|
||||
return this;
|
||||
};
|
||||
|
||||
Project.prototype.addDefaultScene = function () {
|
||||
var scene = new Scene();
|
||||
scene.addDefaultSprite();
|
||||
|
|
|
@ -334,13 +334,16 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide, remixID) {
|
|||
);
|
||||
}
|
||||
if (scenesModel) {
|
||||
if (scenesModel.attributes.select) {
|
||||
project.sceneIdx = +scenesModel.attributes.select;
|
||||
}
|
||||
scenesModel.childrenNamed('scene').forEach(model =>
|
||||
project.scenes.add(this.loadScene(model))
|
||||
);
|
||||
} else {
|
||||
project.scenes.add(this.loadScene(xmlNode, remixID));
|
||||
}
|
||||
return project;
|
||||
return project.initialize();
|
||||
};
|
||||
|
||||
SnapSerializer.prototype.loadScene = function (xmlNode, remixID) {
|
||||
|
@ -1652,13 +1655,15 @@ Project.prototype.toXML = function (serializer) {
|
|||
'<project name="@" app="@" version="@">' +
|
||||
'<notes>$</notes>' +
|
||||
'<thumbnail>$</thumbnail>' +
|
||||
'<scenes>%</scenes>' +
|
||||
'<scenes select="@">%</scenes>' +
|
||||
'</project>',
|
||||
this.name || localize('Untitled'),
|
||||
serializer.app,
|
||||
serializer.version,
|
||||
this.notes || '',
|
||||
thumbdata,
|
||||
this.scenes.asArray().indexOf(
|
||||
this.currentScene) + 1,
|
||||
serializer.store(this.scenes.itemsArray())
|
||||
);
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue