fix flyout freeze (#3550)

This commit is contained in:
Steven Chan 2024-08-15 21:47:05 +00:00 committed by GitHub
parent 4e74007af6
commit 88ecd69dd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 25 deletions

View File

@ -2132,7 +2132,7 @@ export class CommandPhase extends FieldPhase {
}), }),
null, null,
() => { () => {
this.scene.ui.showText(null, 0); this.scene.ui.showText("", 0);
if (!isSwitch) { if (!isSwitch) {
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); 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.setMode(Mode.MESSAGE);
} }
this.scene.ui.showText(trappedAbMessages[0], null, () => { this.scene.ui.showText(trappedAbMessages[0], null, () => {
this.scene.ui.showText(null, 0); this.scene.ui.showText("", 0);
if (!isSwitch) { if (!isSwitch) {
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
} }

View File

@ -382,7 +382,7 @@ export default class PartyUiHandler extends MessageUiHandler {
this.clearOptions(); this.clearOptions();
} else { } else {
this.clearOptions(); 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(); ui.playSelect();
return true; return true;
@ -449,7 +449,7 @@ export default class PartyUiHandler extends MessageUiHandler {
return true; return true;
} else { } else {
this.clearOptions(); 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) { } else if (option === PartyOption.SUMMARY) {
ui.playSelect(); ui.playSelect();
@ -459,7 +459,7 @@ export default class PartyUiHandler extends MessageUiHandler {
this.clearOptions(); this.clearOptions();
ui.playSelect(); ui.playSelect();
pokemon.pauseEvolutions = false; 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) { } else if (option === PartyOption.UNSPLICE) {
this.clearOptions(); this.clearOptions();
ui.playSelect(); ui.playSelect();
@ -472,12 +472,12 @@ export default class PartyUiHandler extends MessageUiHandler {
ui.setMode(Mode.PARTY); ui.setMode(Mode.PARTY);
this.showText(i18next.t("partyUiHandler:wasReverted", { fusionName: fusionName, pokemonName: pokemon.name }), undefined, () => { this.showText(i18next.t("partyUiHandler:wasReverted", { fusionName: fusionName, pokemonName: pokemon.name }), undefined, () => {
ui.setMode(Mode.PARTY); ui.setMode(Mode.PARTY);
this.showText(null, 0); this.showText("", 0);
}, null, true); }, null, true);
}); });
}, () => { }, () => {
ui.setMode(Mode.PARTY); ui.setMode(Mode.PARTY);
this.showText(null, 0); this.showText("", 0);
}); });
}); });
} else if (option === PartyOption.RELEASE) { } else if (option === PartyOption.RELEASE) {
@ -490,11 +490,11 @@ export default class PartyUiHandler extends MessageUiHandler {
this.doRelease(this.cursor); this.doRelease(this.cursor);
}, () => { }, () => {
ui.setMode(Mode.PARTY); ui.setMode(Mode.PARTY);
this.showText(null, 0); this.showText("", 0);
}); });
}); });
} else { } 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; return true;
} else if (option === PartyOption.RENAME) { } else if (option === PartyOption.RENAME) {
@ -730,8 +730,8 @@ export default class PartyUiHandler extends MessageUiHandler {
return changed; return changed;
} }
showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null) { showText(text: string, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null) {
if (text === null) { if (text.length === 0) {
text = defaultMessage; text = defaultMessage;
} }
@ -1057,7 +1057,7 @@ export default class PartyUiHandler extends MessageUiHandler {
this.selectCallback = null; this.selectCallback = null;
selectCallback && selectCallback(this.cursor, PartyOption.RELEASE); selectCallback && selectCallback(this.cursor, PartyOption.RELEASE);
} }
this.showText(null, 0); this.showText("", 0);
}, null, true); }, null, true);
} }
@ -1119,7 +1119,7 @@ export default class PartyUiHandler extends MessageUiHandler {
this.eraseOptionsCursor(); this.eraseOptionsCursor();
this.partyMessageBox.setSize(262, 30); this.partyMessageBox.setSize(262, 30);
this.showText(null, 0); this.showText("", 0);
} }
eraseOptionsCursor() { eraseOptionsCursor() {

View File

@ -271,8 +271,8 @@ export default class UI extends Phaser.GameObjects.Container {
return handler.processInput(button); return handler.processInput(button);
} }
showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void { showText(text: string, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void {
if (text && prompt && text.indexOf("$") > -1) { if (prompt && text.indexOf("$") > -1) {
const messagePages = text.split(/\$/g).map(m => m.trim()); const messagePages = text.split(/\$/g).map(m => m.trim());
let showMessageAndCallback = () => callback && callback(); let showMessageAndCallback = () => callback && callback();
for (let p = messagePages.length - 1; p >= 0; p--) { for (let p = messagePages.length - 1; p >= 0; p--) {
@ -282,17 +282,12 @@ export default class UI extends Phaser.GameObjects.Container {
showMessageAndCallback(); showMessageAndCallback();
} else { } else {
const handler = this.getHandler(); 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) { if (handler instanceof MessageUiHandler) {
(handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay); (handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
} else { } else {
this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay); this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay);
} }
}
} }
} }