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

Make (equivalent for) dragAndMoveBall available again #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

igrep
Copy link
Contributor

@igrep igrep commented Jun 5, 2024

This is still draft because I left a several things below and I want to show you before completing to reduce the risk in case of refusal. FEEDBACK WELCOME!

Background

When I first play with brick-block-anywhere on my website, I found a bug that could be a good chance for me to learn the browser's behavior. This feature is very useful for reproducing the bug and testing after fixing it.

Changes Summary

  • Add a function controlBallByMouse to move the ball by mouse so that we can easily put the ball at some place for debugging.
  • Abstract the procedure to move the ball (updateBallPositionBy and updateBallPositionTo) to hide the details and for consistency.
  • Merge TestMessage into StartMessage because now the non-debugging mode has to know whether the debugging mode is enabled to disable the default movement of the ball.
    • Bonus: this change also makes 12c7f53 unnecessary. It's simpler!

Screenshot

bba-control-by-mouse

igrep added 3 commits June 1, 2024 18:37
Background
====

When I first play with brick-block-anywhere on [my website](https://the.igreque.info/),
I found a bug that could be a good chance for me to learn the browser's
behavior. This feature is very useful for reproducing the bug and testing
after fixing it.

Changes Summary
====

- Add a function `controlBallByMouse` to move the ball by mouse so that we
  can easily put the ball at some place for debugging.
- Abstract the procedure to move the ball (`updateBallPositionBy` and
  `updateBallPositionTo`) to hide the details and for consistency.
- Merge `TestMessage` into `StartMessage` because now the non-debugging
  mode has to know whether the debugging mode is enabled to disable
  the default movement of the ball.
    - Bonus: this change also makes canalun@12c7f53
      unnecessary. It's simpler!

Next
====

- More customizable debugging mode: make `controlMode` and
  `visualizeBlocks` separately configurable on popup.html.
- Refactor: apply `updateBallPositionTo` to other objects if possible and
  it deserves.
Comment on lines 12 to 15
sound: boolean,
visualizeBlocks: boolean,
controlMode: "normal" | "mouse"
}
Copy link
Owner

@canalun canalun Jun 21, 2024

Choose a reason for hiding this comment

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

[imo] How about a structure like this?👀 I think it might be more robust.

Suggested change
sound: boolean,
visualizeBlocks: boolean,
controlMode: "normal" | "mouse"
}
sound: boolean
} & {
visualizeBlocks: false,
controlMode: "normal"
} | {
visualizeBlocks: true,
controlMode: "mouse"
}

Copy link
Contributor Author

@igrep igrep Jun 22, 2024

Choose a reason for hiding this comment

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

🤔 I'm undecided about this.

I found two bugs using the controlMode: "mouse" feature. I actually couldn't find one of the bugs actually because the borders drawn by visualizeBlocks prevent me from reproducing it. That's why I left the TODO "More customizable debugging mode: make controlMode and visualizeBlocks separately configurable on popup.html.".

But now, I know how to fix it and the change to fix it would perhaps remove the root problem of visualizeBlocks. So separating them could just make the code more complex.

I beg your opinion!

NOTE: I'll send another PR to fix the bug mentioned here today or tomorrow!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rethinking this problem, now I want to keep as is.

  • As my need for separating the debug options has already been satisfied by (manually editing the code), we would rarely need to switch them independently. So keep popup.tsx simple by not adding new <input>s for the time being.
  • But IMO visualizeBlocks and controlMode are essentially different. They should be configured independently (even by temporarily updating the code). Your suggestion makes it a little harder to do that.

controlMode: "normal" | "mouse"
}

export function disableScoreboardIfDebug(options: StartOptions): StartOptions {
Copy link
Owner

Choose a reason for hiding this comment

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

[Q] Is it possible to remove this function and make the scoreboard disabeld for the debug mode within sendMessageToIsolatedWorldOnActiveTabForTest() in popup.tsx? I'd like to hear your opnion :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Indeed. I'm a little worried that'd make popup.tsx complex, but more user-friendly!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems I mistook your comment wrong 😅 . But 2614729 would surpass your expectation!

@canalun
Copy link
Owner

canalun commented Jun 21, 2024

@igrep
Apologies for my late reply. After a busy month, now I have time to review this PR.
I like your idea! So could you please go for it? Sorry for late response.
(FYI. I've left some comments, thank you for checking them!)

@canalun
Copy link
Owner

canalun commented Jun 21, 2024

And I like your branch name :)

@igrep
Copy link
Contributor Author

igrep commented Jun 22, 2024

And I like your branch name :)

Thank you! 😁 To tell the truth, I couldn't make up a good name for controlMode: "mouse" at first. Then I decided to give a name that sounds something super because it breaks the nature of the brick-break game. "God mode" might be more suitable, but "God" could be so religious that I couldn't determine it's safe. "Ninja" would have no such a problem and everyone loves it by contrast!

And the prefix "2" means it's just the second try 😅 .

- Disable scoreboard on UI when the debug mode is enabled, then delete `disableScoreboardIfDebug`.
    - Answer to [a review comment from canalun](canalun#15 (comment)).
        - It seems I actually took the comment wrong, but this would make it easier to add independent debug options.
- Abstract the common steps in `sendMessage*` functions.
- Add the "Start" button to the bottom
    - This makes easier to start when enabling the debug mode.
@igrep igrep marked this pull request as ready for review June 24, 2024 12:44
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