From 88ecd69dd7f5d5162296ceaf8fe6606e5d047042 Mon Sep 17 00:00:00 2001 From: Steven Chan <29343843+chansyu@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:47:05 +0000 Subject: [PATCH] fix flyout freeze (#3550) --- src/phases.ts | 4 ++-- src/ui/party-ui-handler.ts | 22 +++++++++++----------- src/ui/ui.ts | 19 +++++++------------ 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 2acb054c2ca..224f172b3e0 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2132,7 +2132,7 @@ export class CommandPhase extends FieldPhase { }), null, () => { - this.scene.ui.showText(null, 0); + this.scene.ui.showText("", 0); if (!isSwitch) { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); } @@ -2142,7 +2142,7 @@ export class CommandPhase extends FieldPhase { this.scene.ui.setMode(Mode.MESSAGE); } this.scene.ui.showText(trappedAbMessages[0], null, () => { - this.scene.ui.showText(null, 0); + this.scene.ui.showText("", 0); if (!isSwitch) { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); } diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index c34b19d9471..5e1ca7ccbb0 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -382,7 +382,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.clearOptions(); } else { this.clearOptions(); - this.showText(filterResult as string, undefined, () => this.showText(null, 0), undefined, true); + this.showText(filterResult as string, undefined, () => this.showText("", 0), undefined, true); } ui.playSelect(); return true; @@ -449,7 +449,7 @@ export default class PartyUiHandler extends MessageUiHandler { return true; } else { this.clearOptions(); - this.showText(filterResult as string, undefined, () => this.showText(null, 0), undefined, true); + this.showText(filterResult as string, undefined, () => this.showText("", 0), undefined, true); } } else if (option === PartyOption.SUMMARY) { ui.playSelect(); @@ -459,7 +459,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.clearOptions(); ui.playSelect(); pokemon.pauseEvolutions = false; - this.showText(i18next.t("partyUiHandler:unpausedEvolutions", { pokemonName: getPokemonNameWithAffix(pokemon) }), undefined, () => this.showText(null, 0), null, true); + this.showText(i18next.t("partyUiHandler:unpausedEvolutions", { pokemonName: getPokemonNameWithAffix(pokemon) }), undefined, () => this.showText("", 0), null, true); } else if (option === PartyOption.UNSPLICE) { this.clearOptions(); ui.playSelect(); @@ -472,12 +472,12 @@ export default class PartyUiHandler extends MessageUiHandler { ui.setMode(Mode.PARTY); this.showText(i18next.t("partyUiHandler:wasReverted", { fusionName: fusionName, pokemonName: pokemon.name }), undefined, () => { ui.setMode(Mode.PARTY); - this.showText(null, 0); + this.showText("", 0); }, null, true); }); }, () => { ui.setMode(Mode.PARTY); - this.showText(null, 0); + this.showText("", 0); }); }); } else if (option === PartyOption.RELEASE) { @@ -490,11 +490,11 @@ export default class PartyUiHandler extends MessageUiHandler { this.doRelease(this.cursor); }, () => { ui.setMode(Mode.PARTY); - this.showText(null, 0); + this.showText("", 0); }); }); } else { - this.showText(i18next.t("partyUiHandler:releaseInBattle"), null, () => this.showText(null, 0), null, true); + this.showText(i18next.t("partyUiHandler:releaseInBattle"), null, () => this.showText("", 0), null, true); } return true; } else if (option === PartyOption.RENAME) { @@ -730,8 +730,8 @@ export default class PartyUiHandler extends MessageUiHandler { return changed; } - showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null) { - if (text === null) { + showText(text: string, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null) { + if (text.length === 0) { text = defaultMessage; } @@ -1057,7 +1057,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.selectCallback = null; selectCallback && selectCallback(this.cursor, PartyOption.RELEASE); } - this.showText(null, 0); + this.showText("", 0); }, null, true); } @@ -1119,7 +1119,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.eraseOptionsCursor(); this.partyMessageBox.setSize(262, 30); - this.showText(null, 0); + this.showText("", 0); } eraseOptionsCursor() { diff --git a/src/ui/ui.ts b/src/ui/ui.ts index c2e8fd8e7bb..67002e32283 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -271,8 +271,8 @@ export default class UI extends Phaser.GameObjects.Container { return handler.processInput(button); } - showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void { - if (text && prompt && text.indexOf("$") > -1) { + showText(text: string, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void { + if (prompt && text.indexOf("$") > -1) { const messagePages = text.split(/\$/g).map(m => m.trim()); let showMessageAndCallback = () => callback && callback(); for (let p = messagePages.length - 1; p >= 0; p--) { @@ -282,17 +282,12 @@ export default class UI extends Phaser.GameObjects.Container { showMessageAndCallback(); } else { const handler = this.getHandler(); - if (handler instanceof PartyUiHandler) { - (handler as PartyUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay); - return; - } - if (text) { - if (handler instanceof MessageUiHandler) { - (handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay); - } else { - this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay); - } + if (handler instanceof MessageUiHandler) { + (handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay); + } else { + this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay); } + } }