From 6926f7085bb2d1e3df02a6eb0547e40c5d47ef3f Mon Sep 17 00:00:00 2001 From: Manuel Menezes de Sequeira Date: Tue, 20 May 2014 13:23:24 +0100 Subject: Add localization to connection error message. --- cloud.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cloud.js b/cloud.js index 17fc76b..0dd7780 100644 --- a/cloud.js +++ b/cloud.js @@ -107,7 +107,7 @@ Cloud.prototype.signup = function ( errorCall.call( null, myself.url + 'SignUp', - 'could not connect to:' + localize('could not connect to:') ); } } @@ -164,7 +164,7 @@ Cloud.prototype.getPublicProject = function ( errorCall.call( null, myself.url + 'Public', - 'could not connect to:' + localize('could not connect to:') ); } } @@ -217,7 +217,7 @@ Cloud.prototype.resetPassword = function ( errorCall.call( null, myself.url + 'ResetPW', - 'could not connect to:' + localize('could not connect to:') ); } } @@ -264,7 +264,7 @@ Cloud.prototype.connect = function ( errorCall.call( null, myself.url, - 'could not connect to:' + localize('could not connect to:') ); } } @@ -533,7 +533,7 @@ Cloud.prototype.callService = function ( errorCall.call( this, request.responseText, - 'Service: ' + serviceName + localize('Service:') + ' ' + localize(serviceName) ); return; } -- cgit v1.3.1 From 43bfc95c1bda3912263475c4e49e9b4a4591c6de Mon Sep 17 00:00:00 2001 From: Manuel Menezes de Sequeira Date: Tue, 20 May 2014 13:26:08 +0100 Subject: Add new Portuguese localizations for stage size, flat line ends, dates sensor block, and Snap\!Cloud stuff. --- lang-pt.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/lang-pt.js b/lang-pt.js index c5e33b0..ffc8bf1 100755 --- a/lang-pt.js +++ b/lang-pt.js @@ -685,6 +685,16 @@ SnapTranslator.dict.pt = { 'Língua…', 'Zoom blocks...': 'Ampliação dos blocos…', + 'Stage size...': + 'Tamanho do palco…', + 'Stage size': + 'Tamanho do palco', + 'Stage width': + 'Largura do palco', + 'Stage height': + 'Altura do palco', + 'Default': + 'Normal', 'Blurred shadows': 'Sombras desfocadas', 'uncheck to use solid drop\nshadows and highlights': @@ -767,6 +777,12 @@ SnapTranslator.dict.pt = { 'Desassinalar para aumentar a velocidade\npermitindo ritmos variáveis das tramas.', 'check for smooth, predictable\nanimations across computers': 'Assinalar para obter animações mais suaves\ne previsíveis de computador para computador.', + 'Flat line ends': + 'Extremos das linhas planos', + 'check for flat ends of lines': + 'Assinalar para que os extremos das linhas\ndesenhadas pela caneta sejam planos.', + 'uncheck for round ends of lines': + 'Desassinalar para que os extremos das linhas\ndesenhadas pela caneta sejam redondos.', // entradas 'with inputs': @@ -1254,20 +1270,62 @@ SnapTranslator.dict.pt = { 'um item ao acaso', // em falta no ficheiro lang-de.js + 'current %dates': + '%dates corrente', + 'year': + 'ano', + 'month': + 'mês', + 'date': + 'dia', + 'day of week': + 'dia da semana', + 'hour': + 'hora', + 'minute': + 'minuto', + 'second': + 'segundo', + 'time in milliseconds': + 'tempo (em milisegundos)', + 'find blocks...': + 'procurar blocos…', 'costume name': 'o nome do traje', 'Open': 'Abrir', 'Share': 'Partilhar', + 'Snap!Cloud': + 'Snap!Nuvem', 'Cloud': 'Nuvem', + 'could not connect to:': + 'Não foi possível ligar a:', + 'Service:': + 'Serviço:', + 'login': + 'autenticação', + 'ERROR: INVALID PASSWORD': + 'ERRO: PALAVRA-PASSE INVÁLIDA', 'Browser': 'Navegador', 'Sign up': 'Registar nova conta', + 'Signup': + 'Registo de nova conta', 'Sign in': 'Entrar', + 'Logout': + 'Sair', + 'Change Password...': + 'Alterar palavra-passe…', + 'Change Password': + 'Alterar palavra-passe', + 'Account created.': + 'Conta criada.', + 'An e-mail with your password\nhas been sent to the address provided': + 'Foi enviada uma mensagem para\no endereço disponibilizado\ncontendo a sua palavra-passe.', 'now connected.': 'entrou.', 'disconnected.': @@ -1280,6 +1338,12 @@ SnapTranslator.dict.pt = { 'Nome de utilizador:', 'Password:': 'Palavra-passe:', + 'Old password:': + 'Palavra-passe actual:', + 'New password:': + 'Nova palavra-passe:', + 'Repeat new password:': + 'Repita a nova palavra-passe:', 'Birth date:': 'Data de nascimento:', 'January': -- cgit v1.3.1 From 8125861f8062727cc7a3abb2e3a140279a10b862 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 26 May 2014 09:40:55 +0200 Subject: Fixed #445 (minor search + zoom issues) --- history.txt | 4 ++++ objects.js | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index 126c11c..ecfdff4 100755 --- a/history.txt +++ b/history.txt @@ -2133,3 +2133,7 @@ ______ * Threads: new Variable data structure, for refactoring upvar references, not yet used anywhere * Objects, GUI: Search Blocks, feature. Thanks, Kyle, for architecting and designing this!!! * Objects, GUI: Keyboard-shortcuts for opening (cmd-o), saving (cmd-s) projects and for finding blocks (cmd-f) + +140526 +------ +* Objects: Fixed #445 (minor search + zoom issues) diff --git a/objects.js b/objects.js index 66ceb97..5f91606 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-May-20'; +modules.objects = '2014-May-26'; var SpriteMorph; var StageMorph; @@ -2348,13 +2348,11 @@ SpriteMorph.prototype.searchBlocks = function () { } searchPane.owner = this; - searchPane.padding = unit / 2; searchPane.color = myself.paletteColor; searchPane.contents.color = myself.paletteColor; - searchPane.growth = new Point(0, MorphicPreferences.scrollBarSize); searchPane.addContents(searchBar); searchBar.drawNew(); - searchBar.setWidth(ide.logo.width() - 20); + searchBar.setWidth(ide.logo.width() - 30); searchBar.contrast = 90; searchBar.setPosition( searchPane.contents.topLeft().add(new Point(10, 10)) -- cgit v1.3.1 From 24f7a37a56e4c44d6dd339f227507871867f1436 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 26 May 2014 09:57:21 +0200 Subject: Localization additions and Portuguese translation update, thanks, Manuel! --- cloud.js | 5 +++-- history.txt | 1 + lang-pt.js | 2 +- locale.js | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cloud.js b/cloud.js index 0dd7780..54189d8 100644 --- a/cloud.js +++ b/cloud.js @@ -27,9 +27,10 @@ // Global settings ///////////////////////////////////////////////////// -/*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/ +/*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop, +localize*/ -modules.cloud = '2014-January-09'; +modules.cloud = '2014-May-26'; // Global stuff diff --git a/history.txt b/history.txt index ecfdff4..8155285 100755 --- a/history.txt +++ b/history.txt @@ -2137,3 +2137,4 @@ ______ 140526 ------ * Objects: Fixed #445 (minor search + zoom issues) +* Localization additions and Portuguese translation update, thanks, Manuel! diff --git a/lang-pt.js b/lang-pt.js index ffc8bf1..226abf5 100755 --- a/lang-pt.js +++ b/lang-pt.js @@ -185,7 +185,7 @@ SnapTranslator.dict.pt = { 'translator_e-mail': 'mmsequeira@gmail.com', 'last_changed': - '2014-01-12', + '2014-05-26', // GUI // control bar: diff --git a/locale.js b/locale.js index d981960..c10aa64 100644 --- a/locale.js +++ b/locale.js @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2014-May-02'; +modules.locale = '2014-May-26'; // Global stuff @@ -209,7 +209,7 @@ SnapTranslator.dict.pt = { 'translator_e-mail': 'mmsequeira@gmail.com', 'last_changed': - '2014-01-12' + '2014-05-26' }; SnapTranslator.dict.cs = { -- cgit v1.3.1 From 6a4b4afbe98fa99623a81a89e2f6505ff5704d38 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 26 May 2014 10:46:00 +0200 Subject: Show last-changed-timestamp of cloud projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit display a tool-tip “bubble” in the “Open-Project” dialog next to the preview field --- gui.js | 16 ++++++++++++++-- history.txt | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 4de6b3d..981696a 100644 --- a/gui.js +++ b/gui.js @@ -64,11 +64,12 @@ standardSettings, Sound, BlockMorph, ToggleMorph, InputSlotDialogMorph, ScriptsMorph, isNil, SymbolMorph, BlockExportDialogMorph, BlockImportDialogMorph, SnapTranslator, localize, List, InputSlotMorph, SnapCloud, Uint8Array, HandleMorph, SVG_Costume, fontHeight, hex_sha512, -sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph, Audio*/ +sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph, Audio, +SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2014-May-20'; +modules.gui = '2014-May-26'; // Declarations @@ -4533,6 +4534,17 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { myself.preview.texture = item.Thumbnail || null; myself.preview.cachedTexture = null; myself.preview.drawNew(); + (new SpeechBubbleMorph(new TextMorph( + localize('last changed') + '\n' + item.Updated, + null, + null, + null, + null, + 'center' + ))).popUp( + myself.world(), + myself.preview.rightCenter().add(new Point(2, 0)) + ); } if (item.Public === 'true') { myself.shareButton.hide(); diff --git a/history.txt b/history.txt index 8155285..bd4d9fe 100755 --- a/history.txt +++ b/history.txt @@ -2138,3 +2138,4 @@ ______ ------ * Objects: Fixed #445 (minor search + zoom issues) * Localization additions and Portuguese translation update, thanks, Manuel! +* GUI, cloud: Show last-changed-timestamp when opening cloud projects -- cgit v1.3.1 From e1b97b98df9219865d08566bb10309603a9b12fe Mon Sep 17 00:00:00 2001 From: yuan Date: Tue, 27 May 2014 00:57:19 -0700 Subject: added graphics effects that work for all redraws; incorporated most recent updates to Snap! --- blocks.js | 16 +++----- objects.js | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 138 insertions(+), 14 deletions(-) diff --git a/blocks.js b/blocks.js index 69ae610..da5e929 100644 --- a/blocks.js +++ b/blocks.js @@ -913,16 +913,12 @@ 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 ); diff --git a/objects.js b/objects.js index 5f91606..b1e2892 100644 --- a/objects.js +++ b/objects.js @@ -1297,6 +1297,19 @@ SpriteMorph.prototype.init = function (globals) { this.isDraggable = true; this.isDown = false; + this.graphicsValues = { 'color': 0, //dictionary of all the orignal values + 'fisheye': 0, + 'whirl': 0, + 'pixelate': 0, + 'mosaic': 0, + 'brightness': 0, + 'negative': 0, + 'comic': 0, + 'duplicate': 0, + 'confetti': 0 + }; + this.graphicsChanged = false; + this.heading = 90; this.changed(); this.drawNew(); @@ -1421,6 +1434,9 @@ SpriteMorph.prototype.drawNew = function () { ctx.rotate(radians(facing - 90)); ctx.drawImage(pic.contents, 0, 0); + // apply graphics effects to image + this.image = this.applyGraphicsEffects(this.image); + // adjust my position to the rotation this.setCenter(currentCenter, true); // just me @@ -1443,6 +1459,7 @@ SpriteMorph.prototype.drawNew = function () { this.setCenter(currentCenter, true); // just me SpriteMorph.uber.drawNew.call(this, facing); this.rotationOffset = this.extent().divideBy(2); + this.image = this.applyGraphicsEffects(this.image); if (isLoadingCostume) { // retry until costume is done loading cst = this.costume; handle = setInterval( @@ -2833,12 +2850,118 @@ SpriteMorph.prototype.changeScale = function (delta) { // SpriteMorph graphic effects +SpriteMorph.prototype.applyGraphicsEffects = function (canvas) { +// For every effect: apply transform of that effect(canvas, stored value) +// The future: write more effects here + + function transform_negative(p, value) { + if (value !== 0) { + for (i = 0; i < p.length; i = i + 4) { + var rcom = 255 - p[i + 0] + var gcom = 255 - p[i + 1] + var bcom = 255 - p[i + 2] + + if (p[i + 0] < rcom) { //check if current number less than the complement. if so, then + p[i + 0] = p[i + 0] + value + } else if (p[i + 0] > rcom) { + p[i + 0] = p[i + 0] - value //or else decrease towards it + } + if (p[i + 1] < gcom) { + p[i + 1] = p[i + 1] + value + } else if (p[i + 1] > gcom) { + p[i + 1] = p[i + 1] - value + } + if (p[i + 2] < bcom) { + p[i + 2] = p[i + 2] + value + } else if (p[i + 2] > bcom) { + p[i + 2] = p[i + 2] - value + }; + }; + }; + return p; + }; + + function transform_brightness(p, value) { + if (value !== 0) { + for (i = 0; i < p.length; i += 4) { + p[i+0] = p[i+0] + value; //255 = 100% of this color. 255 everything = white. + p[i+1] = p[i+1] + value; //if value is negative, add more value to p. if value is positive, subtract value from p + p[i+2] = p[i+2] + value; + p[i+3] = p[i+3]; + }; + }; + return p; + }; + + function transform_comic(p, value) { + if (value !== 0) { + for (i = 0; i < p.length; i += 4) { + var frequency = value; + p[i + 0] = p[i + 0] + Math.sin(i * frequency) * 127 + 128 + p[i + 1] = p[i + 1] + Math.sin(i * frequency) * 127 + 128 + p[i + 2] = p[i + 2] + Math.sin(i * frequency) * 127 + 128 + p[i + 3] = p[i + 3]; + }; + }; + return p; + }; + + function transform_duplicate(p, value) { + if (value !== 0) { + for (i = 0; i < p.length; i += 4) { + p[i + 0] = p[i * value + 0] + p[i + 1] = p[i * value + 1] + p[i + 2] = p[i * value + 2] + p[i + 3] = p[i * value + 3]; + }; + }; + return p; + }; + + function transform_confetti(p, value) { + if (value !== 0) { + for (i = 0; i < p.length; i++) { + p[i] = Math.sin(value * p[i]) * 127 + p[i] + }; + }; + return p; + }; + + if (this.graphicsChanged) { + ctx = canvas.getContext("2d"); + imagedata = ctx.getImageData(0, 0, canvas.width, canvas.height); + pixels = imagedata.data; + + // for each effect, do a transform. at any given time, a sprite should wear all 7 effects + /*pixels = transform_whirl(pixels, this.graphicsValues['whirl']);*/ + pixels = transform_negative(pixels, this.graphicsValues['negative']); + pixels = transform_brightness(pixels, this.graphicsValues['brightness']); + pixels = transform_comic(pixels, this.graphicsValues['comic']); + /*pixels = transform_pixelate(pixels, this.graphicsValues['pixelate']);*/ + pixels = transform_duplicate(pixels, this.graphicsValues['duplicate']); + /*pixels = transform_color(pixels, this.graphicsValues['color']);*/ + /*pixels = transform_fisheye(pixels, this.graphicsValues['fisheye']);*/ + pixels = transform_confetti(pixels, this.graphicsValues['confetti']); + + //the last object will have all the transformations done on it + newimagedata = ctx.createImageData(imagedata); //make new imgdata object + newimagedata.data.set(pixels); //add transformed pixels + ctx.putImageData(newimagedata, 0, 0); + }; + + return canvas; //for each effect, apply the transformation on the image we receive +}; + SpriteMorph.prototype.setEffect = function (effect, value) { var eff = effect instanceof Array ? effect[0] : null; if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100; - this.changed(); - } + } else { + this.graphicsValues[eff] = value; + }; + this.graphicsChanged = true; + this.drawNew(); + this.changed(); }; SpriteMorph.prototype.getGhostEffect = function () { @@ -2848,11 +2971,16 @@ SpriteMorph.prototype.getGhostEffect = function () { SpriteMorph.prototype.changeEffect = function (effect, value) { var eff = effect instanceof Array ? effect[0] : null; if (eff === 'ghost') { - this.setEffect(effect, this.getGhostEffect() + (+value || 0)); - } + this.setEffect(effect, this.getGhostEffect() + (+value || 0)); //special for ghost because its value is the alpha value + } else { + this.setEffect(effect, this.graphicsValues[eff] + value); + }; }; SpriteMorph.prototype.clearEffects = function () { + for (var effect in this.graphicsValues) { + this.setEffect([effect], 0); + }; this.setEffect(['ghost'], 0); }; -- cgit v1.3.1 From ab218322f3227a40e38b891be84b58ad49c82d74 Mon Sep 17 00:00:00 2001 From: yuan Date: Wed, 28 May 2014 02:38:04 -0700 Subject: changed graphicsChanged boolean to a function --- objects.js | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/objects.js b/objects.js index b1e2892..c0e7357 100644 --- a/objects.js +++ b/objects.js @@ -1292,23 +1292,22 @@ SpriteMorph.prototype.init = function (globals) { this.idx = 0; // not to be serialized (!) - used for de-serialization this.wasWarped = false; // not to be serialized, used for fast-tracking - SpriteMorph.uber.init.call(this); - - this.isDraggable = true; - this.isDown = false; - - this.graphicsValues = { 'color': 0, //dictionary of all the orignal values + this.graphicsValues = { 'negative': 0, //dictionary of all the orignal values 'fisheye': 0, 'whirl': 0, 'pixelate': 0, 'mosaic': 0, 'brightness': 0, - 'negative': 0, + 'color': 0, 'comic': 0, 'duplicate': 0, 'confetti': 0 }; - this.graphicsChanged = false; + + SpriteMorph.uber.init.call(this); + + this.isDraggable = true; + this.isDown = false; this.heading = 90; this.changed(); @@ -2848,7 +2847,16 @@ SpriteMorph.prototype.changeScale = function (delta) { this.setScale(this.getScale() + (+delta || 0)); }; -// SpriteMorph graphic effects +//spritemorph graphics effects + +SpriteMorph.prototype.graphicsChanged = function () { + var myself = this; + return Object.keys(this.graphicsValues).some( + function(any) { + return myself.graphicsValues[any] < 0 || myself.graphicsValues[any] > 0; + } + ); +}; SpriteMorph.prototype.applyGraphicsEffects = function (canvas) { // For every effect: apply transform of that effect(canvas, stored value) @@ -2927,7 +2935,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) { return p; }; - if (this.graphicsChanged) { + if (this.graphicsChanged()) { //operates image pixel manipulation if graphicschanged = true. ctx = canvas.getContext("2d"); imagedata = ctx.getImageData(0, 0, canvas.width, canvas.height); pixels = imagedata.data; @@ -2957,9 +2965,8 @@ SpriteMorph.prototype.setEffect = function (effect, value) { if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100; } else { - this.graphicsValues[eff] = value; + this.graphicsValues[eff] = value; //changes the value of the dictionary }; - this.graphicsChanged = true; this.drawNew(); this.changed(); }; @@ -4134,6 +4141,18 @@ StageMorph.prototype.init = function (globals) { this.trailsCanvas = null; this.isThreadSafe = false; + this.graphicsValues = { 'negative': 0, //dictionary of all the orignal values + 'fisheye': 0, + 'whirl': 0, + 'pixelate': 0, + 'mosaic': 0, + 'brightness': 0, + 'color': 0, + 'comic': 0, + 'duplicate': 0, + 'confetti': 0 + }; + StageMorph.uber.init.call(this); this.acceptsDrops = false; @@ -4189,8 +4208,8 @@ StageMorph.prototype.setScale = function (number) { StageMorph.prototype.drawNew = function () { var ctx; - StageMorph.uber.drawNew.call(this); - if (this.costume) { + StageMorph.uber.drawNew.call(this); //call drawNew from framemorph + if (this.costume) { //if it's wearing a costume ctx = this.image.getContext('2d'); ctx.scale(this.scale, this.scale); ctx.drawImage( -- cgit v1.3.1 From 94ad721bfe5f63e6545abf96ca6349977c6b06fd Mon Sep 17 00:00:00 2001 From: yuan Date: Wed, 28 May 2014 23:17:04 -0700 Subject: good to go for stagemorph --- objects.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/objects.js b/objects.js index c0e7357..5eb481c 100644 --- a/objects.js +++ b/objects.js @@ -1431,7 +1431,7 @@ SpriteMorph.prototype.drawNew = function () { ctx.scale(this.scale * stageScale, this.scale * stageScale); ctx.translate(shift.x, shift.y); ctx.rotate(radians(facing - 90)); - ctx.drawImage(pic.contents, 0, 0); + ctx.drawImage(pic.contents, 0, 0); // apply graphics effects to image this.image = this.applyGraphicsEffects(this.image); @@ -2978,7 +2978,7 @@ SpriteMorph.prototype.getGhostEffect = function () { SpriteMorph.prototype.changeEffect = function (effect, value) { var eff = effect instanceof Array ? effect[0] : null; if (eff === 'ghost') { - this.setEffect(effect, this.getGhostEffect() + (+value || 0)); //special for ghost because its value is the alpha value + this.setEffect(effect, this.getGhostEffect() + (+value || 0)); //special for ghost because of alpha value } else { this.setEffect(effect, this.graphicsValues[eff] + value); }; @@ -4141,7 +4141,7 @@ StageMorph.prototype.init = function (globals) { this.trailsCanvas = null; this.isThreadSafe = false; - this.graphicsValues = { 'negative': 0, //dictionary of all the orignal values + this.graphicsValues = { 'negative': 0, //dictionary of all the original values 'fisheye': 0, 'whirl': 0, 'pixelate': 0, @@ -4208,15 +4208,16 @@ StageMorph.prototype.setScale = function (number) { StageMorph.prototype.drawNew = function () { var ctx; - StageMorph.uber.drawNew.call(this); //call drawNew from framemorph - if (this.costume) { //if it's wearing a costume + StageMorph.uber.drawNew.call(this); + if (this.costume) { //if wearing a costume ctx = this.image.getContext('2d'); ctx.scale(this.scale, this.scale); - ctx.drawImage( - this.costume.contents, - (this.width() / this.scale - this.costume.width()) / 2, - (this.height() / this.scale - this.costume.height()) / 2 + ctx.drawImage( //drawimage on this new 2d canvas with these inputs: image, x and y + this.costume.contents, //this is the image + (this.width() / this.scale - this.costume.width()) / 2, //width = canvas wdith - costume width/2 + (this.height() / this.scale - this.costume.height()) / 2 //this is the y ); + this.image = this.applyGraphicsEffects(this.image) //apply graphics effects to this image. } }; @@ -5240,6 +5241,12 @@ StageMorph.prototype.reportCostumes // StageMorph graphic effects +StageMorph.prototype.graphicsChanged + = SpriteMorph.prototype.graphicsChanged; + +StageMorph.prototype.applyGraphicsEffects + = SpriteMorph.prototype.applyGraphicsEffects; + StageMorph.prototype.setEffect = SpriteMorph.prototype.setEffect; -- cgit v1.3.1 From 8971d29adc0fbcb75b60dd58c3043c8eb2e150a1 Mon Sep 17 00:00:00 2001 From: yuan Date: Wed, 28 May 2014 23:45:43 -0700 Subject: cleaned up my comments --- objects.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/objects.js b/objects.js index 5eb481c..7d6ce14 100644 --- a/objects.js +++ b/objects.js @@ -2847,7 +2847,7 @@ SpriteMorph.prototype.changeScale = function (delta) { this.setScale(this.getScale() + (+delta || 0)); }; -//spritemorph graphics effects +// Spritemorph graphics effects SpriteMorph.prototype.graphicsChanged = function () { var myself = this; @@ -4209,13 +4209,13 @@ StageMorph.prototype.setScale = function (number) { StageMorph.prototype.drawNew = function () { var ctx; StageMorph.uber.drawNew.call(this); - if (this.costume) { //if wearing a costume + if (this.costume) { ctx = this.image.getContext('2d'); ctx.scale(this.scale, this.scale); - ctx.drawImage( //drawimage on this new 2d canvas with these inputs: image, x and y - this.costume.contents, //this is the image - (this.width() / this.scale - this.costume.width()) / 2, //width = canvas wdith - costume width/2 - (this.height() / this.scale - this.costume.height()) / 2 //this is the y + ctx.drawImage( + this.costume.contents, + (this.width() / this.scale - this.costume.width()) / 2, + (this.height() / this.scale - this.costume.height()) / 2 ); this.image = this.applyGraphicsEffects(this.image) //apply graphics effects to this image. } -- cgit v1.3.1 From e7f9ff5dcbac3459c9ab111aea3e4096467d5ea5 Mon Sep 17 00:00:00 2001 From: yuan Date: Mon, 2 Jun 2014 00:07:00 -0700 Subject: JSLinted --- blocks.js | 4 +- objects.js | 183 ++++++++++++++++++++++++++++++++----------------------------- 2 files changed, 97 insertions(+), 90 deletions(-) diff --git a/blocks.js b/blocks.js index da5e929..65ab90b 100644 --- a/blocks.js +++ b/blocks.js @@ -918,8 +918,8 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { negative : ['negative'], comic: ['comic'], duplicate: ['duplicate'], - confetti: ['confetti'], - }, + confetti: ['confetti'] + }, true ); part.setContents(['ghost']); diff --git a/objects.js b/objects.js index 7d6ce14..81ce072 100644 --- a/objects.js +++ b/objects.js @@ -1292,11 +1292,11 @@ SpriteMorph.prototype.init = function (globals) { this.idx = 0; // not to be serialized (!) - used for de-serialization this.wasWarped = false; // not to be serialized, used for fast-tracking - this.graphicsValues = { 'negative': 0, //dictionary of all the orignal values - 'fisheye': 0, - 'whirl': 0, - 'pixelate': 0, - 'mosaic': 0, + this.graphicsValues = { 'negative': 0, + 'fisheye': 0, + 'whirl': 0, + 'pixelate': 0, + 'mosaic': 0, 'brightness': 0, 'color': 0, 'comic': 0, @@ -1431,7 +1431,7 @@ SpriteMorph.prototype.drawNew = function () { ctx.scale(this.scale * stageScale, this.scale * stageScale); ctx.translate(shift.x, shift.y); ctx.rotate(radians(facing - 90)); - ctx.drawImage(pic.contents, 0, 0); + ctx.drawImage(pic.contents, 0, 0); // apply graphics effects to image this.image = this.applyGraphicsEffects(this.image); @@ -2847,13 +2847,14 @@ SpriteMorph.prototype.changeScale = function (delta) { this.setScale(this.getScale() + (+delta || 0)); }; -// Spritemorph graphics effects +// Spritemorph graphic effects SpriteMorph.prototype.graphicsChanged = function () { var myself = this; return Object.keys(this.graphicsValues).some( - function(any) { - return myself.graphicsValues[any] < 0 || myself.graphicsValues[any] > 0; + function (any) { + return myself.graphicsValues[any] < 0 || + myself.graphicsValues[any] > 0; } ); }; @@ -2861,103 +2862,106 @@ SpriteMorph.prototype.graphicsChanged = function () { SpriteMorph.prototype.applyGraphicsEffects = function (canvas) { // For every effect: apply transform of that effect(canvas, stored value) // The future: write more effects here + var ctx, imagedata, pixels, newimagedata; function transform_negative(p, value) { + var i, rcom, gcom, bcom; if (value !== 0) { - for (i = 0; i < p.length; i = i + 4) { - var rcom = 255 - p[i + 0] - var gcom = 255 - p[i + 1] - var bcom = 255 - p[i + 2] - - if (p[i + 0] < rcom) { //check if current number less than the complement. if so, then - p[i + 0] = p[i + 0] + value - } else if (p[i + 0] > rcom) { - p[i + 0] = p[i + 0] - value //or else decrease towards it + for (i = 0; i < p.length; i += 4) { + rcom = 255 - p[i]; + gcom = 255 - p[i + 1]; + bcom = 255 - p[i + 2]; + + if (p[i] < rcom) { //compare to the complement + p[i] += value; + } else if (p[i] > rcom) { + p[i] -= value; } if (p[i + 1] < gcom) { - p[i + 1] = p[i + 1] + value + p[i + 1] += value; } else if (p[i + 1] > gcom) { - p[i + 1] = p[i + 1] - value + p[i + 1] -= value; } if (p[i + 2] < bcom) { - p[i + 2] = p[i + 2] + value + p[i + 2] += value; } else if (p[i + 2] > bcom) { - p[i + 2] = p[i + 2] - value - }; - }; - }; + p[i + 2] -= value; + } + } + } return p; - }; + } function transform_brightness(p, value) { + var i; if (value !== 0) { for (i = 0; i < p.length; i += 4) { - p[i+0] = p[i+0] + value; //255 = 100% of this color. 255 everything = white. - p[i+1] = p[i+1] + value; //if value is negative, add more value to p. if value is positive, subtract value from p - p[i+2] = p[i+2] + value; - p[i+3] = p[i+3]; - }; - }; + p[i] += value; //255 = 100% of this color + p[i + 1] += value; + p[i + 2] += value; + } + } return p; - }; + } function transform_comic(p, value) { + var i; if (value !== 0) { for (i = 0; i < p.length; i += 4) { - var frequency = value; - p[i + 0] = p[i + 0] + Math.sin(i * frequency) * 127 + 128 - p[i + 1] = p[i + 1] + Math.sin(i * frequency) * 127 + 128 - p[i + 2] = p[i + 2] + Math.sin(i * frequency) * 127 + 128 - p[i + 3] = p[i + 3]; - }; - }; - return p; - }; + p[i] += Math.sin(i * value) * 127 + 128; + p[i + 1] += Math.sin(i * value) * 127 + 128; + p[i + 2] += Math.sin(i * value) * 127 + 128; + } + } + return p; + } function transform_duplicate(p, value) { + var i; if (value !== 0) { for (i = 0; i < p.length; i += 4) { - p[i + 0] = p[i * value + 0] - p[i + 1] = p[i * value + 1] - p[i + 2] = p[i * value + 2] + p[i] = p[i * value]; + p[i + 1] = p[i * value + 1]; + p[i + 2] = p[i * value + 2]; p[i + 3] = p[i * value + 3]; - }; - }; + } + } return p; - }; + } function transform_confetti(p, value) { + var i; if (value !== 0) { - for (i = 0; i < p.length; i++) { - p[i] = Math.sin(value * p[i]) * 127 + p[i] - }; - }; + for (i = 0; i < p.length; i += 1) { + p[i] = Math.sin(value * p[i]) * 127 + p[i]; + } + } return p; - }; + } - if (this.graphicsChanged()) { //operates image pixel manipulation if graphicschanged = true. - ctx = canvas.getContext("2d"); + if (this.graphicsChanged()) { + ctx = canvas.getContext("2d"); imagedata = ctx.getImageData(0, 0, canvas.width, canvas.height); pixels = imagedata.data; - // for each effect, do a transform. at any given time, a sprite should wear all 7 effects - /*pixels = transform_whirl(pixels, this.graphicsValues['whirl']);*/ - pixels = transform_negative(pixels, this.graphicsValues['negative']); - pixels = transform_brightness(pixels, this.graphicsValues['brightness']); - pixels = transform_comic(pixels, this.graphicsValues['comic']); - /*pixels = transform_pixelate(pixels, this.graphicsValues['pixelate']);*/ - pixels = transform_duplicate(pixels, this.graphicsValues['duplicate']); - /*pixels = transform_color(pixels, this.graphicsValues['color']);*/ - /*pixels = transform_fisheye(pixels, this.graphicsValues['fisheye']);*/ - pixels = transform_confetti(pixels, this.graphicsValues['confetti']); - + //A sprite should wear all 7 effects at once + /*pixels = transform_whirl(pixels, this.graphicsValues.whirl);*/ + pixels = transform_negative(pixels, this.graphicsValues.negative); + pixels = transform_brightness(pixels, this.graphicsValues.brightness); + pixels = transform_comic(pixels, this.graphicsValues.comic); + /*pixels = transform_pixelate(pixels, this.graphicsValues.pixelate);*/ + pixels = transform_duplicate(pixels, this.graphicsValues.duplicate); + /*pixels = transform_color(pixels, this.graphicsValues.color);*/ + /*pixels = transform_fisheye(pixels, this.graphicsValues.fisheye);*/ + pixels = transform_confetti(pixels, this.graphicsValues.confetti); + //the last object will have all the transformations done on it - newimagedata = ctx.createImageData(imagedata); //make new imgdata object - newimagedata.data.set(pixels); //add transformed pixels + newimagedata = ctx.createImageData(imagedata); //make imgdata object + newimagedata.data.set(pixels); //add transformed pixels ctx.putImageData(newimagedata, 0, 0); - }; + } - return canvas; //for each effect, apply the transformation on the image we receive + return canvas; }; SpriteMorph.prototype.setEffect = function (effect, value) { @@ -2965,8 +2969,8 @@ SpriteMorph.prototype.setEffect = function (effect, value) { if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100; } else { - this.graphicsValues[eff] = value; //changes the value of the dictionary - }; + this.graphicsValues[eff] = value; + } this.drawNew(); this.changed(); }; @@ -2978,16 +2982,19 @@ SpriteMorph.prototype.getGhostEffect = function () { SpriteMorph.prototype.changeEffect = function (effect, value) { var eff = effect instanceof Array ? effect[0] : null; if (eff === 'ghost') { - this.setEffect(effect, this.getGhostEffect() + (+value || 0)); //special for ghost because of alpha value + this.setEffect(effect, this.getGhostEffect() + (+value || 0)); } else { this.setEffect(effect, this.graphicsValues[eff] + value); - }; + } }; SpriteMorph.prototype.clearEffects = function () { - for (var effect in this.graphicsValues) { - this.setEffect([effect], 0); - }; + var effect; + for (effect in this.graphicsValues) { + if (this.graphicsValues.hasOwnProperty(effect)) { + this.setEffect([effect], 0); + } + } this.setEffect(['ghost'], 0); }; @@ -4141,17 +4148,17 @@ StageMorph.prototype.init = function (globals) { this.trailsCanvas = null; this.isThreadSafe = false; - this.graphicsValues = { 'negative': 0, //dictionary of all the original values - 'fisheye': 0, - 'whirl': 0, - 'pixelate': 0, - 'mosaic': 0, + this.graphicsValues = { 'negative': 0, + 'fisheye': 0, + 'whirl': 0, + 'pixelate': 0, + 'mosaic': 0, 'brightness': 0, 'color': 0, 'comic': 0, 'duplicate': 0, 'confetti': 0 - }; + }; StageMorph.uber.init.call(this); @@ -4209,15 +4216,15 @@ StageMorph.prototype.setScale = function (number) { StageMorph.prototype.drawNew = function () { var ctx; StageMorph.uber.drawNew.call(this); - if (this.costume) { + if (this.costume) { ctx = this.image.getContext('2d'); ctx.scale(this.scale, this.scale); - ctx.drawImage( - this.costume.contents, + ctx.drawImage( + this.costume.contents, (this.width() / this.scale - this.costume.width()) / 2, - (this.height() / this.scale - this.costume.height()) / 2 + (this.height() / this.scale - this.costume.height()) / 2 ); - this.image = this.applyGraphicsEffects(this.image) //apply graphics effects to this image. + this.image = this.applyGraphicsEffects(this.image); } }; -- cgit v1.3.1 From 64a1636736e5b535996deddfddf9d0318e1f56e2 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Mon, 2 Jun 2014 15:20:33 -0400 Subject: Fixed loading blank inputs --- store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store.js b/store.js index e143245..e448f74 100644 --- a/store.js +++ b/store.js @@ -1032,7 +1032,7 @@ SnapSerializer.prototype.loadInput = function (model, input, block) { input.setColor(this.loadColor(model.contents)); } else { val = this.loadValue(model); - if (val) { + if (val !== undefined && val !== null && input.setContents) { input.setContents(this.loadValue(model)); } } -- cgit v1.3.1 From ee695213cfe947f0dc69de9c640879da96582ddd Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Mon, 2 Jun 2014 15:55:28 -0400 Subject: Fixed ctrl/cmd+shift+s saving the project in place --- objects.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/objects.js b/objects.js index 5f91606..f48b13a 100644 --- a/objects.js +++ b/objects.js @@ -4395,7 +4395,7 @@ StageMorph.prototype.processKeyEvent = function (event, action) { default: keyName = String.fromCharCode(event.keyCode || event.charCode); if (event.ctrlKey || event.metaKey) { - keyName = 'ctrl ' + keyName; + keyName = 'ctrl ' + (event.shiftKey ? 'shift ' : '') + keyName; } } action.call(this, keyName); @@ -4420,6 +4420,9 @@ StageMorph.prototype.fireKeyEvent = function (key) { if (evt === 'ctrl s') { return this.parentThatIsA(IDE_Morph).save(); } + if (evt === 'ctrl shift s') { + return this.parentThatIsA(IDE_Morph).saveProjectsBrowser(); + } if (evt === 'esc') { return this.fireStopAllEvent(); } -- cgit v1.3.1 From 2710f5b30777d356382763d0b4d30f3472e5b951 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Mon, 2 Jun 2014 15:53:12 -0400 Subject: Fixed the equals block when one list is linked and the other is not --- lists.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lists.js b/lists.js index 3166bf1..13ec880 100644 --- a/lists.js +++ b/lists.js @@ -305,7 +305,7 @@ List.prototype.equalTo = function (other) { if (this.length() !== other.length()) { return false; } - for (i = 0; i < this.length(); i += 1) { + for (i = 1; i <= this.length(); i += 1) { if (!snapEquals(this.at(i), other.at(i))) { return false; } -- cgit v1.3.1 From 6d9ce7b61c61ff737133dd3490c6caf854793f04 Mon Sep 17 00:00:00 2001 From: Hardmath123 Date: Tue, 3 Jun 2014 15:28:07 -0700 Subject: Added scaling and flipping --- paint.js | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/paint.js b/paint.js index ee40b23..12f4f82 100644 --- a/paint.js +++ b/paint.js @@ -3,12 +3,12 @@ a paint editor for Snap! inspired by the Scratch paint editor. - + written by Kartik Chandra Copyright (C) 2014 by Kartik Chandra - + This file is part of Snap!. - + Snap! is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of @@ -133,6 +133,10 @@ PaintEditorMorph.prototype.buildContents = function () { this.buildToolbox(); this.controls.add(this.toolbox); + this.scaleBox = new AlignmentMorph('row', this.padding); + this.buildScaleBox(); + this.controls.add(this.scaleBox); + this.propertiesControls = { colorpicker: null, penSizeSlider: null, @@ -218,6 +222,27 @@ PaintEditorMorph.prototype.buildEdits = function () { this.edits.fixLayout(); }; +PaintEditorMorph.prototype.buildScaleBox = function () { + var paper = this.paper; + this.scaleBox.add(this.pushButton( + "grow", + function () {paper.scale(0.05, 0.05); } + )); + this.scaleBox.add(this.pushButton( + "shrink", + function () {paper.scale(-0.05, -0.05); } + )); + this.scaleBox.add(this.pushButton( + "flipX", + function () {paper.scale(-2, 0); } + )); + this.scaleBox.add(this.pushButton( + "flipY", + function () {paper.scale(0, -2); } + )); + this.scaleBox.fixLayout(); +}; + PaintEditorMorph.prototype.openIn = function (world, oldim, oldrc, callback) { // Open the editor in a world with an optional image to edit this.oldim = oldim; @@ -558,6 +583,19 @@ PaintCanvasMorph.prototype.init = function (shift) { this.buildContents(); }; +PaintCanvasMorph.prototype.scale = function(x, y) { + this.mask = newCanvas(this.extent()); + var c = newCanvas(this.extent()); + c.getContext("2d").save(); + c.getContext("2d").translate(this.rotationCenter.x, this.rotationCenter.y); + c.getContext("2d").scale(1 + x, 1 + y); + c.getContext("2d").drawImage(this.paper, -this.rotationCenter.x, -this.rotationCenter.y); + c.getContext("2d").restore(); + this.paper = c; + this.drawNew(); + this.changed(); +}; + PaintCanvasMorph.prototype.cacheUndo = function () { var cachecan = newCanvas(this.extent()); this.merge(this.paper, cachecan); -- cgit v1.3.1 From f5fca5418765f1783e056de82072351d144adb50 Mon Sep 17 00:00:00 2001 From: Hardmath123 Date: Tue, 3 Jun 2014 15:32:41 -0700 Subject: Docs, symbols --- paint.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/paint.js b/paint.js index 12f4f82..d4d2954 100644 --- a/paint.js +++ b/paint.js @@ -53,6 +53,7 @@ Jan 08 - mouse leave dragging fix (Kartik) Feb 11 - dynamically adjust to stage dimensions (Jens) Apr 30 - localizations (Manuel) + June 3 - transformations (Kartik) */ @@ -66,7 +67,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-May-02'; +modules.paint = '2014-June-3'; // Declarations @@ -233,11 +234,11 @@ PaintEditorMorph.prototype.buildScaleBox = function () { function () {paper.scale(-0.05, -0.05); } )); this.scaleBox.add(this.pushButton( - "flipX", + "flip ↔", function () {paper.scale(-2, 0); } )); this.scaleBox.add(this.pushButton( - "flipY", + "flip ↕", function () {paper.scale(0, -2); } )); this.scaleBox.fixLayout(); -- cgit v1.3.1 From ef3997cccf833aebd3d5d3fbecfdc2c13dab9631 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Jun 2014 12:39:28 +0200 Subject: Blocks: refactor “script pics” feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blocks.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/blocks.js b/blocks.js index 69ae610..3e8aa60 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-May-02'; +modules.blocks = '2014-June-04'; var SyntaxElementMorph; @@ -4957,6 +4957,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 +4985,7 @@ ScriptsMorph.prototype.exportScriptsPicture = function () { ); } }); - window.open(pic.toDataURL()); + return pic; }; ScriptsMorph.prototype.addComment = function () { -- cgit v1.3.1 From 50203901eaac7f4ed277bb8ab981037dcc28687f Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Jun 2014 12:40:03 +0200 Subject: BYOB: new scriptsPicture() method for custom block definitions --- byob.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/byob.js b/byob.js index 6a10110..0f79acf 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2014-May-02'; +modules.byob = '2014-Jun-04'; // Declarations @@ -336,6 +336,43 @@ CustomBlockDefinition.prototype.parseSpec = function (spec) { return parts; }; +// CustomBlockDefinition picturing + +CustomBlockDefinition.prototype.scriptsPicture = function () { + var scripts, proto, block, comment; + + scripts = new ScriptsMorph(); + scripts.cleanUpMargin = 10; + proto = new PrototypeHatBlockMorph(this); + proto.setPosition(scripts.position().add(10)); + if (this.comment !== null) { + comment = this.comment.fullCopy(); + proto.comment = comment; + comment.block = proto; + } + if (this.body !== null) { + proto.nextBlock(this.body.expression.fullCopy()); + } + scripts.add(proto); + proto.fixBlockColor(null, true); + this.scripts.forEach(function (element) { + block = element.fullCopy(); + block.setPosition(scripts.position().add(element.position())); + scripts.add(block); + if (block instanceof BlockMorph) { + block.allComments().forEach(function (comment) { + comment.align(block); + }); + } + }); + proto.allComments().forEach(function (comment) { + comment.align(proto); + }); + proto.children[0].fixLayout(); + scripts.fixMultiArgs(); + return scripts.scriptsPicture(); +}; + // CustomCommandBlockMorph ///////////////////////////////////////////// // CustomCommandBlockMorph inherits from CommandBlockMorph: -- cgit v1.3.1 From bae41fde2870706b200aa9ec2b0e00ca5ceb59d9 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Jun 2014 12:40:44 +0200 Subject: GUI: new (hidden) feature: “Export all scripts as pic” MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (including custom block refs) --- gui.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- history.txt | 6 ++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/gui.js b/gui.js index 981696a..67510cf 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2014-May-26'; +modules.gui = '2014-Jun-04'; // Declarations @@ -2350,6 +2350,15 @@ IDE_Morph.prototype.projectMenu = function () { '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.addItem( 'Import tools', @@ -2847,6 +2856,56 @@ IDE_Morph.prototype.exportSprite = function (sprite) { + ''); }; +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) { var msg, myself = this; diff --git a/history.txt b/history.txt index bd4d9fe..a72aa2c 100755 --- a/history.txt +++ b/history.txt @@ -2139,3 +2139,9 @@ ______ * Objects: Fixed #445 (minor search + zoom issues) * Localization additions and Portuguese translation update, thanks, Manuel! * 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) -- cgit v1.3.1 From ac39877b9c7f2cfadfca581fc98fe3b6a3c434fb Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Jun 2014 13:48:43 +0200 Subject: German translation update, tweaks --- gui.js | 1 + history.txt | 3 +++ lang-de.js | 10 +++++++++- lists.js | 2 +- locale.js | 4 ++-- objects.js | 3 ++- store.js | 4 ++-- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/gui.js b/gui.js index 67510cf..d12453b 100644 --- a/gui.js +++ b/gui.js @@ -2535,6 +2535,7 @@ IDE_Morph.prototype.aboutSnap = function () { + '\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, ' + 'countless bugfixes' + '\nKartik Chandra: Paint Editor' + + '\nYuan Yuan: Graphic Effects' + '\nIan Reynolds: UI Design, Event Bindings, ' + 'Sound primitives' + '\nIvan Motyashov: Initial Squeak Porting' diff --git a/history.txt b/history.txt index a72aa2c..a6b3276 100755 --- a/history.txt +++ b/history.txt @@ -2145,3 +2145,6 @@ ______ * 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) +* Graphic effects!!! Yay, thanks, Yuan! +* Bug fixes from Nathan, yay, thank, Nathan!! +* German translation update diff --git a/lang-de.js b/lang-de.js index 9ce0c50..0a62da0 100644 --- a/lang-de.js +++ b/lang-de.js @@ -185,7 +185,7 @@ SnapTranslator.dict.de = { 'translator_e-mail': 'jens@moenig.org', // optional 'last_changed': - '2014-02-13', // this, too, will appear in the Translators tab + '2014-06-04', // this, too, will appear in the Translators tab // GUI // control bar: @@ -1122,8 +1122,16 @@ SnapTranslator.dict.de = { 'Leer', // graphical effects + 'brightness': + 'Helligeit', 'ghost': 'Durchsichtigkeit', + 'negative': + 'Farbumkehr', + 'comic': + 'Moire', + 'confetti': + 'Farbverschiebung', // keys 'space': diff --git a/lists.js b/lists.js index 13ec880..ea553b0 100644 --- a/lists.js +++ b/lists.js @@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph, StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, MorphicPreferences*/ -modules.lists = '2014-January-09'; +modules.lists = '2014-Jun-04'; var List; var ListWatcherMorph; diff --git a/locale.js b/locale.js index c10aa64..614b38c 100644 --- a/locale.js +++ b/locale.js @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2014-May-26'; +modules.locale = '2014-Jun-04'; // Global stuff @@ -149,7 +149,7 @@ SnapTranslator.dict.de = { 'translator_e-mail': 'jens@moenig.org', 'last_changed': - '2014-02-13' + '2014-06-04' }; SnapTranslator.dict.it = { diff --git a/objects.js b/objects.js index cc4371b..dc02051 100644 --- a/objects.js +++ b/objects.js @@ -61,6 +61,7 @@ sound handling Achal Dave contributed research and prototyping for creating music using the Web Audio API + Yuan Yuan contributed graphic effects for costumes */ @@ -124,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-May-26'; +modules.objects = '2014-Jun-04'; var SpriteMorph; var StageMorph; diff --git a/store.js b/store.js index e448f74..11e2757 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2014-May-02'; +modules.store = '2014-Jun-04'; // XML_Serializer /////////////////////////////////////////////////////// @@ -1032,7 +1032,7 @@ SnapSerializer.prototype.loadInput = function (model, input, block) { input.setColor(this.loadColor(model.contents)); } else { val = this.loadValue(model); - if (val !== undefined && val !== null && input.setContents) { + if (!isNil(val) && input.setContents) { input.setContents(this.loadValue(model)); } } -- cgit v1.3.1 From ef140b093ebb61d37235ce7f4baf5fd4c0baf01d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Jun 2014 14:16:57 +0200 Subject: Paint Editor transform integration - little tweaks Thanks, Kartik!! --- history.txt | 3 ++- paint.js | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/history.txt b/history.txt index a6b3276..72a34a6 100755 --- a/history.txt +++ b/history.txt @@ -2146,5 +2146,6 @@ ______ * BYOB: new scriptsPicture() method for custom block definitions * GUI: new (hidden) feature: “Export all scripts as pic” (including custom block refs) * Graphic effects!!! Yay, thanks, Yuan! -* Bug fixes from Nathan, yay, thank, Nathan!! +* Bug fixes from Nathan, yay, thanks, Nathan!! * German translation update +* Paint Editor transforms, yay, thanks, Kartik!! diff --git a/paint.js b/paint.js index d4d2954..7105b72 100644 --- a/paint.js +++ b/paint.js @@ -54,6 +54,7 @@ Feb 11 - dynamically adjust to stage dimensions (Jens) Apr 30 - localizations (Manuel) June 3 - transformations (Kartik) + June 4 - tweaks (Jens) */ @@ -67,7 +68,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-June-3'; +modules.paint = '2014-June-4'; // Declarations @@ -112,10 +113,10 @@ PaintEditorMorph.prototype.buildContents = function () { this.paper.setExtent(StageMorph.prototype.dimensions); this.addBody(new AlignmentMorph('row', this.padding)); - this.controls = new AlignmentMorph('column', this.padding); + this.controls = new AlignmentMorph('column', this.padding / 2); this.controls.alignment = 'left'; - this.edits = new AlignmentMorph('row', this.padding); + this.edits = new AlignmentMorph('row', this.padding / 2); this.buildEdits(); this.controls.add(this.edits); @@ -134,7 +135,7 @@ PaintEditorMorph.prototype.buildContents = function () { this.buildToolbox(); this.controls.add(this.toolbox); - this.scaleBox = new AlignmentMorph('row', this.padding); + this.scaleBox = new AlignmentMorph('row', this.padding / 2); this.buildScaleBox(); this.controls.add(this.scaleBox); @@ -584,13 +585,20 @@ PaintCanvasMorph.prototype.init = function (shift) { this.buildContents(); }; -PaintCanvasMorph.prototype.scale = function(x, y) { +PaintCanvasMorph.prototype.scale = function (x, y) { this.mask = newCanvas(this.extent()); var c = newCanvas(this.extent()); c.getContext("2d").save(); - c.getContext("2d").translate(this.rotationCenter.x, this.rotationCenter.y); + c.getContext("2d").translate( + this.rotationCenter.x, + this.rotationCenter.y + ); c.getContext("2d").scale(1 + x, 1 + y); - c.getContext("2d").drawImage(this.paper, -this.rotationCenter.x, -this.rotationCenter.y); + c.getContext("2d").drawImage( + this.paper, + -this.rotationCenter.x, + -this.rotationCenter.y + ); c.getContext("2d").restore(); this.paper = c; this.drawNew(); -- cgit v1.3.1 From c09c4c2b306a36a8471480d07cbb7645bbdc6a66 Mon Sep 17 00:00:00 2001 From: Manuel Menezes de Sequeira Date: Wed, 4 Jun 2014 15:41:13 +0100 Subject: Add Portuguese translation of graphic effects, costume transformations, and exporting of scripts as pic. --- lang-pt.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lang-pt.js b/lang-pt.js index 226abf5..d28c290 100755 --- a/lang-pt.js +++ b/lang-pt.js @@ -1122,8 +1122,16 @@ SnapTranslator.dict.pt = { 'vazio', // efeitos gráficos + 'brightness': + 'brilho', 'ghost': 'fantasma', + 'negative': + 'negativo', + 'comic': + 'ondeado', + 'confetti': + 'cor', // teclas 'space': @@ -1270,6 +1278,18 @@ SnapTranslator.dict.pt = { 'um item ao acaso', // em falta no ficheiro lang-de.js + 'grow': + 'aumentar', + 'shrink': + 'reduzir', + 'flip ↔': + 'inverter ↔', + 'flip ↕': + 'inverter ↕', + 'Export all scripts as pic...': + 'Exportar todos os guiões como fotografia…', + 'show a picture of all scripts\nand block definitions': + 'Mostra uma imagem com todos\nos guiões e definições de blocos', 'current %dates': '%dates corrente', 'year': -- cgit v1.3.1 From f80235ee43f21db5a4036ce0cdbea65cc821899b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 5 Jun 2014 17:13:27 +0200 Subject: stop replacing the empty string with the number zero in watchers fixed #473 --- history.txt | 4 ++++ objects.js | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index 72a34a6..44160ca 100755 --- a/history.txt +++ b/history.txt @@ -2149,3 +2149,7 @@ ______ * Bug fixes from Nathan, yay, thanks, Nathan!! * German translation update * Paint Editor transforms, yay, thanks, Kartik!! + +140605 +------ +* Objects: stop replacing the empty string with the number zero in watchers diff --git a/objects.js b/objects.js index dc02051..e3f1674 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-Jun-04'; +modules.objects = '2014-Jun-05'; var SpriteMorph; var StageMorph; @@ -6591,9 +6591,11 @@ WatcherMorph.prototype.update = function () { } else { newValue = this.target[this.getter](); } - num = +newValue; - if (typeof newValue !== 'boolean' && !isNaN(num)) { - newValue = Math.round(newValue * 1000000000) / 1000000000; + if (newValue !== '' && !isNil(newValue)) { + num = +newValue; + if (typeof newValue !== 'boolean' && !isNaN(num)) { + newValue = Math.round(newValue * 1000000000) / 1000000000; + } } if (newValue !== this.currentValue) { this.changed(); -- cgit v1.3.1 From 9f690fbfa393c2bc73ac4a8a479ae089161a7556 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 5 Jun 2014 17:16:27 +0200 Subject: initialize new variables with zero (instead of null) --- history.txt | 1 + threads.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/history.txt b/history.txt index 44160ca..53e6087 100755 --- a/history.txt +++ b/history.txt @@ -2153,3 +2153,4 @@ ______ 140605 ------ * Objects: stop replacing the empty string with the number zero in watchers +* Threads: initialize new variables with zero (instead of null) diff --git a/threads.js b/threads.js index 21147a3..d489441 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-May-20'; +modules.threads = '2014-Jun-05'; var ThreadManager; var Process; @@ -3054,7 +3054,7 @@ VariableFrame.prototype.getVar = function (name, upvars) { VariableFrame.prototype.addVar = function (name, value) { this.vars[name] = (value === 0 ? 0 : value === false ? false - : value === '' ? '' : value || null); + : value === '' ? '' : value || 0); }; VariableFrame.prototype.deleteVar = function (name) { -- cgit v1.3.1 From ccdce5da74cbc0b8bd1f60c8981894bc1f0e164b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 5 Jun 2014 17:42:36 +0200 Subject: fixed #465 --- history.txt | 1 + objects.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/history.txt b/history.txt index 53e6087..da0aebf 100755 --- a/history.txt +++ b/history.txt @@ -2154,3 +2154,4 @@ ______ ------ * Objects: stop replacing the empty string with the number zero in watchers * Threads: initialize new variables with zero (instead of null) +* Objects: fixed #465 diff --git a/objects.js b/objects.js index e3f1674..41f3e4a 100644 --- a/objects.js +++ b/objects.js @@ -3204,11 +3204,12 @@ SpriteMorph.prototype.forward = function (steps) { SpriteMorph.prototype.setHeading = function (degrees) { var x = this.xPosition(), y = this.yPosition(), - turn = degrees - this.heading; + dir = (+degrees || 90), + turn = dir - this.heading; // apply to myself this.changed(); - SpriteMorph.uber.setHeading.call(this, degrees); + SpriteMorph.uber.setHeading.call(this, dir); this.silentGotoXY(x, y, true); // just me this.positionTalkBubble(); -- cgit v1.3.1 From d7f30820b5d0363b89af5201643188545dd3e815 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 5 Jun 2014 17:56:19 +0200 Subject: fixed #457 --- history.txt | 1 + objects.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index da0aebf..fd4acc8 100755 --- a/history.txt +++ b/history.txt @@ -2155,3 +2155,4 @@ ______ * Objects: stop replacing the empty string with the number zero in watchers * Threads: initialize new variables with zero (instead of null) * Objects: fixed #465 +* Threads: fixed #457 diff --git a/objects.js b/objects.js index 41f3e4a..5de468b 100644 --- a/objects.js +++ b/objects.js @@ -4144,7 +4144,7 @@ StageMorph.prototype.init = function (globals) { this.keysPressed = {}; // for handling keyboard events, do not persist this.blocksCache = {}; // not to be serialized (!) this.paletteCache = {}; // not to be serialized (!) - this.lastAnswer = null; // last user input, do not persist + this.lastAnswer = ''; // last user input, do not persist this.activeSounds = []; // do not persist this.trailsCanvas = null; -- cgit v1.3.1 From fdfd74f79e5bfc6388397bdcc258e4672964f675 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 5 Jun 2014 22:29:16 +0200 Subject: fixes a but in setHeading() thanks, Brian! --- objects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects.js b/objects.js index 5de468b..897f14d 100644 --- a/objects.js +++ b/objects.js @@ -3204,7 +3204,7 @@ SpriteMorph.prototype.forward = function (steps) { SpriteMorph.prototype.setHeading = function (degrees) { var x = this.xPosition(), y = this.yPosition(), - dir = (+degrees || 90), + dir = (+degrees || 0), turn = dir - this.heading; // apply to myself -- cgit v1.3.1 From 4e2ce9a4ee2ffb5e22423290fd3ae34045e339fb Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 09:07:42 +0200 Subject: gracefully hide & show the stage, fixed #281 --- history.txt | 6 +++++- objects.js | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/history.txt b/history.txt index fd4acc8..3f52e14 100755 --- a/history.txt +++ b/history.txt @@ -2155,4 +2155,8 @@ ______ * Objects: stop replacing the empty string with the number zero in watchers * Threads: initialize new variables with zero (instead of null) * Objects: fixed #465 -* Threads: fixed #457 +* Objects: fixed #457 + +140605 +------ +* Objects: gracefully hide & show the stage, fixed #281 diff --git a/objects.js b/objects.js index 897f14d..88ee351 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-Jun-05'; +modules.objects = '2014-Jun-06'; var SpriteMorph; var StageMorph; @@ -5191,6 +5191,23 @@ StageMorph.prototype.thumbnail = function (extentPoint, excludedSprite) { return trg; }; +// StageMorph hiding and showing: + +/* + override the inherited behavior to recursively hide/show all + children. +*/ + +StageMorph.prototype.hide = function () { + this.isVisible = false; + this.changed(); +}; + +StageMorph.prototype.show = function () { + this.isVisible = true; + this.changed(); +}; + // StageMorph cloning overrice StageMorph.prototype.createClone = nop; -- cgit v1.3.1 From 76f6ad4c235f96dab4c67f2bae8b1bd9a8f20c7b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 09:15:16 +0200 Subject: add hide and show blocks for the stage --- history.txt | 1 + objects.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/history.txt b/history.txt index 3f52e14..cabc941 100755 --- a/history.txt +++ b/history.txt @@ -2160,3 +2160,4 @@ ______ 140605 ------ * Objects: gracefully hide & show the stage, fixed #281 +* Objects: add hide and show blocks to the stage’s “looks” category diff --git a/objects.js b/objects.js index 88ee351..607df14 100644 --- a/objects.js +++ b/objects.js @@ -4739,6 +4739,9 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('changeEffect')); blocks.push(block('setEffect')); blocks.push(block('clearEffects')); + blocks.push('-'); + blocks.push(block('show')); + blocks.push(block('hide')); // for debugging: /////////////// -- cgit v1.3.1 From 3f04b5b474d5b189182b90246280d25c4e858693 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 10:34:15 +0200 Subject: more relabelling options for SAY and THINK variants --- history.txt | 1 + objects.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index cabc941..127e01b 100755 --- a/history.txt +++ b/history.txt @@ -2161,3 +2161,4 @@ ______ ------ * Objects: gracefully hide & show the stage, fixed #281 * Objects: add hide and show blocks to the stage’s “looks” category +* Objects: added more relabelling options to SAY and THINK variants diff --git a/objects.js b/objects.js index 607df14..1d027c2 100644 --- a/objects.js +++ b/objects.js @@ -1199,10 +1199,10 @@ SpriteMorph.prototype.blockAlternatives = { yPosition: ['xPosition'], // looks: - doSayFor: ['doThinkFor'], - doThinkFor: ['doSayFor'], - bubble: ['doThink'], - doThink: ['bubble'], + doSayFor: ['doThinkFor', 'bubble', 'doThink'], + doThinkFor: ['doSayFor', 'doThink', 'bubble'], + bubble: ['doThink', 'doSayFor', 'doThinkFor'], + doThink: ['bubble', 'doSayFor', 'doThinkFor'], show: ['hide'], hide: ['show'], changeEffect: ['setEffect'], -- cgit v1.3.1 From 9bbe9b2e0af9afd5d94d65d0f7399126c235384b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 11:45:41 +0200 Subject: enable relabelling blocks with C-Slots --- blocks.js | 12 ++++++++++-- history.txt | 1 + objects.js | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/blocks.js b/blocks.js index b2955e9..4890fa1 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-June-04'; +modules.blocks = '2014-June-06'; var SyntaxElementMorph; @@ -2295,6 +2295,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) { @@ -2305,7 +2306,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; }); diff --git a/history.txt b/history.txt index 127e01b..9a1ec59 100755 --- a/history.txt +++ b/history.txt @@ -2162,3 +2162,4 @@ ______ * Objects: gracefully hide & show the stage, fixed #281 * Objects: add hide and show blocks to the stage’s “looks” category * Objects: added more relabelling options to SAY and THINK variants +* Blocks, objects: enable relabelling blocks with C-Slots diff --git a/objects.js b/objects.js index 1d027c2..5aac197 100644 --- a/objects.js +++ b/objects.js @@ -1233,6 +1233,10 @@ SpriteMorph.prototype.blockAlternatives = { receiveClick: ['receiveGo'], doBroadcast: ['doBroadcastAndWait'], doBroadcastAndWait: ['doBroadcast'], + doIf: ['doIfElse', 'doUntil'], + doIfElse: ['doIf', 'doUntil'], + doRepeat: ['doUntil'], + doUntil: ['doRepeat', 'doIf'], // sensing: getLastAnswer: ['getTimer'], -- cgit v1.3.1 From dcd7fb92546d6e9d9b4bd7eeb7d15417cdba3d50 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 11:56:47 +0200 Subject: enable relabelling blocks across categories --- blocks.js | 1 + history.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/blocks.js b/blocks.js index 4890fa1..d5730b6 100644 --- a/blocks.js +++ b/blocks.js @@ -2268,6 +2268,7 @@ BlockMorph.prototype.relabel = function (alternativeSelectors) { menu.addItem( block, function () { + myself.setCategory(SpriteMorph.prototype.blocks[sel].category); myself.setSelector(sel); } ); diff --git a/history.txt b/history.txt index 9a1ec59..72268f6 100755 --- a/history.txt +++ b/history.txt @@ -2163,3 +2163,4 @@ ______ * Objects: add hide and show blocks to the stage’s “looks” category * Objects: added more relabelling options to SAY and THINK variants * Blocks, objects: enable relabelling blocks with C-Slots +* Blocks: enable relabelling blocks across categories -- cgit v1.3.1 From 7f1b542e73ce6cc80aa6c154152e96b336d18c00 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 11:58:17 +0200 Subject: more relabelling options for SAY, THINK, ASK --- history.txt | 1 + objects.js | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index 72268f6..97b487e 100755 --- a/history.txt +++ b/history.txt @@ -2164,3 +2164,4 @@ ______ * Objects: added more relabelling options to SAY and THINK variants * Blocks, objects: enable relabelling blocks with C-Slots * Blocks: enable relabelling blocks across categories +* Objects: more relabelling options for SAY, THINK, ASK diff --git a/objects.js b/objects.js index 5aac197..89bc815 100644 --- a/objects.js +++ b/objects.js @@ -1199,10 +1199,10 @@ SpriteMorph.prototype.blockAlternatives = { yPosition: ['xPosition'], // looks: - doSayFor: ['doThinkFor', 'bubble', 'doThink'], - doThinkFor: ['doSayFor', 'doThink', 'bubble'], - bubble: ['doThink', 'doSayFor', 'doThinkFor'], - doThink: ['bubble', 'doSayFor', 'doThinkFor'], + doSayFor: ['doThinkFor', 'bubble', 'doThink', 'doAsk'], + doThinkFor: ['doSayFor', 'doThink', 'bubble', 'doAsk'], + bubble: ['doThink', 'doAsk', 'doSayFor', 'doThinkFor'], + doThink: ['bubble', 'doAsk', 'doSayFor', 'doThinkFor'], show: ['hide'], hide: ['show'], changeEffect: ['setEffect'], @@ -1239,6 +1239,7 @@ SpriteMorph.prototype.blockAlternatives = { doUntil: ['doRepeat', 'doIf'], // sensing: + doAsk: ['bubble', 'doThink', 'doSayFor', 'doThinkFor'], getLastAnswer: ['getTimer'], getTimer: ['getLastAnswer'], reportMouseX: ['reportMouseY'], -- cgit v1.3.1 From 0b80976c9c2fc688663c521f4eb9a583b36949c4 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 12:12:19 +0200 Subject: tweaks --- blocks.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blocks.js b/blocks.js index d5730b6..4d14351 100644 --- a/blocks.js +++ b/blocks.js @@ -2268,7 +2268,6 @@ BlockMorph.prototype.relabel = function (alternativeSelectors) { menu.addItem( block, function () { - myself.setCategory(SpriteMorph.prototype.blocks[sel].category); myself.setSelector(sel); } ); @@ -2284,7 +2283,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); -- cgit v1.3.1 From a5eace927aae19f8141eb525a72b18b757f57261 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 13:04:46 +0200 Subject: show zebra-coloring when previewing cross-category relabels --- blocks.js | 1 + 1 file changed, 1 insertion(+) diff --git a/blocks.js b/blocks.js index 4d14351..af5542f 100644 --- a/blocks.js +++ b/blocks.js @@ -2264,6 +2264,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, -- cgit v1.3.1 From 7f8d5a3d1eacdc78f61da8e82ac481bbbb825938 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Jun 2014 13:57:45 +0200 Subject: relabelling custom blocks (experimental) --- blocks.js | 9 +++++++++ byob.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- history.txt | 1 + 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index af5542f..159d1a2 100644 --- a/blocks.js +++ b/blocks.js @@ -2009,6 +2009,7 @@ BlockMorph.prototype.userMenu = function () { var menu = new MenuMorph(this), world = this.world(), myself = this, + alternatives, blck; menu.addItem( @@ -2066,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( diff --git a/byob.js b/byob.js index 0f79acf..a17f976 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2014-Jun-04'; +modules.byob = '2014-Jun-06'; // Declarations @@ -745,6 +745,7 @@ CustomCommandBlockMorph.prototype.userMenu = function () { } else { menu.addLine(); } + // menu.addItem("export definition...", 'exportBlockDefinition'); menu.addItem("delete block definition...", 'deleteBlockDefinition'); } @@ -846,6 +847,44 @@ CustomCommandBlockMorph.prototype.popUpbubbleHelp = function ( ).popUp(this.world(), this.rightCenter().add(new Point(-8, 0))); }; +// CustomCommandBlockMorph relabelling + +CustomCommandBlockMorph.prototype.relabel = function (alternatives) { + var menu = new MenuMorph(this), + oldInputs = this.inputs().map( + function (each) {return each.fullCopy(); } + ), + myself = this; + alternatives.forEach(function (def) { + var block = def.blockInstance(); + block.restoreInputs(oldInputs); + block.fixBlockColor(null, true); + block.addShadow(new Point(3, 3)); + menu.addItem( + block, + function () { + myself.definition = def; + myself.refresh(); + } + ); + }); + menu.popup(this.world(), this.bottomLeft().subtract(new Point( + 8, + this instanceof CommandBlockMorph ? this.corner : 0 + ))); +}; + +CustomCommandBlockMorph.prototype.alternatives = function () { + var rcvr = this.receiver(), + stage = rcvr.parentThatIsA(StageMorph), + allDefs = rcvr.customBlocks.concat(stage.globalBlocks), + myself = this; + return allDefs.filter(function (each) { + return each !== myself.definition && + each.type === myself.definition.type; + }); +}; + // CustomReporterBlockMorph //////////////////////////////////////////// // CustomReporterBlockMorph inherits from ReporterBlockMorph: @@ -961,6 +1000,14 @@ CustomReporterBlockMorph.prototype.bubbleHelp CustomReporterBlockMorph.prototype.popUpbubbleHelp = CustomCommandBlockMorph.prototype.popUpbubbleHelp; +// CustomReporterBlockMorph relabelling + +CustomReporterBlockMorph.prototype.relabel + = CustomCommandBlockMorph.prototype.relabel; + +CustomReporterBlockMorph.prototype.alternatives + = CustomCommandBlockMorph.prototype.alternatives; + // JaggedBlockMorph //////////////////////////////////////////////////// /* diff --git a/history.txt b/history.txt index 97b487e..02fc2a0 100755 --- a/history.txt +++ b/history.txt @@ -2165,3 +2165,4 @@ ______ * Blocks, objects: enable relabelling blocks with C-Slots * Blocks: enable relabelling blocks across categories * Objects: more relabelling options for SAY, THINK, ASK +* BYOB, Blocks: relabelling custom blocks (experimental) -- cgit v1.3.1