[qol] add missing error messages in starter UI

This commit is contained in:
MokaStitcher 2024-09-14 17:33:39 +02:00
parent 6030b780f2
commit d053b6873c
2 changed files with 24 additions and 11 deletions

View File

@ -2,6 +2,7 @@
"confirmStartTeam": "Begin with these Pokémon?",
"confirmExit": "Do you want to exit?",
"invalidParty": "This is not a valid starting party!",
"emptyParty": "Press Space or Z to add Pokémon to your party.\nPress ENTER or Start to start the run.",
"gen1": "I",
"gen2": "II",
"gen3": "III",

View File

@ -38,7 +38,6 @@ import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { Button } from "#enums/buttons";
import { EggSourceType } from "#app/enums/egg-source-types";
import AwaitableUiHandler from "./awaitable-ui-handler";
import { DropDown, DropDownLabel, DropDownOption, DropDownState, DropDownType, SortCriteria } from "./dropdown";
import { StarterContainer } from "./starter-container";
import { DropDownColumn, FilterBar } from "./filter-bar";
@ -1074,15 +1073,21 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
}
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer) {
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer, moveToTop?: boolean) {
super.showText(text, delay, callback, callbackDelay, prompt, promptDelay);
if (text?.indexOf("\n") === -1) {
this.starterSelectMessageBox.setSize(318, 28);
this.message.setY(-22);
const singleLine = text?.indexOf("\n") === -1;
this.starterSelectMessageBox.setSize(318, singleLine ? 28 : 42);
if (moveToTop) {
this.starterSelectMessageBox.setOrigin(0, 0);
this.starterSelectMessageBoxContainer.setY(0);
this.message.setY(4);
} else {
this.starterSelectMessageBox.setSize(318, 42);
this.message.setY(-37);
this.starterSelectMessageBoxContainer.setY(this.scene.game.canvas.height / 6);
this.starterSelectMessageBox.setOrigin(0, 1);
this.message.setY(singleLine ? -22 : -37);
}
this.starterSelectMessageBoxContainer.setVisible(!!text?.length);
@ -1291,6 +1296,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
if (this.tryStart(true)) {
success = true;
} else {
// pressing enter with an empty party -> display message with the controls
this.tutorialActive = true;
this.showText(i18next.t("starterSelectUiHandler:emptyParty"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), undefined, true);
error = true;
}
} else if (button === Button.CANCEL) {
@ -1806,7 +1814,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
options.push({
label: `x${sameSpeciesEggCost} ${i18next.t("starterSelectUiHandler:sameSpeciesEgg")}`,
handler: () => {
if (this.scene.gameData.eggs.length < 99 && (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost)) {
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost) {
if (this.scene.gameData.eggs.length >= 99) {
// Egg list full, show error message at the top of the screen and abort
this.showText(i18next.t("egg:tooManyEggs"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), 2000, false, undefined, true);
return false;
}
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
starterData.candyCount -= sameSpeciesEggCost;
}
@ -3531,9 +3544,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}, cancel, null, null, 19);
});
} else {
const handler = this.scene.ui.getHandler() as AwaitableUiHandler;
handler.tutorialActive = true;
this.scene.ui.showText(i18next.t("starterSelectUiHandler:invalidParty"), null, () => this.scene.ui.showText("", 0, () => handler.tutorialActive = false), null, true);
this.tutorialActive = true;
this.showText(i18next.t("starterSelectUiHandler:invalidParty"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), undefined, true);
}
return true;
}