From d442770de60d78189ebf68686d556c6759fba5c5 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 1 Apr 2024 10:06:28 -0400 Subject: [PATCH] Add themed namebox --- public/images/ui/bg.png | Bin 703 -> 1382 bytes public/images/ui/legacy/namebox.json | 41 +++++++++ public/images/ui/legacy/namebox.png | Bin 278 -> 193 bytes public/images/ui/namebox.json | 125 +++++++++++++++++++++++++++ public/images/ui/namebox.png | Bin 312 -> 397 bytes src/battle-scene.ts | 2 +- src/ui/battle-message-ui-handler.ts | 2 +- src/ui/ui-theme.ts | 12 +-- 8 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 public/images/ui/legacy/namebox.json create mode 100644 public/images/ui/namebox.json diff --git a/public/images/ui/bg.png b/public/images/ui/bg.png index 9d39d701fe1e3c571cd536484d496bd4b3d59cae..9c35e80ff8b08a9c0b5d629156906f357fd4037e 100644 GIT binary patch literal 1382 zcmeAS@N?(olHy`uVBq!ia0y~yU~~YoKX9-C$wJ+|*+7c1ILO_JVcj{Imp~3nx}&cn z1H;CC?mvmFK<+nB7srr_xVLxrW`#ydG$dZX(|A`e_f3zzMq|SY#`=qH+R9xwez4!V zp~)3h!7BEMcgfbxTfPVtahL6EIrF5zNWxv+>gtm{=P$3>dhXuW)9lp;B`=%g$}(_B z#ZTksR+wNiPu^a$!QoOxNlqj~DZ@Bl0fR;jP(qbOdKhk z3KLWt9HucaMbeyOs;4{m-mLeGLC4N6)@I^R>2*Ioja9%y>U{rv5eJ3Lnn*hxprdCj z^JHjLxt`Flrtrn%YGI&n`fTbnfD#r}ulqpWI5PD$NOQ2ZI7stp?{pRck0M^S6G9FO z-VBX8j4Yd21ZdA$Q<(Mi(X|@>2}XV~JN1y9cj9q7$a&84_dzkSEEDLglco|1**Q5m zGk}rt@z>L6P%KPlKM!=bRJQp$E}*h=^Y^I%&4`GzQf_dVlx;wt2th=A@8{*~bI*Qf z&`f@NEEdUm>*M!{0;2}#b`Dg})b2`P0{UY2^3@>Eif=y;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)qVX*bKNl|bEu^G0( zA%Nk9galTXNxXQ$5O81vRzn$&8h5#Ii>}*AtYLT!eI4Y^#C{f5y_rFt-Obk>8qXv!|I4BJK%4D`2y)+>fU@LW)7+%UOKvyL3 z;srs&BwoD0wEU&a0w(LTWxLQ_8E{|&UPEyfUuVm9(WZc1^3p%KUH_VqGL?VPsLeRJ;RCbiq!WOKJ&6%Mst%A+jx=3t%M z-rUnIVzCx;~*Pg*@Rx5~X!Uyr6U!6^MpXv~PJsX*lVhibU{RpblSM8kTs5D6S1j^6rKl+%eolP;C*gBHjhDq} mTZ*Tg3Z4J?(y#BYzw_1@>)UQ!^fm(MaRyIUKbLh*2~7YHS&zE_ literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1Ig8=fwXAr`$$ zuO8$*tiZ#1LH-Ksj*WfCKeWgleqE5vQkBu`RKU5!F6!B9%@a==f;E@E`nrBVzht8Jy0OA1GAP)86SB&S?)TWe`ZtIpw%x^=!@A1@7j-ZOeDXpDHlkAFKGh=El|gx$WU)$F?ow zd>cI_Xxd>f&BI}=4>mvXpAsI+U9;#*N$i7lmo77&)0gTe~DWM4f D;4pij diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 0ebd972d4c8..b3bb1eb0bf8 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -286,7 +286,7 @@ export default class BattleScene extends Phaser.Scene { for (let w = 1; w <= 5; w++) this.loadImage(`window_${w}${getWindowVariantSuffix(wv)}`, 'ui/windows'); } - this.loadImage('namebox', 'ui'); + this.loadAtlas('namebox', 'ui'); this.loadImage('pbinfo_player', 'ui'); this.loadImage('pbinfo_player_mini', 'ui'); this.loadImage('pbinfo_enemy_mini', 'ui'); diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index f5adfa4ed41..23830cd75f4 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -72,7 +72,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler { this.nameBoxContainer = this.scene.add.container(0, -16); this.nameBoxContainer.setVisible(false); - this.nameBox = this.scene.add.nineslice(0, 0, 'namebox', null, 72, 16, 8, 8, 5, 5); + this.nameBox = this.scene.add.nineslice(0, 0, 'namebox', this.scene.windowType, 72, 16, 8, 8, 5, 5); this.nameBox.setOrigin(0, 0); this.nameText = addTextObject(this.scene, 8, 0, 'Rival', TextStyle.MESSAGE, { maxLines: 1 }); diff --git a/src/ui/ui-theme.ts b/src/ui/ui-theme.ts index 28612fbcbdd..26ba4be708f 100644 --- a/src/ui/ui-theme.ts +++ b/src/ui/ui-theme.ts @@ -58,7 +58,7 @@ export function addWindow(scene: BattleScene, x: number, y: number, width: numbe export function updateWindowType(scene: BattleScene, windowTypeIndex: integer): void { const windowObjects: [Phaser.GameObjects.NineSlice, WindowVariant][] = []; - const bgObjects: Phaser.GameObjects.Image[] = []; + const themedObjects: Phaser.GameObjects.Image[] = []; const traverse = (object: any) => { if (object.hasOwnProperty('children')) { const children = object.children as Phaser.GameObjects.DisplayList; @@ -70,8 +70,10 @@ export function updateWindowType(scene: BattleScene, windowTypeIndex: integer): } else if (object instanceof Phaser.GameObjects.NineSlice) { if (object.texture.key.startsWith('window_')) windowObjects.push([ object, object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.XTHIN)) ? WindowVariant.XTHIN : object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.THIN)) ? WindowVariant.THIN : WindowVariant.NORMAL ]); - } else if (object instanceof Phaser.GameObjects.Sprite && object.texture?.key === 'bg') - bgObjects.push(object) + } else if (object instanceof Phaser.GameObjects.Sprite) { + if ([ 'bg', 'namebox' ].includes(object.texture?.key)) + themedObjects.push(object); + } } traverse(scene); @@ -86,8 +88,8 @@ export function updateWindowType(scene: BattleScene, windowTypeIndex: integer): for (let [ window, variant ] of windowObjects) window.setTexture(`${windowKey}${getWindowVariantSuffix(variant)}`); - for (let bg of bgObjects) - bg.setFrame(windowTypeIndex); + for (let obj of themedObjects) + obj.setFrame(windowTypeIndex); } export function addUiThemeOverrides(scene: BattleScene): void {