From 8e258189990b63c71789cb289c8f672758294b6f Mon Sep 17 00:00:00 2001 From: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Sun, 23 May 2021 11:29:49 +0100 Subject: [PATCH] Added a button to return to the menu after a puzzle is completed (#1170) * added another button to return to the menu * improved menu return * fixed continue button to not go back to menu --- .../hud/parts/puzzle_complete_notification.js | 31 +++++++++++++------ translations/base-en.yaml | 3 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/js/game/hud/parts/puzzle_complete_notification.js b/src/js/game/hud/parts/puzzle_complete_notification.js index 4d68daa9..b0235417 100644 --- a/src/js/game/hud/parts/puzzle_complete_notification.js +++ b/src/js/game/hud/parts/puzzle_complete_notification.js @@ -52,12 +52,22 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart { this.updateState(); }); - this.btnClose = document.createElement("button"); - this.btnClose.classList.add("close", "styledButton"); - this.btnClose.innerText = T.ingame.puzzleCompletion.buttonSubmit; - dialog.appendChild(this.btnClose); + this.continueBtn = document.createElement("button"); + this.continueBtn.classList.add("close", "styledButton"); + this.continueBtn.innerText = T.ingame.puzzleCompletion.continueBtn; + dialog.appendChild(this.continueBtn); - this.trackClicks(this.btnClose, this.close); + this.menuBtn = document.createElement("button"); + this.menuBtn.classList.add("close", "styledButton"); + this.menuBtn.innerText = T.ingame.puzzleCompletion.menuBtn; + dialog.appendChild(this.menuBtn); + + this.trackClicks(this.continueBtn, () => { + this.close(false); + }); + this.trackClicks(this.menuBtn, () => { + this.close(true); + }); } updateState() { @@ -79,13 +89,16 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart { return this.visible; } - close() { + close(toMenu) { /** @type {PuzzlePlayGameMode} */ (this.root.gameMode) .trackCompleted(this.userDidLikePuzzle, Math.round(this.timeOfCompletion)) .then(() => { - // this.root.gameState.moveToState("PuzzleMenuState"); - this.visible = false; - this.cleanup(); + if (toMenu) { + this.root.gameState.moveToState("PuzzleMenuState"); + } else { + this.visible = false; + this.cleanup(); + } }); } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 565cf377..aba636b6 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -626,7 +626,8 @@ ingame: titleRating: How difficult did you find the puzzle? titleRatingDesc: Your rating will help me to make you better suggestions in the future - buttonSubmit: Continue + continueBtn: Continue + menuBtn: Menu puzzleMetadata: author: Author