mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-27 10:42:25 +02:00
Show names of regional and other forms where appropriate
This commit is contained in:
parent
102b4fa351
commit
be62e565fc
@ -710,6 +710,42 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the form name for species with just one form (regional variants, Floette, Ursaluna)
|
||||||
|
* @param species the species to check
|
||||||
|
* @returns the pokemon-form locale key for the single form name ("Alolan Form", "Eternal Flower" etc)
|
||||||
|
*/
|
||||||
|
getFormNameToDisplay(formIndex: number = 0, key?: string, append: boolean = false): string {
|
||||||
|
const formKey = key ?? (this.forms?.[formIndex!]?.formKey);
|
||||||
|
const formText = Utils.capitalizeString(formKey, "-", false, false) || "";
|
||||||
|
const speciesName = Utils.capitalizeString(Species[this.speciesId], "_", true, false);
|
||||||
|
let ret: string = "";
|
||||||
|
|
||||||
|
const region = this.getRegion();
|
||||||
|
if (this.speciesId === Species.ARCEUS) {
|
||||||
|
ret = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`);
|
||||||
|
} else if ([ SpeciesFormKey.MEGA_X, SpeciesFormKey.MEGA_Y, SpeciesFormKey.GIGANTAMAX_RAPID, SpeciesFormKey.GIGANTAMAX_SINGLE ].includes(formKey)) {
|
||||||
|
return i18next.t(`battlePokemonForm:${formKey}`, { pokemonName: "" });
|
||||||
|
} else if (region === Region.NORMAL || (this.speciesId === Species.GALAR_DARMANITAN && formIndex > 0) || this.speciesId === Species.PALDEA_TAUROS) {
|
||||||
|
const i18key = `pokemonForm:${speciesName}${formText}`;
|
||||||
|
if (i18next.exists(i18key)) {
|
||||||
|
ret = i18next.t(i18key);
|
||||||
|
} else {
|
||||||
|
const rootSpeciesName = Utils.capitalizeString(Species[this.getRootSpeciesId()], "_", true, false);
|
||||||
|
const i18RootKey = `pokemonForm:${rootSpeciesName}${formText}`;
|
||||||
|
ret = i18next.exists(i18RootKey) ? i18next.t(i18RootKey) : formText;
|
||||||
|
}
|
||||||
|
} else if (this.speciesId === Species.ETERNAL_FLOETTE) {
|
||||||
|
ret = i18next.t("pokemonForm:floetteEternalFlower");
|
||||||
|
} else if (this.speciesId === Species.BLOODMOON_URSALUNA) {
|
||||||
|
ret = i18next.t("pokemonForm:ursalunaBloodmoon");
|
||||||
|
} else {
|
||||||
|
const regionalName = i18next.t(`pokemonForm:regionalForm${Region[region]}`);
|
||||||
|
ret = regionalName;
|
||||||
|
}
|
||||||
|
return ret + (append ? this.name : "");
|
||||||
|
}
|
||||||
|
|
||||||
localize(): void {
|
localize(): void {
|
||||||
this.name = i18next.t(`pokemon:${Species[this.speciesId].toLowerCase()}`);
|
this.name = i18next.t(`pokemon:${Species[this.speciesId].toLowerCase()}`);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import type { SpeciesFormChange } from "#app/data/pokemon-forms";
|
|||||||
import { pokemonFormChanges } from "#app/data/pokemon-forms";
|
import { pokemonFormChanges } from "#app/data/pokemon-forms";
|
||||||
import type { LevelMoves } from "#app/data/balance/pokemon-level-moves";
|
import type { LevelMoves } from "#app/data/balance/pokemon-level-moves";
|
||||||
import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
|
import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
|
||||||
import type { PokemonForm } from "#app/data/pokemon-species";
|
|
||||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
import { allSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
import { allSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
||||||
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
|
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
|
||||||
@ -45,7 +44,7 @@ import { Button } from "#enums/buttons";
|
|||||||
import { EggSourceType } from "#enums/egg-source-types";
|
import { EggSourceType } from "#enums/egg-source-types";
|
||||||
import { StarterContainer } from "#app/ui/starter-container";
|
import { StarterContainer } from "#app/ui/starter-container";
|
||||||
import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters";
|
import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters";
|
||||||
import { BooleanHolder, capitalizeString, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, rgbHexToRgba, toReadableString } from "#app/utils";
|
import { BooleanHolder, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, rgbHexToRgba, toReadableString } from "#app/utils";
|
||||||
import type { Nature } from "#enums/nature";
|
import type { Nature } from "#enums/nature";
|
||||||
import BgmBar from "./bgm-bar";
|
import BgmBar from "./bgm-bar";
|
||||||
import * as Utils from "../utils";
|
import * as Utils from "../utils";
|
||||||
@ -893,31 +892,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Assign a form string to a given species and form
|
|
||||||
* @param formKey the form to format
|
|
||||||
* @param species the species to format
|
|
||||||
* @param speciesId whether the name of the species should be shown at the end
|
|
||||||
* @returns the formatted string
|
|
||||||
*/
|
|
||||||
getFormString(formKey: string, species: PokemonSpecies, append: boolean = false): string {
|
|
||||||
let label: string;
|
|
||||||
const formText = capitalizeString(formKey, "-", false, false) ?? "";
|
|
||||||
const speciesName = capitalizeString(this.getStarterSpecies(species).name, "_", true, false) ?? "";
|
|
||||||
if (species.speciesId === Species.ARCEUS) {
|
|
||||||
label = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`);
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
label = formText ? i18next.t(`pokemonForm:${speciesName}${formText}`) : "";
|
|
||||||
if (label === `${speciesName}${formText}`) {
|
|
||||||
label = i18next.t(`battlePokemonForm:${formKey}`, { pokemonName:species.name });
|
|
||||||
} else {
|
|
||||||
// If the label is only the form, we can append the name of the pokemon
|
|
||||||
label += append ? ` ${species.name}` : "";
|
|
||||||
}
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
processInput(button: Button): boolean {
|
processInput(button: Button): boolean {
|
||||||
if (this.blockInput) {
|
if (this.blockInput) {
|
||||||
return false;
|
return false;
|
||||||
@ -1354,12 +1328,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
this.prevolutions.map(pre => {
|
this.prevolutions.map(pre => {
|
||||||
const preSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[this.species.speciesId]);
|
const preSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[this.species.speciesId]);
|
||||||
|
const preFormIndex: number = preSpecies?.forms.find(f => f.formKey === pre.preFormKey)?.formIndex ?? 0;
|
||||||
|
|
||||||
const conditionText: string = pre.description;
|
const conditionText: string = pre.description;
|
||||||
|
|
||||||
options.push({
|
options.push({
|
||||||
label: pre.preFormKey ?
|
label: pre.preFormKey ?
|
||||||
this.getFormString(pre.preFormKey, preSpecies ?? this.species, true) :
|
(preSpecies ?? this.species).getFormNameToDisplay(preFormIndex, pre.preFormKey, true) :
|
||||||
(preSpecies ?? this.species).getExpandedSpeciesName(),
|
(preSpecies ?? this.species).getExpandedSpeciesName(),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]);
|
const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]);
|
||||||
@ -1400,7 +1375,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
options.push({
|
options.push({
|
||||||
label: evo.evoFormKey ?
|
label: evo.evoFormKey ?
|
||||||
this.getFormString(evo.evoFormKey, evoSpecies ?? this.species, true) :
|
(evoSpecies ?? this.species).getFormNameToDisplay(newFormIndex, evo.evoFormKey, true) :
|
||||||
(evoSpecies ?? this.species).getExpandedSpeciesName(),
|
(evoSpecies ?? this.species).getExpandedSpeciesName(),
|
||||||
style: isCaughtEvo && isFormCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
style: isCaughtEvo && isFormCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
@ -1424,6 +1399,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
handler: () => false
|
handler: () => false
|
||||||
});
|
});
|
||||||
this.battleForms.map(bf => {
|
this.battleForms.map(bf => {
|
||||||
|
const matchingForm = this.species?.forms.find(form => form.formKey === bf.formKey);
|
||||||
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
|
|
||||||
let conditionText:string = "";
|
let conditionText:string = "";
|
||||||
if (bf.trigger) {
|
if (bf.trigger) {
|
||||||
@ -1431,12 +1408,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
} else {
|
} else {
|
||||||
conditionText = "";
|
conditionText = "";
|
||||||
}
|
}
|
||||||
let label: string = this.getFormString(bf.formKey, this.species);
|
let label: string = this.species.getFormNameToDisplay(newFormIndex, bf.formKey);
|
||||||
if (label === "") {
|
if (label === "") {
|
||||||
label = this.species.name;
|
label = this.species.name;
|
||||||
}
|
}
|
||||||
const matchingForm = this.species?.forms.find(form => form.formKey === bf.formKey);
|
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
|
||||||
const isFormCaught = this.isFormCaught(this.species, newFormIndex);
|
const isFormCaught = this.isFormCaught(this.species, newFormIndex);
|
||||||
|
|
||||||
if (conditionText) {
|
if (conditionText) {
|
||||||
@ -2254,7 +2229,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
if (caughtAttr || forSeen) {
|
if (caughtAttr || forSeen) {
|
||||||
const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct?
|
const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct?
|
||||||
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
||||||
this.pokemonFormText.setText(this.getFormString((speciesForm as PokemonForm).formKey, species));
|
this.pokemonFormText.setText(species.getFormNameToDisplay(formIndex));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.setTypeIcons(null, null);
|
this.setTypeIcons(null, null);
|
||||||
|
@ -160,7 +160,7 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer {
|
|||||||
this.pokemonCandyCountText.setVisible(true);
|
this.pokemonCandyCountText.setVisible(true);
|
||||||
|
|
||||||
this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4));
|
this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4));
|
||||||
this.pokemonNameText.setText(species.getExpandedSpeciesName());
|
this.pokemonNameText.setText(species.name);
|
||||||
|
|
||||||
const hasEggMoves = species && speciesEggMoves.hasOwnProperty(species.speciesId);
|
const hasEggMoves = species && speciesEggMoves.hasOwnProperty(species.speciesId);
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import ConfirmUiHandler from "./confirm-ui-handler";
|
|||||||
import { StatsContainer } from "./stats-container";
|
import { StatsContainer } from "./stats-container";
|
||||||
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
|
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
|
||||||
import { addWindow } from "./ui-theme";
|
import { addWindow } from "./ui-theme";
|
||||||
import { Species } from "#enums/species";
|
|
||||||
|
|
||||||
interface LanguageSetting {
|
interface LanguageSetting {
|
||||||
infoContainerTextSize: string;
|
infoContainerTextSize: string;
|
||||||
@ -218,23 +217,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
|
|||||||
this.pokemonGenderText.setVisible(false);
|
this.pokemonGenderText.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const formKey = (pokemon.species?.forms?.[pokemon.formIndex!]?.formKey);
|
const formName = pokemon.species.getFormNameToDisplay(pokemon.formIndex);
|
||||||
const formText = Utils.capitalizeString(formKey, "-", false, false) || "";
|
|
||||||
const speciesName = Utils.capitalizeString(Species[pokemon.species.speciesId], "_", true, false);
|
|
||||||
|
|
||||||
let formName = "";
|
|
||||||
if (pokemon.species.speciesId === Species.ARCEUS) {
|
|
||||||
formName = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`);
|
|
||||||
} else {
|
|
||||||
const i18key = `pokemonForm:${speciesName}${formText}`;
|
|
||||||
if (i18next.exists(i18key)) {
|
|
||||||
formName = i18next.t(i18key);
|
|
||||||
} else {
|
|
||||||
const rootSpeciesName = Utils.capitalizeString(Species[pokemon.species.getRootSpeciesId()], "_", true, false);
|
|
||||||
const i18RootKey = `pokemonForm:${rootSpeciesName}${formText}`;
|
|
||||||
formName = i18next.exists(i18RootKey) ? i18next.t(i18RootKey) : formText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formName) {
|
if (formName) {
|
||||||
this.pokemonFormLabelText.setVisible(true);
|
this.pokemonFormLabelText.setVisible(true);
|
||||||
|
@ -53,7 +53,7 @@ import { EncounterPhase } from "#app/phases/encounter-phase";
|
|||||||
import { TitlePhase } from "#app/phases/title-phase";
|
import { TitlePhase } from "#app/phases/title-phase";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters";
|
import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters";
|
||||||
import { BooleanHolder, capitalizeString, fixedInt, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, randIntRange, rgbHexToRgba, toReadableString } from "#app/utils";
|
import { BooleanHolder, fixedInt, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, randIntRange, rgbHexToRgba, toReadableString } from "#app/utils";
|
||||||
import type { Nature } from "#enums/nature";
|
import type { Nature } from "#enums/nature";
|
||||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||||
|
|
||||||
@ -3408,15 +3408,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}) as StarterMoveset;
|
}) as StarterMoveset;
|
||||||
|
|
||||||
const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct?
|
const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct?
|
||||||
const formText = capitalizeString(species?.forms[formIndex!]?.formKey, "-", false, false); // TODO: is the bang correct?
|
const formText = species.getFormNameToDisplay(formIndex);
|
||||||
|
this.pokemonFormText.setText(formText);
|
||||||
const speciesName = capitalizeString(Species[species.speciesId], "_", true, false);
|
|
||||||
|
|
||||||
if (species.speciesId === Species.ARCEUS) {
|
|
||||||
this.pokemonFormText.setText(i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`));
|
|
||||||
} else {
|
|
||||||
this.pokemonFormText.setText(formText ? i18next.t(`pokemonForm:${speciesName}${formText}`) : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user