diff --git a/src/phases.ts b/src/phases.ts index db14dc022c4..46d1f4b98db 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -622,6 +622,11 @@ export class SelectStarterPhase extends Phase { if (starter.pokerus) { starterPokemon.pokerus = true; } + + if (starter.nickname) { + starterPokemon.nickname = starter.nickname; + } + if (this.scene.gameMode.isSplicedOnly) { starterPokemon.generateFusionSpecies(true); } diff --git a/src/system/game-data.ts b/src/system/game-data.ts index b483ada2829..0d35032d19b 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -198,6 +198,7 @@ export interface StarterAttributes { form?: integer; female?: boolean; shiny?: boolean; + nickname?: string; } export interface StarterPreferences { diff --git a/src/ui/rename-form-ui-handler.ts b/src/ui/rename-form-ui-handler.ts index 35127564b60..33885509344 100644 --- a/src/ui/rename-form-ui-handler.ts +++ b/src/ui/rename-form-ui-handler.ts @@ -36,17 +36,13 @@ export default class RenameFormUiHandler extends FormModalUiHandler { show(args: any[]): boolean { if (super.show(args)) { const config = args[0] as ModalConfig; - this.inputs[0].text = (args[1] as PlayerPokemon).getNameToRender(); - + if (args[1] && typeof (args[1] as PlayerPokemon).getNameToRender === "function") { + this.inputs[0].text = (args[1] as PlayerPokemon).getNameToRender(); + } else { + this.inputs[0].text = args[1]; + } this.submitAction = (_) => { this.sanitizeInputs(); - // const onFail = () => { - // this.scene.ui.setModeWithoutClear(Mode.RENAME_POKEMON, Object.assign(config)); - // this.scene.ui.playError(); - // }; - // if (!this.inputs[0].text) { - // return onFail(); - // } const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); config.buttonActions[0](sanitizedName); return true; diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 43af8d456c1..df661c37fa4 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -55,6 +55,7 @@ export interface Starter { nature: Nature; moveset?: StarterMoveset; pokerus: boolean; + nickname?: string; } interface LanguageSetting { @@ -1542,6 +1543,33 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }); } } + options.push({ + label: i18next.t("menu:rename"), + handler: () => { + ui.playSelect(); + let nickname = starterAttributes.nickname ? String(starterAttributes.nickname) : ""; + nickname = decodeURIComponent(escape(atob(nickname))); + ui.setModeWithoutClear(Mode.RENAME_POKEMON, { + buttonActions: [ + (sanitizedName: string) => { + ui.playSelect(); + starterAttributes.nickname = sanitizedName; + const name = decodeURIComponent(escape(atob(starterAttributes.nickname))); + if (name.length > 0) { + this.pokemonNameText.setText(name); + } else { + this.pokemonNameText.setText(species.name); + } + ui.setMode(Mode.STARTER_SELECT); + }, + () => { + ui.setMode(Mode.STARTER_SELECT); + } + ] + }, nickname); + return true; + } + }); const showUseCandies = () => { // this lets you use your candies const options: any[] = []; // TODO: add proper type if (!(passiveAttr & PassiveAttr.UNLOCKED)) { @@ -2573,7 +2601,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) { this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4)); - this.pokemonNameText.setText(species.name); + if (starterAttributes?.nickname) { + const name = decodeURIComponent(escape(atob(starterAttributes.nickname))); + this.pokemonNameText.setText(name); + } else { + this.pokemonNameText.setText(species.name); + } if (this.speciesStarterDexEntry?.caughtAttr) { const colorScheme = starterColors[species.speciesId]; @@ -3215,7 +3248,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { passive: !(thisObj.scene.gameData.starterData[starterSpecies.speciesId].passiveAttr ^ (PassiveAttr.ENABLED | PassiveAttr.UNLOCKED)), nature: thisObj.starterNatures[i] as Nature, moveset: thisObj.starterMovesets[i], - pokerus: thisObj.pokerusSpecies.includes(starterSpecies) + pokerus: thisObj.pokerusSpecies.includes(starterSpecies), + nickname: thisObj.starterPreferences[starterSpecies.speciesId]?.nickname, }; })); };