Merge pull request from technoboy10/bugfix/gh-1165-monitor-import

Fix importing hidden monitors from Scratch 2 projects
This commit is contained in:
Connor Hudson 2018-06-11 10:27:45 -04:00 committed by GitHub
commit 244ffb38c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 16 deletions
src/engine

View file

@ -522,18 +522,21 @@ class Blocks {
block.targetId = isSpriteSpecific ? optRuntime.getEditingTarget().id : null;
if (wasMonitored && !block.isMonitored) {
optRuntime.requestRemoveMonitor(block.id);
optRuntime.requestHideMonitor(block.id);
} else if (!wasMonitored && block.isMonitored) {
optRuntime.requestAddMonitor(MonitorRecord({
id: block.id,
targetId: block.targetId,
spriteName: block.targetId ? optRuntime.getTargetById(block.targetId).getName() : null,
opcode: block.opcode,
params: this._getBlockParams(block),
// @todo(vm#565) for numerical values with decimals, some countries use comma
value: '',
mode: block.opcode === 'data_listcontents' ? 'list' : 'default'
}));
// Tries to show the monitor for specified block. If it doesn't exist, add the monitor.
if (!optRuntime.requestShowMonitor(block.id)) {
optRuntime.requestAddMonitor(MonitorRecord({
id: block.id,
targetId: block.targetId,
spriteName: block.targetId ? optRuntime.getTargetById(block.targetId).getName() : null,
opcode: block.opcode,
params: this._getBlockParams(block),
// @todo(vm#565) for numerical values with decimals, some countries use comma
value: '',
mode: block.opcode === 'data_listcontents' ? 'list' : 'default'
}));
}
}
break;
}