sceneified trash

snap7
jmoenig 2021-03-25 13:47:45 +01:00
rodzic f4aa21a2a6
commit 098cea0fc4
4 zmienionych plików z 20 dodań i 13 usunięć

Wyświetl plik

@ -2,6 +2,9 @@
## in development:
### 2021-03-25
* gui, scenes: sceneified trash
### 2021-03-19
* gui, store, scenes: capture global settings in scenes

Wyświetl plik

@ -11,8 +11,8 @@
<script src="src/blocks.js?version=2021-02-27"></script>
<script src="src/threads.js?version=2021-03-19"></script>
<script src="src/objects.js?version=2021-03-18"></script>
<script src="src/scenes.js?version=2021-03-19"></script>
<script src="src/gui.js?version=2021-03-18"></script>
<script src="src/scenes.js?version=2021-03-25"></script>
<script src="src/gui.js?version=2021-03-25"></script>
<script src="src/paint.js?version=2021-03-17"></script>
<script src="src/lists.js?version=2021-03-15"></script>
<script src="src/byob.js?version=2021-03-05"></script>

Wyświetl plik

@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/
// Global stuff ////////////////////////////////////////////////////////
modules.gui = '2021-March-19';
modules.gui = '2021-March-25';
// Declarations
@ -212,7 +212,7 @@ function IDE_Morph(isAutoFill) {
this.init(isAutoFill);
}
IDE_Morph.prototype.init = function (isAutoFill) { // +++
IDE_Morph.prototype.init = function (isAutoFill) {
// global font setting
MorphicPreferences.globalFontFamily = 'Helvetica, Arial';
@ -236,8 +236,6 @@ IDE_Morph.prototype.init = function (isAutoFill) { // +++
this.currentCategory = 'motion';
this.currentTab = 'scripts';
this.trash = []; // deleted sprites
// logoURL is disabled because the image data is hard-copied
// to avoid tainting the world canvas
// this.logoURL = this.resourceURL('src', 'snap_logo_sm.png');
@ -3117,7 +3115,7 @@ IDE_Morph.prototype.removeSprite = function (sprite) {
this.recordUnsavedChanges();
// remember the deleted sprite so it can be recovered again later
this.trash.push(sprite);
this.scene.trash.push(sprite);
};
IDE_Morph.prototype.newSoundName = function (name) {
@ -4015,7 +4013,7 @@ IDE_Morph.prototype.projectMenu = function () {
'Select a sound from the media library'
);
if (this.trash.length) {
if (this.scene.trash.length) {
menu.addLine();
menu.addItem(
'Undelete sprites...',
@ -4295,11 +4293,11 @@ IDE_Morph.prototype.undeleteSprites = function (pos) {
var menu = new MenuMorph(sprite => this.undelete(sprite, pos), null, this);
pos = pos || this.corralBar.bottomRight();
if (!this.trash.length) {
if (!this.scene.trash.length) {
this.showMessage('trash is empty');
return;
}
this.trash.forEach(sprite =>
this.scene.trash.forEach(sprite =>
menu.addItem(
[
sprite.thumbnail(new Point(24, 24), null, true), // no corpse
@ -4332,7 +4330,7 @@ IDE_Morph.prototype.undelete = function (aSprite, pos) {
this.sprites.add(aSprite);
this.corral.addSprite(aSprite);
this.selectSprite(aSprite);
this.trash = this.trash.filter(sprite => sprite.isCorpse);
this.scene.updateTrash();
}
);
};
@ -5335,7 +5333,6 @@ IDE_Morph.prototype.switchToScene = function (scene) {
this.fixLayout();
scene.applyGlobalSettings();
this.hasUnsavedEdits = false;
this.trash = []; // +++ sceneify
this.world().keyboardFocus = this.stage;
};

Wyświetl plik

@ -49,7 +49,7 @@
/*global modules, VariableFrame, StageMorph, SpriteMorph, Process*/
modules.scenes = '2021-March-19';
modules.scenes = '2021-March-25';
// Scene /////////////////////////////////////////////////////////
@ -84,6 +84,9 @@ function Scene(aStageMorph) {
// for deserializing - do not persist
this.sprites = {};
this.targetStage = null;
// for undeleting sprites - do not persist
this.trash = [];
}
Scene.prototype.addDefaultSprite = function () {
@ -122,3 +125,7 @@ Scene.prototype.applyGlobalSettings = function () {
Process.prototype.enableLiveCoding = this.enableLiveCoding;
Process.prototype.enableHyperOps = this.enableHyperOps;
};
Scene.prototype.updateTrash = function () {
this.trash = this.trash.filter(sprite => sprite.isCorpse);
};