diff --git a/HISTORY.md b/HISTORY.md index d884315b..3a7f9098 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -7,6 +7,8 @@ * added "pie chart" option to PLOT command in the frequency distribution analysis library * added getProjectXML() method to the API * new noCloud flag that disables cloud access, thanks, Bernat +* **Notable Changes:** + * security: pause generic WHEN hat blocks when loading a project or importing a sprite until the user clicks the green flag or un-pauses the red stop sign, unless opening it with #run:&noRun * **Documentation Updates:** * API update * **Notable Fixes:** @@ -17,6 +19,9 @@ * Russian, thanks, Pavel! * German +### 2020-10-27 +* gui, objects, store: pause generic WHEN hat blocks when loading a project or importing a sprite until the user clicks the green flag or un-pauses the red stop sign, unless opening it with #run:&noRun + ### 2020-10-26 * objects: added test for the existence of generic WHEN hat blocks diff --git a/snap.html b/snap.html index 744305be..90684ff4 100755 --- a/snap.html +++ b/snap.html @@ -10,8 +10,8 @@ - - + + @@ -20,7 +20,7 @@ - + diff --git a/src/gui.js b/src/gui.js index bc6b78b1..ff52a735 100644 --- a/src/gui.js +++ b/src/gui.js @@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2020-October-23'; +modules.gui = '2020-October-27'; // Declarations @@ -2316,6 +2316,10 @@ IDE_Morph.prototype.stopFastTracking = function () { }; IDE_Morph.prototype.runScripts = function () { + if (this.stage.threads.pauseCustomHatBlocks) { + this.stage.threads.pauseCustomHatBlocks = false; + this.controlBar.stopButton.refresh(); + } this.stage.fireGreenFlagEvent(); }; diff --git a/src/objects.js b/src/objects.js index bf43efca..1e471a31 100644 --- a/src/objects.js +++ b/src/objects.js @@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph, AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/ -modules.objects = '2020-October-26'; +modules.objects = '2020-October-27'; var SpriteMorph; var StageMorph; @@ -6438,6 +6438,18 @@ SpriteMorph.prototype.replaceDoubleDefinitionsFor = function (definition) { } }; +// SpriteMorph controlling generic WHEN hats + +SpriteMorph.prototype.pauseGenericHatBlocks = function () { + var stage = this.parentThatIsA(StageMorph), + ide = this.parentThatIsA(IDE_Morph); + if (this.hasGenericHatBlocks()) { + stage.enableCustomHatBlocks = true; + stage.threads.pauseCustomHatBlocks = true; + ide.controlBar.stopButton.refresh(); + } +}; + // SpriteMorph inheritance - general SpriteMorph.prototype.chooseExemplar = function () { @@ -8214,6 +8226,18 @@ StageMorph.prototype.editScripts = function () { scripts.focus.fixLayout(); }; +// StageMorph controlling generic WHEN hats + +StageMorph.prototype.pauseGenericHatBlocks = function () { + var ide = this.parentThatIsA(IDE_Morph); + if (this.hasGenericHatBlocks() || + ide.sprites.asArray().some(any => any.hasGenericHatBlocks())) { + this.enableCustomHatBlocks = true; + this.threads.pauseCustomHatBlocks = true; + ide.controlBar.stopButton.refresh(); + } +}; + // StageMorph block templates StageMorph.prototype.blockTemplates = function (category) { diff --git a/src/store.js b/src/store.js index 4f12fe7b..37ce4f7d 100644 --- a/src/store.js +++ b/src/store.js @@ -61,7 +61,7 @@ normalizeCanvas, contains*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2020-October-21'; +modules.store = '2020-October-27'; // XML_Serializer /////////////////////////////////////////////////////// @@ -709,6 +709,7 @@ SnapSerializer.prototype.loadSprites = function (xmlString, ide) { sprite.gotoXY(+model.attributes.x || 0, +model.attributes.y || 0); this.loadObject(sprite, model); sprite.fixLayout(); + sprite.pauseGenericHatBlocks(); }); // restore inheritance and nesting associations @@ -1650,6 +1651,7 @@ SnapSerializer.prototype.openProject = function (project, ide) { ide.hasChangedMedia = true; } project.stage.fixLayout(); + project.stage.pauseGenericHatBlocks(); ide.createCorral(); ide.selectSprite(sprite); ide.fixLayout();