From 5e51a9e8cb47c774f4914fe0b08e3559f145e970 Mon Sep 17 00:00:00 2001 From: EmberCM Date: Wed, 26 Jun 2024 14:30:59 -0500 Subject: [PATCH] Create tooltip to show Pokemon generation --- src/locales/de/battle-info.ts | 5 +++++ src/locales/de/config.ts | 2 ++ src/locales/en/battle-info.ts | 5 +++++ src/locales/en/config.ts | 2 ++ src/locales/es/battle-info.ts | 5 +++++ src/locales/es/config.ts | 2 ++ src/locales/fr/battle-info.ts | 5 +++++ src/locales/fr/config.ts | 2 ++ src/locales/it/battle-info.ts | 5 +++++ src/locales/it/config.ts | 2 ++ src/locales/ko/battle-info.ts | 5 +++++ src/locales/ko/config.ts | 2 ++ src/locales/pt_BR/battle-info.ts | 5 +++++ src/locales/pt_BR/config.ts | 2 ++ src/locales/zh_CN/battle-info.ts | 5 +++++ src/locales/zh_CN/config.ts | 2 ++ src/locales/zh_TW/battle-info.ts | 5 +++++ src/locales/zh_TW/config.ts | 2 ++ src/ui/battle-info.ts | 10 ++++++++++ 19 files changed, 73 insertions(+) create mode 100644 src/locales/de/battle-info.ts create mode 100644 src/locales/en/battle-info.ts create mode 100644 src/locales/es/battle-info.ts create mode 100644 src/locales/fr/battle-info.ts create mode 100644 src/locales/it/battle-info.ts create mode 100644 src/locales/ko/battle-info.ts create mode 100644 src/locales/pt_BR/battle-info.ts create mode 100644 src/locales/zh_CN/battle-info.ts create mode 100644 src/locales/zh_TW/battle-info.ts diff --git a/src/locales/de/battle-info.ts b/src/locales/de/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/de/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/de/config.ts b/src/locales/de/config.ts index b7bb827d8d3..9509b350d44 100644 --- a/src/locales/de/config.ts +++ b/src/locales/de/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const deConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/en/battle-info.ts b/src/locales/en/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/en/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/en/config.ts b/src/locales/en/config.ts index fbbae3df329..68b479e04f2 100644 --- a/src/locales/en/config.ts +++ b/src/locales/en/config.ts @@ -4,6 +4,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const enConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/es/battle-info.ts b/src/locales/es/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/es/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/es/config.ts b/src/locales/es/config.ts index e09224ce85e..e20b84dc61e 100644 --- a/src/locales/es/config.ts +++ b/src/locales/es/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const esConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/fr/battle-info.ts b/src/locales/fr/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/fr/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/fr/config.ts b/src/locales/fr/config.ts index 6bc5a53a376..0c8fbbb6d33 100644 --- a/src/locales/fr/config.ts +++ b/src/locales/fr/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const frConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/it/battle-info.ts b/src/locales/it/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/it/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/it/config.ts b/src/locales/it/config.ts index fa0ddb5add2..a45bbb8535a 100644 --- a/src/locales/it/config.ts +++ b/src/locales/it/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const itConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/ko/battle-info.ts b/src/locales/ko/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/ko/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/ko/config.ts b/src/locales/ko/config.ts index 10fa5cb9a3d..c86ea8b026c 100644 --- a/src/locales/ko/config.ts +++ b/src/locales/ko/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const koConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/pt_BR/battle-info.ts b/src/locales/pt_BR/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/pt_BR/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/pt_BR/config.ts b/src/locales/pt_BR/config.ts index 53195fbc32e..b9aec9ffddf 100644 --- a/src/locales/pt_BR/config.ts +++ b/src/locales/pt_BR/config.ts @@ -4,6 +4,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const ptBrConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/zh_CN/battle-info.ts b/src/locales/zh_CN/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/zh_CN/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/zh_CN/config.ts b/src/locales/zh_CN/config.ts index 169c91535ed..495f528e86f 100644 --- a/src/locales/zh_CN/config.ts +++ b/src/locales/zh_CN/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const zhCnConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/locales/zh_TW/battle-info.ts b/src/locales/zh_TW/battle-info.ts new file mode 100644 index 00000000000..f24dad46c6c --- /dev/null +++ b/src/locales/zh_TW/battle-info.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/interfaces/locales"; + +export const battleInfo: SimpleTranslationEntries = { + "generation": "Generation {{generation}}", +} as const; diff --git a/src/locales/zh_TW/config.ts b/src/locales/zh_TW/config.ts index 1cbb4e6e2c1..d3f9b866f08 100644 --- a/src/locales/zh_TW/config.ts +++ b/src/locales/zh_TW/config.ts @@ -2,6 +2,7 @@ import { ability } from "./ability"; import { abilityTriggers } from "./ability-trigger"; import { PGFachv, PGMachv } from "./achv"; import { battle } from "./battle"; +import { battleInfo } from "./battle-info"; import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { berry } from "./berry"; import { bgmName } from "./bgm-name"; @@ -47,6 +48,7 @@ export const zhTwConfig = { ability: ability, abilityTriggers: abilityTriggers, battle: battle, + battleInfo: battleInfo, battleMessageUiHandler: battleMessageUiHandler, berry: berry, bgmName: bgmName, diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index c246af73d07..828e08e8d2c 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -10,6 +10,7 @@ import { getVariantTint } from "#app/data/variant"; import { BattleStat } from "#app/data/battle-stat"; import BattleFlyout from "./battle-flyout"; import { WindowVariant, addWindow } from "./ui-theme"; +import i18next from "i18next"; const battleStatOrder = [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.ACC, BattleStat.EVA, BattleStat.SPD ]; @@ -328,6 +329,11 @@ export default class BattleInfo extends Phaser.GameObjects.Container { } if (!this.player) { + if (this.nameText.visible) { + this.nameText.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, i18next.t("battleInfo:generation", { generation: pokemon.species.generation }))); + this.nameText.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip()); + } + const dexEntry = pokemon.scene.gameData.dexData[pokemon.species.speciesId]; this.ownedIcon.setVisible(!!dexEntry.caughtAttr); const opponentPokemonDexAttr = pokemon.getDexAttr(); @@ -644,6 +650,10 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.nameText.setText(displayName); this.lastName = pokemon.name; + + if (this.nameText.visible) { + this.nameText.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.nameText.width, this.nameText.height), Phaser.Geom.Rectangle.Contains); + } } updatePokemonExp(pokemon: Pokemon, instant?: boolean, levelDurationMultiplier: number = 1): Promise {