Setting up filteredFormIndices

This commit is contained in:
Wlowscha 2025-03-29 01:44:49 +01:00
parent 2e2f61ff5d
commit a2c4f7eaf4
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 37 additions and 4 deletions

View File

@ -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;

View File

@ -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();
};