From 927448d7ab4f7069661eb73018463fbf0e40651a Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 24 Nov 2014 10:05:19 +0100 Subject: Fixed #416 --- objects.js | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 4be213a..3b2c07b 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-October-08'; +modules.objects = '2014-November-24'; var SpriteMorph; var StageMorph; @@ -1674,6 +1674,20 @@ SpriteMorph.prototype.blockTemplates = function (category) { return menu; } + function addVar(pair) { + if (pair) { + if (myself.variables.silentFind(pair[0])) { + myself.inform('that name is already in use'); + } else { + myself.addVariable(pair[0], pair[1]); + myself.toggleVariableWatcher(pair[0], pair[1]); + myself.blocksCache[cat] = null; + myself.paletteCache[cat] = null; + myself.parentThatIsA(IDE_Morph).refreshPalette(); + } + } + } + if (cat === 'motion') { blocks.push(block('forward')); @@ -1967,15 +1981,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { function () { new VariableDialogMorph( null, - function (pair) { - if (pair && !myself.variables.silentFind(pair[0])) { - myself.addVariable(pair[0], pair[1]); - myself.toggleVariableWatcher(pair[0], pair[1]); - myself.blocksCache[cat] = null; - myself.paletteCache[cat] = null; - myself.parentThatIsA(IDE_Morph).refreshPalette(); - } - }, + addVar, myself ).prompt( 'Variable name', @@ -4858,6 +4864,20 @@ StageMorph.prototype.blockTemplates = function (category) { ); } + function addVar(pair) { + if (pair) { + if (myself.variables.silentFind(pair[0])) { + myself.inform('that name is already in use'); + } else { + myself.addVariable(pair[0], pair[1]); + myself.toggleVariableWatcher(pair[0], pair[1]); + myself.blocksCache[cat] = null; + myself.paletteCache[cat] = null; + myself.parentThatIsA(IDE_Morph).refreshPalette(); + } + } + } + if (cat === 'motion') { txt = new TextMorph(localize( @@ -5099,15 +5119,7 @@ StageMorph.prototype.blockTemplates = function (category) { function () { new VariableDialogMorph( null, - function (pair) { - if (pair && !myself.variables.silentFind(pair[0])) { - myself.addVariable(pair[0], pair[1]); - myself.toggleVariableWatcher(pair[0], pair[1]); - myself.blocksCache[cat] = null; - myself.paletteCache[cat] = null; - myself.parentThatIsA(IDE_Morph).refreshPalette(); - } - }, + addVar, myself ).prompt( 'Variable name', -- cgit v1.3.1 From 0d8cc567e7f04a9416fc2518646f2d9187840d70 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 24 Nov 2014 10:43:53 +0100 Subject: Fixed #372 --- history.txt | 2 +- objects.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 9d977ad..2d7e53e 100755 --- a/history.txt +++ b/history.txt @@ -2346,4 +2346,4 @@ ______ ------- * Threads: Fixed #318 * Objects: Fixed #416 - +* Objects: Fixed #372 diff --git a/objects.js b/objects.js index 3b2c07b..69376c8 100644 --- a/objects.js +++ b/objects.js @@ -2170,8 +2170,8 @@ SpriteMorph.prototype.freshPalette = function (category) { var defs = SpriteMorph.prototype.blocks, hiddens = StageMorph.prototype.hiddenPrimitives; return Object.keys(hiddens).some(function (any) { - return defs[any].category === category || - contains((more[category] || []), any); + return !isNil(defs[any]) && (defs[any].category === category + || contains((more[category] || []), any)); }); } @@ -2210,7 +2210,7 @@ SpriteMorph.prototype.freshPalette = function (category) { var hiddens = StageMorph.prototype.hiddenPrimitives, defs = SpriteMorph.prototype.blocks; Object.keys(hiddens).forEach(function (sel) { - if (defs[sel].category === category) { + if (defs[sel] && (defs[sel].category === category)) { delete StageMorph.prototype.hiddenPrimitives[sel]; } }); -- cgit v1.3.1 From 1f5934c81f494e897c78f5dde0885e16af913e4d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 1 Dec 2014 11:25:28 +0100 Subject: Don't show hidden elements in the project thumbnail --- history.txt | 4 ++++ objects.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 39a801d..34f967c 100755 --- a/history.txt +++ b/history.txt @@ -2362,3 +2362,7 @@ ______ 1411225 ------- * Threads: Fixed #656 + +141201 +------ +* Objects: Hide hidden elements in the project thumbnail diff --git a/objects.js b/objects.js index 69376c8..f0fe942 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-November-24'; +modules.objects = '2014-December-01'; var SpriteMorph; var StageMorph; @@ -5333,7 +5333,7 @@ StageMorph.prototype.thumbnail = function (extentPoint, excludedSprite) { this.dimensions.y * this.scale ); this.children.forEach(function (morph) { - if (morph !== excludedSprite) { + if (morph.isVisible && (morph !== excludedSprite)) { fb = morph.fullBounds(); fimg = morph.fullImage(); if (fimg.width && fimg.height) { -- cgit v1.3.1 From 17b6ae839b5c15c942440f38fc07bfcc45bc0811 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 3 Dec 2014 12:48:31 +0100 Subject: Improve edge-collision detection of default sprite “arrow” shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- history.txt | 5 +++++ objects.js | 9 ++++++--- threads.js | 14 ++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 986bcc4..b8af0f0 100755 --- a/history.txt +++ b/history.txt @@ -2372,3 +2372,8 @@ ______ 141202 ------ * New Kannada translation. Yay!! Thanks, Vinayakumar R!! + +141203 +------ +* Morphic: Cache actual bounding box of the Pen arrow shape +* Threads, Objects: Improve edge-collision detection of default sprite “arrow” shape diff --git a/objects.js b/objects.js index f0fe942..4ad376c 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-December-01'; +modules.objects = '2014-December-03'; var SpriteMorph; var StageMorph; @@ -3238,8 +3238,11 @@ SpriteMorph.prototype.setCenter = function (aPoint, justMe) { SpriteMorph.prototype.nestingBounds = function () { // same as fullBounds(), except that it uses "parts" instead of children - var result; - result = this.bounds; + // and special cases the costume-less "arrow" shape's bounding box + var result = this.bounds; + if (!this.costume && this.penBounds) { + result = this.penBounds.translateBy(this.position()); + } this.parts.forEach(function (part) { if (part.isVisible) { result = result.merge(part.nestingBounds()); diff --git a/threads.js b/threads.js index 59dd23a..9f9a221 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-November-26'; +modules.threads = '2014-December-03'; var ThreadManager; var Process; @@ -2368,6 +2368,7 @@ Process.prototype.objectTouchingObject = function (thisObj, name) { var myself = this, those, stage, + box, mouse; if (this.inputOption(name) === 'mouse-pointer') { @@ -2379,9 +2380,14 @@ Process.prototype.objectTouchingObject = function (thisObj, name) { } else { stage = thisObj.parentThatIsA(StageMorph); if (stage) { - if (this.inputOption(name) === 'edge' && - !stage.bounds.containsRectangle(thisObj.bounds)) { - return true; + if (this.inputOption(name) === 'edge') { + box = thisObj.bounds; + if (!thisObj.costume && thisObj.penBounds) { + box = thisObj.penBounds.translateBy(thisObj.position()); + } + if (!stage.bounds.containsRectangle(box)) { + return true; + } } if (this.inputOption(name) === 'pen trails' && thisObj.isTouching(stage.penTrailsMorph())) { -- cgit v1.3.1 From ad1fe34d1ed900e1e4fd75e5c5666f6ab28b9c80 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 4 Dec 2014 15:45:18 +0100 Subject: Experimental “ForEach” primitive (hidden in dev mode) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- objects.js | 13 ++++++++++++- threads.js | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 4ad376c..7277719 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-December-03'; +modules.objects = '2014-December-04'; var SpriteMorph; var StageMorph; @@ -1151,6 +1151,13 @@ SpriteMorph.prototype.initBlocks = function () { category: 'lists', spec: 'map %repRing over %l' }, + doForEach: { + dev: true, + type: 'command', + category: 'lists', + spec: 'for %upvar in %l %cs', + defaults: [localize('each item')] + }, // Code mapping - experimental doMapCodeOrHeader: { // experimental @@ -2063,6 +2070,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(txt); blocks.push('-'); blocks.push(block('reportMap')); + blocks.push('-'); + blocks.push(block('doForEach')); } ///////////////////////////////// @@ -5198,6 +5207,8 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(txt); blocks.push('-'); blocks.push(block('reportMap')); + blocks.push('-'); + blocks.push(block('doForEach')); } ///////////////////////////////// diff --git a/threads.js b/threads.js index 9f9a221..c21375e 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-December-03'; +modules.threads = '2014-December-04'; var ThreadManager; var Process; @@ -1679,6 +1679,26 @@ Process.prototype.reportMap = function (reporter, list) { } }; +Process.prototype.doForEach = function (upvar, list, script) { + // perform a script for each element of a list, assigning the + // current iteration's element to a variable with the name + // specified in the "upvar" parameter, so it can be referenced + // within the script. Uses the context's - unused - fourth + // element as temporary storage for the current list index + + if (isNil(this.context.inputs[3])) {this.context.inputs[3] = 1; } + var index = this.context.inputs[3]; + this.context.outerContext.variables.addVar(upvar); + this.context.outerContext.variables.setVar( + upvar, + list.at(index) + ); + if (index > list.length()) {return; } + this.context.inputs[3] += 1; + this.pushContext(); + this.evaluate(script, new List(), true); +}; + // Process interpolated primitives Process.prototype.doWait = function (secs) { -- cgit v1.3.1 From 777498a9f416a8a383e435d19a41f7bdae8ad048 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 17 Dec 2014 08:12:35 +0100 Subject: Experimental “processes” count watcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (hidden in dev mode) --- history.txt | 4 ++++ objects.js | 27 +++++++++++++++++++++++++-- store.js | 5 +++-- 3 files changed, 32 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index a7b88af..2f82c32 100755 --- a/history.txt +++ b/history.txt @@ -2398,3 +2398,7 @@ ______ 141215 ------ * New Swedish translation! Yay!! Thanks, Erik A Olsson! + +141217 +------ +* Objects, Store: Experimental “processes” count watcher (hidden in dev mode) diff --git a/objects.js b/objects.js index 7277719..b155b05 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-December-04'; +modules.objects = '2014-December-17'; var SpriteMorph; var StageMorph; @@ -793,6 +793,12 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'frames' }, + reportThreadCount: { + dev: true, + type: 'reporter', + category: 'sensing', + spec: 'processes' + }, doAsk: { type: 'command', category: 'sensing', @@ -1918,6 +1924,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { txt.setColor(this.paletteTextColor); blocks.push(txt); blocks.push('-'); + blocks.push(watcherToggle('reportThreadCount')); + blocks.push(block('reportThreadCount')); blocks.push(block('colorFiltered')); blocks.push(block('reportStackSize')); blocks.push(block('reportFrameCount')); @@ -3579,6 +3587,16 @@ SpriteMorph.prototype.reportMouseY = function () { return 0; }; +// SpriteMorph thread count (for debugging) + +SpriteMorph.prototype.reportThreadCount = function () { + var stage = this.parentThatIsA(StageMorph); + if (stage) { + return stage.threads.processes.length; + } + return 0; +}; + // SpriteMorph variable watchers (for palette checkbox toggling) SpriteMorph.prototype.findVariableWatcher = function (varName) { @@ -5059,6 +5077,8 @@ StageMorph.prototype.blockTemplates = function (category) { txt.setColor(this.paletteTextColor); blocks.push(txt); blocks.push('-'); + blocks.push(watcherToggle('reportThreadCount')); + blocks.push(block('reportThreadCount')); blocks.push(block('colorFiltered')); blocks.push(block('reportStackSize')); blocks.push(block('reportFrameCount')); @@ -5509,6 +5529,9 @@ StageMorph.prototype.watcherFor = StageMorph.prototype.getLastAnswer = SpriteMorph.prototype.getLastAnswer; +StageMorph.prototype.reportThreadCount + = SpriteMorph.prototype.reportThreadCount; + // StageMorph message broadcasting StageMorph.prototype.allMessageNames @@ -6757,7 +6780,7 @@ WatcherMorph.prototype.object = function () { WatcherMorph.prototype.isGlobal = function (selector) { return contains( ['getLastAnswer', 'getLastMessage', 'getTempo', 'getTimer', - 'reportMouseX', 'reportMouseY'], + 'reportMouseX', 'reportMouseY', 'reportThreadCount'], selector ); }; diff --git a/store.js b/store.js index 7b2b7e1..8cbc10f 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2014-December-06'; +modules.store = '2014-December-17'; // XML_Serializer /////////////////////////////////////////////////////// @@ -267,7 +267,8 @@ SnapSerializer.prototype.watcherLabels = { getTimer: 'timer', getCostumeIdx: 'costume #', reportMouseX: 'mouse x', - reportMouseY: 'mouse y' + reportMouseY: 'mouse y', + reportThreadCount: 'processes' }; // SnapSerializer instance creation: -- cgit v1.3.1