mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #890 from fsih/dropdownMonitor
Update monitor on dropdown change
This commit is contained in:
commit
dfe4cc1e55
3 changed files with 27 additions and 11 deletions
|
@ -244,9 +244,8 @@ class Scratch3LooksBlocks {
|
||||||
getMonitored () {
|
getMonitored () {
|
||||||
return {
|
return {
|
||||||
looks_size: {isSpriteSpecific: true},
|
looks_size: {isSpriteSpecific: true},
|
||||||
looks_costumeorder: {isSpriteSpecific: true},
|
looks_costumenumbername: {isSpriteSpecific: true},
|
||||||
looks_backdroporder: {},
|
looks_backdropnumbername: {}
|
||||||
looks_backdropname: {}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ class Scratch3SensingBlocks {
|
||||||
sensing_answer: {},
|
sensing_answer: {},
|
||||||
sensing_loudness: {},
|
sensing_loudness: {},
|
||||||
sensing_timer: {},
|
sensing_timer: {},
|
||||||
sensing_of: {},
|
|
||||||
sensing_current: {}
|
sensing_current: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ const mutationAdapter = require('./mutation-adapter');
|
||||||
const xmlEscape = require('../util/xml-escape');
|
const xmlEscape = require('../util/xml-escape');
|
||||||
const MonitorRecord = require('./monitor-record');
|
const MonitorRecord = require('./monitor-record');
|
||||||
const Clone = require('../util/clone');
|
const Clone = require('../util/clone');
|
||||||
|
const {Map} = require('immutable');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview
|
* @fileoverview
|
||||||
|
@ -382,22 +383,38 @@ class Blocks {
|
||||||
block.fields[args.name].id = args.value;
|
block.fields[args.name].id = args.value;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Changing the value in a dropdown
|
||||||
block.fields[args.name].value = args.value;
|
block.fields[args.name].value = args.value;
|
||||||
|
|
||||||
|
if (!optRuntime){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const flyoutBlock = block.shadow && block.parent ? this._blocks[block.parent] : block;
|
||||||
|
if (flyoutBlock.isMonitored) {
|
||||||
|
optRuntime.requestUpdateMonitor(Map({
|
||||||
|
id: flyoutBlock.id,
|
||||||
|
params: this._getBlockParams(flyoutBlock)
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'mutation':
|
case 'mutation':
|
||||||
block.mutation = mutationAdapter(args.value);
|
block.mutation = mutationAdapter(args.value);
|
||||||
break;
|
break;
|
||||||
case 'checkbox':
|
case 'checkbox': {
|
||||||
block.isMonitored = args.value;
|
block.isMonitored = args.value;
|
||||||
if (optRuntime) {
|
if (!optRuntime) {
|
||||||
const isSpriteSpecific = optRuntime.monitorBlockInfo.hasOwnProperty(block.opcode) &&
|
break;
|
||||||
optRuntime.monitorBlockInfo[block.opcode].isSpriteSpecific;
|
|
||||||
block.targetId = isSpriteSpecific ? optRuntime.getEditingTarget().id : null;
|
|
||||||
}
|
}
|
||||||
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);
|
optRuntime.requestRemoveMonitor(block.id);
|
||||||
} else if (optRuntime && !wasMonitored && block.isMonitored) {
|
} else if (!wasMonitored && block.isMonitored) {
|
||||||
optRuntime.requestAddMonitor(MonitorRecord({
|
optRuntime.requestAddMonitor(MonitorRecord({
|
||||||
// @todo(vm#564) this will collide if multiple sprites use same block
|
// @todo(vm#564) this will collide if multiple sprites use same block
|
||||||
id: block.id,
|
id: block.id,
|
||||||
|
@ -411,6 +428,7 @@ class Blocks {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.resetCache();
|
this.resetCache();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue