diff options
| author | Michael Ball <cycomachead@gmail.com> | 2014-06-21 11:37:25 -0700 |
|---|---|---|
| committer | Michael Ball <cycomachead@gmail.com> | 2014-06-21 11:37:25 -0700 |
| commit | ec8b14a3758acfc852a6f02010394bd5814d7272 (patch) | |
| tree | 2589fd29d40516c3a5c171a5aca6fcff80b7cff9 /blocks.js | |
| parent | bf03185eb083ea4171121d25ffda3041d91be8e7 (diff) | |
| parent | 7f8d5a3d1eacdc78f61da8e82ac481bbbb825938 (diff) | |
| download | snap-ec8b14a3758acfc852a6f02010394bd5814d7272.tar.gz snap-ec8b14a3758acfc852a6f02010394bd5814d7272.zip | |
Merge pull request #34 from jmoenig/master
updating cs10 branch from jmoenig 0614
Diffstat (limited to 'blocks.js')
| -rw-r--r-- | blocks.js | 52 |
1 files changed, 37 insertions, 15 deletions
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-May-02'; +modules.blocks = '2014-June-06'; var SyntaxElementMorph; @@ -913,17 +913,13 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { part = new InputSlotMorph( null, false, - { - /* - color : 'color', - fisheye : 'fisheye', - whirl : 'whirl', - pixelate : 'pixelate', - mosaic : 'mosaic', - brightness : 'brightness', - */ - ghost : ['ghost'] - }, + { brightness : ['brightness'], + ghost : ['ghost'], + negative : ['negative'], + comic: ['comic'], + duplicate: ['duplicate'], + confetti: ['confetti'] + }, true ); part.setContents(['ghost']); @@ -2013,6 +2009,7 @@ BlockMorph.prototype.userMenu = function () { var menu = new MenuMorph(this), world = this.world(), myself = this, + alternatives, blck; menu.addItem( @@ -2070,6 +2067,14 @@ BlockMorph.prototype.userMenu = function () { ); } ); + } else if (this.definition && this.alternatives) { // custom block + alternatives = this.alternatives(); + if (alternatives.length > 0) { + menu.addItem( + 'relabel...', + function () {myself.relabel(alternatives); } + ); + } } menu.addItem( @@ -2268,6 +2273,7 @@ BlockMorph.prototype.relabel = function (alternativeSelectors) { alternativeSelectors.forEach(function (sel) { var block = SpriteMorph.prototype.blockForSelector(sel); block.restoreInputs(oldInputs); + block.fixBlockColor(null, true); block.addShadow(new Point(3, 3)); menu.addItem( block, @@ -2287,7 +2293,7 @@ BlockMorph.prototype.setSelector = function (aSelector) { var oldInputs = this.inputs(), info; info = SpriteMorph.prototype.blocks[aSelector]; - this.category = info.category; + this.setCategory(info.category); this.selector = aSelector; this.setSpec(localize(info.spec)); this.restoreInputs(oldInputs); @@ -2299,6 +2305,7 @@ BlockMorph.prototype.restoreInputs = function (oldInputs) { // try to restore my previous inputs when my spec has been changed var i = 0, old, + nb, myself = this; this.inputs().forEach(function (inp) { @@ -2309,7 +2316,14 @@ BlockMorph.prototype.restoreInputs = function (oldInputs) { // original - turns empty numberslots to 0: // inp.setContents(old.evaluate()); // "fix" may be wrong b/c constants - inp.setContents(old.contents().text); + if (old.contents) { + inp.setContents(old.contents().text); + } + } else if (old instanceof CSlotMorph && inp instanceof CSlotMorph) { + nb = old.nestedBlock(); + if (nb) { + inp.nestedBlock(nb.fullCopy()); + } } i += 1; }); @@ -4957,6 +4971,14 @@ ScriptsMorph.prototype.cleanUp = function () { }; ScriptsMorph.prototype.exportScriptsPicture = function () { + var pic = this.scriptsPicture(); + if (pic) { + window.open(pic.toDataURL()); + } +}; + +ScriptsMorph.prototype.scriptsPicture = function () { + // private - answer a canvas containing the pictures of all scripts var boundingBox, pic, ctx; if (this.children.length === 0) {return; } boundingBox = this.children[0].fullBounds(); @@ -4977,7 +4999,7 @@ ScriptsMorph.prototype.exportScriptsPicture = function () { ); } }); - window.open(pic.toDataURL()); + return pic; }; ScriptsMorph.prototype.addComment = function () { |
