kopia lustrzana https://github.com/backface/turtlestitch
GUI: new (hidden) feature: “Export all scripts as pic”
(including custom block refs)pull/3/merge
rodzic
50203901ea
commit
bae41fde28
61
gui.js
61
gui.js
|
@ -69,7 +69,7 @@ SpeechBubbleMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.gui = '2014-May-26';
|
modules.gui = '2014-Jun-04';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -2350,6 +2350,15 @@ IDE_Morph.prototype.projectMenu = function () {
|
||||||
'show global custom block definitions as XML\nin a new browser window'
|
'show global custom block definitions as XML\nin a new browser window'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (shiftClicked) {
|
||||||
|
menu.addItem(
|
||||||
|
'Export all scripts as pic...',
|
||||||
|
function () {myself.exportScriptsPicture(); },
|
||||||
|
'show a picture of all scripts\nand block definitions',
|
||||||
|
new Color(100, 0, 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
menu.addLine();
|
menu.addLine();
|
||||||
menu.addItem(
|
menu.addItem(
|
||||||
'Import tools',
|
'Import tools',
|
||||||
|
@ -2847,6 +2856,56 @@ IDE_Morph.prototype.exportSprite = function (sprite) {
|
||||||
+ '</sprites>');
|
+ '</sprites>');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IDE_Morph.prototype.exportScriptsPicture = function () {
|
||||||
|
var pics = [],
|
||||||
|
pic,
|
||||||
|
padding = 20,
|
||||||
|
w = 0,
|
||||||
|
h = 0,
|
||||||
|
y = 0,
|
||||||
|
ctx;
|
||||||
|
|
||||||
|
// collect all script pics
|
||||||
|
this.sprites.asArray().forEach(function (sprite) {
|
||||||
|
pics.push(sprite.image);
|
||||||
|
pics.push(sprite.scripts.scriptsPicture());
|
||||||
|
sprite.customBlocks.forEach(function (def) {
|
||||||
|
pics.push(def.scriptsPicture());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
pics.push(this.stage.image);
|
||||||
|
pics.push(this.stage.scripts.scriptsPicture());
|
||||||
|
this.stage.customBlocks.forEach(function (def) {
|
||||||
|
pics.push(def.scriptsPicture());
|
||||||
|
});
|
||||||
|
|
||||||
|
// collect global block pics
|
||||||
|
this.stage.globalBlocks.forEach(function (def) {
|
||||||
|
pics.push(def.scriptsPicture());
|
||||||
|
});
|
||||||
|
|
||||||
|
pics = pics.filter(function (each) {return !isNil(each); });
|
||||||
|
|
||||||
|
// determine dimensions of composite
|
||||||
|
pics.forEach(function (each) {
|
||||||
|
w = Math.max(w, each.width);
|
||||||
|
h += (each.height);
|
||||||
|
h += padding;
|
||||||
|
});
|
||||||
|
h -= padding;
|
||||||
|
pic = newCanvas(new Point(w, h));
|
||||||
|
ctx = pic.getContext('2d');
|
||||||
|
|
||||||
|
// draw all parts
|
||||||
|
pics.forEach(function (each) {
|
||||||
|
ctx.drawImage(each, 0, y);
|
||||||
|
y += padding;
|
||||||
|
y += each.height;
|
||||||
|
});
|
||||||
|
|
||||||
|
window.open(pic.toDataURL());
|
||||||
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.openProjectString = function (str) {
|
IDE_Morph.prototype.openProjectString = function (str) {
|
||||||
var msg,
|
var msg,
|
||||||
myself = this;
|
myself = this;
|
||||||
|
|
|
@ -2139,3 +2139,9 @@ ______
|
||||||
* Objects: Fixed #445 (minor search + zoom issues)
|
* Objects: Fixed #445 (minor search + zoom issues)
|
||||||
* Localization additions and Portuguese translation update, thanks, Manuel!
|
* Localization additions and Portuguese translation update, thanks, Manuel!
|
||||||
* GUI, cloud: Show last-changed-timestamp when opening cloud projects
|
* GUI, cloud: Show last-changed-timestamp when opening cloud projects
|
||||||
|
|
||||||
|
140604
|
||||||
|
------
|
||||||
|
* Blocks: refactor “script pics” feature
|
||||||
|
* BYOB: new scriptsPicture() method for custom block definitions
|
||||||
|
* GUI: new (hidden) feature: “Export all scripts as pic” (including custom block refs)
|
||||||
|
|
Ładowanie…
Reference in New Issue