mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-07 20:08:54 -04:00
Add "project changed" event
And emit it whenever we think the project has changed. Try to not emit it when a change has happened internally that shouldn't affect the serialized project. This iteration fires the event too frequently, e.g., when switching sprites. This is meant as a simple initial implementation that can be improved.
This commit is contained in:
parent
e071cf3c0c
commit
5022227c15
3 changed files with 31 additions and 4 deletions
src/engine
|
@ -501,6 +501,14 @@ class Runtime extends EventEmitter {
|
|||
return 'PROJECT_LOADED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for report that a change was made that can be saved
|
||||
* @const {string}
|
||||
*/
|
||||
static get PROJECT_CHANGED () {
|
||||
return 'PROJECT_CHANGED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for targets update report.
|
||||
* @const {string}
|
||||
|
@ -1737,7 +1745,6 @@ class Runtime extends EventEmitter {
|
|||
// Script glows must be cleared.
|
||||
this._scriptGlowsPreviousFrame = [];
|
||||
this._updateGlows();
|
||||
this.requestTargetsUpdate(editingTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2035,6 +2042,13 @@ class Runtime extends EventEmitter {
|
|||
this.emit(Runtime.PROJECT_LOADED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report that the project has changed in a way that would affect serialization
|
||||
*/
|
||||
emitProjectChanged () {
|
||||
this.emit(Runtime.PROJECT_CHANGED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report that a new target has been created, possibly by cloning an existing target.
|
||||
* @param {Target} newTarget - the newly created target.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue