-
Notifications
You must be signed in to change notification settings - Fork 1
Respec tify web version #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { isClickInsideButton, loadImages } from "@common"; | ||
| import { isClickInsideButton, loadImages, Utils } from "@common"; | ||
| import { MAP_BTN_IMG } from "@constants"; | ||
|
|
||
| export default class CloseButton { | ||
|
|
@@ -26,17 +26,23 @@ export default class CloseButton { | |
| this.context = context; | ||
| this.canvas = canvas; | ||
|
|
||
| loadImages({ close_button_image: MAP_BTN_IMG }, (images) => { | ||
| this.close_button_image = images["close_button_image"]; | ||
| this.imagesLoaded = true; | ||
| }); | ||
| // don't load the image when respect mode is enabled | ||
| if (!Utils.isRespect) { | ||
| loadImages({ close_button_image: MAP_BTN_IMG }, (images) => { | ||
| this.close_button_image = images["close_button_image"]; | ||
| this.imagesLoaded = true; | ||
| }); | ||
| } | ||
|
|
||
| this.btnSizeAnimation = 0.19; | ||
| this.btnOriginalSize = this.btnSizeAnimation; | ||
| this.orignalPos = { x: posX, y: posY }; | ||
| } | ||
|
|
||
| draw() { | ||
| // hide button in respect mode | ||
| if (Utils.isRespect) return; | ||
|
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
|
|
||
| if (this.imagesLoaded) { | ||
| this.context.drawImage( | ||
| this.close_button_image, | ||
|
|
@@ -56,6 +62,9 @@ export default class CloseButton { | |
| } | ||
|
|
||
| onClick(xClick: number, yClick: number): boolean { | ||
| // ignore clicks in respect mode | ||
| if (Utils.isRespect) return false; | ||
|
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
|
|
||
| const isInside = isClickInsideButton( | ||
| xClick, | ||
| yClick, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ export default class PausePopUp { | |
| this.retryButton = new RetryButton( | ||
| this.context, | ||
| this.canvas, | ||
| this.canvas.width * 0.55, | ||
| this.canvas.width * 0.5 - (this.canvas.width * 0.19) / 2, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The calculation for the const buttonWidthOffset = this.canvas.width * 0.19;
this.retryButton = new RetryButton(
this.context,
this.canvas,
this.canvas.width * 0.5 - buttonWidthOffset / 2,
this.canvas.height * 0.2 +
this.canvas.width * 0.4 - buttonWidthOffset / 2
); |
||
| this.canvas.height * 0.2 + | ||
| this.canvas.width * 0.4 - | ||
| (this.canvas.width * 0.19) / 2 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code conditionally loads the close button image based on
Utils.isRespect. It's good that the image loading is skipped when respect mode is enabled, but consider adding a comment explaining why this is done. This will help future developers understand the intent behind this conditional loading.