From 53f2625168824e4aa1a5a5ee6d93d6ab980d336e Mon Sep 17 00:00:00 2001 From: MokaStitcher Date: Mon, 23 Sep 2024 18:54:59 +0200 Subject: [PATCH] cleanup and doc --- src/ui/egg-list-ui-handler.ts | 10 ++++++++++ src/ui/egg-summary-ui-handler.ts | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ui/egg-list-ui-handler.ts b/src/ui/egg-list-ui-handler.ts index e1885f027f2..0ebc0f8140e 100644 --- a/src/ui/egg-list-ui-handler.ts +++ b/src/ui/egg-list-ui-handler.ts @@ -120,6 +120,9 @@ export default class EggListUiHandler extends MessageUiHandler { return true; } + /** + * Create the grid of egg icons to display + */ private initEggIcons() { this.eggIcons = []; for (let i = 0; i < Math.min(this.ROWS * this.COLUMNS, this.scene.gameData.eggs.length); i++) { @@ -133,6 +136,9 @@ export default class EggListUiHandler extends MessageUiHandler { } } + /** + * Show the grid of egg icons + */ private updateEggIcons() { const indexOffset = this.scrollGridHandler.getItemOffset(); const eggsToShow = Math.min(this.eggIcons.length, this.scene.gameData.eggs.length - indexOffset); @@ -151,6 +157,10 @@ export default class EggListUiHandler extends MessageUiHandler { }); } + /** + * Update the information panel with the information of the given egg + * @param index which egg in the list to display the info for + */ private setEggDetails(index: number): void { const egg = this.scene.gameData.eggs[index]; this.eggSprite.setFrame(`egg_${egg.getKey()}`); diff --git a/src/ui/egg-summary-ui-handler.ts b/src/ui/egg-summary-ui-handler.ts index 9f4e9d6b026..f4c3e056360 100644 --- a/src/ui/egg-summary-ui-handler.ts +++ b/src/ui/egg-summary-ui-handler.ts @@ -3,7 +3,7 @@ import { Mode } from "./ui"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler"; import MessageUiHandler from "./message-ui-handler"; import { getEggTierForSpecies } from "../data/egg"; -import {Button} from "#enums/buttons"; +import { Button } from "#enums/buttons"; import PokemonHatchInfoContainer from "./pokemon-hatch-info-container"; import { EggSummaryPhase } from "#app/phases/egg-summary-phase"; import { EggHatchData } from "#app/data/egg-hatch-data"; @@ -29,6 +29,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler { private summaryContainer: Phaser.GameObjects.Container; /** container for the each pokemon sprites and icons */ private pokemonIconsContainer: Phaser.GameObjects.Container; + /** list of the containers added to pokemonIconsContainer for easier access */ private pokemonContainers: HatchedPokemonContainer[]; /** hatch info container that displays the current pokemon / hatch (main element on left hand side) */ @@ -101,6 +102,8 @@ export default class EggSummaryUiHandler extends MessageUiHandler { this.cursor = -1; this.scrollGridHandler.reset(); this.summaryContainer.setVisible(false); + this.pokemonIconsContainer.removeAll(true); + this.pokemonContainers = []; this.eggHatchBg.setVisible(false); this.getUi().hideTooltip(); @@ -167,7 +170,10 @@ export default class EggSummaryUiHandler extends MessageUiHandler { return true; } - updatePokemonIcons(): void { + /** + * Show the grid of Pokemon icons + */ + private updatePokemonIcons(): void { const itemOffset = this.scrollGridHandler.getItemOffset(); const eggsToShow = Math.min(numRows * numCols, this.eggHatchData.length - itemOffset);