Form names are now localized when catching a pokemon (and probably hatching a egg since its the same dialogue)

This commit is contained in:
Jannik Tappert 2024-08-18 18:59:13 +02:00
parent d61c8f2870
commit 884d4434b9
1 changed files with 23 additions and 9 deletions

View File

@ -12,6 +12,7 @@ import ConfirmUiHandler from "./confirm-ui-handler";
import { StatsContainer } from "./stats-container";
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
import { addWindow } from "./ui-theme";
import {Species} from "#enums/species";
interface LanguageSetting {
infoContainerTextSize: string;
@ -226,7 +227,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
this.pokemonGenderText.setVisible(false);
}
if (pokemon.species.forms?.[pokemon.formIndex]?.formName) {
if (pokemon.species.forms?.[pokemon.formIndex]?.formName && pokemon.species.forms?.[pokemon.formIndex]?.formName !== "Normal") {
this.pokemonFormLabelText.setVisible(true);
this.pokemonFormText.setVisible(true);
const newForm = BigInt(1 << pokemon.formIndex) * DexAttr.DEFAULT_FORM;
@ -239,15 +240,28 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
this.pokemonFormLabelText.setShadowColor(getTextColor(TextStyle.WINDOW, true, this.scene.uiTheme));
}
const formName = pokemon.species.forms?.[pokemon.formIndex]?.formName;
this.pokemonFormText.setText(formName.length > this.numCharsBeforeCutoff ? formName.substring(0, this.numCharsBeforeCutoff - 3) + "..." : formName);
if (formName.length > this.numCharsBeforeCutoff) {
this.pokemonFormText.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.pokemonFormText.width, this.pokemonFormText.height), Phaser.Geom.Rectangle.Contains);
this.pokemonFormText.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip("", pokemon.species.forms?.[pokemon.formIndex]?.formName, true));
this.pokemonFormText.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
} else {
this.pokemonFormText.disableInteractive();
const pokemonForm = (pokemon.species?.forms?.[pokemon.formIndex!]?.formKey) || "";
let formName = "";
if (pokemonForm !== "") {
const formText = Utils.capitalizeString(pokemonForm, "-", false, false); // TODO: is the bang correct?
const speciesName = Utils.capitalizeString(Species[pokemon.species.getRootSpeciesId()], "_", true, false);
if (pokemon.species.speciesId === Species.ARCEUS) {
formName = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`);
} else {
formName = formText ? i18next.t(`pokemonForm:${speciesName}${formText}`) : "";
}
this.pokemonFormText.setText(formName.length > this.numCharsBeforeCutoff ? formName.substring(0, this.numCharsBeforeCutoff - 3) + "..." : formName);
if (formName.length > this.numCharsBeforeCutoff) {
this.pokemonFormText.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.pokemonFormText.width, this.pokemonFormText.height), Phaser.Geom.Rectangle.Contains);
this.pokemonFormText.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip("", formName, true));
this.pokemonFormText.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
} else {
this.pokemonFormText.disableInteractive();
}
}
} else {
this.pokemonFormLabelText.setVisible(false);
this.pokemonFormText.setVisible(false);