From 25245d977295d571819883598ad8823168f6ceeb Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 1 Aug 2025 00:19:43 +0200 Subject: [PATCH 01/13] constants for position of discard button --- src/ui/party-ui-handler.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index b259316f6fa..c1e8ed61555 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -31,6 +31,11 @@ import { toTitleCase } from "#utils/strings"; import i18next from "i18next"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; +const DISCARD_BUTTON_X = 60; +const DISCARD_BUTTON_X_DOUBLES = 64; +const DISCARD_BUTTON_Y = -globalScene.game.canvas.height / 15 - 1; +const DISCARD_BUTTON_Y_DOUBLES = -48; + const defaultMessage = i18next.t("partyUiHandler:choosePokemon"); /** @@ -317,10 +322,8 @@ export class PartyUiHandler extends MessageUiHandler { this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler.setup(); - const partyDiscardModeButton = new PartyDiscardModeButton(60, -globalScene.game.canvas.height / 15 - 1, this); - + const partyDiscardModeButton = new PartyDiscardModeButton(DISCARD_BUTTON_X, DISCARD_BUTTON_Y, this); partyContainer.add(partyDiscardModeButton); - this.partyDiscardModeButton = partyDiscardModeButton; // prepare move overlay. in case it appears to be too big, set the overlayScale to .5 @@ -2199,10 +2202,6 @@ class PartyDiscardModeButton extends Phaser.GameObjects.Container { this.discardIcon.setVisible(false); this.textBox.setVisible(true); this.textBox.setText(i18next.t("partyUiHandler:TRANSFER")); - this.setPosition( - globalScene.currentBattle.double ? 64 : 60, - globalScene.currentBattle.double ? -48 : -globalScene.game.canvas.height / 15 - 1, - ); this.transferIcon.displayWidth = this.textBox.text.length * 9 + 3; break; case PartyUiMode.DISCARD: @@ -2210,13 +2209,13 @@ class PartyDiscardModeButton extends Phaser.GameObjects.Container { this.discardIcon.setVisible(true); this.textBox.setVisible(true); this.textBox.setText(i18next.t("partyUiHandler:DISCARD")); - this.setPosition( - globalScene.currentBattle.double ? 64 : 60, - globalScene.currentBattle.double ? -48 : -globalScene.game.canvas.height / 15 - 1, - ); this.discardIcon.displayWidth = this.textBox.text.length * 9 + 3; break; } + this.setPosition( + globalScene.currentBattle.double ? DISCARD_BUTTON_X_DOUBLES : DISCARD_BUTTON_X, + globalScene.currentBattle.double ? DISCARD_BUTTON_Y_DOUBLES : DISCARD_BUTTON_Y, + ); } clear() { From 941c45f70459b0bd2b65a3965b1a8f36c596ee12 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 1 Aug 2025 00:46:15 +0200 Subject: [PATCH 02/13] Moved transfer/discard button up in doubles --- src/ui/party-ui-handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index c1e8ed61555..d01b510e30f 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -33,8 +33,8 @@ import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; const DISCARD_BUTTON_X = 60; const DISCARD_BUTTON_X_DOUBLES = 64; -const DISCARD_BUTTON_Y = -globalScene.game.canvas.height / 15 - 1; -const DISCARD_BUTTON_Y_DOUBLES = -48; +const DISCARD_BUTTON_Y = -73; +const DISCARD_BUTTON_Y_DOUBLES = -58; const defaultMessage = i18next.t("partyUiHandler:choosePokemon"); From 6bf01622b25cda8f888343d4e6786f77b42e906d Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 1 Aug 2025 08:42:39 +0200 Subject: [PATCH 03/13] Fixed the various `.setOrigin(0,0)` --- src/ui/party-ui-handler.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index d01b510e30f..af9059e6cc4 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -306,7 +306,7 @@ export class PartyUiHandler extends MessageUiHandler { const partyMessageText = addTextObject(10, 8, defaultMessage, TextStyle.WINDOW, { maxLines: 2 }); partyMessageText.setName("text-party-msg"); - partyMessageText.setOrigin(0, 0); + partyMessageText.setOrigin(0); partyMessageBoxContainer.add(partyMessageText); this.message = partyMessageText; @@ -1237,7 +1237,7 @@ export class PartyUiHandler extends MessageUiHandler { } if (!this.optionsCursorObj) { this.optionsCursorObj = globalScene.add.image(0, 0, "cursor"); - this.optionsCursorObj.setOrigin(0, 0); + this.optionsCursorObj.setOrigin(0); this.optionsContainer.add(this.optionsCursorObj); } this.optionsCursorObj.setPosition( @@ -1609,7 +1609,7 @@ export class PartyUiHandler extends MessageUiHandler { optionText.setColor("#40c8f8"); optionText.setShadowColor("#006090"); } - optionText.setOrigin(0, 0); + optionText.setOrigin(0); /** For every item that has stack bigger than 1, display the current quantity selection */ const itemModifiers = this.getItemModifiers(pokemon); @@ -1900,7 +1900,7 @@ class PartySlot extends Phaser.GameObjects.Container { this.slotIndex >= battlerCount ? 21 : 24, (this.slotIndex >= battlerCount ? 2 : 10) + (offsetJa ? 2 : 0), ); - this.slotName.setOrigin(0, 0); + this.slotName.setOrigin(0); const slotLevelLabel = globalScene.add.image(0, 0, "party_slot_overlay_lv"); slotLevelLabel.setPositionRelative( @@ -1908,7 +1908,7 @@ class PartySlot extends Phaser.GameObjects.Container { (this.slotIndex >= battlerCount ? 21 : 24) + 8, (this.slotIndex >= battlerCount ? 2 : 10) + 12, ); - slotLevelLabel.setOrigin(0, 0); + slotLevelLabel.setOrigin(0); const slotLevelText = addTextObject( 0, @@ -1940,7 +1940,7 @@ class PartySlot extends Phaser.GameObjects.Container { if (this.pokemon.fusionSpecies) { const splicedIcon = globalScene.add.image(0, 0, "icon_spliced"); splicedIcon.setScale(0.5); - splicedIcon.setOrigin(0, 0); + splicedIcon.setOrigin(0); if (this.slotIndex >= battlerCount) { splicedIcon.setPositionRelative(slotLevelLabel, 36 + (genderSymbol ? 8 : 0), 0.5); } else { @@ -1953,7 +1953,7 @@ class PartySlot extends Phaser.GameObjects.Container { if (this.pokemon.status) { const statusIndicator = globalScene.add.sprite(0, 0, getLocalizedSpriteKey("statuses")); statusIndicator.setFrame(StatusEffect[this.pokemon.status?.effect].toLowerCase()); - statusIndicator.setOrigin(0, 0); + statusIndicator.setOrigin(0); statusIndicator.setPositionRelative(slotLevelLabel, this.slotIndex >= battlerCount ? 43 : 55, 0); slotInfoContainer.add(statusIndicator); @@ -1963,7 +1963,7 @@ class PartySlot extends Phaser.GameObjects.Container { const doubleShiny = this.pokemon.isDoubleShiny(false); const shinyStar = globalScene.add.image(0, 0, `shiny_star_small${doubleShiny ? "_1" : ""}`); - shinyStar.setOrigin(0, 0); + shinyStar.setOrigin(0); shinyStar.setPositionRelative(this.slotName, -9, 3); shinyStar.setTint(getVariantTint(this.pokemon.getBaseVariant())); @@ -1986,7 +1986,7 @@ class PartySlot extends Phaser.GameObjects.Container { this.slotIndex >= battlerCount ? 72 : 8, this.slotIndex >= battlerCount ? 6 : 31, ); - this.slotHpBar.setOrigin(0, 0); + this.slotHpBar.setOrigin(0); this.slotHpBar.setVisible(false); const hpRatio = this.pokemon.getHpRatio(); @@ -1998,7 +1998,7 @@ class PartySlot extends Phaser.GameObjects.Container { hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low", ); this.slotHpOverlay.setPositionRelative(this.slotHpBar, 16, 2); - this.slotHpOverlay.setOrigin(0, 0); + this.slotHpOverlay.setOrigin(0); this.slotHpOverlay.setScale(hpRatio, 1); this.slotHpOverlay.setVisible(false); From b1475d11b3f923d7ff840e111eb5a44add543fc0 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 1 Aug 2025 09:40:56 +0200 Subject: [PATCH 04/13] Small clean up --- src/ui/party-ui-handler.ts | 111 ++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 62 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index af9059e6cc4..367da243dde 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1855,24 +1855,19 @@ class PartySlot extends Phaser.GameObjects.Container { const battlerCount = globalScene.currentBattle.getBattlerCount(); - const slotKey = `party_slot${this.slotIndex >= battlerCount ? "" : "_main"}`; + const slotKey = this.slotIndex >= battlerCount ? "party_slot" : "party_slot_main"; + const slotBgKey = this.pokemon.hp ? slotKey : `${slotKey}${"_fnt"}`; + this.slotBg = globalScene.add.sprite(0, 0, slotKey, slotBgKey); + this.add(this.slotBg); - const slotBg = globalScene.add.sprite(0, 0, slotKey, `${slotKey}${this.pokemon.hp ? "" : "_fnt"}`); - this.slotBg = slotBg; - - this.add(slotBg); - - const slotPb = globalScene.add.sprite( + this.slotPb = globalScene.add.sprite( this.slotIndex >= battlerCount ? -85.5 : -51, this.slotIndex >= battlerCount ? 0 : -20.5, "party_pb", ); - this.slotPb = slotPb; - - this.add(slotPb); - - this.pokemonIcon = globalScene.addPokemonIcon(this.pokemon, slotPb.x, slotPb.y, 0.5, 0.5, true); + this.add(this.slotPb); + this.pokemonIcon = globalScene.addPokemonIcon(this.pokemon, this.slotPb.x, this.slotPb.y, 0.5, 0.5, true); this.add(this.pokemonIcon); this.iconAnimHandler.addOrUpdate(this.pokemonIcon, PokemonIconAnimMode.PASSIVE); @@ -1896,28 +1891,29 @@ class PartySlot extends Phaser.GameObjects.Container { this.slotName = addTextObject(0, 0, displayName, TextStyle.PARTY); this.slotName.setPositionRelative( - slotBg, + this.slotBg, this.slotIndex >= battlerCount ? 21 : 24, (this.slotIndex >= battlerCount ? 2 : 10) + (offsetJa ? 2 : 0), ); this.slotName.setOrigin(0); - const slotLevelLabel = globalScene.add.image(0, 0, "party_slot_overlay_lv"); - slotLevelLabel.setPositionRelative( - slotBg, - (this.slotIndex >= battlerCount ? 21 : 24) + 8, - (this.slotIndex >= battlerCount ? 2 : 10) + 12, - ); - slotLevelLabel.setOrigin(0); + const slotLevelLabel = globalScene.add + .image(0, 0, "party_slot_overlay_lv") + .setPositionRelative( + this.slotBg, + (this.slotIndex >= battlerCount ? 21 : 24) + 8, + (this.slotIndex >= battlerCount ? 2 : 10) + 12, + ) + .setOrigin(0); const slotLevelText = addTextObject( 0, 0, this.pokemon.level.toString(), this.pokemon.level < globalScene.getMaxExpLevel() ? TextStyle.PARTY : TextStyle.PARTY_RED, - ); - slotLevelText.setPositionRelative(slotLevelLabel, 9, offsetJa ? 1.5 : 0); - slotLevelText.setOrigin(0, 0.25); + ) + .setPositionRelative(slotLevelLabel, 9, offsetJa ? 1.5 : 0) + .setOrigin(0, 0.25); slotInfoContainer.add([this.slotName, slotLevelLabel, slotLevelText]); @@ -1946,27 +1942,26 @@ class PartySlot extends Phaser.GameObjects.Container { } else { splicedIcon.setPositionRelative(this.slotName, 76, 3.5); } - slotInfoContainer.add(splicedIcon); } if (this.pokemon.status) { - const statusIndicator = globalScene.add.sprite(0, 0, getLocalizedSpriteKey("statuses")); - statusIndicator.setFrame(StatusEffect[this.pokemon.status?.effect].toLowerCase()); - statusIndicator.setOrigin(0); - statusIndicator.setPositionRelative(slotLevelLabel, this.slotIndex >= battlerCount ? 43 : 55, 0); - + const statusIndicator = globalScene.add + .sprite(0, 0, getLocalizedSpriteKey("statuses")) + .setFrame(StatusEffect[this.pokemon.status?.effect].toLowerCase()) + .setOrigin(0) + .setPositionRelative(slotLevelLabel, this.slotIndex >= battlerCount ? 43 : 55, 0); slotInfoContainer.add(statusIndicator); } if (this.pokemon.isShiny()) { const doubleShiny = this.pokemon.isDoubleShiny(false); - const shinyStar = globalScene.add.image(0, 0, `shiny_star_small${doubleShiny ? "_1" : ""}`); - shinyStar.setOrigin(0); - shinyStar.setPositionRelative(this.slotName, -9, 3); - shinyStar.setTint(getVariantTint(this.pokemon.getBaseVariant())); - + const shinyStar = globalScene.add + .image(0, 0, `shiny_star_small${doubleShiny ? "_1" : ""}`) + .setOrigin(0) + .setPositionRelative(this.slotName, -9, 3) + .setTint(getVariantTint(this.pokemon.getBaseVariant())); slotInfoContainer.add(shinyStar); if (doubleShiny) { @@ -1975,52 +1970,44 @@ class PartySlot extends Phaser.GameObjects.Container { .setOrigin(0) .setPosition(shinyStar.x, shinyStar.y) .setTint(getVariantTint(this.pokemon.fusionVariant)); - slotInfoContainer.add(fusionShinyStar); } } - this.slotHpBar = globalScene.add.image(0, 0, "party_slot_hp_bar"); - this.slotHpBar.setPositionRelative( - slotBg, - this.slotIndex >= battlerCount ? 72 : 8, - this.slotIndex >= battlerCount ? 6 : 31, - ); - this.slotHpBar.setOrigin(0); - this.slotHpBar.setVisible(false); + this.slotHpBar = globalScene.add.image(0, 0, "party_slot_hp_bar").setOrigin(0).setVisible(false); const hpRatio = this.pokemon.getHpRatio(); - this.slotHpOverlay = globalScene.add.sprite( - 0, - 0, - "party_slot_hp_overlay", - hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low", + this.slotHpOverlay = globalScene.add + .sprite(0, 0, "party_slot_hp_overlay", hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low") + .setOrigin(0) + .setScale(hpRatio, 1) + .setVisible(false); + + this.slotHpText = addTextObject(0, 0, `${this.pokemon.hp}/${this.pokemon.getMaxHp()}`, TextStyle.PARTY) + .setOrigin(1, 0) + .setVisible(false); + + this.slotDescriptionLabel = addTextObject(0, 0, "", TextStyle.MESSAGE).setOrigin(0, 1).setVisible(false); + + slotInfoContainer.add([this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel]); + + this.slotHpBar.setPositionRelative( + this.slotBg, + this.slotIndex >= battlerCount ? 72 : 8, + this.slotIndex >= battlerCount ? 6 : 31, ); this.slotHpOverlay.setPositionRelative(this.slotHpBar, 16, 2); - this.slotHpOverlay.setOrigin(0); - this.slotHpOverlay.setScale(hpRatio, 1); - this.slotHpOverlay.setVisible(false); - - this.slotHpText = addTextObject(0, 0, `${this.pokemon.hp}/${this.pokemon.getMaxHp()}`, TextStyle.PARTY); this.slotHpText.setPositionRelative( this.slotHpBar, this.slotHpBar.width - 3, this.slotHpBar.height - 2 + (offsetJa ? 2 : 0), ); - this.slotHpText.setOrigin(1, 0); - this.slotHpText.setVisible(false); - - this.slotDescriptionLabel = addTextObject(0, 0, "", TextStyle.MESSAGE); this.slotDescriptionLabel.setPositionRelative( - slotBg, + this.slotBg, this.slotIndex >= battlerCount ? 94 : 32, this.slotIndex >= battlerCount ? 16 : 46, ); - this.slotDescriptionLabel.setOrigin(0, 1); - this.slotDescriptionLabel.setVisible(false); - - slotInfoContainer.add([this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel]); if (partyUiMode !== PartyUiMode.TM_MODIFIER) { this.slotDescriptionLabel.setVisible(false); From 910b4c0af92bd242bbf98c2f9bce6a7451873b13 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 1 Aug 2025 23:29:19 +0200 Subject: [PATCH 05/13] Added `isBenched` property to slots; x origin of `slotBg` is now 0 --- src/ui/party-ui-handler.ts | 54 +++++++++++++++----------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 367da243dde..c22727e5003 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1806,6 +1806,7 @@ class PartySlot extends Phaser.GameObjects.Container { private selected: boolean; private transfer: boolean; private slotIndex: number; + private isBenched: boolean; private pokemon: PlayerPokemon; private slotBg: Phaser.GameObjects.Image; @@ -1828,7 +1829,7 @@ class PartySlot extends Phaser.GameObjects.Container { ) { super( globalScene, - slotIndex >= globalScene.currentBattle.getBattlerCount() ? 230.5 : 64, + slotIndex >= globalScene.currentBattle.getBattlerCount() ? 230.5 - 175 / 2 : 64 - 110 / 2, slotIndex >= globalScene.currentBattle.getBattlerCount() ? -184 + (globalScene.currentBattle.double ? -40 : 0) + @@ -1839,6 +1840,8 @@ class PartySlot extends Phaser.GameObjects.Container { ); this.slotIndex = slotIndex; + const battlerCount = globalScene.currentBattle.getBattlerCount(); + this.isBenched = this.slotIndex >= battlerCount; this.pokemon = pokemon; this.iconAnimHandler = iconAnimHandler; @@ -1853,21 +1856,19 @@ class PartySlot extends Phaser.GameObjects.Container { const currentLanguage = i18next.resolvedLanguage ?? "en"; const offsetJa = currentLanguage === "ja"; - const battlerCount = globalScene.currentBattle.getBattlerCount(); - - const slotKey = this.slotIndex >= battlerCount ? "party_slot" : "party_slot_main"; + const slotKey = this.isBenched ? "party_slot" : "party_slot_main"; const slotBgKey = this.pokemon.hp ? slotKey : `${slotKey}${"_fnt"}`; this.slotBg = globalScene.add.sprite(0, 0, slotKey, slotBgKey); + console.log("Real x of BG: ", this.slotBg.x, this.slotBg.width); + this.slotBg.setOrigin(0, 0.5); this.add(this.slotBg); - this.slotPb = globalScene.add.sprite( - this.slotIndex >= battlerCount ? -85.5 : -51, - this.slotIndex >= battlerCount ? 0 : -20.5, - "party_pb", - ); + this.slotPb = globalScene.add.sprite(0, 0, "party_pb"); + this.slotPb.setPosition(this.isBenched ? -85.5 + 175 / 2 : -51 + 110 / 2, this.isBenched ? 0 : -20.5); this.add(this.slotPb); this.pokemonIcon = globalScene.addPokemonIcon(this.pokemon, this.slotPb.x, this.slotPb.y, 0.5, 0.5, true); + // this.pokemonIcon.setPosition(); this.add(this.pokemonIcon); this.iconAnimHandler.addOrUpdate(this.pokemonIcon, PokemonIconAnimMode.PASSIVE); @@ -1881,7 +1882,7 @@ class PartySlot extends Phaser.GameObjects.Container { const nameSizeTest = addTextObject(0, 0, displayName, TextStyle.PARTY); nameTextWidth = nameSizeTest.displayWidth; - while (nameTextWidth > (this.slotIndex >= battlerCount ? 52 : 76 - (this.pokemon.fusionSpecies ? 8 : 0))) { + while (nameTextWidth > (this.isBenched ? 52 : 76 - (this.pokemon.fusionSpecies ? 8 : 0))) { displayName = `${displayName.slice(0, displayName.endsWith(".") ? -2 : -1).trimEnd()}.`; nameSizeTest.setText(displayName); nameTextWidth = nameSizeTest.displayWidth; @@ -1892,18 +1893,14 @@ class PartySlot extends Phaser.GameObjects.Container { this.slotName = addTextObject(0, 0, displayName, TextStyle.PARTY); this.slotName.setPositionRelative( this.slotBg, - this.slotIndex >= battlerCount ? 21 : 24, - (this.slotIndex >= battlerCount ? 2 : 10) + (offsetJa ? 2 : 0), + this.isBenched ? 21 : 24, + (this.isBenched ? 2 : 10) + (offsetJa ? 2 : 0), ); this.slotName.setOrigin(0); const slotLevelLabel = globalScene.add .image(0, 0, "party_slot_overlay_lv") - .setPositionRelative( - this.slotBg, - (this.slotIndex >= battlerCount ? 21 : 24) + 8, - (this.slotIndex >= battlerCount ? 2 : 10) + 12, - ) + .setPositionRelative(this.slotBg, (this.isBenched ? 21 : 24) + 8, (this.isBenched ? 2 : 10) + 12) .setOrigin(0); const slotLevelText = addTextObject( @@ -1923,7 +1920,7 @@ class PartySlot extends Phaser.GameObjects.Container { const slotGenderText = addTextObject(0, 0, genderSymbol, TextStyle.PARTY); slotGenderText.setColor(getGenderColor(this.pokemon.getGender(true))); slotGenderText.setShadowColor(getGenderColor(this.pokemon.getGender(true), true)); - if (this.slotIndex >= battlerCount) { + if (this.isBenched) { slotGenderText.setPositionRelative(slotLevelLabel, 36, 0); } else { slotGenderText.setPositionRelative(this.slotName, 76 - (this.pokemon.fusionSpecies ? 8 : 0), 3); @@ -1937,7 +1934,7 @@ class PartySlot extends Phaser.GameObjects.Container { const splicedIcon = globalScene.add.image(0, 0, "icon_spliced"); splicedIcon.setScale(0.5); splicedIcon.setOrigin(0); - if (this.slotIndex >= battlerCount) { + if (this.isBenched) { splicedIcon.setPositionRelative(slotLevelLabel, 36 + (genderSymbol ? 8 : 0), 0.5); } else { splicedIcon.setPositionRelative(this.slotName, 76, 3.5); @@ -1950,7 +1947,7 @@ class PartySlot extends Phaser.GameObjects.Container { .sprite(0, 0, getLocalizedSpriteKey("statuses")) .setFrame(StatusEffect[this.pokemon.status?.effect].toLowerCase()) .setOrigin(0) - .setPositionRelative(slotLevelLabel, this.slotIndex >= battlerCount ? 43 : 55, 0); + .setPositionRelative(slotLevelLabel, this.isBenched ? 43 : 55, 0); slotInfoContainer.add(statusIndicator); } @@ -1992,22 +1989,14 @@ class PartySlot extends Phaser.GameObjects.Container { slotInfoContainer.add([this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel]); - this.slotHpBar.setPositionRelative( - this.slotBg, - this.slotIndex >= battlerCount ? 72 : 8, - this.slotIndex >= battlerCount ? 6 : 31, - ); + this.slotHpBar.setPositionRelative(this.slotBg, this.isBenched ? 72 : 8, this.isBenched ? 6 : 31); this.slotHpOverlay.setPositionRelative(this.slotHpBar, 16, 2); this.slotHpText.setPositionRelative( this.slotHpBar, this.slotHpBar.width - 3, this.slotHpBar.height - 2 + (offsetJa ? 2 : 0), ); - this.slotDescriptionLabel.setPositionRelative( - this.slotBg, - this.slotIndex >= battlerCount ? 94 : 32, - this.slotIndex >= battlerCount ? 16 : 46, - ); + this.slotDescriptionLabel.setPositionRelative(this.slotBg, this.isBenched ? 94 : 32, this.isBenched ? 16 : 46); if (partyUiMode !== PartyUiMode.TM_MODIFIER) { this.slotDescriptionLabel.setVisible(false); @@ -2067,10 +2056,9 @@ class PartySlot extends Phaser.GameObjects.Container { } private updateSlotTexture(): void { - const battlerCount = globalScene.currentBattle.getBattlerCount(); this.slotBg.setTexture( - `party_slot${this.slotIndex >= battlerCount ? "" : "_main"}`, - `party_slot${this.slotIndex >= battlerCount ? "" : "_main"}${this.transfer ? "_swap" : this.pokemon.hp ? "" : "_fnt"}${this.selected ? "_sel" : ""}`, + `party_slot${this.isBenched ? "" : "_main"}`, + `party_slot${this.isBenched ? "" : "_main"}${this.transfer ? "_swap" : this.pokemon.hp ? "" : "_fnt"}${this.selected ? "_sel" : ""}`, ); } } From 57cc77a9372c6ba6744503e8733bd9262c485624 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 2 Aug 2025 00:07:25 +0200 Subject: [PATCH 06/13] Also set y origin to 0 --- src/ui/party-ui-handler.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index c22727e5003..aa4df087d30 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1829,14 +1829,15 @@ class PartySlot extends Phaser.GameObjects.Container { ) { super( globalScene, - slotIndex >= globalScene.currentBattle.getBattlerCount() ? 230.5 - 175 / 2 : 64 - 110 / 2, + slotIndex >= globalScene.currentBattle.getBattlerCount() ? 143 : 9, slotIndex >= globalScene.currentBattle.getBattlerCount() - ? -184 + + ? -184 - + 12 + (globalScene.currentBattle.double ? -40 : 0) + (28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex : partyUiMode === PartyUiMode.MODIFIER_TRANSFER - ? -124 + (globalScene.currentBattle.double ? -20 : 0) + slotIndex * 55 - : -124 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64, + ? -124 - 49 / 2 + (globalScene.currentBattle.double ? -20 : 0) + slotIndex * 55 + : -124 - 49 / 2 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64, ); this.slotIndex = slotIndex; @@ -1859,12 +1860,12 @@ class PartySlot extends Phaser.GameObjects.Container { const slotKey = this.isBenched ? "party_slot" : "party_slot_main"; const slotBgKey = this.pokemon.hp ? slotKey : `${slotKey}${"_fnt"}`; this.slotBg = globalScene.add.sprite(0, 0, slotKey, slotBgKey); - console.log("Real x of BG: ", this.slotBg.x, this.slotBg.width); - this.slotBg.setOrigin(0, 0.5); + console.log("Real y of BG: ", this.slotBg.y, this.slotBg.height); + this.slotBg.setOrigin(0); this.add(this.slotBg); this.slotPb = globalScene.add.sprite(0, 0, "party_pb"); - this.slotPb.setPosition(this.isBenched ? -85.5 + 175 / 2 : -51 + 110 / 2, this.isBenched ? 0 : -20.5); + this.slotPb.setPosition(this.isBenched ? 2 : 4, this.isBenched ? 12 : 4); this.add(this.slotPb); this.pokemonIcon = globalScene.addPokemonIcon(this.pokemon, this.slotPb.x, this.slotPb.y, 0.5, 0.5, true); From 403c2b6e9efb358ebdcb009440d8055925ccbd92 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 2 Aug 2025 00:24:49 +0200 Subject: [PATCH 07/13] Offsets are relevant to the same thing --- src/ui/party-ui-handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index aa4df087d30..716a40a02e5 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1924,7 +1924,7 @@ class PartySlot extends Phaser.GameObjects.Container { if (this.isBenched) { slotGenderText.setPositionRelative(slotLevelLabel, 36, 0); } else { - slotGenderText.setPositionRelative(this.slotName, 76 - (this.pokemon.fusionSpecies ? 8 : 0), 3); + slotGenderText.setPositionRelative(slotLevelLabel, 68 - (this.pokemon.fusionSpecies ? 8 : 0), -9); } slotGenderText.setOrigin(0, 0.25); @@ -1938,7 +1938,7 @@ class PartySlot extends Phaser.GameObjects.Container { if (this.isBenched) { splicedIcon.setPositionRelative(slotLevelLabel, 36 + (genderSymbol ? 8 : 0), 0.5); } else { - splicedIcon.setPositionRelative(this.slotName, 76, 3.5); + splicedIcon.setPositionRelative(slotLevelLabel, 68, 3.5 - 12); } slotInfoContainer.add(splicedIcon); } From 0f1785b97a1f07a7f5738512c5a65071421f2317 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 2 Aug 2025 08:24:57 +0200 Subject: [PATCH 08/13] Introducing const object to store ui magic numbers --- src/ui/party-ui-handler.ts | 49 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 716a40a02e5..3e3b22f6685 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1860,12 +1860,25 @@ class PartySlot extends Phaser.GameObjects.Container { const slotKey = this.isBenched ? "party_slot" : "party_slot_main"; const slotBgKey = this.pokemon.hp ? slotKey : `${slotKey}${"_fnt"}`; this.slotBg = globalScene.add.sprite(0, 0, slotKey, slotBgKey); - console.log("Real y of BG: ", this.slotBg.y, this.slotBg.height); this.slotBg.setOrigin(0); this.add(this.slotBg); + const magicNumbers = { + slotPb: { x: 4, y: 4 }, + namePosition: { x: 24, y: 10 + (offsetJa ? 2 : 0) }, + nameTextWidth: 76 - (this.pokemon.fusionSpecies ? 8 : 0), + levelLabelPosition: { x: 24 + 8, y: 10 + 12 }, + }; + + if (this.isBenched) { + magicNumbers.slotPb = { x: 2, y: 12 }; + magicNumbers.namePosition = { x: 21, y: 2 + (offsetJa ? 2 : 0) }; + magicNumbers.nameTextWidth = 52; + magicNumbers.levelLabelPosition = { x: 21 + 8, y: 2 + 12 }; + } + this.slotPb = globalScene.add.sprite(0, 0, "party_pb"); - this.slotPb.setPosition(this.isBenched ? 2 : 4, this.isBenched ? 12 : 4); + this.slotPb.setPosition(magicNumbers.slotPb.x, magicNumbers.slotPb.y); this.add(this.slotPb); this.pokemonIcon = globalScene.addPokemonIcon(this.pokemon, this.slotPb.x, this.slotPb.y, 0.5, 0.5, true); @@ -1883,7 +1896,7 @@ class PartySlot extends Phaser.GameObjects.Container { const nameSizeTest = addTextObject(0, 0, displayName, TextStyle.PARTY); nameTextWidth = nameSizeTest.displayWidth; - while (nameTextWidth > (this.isBenched ? 52 : 76 - (this.pokemon.fusionSpecies ? 8 : 0))) { + while (nameTextWidth > magicNumbers.nameTextWidth) { displayName = `${displayName.slice(0, displayName.endsWith(".") ? -2 : -1).trimEnd()}.`; nameSizeTest.setText(displayName); nameTextWidth = nameSizeTest.displayWidth; @@ -1892,16 +1905,12 @@ class PartySlot extends Phaser.GameObjects.Container { nameSizeTest.destroy(); this.slotName = addTextObject(0, 0, displayName, TextStyle.PARTY); - this.slotName.setPositionRelative( - this.slotBg, - this.isBenched ? 21 : 24, - (this.isBenched ? 2 : 10) + (offsetJa ? 2 : 0), - ); + this.slotName.setPositionRelative(this.slotBg, magicNumbers.namePosition.x, magicNumbers.namePosition.y); this.slotName.setOrigin(0); const slotLevelLabel = globalScene.add .image(0, 0, "party_slot_overlay_lv") - .setPositionRelative(this.slotBg, (this.isBenched ? 21 : 24) + 8, (this.isBenched ? 2 : 10) + 12) + .setPositionRelative(this.slotBg, magicNumbers.levelLabelPosition.x, magicNumbers.levelLabelPosition.y) .setOrigin(0); const slotLevelText = addTextObject( @@ -1972,33 +1981,33 @@ class PartySlot extends Phaser.GameObjects.Container { } } - this.slotHpBar = globalScene.add.image(0, 0, "party_slot_hp_bar").setOrigin(0).setVisible(false); + this.slotHpBar = globalScene.add + .image(0, 0, "party_slot_hp_bar") + .setOrigin(0) + .setVisible(false) + .setPositionRelative(this.slotBg, this.isBenched ? 72 : 8, this.isBenched ? 6 : 31); const hpRatio = this.pokemon.getHpRatio(); this.slotHpOverlay = globalScene.add .sprite(0, 0, "party_slot_hp_overlay", hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low") .setOrigin(0) + .setPositionRelative(this.slotHpBar, 16, 2) .setScale(hpRatio, 1) .setVisible(false); this.slotHpText = addTextObject(0, 0, `${this.pokemon.hp}/${this.pokemon.getMaxHp()}`, TextStyle.PARTY) .setOrigin(1, 0) + .setPositionRelative(this.slotHpBar, this.slotHpBar.width - 3, this.slotHpBar.height - 2 + (offsetJa ? 2 : 0)) .setVisible(false); - this.slotDescriptionLabel = addTextObject(0, 0, "", TextStyle.MESSAGE).setOrigin(0, 1).setVisible(false); + this.slotDescriptionLabel = addTextObject(0, 0, "", TextStyle.MESSAGE) + .setOrigin(0, 1) + .setVisible(false) + .setPositionRelative(this.slotBg, this.isBenched ? 94 : 32, this.isBenched ? 16 : 46); slotInfoContainer.add([this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel]); - this.slotHpBar.setPositionRelative(this.slotBg, this.isBenched ? 72 : 8, this.isBenched ? 6 : 31); - this.slotHpOverlay.setPositionRelative(this.slotHpBar, 16, 2); - this.slotHpText.setPositionRelative( - this.slotHpBar, - this.slotHpBar.width - 3, - this.slotHpBar.height - 2 + (offsetJa ? 2 : 0), - ); - this.slotDescriptionLabel.setPositionRelative(this.slotBg, this.isBenched ? 94 : 32, this.isBenched ? 16 : 46); - if (partyUiMode !== PartyUiMode.TM_MODIFIER) { this.slotDescriptionLabel.setVisible(false); this.slotHpBar.setVisible(true); From 0ef60dd445ba3d4258e0c3211054dcda29c2ac63 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 2 Aug 2025 09:59:08 +0200 Subject: [PATCH 09/13] More magic numbers in const --- src/ui/party-ui-handler.ts | 102 ++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 3e3b22f6685..1a91177ad61 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1863,18 +1863,47 @@ class PartySlot extends Phaser.GameObjects.Container { this.slotBg.setOrigin(0); this.add(this.slotBg); + const genderSymbol = getGenderSymbol(this.pokemon.getGender(true)); + const isFusion = this.pokemon.fusionSpecies; + + // Here we define positions and offsets const magicNumbers = { slotPb: { x: 4, y: 4 }, namePosition: { x: 24, y: 10 + (offsetJa ? 2 : 0) }, - nameTextWidth: 76 - (this.pokemon.fusionSpecies ? 8 : 0), + nameTextWidth: 76 - (isFusion ? 8 : 0), levelLabelPosition: { x: 24 + 8, y: 10 + 12 }, + levelTextToLevelLabelOffset: { x: 9, y: offsetJa ? 1.5 : 0 }, + genderTextToLevelLabelOffset: { x: 68 - (isFusion ? 8 : 0), y: -9 }, + splicedIconToLevelLabelOffset: { x: 68, y: 3.5 - 12 }, + statusIconToLevelLabelOffset: { x: 55, y: 0 }, + shinyIconToNameOffset: { x: -9, y: 3 }, + hpBarPosition: { x: 8, y: 31 }, + hpOverlayToBarOffset: { x: 16, y: 2 }, // This should stay fixed + hpTextToBarOffset: { x: -3, y: -2 + (offsetJa ? 2 : 0) }, // This should stay fixed; relative to HP bar length + descriptionLabelPosition: { x: 32, y: 46 }, }; + if ( + (partyUiMode === PartyUiMode.MODIFIER_TRANSFER || partyUiMode === PartyUiMode.DISCARD) && + globalScene.currentBattle.double && + !this.isBenched + ) { + magicNumbers.namePosition.y -= 8; + magicNumbers.levelLabelPosition.y -= 8; + magicNumbers.hpBarPosition.y -= 8; + magicNumbers.descriptionLabelPosition.y -= 8; + } + if (this.isBenched) { magicNumbers.slotPb = { x: 2, y: 12 }; magicNumbers.namePosition = { x: 21, y: 2 + (offsetJa ? 2 : 0) }; magicNumbers.nameTextWidth = 52; magicNumbers.levelLabelPosition = { x: 21 + 8, y: 2 + 12 }; + magicNumbers.genderTextToLevelLabelOffset = { x: 36, y: 0 }; + magicNumbers.splicedIconToLevelLabelOffset = { x: 36 + (genderSymbol ? 8 : 0), y: 0.5 }; + magicNumbers.statusIconToLevelLabelOffset = { x: 43, y: 0 }; + magicNumbers.hpBarPosition = { x: 72, y: 6 }; + magicNumbers.descriptionLabelPosition = { x: 94, y: 16 }; } this.slotPb = globalScene.add.sprite(0, 0, "party_pb"); @@ -1919,36 +1948,37 @@ class PartySlot extends Phaser.GameObjects.Container { this.pokemon.level.toString(), this.pokemon.level < globalScene.getMaxExpLevel() ? TextStyle.PARTY : TextStyle.PARTY_RED, ) - .setPositionRelative(slotLevelLabel, 9, offsetJa ? 1.5 : 0) + .setPositionRelative( + slotLevelLabel, + magicNumbers.levelTextToLevelLabelOffset.x, + magicNumbers.levelTextToLevelLabelOffset.y, + ) .setOrigin(0, 0.25); - slotInfoContainer.add([this.slotName, slotLevelLabel, slotLevelText]); - const genderSymbol = getGenderSymbol(this.pokemon.getGender(true)); - if (genderSymbol) { - const slotGenderText = addTextObject(0, 0, genderSymbol, TextStyle.PARTY); - slotGenderText.setColor(getGenderColor(this.pokemon.getGender(true))); - slotGenderText.setShadowColor(getGenderColor(this.pokemon.getGender(true), true)); - if (this.isBenched) { - slotGenderText.setPositionRelative(slotLevelLabel, 36, 0); - } else { - slotGenderText.setPositionRelative(slotLevelLabel, 68 - (this.pokemon.fusionSpecies ? 8 : 0), -9); - } - slotGenderText.setOrigin(0, 0.25); - + const slotGenderText = addTextObject(0, 0, genderSymbol, TextStyle.PARTY) + .setColor(getGenderColor(this.pokemon.getGender(true))) + .setShadowColor(getGenderColor(this.pokemon.getGender(true), true)) + .setPositionRelative( + slotLevelLabel, + magicNumbers.genderTextToLevelLabelOffset.x, + magicNumbers.genderTextToLevelLabelOffset.y, + ) + .setOrigin(0, 0.25); slotInfoContainer.add(slotGenderText); } - if (this.pokemon.fusionSpecies) { - const splicedIcon = globalScene.add.image(0, 0, "icon_spliced"); - splicedIcon.setScale(0.5); - splicedIcon.setOrigin(0); - if (this.isBenched) { - splicedIcon.setPositionRelative(slotLevelLabel, 36 + (genderSymbol ? 8 : 0), 0.5); - } else { - splicedIcon.setPositionRelative(slotLevelLabel, 68, 3.5 - 12); - } + if (isFusion) { + const splicedIcon = globalScene.add + .image(0, 0, "icon_spliced") + .setScale(0.5) + .setOrigin(0) + .setPositionRelative( + slotLevelLabel, + magicNumbers.splicedIconToLevelLabelOffset.x, + magicNumbers.splicedIconToLevelLabelOffset.y, + ); slotInfoContainer.add(splicedIcon); } @@ -1957,7 +1987,11 @@ class PartySlot extends Phaser.GameObjects.Container { .sprite(0, 0, getLocalizedSpriteKey("statuses")) .setFrame(StatusEffect[this.pokemon.status?.effect].toLowerCase()) .setOrigin(0) - .setPositionRelative(slotLevelLabel, this.isBenched ? 43 : 55, 0); + .setPositionRelative( + slotLevelLabel, + magicNumbers.statusIconToLevelLabelOffset.x, + magicNumbers.statusIconToLevelLabelOffset.y, + ); slotInfoContainer.add(statusIndicator); } @@ -1967,7 +2001,7 @@ class PartySlot extends Phaser.GameObjects.Container { const shinyStar = globalScene.add .image(0, 0, `shiny_star_small${doubleShiny ? "_1" : ""}`) .setOrigin(0) - .setPositionRelative(this.slotName, -9, 3) + .setPositionRelative(this.slotName, magicNumbers.shinyIconToNameOffset.x, magicNumbers.shinyIconToNameOffset.y) .setTint(getVariantTint(this.pokemon.getBaseVariant())); slotInfoContainer.add(shinyStar); @@ -1985,26 +2019,34 @@ class PartySlot extends Phaser.GameObjects.Container { .image(0, 0, "party_slot_hp_bar") .setOrigin(0) .setVisible(false) - .setPositionRelative(this.slotBg, this.isBenched ? 72 : 8, this.isBenched ? 6 : 31); + .setPositionRelative(this.slotBg, magicNumbers.hpBarPosition.x, magicNumbers.hpBarPosition.y); const hpRatio = this.pokemon.getHpRatio(); this.slotHpOverlay = globalScene.add .sprite(0, 0, "party_slot_hp_overlay", hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low") .setOrigin(0) - .setPositionRelative(this.slotHpBar, 16, 2) + .setPositionRelative(this.slotHpBar, magicNumbers.hpOverlayToBarOffset.x, magicNumbers.hpOverlayToBarOffset.y) .setScale(hpRatio, 1) .setVisible(false); this.slotHpText = addTextObject(0, 0, `${this.pokemon.hp}/${this.pokemon.getMaxHp()}`, TextStyle.PARTY) .setOrigin(1, 0) - .setPositionRelative(this.slotHpBar, this.slotHpBar.width - 3, this.slotHpBar.height - 2 + (offsetJa ? 2 : 0)) + .setPositionRelative( + this.slotHpBar, + this.slotHpBar.width + magicNumbers.hpTextToBarOffset.x, + this.slotHpBar.height + magicNumbers.hpTextToBarOffset.y, + ) // TODO: annoying because it contains the width .setVisible(false); this.slotDescriptionLabel = addTextObject(0, 0, "", TextStyle.MESSAGE) .setOrigin(0, 1) .setVisible(false) - .setPositionRelative(this.slotBg, this.isBenched ? 94 : 32, this.isBenched ? 16 : 46); + .setPositionRelative( + this.slotBg, + magicNumbers.descriptionLabelPosition.x, + magicNumbers.descriptionLabelPosition.y, + ); slotInfoContainer.add([this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel]); From 11ba28b053b3397523f055dfd0912233a49c91d7 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 2 Aug 2025 21:18:31 +0200 Subject: [PATCH 10/13] Laid out numbers for slot positions --- src/ui/party-ui-handler.ts | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 1a91177ad61..c1951a633c2 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1827,18 +1827,30 @@ class PartySlot extends Phaser.GameObjects.Container { partyUiMode: PartyUiMode, tmMoveId: MoveId, ) { - super( - globalScene, - slotIndex >= globalScene.currentBattle.getBattlerCount() ? 143 : 9, - slotIndex >= globalScene.currentBattle.getBattlerCount() - ? -184 - - 12 + - (globalScene.currentBattle.double ? -40 : 0) + - (28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex - : partyUiMode === PartyUiMode.MODIFIER_TRANSFER - ? -124 - 49 / 2 + (globalScene.currentBattle.double ? -20 : 0) + slotIndex * 55 - : -124 - 49 / 2 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64, - ); + const isBenched = slotIndex >= globalScene.currentBattle.getBattlerCount(); + const isDoubleBattle = globalScene.currentBattle.double; + const isItemManageMode = partyUiMode === PartyUiMode.MODIFIER_TRANSFER || partyUiMode === PartyUiMode.DISCARD; + + /** + Here we determine the position of the slot. + The x coordinate depends on whether the pokemon is on the field or in the bench. + The y coordinate is more complex to determine + */ + const slotPositionX = isBenched ? 143 : 9; + + let slotPositionY = 0; + if (isBenched) { + slotPositionY = -196 + (isDoubleBattle ? -40 : 0); + slotPositionY += (28 + (isDoubleBattle ? 8 : 0)) * slotIndex; + } else { + slotPositionY = -148.5; + if (isDoubleBattle) { + slotPositionY += isItemManageMode ? -20 : -8; + } + slotPositionY += (isItemManageMode ? (isDoubleBattle ? 47 : 55) : 64) * slotIndex; + } + + super(globalScene, slotPositionX, slotPositionY); this.slotIndex = slotIndex; const battlerCount = globalScene.currentBattle.getBattlerCount(); From a88157b1c8d49003e7f99cb21651662f86b1924b Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:47:34 +0200 Subject: [PATCH 11/13] Added smaller main slots for transfer mode in doubles --- public/images/ui/party_slot_main_short.json | 146 ++++++++++++++++++++ public/images/ui/party_slot_main_short.png | Bin 0 -> 2543 bytes src/loading-scene.ts | 1 + src/ui/party-ui-handler.ts | 22 +-- 4 files changed, 159 insertions(+), 10 deletions(-) create mode 100644 public/images/ui/party_slot_main_short.json create mode 100644 public/images/ui/party_slot_main_short.png diff --git a/public/images/ui/party_slot_main_short.json b/public/images/ui/party_slot_main_short.json new file mode 100644 index 00000000000..d738d524a5b --- /dev/null +++ b/public/images/ui/party_slot_main_short.json @@ -0,0 +1,146 @@ +{ + "textures": [ + { + "image": "party_slot_main_short.png", + "format": "RGBA8888", + "size": { + "w": 110, + "h": 294 + }, + "scale": 1, + "frames": [ + { + "filename": "party_slot_main_short", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 110, + "h": 41 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + }, + "frame": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + } + }, + { + "filename": "party_slot_main_short_sel", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 110, + "h": 41 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + }, + "frame": { + "x": 0, + "y": 41, + "w": 110, + "h": 41 + } + }, + { + "filename": "party_slot_main_short_fnt", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 110, + "h": 41 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + }, + "frame": { + "x": 0, + "y": 82, + "w": 110, + "h": 41 + } + }, + { + "filename": "party_slot_main_short_fnt_sel", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 110, + "h": 41 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + }, + "frame": { + "x": 0, + "y": 123, + "w": 110, + "h": 41 + } + }, + { + "filename": "party_slot_main_short_swap", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 110, + "h": 41 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + }, + "frame": { + "x": 0, + "y": 164, + "w": 110, + "h": 41 + } + }, + { + "filename": "party_slot_main_short_swap_sel", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 110, + "h": 41 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 110, + "h": 41 + }, + "frame": { + "x": 0, + "y": 205, + "w": 110, + "h": 41 + } + } + ] + } + ], + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "3.0", + "smartupdate": "$TexturePacker:SmartUpdate:29685f2f538901cf5bf7f0ed2ea867c3:a080ea6c8cccd1e03244214053e79796:565f7afc5ca419b6ba8dbce51ea30818$" + } +} diff --git a/public/images/ui/party_slot_main_short.png b/public/images/ui/party_slot_main_short.png new file mode 100644 index 0000000000000000000000000000000000000000..235810db3ac3bab29e8f23d6b821e5a61ec26d45 GIT binary patch literal 2543 zcmbuBdo)ygAI6QrcAb(CHd86*lyV&!8jM@WEjck!qaudFh?sO-B63NSoQ{l3G~t}W zC_5!n#!O7qG&@QuX@-znXH;kCrgu-?{(skc_gcUG-RryeU(aVf&$IJ)_<3lk>Z{7h z$!U0by6r?}9CD<}O2~an-1Vo(Kqc<jyaE4+P4;P1`N)FjEahH_^nQjTLVrH?>^yQKjDU^If<)a zv%8Nb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dkzeT`Y z*Q+f~X}G{j%!*NG;yvwS|JxcpL<*Drqc!lsi(bcmO)9-6KfB!}eT$I#*WmeUTw|Nq zXYZzRT+g$MgB+Qm9U;Ry74+o9luFBr^!~K8h2No6|26F0=!w1+l+U{4dj35jbq%3~ z`h^j_SZjSUY6XU}_pT!$kxHC?-IPW^vPP|gZ_oB-l(b_lWy*Ko|9_PK(w3UKBHuwf z?a1{+T7For$qNNuA-Ane&i@n(zZ5>dvo|h<57@kMDSS%AyM*||_s@}Gt|Nb-vG^_AO*JS!tdcJ&38$cC4@pIej5zO4TMLpG+T literal 0 HcmV?d00001 diff --git a/src/loading-scene.ts b/src/loading-scene.ts index c5b0263e785..740bfab8fce 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -121,6 +121,7 @@ export class LoadingScene extends SceneBase { this.loadImage("party_bg_double", "ui"); this.loadImage("party_bg_double_manage", "ui"); this.loadAtlas("party_slot_main", "ui"); + this.loadAtlas("party_slot_main_short", "ui"); this.loadAtlas("party_slot", "ui"); this.loadImage("party_slot_overlay_lv", "ui"); this.loadImage("party_slot_hp_bar", "ui"); diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index c1951a633c2..a90f2082a0f 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1817,6 +1817,7 @@ class PartySlot extends Phaser.GameObjects.Container { public slotHpText: Phaser.GameObjects.Text; public slotDescriptionLabel: Phaser.GameObjects.Text; // this is used to show text instead of the HP bar i.e. for showing "Able"/"Not Able" for TMs when you try to learn them + private slotBgKey: string; private pokemonIcon: Phaser.GameObjects.Container; private iconAnimHandler: PokemonIconAnimHandler; @@ -1868,10 +1869,15 @@ class PartySlot extends Phaser.GameObjects.Container { setup(partyUiMode: PartyUiMode, tmMoveId: MoveId) { const currentLanguage = i18next.resolvedLanguage ?? "en"; const offsetJa = currentLanguage === "ja"; + const isItemManageMode = partyUiMode === PartyUiMode.MODIFIER_TRANSFER || partyUiMode === PartyUiMode.DISCARD; - const slotKey = this.isBenched ? "party_slot" : "party_slot_main"; - const slotBgKey = this.pokemon.hp ? slotKey : `${slotKey}${"_fnt"}`; - this.slotBg = globalScene.add.sprite(0, 0, slotKey, slotBgKey); + const slotKey = this.isBenched + ? "party_slot" + : isItemManageMode && globalScene.currentBattle.double + ? "party_slot_main_short" + : "party_slot_main"; + this.slotBgKey = this.pokemon.hp ? slotKey : `${slotKey}${"_fnt"}`; + this.slotBg = globalScene.add.sprite(0, 0, slotKey, this.slotBgKey); this.slotBg.setOrigin(0); this.add(this.slotBg); @@ -1895,11 +1901,7 @@ class PartySlot extends Phaser.GameObjects.Container { descriptionLabelPosition: { x: 32, y: 46 }, }; - if ( - (partyUiMode === PartyUiMode.MODIFIER_TRANSFER || partyUiMode === PartyUiMode.DISCARD) && - globalScene.currentBattle.double && - !this.isBenched - ) { + if (isItemManageMode && globalScene.currentBattle.double && !this.isBenched) { magicNumbers.namePosition.y -= 8; magicNumbers.levelLabelPosition.y -= 8; magicNumbers.hpBarPosition.y -= 8; @@ -2121,8 +2123,8 @@ class PartySlot extends Phaser.GameObjects.Container { private updateSlotTexture(): void { this.slotBg.setTexture( - `party_slot${this.isBenched ? "" : "_main"}`, - `party_slot${this.isBenched ? "" : "_main"}${this.transfer ? "_swap" : this.pokemon.hp ? "" : "_fnt"}${this.selected ? "_sel" : ""}`, + this.slotBgKey, + `${this.slotBgKey}${this.transfer ? "_swap" : this.pokemon.hp ? "" : "_fnt"}${this.selected ? "_sel" : ""}`, ); } } From 6bdadcc3e279f45b1300009b091ff0fdf9648c1b Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sun, 3 Aug 2025 00:02:36 +0200 Subject: [PATCH 12/13] Changed background to fit new slot disposition --- public/images/ui/party_bg_double_manage.png | Bin 837 -> 4143 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/ui/party_bg_double_manage.png b/public/images/ui/party_bg_double_man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6wz79Gao2ow0Mb8&4iG)?~}NI mac}K;G_R`z3Qp9065h@3z4m0j+Y4Z>VDNPHb6Mw<&;$Syf@jYF From e9318ec4c2b9e9c1a36c865fc97a13d05b48adfb Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sun, 3 Aug 2025 15:52:01 +0200 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> --- src/ui/party-ui-handler.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index a90f2082a0f..b7a478e0bd0 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1832,14 +1832,14 @@ class PartySlot extends Phaser.GameObjects.Container { const isDoubleBattle = globalScene.currentBattle.double; const isItemManageMode = partyUiMode === PartyUiMode.MODIFIER_TRANSFER || partyUiMode === PartyUiMode.DISCARD; - /** - Here we determine the position of the slot. - The x coordinate depends on whether the pokemon is on the field or in the bench. - The y coordinate is more complex to determine + /* + * Here we determine the position of the slot. + * The x coordinate depends on whether the pokemon is on the field or in the bench. + * The y coordinate depends on various factors, such as */ const slotPositionX = isBenched ? 143 : 9; - let slotPositionY = 0; + let slotPositionY: number; if (isBenched) { slotPositionY = -196 + (isDoubleBattle ? -40 : 0); slotPositionY += (28 + (isDoubleBattle ? 8 : 0)) * slotIndex; @@ -1854,8 +1854,7 @@ class PartySlot extends Phaser.GameObjects.Container { super(globalScene, slotPositionX, slotPositionY); this.slotIndex = slotIndex; - const battlerCount = globalScene.currentBattle.getBattlerCount(); - this.isBenched = this.slotIndex >= battlerCount; + this.isBenched = isBenched; this.pokemon = pokemon; this.iconAnimHandler = iconAnimHandler; @@ -1925,7 +1924,6 @@ class PartySlot extends Phaser.GameObjects.Container { this.add(this.slotPb); this.pokemonIcon = globalScene.addPokemonIcon(this.pokemon, this.slotPb.x, this.slotPb.y, 0.5, 0.5, true); - // this.pokemonIcon.setPosition(); this.add(this.pokemonIcon); this.iconAnimHandler.addOrUpdate(this.pokemonIcon, PokemonIconAnimMode.PASSIVE);