mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Don't serialize x and y for sb2 comments so that they can be auto positioned.
This commit is contained in:
parent
b0aa288916
commit
f079eb4bbd
2 changed files with 8 additions and 5 deletions
|
@ -17,8 +17,8 @@ class Comment {
|
|||
constructor (id, text, x, y, width, height, minimized) {
|
||||
this.id = id || uid();
|
||||
this.text = text;
|
||||
this.x = cast.toNumber(x);
|
||||
this.y = cast.toNumber(y);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = Math.max(cast.toNumber(width), Comment.MIN_WIDTH);
|
||||
this.height = Math.max(cast.toNumber(height), Comment.MIN_HEIGHT);
|
||||
this.minimized = minimized || false;
|
||||
|
|
|
@ -449,16 +449,19 @@ const parseScratchObject = function (object, runtime, extensions, topLevel, zip)
|
|||
const blockComments = {};
|
||||
if (object.hasOwnProperty('scriptComments')) {
|
||||
const comments = object.scriptComments.map(commentDesc => {
|
||||
const isBlockComment = commentDesc[5] >= 0;
|
||||
const newComment = new Comment(
|
||||
null, // generate a new id for this comment
|
||||
commentDesc[6], // text content of sb2 comment
|
||||
commentDesc[0] * 1.5, // x position of comment
|
||||
commentDesc[1] * 2.2, // y position of comment
|
||||
// Only serialize x & y position of comment if it's a workspace comment
|
||||
// If it's a block comment, we'll let scratch-blocks handle positioning
|
||||
isBlockComment ? null : commentDesc[0] * 1.5, // x position of comment
|
||||
isBlockComment ? null : commentDesc[1] * 2.2, // y position of comment
|
||||
commentDesc[2] * 1.5, // width of comment
|
||||
commentDesc[3] * 2.2, // height of comment
|
||||
!commentDesc[4] // commentDesc[4] -- false means minimized, true means full screen
|
||||
);
|
||||
if (commentDesc[5] >= 0) {
|
||||
if (isBlockComment) {
|
||||
// commentDesc[5] refers to the index of the block that this
|
||||
// comment is attached to -- in a flattened version of the
|
||||
// scripts array.
|
||||
|
|
Loading…
Reference in a new issue