mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-09 17:09:26 +02:00
[Refactor] Added PhaseManager.toTitleScreen
(#6114)
* Added `toTitlePhase`; documented phase manager * Documented phase methods * Fixed syntax errors + updated signature * Reverted all the goodies * Fixed missing shift phase call GHAG * Reverted change
This commit is contained in:
parent
f7b87f3d1e
commit
8b304adf14
@ -657,9 +657,7 @@ export class BattleScene extends SceneBase {
|
|||||||
).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
||||||
this.initStarterColors(),
|
this.initStarterColors(),
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
this.phaseManager.pushNew("LoginPhase");
|
this.phaseManager.toTitleScreen(true);
|
||||||
this.phaseManager.pushNew("TitlePhase");
|
|
||||||
|
|
||||||
this.phaseManager.shiftPhase();
|
this.phaseManager.shiftPhase();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1269,13 +1267,12 @@ export class BattleScene extends SceneBase {
|
|||||||
duration: 250,
|
duration: 250,
|
||||||
ease: "Sine.easeInOut",
|
ease: "Sine.easeInOut",
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this.phaseManager.clearPhaseQueue();
|
|
||||||
|
|
||||||
this.ui.freeUIData();
|
this.ui.freeUIData();
|
||||||
this.uiContainer.remove(this.ui, true);
|
this.uiContainer.remove(this.ui, true);
|
||||||
this.uiContainer.destroy();
|
this.uiContainer.destroy();
|
||||||
this.children.removeAll(true);
|
this.children.removeAll(true);
|
||||||
this.game.domContainer.innerHTML = "";
|
this.game.domContainer.innerHTML = "";
|
||||||
|
// TODO: `launchBattle` calls `reset(false, false, true)`
|
||||||
this.launchBattle();
|
this.launchBattle();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Enum representation of the phase types held by implementations of {@linkcode PhasePriorityQueue}
|
* Enum representation of the phase types held by implementations of {@linkcode PhasePriorityQueue}.
|
||||||
*/
|
*/
|
||||||
|
// TODO: We currently assume these are in order
|
||||||
export enum DynamicPhaseType {
|
export enum DynamicPhaseType {
|
||||||
POST_SUMMON
|
POST_SUMMON
|
||||||
}
|
}
|
||||||
|
@ -244,6 +244,21 @@ export class PhaseManager {
|
|||||||
this.dynamicPhaseTypes = [PostSummonPhase];
|
this.dynamicPhaseTypes = [PostSummonPhase];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(addLogin = false): void {
|
||||||
|
this.clearAllPhases();
|
||||||
|
|
||||||
|
if (addLogin) {
|
||||||
|
this.unshiftNew("LoginPhase");
|
||||||
|
}
|
||||||
|
this.unshiftNew("TitlePhase");
|
||||||
|
}
|
||||||
|
|
||||||
/* Phase Functions */
|
/* Phase Functions */
|
||||||
getCurrentPhase(): Phase | null {
|
getCurrentPhase(): Phase | null {
|
||||||
return this.currentPhase;
|
return this.currentPhase;
|
||||||
|
@ -24,10 +24,11 @@ export class SelectStarterPhase extends Phase {
|
|||||||
globalScene.ui.setMode(UiMode.STARTER_SELECT, (starters: Starter[]) => {
|
globalScene.ui.setMode(UiMode.STARTER_SELECT, (starters: Starter[]) => {
|
||||||
globalScene.ui.clearText();
|
globalScene.ui.clearText();
|
||||||
globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
||||||
|
// If clicking cancel, back out to title screen
|
||||||
if (slotId === -1) {
|
if (slotId === -1) {
|
||||||
globalScene.phaseManager.clearPhaseQueue();
|
globalScene.phaseManager.toTitleScreen();
|
||||||
globalScene.phaseManager.pushNew("TitlePhase");
|
this.end();
|
||||||
return this.end();
|
return;
|
||||||
}
|
}
|
||||||
globalScene.sessionSlotId = slotId;
|
globalScene.sessionSlotId = slotId;
|
||||||
this.initBattle(starters);
|
this.initBattle(starters);
|
||||||
|
@ -114,11 +114,11 @@ export class TitlePhase extends Phase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Cancel button = back to title
|
||||||
options.push({
|
options.push({
|
||||||
label: i18next.t("menu:cancel"),
|
label: i18next.t("menu:cancel"),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
globalScene.phaseManager.clearPhaseQueue();
|
globalScene.phaseManager.toTitleScreen();
|
||||||
globalScene.phaseManager.pushNew("TitlePhase");
|
|
||||||
super.end();
|
super.end();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -191,11 +191,12 @@ export class TitlePhase extends Phase {
|
|||||||
initDailyRun(): void {
|
initDailyRun(): void {
|
||||||
globalScene.ui.clearText();
|
globalScene.ui.clearText();
|
||||||
globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
||||||
globalScene.phaseManager.clearPhaseQueue();
|
|
||||||
if (slotId === -1) {
|
if (slotId === -1) {
|
||||||
globalScene.phaseManager.pushNew("TitlePhase");
|
globalScene.phaseManager.toTitleScreen();
|
||||||
return super.end();
|
super.end();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
globalScene.phaseManager.clearPhaseQueue();
|
||||||
globalScene.sessionSlotId = slotId;
|
globalScene.sessionSlotId = slotId;
|
||||||
|
|
||||||
const generateDaily = (seed: string) => {
|
const generateDaily = (seed: string) => {
|
||||||
|
@ -382,8 +382,7 @@ export class GameChallengesUiHandler extends UiHandler {
|
|||||||
this.cursorObj?.setVisible(true);
|
this.cursorObj?.setVisible(true);
|
||||||
this.updateChallengeArrows(this.startCursor.visible);
|
this.updateChallengeArrows(this.startCursor.visible);
|
||||||
} else {
|
} else {
|
||||||
globalScene.phaseManager.clearPhaseQueue();
|
globalScene.phaseManager.toTitleScreen();
|
||||||
globalScene.phaseManager.pushNew("TitlePhase");
|
|
||||||
globalScene.phaseManager.getCurrentPhase()?.end();
|
globalScene.phaseManager.getCurrentPhase()?.end();
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -4303,7 +4303,10 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tryExit(): boolean {
|
/**
|
||||||
|
* Attempt to back out of the starter selection screen into the appropriate parent modal
|
||||||
|
*/
|
||||||
|
tryExit(): void {
|
||||||
this.blockInput = true;
|
this.blockInput = true;
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
@ -4317,12 +4320,13 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
UiMode.CONFIRM,
|
UiMode.CONFIRM,
|
||||||
() => {
|
() => {
|
||||||
ui.setMode(UiMode.STARTER_SELECT);
|
ui.setMode(UiMode.STARTER_SELECT);
|
||||||
globalScene.phaseManager.clearPhaseQueue();
|
// Non-challenge modes go directly back to title, while challenge modes go to the selection screen.
|
||||||
if (globalScene.gameMode.isChallenge) {
|
if (!globalScene.gameMode.isChallenge) {
|
||||||
|
globalScene.phaseManager.toTitleScreen();
|
||||||
|
} else {
|
||||||
|
globalScene.phaseManager.clearPhaseQueue();
|
||||||
globalScene.phaseManager.pushNew("SelectChallengePhase");
|
globalScene.phaseManager.pushNew("SelectChallengePhase");
|
||||||
globalScene.phaseManager.pushNew("EncounterPhase");
|
globalScene.phaseManager.pushNew("EncounterPhase");
|
||||||
} else {
|
|
||||||
globalScene.phaseManager.pushNew("TitlePhase");
|
|
||||||
}
|
}
|
||||||
this.clearText();
|
this.clearText();
|
||||||
globalScene.phaseManager.getCurrentPhase()?.end();
|
globalScene.phaseManager.getCurrentPhase()?.end();
|
||||||
@ -4333,8 +4337,6 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
19,
|
19,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tryStart(manualTrigger = false): boolean {
|
tryStart(manualTrigger = false): boolean {
|
||||||
|
@ -103,12 +103,9 @@ export class GameManager {
|
|||||||
if (!firstTimeScene) {
|
if (!firstTimeScene) {
|
||||||
this.scene.reset(false, true);
|
this.scene.reset(false, true);
|
||||||
(this.scene.ui.handlers[UiMode.STARTER_SELECT] as StarterSelectUiHandler).clearStarterPreferences();
|
(this.scene.ui.handlers[UiMode.STARTER_SELECT] as StarterSelectUiHandler).clearStarterPreferences();
|
||||||
this.scene.phaseManager.clearAllPhases();
|
|
||||||
|
|
||||||
// Must be run after phase interceptor has been initialized.
|
// Must be run after phase interceptor has been initialized.
|
||||||
|
this.scene.phaseManager.toTitleScreen(true);
|
||||||
this.scene.phaseManager.pushNew("LoginPhase");
|
|
||||||
this.scene.phaseManager.pushNew("TitlePhase");
|
|
||||||
this.scene.phaseManager.shiftPhase();
|
this.scene.phaseManager.shiftPhase();
|
||||||
|
|
||||||
this.gameWrapper.scene = this.scene;
|
this.gameWrapper.scene = this.scene;
|
||||||
|
Loading…
Reference in New Issue
Block a user