Bubble string length limit

This commit is contained in:
apple502j 2018-09-14 20:56:40 +09:00 committed by GitHub
parent 64a1d3e02b
commit 7b6ba8cb9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,6 +58,14 @@ class Scratch3LooksBlocks {
return 'Scratch.looks'; return 'Scratch.looks';
} }
/**
* Limit for say bubble string.
* @const {string}
*/
static get SAY_BUBBLE_LIMIT () {
return 330;
}
/** /**
* @param {Target} target - collect bubble state for this target. Probably, but not necessarily, a RenderedTarget. * @param {Target} target - collect bubble state for this target. Probably, but not necessarily, a RenderedTarget.
* @returns {BubbleState} the mutable bubble state associated with that target. This will be created if necessary. * @returns {BubbleState} the mutable bubble state associated with that target. This will be created if necessary.
@ -278,7 +286,7 @@ class Scratch3LooksBlocks {
if (typeof message === 'number') { if (typeof message === 'number') {
message = parseFloat(message.toFixed(2)); message = parseFloat(message.toFixed(2));
} }
message = String(message); message = String(message).substr(0, Scratch3LooksBlocks.SAY_BUBBLE_LIMIT);
this.runtime.emit('SAY', util.target, 'say', message); this.runtime.emit('SAY', util.target, 'say', message);
} }
@ -299,7 +307,7 @@ class Scratch3LooksBlocks {
} }
think (args, util) { think (args, util) {
this._updateBubble(util.target, 'think', String(args.MESSAGE)); this._updateBubble(util.target, 'think', String(args.MESSAGE).substr(0, Scratch3LooksBlocks.SAY_BUBBLE_LIMIT));
} }
thinkforsecs (args, util) { thinkforsecs (args, util) {