mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-18 17:30:58 -04:00
Better glows (#152)
* Strip out old script glowing in thread management * Add new tracking mechanism for glowing scripts * Track parents and use them to determine script glows * Use top-block for a thread if there's nothing on the stack * Remove `console.log`
This commit is contained in:
parent
797f844de3
commit
5df0acc895
7 changed files with 107 additions and 28 deletions
src/engine
|
@ -115,6 +115,20 @@ Blocks.prototype.getInputs = function (id) {
|
|||
return inputs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the top-level script for a given block.
|
||||
* @param {?string} id ID of block to query.
|
||||
* @return {?string} ID of top-level script block.
|
||||
*/
|
||||
Blocks.prototype.getTopLevelScript = function (id) {
|
||||
if (typeof this._blocks[id] === 'undefined') return null;
|
||||
var block = this._blocks[id];
|
||||
while (block.parent !== null) {
|
||||
block = this._blocks[block.parent];
|
||||
}
|
||||
return block.id;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -237,6 +251,7 @@ Blocks.prototype.moveBlock = function (e) {
|
|||
// This block was connected to the old parent's next connection.
|
||||
oldParent.next = null;
|
||||
}
|
||||
this._blocks[e.id].parent = null;
|
||||
}
|
||||
|
||||
// Has the block become a top-level block?
|
||||
|
@ -262,6 +277,7 @@ Blocks.prototype.moveBlock = function (e) {
|
|||
// Moved to the new parent's next connection.
|
||||
this._blocks[e.newParent].next = e.id;
|
||||
}
|
||||
this._blocks[e.id].parent = e.newParent;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue