diff --git a/src/battle-scene.ts b/src/battle-scene.ts index c8c4c275e01..54ad51c0d71 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -669,7 +669,7 @@ export class BattleScene extends SceneBase { ).then(() => loadMoveAnimAssets(defaultMoves, true)), this.initStarterColors(), ]).then(() => { - this.phaseManager.toTitleScreen("addLogin"); + this.phaseManager.toTitleScreen(true); }); } diff --git a/src/phase-manager.ts b/src/phase-manager.ts index 369a117ded9..e713c21b932 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -257,18 +257,15 @@ export class PhaseManager { } /** - * Add a new {@linkcode TitlePhase}. - * @param clearPhaseQueue - Whether to clear the phase queue before adding a new {@linkcode TitlePhase}. - * If set to `addLogin`, will add a new {@linkcode LoginPhase} before the {@linkcode TitlePhase} + * Clear all previously set phases, then add a new {@linkcode TitlePhase} to transition to the title screen. + * @param addLogin - Whether to add a new {@linkcode LoginPhase} before the {@linkcode TitlePhase} * (but reset everything else). * Default `false` */ - public toTitleScreen(clearPhaseQueue: boolean | "addLogin" = false): void { - if (clearPhaseQueue) { - this.clearAllPhases(); - } + public toTitleScreen(addLogin = false): void { + this.clearAllPhases(); - if (clearPhaseQueue === "addLogin") { + if (addLogin) { this.unshiftNew("LoginPhase"); } this.unshiftNew("TitlePhase"); diff --git a/src/phases/select-starter-phase.ts b/src/phases/select-starter-phase.ts index d524db39557..8363ac61ec3 100644 --- a/src/phases/select-starter-phase.ts +++ b/src/phases/select-starter-phase.ts @@ -26,7 +26,7 @@ export class SelectStarterPhase extends Phase { globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { // If clicking cancel, back out to title screen if (slotId === -1) { - globalScene.phaseManager.toTitleScreen(true); + globalScene.phaseManager.toTitleScreen(); this.end(); return; } diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index 7bf85d1d176..c644fc799e8 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -118,7 +118,7 @@ export class TitlePhase extends Phase { options.push({ label: i18next.t("menu:cancel"), handler: () => { - globalScene.phaseManager.toTitleScreen(true); + globalScene.phaseManager.toTitleScreen(); super.end(); return true; }, @@ -192,7 +192,7 @@ export class TitlePhase extends Phase { globalScene.ui.clearText(); globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { if (slotId === -1) { - globalScene.phaseManager.toTitleScreen(true); + globalScene.phaseManager.toTitleScreen(); super.end(); return; } diff --git a/src/ui/challenges-select-ui-handler.ts b/src/ui/challenges-select-ui-handler.ts index 1f56424efa1..48daf26b6b1 100644 --- a/src/ui/challenges-select-ui-handler.ts +++ b/src/ui/challenges-select-ui-handler.ts @@ -381,7 +381,7 @@ export class GameChallengesUiHandler extends UiHandler { this.cursorObj?.setVisible(true); this.updateChallengeArrows(this.startCursor.visible); } else { - globalScene.phaseManager.toTitleScreen(true); + globalScene.phaseManager.toTitleScreen(); globalScene.phaseManager.getCurrentPhase()?.end(); } success = true; diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 6b9e26d9595..79573123ce8 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -4321,7 +4321,7 @@ export class StarterSelectUiHandler extends MessageUiHandler { ui.setMode(UiMode.STARTER_SELECT); // Non-challenge modes go directly back to title, while challenge modes go to the selection screen. if (!globalScene.gameMode.isChallenge) { - globalScene.phaseManager.toTitleScreen(true); + globalScene.phaseManager.toTitleScreen(); } else { globalScene.phaseManager.clearPhaseQueue(); globalScene.phaseManager.pushNew("SelectChallengePhase"); diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index 6ce5ad74f9b..dc5704509df 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -105,7 +105,7 @@ export class GameManager { (this.scene.ui.handlers[UiMode.STARTER_SELECT] as StarterSelectUiHandler).clearStarterPreferences(); // Must be run after phase interceptor has been initialized. - this.scene.phaseManager.toTitlePhase("addLogin"); + this.scene.phaseManager.toTitleScreen(true); this.scene.phaseManager.shiftPhase(); this.gameWrapper.scene = this.scene;