kopia lustrzana https://github.com/backface/turtlestitch
undelete sprites
rodzic
c43ac46add
commit
de976a2036
|
@ -2,6 +2,8 @@
|
|||
|
||||
## in development:
|
||||
|
||||
* **New Features:**
|
||||
* undelete sprites
|
||||
* **Notable Changes:**
|
||||
* optimized special cases for COMBINE (sum, product, min, max) by up to 34 x
|
||||
* custom block label parts inside the prototype (in the block editor) are now displayed the same as in block instances
|
||||
|
@ -12,6 +14,7 @@
|
|||
### 2021-03-02
|
||||
* threads: optimized special cases for COMBINE (sum, product, min, max) by up to 34 x
|
||||
* threads: optimized special cases for compiled version of COMBINE
|
||||
* gui, objects: undelete sprites
|
||||
|
||||
### 2021-03-01
|
||||
* byob: improved layout and rendering of (+) buttons in custom block prototypes
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<script src="src/widgets.js?version=2021-01-05"></script>
|
||||
<script src="src/blocks.js?version=2021-02-27"></script>
|
||||
<script src="src/threads.js?version=2021-03-02"></script>
|
||||
<script src="src/objects.js?version=2021-02-23"></script>
|
||||
<script src="src/objects.js?version=2021-03-02"></script>
|
||||
<script src="src/gui.js?version=2021-02-27"></script>
|
||||
<script src="src/paint.js?version=2020-05-17"></script>
|
||||
<script src="src/lists.js?version=2021-02-20"></script>
|
||||
|
|
47
src/gui.js
47
src/gui.js
|
@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2021-February-27';
|
||||
modules.gui = '2021-March-02';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -235,6 +235,8 @@ IDE_Morph.prototype.init = function (isAutoFill) {
|
|||
this.projectName = '';
|
||||
this.projectNotes = '';
|
||||
|
||||
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');
|
||||
|
@ -3071,6 +3073,9 @@ IDE_Morph.prototype.removeSprite = function (sprite) {
|
|||
|
||||
this.selectSprite(this.currentSprite);
|
||||
this.recordUnsavedChanges();
|
||||
|
||||
// remember the deleted sprite so it can be recovered again later
|
||||
this.trash.push(sprite);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.newSoundName = function (name) {
|
||||
|
@ -3968,6 +3973,11 @@ IDE_Morph.prototype.projectMenu = function () {
|
|||
'Select a sound from the media library'
|
||||
);
|
||||
|
||||
if (this.trash.length) {
|
||||
menu.addLine();
|
||||
menu.addItem('Undelete...', 'undeleteSprites');
|
||||
}
|
||||
|
||||
menu.popup(world, pos);
|
||||
};
|
||||
|
||||
|
@ -4230,6 +4240,41 @@ IDE_Morph.prototype.popupMediaImportDialog = function (folderName, items) {
|
|||
);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.undeleteSprites = function () {
|
||||
// pop up a menu showing deleted sprites that can be recovered
|
||||
// by clicking on them
|
||||
var menu = new MenuMorph(this.undelete, 'Undelete', this),
|
||||
pos = this.controlBar.projectButton.bottomLeft();
|
||||
|
||||
this.trash.forEach(sprite =>
|
||||
menu.addItem(
|
||||
[
|
||||
sprite.thumbnail(new Point(24, 24), null, true), // no corpse
|
||||
sprite.name,
|
||||
],
|
||||
sprite
|
||||
)
|
||||
);
|
||||
menu.popup(this.world(), pos);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.undelete = function (aSprite) {
|
||||
var rnd = Process.prototype.reportBasicRandom;
|
||||
aSprite.isCorpse = false;
|
||||
aSprite.version = Date.now();
|
||||
aSprite.name = this.newSpriteName(aSprite.name);
|
||||
aSprite.setCenter(this.stage.center());
|
||||
this.stage.add(aSprite);
|
||||
aSprite.setXPosition(rnd.call(this, -100, 100));
|
||||
aSprite.setYPosition(rnd.call(this, -100, 100));
|
||||
aSprite.fixLayout();
|
||||
aSprite.rerender();
|
||||
this.sprites.add(aSprite);
|
||||
this.corral.addSprite(aSprite);
|
||||
this.selectSprite(aSprite);
|
||||
this.trash = this.trash.filter(sprite => sprite.isCorpse);
|
||||
};
|
||||
|
||||
// IDE_Morph menu actions
|
||||
|
||||
IDE_Morph.prototype.aboutSnap = function () {
|
||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
|||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||
|
||||
modules.objects = '2021-February-23';
|
||||
modules.objects = '2021-March-02';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -7229,7 +7229,7 @@ SpriteMorph.prototype.inheritedMethods = function () {
|
|||
|
||||
// SpriteMorph thumbnail
|
||||
|
||||
SpriteMorph.prototype.thumbnail = function (extentPoint, recycleMe) {
|
||||
SpriteMorph.prototype.thumbnail = function (extentPoint, recycleMe, noCorpse) {
|
||||
// answer a new Canvas of extentPoint dimensions containing
|
||||
// my thumbnail representation keeping the originial aspect ratio
|
||||
// a "recycleMe canvas can be passed for re-use
|
||||
|
@ -7259,7 +7259,7 @@ SpriteMorph.prototype.thumbnail = function (extentPoint, recycleMe) {
|
|||
}
|
||||
|
||||
ctx.save();
|
||||
if (this.isCorpse) {
|
||||
if (this.isCorpse && !noCorpse) {
|
||||
ctx.globalAlpha = 0.3;
|
||||
}
|
||||
if (w && h && src.width && src.height) {
|
||||
|
@ -7270,7 +7270,7 @@ SpriteMorph.prototype.thumbnail = function (extentPoint, recycleMe) {
|
|||
Math.floor(yOffset / scale)
|
||||
);
|
||||
}
|
||||
if (this.isCorpse) {
|
||||
if (this.isCorpse && !noCorpse) {
|
||||
ctx.restore();
|
||||
xOut('white', 0.8, 6);
|
||||
xOut('black', 0.8, 1);
|
||||
|
|
Ładowanie…
Reference in New Issue