Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamelab: showMobileControls() API #22609

Merged
merged 5 commits into from May 25, 2018
Merged

Gamelab: showMobileControls() API #22609

merged 5 commits into from May 25, 2018

Conversation

cpirich
Copy link
Contributor

@cpirich cpirich commented May 23, 2018

  • Add new showMobileControls(spaceButtonVisible, dpadVisible, dpadFourWay, mobileOnly) API which controls the visibility of the space button and the d-pad, the behavior of the d-pad (four way vs eight way), and whether or not the controls appear only on mobile devices for this project. All values are true by default (if the student never calls the API)
  • Changed the rendering location of the d-pad and space button to be below the gameButtons area (instead of the within and to the right of the Run button), so that they can use the full 400px of width when visible on the /edit page
    • Added support for responsive scaling of the d-pad and space button and manual resizing using the vertical visualization resize bar
  • Add mobileControlsConfig as a property on GameLab which is routed into the redux store
  • Add tests for the action / reducer
  • Remove show_d_pad property from the dashboard levels and level builder. It had not been used in a while (except for in the past few weeks as an override to force the d-pad off on mobile). This property conflicted with the new API.

@cpirich cpirich requested a review from islemaster May 23, 2018 15:18
@@ -1746,7 +1768,7 @@ a.WireframeButtons_active, div.WireframeButtons_active {

#gameButtons {
width: auto;
padding: 1% 5%;
padding: 4px 5%;
Copy link
Contributor Author

@cpirich cpirich May 23, 2018

Choose a reason for hiding this comment

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

The vertical padding was changed to be explicit, which is helpful for other height calculations in this area. Since gameButtons is rendered at 400px wide, 1% is equal to 4px

@@ -939,7 +938,7 @@ GameLab.prototype.onDPadMouseMove = function (e) {
clientY = e.touches[0].clientY;
}

if (experiments.isEnabled('fourWayDPad')) {
if (this.mobileControlsConfig.dpadFourWay) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this PR also removing this experiment / enabling it for everyone? Or was this leftover from a past PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it removes the experiment. @poorvasingal wants the 4-way to be the default now, and the new API allows you to change it to 8-way.

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Can you provide a screenshot of the new appearance, since it looks like you've moved the controls?

I see a test for the new reducer function but can we get any coverage of the new droplet block, the React component, and/or the actual show/hide behavior being implemented here?

Is this block a complete no-op on desktop, or should it somehow indicate to the student that it's been called / will take effect on mobile? Maybe something as simple as logging to the console in desktop mode would prevent possible confusion.

new window.p5(function (p5obj) {
this.p5 = p5obj;
this.p5.useQuadTree(false);
this.setP5FrameRate();
this.gameLabWorld = new GameLabWorld(p5obj);

p5obj.showMobileControls = function (
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we get anything out of putting this on our p5 object? It seems like this could live someplace else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the most convenient place for it to be marshaled in the global space. But I can look at wedging it in specifically in other spot.

@@ -32,7 +32,6 @@
"hide_view_data_button": "false",
"debugger_disabled": "true",
"hide_animation_mode": "false",
"show_d_pad": "false",
Copy link
Contributor

Choose a reason for hiding this comment

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

A number of these levels have show_d_pad set to false, but you're removing that parameter and making the default true. Do we need to also update these levels to use the new block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this param hasn't really been used. when it was, it was primarily hiding it on the desktop. For about a year, it did nothing at all.

The new default is "not visible on desktop, visible on the mobile share page"

I don't believe that the level builders ever set this flag considering the mobile share experience.

@cpirich
Copy link
Contributor Author

cpirich commented May 25, 2018

I asked @poorvasingal about the idea of console logging in response to calling the function (based on your comment), given that it may not be obvious that it had any effect, but she felt like we are fine without logging.

I'll take a look at other tests that could be created here.

And I'll be sure to update the PR with a screenshot.

@cpirich
Copy link
Contributor Author

cpirich commented May 25, 2018

Screenshot attached
If the student calls the API with mobileOnly set to false, you can now see these controls on the /edit page:
screen shot 2018-05-25 at 12 14 39 pm

@cpirich cpirich merged commit ffc0145 into staging May 25, 2018
@cpirich cpirich deleted the gamelab_showMobileControls branch May 25, 2018 23:23
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.

None yet

2 participants