mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 22:12:16 +02:00
[UI/UX] Pokedex - Page turning takes filters into account (#5372)
* Introducing list of indices of filtered mons to be passed to the Pokédex Page for scrolling * Update pokedex-page-ui-handler.ts
This commit is contained in:
parent
6857cd459c
commit
4128d09a1d
@ -16,7 +16,7 @@ import { pokemonFormChanges } from "#app/data/pokemon-forms";
|
|||||||
import type { LevelMoves } from "#app/data/balance/pokemon-level-moves";
|
import type { LevelMoves } from "#app/data/balance/pokemon-level-moves";
|
||||||
import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
|
import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves";
|
||||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
import { allSpecies, getPokemonSpeciesForm, normalForm } from "#app/data/pokemon-species";
|
import { allSpecies, getPokemonSpecies, getPokemonSpeciesForm, normalForm } from "#app/data/pokemon-species";
|
||||||
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
|
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
|
||||||
import { starterPassiveAbilities } from "#app/data/balance/passives";
|
import { starterPassiveAbilities } from "#app/data/balance/passives";
|
||||||
import { Type } from "#enums/type";
|
import { Type } from "#enums/type";
|
||||||
@ -244,6 +244,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
private menuOptions: MenuOptions[];
|
private menuOptions: MenuOptions[];
|
||||||
protected scale: number = 0.1666666667;
|
protected scale: number = 0.1666666667;
|
||||||
private menuDescriptions: string[];
|
private menuDescriptions: string[];
|
||||||
|
private filteredIndices: Species[] | null = null;
|
||||||
|
|
||||||
private availableVariants: number;
|
private availableVariants: number;
|
||||||
private unlockedVariants: boolean[];
|
private unlockedVariants: boolean[];
|
||||||
@ -560,6 +561,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.species = args[0];
|
this.species = args[0];
|
||||||
this.formIndex = args[1] ?? 0;
|
this.formIndex = args[1] ?? 0;
|
||||||
this.savedStarterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 };
|
this.savedStarterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 };
|
||||||
|
this.filteredIndices = args[3] ?? null;
|
||||||
this.starterSetup();
|
this.starterSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1447,7 +1449,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.savedStarterAttributes.form = newFormIndex;
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes, this.filteredIndices);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onHover: () => this.showText(conditionText)
|
onHover: () => this.showText(conditionText)
|
||||||
@ -1752,31 +1754,45 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
this.blockInput = true;
|
this.blockInput = true;
|
||||||
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
const index = allSpecies.findIndex(species => species.speciesId === this.species.speciesId);
|
let newSpecies: PokemonSpecies;
|
||||||
const newIndex = index <= 0 ? allSpecies.length - 1 : index - 1;
|
if (this.filteredIndices) {
|
||||||
const newSpecies = allSpecies[newIndex];
|
const index = this.filteredIndices.findIndex(id => id === this.species.speciesId);
|
||||||
|
const newIndex = index <= 0 ? this.filteredIndices.length - 1 : index - 1;
|
||||||
|
newSpecies = getPokemonSpecies(this.filteredIndices[newIndex]);
|
||||||
|
} else {
|
||||||
|
const index = allSpecies.findIndex(species => species.speciesId === this.species.speciesId);
|
||||||
|
const newIndex = index <= 0 ? allSpecies.length - 1 : index - 1;
|
||||||
|
newSpecies = allSpecies[newIndex];
|
||||||
|
}
|
||||||
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey);
|
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey);
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
this.savedStarterAttributes.form = newFormIndex;
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes, this.filteredIndices);
|
||||||
});
|
});
|
||||||
this.blockInput = false;
|
this.blockInput = false;
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
const index = allSpecies.findIndex(species => species.speciesId === this.species.speciesId);
|
let newSpecies: PokemonSpecies;
|
||||||
const newIndex = index >= allSpecies.length - 1 ? 0 : index + 1;
|
if (this.filteredIndices) {
|
||||||
const newSpecies = allSpecies[newIndex];
|
const index = this.filteredIndices.findIndex(id => id === this.species.speciesId);
|
||||||
|
const newIndex = index >= this.filteredIndices.length - 1 ? 0 : index + 1;
|
||||||
|
newSpecies = getPokemonSpecies(this.filteredIndices[newIndex]);
|
||||||
|
} else {
|
||||||
|
const index = allSpecies.findIndex(species => species.speciesId === this.species.speciesId);
|
||||||
|
const newIndex = index >= allSpecies.length - 1 ? 0 : index + 1;
|
||||||
|
newSpecies = allSpecies[newIndex];
|
||||||
|
}
|
||||||
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey);
|
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey);
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
this.savedStarterAttributes.form = newFormIndex;
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes, this.filteredIndices);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
private showFormTrayIconElement: Phaser.GameObjects.Sprite;
|
private showFormTrayIconElement: Phaser.GameObjects.Sprite;
|
||||||
private showFormTrayLabel: Phaser.GameObjects.Text;
|
private showFormTrayLabel: Phaser.GameObjects.Text;
|
||||||
private canShowFormTray: boolean;
|
private canShowFormTray: boolean;
|
||||||
|
private filteredIndices: Species[];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(Mode.POKEDEX);
|
super(Mode.POKEDEX);
|
||||||
@ -1037,7 +1038,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
} else if (this.showingTray) {
|
} else if (this.showingTray) {
|
||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
const formIndex = this.trayForms[this.trayCursor].formIndex;
|
const formIndex = this.trayForms[this.trayCursor].formIndex;
|
||||||
ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, formIndex, { form: formIndex });
|
ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, formIndex, { form: formIndex }, this.filteredIndices);
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
const numberOfForms = this.trayContainers.length;
|
const numberOfForms = this.trayContainers.length;
|
||||||
@ -1084,7 +1085,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, 0);
|
ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, 0, null, this.filteredIndices);
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
@ -1551,6 +1552,8 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.filteredIndices = this.filteredPokemonContainers.map(c => c.species.speciesId);
|
||||||
|
|
||||||
this.updateScroll();
|
this.updateScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user