mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-05-05 07:54:09 +01:00
[Enhancement] Allow nickname assignment in the starter select UI. (#3456)
* add rename nickname in starter UI * update requested changes
This commit is contained in:
parent
57a4e1cc47
commit
d2eea96777
@ -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);
|
||||
}
|
||||
|
@ -198,6 +198,7 @@ export interface StarterAttributes {
|
||||
form?: integer;
|
||||
female?: boolean;
|
||||
shiny?: boolean;
|
||||
nickname?: string;
|
||||
}
|
||||
|
||||
export interface StarterPreferences {
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user