From 0b6d7adf3e69e296662169fa3b53a9f7a95de4e5 Mon Sep 17 00:00:00 2001 From: DD Liu Date: Mon, 8 Jan 2018 20:22:18 -0500 Subject: [PATCH 1/4] Update monitor on dropdown change --- src/engine/blocks.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 920128dc6..487115d13 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -3,6 +3,7 @@ const mutationAdapter = require('./mutation-adapter'); const xmlEscape = require('../util/xml-escape'); const MonitorRecord = require('./monitor-record'); const Clone = require('../util/clone'); +const {Map} = require('immutable'); /** * @fileoverview @@ -382,7 +383,20 @@ class Blocks { block.fields[args.name].id = args.value; } } else { + // Changing the value in a dropdown block.fields[args.name].value = args.value; + + if (!optRuntime || !block.parent){ + break; + } + + const parent = this._blocks[block.parent]; + if (parent.isMonitored) { + optRuntime.requestUpdateMonitor(Map({ + id: parent.id, + params: this._getBlockParams(parent) + })); + } } break; case 'mutation': @@ -390,14 +404,17 @@ class Blocks { break; case 'checkbox': block.isMonitored = args.value; - if (optRuntime) { - const isSpriteSpecific = optRuntime.monitorBlockInfo.hasOwnProperty(block.opcode) && - optRuntime.monitorBlockInfo[block.opcode].isSpriteSpecific; - block.targetId = isSpriteSpecific ? optRuntime.getEditingTarget().id : null; + if (!optRuntime) { + break; } - if (optRuntime && wasMonitored && !block.isMonitored) { + + const isSpriteSpecific = optRuntime.monitorBlockInfo.hasOwnProperty(block.opcode) && + optRuntime.monitorBlockInfo[block.opcode].isSpriteSpecific; + block.targetId = isSpriteSpecific ? optRuntime.getEditingTarget().id : null; + + if (wasMonitored && !block.isMonitored) { optRuntime.requestRemoveMonitor(block.id); - } else if (optRuntime && !wasMonitored && block.isMonitored) { + } else if (!wasMonitored && block.isMonitored) { optRuntime.requestAddMonitor(MonitorRecord({ // @todo(vm#564) this will collide if multiple sprites use same block id: block.id, From db662b8584e2eb2de1ac3793f2f54ffba074f840 Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 9 Jan 2018 14:55:46 -0500 Subject: [PATCH 2/4] fix lint --- src/engine/blocks.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 487115d13..d5e734ceb 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -402,7 +402,7 @@ class Blocks { case 'mutation': block.mutation = mutationAdapter(args.value); break; - case 'checkbox': + case 'checkbox': { block.isMonitored = args.value; if (!optRuntime) { break; @@ -428,6 +428,7 @@ class Blocks { } break; } + } this.resetCache(); } From fce83dc2c3ebb633568c7b9183e16ed87209dc1e Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 10 Jan 2018 17:50:48 -0500 Subject: [PATCH 3/4] make it work for non-droppable inputs --- src/engine/blocks.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index d5e734ceb..b889f2010 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -386,15 +386,15 @@ class Blocks { // Changing the value in a dropdown block.fields[args.name].value = args.value; - if (!optRuntime || !block.parent){ + if (!optRuntime){ break; } - const parent = this._blocks[block.parent]; - if (parent.isMonitored) { + const flyoutBlock = block.shadow && block.parent ? this._blocks[block.parent] : block; + if (flyoutBlock.isMonitored) { optRuntime.requestUpdateMonitor(Map({ - id: parent.id, - params: this._getBlockParams(parent) + id: flyoutBlock.id, + params: this._getBlockParams(flyoutBlock) })); } } From 323aafd165cd870d6ec4d3ca0453c389f55a284c Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 10 Jan 2018 17:57:04 -0500 Subject: [PATCH 4/4] Update VM's model of monitored blocks --- src/blocks/scratch3_looks.js | 5 ++--- src/blocks/scratch3_sensing.js | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index 546f594df..e173ca04d 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -244,9 +244,8 @@ class Scratch3LooksBlocks { getMonitored () { return { looks_size: {isSpriteSpecific: true}, - looks_costumeorder: {isSpriteSpecific: true}, - looks_backdroporder: {}, - looks_backdropname: {} + looks_costumenumbername: {isSpriteSpecific: true}, + looks_backdropnumbername: {} }; } diff --git a/src/blocks/scratch3_sensing.js b/src/blocks/scratch3_sensing.js index 4f977a612..0cd4dde6d 100644 --- a/src/blocks/scratch3_sensing.js +++ b/src/blocks/scratch3_sensing.js @@ -56,7 +56,6 @@ class Scratch3SensingBlocks { sensing_answer: {}, sensing_loudness: {}, sensing_timer: {}, - sensing_of: {}, sensing_current: {} }; }