From 26a50983472d15b002b08818643e7adc43075d9c Mon Sep 17 00:00:00 2001 From: DD Liu Date: Mon, 8 May 2017 16:51:45 -0400 Subject: [PATCH] don't show visual report when monitor is running --- src/engine/blocks.js | 2 +- src/engine/execute.js | 2 +- src/engine/runtime.js | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index f27d63c52..9e4a4c9ed 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -194,7 +194,7 @@ class Blocks { // UI event: clicked scripts toggle in the runtime. if (e.element === 'stackclick') { if (optRuntime) { - optRuntime.toggleScript(e.blockId); + optRuntime.toggleScript(e.blockId, {showVisualReport: true}); } return; } diff --git a/src/engine/execute.js b/src/engine/execute.js index 707859551..2b66c5e73 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -85,7 +85,7 @@ const execute = function (sequencer, thread) { } else { // In a non-hat, report the value visually if necessary if // at the top of the thread stack. - if (typeof resolvedValue !== 'undefined' && thread.atStackTop()) { + if (typeof resolvedValue !== 'undefined' && thread.showVisualReport && thread.atStackTop()) { runtime.visualReport(currentBlockId, resolvedValue); } // Finished any yields. diff --git a/src/engine/runtime.js b/src/engine/runtime.js index f2781a73e..34c008a1e 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -369,11 +369,13 @@ class Runtime extends EventEmitter { * Create a thread and push it to the list of threads. * @param {!string} id ID of block that starts the stack. * @param {!Target} target Target to run thread on. + * @param {?boolean} optShowVisualReport true if the script should show speech bubble for its value * @return {!Thread} The newly created thread. */ - _pushThread (id, target) { + _pushThread (id, target, optShowVisualReport) { const thread = new Thread(id); thread.target = target; + thread.showVisualReport = optShowVisualReport; thread.pushStack(id); this.threads.push(thread); return thread; @@ -423,9 +425,11 @@ class Runtime extends EventEmitter { /** * Toggle a script. * @param {!string} topBlockId ID of block that starts the script. - * @param {?string} optTarget target ID for target to run script on. If not supplied, uses editing target. + * @param {?object} opts optional arguments to toggle script + * @param {?string} opts.target target ID for target to run script on. If not supplied, uses editing target. + * @param {?boolean} opts.showVisualReport true if the speech bubble should pop up on the block, false if not. */ - toggleScript (topBlockId, optTarget) { + toggleScript (topBlockId, opts) { // Remove any existing thread. for (let i = 0; i < this.threads.length; i++) { if (this.threads[i].topBlock === topBlockId) { @@ -434,7 +438,10 @@ class Runtime extends EventEmitter { } } // Otherwise add it. - this._pushThread(topBlockId, optTarget ? optTarget : this._editingTarget); + this._pushThread( + topBlockId, + opts && opts.target ? opts.target : this._editingTarget, + opts ? opts.showVisualReport : false); } /**