Skip to content

Pseudo-blocking ask block for Play Lab#9749

Merged
joshlory merged 7 commits into
stagingfrom
pseudo-blocking-ask-block
Aug 1, 2016
Merged

Pseudo-blocking ask block for Play Lab#9749
joshlory merged 7 commits into
stagingfrom
pseudo-blocking-ask-block

Conversation

@joshlory

@joshlory joshlory commented Jul 29, 2016

Copy link
Copy Markdown
Contributor

This change builds on PR #9610 to use an input prompt that shows up in the play space instead of the browser's modal prompt() dialog.

screen shot 2016-07-29 at 12 12 51 pm

Before, we got blocking for free because prompt() stops JavaScript execution until the user enters a value. With this change, we must alter code generation to place all subsequent blocks inside a callback after an "ask" block.

A new askCallback event queue is created in order for the callback to execute as part of the Play Lab command queue.

Comment thread apps/src/studio/studio.js
var cmd = handler.cmdQueue[0];
if (cmd && cmd.name === 'moveDistance' && cmd.opts.spriteIndex === index) {
var distThisMove = Math.min(cmd.opts.queuedDistance,
var distThisMove = Math.min(cmd.opts.queuedDistance || Infinity,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand why this is needed, but cmd.opts.queuedDistance is occasionally undefined and Math.min(undefined, 2) is NaN.

@Hamms

Hamms commented Jul 29, 2016

Copy link
Copy Markdown
Contributor

couple comments, but otherwise LGTM! Far less complexity than I expected for such a feature; very elegantly done.

@joshlory

joshlory commented Jul 29, 2016

Copy link
Copy Markdown
Contributor Author

TODO:

  • Fix nested ask blocks.
  • Resetting the puzzle should hide the prompt.

Comment thread apps/src/studio/studio.js Outdated
};

Studio.hideInputPrompt = function () {
// To be overriden when the prompt is displayed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we (presumably) only ever want one prompt shown at once, what about if askForInput does something like Studio.inputPrompt = target (after perhaps checking to make sure that it isn't already assigned), and this method references and clears that variable?

@Hamms

Hamms commented Aug 1, 2016

Copy link
Copy Markdown
Contributor

LGTM after comments

@joshlory joshlory merged commit 9618ba5 into staging Aug 1, 2016
@joshlory joshlory deleted the pseudo-blocking-ask-block branch August 1, 2016 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants