Add PROJECT_RUN_START/STOP events
These events signal when any threads are running or when all threads have stopped running. This maps to whether the green flag or the stop button should be illuminated in the GUI.
This commit is contained in:
1 parent
2ff719f2ba
commit
55ac7e269c
2 files changed
+38
No files matched your search
@@ -83,6 +83,12 @@ var Runtime = function () {
|
||||
*/
|
||||
this._scriptGlowsPreviousFrame = [];
|
||||
|
||||
/**
|
||||
* Number of threads running during the previous frame
|
||||
* @type {number}
|
||||
*/
|
||||
this._threadCount = 0;
|
||||
|
||||
/**
|
||||
* Currently known number of clones, used to enforce clone limit.
|
||||
* @type {number}
|
||||
@@ -179,6 +185,18 @@ Runtime.BLOCK_GLOW_ON = 'BLOCK_GLOW_ON';
|
||||
*/
|
||||
Runtime.BLOCK_GLOW_OFF = 'BLOCK_GLOW_OFF';
|
||||
|
||||
/**
|
||||
* Event name for glowing the green flag
|
||||
* @const {string}
|
||||
*/
|
||||
Runtime.PROJECT_RUN_START = 'PROJECT_RUN_START'
|
||||
|
||||
/**
|
||||
* Event name for unglowing the green flag
|
||||
* @const {string}
|
||||
*/
|
||||
Runtime.PROJECT_RUN_STOP = 'PROJECT_RUN_STOP'
|
||||
|
||||
/**
|
||||
* Event name for visual value report.
|
||||
* @const {string}
|
||||
@@ -552,6 +570,7 @@ Runtime.prototype._step = function () {
|
||||
this.redrawRequested = false;
|
||||
var inactiveThreads = this.sequencer.stepThreads();
|
||||
this._updateGlows(inactiveThreads);
|
||||
this._setThreadCount(this.threads.length);
|
||||
if (this.renderer) {
|
||||
// @todo: Only render when this.redrawRequested or clones rendered.
|
||||
this.renderer.draw();
|
||||
@@ -639,6 +658,20 @@ Runtime.prototype._updateGlows = function (optExtraThreads) {
|
||||
this._scriptGlowsPreviousFrame = finalScriptGlows;
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit run start/stop after each tick. Emits when `this.threads.length` goes
|
||||
* between non-zero and zero
|
||||
*/
|
||||
Runtime.prototype._setThreadCount = function (threadCount) {
|
||||
if (this._threadCount === 0 && threadCount > 0) {
|
||||
this.emit(Runtime.PROJECT_RUN_START);
|
||||
}
|
||||
if (this._threadCount > 0 && threadCount === 0) {
|
||||
this.emit(Runtime.PROJECT_RUN_STOP);
|
||||
}
|
||||
this._threadCount = threadCount;
|
||||
};
|
||||
|
||||
/**
|
||||
* "Quiet" a script's glow: stop the VM from generating glow/unglow events
|
||||
* about that script. Use when a script has just been deleted, but we may
|
||||
|
||||
Reference in new issue
Block a user