mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Save and load the origin
This commit is contained in:
parent
65f22c15f3
commit
0b4b32dcb0
2 changed files with 17 additions and 0 deletions
|
@ -392,6 +392,13 @@ class Runtime extends EventEmitter {
|
|||
* @type {function}
|
||||
*/
|
||||
this.removeCloudVariable = this._initializeRemoveCloudVariable(newCloudDataManager);
|
||||
|
||||
/**
|
||||
* A string representing the origin of the current project from outside of the
|
||||
* Scratch community, such as CSFirst.
|
||||
* @type {?string}
|
||||
*/
|
||||
this.origin = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -561,6 +561,9 @@ const serialize = function (runtime, targetId) {
|
|||
const meta = Object.create(null);
|
||||
meta.semver = '3.0.0';
|
||||
meta.vm = vmPackage.version;
|
||||
if (runtime.origin) {
|
||||
meta.origin = runtime.origin;
|
||||
}
|
||||
|
||||
// Attach full user agent string to metadata if available
|
||||
meta.agent = 'none';
|
||||
|
@ -1235,6 +1238,13 @@ const deserialize = function (json, runtime, zip, isSingleSprite) {
|
|||
extensionURLs: new Map()
|
||||
};
|
||||
|
||||
// Store the origin field (e.g. project originated at CSFirst) so that we can save it again.
|
||||
if (json.meta && json.meta.origin) {
|
||||
runtime.origin = json.meta.origin;
|
||||
} else {
|
||||
runtime.origin = null;
|
||||
}
|
||||
|
||||
// First keep track of the current target order in the json,
|
||||
// then sort by the layer order property before parsing the targets
|
||||
// so that their corresponding render drawables can be created in
|
||||
|
|
Loading…
Reference in a new issue