From 864a3b62a02fbc5a039d2b97e114177c04318add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Mon, 11 Jul 2022 19:24:31 +0200 Subject: [PATCH] embed blocks code into all custom block definition pics --- HISTORY.md | 2 ++ snap.html | 2 +- src/byob.js | 29 +++++++++++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index a20ded63..37f027ca 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -60,6 +60,8 @@ ### 2022-07-11 * extensions: fixed #3065 * threads: added support to the OF reporter for binding a ring to another one, e.g. THIS SCRIPT to access its local variables +* byob: embed blocks code into all custom block definition pics + ### 2022-07-04 * blocks, gui: directly import embedded blocks from a smart pic if the pic is dragged and dropped onto a scripting area or palette - otherwise import the pic as costume (with embedded blocks) * gui: import smart pic as costume via "Import..." item in the project menu diff --git a/snap.html b/snap.html index beb8f033..15313e13 100755 --- a/snap.html +++ b/snap.html @@ -23,7 +23,7 @@ - + diff --git a/src/byob.js b/src/byob.js index 695955ba..75ca6b31 100644 --- a/src/byob.js +++ b/src/byob.js @@ -105,13 +105,13 @@ ToggleButtonMorph, IDE_Morph, MenuMorph, ToggleElementMorph, fontHeight, isNil, StageMorph, SyntaxElementMorph, CommentMorph, localize, CSlotMorph, Variable, MorphicPreferences, SymbolMorph, CursorMorph, VariableFrame, BooleanSlotMorph, WatcherMorph, XML_Serializer, SnapTranslator, SnapExtensions, MultiArgMorph, -ArgLabelMorph*/ +ArgLabelMorph, embedMetadataPNG*/ /*jshint esversion: 6*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2022-June-29'; +modules.byob = '2022-July-11'; // Declarations @@ -1362,16 +1362,29 @@ CustomCommandBlockMorph.prototype.userMenu = function () { if (this.isPrototype) { menu = new MenuMorph(this); menu.addItem( - "script pic...", + "script pic...", // +++ function () { - var ide = this.world().children[0]; - ide.saveCanvasAs( - this.topBlock().scriptPic(), - (ide.projectName || localize('untitled')) + ' ' + + var ide = this.world().children[0], + top = this.topBlock(), + xml = ide.blocksLibraryXML( + [top.definition].concat( + top.definition.collectDependencies( + [], + [], + top.scriptTarget() + ) + ), + null, + true + ); + ide.saveFileAs( + embedMetadataPNG(top.scriptPic(), xml), + 'image/png', + (ide.getProjectName() || localize('untitled')) + ' ' + localize('script pic') ); }, - 'open a new window\nwith a picture of this script' + 'save a picture\nof this script' ); menu.addItem( "translations...",