Add themed namebox

This commit is contained in:
Flashfyre committed 2024-04-01 10:06:28 -04:00
1 parent eb6ee79b3e
commit d442770de6
8 files changed
+175 -7

No files matched your search

+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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 });
+7 -5
View File
@@ -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 {