From 05f114c8a44e6b6ccb74e50d489359b5673ecc01 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 6 Feb 2024 23:11:00 -0500 Subject: [PATCH] Minor UI changes --- src/battle-scene.ts | 1 - src/system/game-data.ts | 2 +- src/ui/abstact-option-select-ui-handler.ts | 3 +- src/ui/confirm-ui-handler.ts | 7 +-- src/ui/game-mode-select-ui-handler.ts | 58 ---------------------- src/ui/menu-ui-handler.ts | 2 +- src/ui/starter-select-ui-handler.ts | 29 +++++++++-- src/ui/text.ts | 2 +- src/ui/ui.ts | 4 -- 9 files changed, 34 insertions(+), 74 deletions(-) delete mode 100644 src/ui/game-mode-select-ui-handler.ts diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 2d2183098..99f1a11bf 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1128,7 +1128,6 @@ export default class BattleScene extends Phaser.Scene { case Mode.BIOME_SELECT: case Mode.STARTER_SELECT: case Mode.CONFIRM: - case Mode.GAME_MODE_SELECT: this.ui.setOverlayMode(Mode.MENU); inputSuccess = true; break; diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 841aefe6b..8b42ae48f 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -676,7 +676,7 @@ export class GameData { }, () => { this.scene.ui.revertMode(); this.scene.ui.showText(null, 0); - }, false, 98); + }, false, -98); }); }; })((e.target as any).files[0]); diff --git a/src/ui/abstact-option-select-ui-handler.ts b/src/ui/abstact-option-select-ui-handler.ts index 31d925769..f03523144 100644 --- a/src/ui/abstact-option-select-ui-handler.ts +++ b/src/ui/abstact-option-select-ui-handler.ts @@ -6,6 +6,7 @@ import { addWindow } from "./window"; export interface OptionSelectConfig { xOffset?: number; + yOffset?: number; options: OptionSelectItem[]; } @@ -58,7 +59,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { this.optionSelectText = addTextObject(this.scene, 0, 0, options.map(o => o.label).join('\n'), TextStyle.WINDOW, { maxLines: options.length }); this.optionSelectText.setLineSpacing(12); this.optionSelectContainer.add(this.optionSelectText); - this.optionSelectContainer.x = (this.scene.game.canvas.width / 6) - 1 - (this.config?.xOffset || 0); + this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 - (this.config?.xOffset || 0), -48 + (this.config?.yOffset || 0)); this.optionSelectBg.width = Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth()); this.optionSelectBg.height = this.getWindowHeight(); diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index f25d142b2..b7ac2ff77 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -31,11 +31,12 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { super.show([ config ]); - this.switchCheck = args.length >= 3 && args[2] as boolean; + this.switchCheck = args.length >= 3 && args[2] !== null && args[2] as boolean; - const xOffset = (args.length >= 4 ? -args[3] as number : 0); + const xOffset = (args.length >= 4 && args[3] !== null ? args[3] as number : 0); + const yOffset = (args.length >= 5 && args[4] !== null ? args[4] as number : 0); - this.optionSelectContainer.x = (this.scene.game.canvas.width / 6) - 1 + xOffset; + this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset); this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); diff --git a/src/ui/game-mode-select-ui-handler.ts b/src/ui/game-mode-select-ui-handler.ts deleted file mode 100644 index 70ea0f68d..000000000 --- a/src/ui/game-mode-select-ui-handler.ts +++ /dev/null @@ -1,58 +0,0 @@ -import BattleScene from "../battle-scene"; -import { GameMode, gameModeNames } from "../game-mode"; -import { Unlockables } from "../system/unlockables"; -import AbstractOptionSelectUiHandler, { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler"; -import { Mode } from "./ui"; - -export default class GameModeSelectUiHandler extends AbstractOptionSelectUiHandler { - - constructor(scene: BattleScene) { - super(scene, Mode.GAME_MODE_SELECT); - } - - getWindowWidth(): integer { - return 104; - } - - show(args: any[]): boolean { - if (args.length === 2 && args[0] instanceof Function && args[1] instanceof Function) { - const options: OptionSelectItem[] = [ - { - label: gameModeNames[GameMode.CLASSIC], - handler: () => args[0](GameMode.CLASSIC) - } - ]; - - if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { - options.push({ - label: gameModeNames[GameMode.ENDLESS], - handler: () => args[0](GameMode.ENDLESS) - }); - if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { - options.push({ - label: gameModeNames[GameMode.SPLICED_ENDLESS], - handler: () => args[0](GameMode.SPLICED_ENDLESS) - }); - } - } - - options.push({ - label: 'Cancel', - handler: args[1] - }) - - const config: OptionSelectConfig = { - options: options - }; - - super.show([ config ]); - - this.optionSelectContainer.setVisible(true); - this.setCursor(0); - - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 1d145d49c..ed0d36b82 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -198,7 +198,7 @@ export default class MenuUiHandler extends MessageUiHandler { ui.setOverlayMode(Mode.CONFIRM, doLogout, () => { ui.revertMode(); ui.showText(null, 0); - }, false, 98); + }, false, -98); }); } else doLogout(); diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 7217960eb..0d8a61352 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -6,7 +6,7 @@ import { Mode } from "./ui"; import MessageUiHandler from "./message-ui-handler"; import { Gender, getGenderColor, getGenderSymbol } from "../data/gender"; import { allAbilities } from "../data/ability"; -import { GameMode } from "../game-mode"; +import { GameMode, gameModeNames } from "../game-mode"; import { Unlockables } from "../system/unlockables"; import { GrowthRate, getGrowthRateColor } from "../data/exp"; import { DexAttr, DexEntry } from "../system/game-data"; @@ -463,7 +463,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { ui.setMode(Mode.STARTER_SELECT); } } - ] + ], + yOffset: 47 }); success = true; } @@ -925,10 +926,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }; if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { ui.setMode(Mode.STARTER_SELECT); - ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, startRun, cancel)); + const options = [ + { + label: gameModeNames[GameMode.CLASSIC], + handler: () => startRun(GameMode.CLASSIC) + }, + { + label: gameModeNames[GameMode.ENDLESS], + handler: () => startRun(GameMode.ENDLESS) + } + ]; + if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { + options.push({ + label: gameModeNames[GameMode.SPLICED_ENDLESS], + handler: () => startRun(GameMode.SPLICED_ENDLESS) + }); + } + options.push({ + label: 'Cancel', + handler: () => cancel() + }); + ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, yOffset: 19 })); } else startRun(GameMode.CLASSIC); - }, cancel); + }, cancel, null, null, 19); }); return true; diff --git a/src/ui/text.ts b/src/ui/text.ts index f71623789..7e1427f09 100644 --- a/src/ui/text.ts +++ b/src/ui/text.ts @@ -100,7 +100,7 @@ function getTextStyleOptions(style: TextStyle, extraStyleOptions?: Phaser.Types. if (extraStyleOptions) { if (extraStyleOptions.fontSize) { - const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.slice(0, -2)); + const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize.toString().slice(0, -2)); shadowSize *= sizeRatio; } styleOptions = Object.assign(styleOptions, extraStyleOptions); diff --git a/src/ui/ui.ts b/src/ui/ui.ts index 2aea02646..5f6ba47e4 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -13,7 +13,6 @@ import StarterSelectUiHandler from './starter-select-ui-handler'; import EvolutionSceneHandler from './evolution-scene-handler'; import BiomeSelectUiHandler from './biome-select-ui-handler'; import TargetSelectUiHandler from './target-select-ui-handler'; -import GameModeSelectUiHandler from './game-mode-select-ui-handler'; import SettingsUiHandler from './settings-ui-handler'; import { TextStyle, addTextObject } from './text'; import AchvBar from './achv-bar'; @@ -46,7 +45,6 @@ export enum Mode { EGG_HATCH_SCENE, CONFIRM, OPTION_SELECT, - GAME_MODE_SELECT, MENU, SETTINGS, ACHIEVEMENTS, @@ -72,7 +70,6 @@ const transitionModes = [ const noTransitionModes = [ Mode.CONFIRM, Mode.OPTION_SELECT, - Mode.GAME_MODE_SELECT, Mode.MENU, Mode.SETTINGS, Mode.ACHIEVEMENTS, @@ -117,7 +114,6 @@ export default class UI extends Phaser.GameObjects.Container { new EggHatchSceneHandler(scene), new ConfirmUiHandler(scene), new OptionSelectUiHandler(scene), - new GameModeSelectUiHandler(scene), new MenuUiHandler(scene), new SettingsUiHandler(scene), new AchvsUiHandler(scene),