mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-08 11:34:40 -04:00
Add block-by-block feedback to the VM playground
This commit is contained in:
parent
f2734950d7
commit
5767e05d56
3 changed files with 20 additions and 2 deletions
|
@ -49,13 +49,20 @@ window.onload = function() {
|
||||||
};
|
};
|
||||||
updateThreadExplorer();
|
updateThreadExplorer();
|
||||||
|
|
||||||
// Feedback for stacks running.
|
// Feedback for stacks and blocks running.
|
||||||
vm.runtime.on('STACK_GLOW_ON', function(blockId) {
|
vm.runtime.on('STACK_GLOW_ON', function(blockId) {
|
||||||
workspace.glowStack(blockId, true);
|
workspace.glowStack(blockId, true);
|
||||||
});
|
});
|
||||||
vm.runtime.on('STACK_GLOW_OFF', function(blockId) {
|
vm.runtime.on('STACK_GLOW_OFF', function(blockId) {
|
||||||
workspace.glowStack(blockId, false);
|
workspace.glowStack(blockId, false);
|
||||||
});
|
});
|
||||||
|
vm.runtime.on('BLOCK_GLOW_ON', function(blockId) {
|
||||||
|
workspace.glowBlock(blockId, true);
|
||||||
|
});
|
||||||
|
vm.runtime.on('BLOCK_GLOW_OFF', function(blockId) {
|
||||||
|
workspace.glowBlock(blockId, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Run threads
|
// Run threads
|
||||||
vm.runtime.start();
|
vm.runtime.start();
|
||||||
|
|
|
@ -199,7 +199,13 @@ Runtime.prototype.startDistanceSensors = function () {
|
||||||
Runtime.prototype.stopAll = function () {
|
Runtime.prototype.stopAll = function () {
|
||||||
var threadsCopy = this.threads.slice();
|
var threadsCopy = this.threads.slice();
|
||||||
while (threadsCopy.length > 0) {
|
while (threadsCopy.length > 0) {
|
||||||
this._removeThread(threadsCopy.pop());
|
var poppedThread = threadsCopy.pop();
|
||||||
|
// Unglow any blocks on this thread's stack.
|
||||||
|
for (var i = 0; i < poppedThread.stack.length; i++) {
|
||||||
|
this.glowBlock(poppedThread.stack[i], false);
|
||||||
|
}
|
||||||
|
// Actually remove the thread.
|
||||||
|
this._removeThread(poppedThread);
|
||||||
}
|
}
|
||||||
// @todo call stop function in all extensions/packages/WeDo stub
|
// @todo call stop function in all extensions/packages/WeDo stub
|
||||||
if (window.native) {
|
if (window.native) {
|
||||||
|
|
|
@ -134,6 +134,8 @@ Sequencer.prototype.stepThread = function (thread) {
|
||||||
// Pop the stack and stack frame
|
// Pop the stack and stack frame
|
||||||
thread.stack.pop();
|
thread.stack.pop();
|
||||||
thread.stackFrames.pop();
|
thread.stackFrames.pop();
|
||||||
|
// Stop showing run feedback in the editor.
|
||||||
|
instance.runtime.glowBlock(currentBlock, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -199,6 +201,9 @@ Sequencer.prototype.stepThread = function (thread) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start showing run feedback in the editor.
|
||||||
|
this.runtime.glowBlock(currentBlock, true);
|
||||||
|
|
||||||
if (!opcode) {
|
if (!opcode) {
|
||||||
console.warn('Could not get opcode for block: ' + currentBlock);
|
console.warn('Could not get opcode for block: ' + currentBlock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue