mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Update extensions to load when deserializing monitors. This is necessary when the monitor is the only part of the project that uses the extension. Update extension monitor color category.
This commit is contained in:
parent
df24ca7b46
commit
14bee14d8c
2 changed files with 10 additions and 4 deletions
|
@ -2102,9 +2102,9 @@ class Runtime extends EventEmitter {
|
|||
const block = categoryInfo.blocks.find(b => b.info.opcode === opcode);
|
||||
if (!block) return;
|
||||
|
||||
// TODO: should this use some other category? Also, we may want to format the label in a locale-specific way.
|
||||
// TODO: we may want to format the label in a locale-specific way.
|
||||
return {
|
||||
category: 'data',
|
||||
category: 'extension', // This assumes that all extensions have the same monitor color.
|
||||
label: `${categoryInfo.name}: ${block.info.text}`
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1038,7 +1038,7 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
|
|||
return Promise.all(costumePromises.concat(soundPromises)).then(() => target);
|
||||
};
|
||||
|
||||
const deserializeMonitor = function (monitorData, runtime, targets) {
|
||||
const deserializeMonitor = function (monitorData, runtime, targets, extensions) {
|
||||
// If the serialized monitor has spriteName defined, look up the sprite
|
||||
// by name in the given list of targets and update the monitor's targetId
|
||||
// to match the sprite's id.
|
||||
|
@ -1115,6 +1115,12 @@ const deserializeMonitor = function (monitorData, runtime, targets) {
|
|||
}
|
||||
|
||||
runtime.monitorBlocks.createBlock(monitorBlock);
|
||||
|
||||
// If the block is from an extension, record it.
|
||||
const extensionID = getExtensionIdForOpcode(monitorBlock.opcode);
|
||||
if (extensionID) {
|
||||
extensions.extensionIDs.add(extensionID);
|
||||
}
|
||||
}
|
||||
// Otherwise, the monitor block will get created when the toolbox updates
|
||||
// after the target has been installed.
|
||||
|
@ -1160,7 +1166,7 @@ const deserialize = function (json, runtime, zip, isSingleSprite) {
|
|||
return t;
|
||||
}))
|
||||
.then(targets => {
|
||||
monitorObjects.map(monitorDesc => deserializeMonitor(monitorDesc, runtime, targets));
|
||||
monitorObjects.map(monitorDesc => deserializeMonitor(monitorDesc, runtime, targets, extensions));
|
||||
return targets;
|
||||
})
|
||||
.then(targets => ({
|
||||
|
|
Loading…
Reference in a new issue