Merge pull request #817 from sjhuang26/develop

Fix ask-and-wait in stage
This commit is contained in:
Paul Kaplan 2017-12-01 11:53:37 -05:00 committed by GitHub
commit 0722708004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,9 +63,9 @@ class Scratch3SensingBlocks {
this._answer = answer; this._answer = answer;
const questionObj = this._questionList.shift(); const questionObj = this._questionList.shift();
if (questionObj) { if (questionObj) {
const [_question, resolve, target, wasVisible] = questionObj; const [_question, resolve, target, wasVisible, wasStage] = questionObj;
// If the target was visible when asked, hide the say bubble. // If the target was visible when asked, hide the say bubble unless the target was the stage.
if (wasVisible) { if (wasVisible && !wasStage) {
this.runtime.emit('SAY', target, 'say', ''); this.runtime.emit('SAY', target, 'say', '');
} }
resolve(); resolve();
@ -73,16 +73,16 @@ class Scratch3SensingBlocks {
} }
} }
_enqueueAsk (question, resolve, target, wasVisible) { _enqueueAsk (question, resolve, target, wasVisible, wasStage) {
this._questionList.push([question, resolve, target, wasVisible]); this._questionList.push([question, resolve, target, wasVisible, wasStage]);
} }
_askNextQuestion () { _askNextQuestion () {
if (this._questionList.length > 0) { if (this._questionList.length > 0) {
const [question, _resolve, target, wasVisible] = this._questionList[0]; const [question, _resolve, target, wasVisible, wasStage] = this._questionList[0];
// If the target is visible, emit a blank question and use the // If the target is visible, emit a blank question and use the
// say event to trigger a bubble. // say event to trigger a bubble unless the target was the stage.
if (wasVisible) { if (wasVisible && !wasStage) {
this.runtime.emit('SAY', target, 'say', question); this.runtime.emit('SAY', target, 'say', question);
this.runtime.emit('QUESTION', ''); this.runtime.emit('QUESTION', '');
} else { } else {
@ -100,7 +100,7 @@ class Scratch3SensingBlocks {
const _target = util.target; const _target = util.target;
return new Promise(resolve => { return new Promise(resolve => {
const isQuestionAsked = this._questionList.length > 0; const isQuestionAsked = this._questionList.length > 0;
this._enqueueAsk(args.QUESTION, resolve, _target, _target.visible); this._enqueueAsk(args.QUESTION, resolve, _target, _target.visible, _target.isStage);
if (!isQuestionAsked) { if (!isQuestionAsked) {
this._askNextQuestion(); this._askNextQuestion();
} }