kopia lustrzana https://github.com/backface/turtlestitch
more scene-refactorings
rodzic
05e85b1bc7
commit
87b8b24713
|
@ -6,6 +6,9 @@
|
||||||
* repeat stops when encountering a non-numerical counter input, thanks, Stefan!
|
* repeat stops when encountering a non-numerical counter input, thanks, Stefan!
|
||||||
* updated list-utilities library, thanks, Brian!
|
* updated list-utilities library, thanks, Brian!
|
||||||
|
|
||||||
|
### 2021-03-18
|
||||||
|
* gui, scenes, objects: more scene-refactorings
|
||||||
|
|
||||||
### 2021-03-17
|
### 2021-03-17
|
||||||
* objects, gui, paint, sketch, store: de-globalized stage dimensions
|
* objects, gui, paint, sketch, store: de-globalized stage dimensions
|
||||||
* new dev version
|
* new dev version
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
<script src="src/widgets.js?version=2021-01-05"></script>
|
<script src="src/widgets.js?version=2021-01-05"></script>
|
||||||
<script src="src/blocks.js?version=2021-02-27"></script>
|
<script src="src/blocks.js?version=2021-02-27"></script>
|
||||||
<script src="src/threads.js?version=2021-03-17"></script>
|
<script src="src/threads.js?version=2021-03-17"></script>
|
||||||
<script src="src/objects.js?version=2021-03-17"></script>
|
<script src="src/objects.js?version=2021-03-18"></script>
|
||||||
<script src="src/scenes.js?version=2021-03-17"></script>
|
<script src="src/scenes.js?version=2021-03-18"></script>
|
||||||
<script src="src/gui.js?version=2021-03-17"></script>
|
<script src="src/gui.js?version=2021-03-18"></script>
|
||||||
<script src="src/paint.js?version=2021-03-17"></script>
|
<script src="src/paint.js?version=2021-03-17"></script>
|
||||||
<script src="src/lists.js?version=2021-03-15"></script>
|
<script src="src/lists.js?version=2021-03-15"></script>
|
||||||
<script src="src/byob.js?version=2021-03-05"></script>
|
<script src="src/byob.js?version=2021-03-05"></script>
|
||||||
|
|
110
src/gui.js
110
src/gui.js
|
@ -62,7 +62,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud, Audio,
|
/*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud, Audio,
|
||||||
ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, VariableFrame, Sound,
|
ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, Sound, Scene,
|
||||||
StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph, normalizeCanvas,
|
StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph, normalizeCanvas,
|
||||||
ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, sb,
|
ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, sb,
|
||||||
InputFieldMorph, FrameMorph, Process, nop, SnapSerializer, ListMorph, detect,
|
InputFieldMorph, FrameMorph, Process, nop, SnapSerializer, ListMorph, detect,
|
||||||
|
@ -74,12 +74,11 @@ CommandBlockMorph, BooleanSlotMorph, RingReporterSlotMorph, ScriptFocusMorph,
|
||||||
BlockLabelPlaceHolderMorph, SpeechBubbleMorph, XML_Element, WatcherMorph, WHITE,
|
BlockLabelPlaceHolderMorph, SpeechBubbleMorph, XML_Element, WatcherMorph, WHITE,
|
||||||
BlockRemovalDialogMorph,TableMorph, isSnapObject, isRetinaEnabled, SliderMorph,
|
BlockRemovalDialogMorph,TableMorph, isSnapObject, isRetinaEnabled, SliderMorph,
|
||||||
disableRetinaSupport, enableRetinaSupport, isRetinaSupported, MediaRecorder,
|
disableRetinaSupport, enableRetinaSupport, isRetinaSupported, MediaRecorder,
|
||||||
Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK,
|
Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/
|
||||||
Scene*/
|
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.gui = '2021-March-17';
|
modules.gui = '2021-March-18';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -213,7 +212,7 @@ function IDE_Morph(isAutoFill) {
|
||||||
this.init(isAutoFill);
|
this.init(isAutoFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDE_Morph.prototype.init = function (isAutoFill) {
|
IDE_Morph.prototype.init = function (isAutoFill) { // +++
|
||||||
// global font setting
|
// global font setting
|
||||||
MorphicPreferences.globalFontFamily = 'Helvetica, Arial';
|
MorphicPreferences.globalFontFamily = 'Helvetica, Arial';
|
||||||
|
|
||||||
|
@ -230,12 +229,12 @@ IDE_Morph.prototype.init = function (isAutoFill) {
|
||||||
|
|
||||||
this.scene = new Scene();
|
this.scene = new Scene();
|
||||||
this.globalVariables = this.scene.globalVariables;
|
this.globalVariables = this.scene.globalVariables;
|
||||||
this.currentSprite = new SpriteMorph(this.globalVariables);
|
this.currentSprite = this.scene.addDefaultSprite();
|
||||||
this.sprites = new List([this.currentSprite]);
|
this.sprites = new List([this.currentSprite]);
|
||||||
|
this.projectName = this.scene.name;
|
||||||
|
this.projectNotes = this.scene.notes;
|
||||||
this.currentCategory = 'motion';
|
this.currentCategory = 'motion';
|
||||||
this.currentTab = 'scripts';
|
this.currentTab = 'scripts';
|
||||||
this.projectName = '';
|
|
||||||
this.projectNotes = '';
|
|
||||||
|
|
||||||
this.trash = []; // deleted sprites
|
this.trash = []; // deleted sprites
|
||||||
|
|
||||||
|
@ -1377,20 +1376,11 @@ IDE_Morph.prototype.createPaletteHandle = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.createStage = function () {
|
IDE_Morph.prototype.createStage = function () {
|
||||||
// assumes that the logo pane has already been created
|
if (this.stage) {
|
||||||
if (this.stage) {this.stage.destroy(); }
|
this.stage.destroy();
|
||||||
StageMorph.prototype.frameRate = 0;
|
|
||||||
this.stage = new StageMorph(this.globalVariables);
|
|
||||||
this.stage.setExtent(this.stage.dimensions); // dimensions are fixed
|
|
||||||
if (this.currentSprite instanceof SpriteMorph) {
|
|
||||||
this.currentSprite.setPosition(
|
|
||||||
this.stage.center().subtract(
|
|
||||||
this.currentSprite.extent().divideBy(2)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
this.stage.add(this.currentSprite);
|
|
||||||
}
|
}
|
||||||
this.add(this.stage);
|
this.add(this.scene.stage);
|
||||||
|
this.stage = this.scene.stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.createStageHandle = function () {
|
IDE_Morph.prototype.createStageHandle = function () {
|
||||||
|
@ -2820,7 +2810,7 @@ IDE_Morph.prototype.restore = function () {
|
||||||
|
|
||||||
// IDE_Morph sprite list access
|
// IDE_Morph sprite list access
|
||||||
|
|
||||||
IDE_Morph.prototype.addNewSprite = function () {
|
IDE_Morph.prototype.addNewSprite = function () { // +++ sceneify
|
||||||
var sprite = new SpriteMorph(this.globalVariables),
|
var sprite = new SpriteMorph(this.globalVariables),
|
||||||
rnd = Process.prototype.reportBasicRandom;
|
rnd = Process.prototype.reportBasicRandom;
|
||||||
|
|
||||||
|
@ -2847,7 +2837,7 @@ IDE_Morph.prototype.addNewSprite = function () {
|
||||||
this.selectSprite(sprite);
|
this.selectSprite(sprite);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.paintNewSprite = function () {
|
IDE_Morph.prototype.paintNewSprite = function () { // +++ sceneify
|
||||||
var sprite = new SpriteMorph(this.globalVariables),
|
var sprite = new SpriteMorph(this.globalVariables),
|
||||||
cos = new Costume();
|
cos = new Costume();
|
||||||
|
|
||||||
|
@ -2870,7 +2860,7 @@ IDE_Morph.prototype.paintNewSprite = function () {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.newCamSprite = function () {
|
IDE_Morph.prototype.newCamSprite = function () { // +++ sceneify
|
||||||
var sprite = new SpriteMorph(this.globalVariables),
|
var sprite = new SpriteMorph(this.globalVariables),
|
||||||
camDialog;
|
camDialog;
|
||||||
|
|
||||||
|
@ -4588,6 +4578,9 @@ IDE_Morph.prototype.editProjectNotes = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.newProject = function () { // +++
|
IDE_Morph.prototype.newProject = function () { // +++
|
||||||
|
var scene = new Scene();
|
||||||
|
|
||||||
|
scene.addDefaultSprite();
|
||||||
this.source = this.cloud.username ? 'cloud' : null;
|
this.source = this.cloud.username ? 'cloud' : null;
|
||||||
if (this.stage) {
|
if (this.stage) {
|
||||||
this.stage.destroy();
|
this.stage.destroy();
|
||||||
|
@ -4595,32 +4588,7 @@ IDE_Morph.prototype.newProject = function () { // +++
|
||||||
if (location.hash.substr(0, 6) !== '#lang:') {
|
if (location.hash.substr(0, 6) !== '#lang:') {
|
||||||
location.hash = '';
|
location.hash = '';
|
||||||
}
|
}
|
||||||
// +++ this.switchToScene(new Scene());
|
this.switchToScene(scene);
|
||||||
|
|
||||||
|
|
||||||
this.globalVariables = new VariableFrame();
|
|
||||||
this.currentSprite = new SpriteMorph(this.globalVariables);
|
|
||||||
this.sprites = new List([this.currentSprite]);
|
|
||||||
// +++ StageMorph.prototype.dimensions = new Point(480, 360);
|
|
||||||
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.setProjectName('');
|
|
||||||
this.projectNotes = '';
|
|
||||||
this.trash = [];
|
|
||||||
this.createStage();
|
|
||||||
this.add(this.stage);
|
|
||||||
this.createCorral();
|
|
||||||
this.selectSprite(this.stage.children[0]);
|
|
||||||
this.fixLayout();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.save = function () {
|
IDE_Morph.prototype.save = function () {
|
||||||
|
@ -5091,19 +5059,9 @@ IDE_Morph.prototype.openProjectString = function (str, callback) {
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.rawOpenProjectString = function (str) { // +++
|
IDE_Morph.prototype.rawOpenProjectString = function (str) {
|
||||||
this.toggleAppMode(false);
|
this.toggleAppMode(false);
|
||||||
this.spriteBar.tabBar.tabTo('scripts');
|
this.spriteBar.tabBar.tabTo('scripts');
|
||||||
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;
|
|
||||||
Process.prototype.enableLiveCoding = false;
|
|
||||||
this.trash = [];
|
|
||||||
this.hasUnsavedEdits = false;
|
|
||||||
if (Process.prototype.isCatchingErrors) {
|
if (Process.prototype.isCatchingErrors) {
|
||||||
try {
|
try {
|
||||||
this.switchToScene(
|
this.switchToScene(
|
||||||
|
@ -5132,18 +5090,9 @@ IDE_Morph.prototype.openCloudDataString = function (str) {
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.rawOpenCloudDataString = function (str) { // +++
|
IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
|
||||||
var model;
|
var model;
|
||||||
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;
|
|
||||||
Process.prototype.enableLiveCoding = false;
|
|
||||||
this.trash = [];
|
|
||||||
this.hasUnsavedEdits = false;
|
|
||||||
if (Process.prototype.isCatchingErrors) {
|
if (Process.prototype.isCatchingErrors) {
|
||||||
try {
|
try {
|
||||||
model = this.serializer.parse(str);
|
model = this.serializer.parse(str);
|
||||||
|
@ -5359,7 +5308,7 @@ IDE_Morph.prototype.openProject = function (name) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.switchToScene = function (scene) { // +++
|
IDE_Morph.prototype.switchToScene = function (scene) {
|
||||||
var sprites = [];
|
var sprites = [];
|
||||||
if (!scene || !scene.stage) {
|
if (!scene || !scene.stage) {
|
||||||
return;
|
return;
|
||||||
|
@ -5383,6 +5332,21 @@ 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();
|
||||||
|
|
||||||
|
// +++ 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.trash = [];
|
||||||
|
|
||||||
this.world().keyboardFocus = this.stage;
|
this.world().keyboardFocus = this.stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
||||||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||||
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||||
|
|
||||||
modules.objects = '2021-March-17';
|
modules.objects = '2021-March-18';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -7776,6 +7776,7 @@ StageMorph.prototype.init = function (globals) {
|
||||||
|
|
||||||
StageMorph.uber.init.call(this);
|
StageMorph.uber.init.call(this);
|
||||||
|
|
||||||
|
this.setExtent(this.dimensions);
|
||||||
this.isCachingImage = true;
|
this.isCachingImage = true;
|
||||||
this.cachedHSV = this.color.hsv();
|
this.cachedHSV = this.color.hsv();
|
||||||
this.acceptsDrops = false;
|
this.acceptsDrops = false;
|
||||||
|
|
|
@ -47,9 +47,9 @@
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*global modules, VariableFrame, aStageMorph*/
|
/*global modules, VariableFrame, StageMorph, SpriteMorph*/
|
||||||
|
|
||||||
modules.scenes = '2021-March-12';
|
modules.scenes = '2021-March-18';
|
||||||
|
|
||||||
// Scene /////////////////////////////////////////////////////////
|
// Scene /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ modules.scenes = '2021-March-12';
|
||||||
// Scene instance creation:
|
// Scene instance creation:
|
||||||
|
|
||||||
function Scene(aStageMorph) {
|
function Scene(aStageMorph) {
|
||||||
this.name = null;
|
this.name = '';
|
||||||
this.notes = null;
|
this.notes = '';
|
||||||
this.globalVariables = aStageMorph ?
|
this.globalVariables = aStageMorph ?
|
||||||
aStageMorph.globalVariables() : new VariableFrame();
|
aStageMorph.globalVariables() : new VariableFrame();
|
||||||
this.stage = aStageMorph || new StageMorph(this.globalVariables);
|
this.stage = aStageMorph || new StageMorph(this.globalVariables);
|
||||||
|
@ -71,3 +71,14 @@ function Scene(aStageMorph) {
|
||||||
this.sprites = {};
|
this.sprites = {};
|
||||||
this.targetStage = null;
|
this.targetStage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scene.prototype.addDefaultSprite = function () {
|
||||||
|
var sprite = new SpriteMorph(this.globalVariables);
|
||||||
|
sprite.setPosition(
|
||||||
|
this.stage.center().subtract(
|
||||||
|
sprite.extent().divideBy(2)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
this.stage.add(sprite);
|
||||||
|
return sprite;
|
||||||
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue