mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -05:00
Remove leftover instances of MONITORS_ADDED and MONITORS_REMOVED, change updateMonitor to requestUpdateMonitor, update some todos with tracking numbers.
This commit is contained in:
parent
7a1b3eccd0
commit
6ee1e6614c
4 changed files with 13 additions and 34 deletions
|
@ -291,20 +291,20 @@ class Blocks {
|
|||
case 'checkbox':
|
||||
block.isMonitored = args.value;
|
||||
if (optRuntime && wasMonitored && !block.isMonitored) {
|
||||
optRuntime.removeMonitor(block.id);
|
||||
optRuntime.requestRemoveMonitor(block.id);
|
||||
} else if (optRuntime && !wasMonitored && block.isMonitored) {
|
||||
optRuntime.addMonitor(
|
||||
optRuntime.requestAddMonitor(
|
||||
// Ensure that value is not undefined, since React requires it
|
||||
{
|
||||
// @todo(dd) this will collide if multiple sprites use same block
|
||||
// @todo(vm#564) this will collide if multiple sprites use same block
|
||||
id: block.id,
|
||||
category: 'data',
|
||||
// @todo(dd) how to handle translation here?
|
||||
// @todo(vm#565) how to handle translation here?
|
||||
label: block.opcode,
|
||||
// @todo(dd) for numerical values with decimals, some countries use comma
|
||||
// @todo(vm#565) for numerical values with decimals, some countries use comma
|
||||
value: '',
|
||||
x: 0,
|
||||
// @todo(dd) Don't require sending x and y when instantiating a
|
||||
// @todo(vm#566) Don't require sending x and y when instantiating a
|
||||
// monitor. If it's not preset the GUI should decide.
|
||||
y: 0
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ const execute = function (sequencer, thread) {
|
|||
runtime.visualReport(currentBlockId, resolvedValue);
|
||||
}
|
||||
if (thread.updateMonitor) {
|
||||
runtime.updateMonitor({
|
||||
runtime.requestUpdateMonitor({
|
||||
id: currentBlockId,
|
||||
value: String(resolvedValue)
|
||||
});
|
||||
|
|
|
@ -246,22 +246,6 @@ class Runtime extends EventEmitter {
|
|||
return 'MONITORS_UPDATE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for monitors removed.
|
||||
* @const {string}
|
||||
*/
|
||||
static get MONITORS_REMOVED () {
|
||||
return 'MONITORS_REMOVED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for monitors added.
|
||||
* @const {string}
|
||||
*/
|
||||
static get MONITORS_ADDED () {
|
||||
return 'MONITORS_ADDED';
|
||||
}
|
||||
|
||||
/**
|
||||
* How rapidly we try to step threads by default, in ms.
|
||||
*/
|
||||
|
@ -400,7 +384,7 @@ class Runtime extends EventEmitter {
|
|||
* @param {!Target} target Target to run thread on.
|
||||
* @param {?object} opts optional arguments
|
||||
* @param {?boolean} opts.showVisualReport true if the script should show speech bubble for its value
|
||||
* @param {?boolean} opts.updateMonitor true if the script should show and update a monitor with its value
|
||||
* @param {?boolean} opts.updateMonitor true if the script should update a monitor value
|
||||
* @return {!Thread} The newly created thread.
|
||||
*/
|
||||
_pushThread (id, target, opts) {
|
||||
|
@ -468,7 +452,7 @@ class Runtime extends EventEmitter {
|
|||
* @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.
|
||||
* @param {?boolean} opts.updateMonitor true if the monitor for this block should show and get updated.
|
||||
* @param {?boolean} opts.updateMonitor true if the monitor for this block should get updated.
|
||||
*/
|
||||
toggleScript (topBlockId, opts) {
|
||||
opts = Object.assign({
|
||||
|
@ -702,6 +686,7 @@ class Runtime extends EventEmitter {
|
|||
// @todo: Only render when this.redrawRequested or clones rendered.
|
||||
this.renderer.draw();
|
||||
}
|
||||
// @todo only emit if monitors has changed since last time.
|
||||
this.emit(Runtime.MONITORS_UPDATE,
|
||||
Object.keys(this._monitorState).map(key => this._monitorState[key])
|
||||
);
|
||||
|
@ -888,7 +873,7 @@ class Runtime extends EventEmitter {
|
|||
* overwrites it.
|
||||
* @param {!object} monitor Monitor to add.
|
||||
*/
|
||||
addMonitor (monitor) {
|
||||
requestAddMonitor (monitor) {
|
||||
this._monitorState[monitor.id] = monitor;
|
||||
}
|
||||
|
||||
|
@ -897,7 +882,7 @@ class Runtime extends EventEmitter {
|
|||
* exist in the state.
|
||||
* @param {!object} monitor Monitor to update.
|
||||
*/
|
||||
updateMonitor (monitor) {
|
||||
requestUpdateMonitor (monitor) {
|
||||
if (this._monitorState.hasOwnProperty(monitor.id)) {
|
||||
this._monitorState[monitor.id] = Object.assign({}, this._monitorState[monitor.id], monitor);
|
||||
}
|
||||
|
@ -908,7 +893,7 @@ class Runtime extends EventEmitter {
|
|||
* not exist in the state.
|
||||
* @param {!object} monitorId ID of the monitor to remove.
|
||||
*/
|
||||
removeMonitor (monitorId) {
|
||||
requestRemoveMonitor (monitorId) {
|
||||
delete this._monitorState[monitorId];
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,6 @@ class VirtualMachine extends EventEmitter {
|
|||
instance.runtime.on(Runtime.MONITORS_UPDATE, monitorList => {
|
||||
instance.emit(Runtime.MONITORS_UPDATE, monitorList);
|
||||
});
|
||||
instance.runtime.on(Runtime.MONITORS_REMOVED, monitorList => {
|
||||
instance.emit(Runtime.MONITORS_REMOVED, monitorList);
|
||||
});
|
||||
instance.runtime.on(Runtime.MONITORS_ADDED, monitorList => {
|
||||
instance.emit(Runtime.MONITORS_ADDED, monitorList);
|
||||
});
|
||||
|
||||
this.blockListener = this.blockListener.bind(this);
|
||||
this.flyoutBlockListener = this.flyoutBlockListener.bind(this);
|
||||
|
|
Loading…
Reference in a new issue