From ca9445c245d6c36f9a53ff3afeef47ff6920b59b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 31 Mar 2014 12:01:03 +0200 Subject: experimental “wardrobe” and “jukebox” reporters in dev mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tentative preparations for first-class costumes and sounds --- objects.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 46a951f..37daa69 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-February-11'; +modules.objects = '2014-March-31'; var SpriteMorph; var StageMorph; @@ -389,6 +389,12 @@ SpriteMorph.prototype.initBlocks = function () { }, // Looks - Debugging primitives for development mode + reportCostumes: { + type: 'reporter', + category: 'looks', + spec: 'wardrobe' + }, + alert: { type: 'command', category: 'looks', @@ -446,6 +452,13 @@ SpriteMorph.prototype.initBlocks = function () { spec: 'tempo' }, + // Sound - Debugging primitives for development mode + reportSounds: { + type: 'reporter', + category: 'sound', + spec: 'jukebox' + }, + // Pen clear: { type: 'command', @@ -1620,6 +1633,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { txt.setColor(this.paletteTextColor); blocks.push(txt); blocks.push('-'); + blocks.push(block('reportCostumes')); + blocks.push('-'); blocks.push(block('log')); blocks.push(block('alert')); } @@ -1641,6 +1656,20 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(watcherToggle('getTempo')); blocks.push(block('getTempo')); + // for debugging: /////////////// + + if (this.world().isDevMode) { + blocks.push('-'); + txt = new TextMorph(localize( + 'development mode \ndebugging primitives:' + )); + txt.fontSize = 9; + txt.setColor(this.paletteTextColor); + blocks.push(txt); + blocks.push('-'); + blocks.push(block('reportSounds')); + } + } else if (cat === 'pen') { blocks.push(block('clear')); @@ -2292,6 +2321,10 @@ SpriteMorph.prototype.doSwitchToCostume = function (id) { this.wearCostume(costume); }; +SpriteMorph.prototype.reportCostumes = function () { + return this.costumes; +}; + // SpriteMorph sound management SpriteMorph.prototype.addSound = function (audio, name) { @@ -2317,6 +2350,10 @@ SpriteMorph.prototype.playSound = function (name) { } }; +SpriteMorph.prototype.reportSounds = function () { + return this.sounds; +}; + // SpriteMorph user menu SpriteMorph.prototype.userMenu = function () { @@ -4353,6 +4390,8 @@ StageMorph.prototype.blockTemplates = function (category) { txt.setColor(this.paletteTextColor); blocks.push(txt); blocks.push('-'); + blocks.push(block('reportCostumes')); + blocks.push('-'); blocks.push(block('log')); blocks.push(block('alert')); } @@ -4374,6 +4413,20 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(watcherToggle('getTempo')); blocks.push(block('getTempo')); + // for debugging: /////////////// + + if (this.world().isDevMode) { + blocks.push('-'); + txt = new TextMorph(localize( + 'development mode \ndebugging primitives:' + )); + txt.fontSize = 9; + txt.setColor(this.paletteTextColor); + blocks.push(txt); + blocks.push('-'); + blocks.push(block('reportSounds')); + } + } else if (cat === 'pen') { blocks.push(block('clear')); @@ -4832,6 +4885,9 @@ StageMorph.prototype.doWearPreviousCostume StageMorph.prototype.doSwitchToCostume = SpriteMorph.prototype.doSwitchToCostume; +StageMorph.prototype.reportCostumes + = SpriteMorph.prototype.reportCostumes; + // StageMorph graphic effects StageMorph.prototype.setEffect @@ -4873,6 +4929,9 @@ StageMorph.prototype.resumeAllActiveSounds = function () { }); }; +StageMorph.prototype.reportSounds + = SpriteMorph.prototype.reportSounds; + // StageMorph non-variable watchers StageMorph.prototype.toggleWatcher -- cgit v1.3.1 From 6fd93533ecb01c27589bfe569d8e22013a77f65c Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 31 Mar 2014 13:09:31 +0200 Subject: display costume thumbnails in speech/thought/value bubbles and watcher cells --- blocks.js | 8 +++++++- history.txt | 1 + objects.js | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index 480545d..f0ddd93 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-February-11'; +modules.blocks = '2014-March-31'; var SyntaxElementMorph; @@ -1635,6 +1635,12 @@ SyntaxElementMorph.prototype.showBubble = function (value) { morphToShow.silentSetWidth(img.width); morphToShow.silentSetHeight(img.height); morphToShow.image = img; + } else if (value instanceof Costume) { + img = value.thumbnail(new Point(40, 40)); + morphToShow = new Morph(); + morphToShow.silentSetWidth(img.width); + morphToShow.silentSetHeight(img.height); + morphToShow.image = img; } else if (value instanceof Context) { img = value.image(); morphToShow = new Morph(); diff --git a/history.txt b/history.txt index 4c4201e..1399ba6 100755 --- a/history.txt +++ b/history.txt @@ -2107,3 +2107,4 @@ ______ 140331 ------ * Objects: experimental “wardrobe” and “jukebox” reporters in dev mode +* Blocks, Objects: display costume thumbnails in speech/thought/value bubbles and watcher cells diff --git a/objects.js b/objects.js index 37daa69..a6d2c9a 100644 --- a/objects.js +++ b/objects.js @@ -5058,6 +5058,12 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data) { contents.silentSetWidth(img.width); contents.silentSetHeight(img.height); contents.image = img; + } else if (data instanceof Costume) { + img = data.thumbnail(new Point(40, 40)); + contents = new Morph(); + contents.silentSetWidth(img.width); + contents.silentSetHeight(img.height); + contents.image = img; } else if (data instanceof HTMLCanvasElement) { contents = new Morph(); contents.silentSetWidth(data.width); @@ -5900,6 +5906,12 @@ CellMorph.prototype.drawNew = function () { this.contentsMorph.silentSetWidth(img.width); this.contentsMorph.silentSetHeight(img.height); this.contentsMorph.image = img; + } else if (this.contents instanceof Costume) { + img = this.contents.thumbnail(new Point(40, 40)); + this.contentsMorph = new Morph(); + this.contentsMorph.silentSetWidth(img.width); + this.contentsMorph.silentSetHeight(img.height); + this.contentsMorph.image = img; } else if (this.contents instanceof List) { if (this.isCircular()) { this.contentsMorph = new TextMorph( -- cgit v1.3.1 From ce3340e623fd0f03ecb15de5ec54eda8113c7c67 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 31 Mar 2014 13:19:39 +0200 Subject: let “switch to costume” block accept actual costume objects (in addition to names and numbers) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- history.txt | 1 + objects.js | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 1399ba6..2c0362b 100755 --- a/history.txt +++ b/history.txt @@ -2108,3 +2108,4 @@ ______ ------ * Objects: experimental “wardrobe” and “jukebox” reporters in dev mode * Blocks, Objects: display costume thumbnails in speech/thought/value bubbles and watcher cells +* Objects: let “switch to costume” block accept actual costume objects (in addition to names and numbers) diff --git a/objects.js b/objects.js index a6d2c9a..cc02ebe 100644 --- a/objects.js +++ b/objects.js @@ -2291,6 +2291,11 @@ SpriteMorph.prototype.doWearPreviousCostume = function () { }; SpriteMorph.prototype.doSwitchToCostume = function (id) { + if (id instanceof Costume) { // allow first-class costumes + this.wearCostume(id); + return; + } + var num, arr = this.costumes.asArray(), costume; -- cgit v1.3.1 From 442265ba5f38aba57d8aea19c8c36ccfc6e39a26 Mon Sep 17 00:00:00 2001 From: Nathaniel Titterton Date: Thu, 17 Apr 2014 12:21:31 -0700 Subject: give error message when attempting to import (into a variable) with a non-text file; don't read every file in multifile import --- objects.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index cc02ebe..fcb8796 100644 --- a/objects.js +++ b/objects.js @@ -6466,11 +6466,11 @@ WatcherMorph.prototype.userMenu = function () { document.body.removeChild(inp); ide.filePicker = null; if (inp.files.length > 0) { - for (i = 0; i < inp.files.length; i += 1) { - file = inp.files[i]; - if (file.type.indexOf("text") === 0) { - readText(file); - } + file = inp.files[inp.files.length - 1]; + if (file.type.indexOf("text") === 0) { + readText(file); + } else { + ide.inform("Unable to import", "Snap! can only import \"text\" files.\n You selected a file of type \"" + file.type + "\"."); } } }, -- cgit v1.3.1 From d2c47608441bb4a9b221ad11581e964248c3f967 Mon Sep 17 00:00:00 2001 From: blob8108 Date: Sat, 26 Apr 2014 01:10:57 +0100 Subject: Add charset to variable export --- objects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 41b511d..9c5087a 100644 --- a/objects.js +++ b/objects.js @@ -6339,7 +6339,7 @@ WatcherMorph.prototype.userMenu = function () { 'export...', function () { window.open( - 'data:text/plain,' + + 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.currentValue.toString()) ); } -- cgit v1.3.1 From 51e17d2ce9368c3546b7e27809dfbd187cefb246 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 30 Apr 2014 12:18:06 +0200 Subject: enable storage of first-class costumes --- history.txt | 6 ++++++ objects.js | 2 +- store.js | 14 ++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 2c0362b..69b48bc 100755 --- a/history.txt +++ b/history.txt @@ -2109,3 +2109,9 @@ ______ * Objects: experimental “wardrobe” and “jukebox” reporters in dev mode * Blocks, Objects: display costume thumbnails in speech/thought/value bubbles and watcher cells * Objects: let “switch to costume” block accept actual costume objects (in addition to names and numbers) + +140430 +------ +* new Finnish translation, yay! Thanks, Jouni! +* new Brazilian Portuguese translation, yay! Thanks, Aldo! +* enable storage and retrieval of first-class costumes in both file formats diff --git a/objects.js b/objects.js index 1c4e61e..b506195 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-March-31'; +modules.objects = '2014-April-30'; var SpriteMorph; var StageMorph; diff --git a/store.js b/store.js index b3f5d95..d69667a 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2014-February-13'; +modules.store = '2014-April-30'; // XML_Serializer /////////////////////////////////////////////////////// @@ -457,8 +457,6 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) { } }); - this.objects = {}; - /* Global Variables */ if (model.globalVariables) { @@ -468,6 +466,8 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) { ); } + this.objects = {}; + /* Watchers */ model.sprites.childrenNamed('watcher').forEach(function (model) { @@ -521,7 +521,7 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) { )) ); project.stage.add(watcher); - watcher.update(); + watcher.onNextStep = function () {this.currentValue = null; }; // set watcher's contentsMorph's extent if it is showing a list and // its monitor dimensions are given @@ -1302,6 +1302,12 @@ SnapSerializer.prototype.openProject = function (project, ide) { ide.createCorral(); ide.selectSprite(sprite); ide.fixLayout(); + + // force watchers to update + //project.stage.watchers().forEach(function (watcher) { + // watcher.onNextStep = function () {this.currentValue = null;}; + //}) + ide.world().keyboardReceiver = project.stage; }; -- cgit v1.3.1 From 7edecf8255860cd2498bd8e9e72bec5e29992489 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 2 May 2014 08:40:17 +0200 Subject: integrate #394 --- history.txt | 4 ++++ objects.js | 27 +++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 5fb2b40..bcf8e5c 100755 --- a/history.txt +++ b/history.txt @@ -2120,3 +2120,7 @@ ______ * text-encoding fix for exporting variable contents, thanks, Blob! * set turbo mode block fix, thanks, Michael and Nathan! * enable storage and retrieval of first-class costumes in both file formats + +140502 +------ +* error message when trying to import a non-text file into a variable, thanks, Nate! diff --git a/objects.js b/objects.js index 21d5156..d1e99ff 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-April-30'; +modules.objects = '2014-May-02'; var SpriteMorph; var StageMorph; @@ -6450,7 +6450,17 @@ WatcherMorph.prototype.userMenu = function () { inp.addEventListener( "change", function () { - var file, i; + var file; + + function txtOnlyMsg(ftype) { + ide.inform( + 'Unable to import', + 'Snap! can only import "text" files.\n' + + 'You selected a file of type "' + + ftype + + '".' + ); + } function readText(aFile) { var frd = new FileReader(); @@ -6460,18 +6470,19 @@ WatcherMorph.prototype.userMenu = function () { e.target.result ); }; - frd.readAsText(aFile); + + if (aFile.type.indexOf("text") === 0) { + frd.readAsText(aFile); + } else { + txtOnlyMsg(aFile.type); + } } document.body.removeChild(inp); ide.filePicker = null; if (inp.files.length > 0) { file = inp.files[inp.files.length - 1]; - if (file.type.indexOf("text") === 0) { - readText(file); - } else { - ide.inform("Unable to import", "Snap! can only import \"text\" files.\n You selected a file of type \"" + file.type + "\"."); - } + readText(file); } }, false -- cgit v1.3.1