From 1e63f99765ed0575ba12b721821e86a601fb3809 Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:06:03 -0400 Subject: [PATCH 1/8] Added trainer team bar --- src/battle-scene.ts | 6 +++++ src/ui/trainer-team-bar.ts | 54 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/ui/trainer-team-bar.ts diff --git a/src/battle-scene.ts b/src/battle-scene.ts index ba0720baab2..4cc837cada8 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -54,6 +54,7 @@ import {InputsController} from "./inputs-controller"; import {UiInputs} from "./ui-inputs"; import { NewArenaEvent } from "./events/battle-scene"; import ArenaFlyout from "./ui/arena-flyout"; +import TeamBar from "./ui/trainer-team-bar"; import { EaseType } from "#enums/ease-type"; import { Abilities } from "#enums/abilities"; import { BattleSpec } from "#enums/battle-spec"; @@ -220,6 +221,7 @@ export default class BattleScene extends SceneBase { private modifierBar: ModifierBar; private enemyModifierBar: ModifierBar; public arenaFlyout: ArenaFlyout; + public trainerBar: TeamBar; private fieldOverlay: Phaser.GameObjects.Rectangle; private shopOverlay: Phaser.GameObjects.Rectangle; @@ -473,6 +475,9 @@ export default class BattleScene extends SceneBase { this.arenaFlyout = new ArenaFlyout(this); this.fieldUI.add(this.arenaFlyout); this.fieldUI.moveBelow(this.arenaFlyout, this.fieldOverlay); + this.trainerBar = new TeamBar(this); + this.fieldUI.add(this.trainerBar); + this.fieldUI.moveBelow(this.trainerBar, this.fieldOverlay); this.updateUIPositions(); @@ -1396,6 +1401,7 @@ export default class BattleScene extends SceneBase { } processInfoButton(pressed: boolean): void { this.arenaFlyout.toggleFlyout(pressed); + this.trainerBar.toggleFlyout(pressed); } showFieldOverlay(duration: integer): Promise { diff --git a/src/ui/trainer-team-bar.ts b/src/ui/trainer-team-bar.ts new file mode 100644 index 00000000000..7051ad5434e --- /dev/null +++ b/src/ui/trainer-team-bar.ts @@ -0,0 +1,54 @@ +import BattleScene from "../battle-scene"; +import {addTextObject, TextStyle} from "./text"; +import i18next from "i18next"; +import * as Utils from "#app/utils"; +import { EnemyPokemon } from "#app/field/pokemon.js"; + +export default class TeamBar extends Phaser.GameObjects.Container { + // Public vars + public party: EnemyPokemon[]; + public gamescene: BattleScene; + + // Private vars + private bg: Phaser.GameObjects.NineSlice; + private teamIcons: Array; + private tween: Phaser.Tweens.Tween; + private components: any[] = []; + + // Constructor + constructor(scene: Phaser.Scene) { + super(scene, -150, 0); + this.gamescene = scene as BattleScene; + this.components = [this] + this.bg = this.scene.add.nineslice(-5, -5, "ability_bar_left", null, 200, 100, 0, 0, 10, 10); + this.bg.setOrigin(0, 0); + this.add(this.bg); + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 6; j++) { + if (i == 0) this.teamIcons[j] = [] + this.teamIcons[j][i] = this.scene.add.sprite(0, 0, "pb_tray_ball", "empty") + this.teamIcons[j][i].setOrigin(0, 0); + //this.teamIcons[j][i].setVisible(false); + this.add(this.teamIcons[j][i]) + this.components.push(this.teamIcons[j][i]) + } + } + } + + /* + Show or hide the BGM bar. + @param {boolean} visible Whether to show or hide the BGM bar. + */ + public toggleFlyout(visible: boolean): void { + this.scene.tweens.add({ + targets: this, + x: visible ? 0 : -200, + alpha: visible ? 1 : 0, + duration: 500, + ease: "Sine.easeInOut" + //onComplete: () => { + // + //} + }); + } +} \ No newline at end of file From 96146891dcf7c97c5b34985f99d48f5158a3144c Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:08:50 -0400 Subject: [PATCH 2/8] Change activation trigger Switch the bar to show with the C key instead of the V key (no space with V key) --- src/battle-scene.ts | 1 - src/ui/battle-info.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 4cc837cada8..1d443c0c288 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1401,7 +1401,6 @@ export default class BattleScene extends SceneBase { } processInfoButton(pressed: boolean): void { this.arenaFlyout.toggleFlyout(pressed); - this.trainerBar.toggleFlyout(pressed); } showFieldOverlay(duration: integer): Promise { diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 3b889228e27..e822b2664db 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -442,6 +442,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { ease: "Sine.easeInOut", alpha: visible ? 1 : 0 }); + (this.scene as BattleScene).trainerBar.toggleFlyout(visible); } updateBossSegments(pokemon: EnemyPokemon): void { From adb2f90d962004a500bdb44c973c500c2cd23638 Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:26:12 -0400 Subject: [PATCH 3/8] Commit --- src/battle-scene.ts | 11 ++++++-- src/ui/trainer-team-bar.ts | 56 +++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 1d443c0c288..4b517dc4d88 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -472,12 +472,12 @@ export default class BattleScene extends SceneBase { this.luckLabelText.setVisible(false); this.fieldUI.add(this.luckLabelText); - this.arenaFlyout = new ArenaFlyout(this); - this.fieldUI.add(this.arenaFlyout); - this.fieldUI.moveBelow(this.arenaFlyout, this.fieldOverlay); this.trainerBar = new TeamBar(this); this.fieldUI.add(this.trainerBar); this.fieldUI.moveBelow(this.trainerBar, this.fieldOverlay); + this.arenaFlyout = new ArenaFlyout(this); + this.fieldUI.add(this.arenaFlyout); + this.fieldUI.moveBelow(this.arenaFlyout, this.fieldOverlay); this.updateUIPositions(); @@ -1400,6 +1400,11 @@ export default class BattleScene extends SceneBase { this.fieldUI.moveBelow(gameObject, this.fieldOverlay); } processInfoButton(pressed: boolean): void { + if (pressed) { + this.trainerBar.tempToggleFlyout(false) + } else { + this.trainerBar.revertFlyout() + } this.arenaFlyout.toggleFlyout(pressed); } diff --git a/src/ui/trainer-team-bar.ts b/src/ui/trainer-team-bar.ts index 7051ad5434e..4407b4557a1 100644 --- a/src/ui/trainer-team-bar.ts +++ b/src/ui/trainer-team-bar.ts @@ -11,28 +11,20 @@ export default class TeamBar extends Phaser.GameObjects.Container { // Private vars private bg: Phaser.GameObjects.NineSlice; - private teamIcons: Array; + private teamIcons: Array = []; private tween: Phaser.Tweens.Tween; private components: any[] = []; + private shown: boolean = false; + private overridden: boolean = false; // Constructor constructor(scene: Phaser.Scene) { - super(scene, -150, 0); + super(scene, -200, -107); this.gamescene = scene as BattleScene; this.components = [this] - this.bg = this.scene.add.nineslice(-5, -5, "ability_bar_left", null, 200, 100, 0, 0, 10, 10); + this.bg = this.scene.add.nineslice(-5, -5, "ability_bar_left", null, 200, 70, 10, 10); this.bg.setOrigin(0, 0); this.add(this.bg); - for (var i = 0; i < 1; i++) { - for (var j = 0; j < 6; j++) { - if (i == 0) this.teamIcons[j] = [] - this.teamIcons[j][i] = this.scene.add.sprite(0, 0, "pb_tray_ball", "empty") - this.teamIcons[j][i].setOrigin(0, 0); - //this.teamIcons[j][i].setVisible(false); - this.add(this.teamIcons[j][i]) - this.components.push(this.teamIcons[j][i]) - } - } } /* @@ -40,15 +32,41 @@ export default class TeamBar extends Phaser.GameObjects.Container { @param {boolean} visible Whether to show or hide the BGM bar. */ public toggleFlyout(visible: boolean): void { + //console.log("Update team bar", visible) + if (this.overridden) return; // Don't toggle the state if it has been overridden + this.shown = visible this.scene.tweens.add({ targets: this, - x: visible ? 0 : -200, - alpha: visible ? 1 : 0, + x: visible ? -100 : -200, duration: 500, - ease: "Sine.easeInOut" - //onComplete: () => { - // - //} + ease: "Sine.easeInOut", + onUpdate: () => { + } + }); + } + public tempToggleFlyout(visible: boolean): void { + this.overridden = true + //console.log("Update team bar", visible) + this.scene.tweens.add({ + targets: this, + x: visible ? -100 : -200, + duration: 500, + ease: "Sine.easeInOut", + onUpdate: () => { + } + }); + } + public revertFlyout(): void { + var visible = this.shown + this.overridden = false + //console.log("Update team bar", visible) + this.scene.tweens.add({ + targets: this, + x: visible ? -100 : -200, + duration: 500, + ease: "Sine.easeInOut", + onUpdate: () => { + } }); } } \ No newline at end of file From 1b22cafee3949d0ccd243ea7dbf95b880a7ed63b Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:31:20 -0400 Subject: [PATCH 4/8] Undo all changes --- src/battle-scene.ts | 10 ------ src/ui/trainer-team-bar.ts | 72 -------------------------------------- 2 files changed, 82 deletions(-) delete mode 100644 src/ui/trainer-team-bar.ts diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 4b517dc4d88..ba0720baab2 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -54,7 +54,6 @@ import {InputsController} from "./inputs-controller"; import {UiInputs} from "./ui-inputs"; import { NewArenaEvent } from "./events/battle-scene"; import ArenaFlyout from "./ui/arena-flyout"; -import TeamBar from "./ui/trainer-team-bar"; import { EaseType } from "#enums/ease-type"; import { Abilities } from "#enums/abilities"; import { BattleSpec } from "#enums/battle-spec"; @@ -221,7 +220,6 @@ export default class BattleScene extends SceneBase { private modifierBar: ModifierBar; private enemyModifierBar: ModifierBar; public arenaFlyout: ArenaFlyout; - public trainerBar: TeamBar; private fieldOverlay: Phaser.GameObjects.Rectangle; private shopOverlay: Phaser.GameObjects.Rectangle; @@ -472,9 +470,6 @@ export default class BattleScene extends SceneBase { this.luckLabelText.setVisible(false); this.fieldUI.add(this.luckLabelText); - this.trainerBar = new TeamBar(this); - this.fieldUI.add(this.trainerBar); - this.fieldUI.moveBelow(this.trainerBar, this.fieldOverlay); this.arenaFlyout = new ArenaFlyout(this); this.fieldUI.add(this.arenaFlyout); this.fieldUI.moveBelow(this.arenaFlyout, this.fieldOverlay); @@ -1400,11 +1395,6 @@ export default class BattleScene extends SceneBase { this.fieldUI.moveBelow(gameObject, this.fieldOverlay); } processInfoButton(pressed: boolean): void { - if (pressed) { - this.trainerBar.tempToggleFlyout(false) - } else { - this.trainerBar.revertFlyout() - } this.arenaFlyout.toggleFlyout(pressed); } diff --git a/src/ui/trainer-team-bar.ts b/src/ui/trainer-team-bar.ts deleted file mode 100644 index 4407b4557a1..00000000000 --- a/src/ui/trainer-team-bar.ts +++ /dev/null @@ -1,72 +0,0 @@ -import BattleScene from "../battle-scene"; -import {addTextObject, TextStyle} from "./text"; -import i18next from "i18next"; -import * as Utils from "#app/utils"; -import { EnemyPokemon } from "#app/field/pokemon.js"; - -export default class TeamBar extends Phaser.GameObjects.Container { - // Public vars - public party: EnemyPokemon[]; - public gamescene: BattleScene; - - // Private vars - private bg: Phaser.GameObjects.NineSlice; - private teamIcons: Array = []; - private tween: Phaser.Tweens.Tween; - private components: any[] = []; - private shown: boolean = false; - private overridden: boolean = false; - - // Constructor - constructor(scene: Phaser.Scene) { - super(scene, -200, -107); - this.gamescene = scene as BattleScene; - this.components = [this] - this.bg = this.scene.add.nineslice(-5, -5, "ability_bar_left", null, 200, 70, 10, 10); - this.bg.setOrigin(0, 0); - this.add(this.bg); - } - - /* - Show or hide the BGM bar. - @param {boolean} visible Whether to show or hide the BGM bar. - */ - public toggleFlyout(visible: boolean): void { - //console.log("Update team bar", visible) - if (this.overridden) return; // Don't toggle the state if it has been overridden - this.shown = visible - this.scene.tweens.add({ - targets: this, - x: visible ? -100 : -200, - duration: 500, - ease: "Sine.easeInOut", - onUpdate: () => { - } - }); - } - public tempToggleFlyout(visible: boolean): void { - this.overridden = true - //console.log("Update team bar", visible) - this.scene.tweens.add({ - targets: this, - x: visible ? -100 : -200, - duration: 500, - ease: "Sine.easeInOut", - onUpdate: () => { - } - }); - } - public revertFlyout(): void { - var visible = this.shown - this.overridden = false - //console.log("Update team bar", visible) - this.scene.tweens.add({ - targets: this, - x: visible ? -100 : -200, - duration: 500, - ease: "Sine.easeInOut", - onUpdate: () => { - } - }); - } -} \ No newline at end of file From c296fcbbcd22ca946bb55f9016a2e097b552347b Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:32:13 -0400 Subject: [PATCH 5/8] Revert but for real this time --- src/ui/battle-info.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index e822b2664db..3b889228e27 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -442,7 +442,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container { ease: "Sine.easeInOut", alpha: visible ? 1 : 0 }); - (this.scene as BattleScene).trainerBar.toggleFlyout(visible); } updateBossSegments(pokemon: EnemyPokemon): void { From 2b40ac7d584beafde76ea977d47dece72ad2365e Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:59:27 -0400 Subject: [PATCH 6/8] Team display shows on bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flyout soon™ --- src/battle-scene.ts | 1 + src/field/pokemon.ts | 2 + src/phases.ts | 29 +++++ src/system/settings/settings.ts | 5 + src/ui/battle-info.ts | 201 +++++++++++++++++++++++++++++++- 5 files changed, 236 insertions(+), 2 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index ba0720baab2..743fe467d1c 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -112,6 +112,7 @@ export default class BattleScene extends SceneBase { public damageNumbersMode: integer = 0; public reroll: boolean = false; public showMovesetFlyout: boolean = true; + public showTeams: boolean = true; public showArenaFlyout: boolean = true; public showTimeOfDayWidget: boolean = true; public timeOfDayAnimation: EaseType = EaseType.NONE; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index b76717d7d44..cfae5072237 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -108,6 +108,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { private shinySparkle: Phaser.GameObjects.Sprite; + public usedInBattle: boolean = false; + constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData) { super(scene, x, y); diff --git a/src/phases.ts b/src/phases.ts index df7314e6285..fc8ed5ec591 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1873,6 +1873,9 @@ export class TurnInitPhase extends FieldPhase { if (pokemon?.isActive()) { if (pokemon.isPlayer()) { this.scene.currentBattle.addParticipant(pokemon as PlayerPokemon); + } else { + pokemon.usedInBattle = true; + pokemon.getBattleInfo().iconsActive = true } pokemon.resetTurnData(); @@ -1881,6 +1884,32 @@ export class TurnInitPhase extends FieldPhase { } }); + var Pt = this.scene.getEnemyParty() + var Pt2 = Pt.slice() + if (Pt2.length > 1) { + Pt2[1] = Pt[0] + Pt2[0] = Pt[1] + } + Pt.forEach((pokemon, i) => { + if (pokemon.hasTrainer() || true) { + console.log(i) + if (pokemon.getFieldIndex() == 1 && pokemon.isOnField()) { + // Switch this to cycle between + // - hiding the top mon's team bar + // - showing the bottom mon's team bar with its active slots reversed + if (false) { + pokemon.getBattleInfo().displayParty(Pt) + Pt[0].getBattleInfo().switchIconVisibility(false); // Make the top mon's team bar go away + Pt[0].getBattleInfo().iconsActive = false; // Prevent the top mon from re-opening its bar + } else { + pokemon.getBattleInfo().displayParty(Pt2) + } + } else { + pokemon.getBattleInfo().displayParty(Pt) + } + } + }) + this.scene.pushPhase(new TurnStartPhase(this.scene)); this.end(); diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index b09de095259..bf3a5359fff 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -98,6 +98,7 @@ export const SettingKeys = { SE_Volume: "SE_VOLUME", Music_Preference: "MUSIC_PREFERENCE", Show_BGM_Bar: "SHOW_BGM_BAR", + Show_Pokemon_Teams: "SHOW_POKEMON_TEAMS" }; /** @@ -645,6 +646,10 @@ export function setSetting(scene: BattleScene, setting: string, value: integer): case SettingKeys.Show_Moveset_Flyout: scene.showMovesetFlyout = Setting[index].options[value].value === "On"; break; + case SettingKeys.Show_Pokemon_Teams: + // Currently not used + scene.showTeams = Setting[index].options[value].value === "On"; + break; case SettingKeys.Show_Arena_Flyout: scene.showArenaFlyout = Setting[index].options[value].value === "On"; break; diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 3b889228e27..652718342bb 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -70,6 +70,15 @@ export default class BattleInfo extends Phaser.GameObjects.Container { public flyoutMenu?: BattleFlyout; + private teamIcons: Phaser.GameObjects.Sprite[]; + private teamIconOver: Phaser.GameObjects.Sprite[]; + private teamIconsShow: boolean[]; + public iconsActive: boolean = false; + private teamCount: integer = 0; + private showingTeam: boolean = false; + private pressedShow: boolean = false; + private override: boolean = false; + constructor(scene: Phaser.Scene, x: number, y: number, player: boolean) { super(scene, x, y); this.baseY = y; @@ -114,6 +123,27 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.ownedIcon.setPositionRelative(this.nameText, 0, 11.75); this.add(this.ownedIcon); + this.teamIcons = new Array(6); + this.teamIconOver = new Array(6); + this.teamIconsShow = new Array(6).fill(false); + + for (var ballindex = 0; ballindex < 6; ballindex++) { + this.teamIcons[ballindex] = this.scene.add.sprite(0, 0, "pb_tray_ball", "empty") + this.teamIcons[ballindex].setName("pb_teamball_" + ballindex); + this.teamIcons[ballindex].setVisible(true); + this.teamIcons[ballindex].setAlpha(0); + this.teamIcons[ballindex].setOrigin(0, 0); + this.teamIcons[ballindex].setPositionRelative(this.nameText, 6 * ballindex, 11.75); + this.add(this.teamIcons[ballindex]); + this.teamIconOver[ballindex] = this.scene.add.sprite(0, 0, "pb_tray_ball", "empty") + this.teamIconOver[ballindex].setName("pb_teamball_" + ballindex); + this.teamIconOver[ballindex].setVisible(true); + this.teamIconOver[ballindex].setAlpha(0); + this.teamIconOver[ballindex].setOrigin(0, 0); + this.teamIconOver[ballindex].setPositionRelative(this.nameText, 6 * ballindex, 11.75); + this.add(this.teamIconOver[ballindex]); + } + this.championRibbon = this.scene.add.sprite(0, 0, "champion_ribbon"); this.championRibbon.setName("icon_champion_ribbon"); this.championRibbon.setVisible(false); @@ -484,6 +514,116 @@ export default class BattleInfo extends Phaser.GameObjects.Container { } } + displayParty(overwriteparty?: Pokemon[], useparty?: EnemyPokemon[]): void { + // Floor 8: 2 pokemon + // Floor 25: 3 + // Floor 55: 4 + // Floor 95: 5 + // Floor 145: 6 + // Floor 195: 6 + var party = (this.scene as BattleScene).getEnemyParty() + if (useparty != undefined) { + console.debug("Using specified enemy party"); + //party = useparty; + } else if (overwriteparty != undefined) { + console.debug("Using specified party"); + } + var P; + if (useparty != undefined) { + //console.debug("Using specified enemy party"); + P = useparty; + } else if (overwriteparty != undefined) { + //console.debug("Using specified party"); + P = overwriteparty + } else { + P = party + } + var staticparty = (this.scene as BattleScene).getEnemyParty() + var states = new Array(6) + for (var i = 0; i < 6; i++) { + states[i] = "empty"; + } + var total_visible = 0 + for (var i = 0; i < P.length; i++) { + states[i] = "ball" + if (!party[i].hp) { + states[i] = "faint" + } else if (party[i].status) { + states[i] = "ball" + } + if (P[i].isOnField()) { + //console.log(P[i].name + " is in battle; set it as seen") + P[i].usedInBattle = true + } + if (P[i].usedInBattle) total_visible++; + //console.log(P[i].name, P[i].getIconAtlasKey(true)) + } + console.log("Updating ball icons for party (" + P.length + ")") + if (staticparty.length > 0) { + for (var i = 0; i < staticparty.length; i++) { + //console.log(i, staticparty[i].name) + } + } + var Spacing = P.length == 6 ? 6 : 8 + this.teamCount = P.length + for (var ballindex = 0; ballindex < 6; ballindex++) { + //console.log(ballindex + ": setting icon " + states[ballindex]) + if (states[ballindex] == "ball" && P[ballindex].usedInBattle) { + this.teamIcons[ballindex].setTexture(P[ballindex].getIconAtlasKey(true)) + this.teamIcons[ballindex].setFrame(P[ballindex].getIconId(true)) + this.teamIcons[ballindex].setPositionRelative(this.nameText, Spacing * ballindex - 3, 11.75 - 4); + this.teamIcons[ballindex].setDisplaySize(18 * 0.8, 15 * 0.8) + this.teamIconOver[ballindex].setTexture(P[ballindex].getIconAtlasKey(true)) + this.teamIconOver[ballindex].setFrame(P[ballindex].getIconId(true)) + this.teamIconOver[ballindex].setPositionRelative(this.nameText, Spacing * ballindex - 3, 11.75 - 4); + this.teamIconOver[ballindex].setDisplaySize(18 * 0.8, 15 * 0.8) + this.teamIconOver[ballindex].setVisible(true) + this.teamIconsShow[ballindex] = true + if (P[ballindex].status && P[ballindex].hp) { + switch (P[ballindex].status.effect) { + case StatusEffect.NONE: + // Uncallable; replaced by "ball" + break; + case StatusEffect.POISON: + this.teamIconOver[ballindex].setTintFill(0xe40dfc) + break; + case StatusEffect.TOXIC: + this.teamIconOver[ballindex].setTintFill(0xfa2590) + break; + case StatusEffect.PARALYSIS: + this.teamIconOver[ballindex].setTintFill(0xf7ec1e) + break; + case StatusEffect.SLEEP: + this.teamIconOver[ballindex].setTintFill(0x54bfaa) + break; + case StatusEffect.FREEZE: + this.teamIconOver[ballindex].setTintFill(0xcbf0f2) + break; + case StatusEffect.BURN: + this.teamIconOver[ballindex].setTintFill(0xf51905) + break; + case StatusEffect.FAINT: + // Uncallable; replaced by "faint" + break; + } + } else { + this.teamIconOver[ballindex].clearTint() + this.teamIconOver[ballindex].setVisible(false) + this.teamIconsShow[ballindex] = false + } + } else { + this.teamIcons[ballindex].setTexture("pb_tray_ball") + this.teamIcons[ballindex].setFrame(states[ballindex]) + this.teamIcons[ballindex].setPositionRelative(this.nameText, Spacing * ballindex, 11.75); + this.teamIcons[ballindex].setDisplaySize(7, 7) + this.teamIcons[ballindex].setVisible(states[ballindex] != 'empty') + this.teamIconOver[ballindex].clearTint() + this.teamIconOver[ballindex].setVisible(false) + this.teamIconsShow[ballindex] = false + } + } + } + setOffset(offset: boolean): void { if (this.offset === offset) { return; @@ -532,11 +672,15 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (this.lastStatus !== StatusEffect.NONE) { this.statusIndicator.setFrame(StatusEffect[this.lastStatus].toLowerCase()); + } else if (this.player) { + this.statusIndicator.setVisible(!!this.lastStatus); + } else { + this.statusIndicator.setVisible(!!this.lastStatus); + this.switchIconVisibility(this.showingTeam, true) } - this.statusIndicator.setVisible(!!this.lastStatus); if (!this.player && this.ownedIcon.visible) { - this.ownedIcon.setAlpha(this.statusIndicator.visible ? 0 : 1); + this.switchIconVisibility(this.showingTeam, true) } } @@ -746,6 +890,59 @@ export default class BattleInfo extends Phaser.GameObjects.Container { } } + /** + * Overrides the state of the team display. + * + * The state can't be switched by the player until the override is removed, but you can call this again to change the override state. + */ + addTeamDisplayOverride(visible: boolean): void { + this.override = true; + this.switchIconVisibility(visible); + } + /** + * Removes any override on the team display. + * + * The team display will then show/hide as required. + */ + removeTeamDisplayOverride(): void { + this.override = false; + this.switchIconVisibility(this.pressedShow); + } + + /** Show or hide team display. */ + switchIconVisibility(visible: boolean = this.showingTeam, override?: boolean): void { + if (!this.iconsActive) visible = false + if (this.showingTeam == visible && !override) return; // Don't spam requests + this.showingTeam = visible + this.scene.tweens.add({ + targets: this.teamIcons, + duration: Utils.fixedInt(125), + ease: "Sine.easeInOut", + alpha: visible ? 1 : 0 + }); + this.scene.tweens.add({ + targets: this.teamIconOver, + duration: Utils.fixedInt(125), + ease: "Sine.easeInOut", + alphaTopLeft: visible ? 0.4 : 0, + alphaTopRight: visible ? 0.4 : 0, + alphaBottomLeft: visible ? 0.7 : 0, + alphaBottomRight: visible ? 0.7 : 0, + }); + this.scene.tweens.add({ + targets: [ this.championRibbon, this.ownedIcon ], + duration: Utils.fixedInt(125), + ease: "Sine.easeInOut", + alpha: visible && this.iconsActive ? 0 : this.statusIndicator.visible ? 0 : 1 + }); + this.scene.tweens.add({ + targets: this.statusIndicator, + duration: Utils.fixedInt(125), + ease: "Sine.easeInOut", + alpha: visible && this.iconsActive ? 0 : (!!this.lastStatus ? 1 : 0) + }); + } + /** * Show or hide the type effectiveness multiplier window * Passing undefined will hide the window From 71b1e59b615248dfe52ed52b9e32f903ba27577a Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:47:28 -0400 Subject: [PATCH 7/8] Added setting to enable / disable display --- src/battle-scene.ts | 1 + src/field/pokemon.ts | 3 +++ src/system/settings/settings.ts | 24 ++++++++++++++++++++++-- src/ui-inputs.ts | 8 +++++++- src/ui/battle-info.ts | 6 ++++++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 743fe467d1c..f3dc86e57c9 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -113,6 +113,7 @@ export default class BattleScene extends SceneBase { public reroll: boolean = false; public showMovesetFlyout: boolean = true; public showTeams: boolean = true; + public showTeamSprites: boolean = false; public showArenaFlyout: boolean = true; public showTimeOfDayWidget: boolean = true; public timeOfDayAnimation: EaseType = EaseType.NONE; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index cfae5072237..a24a3263ec8 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1685,6 +1685,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { toggleFlyout(visible: boolean): void { this.battleInfo.toggleFlyout(visible); } + toggleTeamTray(visible: boolean): void { + this.battleInfo.toggleTeamTray(visible); + } addExp(exp: integer) { const maxExpLevel = this.scene.getMaxExpLevel(); diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index bf3a5359fff..9dfba300c78 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -412,6 +412,26 @@ export const Setting: Array = [ default: 1, type: SettingType.DISPLAY }, + { + key: SettingKeys.Show_Pokemon_Teams, + label: i18next.t("settings:showTeamTray"), + options: [ + { + value: "Off", + label: i18next.t("settings:off") + }, + { + value: "Ball", + label: i18next.t("settings:simple") + }, + { + value: "Sprite", + label: i18next.t("settings:fancy") + } + ], + default: 1, + type: SettingType.DISPLAY + }, { key: SettingKeys.Show_Arena_Flyout, label: i18next.t("settings:showArenaFlyout"), @@ -647,8 +667,8 @@ export function setSetting(scene: BattleScene, setting: string, value: integer): scene.showMovesetFlyout = Setting[index].options[value].value === "On"; break; case SettingKeys.Show_Pokemon_Teams: - // Currently not used - scene.showTeams = Setting[index].options[value].value === "On"; + scene.showTeams = Setting[index].options[value].value !== "Off"; + scene.showTeamSprites = Setting[index].options[value].value === "Sprite"; break; case SettingKeys.Show_Arena_Flyout: scene.showArenaFlyout = Setting[index].options[value].value === "On"; diff --git a/src/ui-inputs.ts b/src/ui-inputs.ts index 9288fd35892..d219f3503d4 100644 --- a/src/ui-inputs.ts +++ b/src/ui-inputs.ts @@ -132,7 +132,7 @@ export class UiInputs { buttonStats(pressed: boolean = true): void { // allow access to Button.STATS as a toggle for other elements for (const t of this.scene.getInfoToggles(true)) { - t.toggleInfo(pressed); + t.toggleInfo(pressed,); } // handle normal pokemon battle ui for (const p of this.scene.getField().filter(p => p?.isActive(true))) { @@ -146,6 +146,12 @@ export class UiInputs { } } + if (this.scene.showTeams) { + for (const p of this.scene.getField().filter(p => p?.isActive(true))) { + p.toggleTeamTray(pressed); + } + } + if (this.scene.showArenaFlyout) { this.scene.ui.processInfoButton(pressed); } diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 652718342bb..ef675c44298 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -888,6 +888,12 @@ export default class BattleInfo extends Phaser.GameObjects.Container { } else { this.updateEffectiveness(this.currentEffectiveness); } + if (!this.override) this.switchIconVisibility(visible); + // this.teamIconOver[ballindex].setAlpha(0.4, 0.4, 0.7, 0.7) + } + toggleTeamTray(visible: boolean): void { + this.pressedShow = visible; + if (!this.override) this.switchIconVisibility(visible); } /** From 498ee9c4f0204d888a6edd67c57801716309b5bc Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:52:22 -0400 Subject: [PATCH 8/8] Make ball sprites hide if sprites are off Status ball is tinted if there's a status condition --- src/ui/battle-info.ts | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index ef675c44298..50852043285 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -549,7 +549,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (!party[i].hp) { states[i] = "faint" } else if (party[i].status) { - states[i] = "ball" + states[i] = (this.scene as BattleScene).showTeamSprites ? "ball" : "status" } if (P[i].isOnField()) { //console.log(P[i].name + " is in battle; set it as seen") @@ -568,7 +568,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.teamCount = P.length for (var ballindex = 0; ballindex < 6; ballindex++) { //console.log(ballindex + ": setting icon " + states[ballindex]) - if (states[ballindex] == "ball" && P[ballindex].usedInBattle) { + if (states[ballindex] == "ball" && P[ballindex].usedInBattle && (this.scene as BattleScene).showTeamSprites) { this.teamIcons[ballindex].setTexture(P[ballindex].getIconAtlasKey(true)) this.teamIcons[ballindex].setFrame(P[ballindex].getIconId(true)) this.teamIcons[ballindex].setPositionRelative(this.nameText, Spacing * ballindex - 3, 11.75 - 4); @@ -620,6 +620,41 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.teamIconOver[ballindex].clearTint() this.teamIconOver[ballindex].setVisible(false) this.teamIconsShow[ballindex] = false + this.teamIcons[ballindex].clearTint() + if (states[ballindex] == "status" && P[ballindex].usedInBattle) { + if (P[ballindex].status && P[ballindex].hp) { + switch (P[ballindex].status.effect) { + case StatusEffect.NONE: + // Uncallable; replaced by "ball" + break; + case StatusEffect.POISON: + this.teamIcons[ballindex].setTintFill(0xe40dfc) + break; + case StatusEffect.TOXIC: + this.teamIcons[ballindex].setTintFill(0xfa2590) + break; + case StatusEffect.PARALYSIS: + this.teamIcons[ballindex].setTintFill(0xf7ec1e) + break; + case StatusEffect.SLEEP: + this.teamIcons[ballindex].setTintFill(0x54bfaa) + break; + case StatusEffect.FREEZE: + this.teamIcons[ballindex].setTintFill(0xcbf0f2) + break; + case StatusEffect.BURN: + this.teamIcons[ballindex].setTintFill(0xf51905) + break; + case StatusEffect.FAINT: + // Uncallable; replaced by "faint" + break; + } + } else if (this.teamIcons[ballindex].tint) { + this.teamIcons[ballindex].clearTint() + } + } else if (this.teamIcons[ballindex].tint) { + this.teamIcons[ballindex].clearTint() + } } } }