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,
() => {
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);
}

View File

@ -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() {

View File

@ -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);
}
}
}