From 3ee29d4e5dbc5c635040b7574652eb2b6959121a Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:53:35 -0400 Subject: [PATCH] Display opponents on saves Adds a text label displaying how many items aren't shown due to size limitations Reduces the items shown from 12 to 9 (or 8 items and the text label, if you have more than 9 items) Shows the opponent's team in the bottom right --- src/messages.ts | 3 ++ src/ui/save-slot-select-ui-handler.ts | 44 +++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/messages.ts b/src/messages.ts index 2259e78abfc..78b992804b4 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -19,6 +19,9 @@ export function getPokemonMessage(pokemon: Pokemon, content: string): string { * @returns {string} ex: "Wild Gengar", "Ectoplasma sauvage" */ export function getPokemonNameWithAffix(pokemon: Pokemon): string { + if (pokemon.scene.currentBattle == null) { + return pokemon.getNameToRender() + } switch (pokemon.scene.currentBattle.battleSpec) { case BattleSpec.DEFAULT: return !pokemon.isPlayer() diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index 3a3586ff361..82a70d51dd2 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -377,6 +377,15 @@ class SessionSlot extends Phaser.GameObjects.Container { const modifierIconsContainer = this.scene.add.container(148, 30); modifierIconsContainer.setScale(0.5); let visibleModifierIndex = 0; + let numberOfModifiers = 0 + const itemDisplayLimit = 9 + for (const m of data.modifiers) { + const modifier = m.toModifier(this.scene, modifiersModule[m.className]); + if (modifier instanceof PokemonHeldItemModifier) { + continue; + } + numberOfModifiers++; + } for (const m of data.modifiers) { const modifier = m.toModifier(this.scene, modifiersModule[m.className]); if (modifier instanceof PokemonHeldItemModifier) { @@ -385,11 +394,42 @@ class SessionSlot extends Phaser.GameObjects.Container { const icon = modifier.getIcon(this.scene, false); icon.setPosition(24 * visibleModifierIndex, 0); modifierIconsContainer.add(icon); - if (++visibleModifierIndex === 12) { + if (++visibleModifierIndex === (numberOfModifiers == itemDisplayLimit ? itemDisplayLimit : itemDisplayLimit - 1)) { break; } } - + if (numberOfModifiers > itemDisplayLimit) { + var plusText = addTextObject(this.scene, 24 * visibleModifierIndex + 20, 4, `+${numberOfModifiers - visibleModifierIndex}`, TextStyle.PARTY, { fontSize: "80px", color: "#f8f8f8" }); + plusText.setShadow(0, 0, null); + plusText.setStroke("#424242", 14); + plusText.setOrigin(1, 0); + modifierIconsContainer.add(plusText); + } + var spacing = 20 + if (data.enemyParty.length == 4) { + spacing = 17 + } + if (data.enemyParty.length == 5) { + spacing = 12 + } + if (data.enemyParty.length == 6) { + spacing = 10 + } + data.enemyParty.forEach((p, i) => { + const iconContainer = this.scene.add.container(24 * 9 + 1 + i*spacing, -1); + const pokemon = p.toPokemon(this.scene); + const icon = this.scene.addPokemonIcon(pokemon, 0, 0, 0, 0); + iconContainer.add(icon); + pokemon.destroy(); + modifierIconsContainer.add(iconContainer); + }) + if (true) { + const vsLabel = addTextObject(this.scene, 24 * 9 + 20, 15, `vs`, TextStyle.PARTY, { fontSize: "80px", color: "#f8f8f8" }); + vsLabel.setShadow(0, 0, null); + vsLabel.setStroke("#424242", 14); + vsLabel.setOrigin(1, 0); + modifierIconsContainer.add(vsLabel); + } this.add(modifierIconsContainer); }