soiz1 commited on
Commit
d28af40
·
verified ·
1 Parent(s): bd17e98

Update src/serialization/sb3.js

Browse files
Files changed (1) hide show
  1. src/serialization/sb3.js +15 -0
src/serialization/sb3.js CHANGED
@@ -1711,6 +1711,21 @@ const deserialize = function (json, runtime, zip, isSingleSprite) {
1711
  }))
1712
  .then(targets => replaceUnsafeCharsInVariableIds(targets))
1713
  .then(targets => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1714
  monitorObjects.map(monitorDesc => deserializeMonitor(monitorDesc, runtime, targets, extensions));
1715
  return targets;
1716
  })
 
1711
  }))
1712
  .then(targets => replaceUnsafeCharsInVariableIds(targets))
1713
  .then(targets => {
1714
+ // at this point, stage size has not been set by 'runtime.parseProjectOptions'
1715
+ const stage = targets.find(t => t.isStage);
1716
+ if (stage) {
1717
+ // vm is not ready yet, so remake 'runtime.findProjectOptionsComment'
1718
+ let projectOptsComment;
1719
+ for (const comment of Object.values(stage?.comments)) {
1720
+ if (comment.text.includes(" // _twconfig_")) {
1721
+ projectOptsComment = comment;
1722
+ break;
1723
+ }
1724
+ }
1725
+
1726
+ if (projectOptsComment) runtime.parseProjectOptions(projectOptsComment);
1727
+ }
1728
+
1729
  monitorObjects.map(monitorDesc => deserializeMonitor(monitorDesc, runtime, targets, extensions));
1730
  return targets;
1731
  })