Renamed two handlers to helpers

This commit is contained in:
Wlowscha 2025-09-10 17:16:55 +02:00
parent ddca519f96
commit fc0e94772b
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
8 changed files with 32 additions and 32 deletions

View File

@ -4,8 +4,8 @@ import { Gender } from "#data/gender";
import type { PokemonSpecies } from "#data/pokemon-species"; import type { PokemonSpecies } from "#data/pokemon-species";
import { DexAttr } from "#enums/dex-attr"; import { DexAttr } from "#enums/dex-attr";
import { getVariantTint } from "#sprites/variant"; import { getVariantTint } from "#sprites/variant";
import type { PokemonIconAnimHandler } from "#ui/utils/pokemon-icon-anim-handler"; import type { PokemonIconAnimHelper } from "#ui/utils/pokemon-icon-anim-helper";
import { PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-handler"; import { PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-helper";
/** /**
* A container for a Pokemon's sprite and icons to get displayed in the egg summary screen * A container for a Pokemon's sprite and icons to get displayed in the egg summary screen
@ -81,9 +81,9 @@ export class HatchedPokemonContainer extends Phaser.GameObjects.Container {
* Animates the pokemon icon if it has a new form or shiny variant * Animates the pokemon icon if it has a new form or shiny variant
* *
* @param hatchData the {@linkcode EggHatchData} to base the icons on * @param hatchData the {@linkcode EggHatchData} to base the icons on
* @param iconAnimHandler the {@linkcode PokemonIconAnimHandler} to use to animate the sprites * @param iconAnimHandler the {@linkcode PokemonIconAnimHelper} to use to animate the sprites
*/ */
updateAndAnimate(hatchData: EggHatchData, iconAnimHandler: PokemonIconAnimHandler) { updateAndAnimate(hatchData: EggHatchData, iconAnimHandler: PokemonIconAnimHelper) {
const displayPokemon = hatchData.pokemon; const displayPokemon = hatchData.pokemon;
this.species = displayPokemon.species; this.species = displayPokemon.species;

View File

@ -6,8 +6,8 @@ import { ScrollBar } from "#ui/containers/scroll-bar";
import { MessageUiHandler } from "#ui/handlers/message-ui-handler"; import { MessageUiHandler } from "#ui/handlers/message-ui-handler";
import { addTextObject } from "#ui/text"; import { addTextObject } from "#ui/text";
import { addWindow } from "#ui/ui-theme"; import { addWindow } from "#ui/ui-theme";
import { PokemonIconAnimHandler, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-handler"; import { PokemonIconAnimHelper, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-helper";
import { ScrollableGridHandler } from "#ui/utils/scrollable-grid-handler"; import { ScrollableGridHelper } from "#ui/utils/scrollable-grid-helper";
import i18next from "i18next"; import i18next from "i18next";
export class EggListUiHandler extends MessageUiHandler { export class EggListUiHandler extends MessageUiHandler {
@ -25,9 +25,9 @@ export class EggListUiHandler extends MessageUiHandler {
private eggListMessageBoxContainer: Phaser.GameObjects.Container; private eggListMessageBoxContainer: Phaser.GameObjects.Container;
private cursorObj: Phaser.GameObjects.Image; private cursorObj: Phaser.GameObjects.Image;
private scrollGridHandler: ScrollableGridHandler; private scrollGridHandler: ScrollableGridHelper;
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHelper;
constructor() { constructor() {
super(UiMode.EGG_LIST); super(UiMode.EGG_LIST);
@ -45,7 +45,7 @@ export class EggListUiHandler extends MessageUiHandler {
const eggListBg = globalScene.add.image(0, 0, "egg_list_bg").setOrigin(0); const eggListBg = globalScene.add.image(0, 0, "egg_list_bg").setOrigin(0);
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHelper();
this.iconAnimHandler.setup(); this.iconAnimHandler.setup();
this.eggNameText = addTextObject(8, 68, "", TextStyle.SUMMARY).setOrigin(0); this.eggNameText = addTextObject(8, 68, "", TextStyle.SUMMARY).setOrigin(0);
@ -64,7 +64,7 @@ export class EggListUiHandler extends MessageUiHandler {
const scrollBar = new ScrollBar(310, 5, 4, 170, this.ROWS); const scrollBar = new ScrollBar(310, 5, 4, 170, this.ROWS);
this.scrollGridHandler = new ScrollableGridHandler(this, this.ROWS, this.COLUMNS) this.scrollGridHandler = new ScrollableGridHelper(this, this.ROWS, this.COLUMNS)
.withScrollBar(scrollBar) .withScrollBar(scrollBar)
.withUpdateGridCallBack(() => this.updateEggIcons()) .withUpdateGridCallBack(() => this.updateEggIcons())
.withUpdateSingleElementCallback((i: number) => this.setEggDetails(i)); .withUpdateSingleElementCallback((i: number) => this.setEggDetails(i));

View File

@ -7,8 +7,8 @@ import { HatchedPokemonContainer } from "#ui/containers/hatched-pokemon-containe
import { PokemonHatchInfoContainer } from "#ui/containers/pokemon-hatch-info-container"; import { PokemonHatchInfoContainer } from "#ui/containers/pokemon-hatch-info-container";
import { ScrollBar } from "#ui/containers/scroll-bar"; import { ScrollBar } from "#ui/containers/scroll-bar";
import { MessageUiHandler } from "#ui/handlers/message-ui-handler"; import { MessageUiHandler } from "#ui/handlers/message-ui-handler";
import { PokemonIconAnimHandler, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-handler"; import { PokemonIconAnimHelper, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-helper";
import { ScrollableGridHandler } from "#ui/utils/scrollable-grid-handler"; import { ScrollableGridHelper } from "#ui/utils/scrollable-grid-helper";
const iconContainerX = 112; const iconContainerX = 112;
const iconContainerY = 9; const iconContainerY = 9;
@ -34,11 +34,11 @@ export class EggSummaryUiHandler extends MessageUiHandler {
/** hatch info container that displays the current pokemon / hatch (main element on left hand side) */ /** hatch info container that displays the current pokemon / hatch (main element on left hand side) */
private infoContainer: PokemonHatchInfoContainer; private infoContainer: PokemonHatchInfoContainer;
/** handles jumping animations for the pokemon sprite icons */ /** handles jumping animations for the pokemon sprite icons */
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHelper;
private eggHatchBg: Phaser.GameObjects.Image; private eggHatchBg: Phaser.GameObjects.Image;
private eggHatchData: EggHatchData[]; private eggHatchData: EggHatchData[];
private scrollGridHandler: ScrollableGridHandler; private scrollGridHandler: ScrollableGridHelper;
private cursorObj: Phaser.GameObjects.Image; private cursorObj: Phaser.GameObjects.Image;
/** used to add a delay before which it is not possible to exit the summary */ /** used to add a delay before which it is not possible to exit the summary */
@ -67,7 +67,7 @@ export class EggSummaryUiHandler extends MessageUiHandler {
this.eggHatchContainer.setVisible(false); this.eggHatchContainer.setVisible(false);
ui.add(this.eggHatchContainer); ui.add(this.eggHatchContainer);
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHelper();
this.iconAnimHandler.setup(); this.iconAnimHandler.setup();
this.eggHatchBg = globalScene.add.image(0, 0, "egg_summary_bg"); this.eggHatchBg = globalScene.add.image(0, 0, "egg_summary_bg");
@ -97,7 +97,7 @@ export class EggSummaryUiHandler extends MessageUiHandler {
); );
this.summaryContainer.add(scrollBar); this.summaryContainer.add(scrollBar);
this.scrollGridHandler = new ScrollableGridHandler(this, numRows, numCols) this.scrollGridHandler = new ScrollableGridHelper(this, numRows, numCols)
.withScrollBar(scrollBar) .withScrollBar(scrollBar)
.withUpdateGridCallBack(() => this.updatePokemonIcons()) .withUpdateGridCallBack(() => this.updatePokemonIcons())
.withUpdateSingleElementCallback((i: number) => this.infoContainer.showHatchInfo(this.eggHatchData[i])); .withUpdateSingleElementCallback((i: number) => this.infoContainer.showHatchInfo(this.eggHatchData[i]));

View File

@ -25,7 +25,7 @@ import { MoveInfoOverlay } from "#ui/containers/move-info-overlay";
import { MessageUiHandler } from "#ui/handlers/message-ui-handler"; import { MessageUiHandler } from "#ui/handlers/message-ui-handler";
import { addBBCodeTextObject, addTextObject, getTextColor } from "#ui/text"; import { addBBCodeTextObject, addTextObject, getTextColor } from "#ui/text";
import { addWindow } from "#ui/ui-theme"; import { addWindow } from "#ui/ui-theme";
import { PokemonIconAnimHandler, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-handler"; import { PokemonIconAnimHelper, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-helper";
import { applyChallenges } from "#utils/challenge-utils"; import { applyChallenges } from "#utils/challenge-utils";
import { BooleanHolder, getLocalizedSpriteKey, randInt } from "#utils/common"; import { BooleanHolder, getLocalizedSpriteKey, randInt } from "#utils/common";
import { toCamelCase, toTitleCase } from "#utils/strings"; import { toCamelCase, toTitleCase } from "#utils/strings";
@ -201,7 +201,7 @@ export class PartyUiHandler extends MessageUiHandler {
private tmMoveId: MoveId; private tmMoveId: MoveId;
private showMovePp: boolean; private showMovePp: boolean;
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHelper;
private blockInput: boolean; private blockInput: boolean;
@ -320,7 +320,7 @@ export class PartyUiHandler extends MessageUiHandler {
this.optionsContainer = globalScene.add.container(globalScene.scaledCanvas.width - 1, -1); this.optionsContainer = globalScene.add.container(globalScene.scaledCanvas.width - 1, -1);
partyContainer.add(this.optionsContainer); partyContainer.add(this.optionsContainer);
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHelper();
this.iconAnimHandler.setup(); this.iconAnimHandler.setup();
const partyDiscardModeButton = new PartyDiscardModeButton(DISCARD_BUTTON_X, DISCARD_BUTTON_Y, this); const partyDiscardModeButton = new PartyDiscardModeButton(DISCARD_BUTTON_X, DISCARD_BUTTON_Y, this);
@ -1892,12 +1892,12 @@ class PartySlot extends Phaser.GameObjects.Container {
private slotBgKey: string; private slotBgKey: string;
private pokemonIcon: Phaser.GameObjects.Container; private pokemonIcon: Phaser.GameObjects.Container;
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHelper;
constructor( constructor(
slotIndex: number, slotIndex: number,
pokemon: PlayerPokemon, pokemon: PlayerPokemon,
iconAnimHandler: PokemonIconAnimHandler, iconAnimHandler: PokemonIconAnimHelper,
partyUiMode: PartyUiMode, partyUiMode: PartyUiMode,
tmMoveId: MoveId, tmMoveId: MoveId,
) { ) {

View File

@ -50,7 +50,7 @@ import type { OptionSelectConfig } from "#ui/handlers/abstract-option-select-ui-
import { MessageUiHandler } from "#ui/handlers/message-ui-handler"; import { MessageUiHandler } from "#ui/handlers/message-ui-handler";
import { addTextObject, getTextColor } from "#ui/text"; import { addTextObject, getTextColor } from "#ui/text";
import { addWindow } from "#ui/ui-theme"; import { addWindow } from "#ui/ui-theme";
import { PokemonIconAnimHandler, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-handler"; import { PokemonIconAnimHelper, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-helper";
import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#utils/common"; import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#utils/common";
import type { StarterPreferences } from "#utils/data"; import type { StarterPreferences } from "#utils/data";
import { loadStarterPreferences } from "#utils/data"; import { loadStarterPreferences } from "#utils/data";
@ -198,7 +198,7 @@ export class PokedexUiHandler extends MessageUiHandler {
public cursorObj: Phaser.GameObjects.Image; public cursorObj: Phaser.GameObjects.Image;
private pokerusCursorObjs: Phaser.GameObjects.Image[]; private pokerusCursorObjs: Phaser.GameObjects.Image[];
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHelper;
private starterPreferences: StarterPreferences; private starterPreferences: StarterPreferences;
@ -482,7 +482,7 @@ export class PokedexUiHandler extends MessageUiHandler {
pokemonContainerWindow.setVisible(false); pokemonContainerWindow.setVisible(false);
} }
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHelper();
this.iconAnimHandler.setup(); this.iconAnimHandler.setup();
this.pokemonNumberText = addTextObject(6, 141, "", TextStyle.SUMMARY); this.pokemonNumberText = addTextObject(6, 141, "", TextStyle.SUMMARY);

View File

@ -67,7 +67,7 @@ import type { OptionSelectItem } from "#ui/handlers/abstract-option-select-ui-ha
import { MessageUiHandler } from "#ui/handlers/message-ui-handler"; import { MessageUiHandler } from "#ui/handlers/message-ui-handler";
import { addBBCodeTextObject, addTextObject, getTextColor } from "#ui/text"; import { addBBCodeTextObject, addTextObject, getTextColor } from "#ui/text";
import { addWindow } from "#ui/ui-theme"; import { addWindow } from "#ui/ui-theme";
import { PokemonIconAnimHandler, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-handler"; import { PokemonIconAnimHelper, PokemonIconAnimMode } from "#ui/utils/pokemon-icon-anim-helper";
import { applyChallenges, checkStarterValidForChallenge } from "#utils/challenge-utils"; import { applyChallenges, checkStarterValidForChallenge } from "#utils/challenge-utils";
import { import {
BooleanHolder, BooleanHolder,
@ -398,7 +398,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
private startCursorObj: Phaser.GameObjects.NineSlice; private startCursorObj: Phaser.GameObjects.NineSlice;
private randomCursorObj: Phaser.GameObjects.NineSlice; private randomCursorObj: Phaser.GameObjects.NineSlice;
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHelper;
//variables to keep track of the dynamically rendered list of instruction prompts for starter select //variables to keep track of the dynamically rendered list of instruction prompts for starter select
private instructionRowX = 0; private instructionRowX = 0;
@ -611,7 +611,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
starterContainerWindow.setVisible(false); starterContainerWindow.setVisible(false);
} }
this.iconAnimHandler = new PokemonIconAnimHandler(); this.iconAnimHandler = new PokemonIconAnimHelper();
this.iconAnimHandler.setup(); this.iconAnimHandler.setup();
this.pokemonSprite = globalScene.add.sprite(53, 63, "pkmn__sub"); this.pokemonSprite = globalScene.add.sprite(53, 63, "pkmn__sub");

View File

@ -9,7 +9,7 @@ export enum PokemonIconAnimMode {
type PokemonIcon = Phaser.GameObjects.Container | Phaser.GameObjects.Sprite; type PokemonIcon = Phaser.GameObjects.Container | Phaser.GameObjects.Sprite;
export class PokemonIconAnimHandler { export class PokemonIconAnimHelper {
private icons: Map<PokemonIcon, PokemonIconAnimMode>; private icons: Map<PokemonIcon, PokemonIconAnimMode>;
private toggled: boolean; private toggled: boolean;

View File

@ -16,7 +16,7 @@ type UpdateDetailsCallbackFunction = (index: number) => void;
* - in `UiHandler.processInput`: call `processNavigationInput` to have it handle the cursor updates while calling the defined callbacks * - in `UiHandler.processInput`: call `processNavigationInput` to have it handle the cursor updates while calling the defined callbacks
* - in `UiHandler.clear`: call `reset` * - in `UiHandler.clear`: call `reset`
*/ */
export class ScrollableGridHandler { export class ScrollableGridHelper {
private readonly ROWS: number; private readonly ROWS: number;
private readonly COLUMNS: number; private readonly COLUMNS: number;
private handler: UiHandler; private handler: UiHandler;
@ -47,7 +47,7 @@ export class ScrollableGridHandler {
* @param scrollBar {@linkcode ScrollBar} * @param scrollBar {@linkcode ScrollBar}
* @returns this * @returns this
*/ */
withScrollBar(scrollBar: ScrollBar): ScrollableGridHandler { withScrollBar(scrollBar: ScrollBar): ScrollableGridHelper {
this.scrollBar = scrollBar; this.scrollBar = scrollBar;
this.scrollBar.setTotalRows(Math.ceil(this.totalElements / this.COLUMNS)); this.scrollBar.setTotalRows(Math.ceil(this.totalElements / this.COLUMNS));
return this; return this;
@ -58,7 +58,7 @@ export class ScrollableGridHandler {
* @param callback {@linkcode UpdateGridCallbackFunction} * @param callback {@linkcode UpdateGridCallbackFunction}
* @returns this * @returns this
*/ */
withUpdateGridCallBack(callback: UpdateGridCallbackFunction): ScrollableGridHandler { withUpdateGridCallBack(callback: UpdateGridCallbackFunction): ScrollableGridHelper {
this.updateGridCallback = callback; this.updateGridCallback = callback;
return this; return this;
} }
@ -68,7 +68,7 @@ export class ScrollableGridHandler {
* @param callback {@linkcode UpdateDetailsCallbackFunction} * @param callback {@linkcode UpdateDetailsCallbackFunction}
* @returns this * @returns this
*/ */
withUpdateSingleElementCallback(callback: UpdateDetailsCallbackFunction): ScrollableGridHandler { withUpdateSingleElementCallback(callback: UpdateDetailsCallbackFunction): ScrollableGridHelper {
this.updateDetailsCallback = callback; this.updateDetailsCallback = callback;
return this; return this;
} }