kopia lustrzana https://github.com/backface/turtlestitch
keep track of unsaved edits
rodzic
7e9faf1577
commit
5a3be048f5
|
@ -11,6 +11,9 @@
|
|||
* fixed a bug in hyperblocks
|
||||
* fixed keyboard formula entry for subtraction
|
||||
|
||||
### 2020-12-20
|
||||
* gui, blocks, objects: keep track of unsaved edits
|
||||
|
||||
### 2020-12-19
|
||||
* threads: added code-documentation for the WARP/timestamp optimization
|
||||
* gui: new auto-backup to localstore feature
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<script src="src/morphic.js?version=2020-12-02"></script>
|
||||
<script src="src/symbols.js?version=2020-10-07"></script>
|
||||
<script src="src/widgets.js?version=2020-10-06"></script>
|
||||
<script src="src/blocks.js?version=2020-12-17"></script>
|
||||
<script src="src/blocks.js?version=2020-12-20"></script>
|
||||
<script src="src/threads.js?version=2020-12-19"></script>
|
||||
<script src="src/objects.js?version=2020-12-16"></script>
|
||||
<script src="src/gui.js?version=2020-12-19"></script>
|
||||
<script src="src/objects.js?version=2020-12-20"></script>
|
||||
<script src="src/gui.js?version=2020-12-20"></script>
|
||||
<script src="src/paint.js?version=2020-05-17"></script>
|
||||
<script src="src/lists.js?version=2020-12-01"></script>
|
||||
<script src="src/byob.js?version=2020-11-27"></script>
|
||||
|
|
|
@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2020-December-17';
|
||||
modules.blocks = '2020-December-20';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -7429,27 +7429,40 @@ ScriptsMorph.prototype.clearDropInfo = function () {
|
|||
|
||||
ScriptsMorph.prototype.recordDrop = function (lastGrabOrigin) {
|
||||
// support for "undrop" / "redrop"
|
||||
var record = {
|
||||
lastDroppedBlock: this.lastDroppedBlock,
|
||||
lastReplacedInput: this.lastReplacedInput,
|
||||
lastDropTarget: this.lastDropTarget,
|
||||
lastPreservedBlocks: this.lastPreservedBlocks,
|
||||
lastNextBlock: this.lastNextBlock,
|
||||
lastWrapParent: this.lastWrapParent,
|
||||
lastOrigin: lastGrabOrigin,
|
||||
var ide, blockEditor,
|
||||
record = {
|
||||
lastDroppedBlock: this.lastDroppedBlock,
|
||||
lastReplacedInput: this.lastReplacedInput,
|
||||
lastDropTarget: this.lastDropTarget,
|
||||
lastPreservedBlocks: this.lastPreservedBlocks,
|
||||
lastNextBlock: this.lastNextBlock,
|
||||
lastWrapParent: this.lastWrapParent,
|
||||
lastOrigin: lastGrabOrigin,
|
||||
|
||||
// for special gestures, e.g. deleting or extracting single commands:
|
||||
action: lastGrabOrigin ? lastGrabOrigin.action || null : null,
|
||||
action: lastGrabOrigin ? lastGrabOrigin.action || null : null,
|
||||
|
||||
situation: null,
|
||||
lastRecord: this.dropRecord,
|
||||
nextRecord: null
|
||||
};
|
||||
situation: null,
|
||||
lastRecord: this.dropRecord,
|
||||
nextRecord: null
|
||||
};
|
||||
if (this.dropRecord) {
|
||||
this.dropRecord.nextRecord = record;
|
||||
}
|
||||
this.dropRecord = record;
|
||||
this.updateToolbar();
|
||||
|
||||
// notify the IDE of an unsaved user edit
|
||||
ide = this.parentThatIsA(IDE_Morph);
|
||||
if (!ide) {
|
||||
blockEditor = this.parentThatIsA(BlockEditorMorph);
|
||||
if (blockEditor) {
|
||||
ide = blockEditor.target.parentThatIsA(IDE_Morph);
|
||||
}
|
||||
}
|
||||
if (ide) {
|
||||
ide.hasUnsavedEdits = true;
|
||||
}
|
||||
};
|
||||
|
||||
ScriptsMorph.prototype.addToolbar = function () {
|
||||
|
|
31
src/gui.js
31
src/gui.js
|
@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2020-December-19';
|
||||
modules.gui = '2020-December-20';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -259,7 +259,11 @@ IDE_Morph.prototype.init = function (isAutoFill) {
|
|||
this.isAppMode = false;
|
||||
this.isSmallStage = false;
|
||||
this.filePicker = null;
|
||||
|
||||
// incrementally saving projects to the cloud is currently unused
|
||||
this.hasChangedMedia = false;
|
||||
|
||||
this.hasUnsavedEdits = false; // keeping track of when to internally backup
|
||||
|
||||
this.isAnimating = true;
|
||||
this.paletteWidth = 200; // initially same as logo width
|
||||
|
@ -1885,6 +1889,7 @@ IDE_Morph.prototype.createCorral = function () {
|
|||
this.corral.addSprite = function (sprite) {
|
||||
this.frame.contents.add(new SpriteIconMorph(sprite));
|
||||
this.fixLayout();
|
||||
this.hasUnsavedEdits = true;
|
||||
};
|
||||
|
||||
this.corral.refresh = function () {
|
||||
|
@ -2136,6 +2141,7 @@ IDE_Morph.prototype.droppedImage = function (aCanvas, name) {
|
|||
this.currentSprite.wearCostume(costume);
|
||||
this.spriteBar.tabBar.tabTo('costumes');
|
||||
this.hasChangedMedia = true;
|
||||
this.hasUnsavedEdits = true;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.droppedSVG = function (anImage, name) {
|
||||
|
@ -2239,6 +2245,7 @@ IDE_Morph.prototype.droppedAudio = function (anAudio, name) {
|
|||
this.currentSprite.addSound(anAudio, name.split('.')[0]); // up to '.'
|
||||
this.spriteBar.tabBar.tabTo('sounds');
|
||||
this.hasChangedMedia = true;
|
||||
this.hasUnsavedEdits = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2262,6 +2269,9 @@ IDE_Morph.prototype.droppedText = function (aString, name, fileType) {
|
|||
location.hash = '';
|
||||
return this.openCloudDataString(aString);
|
||||
}
|
||||
|
||||
this.hasUnsavedEdits = true;
|
||||
|
||||
if (aString.indexOf('<blocks') === 0) {
|
||||
return this.openBlocksString(aString, lbl, true);
|
||||
}
|
||||
|
@ -2744,6 +2754,7 @@ IDE_Morph.prototype.paintNewSprite = function () {
|
|||
() => {
|
||||
sprite.addCostume(cos);
|
||||
sprite.wearCostume(cos);
|
||||
this.hasUnsavedEdits = true;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -2786,6 +2797,7 @@ IDE_Morph.prototype.recordNewSound = function () {
|
|||
this.makeSureRecordingIsMono(sound);
|
||||
this.spriteBar.tabBar.tabTo('sounds');
|
||||
this.hasChangedMedia = true;
|
||||
this.hasUnsavedEdits = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2957,6 +2969,7 @@ IDE_Morph.prototype.duplicateSprite = function (sprite) {
|
|||
duplicate.keepWithin(this.stage);
|
||||
duplicate.isDown = sprite.isDown;
|
||||
this.selectSprite(duplicate);
|
||||
this.hasUnsavedEdits = true;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.instantiateSprite = function (sprite) {
|
||||
|
@ -2972,6 +2985,7 @@ IDE_Morph.prototype.instantiateSprite = function (sprite) {
|
|||
}
|
||||
instance.isDown = sprite.isDown;
|
||||
this.selectSprite(instance);
|
||||
this.hasUnsavedEdits = true;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.removeSprite = function (sprite) {
|
||||
|
@ -2999,6 +3013,7 @@ IDE_Morph.prototype.removeSprite = function (sprite) {
|
|||
) || this.stage;
|
||||
|
||||
this.selectSprite(this.currentSprite);
|
||||
this.hasUnsavedEdits = true;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.newSoundName = function (name) {
|
||||
|
@ -4411,6 +4426,7 @@ IDE_Morph.prototype.newProject = function () {
|
|||
this.createCorral();
|
||||
this.selectSprite(this.stage.children[0]);
|
||||
this.fixLayout();
|
||||
this.hasUnsavedEdits = false;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.save = function () {
|
||||
|
@ -4464,6 +4480,7 @@ IDE_Morph.prototype.exportProject = function (name, plain) {
|
|||
this.setURL('#open:' + dataPrefix + encodeURIComponent(str));
|
||||
this.saveXMLAs(str, name);
|
||||
menu.destroy();
|
||||
this.hasUnsavedEdits = false;
|
||||
this.showMessage('Exported!', 1);
|
||||
} catch (err) {
|
||||
if (Process.prototype.isCatchingErrors) {
|
||||
|
@ -4906,6 +4923,7 @@ IDE_Morph.prototype.rawOpenProjectString = function (str) {
|
|||
);
|
||||
}
|
||||
this.stopFastTracking();
|
||||
this.hasUnsavedEdits = false;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.openCloudDataString = function (str) {
|
||||
|
@ -4958,6 +4976,7 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
|
|||
);
|
||||
}
|
||||
this.stopFastTracking();
|
||||
this.hasUnsavedEdits = false;
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.openBlocksString = function (str, name, silently) {
|
||||
|
@ -6266,7 +6285,10 @@ IDE_Morph.prototype.saveProjectToCloud = function (name) {
|
|||
this.cloud.saveProject(
|
||||
this.projectName,
|
||||
projectBody,
|
||||
() => this.showMessage('saved.', 2),
|
||||
() => {
|
||||
this.hasUnsavedEdits = false;
|
||||
this.showMessage('saved.', 2);
|
||||
},
|
||||
this.cloudError()
|
||||
);
|
||||
};
|
||||
|
@ -8919,6 +8941,7 @@ CostumeIconMorph.prototype.editRotationPointOnly = function () {
|
|||
var ide = this.parentThatIsA(IDE_Morph);
|
||||
this.object.editRotationPointOnly(this.world(), ide);
|
||||
ide.hasChangedMedia = true;
|
||||
ide.hasUnsavedEdits = true;
|
||||
};
|
||||
|
||||
CostumeIconMorph.prototype.renameCostume = function () {
|
||||
|
@ -8936,6 +8959,7 @@ CostumeIconMorph.prototype.renameCostume = function () {
|
|||
);
|
||||
costume.version = Date.now();
|
||||
ide.hasChangedMedia = true;
|
||||
ide.hasUnsavedEdits = true;
|
||||
}
|
||||
}
|
||||
).prompt(
|
||||
|
@ -9379,6 +9403,7 @@ WardrobeMorph.prototype.paintNew = function () {
|
|||
this.updateList();
|
||||
if (ide) {
|
||||
ide.currentSprite.wearCostume(cos);
|
||||
ide.hasUnsavedEdits = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -9397,6 +9422,7 @@ WardrobeMorph.prototype.newFromCam = function () {
|
|||
sprite.addCostume(costume);
|
||||
sprite.wearCostume(costume);
|
||||
this.updateList();
|
||||
ide.hasUnsavedEdits = true;
|
||||
});
|
||||
|
||||
camDialog.key = 'camera';
|
||||
|
@ -9601,6 +9627,7 @@ SoundIconMorph.prototype.renameSound = function () {
|
|||
this.createLabel(); // can be omitted once I'm stepping
|
||||
this.fixLayout(); // can be omitted once I'm stepping
|
||||
ide.hasChangedMedia = true;
|
||||
ide.hasUnsavedEdits = true;
|
||||
}
|
||||
}
|
||||
).prompt(
|
||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
|||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||
|
||||
modules.objects = '2020-December-16';
|
||||
modules.objects = '2020-December-20';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -3309,6 +3309,9 @@ SpriteMorph.prototype.searchBlocks = function (
|
|||
if (selection) {
|
||||
scriptFocus.insertBlock(selection);
|
||||
}
|
||||
if (ide) {
|
||||
ide.hasUnsavedEdits = true;
|
||||
}
|
||||
} else {
|
||||
search = searchBar.getValue();
|
||||
if (search.length > 0) {
|
||||
|
|
Ładowanie…
Reference in New Issue