From a2c4f7eaf4bf0ba1ca0a0115235e423900a90136 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sat, 29 Mar 2025 01:44:49 +0100 Subject: [PATCH] Setting up filteredFormIndices --- src/ui/pokedex-page-ui-handler.ts | 23 +++++++++++++++++++++-- src/ui/pokedex-ui-handler.ts | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/ui/pokedex-page-ui-handler.ts b/src/ui/pokedex-page-ui-handler.ts index ee4e8b62ffc..e26403b2ad1 100644 --- a/src/ui/pokedex-page-ui-handler.ts +++ b/src/ui/pokedex-page-ui-handler.ts @@ -257,7 +257,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { private menuDescriptions: string[]; private isFormGender: boolean; private filteredIndices: Species[] | null = null; - private filteredFormIndices: number[] | null = null; + private filteredFormIndices: (number | null)[] | null = null; + private filteredIndex: number; private availableVariants: number; private unlockedVariants: boolean[]; @@ -699,9 +700,21 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterAttributes = this.initStarterPrefs(); console.log(this.filteredIndices); + console.log(this.filteredFormIndices); console.log(this.savedStarterAttributes); console.log(this.starterAttributes); + if (this.filteredIndices) { + this.filteredIndex = this.filteredIndices.findIndex(id => id === this.species.speciesId); + } + + if (this.filteredFormIndices) { + const newForm = this.filteredFormIndices[this.filteredIndex]; + if (!isNullOrUndefined(newForm)) { + this.starterAttributes.form = newForm; + } + } + this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => Number.parseInt(MenuOptions[m]) as MenuOptions); this.menuContainer.setVisible(true); @@ -984,7 +997,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const caughtAttr = this.isCaught(); // no preferences or Pokemon wasn't caught, return empty attribute - if (!starterAttributes || !caughtAttr) { + if (!starterAttributes || !this.isSeen()) { return {}; } @@ -1681,11 +1694,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.savedStarterAttributes.form = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); + if (this.filteredFormIndices) { + this.filteredFormIndices[this.filteredIndex] = null; + } ui.setMode( Mode.POKEDEX_PAGE, newSpecies, this.savedStarterAttributes, this.filteredIndices, + this.filteredFormIndices, ); return true; }, @@ -2062,6 +2079,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { newSpecies, this.savedStarterAttributes, this.filteredIndices, + this.filteredFormIndices, ); }); this.blockInput = false; @@ -2096,6 +2114,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { newSpecies, this.savedStarterAttributes, this.filteredIndices, + this.filteredFormIndices, ); }); break; diff --git a/src/ui/pokedex-ui-handler.ts b/src/ui/pokedex-ui-handler.ts index 8f2e6ec4545..f91967a1bb0 100644 --- a/src/ui/pokedex-ui-handler.ts +++ b/src/ui/pokedex-ui-handler.ts @@ -220,6 +220,7 @@ export default class PokedexUiHandler extends MessageUiHandler { private showFormTrayLabel: Phaser.GameObjects.Text; private canShowFormTray: boolean; private filteredIndices: Species[]; + private filteredFormIndices: Species[]; constructor() { super(Mode.POKEDEX); @@ -1029,7 +1030,13 @@ export default class PokedexUiHandler extends MessageUiHandler { } else if (this.showingTray) { if (button === Button.ACTION) { const formIndex = this.trayForms[this.trayCursor].formIndex; - ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, { form: formIndex }, this.filteredIndices); + ui.setOverlayMode( + Mode.POKEDEX_PAGE, + this.lastSpecies, + { form: formIndex }, + this.filteredIndices, + this.filteredFormIndices, + ); success = true; } else { const numberOfForms = this.trayContainers.length; @@ -1079,7 +1086,13 @@ export default class PokedexUiHandler extends MessageUiHandler { } else { if (button === Button.ACTION) { const formIndex = this.pokemonContainers[this.cursor]?.formIndex; - ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, { form: formIndex }, this.filteredIndices); + ui.setOverlayMode( + Mode.POKEDEX_PAGE, + this.lastSpecies, + { form: formIndex }, + this.filteredIndices, + this.filteredFormIndices, + ); success = true; } else { switch (button) { @@ -1589,6 +1602,7 @@ export default class PokedexUiHandler extends MessageUiHandler { }); this.filteredIndices = this.filteredPokemonData.map(c => c.species.speciesId); + this.filteredFormIndices = this.filteredPokemonData.map(c => c.formIndex); this.updateScroll(); };