From 5f700590be857c960e8d90d56c7984b2b0896ed5 Mon Sep 17 00:00:00 2001 From: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> Date: Thu, 3 Oct 2024 16:34:29 +0200 Subject: [PATCH] [QOL] Have Friendship Value be shown in summary (#4490) * Have Friendship Value be shown in summary * Fix how "fill" of icon is calced * Update src/locales/de/pokemon-summary.json * Actually add the images * Add correct image files * Update src/ui/summary-ui-handler.ts Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> * Update src/ui/summary-ui-handler.ts Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> * Update src/ui/summary-ui-handler.ts * Update src/ui/summary-ui-handler.ts Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> * Made changed suggested in code review * Update src/locales/en/pokemon-summary.json --------- Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> --- public/images/ui/friendship.png | Bin 0 -> 174 bytes public/images/ui/friendship_overlay.png | Bin 0 -> 182 bytes public/images/ui/legacy/friendship.png | Bin 0 -> 174 bytes .../images/ui/legacy/friendship_overlay.png | Bin 0 -> 182 bytes src/loading-scene.ts | 2 ++ src/ui/summary-ui-handler.ts | 33 ++++++++++++++++++ 6 files changed, 35 insertions(+) create mode 100644 public/images/ui/friendship.png create mode 100644 public/images/ui/friendship_overlay.png create mode 100644 public/images/ui/legacy/friendship.png create mode 100644 public/images/ui/legacy/friendship_overlay.png diff --git a/public/images/ui/friendship.png b/public/images/ui/friendship.png new file mode 100644 index 0000000000000000000000000000000000000000..073adcadc7654da274704444d5cbc773c4a925a2 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngd!3-pihitnGq!^2X+?^QKos)S9VIoSmBi2x?XbGy$vQ#9~stsVD#Pi SG4lt|ECx?kKbLh*2~7YE>pBVm literal 0 HcmV?d00001 diff --git a/public/images/ui/friendship_overlay.png b/public/images/ui/friendship_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..4a4724fbdc9f357caa342f3eab247bb0c8d9a876 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngd!3-pihitnGq!^2X+?^QKos)S9k`3?)aRt&o zf}(3>R6iTp|G#-T?dz^HKq1zWAirRS|3DyfK@DV*i>HfY2*=FO-jj?B3LJ;IcKkmx z&AFw{Ymo*+;sw?~gy?!Mb@LJuD>e>{GIF!lGYH Y8)6xQ9wz_32Q-ht)78&qol`;+0AP_n(*OVf literal 0 HcmV?d00001 diff --git a/public/images/ui/legacy/friendship.png b/public/images/ui/legacy/friendship.png new file mode 100644 index 0000000000000000000000000000000000000000..073adcadc7654da274704444d5cbc773c4a925a2 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngd!3-pihitnGq!^2X+?^QKos)S9VIoSmBi2x?XbGy$vQ#9~stsVD#Pi SG4lt|ECx?kKbLh*2~7YE>pBVm literal 0 HcmV?d00001 diff --git a/public/images/ui/legacy/friendship_overlay.png b/public/images/ui/legacy/friendship_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..4a4724fbdc9f357caa342f3eab247bb0c8d9a876 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngd!3-pihitnGq!^2X+?^QKos)S9k`3?)aRt&o zf}(3>R6iTp|G#-T?dz^HKq1zWAirRS|3DyfK@DV*i>HfY2*=FO-jj?B3LJ;IcKkmx z&AFw{Ymo*+;sw?~gy?!Mb@LJuD>e>{GIF!lGYH Y8)6xQ9wz_32Q-ht)78&qol`;+0AP_n(*OVf literal 0 HcmV?d00001 diff --git a/src/loading-scene.ts b/src/loading-scene.ts index e71082ca8f5..3d4f4d165e6 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -44,6 +44,8 @@ export class LoadingScene extends SceneBase { this.loadAtlas("prompt", "ui"); this.loadImage("candy", "ui"); this.loadImage("candy_overlay", "ui"); + this.loadImage("friendship", "ui"); + this.loadImage("friendship_overlay", "ui"); this.loadImage("cursor", "ui"); this.loadImage("cursor_reverse", "ui"); for (const wv of Utils.getEnumValues(WindowVariant)) { diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 28c3ccdb2e4..d3985b225ff 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -87,6 +87,10 @@ export default class SummaryUiHandler extends UiHandler { private moveAccuracyText: Phaser.GameObjects.Text; private moveCategoryIcon: Phaser.GameObjects.Sprite; private summaryPageTransitionContainer: Phaser.GameObjects.Container; + private friendshipShadow: Phaser.GameObjects.Sprite; + private friendshipText: Phaser.GameObjects.Text; + private friendshipIcon: Phaser.GameObjects.Sprite; + private friendshipOverlay: Phaser.GameObjects.Sprite; private descriptionScrollTween: Phaser.Tweens.Tween | null; private moveCursorBlinkTimer: Phaser.Time.TimerEvent | null; @@ -187,6 +191,25 @@ export default class SummaryUiHandler extends UiHandler { this.candyCountText.setOrigin(0, 0); this.summaryContainer.add(this.candyCountText); + this.friendshipIcon = this.scene.add.sprite(13, -60, "friendship"); + this.friendshipIcon.setScale(0.8); + this.summaryContainer.add(this.friendshipIcon); + + this.friendshipOverlay = this.scene.add.sprite(13, -60, "friendship_overlay"); + this.friendshipOverlay.setScale(0.8); + this.summaryContainer.add(this.friendshipOverlay); + + this.friendshipShadow = this.scene.add.sprite(13, -60, "friendship"); + this.friendshipShadow.setTint(0x000000); + this.friendshipShadow.setAlpha(0.50); + this.friendshipShadow.setScale(0.8); + this.friendshipShadow.setInteractive(new Phaser.Geom.Rectangle(0, 0, 16, 16), Phaser.Geom.Rectangle.Contains); + this.summaryContainer.add(this.friendshipShadow); + + this.friendshipText = addTextObject(this.scene, 20, -66, "x0", TextStyle.WINDOW_ALT, { fontSize: "76px" }); + this.friendshipText.setOrigin(0, 0); + this.summaryContainer.add(this.friendshipText); + this.championRibbon = this.scene.add.image(88, -146, "champion_ribbon"); this.championRibbon.setOrigin(0, 0); //this.championRibbon.setScale(0.8); @@ -292,6 +315,7 @@ export default class SummaryUiHandler extends UiHandler { this.candyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0]))); this.candyOverlay.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1]))); + this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 4)); this.numberText.setColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD)); this.numberText.setShadowColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true)); @@ -345,6 +369,15 @@ export default class SummaryUiHandler extends UiHandler { this.candyShadow.setCrop(0, 0, 16, candyCropY); + if (this.friendshipShadow.visible) { + this.friendshipShadow.on("pointerover", () => this.scene.ui.showTooltip("", `${i18next.t("pokemonSummary:friendship")}`, true)); + this.friendshipShadow.on("pointerout", () => this.scene.ui.hideTooltip()); + } + + this.friendshipText.setText(`${this.pokemon?.friendship || "0"} / 255`); + + this.friendshipShadow.setCrop(0, 0, 16, 16 - (16 * ((this.pokemon?.friendship || 0) / 255))); + const doubleShiny = isFusion && this.pokemon.shiny && this.pokemon.fusionShiny; const baseVariant = !doubleShiny ? this.pokemon.getVariant() : this.pokemon.variant;