kopia lustrzana https://github.com/backface/turtlestitch
capture global settings in scenes
rodzic
a987b4773b
commit
f4aa21a2a6
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
## in development:
|
## in development:
|
||||||
|
|
||||||
|
### 2021-03-19
|
||||||
|
* gui, store, scenes: capture global settings in scenes
|
||||||
|
|
||||||
## 6.7.3
|
## 6.7.3
|
||||||
* **Notable Changes:**
|
* **Notable Changes:**
|
||||||
* hyperized "key _ pressed?" predicate
|
* hyperized "key _ pressed?" predicate
|
||||||
|
|
17
src/gui.js
17
src/gui.js
|
@ -5316,6 +5316,7 @@ IDE_Morph.prototype.switchToScene = function (scene) {
|
||||||
this.siblings().forEach(morph =>
|
this.siblings().forEach(morph =>
|
||||||
morph.destroy()
|
morph.destroy()
|
||||||
);
|
);
|
||||||
|
this.scene.captureGlobalSettings();
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.projectName = scene.name;
|
this.projectName = scene.name;
|
||||||
this.projectNotes = scene.notes || '';
|
this.projectNotes = scene.notes || '';
|
||||||
|
@ -5332,21 +5333,9 @@ IDE_Morph.prototype.switchToScene = function (scene) {
|
||||||
this.createCorral();
|
this.createCorral();
|
||||||
this.selectSprite(sprites[0] || this.stage);
|
this.selectSprite(sprites[0] || this.stage);
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
|
scene.applyGlobalSettings();
|
||||||
// +++ to do: de-globablize settings:
|
|
||||||
StageMorph.prototype.hiddenPrimitives = {};
|
|
||||||
StageMorph.prototype.codeMappings = {};
|
|
||||||
StageMorph.prototype.codeHeaders = {};
|
|
||||||
StageMorph.prototype.enableCodeMapping = false;
|
|
||||||
StageMorph.prototype.enableInheritance = true;
|
|
||||||
StageMorph.prototype.enableSublistIDs = false;
|
|
||||||
StageMorph.prototype.enablePenLogging = false;
|
|
||||||
SpriteMorph.prototype.useFlatLineEnds = false;
|
|
||||||
Process.prototype.enableLiveCoding = false;
|
|
||||||
Process.prototype.enableHyperOps = true;
|
|
||||||
this.hasUnsavedEdits = false;
|
this.hasUnsavedEdits = false;
|
||||||
this.trash = [];
|
this.trash = []; // +++ sceneify
|
||||||
|
|
||||||
this.world().keyboardFocus = this.stage;
|
this.world().keyboardFocus = this.stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*global modules, VariableFrame, StageMorph, SpriteMorph*/
|
/*global modules, VariableFrame, StageMorph, SpriteMorph, Process*/
|
||||||
|
|
||||||
modules.scenes = '2021-March-18';
|
modules.scenes = '2021-March-19';
|
||||||
|
|
||||||
// Scene /////////////////////////////////////////////////////////
|
// Scene /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -67,6 +67,20 @@ function Scene(aStageMorph) {
|
||||||
aStageMorph.globalVariables() : new VariableFrame();
|
aStageMorph.globalVariables() : new VariableFrame();
|
||||||
this.stage = aStageMorph || new StageMorph(this.globalVariables);
|
this.stage = aStageMorph || new StageMorph(this.globalVariables);
|
||||||
|
|
||||||
|
// global settings (shared)
|
||||||
|
this.hiddenPrimitives = {};
|
||||||
|
this.codeMappings = {};
|
||||||
|
this.codeHeaders = {};
|
||||||
|
|
||||||
|
// global settings (copied)
|
||||||
|
this.enableCodeMapping = false;
|
||||||
|
this.enableInheritance = true;
|
||||||
|
this.enableSublistIDs = false;
|
||||||
|
this.enablePenLogging = false;
|
||||||
|
this.useFlatLineEnds = false;
|
||||||
|
this.enableLiveCoding = false;
|
||||||
|
this.enableHyperOps = true;
|
||||||
|
|
||||||
// for deserializing - do not persist
|
// for deserializing - do not persist
|
||||||
this.sprites = {};
|
this.sprites = {};
|
||||||
this.targetStage = null;
|
this.targetStage = null;
|
||||||
|
@ -82,3 +96,29 @@ Scene.prototype.addDefaultSprite = function () {
|
||||||
this.stage.add(sprite);
|
this.stage.add(sprite);
|
||||||
return sprite;
|
return sprite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Scene.prototype.captureGlobalSettings = function () {
|
||||||
|
this.hiddenPrimitives = StageMorph.prototype.hiddenPrimitives;
|
||||||
|
this.codeMappings = StageMorph.prototype.codeMappings;
|
||||||
|
this.codeHeaders = StageMorph.prototype.codeHeaders;
|
||||||
|
this.enableCodeMapping = StageMorph.prototype.enableCodeMapping;
|
||||||
|
this.enableInheritance = StageMorph.prototype.enableInheritance;
|
||||||
|
this.enableSublistIDs = StageMorph.prototype.enableSublistIDs;
|
||||||
|
this.enablePenLogging = StageMorph.prototype.enablePenLogging;
|
||||||
|
this.useFlatLineEnds = SpriteMorph.prototype.useFlatLineEnds;
|
||||||
|
this.enableLiveCoding = Process.prototype.enableLiveCoding;
|
||||||
|
this.enableHyperOps = Process.prototype.enableHyperOps;
|
||||||
|
};
|
||||||
|
|
||||||
|
Scene.prototype.applyGlobalSettings = function () {
|
||||||
|
StageMorph.prototype.hiddenPrimitives = this.hiddenPrimitives;
|
||||||
|
StageMorph.prototype.codeMappings = this.codeMappings;
|
||||||
|
StageMorph.prototype.codeHeaders = this.codeHeaders;
|
||||||
|
StageMorph.prototype.enableCodeMapping = this.enableCodeMapping;
|
||||||
|
StageMorph.prototype.enableInheritance = this.enableInheritance;
|
||||||
|
StageMorph.prototype.enableSublistIDs = this.enableSublistIDs;
|
||||||
|
StageMorph.prototype.enablePenLogging = this.enablePenLogging;
|
||||||
|
SpriteMorph.prototype.useFlatLineEnds = this.useFlatLineEnds;
|
||||||
|
Process.prototype.enableLiveCoding = this.enableLiveCoding;
|
||||||
|
Process.prototype.enableHyperOps = this.enableHyperOps;
|
||||||
|
};
|
||||||
|
|
20
src/store.js
20
src/store.js
|
@ -60,7 +60,7 @@ SyntaxElementMorph, BooleanSlotMorph, normalizeCanvas, contains, Scene*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.store = '2021-March-17';
|
modules.store = '2021-March-19';
|
||||||
|
|
||||||
|
|
||||||
// XML_Serializer ///////////////////////////////////////////////////////
|
// XML_Serializer ///////////////////////////////////////////////////////
|
||||||
|
@ -393,7 +393,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) {
|
||||||
project.stage.pan = +model.stage.attributes.pan;
|
project.stage.pan = +model.stage.attributes.pan;
|
||||||
}
|
}
|
||||||
if (model.stage.attributes.penlog) {
|
if (model.stage.attributes.penlog) {
|
||||||
StageMorph.prototype.enablePenLogging =
|
project.enablePenLogging =
|
||||||
(model.stage.attributes.penlog === 'true');
|
(model.stage.attributes.penlog === 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,19 +420,19 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) {
|
||||||
Math.max(+model.stage.attributes.height, 180);
|
Math.max(+model.stage.attributes.height, 180);
|
||||||
}
|
}
|
||||||
project.stage.setExtent(project.stage.dimensions);
|
project.stage.setExtent(project.stage.dimensions);
|
||||||
SpriteMorph.prototype.useFlatLineEnds =
|
project.useFlatLineEnds =
|
||||||
model.stage.attributes.lines === 'flat';
|
model.stage.attributes.lines === 'flat';
|
||||||
BooleanSlotMorph.prototype.isTernary =
|
BooleanSlotMorph.prototype.isTernary =
|
||||||
model.stage.attributes.ternary !== 'false';
|
model.stage.attributes.ternary !== 'false';
|
||||||
Process.prototype.enableHyperOps =
|
project.enableHyperOps =
|
||||||
model.stage.attributes.hyperops !== 'false';
|
model.stage.attributes.hyperops !== 'false';
|
||||||
project.stage.isThreadSafe =
|
project.stage.isThreadSafe =
|
||||||
model.stage.attributes.threadsafe === 'true';
|
model.stage.attributes.threadsafe === 'true';
|
||||||
StageMorph.prototype.enableCodeMapping =
|
project.enableCodeMapping =
|
||||||
model.stage.attributes.codify === 'true';
|
model.stage.attributes.codify === 'true';
|
||||||
StageMorph.prototype.enableInheritance =
|
project.enableInheritance =
|
||||||
model.stage.attributes.inheritance !== 'false';
|
model.stage.attributes.inheritance !== 'false';
|
||||||
StageMorph.prototype.enableSublistIDs =
|
project.enableSublistIDs =
|
||||||
model.stage.attributes.sublistIDs === 'true';
|
model.stage.attributes.sublistIDs === 'true';
|
||||||
|
|
||||||
model.hiddenPrimitives = model.project.childNamed('hidden');
|
model.hiddenPrimitives = model.project.childNamed('hidden');
|
||||||
|
@ -440,7 +440,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) {
|
||||||
model.hiddenPrimitives.contents.split(' ').forEach(
|
model.hiddenPrimitives.contents.split(' ').forEach(
|
||||||
sel => {
|
sel => {
|
||||||
if (sel) {
|
if (sel) {
|
||||||
StageMorph.prototype.hiddenPrimitives[sel] = true;
|
project.hiddenPrimitives[sel] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -449,14 +449,14 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) {
|
||||||
model.codeHeaders = model.project.childNamed('headers');
|
model.codeHeaders = model.project.childNamed('headers');
|
||||||
if (model.codeHeaders) {
|
if (model.codeHeaders) {
|
||||||
model.codeHeaders.children.forEach(
|
model.codeHeaders.children.forEach(
|
||||||
xml => StageMorph.prototype.codeHeaders[xml.tag] = xml.contents
|
xml => project.codeHeaders[xml.tag] = xml.contents
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
model.codeMappings = model.project.childNamed('code');
|
model.codeMappings = model.project.childNamed('code');
|
||||||
if (model.codeMappings) {
|
if (model.codeMappings) {
|
||||||
model.codeMappings.children.forEach(
|
model.codeMappings.children.forEach(
|
||||||
xml => StageMorph.prototype.codeMappings[xml.tag] = xml.contents
|
xml => project.codeMappings[xml.tag] = xml.contents
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue