diff --git a/public/images/ui/ball_window.png b/public/images/ui/ball_window.png deleted file mode 100644 index e5945888c..000000000 Binary files a/public/images/ui/ball_window.png and /dev/null differ diff --git a/public/images/ui/bmenu0.png b/public/images/ui/bmenu0.png deleted file mode 100644 index fba1a6736..000000000 Binary files a/public/images/ui/bmenu0.png and /dev/null differ diff --git a/public/images/ui/game_mode_select_window.png b/public/images/ui/game_mode_select_window.png deleted file mode 100644 index ee36c93ff..000000000 Binary files a/public/images/ui/game_mode_select_window.png and /dev/null differ diff --git a/public/images/ui/level_up_stats.png b/public/images/ui/level_up_stats.png deleted file mode 100644 index e5cd2d9e7..000000000 Binary files a/public/images/ui/level_up_stats.png and /dev/null differ diff --git a/public/images/ui/mmenu0.png b/public/images/ui/mmenu0.png deleted file mode 100644 index 21afd3f9c..000000000 Binary files a/public/images/ui/mmenu0.png and /dev/null differ diff --git a/public/images/ui/boolean_window.png b/public/images/ui/window.png similarity index 100% rename from public/images/ui/boolean_window.png rename to public/images/ui/window.png diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 816b6936b..a20c358df 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -158,6 +158,7 @@ export default class BattleScene extends Phaser.Scene { this.loadImage('bg_fight', 'ui'); this.loadAtlas('prompt', 'ui'); this.loadImage('cursor', 'ui'); + this.loadImage('window', 'ui'); this.loadImage('pbinfo_player', 'ui'); this.loadImage('pbinfo_player_mini', 'ui'); this.loadImage('pbinfo_enemy_mini', 'ui'); @@ -166,11 +167,7 @@ export default class BattleScene extends Phaser.Scene { this.loadAtlas('overlay_hp', 'ui'); this.loadImage('overlay_exp', 'ui'); this.loadImage('icon_owned', 'ui'); - this.loadImage('level_up_stats', 'ui'); this.loadImage('ability_bar', 'ui'); - this.loadImage('ball_window', 'ui'); - this.loadImage('boolean_window', 'ui'); - this.loadImage('game_mode_select_window', 'ui'); this.loadImage('party_bg', 'ui'); this.loadImage('party_bg_double', 'ui'); diff --git a/src/main.ts b/src/main.ts index 3e084d667..70fd060c5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,7 +15,7 @@ const config: Phaser.Types.Core.GameConfig = { }; const setPositionRelative = function (guideObject: any, x: number, y: number) { - if (guideObject && guideObject.hasOwnProperty('width') && guideObject.hasOwnProperty('height')) { + if (guideObject && guideObject instanceof Phaser.GameObjects.GameObject) { const offsetX = guideObject.width * (-0.5 + (0.5 - guideObject.originX)); const offsetY = guideObject.height * (-0.5 + (0.5 - guideObject.originY)); this.setPosition(guideObject.x + offsetX + x, guideObject.y + offsetY + y); @@ -27,6 +27,7 @@ const setPositionRelative = function (guideObject: any, x: number, y: number) { Phaser.GameObjects.Sprite.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Image.prototype.setPositionRelative = setPositionRelative; +Phaser.GameObjects.NineSlice.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Text.prototype.setPositionRelative = setPositionRelative; document.fonts.load('16px emerald').then(() => document.fonts.load('10px pkmnems')); diff --git a/src/ui/ball-ui-handler.ts b/src/ui/ball-ui-handler.ts index 8cc8d9679..0264d9e82 100644 --- a/src/ui/ball-ui-handler.ts +++ b/src/ui/ball-ui-handler.ts @@ -8,7 +8,7 @@ import UiHandler from "./uiHandler"; export default class BallUiHandler extends UiHandler { private pokeballSelectContainer: Phaser.GameObjects.Container; - private pokeballSelectBg: Phaser.GameObjects.Image; + private pokeballSelectBg: Phaser.GameObjects.NineSlice; private countsText: Phaser.GameObjects.Text; private cursorObj: Phaser.GameObjects.Image; @@ -24,7 +24,7 @@ export default class BallUiHandler extends UiHandler { this.pokeballSelectContainer.setVisible(false); ui.add(this.pokeballSelectContainer); - this.pokeballSelectBg = this.scene.add.image(0, 0, 'ball_window'); + this.pokeballSelectBg = this.scene.add.nineslice(0, 0, 'window', null, 114, 96, 6, 6, 6, 6); this.pokeballSelectBg.setOrigin(0, 1); this.pokeballSelectContainer.add(this.pokeballSelectBg); diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index a9d32390f..0532ca793 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -54,7 +54,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler { this.levelUpStatsContainer = levelUpStatsContainer; - const levelUpStatsBg = this.scene.add.image((this.scene.game.canvas.width / 6), -100, 'level_up_stats'); + const levelUpStatsBg = this.scene.add.nineslice((this.scene.game.canvas.width / 6), -100, 'window', null, 118, 100, 6, 6, 6, 6); levelUpStatsBg.setOrigin(1, 0); levelUpStatsContainer.add(levelUpStatsBg); @@ -75,6 +75,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler { const levelUpStatsValuesContent = addTextObject(this.scene, (this.scene.game.canvas.width / 6) - 7, -94, '', TextStyle.WINDOW, { maxLines: 6 }); levelUpStatsValuesContent.setOrigin(1, 0); + levelUpStatsValuesContent.setAlign('right'); levelUpStatsContainer.add(levelUpStatsValuesContent); this.levelUpStatsValuesContent = levelUpStatsValuesContent; diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index 12cd43e16..d7d9d7add 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -1,6 +1,5 @@ -import BattleScene, { Button } from "../battle-scene"; +import BattleScene from "../battle-scene"; import OptionSelectUiHandler from "./option-select-ui-handler"; -import { addTextObject, TextStyle } from "./text"; import { Mode } from "./ui"; export default class ConfirmUiHandler extends OptionSelectUiHandler { @@ -11,11 +10,11 @@ export default class ConfirmUiHandler extends OptionSelectUiHandler { super(scene, Mode.CONFIRM); } - getWindowName(): string { - return 'boolean_window'; + getWindowWidth(): integer { + return 48; } - getWindowWidth(): integer { + getWindowHeight(): integer { return 48; } diff --git a/src/ui/game-mode-select-ui-handler.ts b/src/ui/game-mode-select-ui-handler.ts index 2092a945d..d76c9f7b8 100644 --- a/src/ui/game-mode-select-ui-handler.ts +++ b/src/ui/game-mode-select-ui-handler.ts @@ -8,11 +8,11 @@ export default class GameModeSelectUiHandler extends OptionSelectUiHandler { super(scene, Mode.GAME_MODE_SELECT); } - getWindowName(): string { - return 'game_mode_select_window'; + getWindowWidth(): integer { + return 64; } - getWindowWidth(): integer { + getWindowHeight(): number { return 64; } diff --git a/src/ui/option-select-ui-handler.ts b/src/ui/option-select-ui-handler.ts index 78b5007d1..06ae9a25c 100644 --- a/src/ui/option-select-ui-handler.ts +++ b/src/ui/option-select-ui-handler.ts @@ -7,7 +7,7 @@ export default abstract class OptionSelectUiHandler extends UiHandler { protected handlers: Function[]; protected optionSelectContainer: Phaser.GameObjects.Container; - protected optionSelectBg: Phaser.GameObjects.Image; + protected optionSelectBg: Phaser.GameObjects.NineSlice; private cursorObj: Phaser.GameObjects.Image; @@ -15,10 +15,10 @@ export default abstract class OptionSelectUiHandler extends UiHandler { super(scene, mode); } - abstract getWindowName(): string; - abstract getWindowWidth(): integer; + abstract getWindowHeight(): integer; + abstract getOptions(): string[]; setup() { @@ -28,7 +28,7 @@ export default abstract class OptionSelectUiHandler extends UiHandler { this.optionSelectContainer.setVisible(false); ui.add(this.optionSelectContainer); - this.optionSelectBg = this.scene.add.image(0, 0, this.getWindowName()); + this.optionSelectBg = this.scene.add.nineslice(0, 0, 'window', null, this.getWindowWidth(), this.getWindowHeight(), 6, 6, 6, 6); this.optionSelectBg.setOrigin(0, 1); this.optionSelectContainer.add(this.optionSelectBg);