mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 14:02:18 +02:00
[UI/UX] Reducing number of containers in the Pokédex (#5400)
* PokedexMonContainer now has a method to change species. * Not setting tint to 0 in the container * Using only 81 containers in Pokédex * Apply suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
d11f02aa3d
commit
8cc5f650f3
@ -36,26 +36,7 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container {
|
|||||||
constructor(species: PokemonSpecies, options: SpeciesDetails = {}) {
|
constructor(species: PokemonSpecies, options: SpeciesDetails = {}) {
|
||||||
super(globalScene, 0, 0);
|
super(globalScene, 0, 0);
|
||||||
|
|
||||||
this.species = species;
|
this.setSpecies(species, options);
|
||||||
|
|
||||||
const { shiny, formIndex, female, variant } = options;
|
|
||||||
|
|
||||||
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, false, true);
|
|
||||||
const defaultProps = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
|
||||||
|
|
||||||
if (!isNullOrUndefined(formIndex)) {
|
|
||||||
defaultProps.formIndex = formIndex;
|
|
||||||
}
|
|
||||||
if (!isNullOrUndefined(shiny)) {
|
|
||||||
defaultProps.shiny = shiny;
|
|
||||||
}
|
|
||||||
if (!isNullOrUndefined(variant)) {
|
|
||||||
defaultProps.variant = variant;
|
|
||||||
}
|
|
||||||
if (!isNullOrUndefined(female)) {
|
|
||||||
defaultProps.female = female;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// starter passive bg
|
// starter passive bg
|
||||||
const starterPassiveBg = globalScene.add.image(2, 5, "passive_bg");
|
const starterPassiveBg = globalScene.add.image(2, 5, "passive_bg");
|
||||||
@ -65,15 +46,6 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container {
|
|||||||
this.add(starterPassiveBg);
|
this.add(starterPassiveBg);
|
||||||
this.starterPassiveBgs = starterPassiveBg;
|
this.starterPassiveBgs = starterPassiveBg;
|
||||||
|
|
||||||
// icon
|
|
||||||
this.icon = globalScene.add.sprite(-2, 2, species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant));
|
|
||||||
this.icon.setScale(0.5);
|
|
||||||
this.icon.setOrigin(0, 0);
|
|
||||||
this.icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant));
|
|
||||||
this.checkIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant);
|
|
||||||
this.icon.setTint(0);
|
|
||||||
this.add(this.icon);
|
|
||||||
|
|
||||||
// shiny icons
|
// shiny icons
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
const shinyIcon = globalScene.add.image(i * -3 + 12, 2, "shiny_star_small");
|
const shinyIcon = globalScene.add.image(i * -3 + 12, 2, "shiny_star_small");
|
||||||
@ -196,6 +168,42 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container {
|
|||||||
this.passive2OverlayIcon = passive2OverlayIcon;
|
this.passive2OverlayIcon = passive2OverlayIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSpecies(species: PokemonSpecies, options: SpeciesDetails = {}) {
|
||||||
|
|
||||||
|
this.species = species;
|
||||||
|
|
||||||
|
const { shiny, formIndex, female, variant } = options;
|
||||||
|
|
||||||
|
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, false, true);
|
||||||
|
const defaultProps = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
||||||
|
|
||||||
|
if (!isNullOrUndefined(formIndex)) {
|
||||||
|
defaultProps.formIndex = formIndex;
|
||||||
|
}
|
||||||
|
if (!isNullOrUndefined(shiny)) {
|
||||||
|
defaultProps.shiny = shiny;
|
||||||
|
}
|
||||||
|
if (!isNullOrUndefined(variant)) {
|
||||||
|
defaultProps.variant = variant;
|
||||||
|
}
|
||||||
|
if (!isNullOrUndefined(female)) {
|
||||||
|
defaultProps.female = female;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.icon) {
|
||||||
|
this.remove(this.icon);
|
||||||
|
this.icon.destroy(); // Properly removes the sprite from memory
|
||||||
|
}
|
||||||
|
|
||||||
|
// icon
|
||||||
|
this.icon = globalScene.add.sprite(-2, 2, species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant));
|
||||||
|
this.icon.setScale(0.5);
|
||||||
|
this.icon.setOrigin(0, 0);
|
||||||
|
this.icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant));
|
||||||
|
this.checkIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant);
|
||||||
|
this.add(this.icon);
|
||||||
|
}
|
||||||
|
|
||||||
checkIconId(female, formIndex, shiny, variant) {
|
checkIconId(female, formIndex, shiny, variant) {
|
||||||
if (this.icon.frame.name !== this.species.getIconId(female, formIndex, shiny, variant)) {
|
if (this.icon.frame.name !== this.species.getIconId(female, formIndex, shiny, variant)) {
|
||||||
console.log(`${this.species.name}'s variant icon does not exist. Replacing with default.`);
|
console.log(`${this.species.name}'s variant icon does not exist. Replacing with default.`);
|
||||||
|
@ -109,6 +109,17 @@ enum FilterTextOptions{
|
|||||||
ABILITY_2,
|
ABILITY_2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ContainerData {
|
||||||
|
species: PokemonSpecies,
|
||||||
|
cost: number,
|
||||||
|
props: DexAttrProps,
|
||||||
|
eggMove1?: boolean,
|
||||||
|
eggMove2?: boolean,
|
||||||
|
tmMove1?: boolean,
|
||||||
|
tmMove2?: boolean,
|
||||||
|
passive1?: boolean,
|
||||||
|
passive2?: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
const valueReductionMax = 2;
|
const valueReductionMax = 2;
|
||||||
|
|
||||||
@ -121,11 +132,11 @@ const speciesContainerX = 143;
|
|||||||
* @param index UI index to calculate the starter position of
|
* @param index UI index to calculate the starter position of
|
||||||
* @returns An interface with an x and y property
|
* @returns An interface with an x and y property
|
||||||
*/
|
*/
|
||||||
function calcStarterPosition(index: number, scrollCursor:number = 0): {x: number, y: number} {
|
function calcStarterPosition(index: number): {x: number, y: number} {
|
||||||
const yOffset = 13;
|
const yOffset = 13;
|
||||||
const height = 17;
|
const height = 17;
|
||||||
const x = (index % 9) * 18;
|
const x = (index % 9) * 18;
|
||||||
const y = yOffset + (Math.floor(index / 9) - scrollCursor) * height;
|
const y = yOffset + (Math.floor(index / 9)) * height;
|
||||||
|
|
||||||
return { x: x, y: y };
|
return { x: x, y: y };
|
||||||
}
|
}
|
||||||
@ -145,8 +156,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
private filterBarContainer: Phaser.GameObjects.Container;
|
private filterBarContainer: Phaser.GameObjects.Container;
|
||||||
private filterBar: FilterBar;
|
private filterBar: FilterBar;
|
||||||
private pokemonContainers: PokedexMonContainer[] = [];
|
private pokemonContainers: PokedexMonContainer[] = [];
|
||||||
private filteredPokemonContainers: PokedexMonContainer[] = [];
|
private filteredPokemonData: ContainerData[] = [];
|
||||||
private validPokemonContainers: PokedexMonContainer[] = [];
|
|
||||||
private pokemonNumberText: Phaser.GameObjects.Text;
|
private pokemonNumberText: Phaser.GameObjects.Text;
|
||||||
private pokemonSprite: Phaser.GameObjects.Sprite;
|
private pokemonSprite: Phaser.GameObjects.Sprite;
|
||||||
private pokemonNameText: Phaser.GameObjects.Text;
|
private pokemonNameText: Phaser.GameObjects.Text;
|
||||||
@ -160,6 +170,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
private filterMode: boolean;
|
private filterMode: boolean;
|
||||||
private filterBarCursor: number = 0;
|
private filterBarCursor: number = 0;
|
||||||
private scrollCursor: number;
|
private scrollCursor: number;
|
||||||
|
private oldCursor: number = -1;
|
||||||
|
|
||||||
private allSpecies: PokemonSpecies[] = [];
|
private allSpecies: PokemonSpecies[] = [];
|
||||||
private lastSpecies: PokemonSpecies;
|
private lastSpecies: PokemonSpecies;
|
||||||
@ -447,8 +458,13 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
for (const species of allSpecies) {
|
for (const species of allSpecies) {
|
||||||
this.speciesLoaded.set(species.speciesId, false);
|
this.speciesLoaded.set(species.speciesId, false);
|
||||||
this.allSpecies.push(species);
|
this.allSpecies.push(species);
|
||||||
|
}
|
||||||
|
|
||||||
const pokemonContainer = new PokedexMonContainer(species).setVisible(false);
|
// Here code to declare 81 containers
|
||||||
|
for (let i = 0; i < 81; i++) {
|
||||||
|
const pokemonContainer = new PokedexMonContainer(this.allSpecies[i]).setVisible(false);
|
||||||
|
const pos = calcStarterPosition(i);
|
||||||
|
pokemonContainer.setPosition(pos.x, pos.y);
|
||||||
this.iconAnimHandler.addOrUpdate(pokemonContainer.icon, PokemonIconAnimMode.NONE);
|
this.iconAnimHandler.addOrUpdate(pokemonContainer.icon, PokemonIconAnimMode.NONE);
|
||||||
this.pokemonContainers.push(pokemonContainer);
|
this.pokemonContainers.push(pokemonContainer);
|
||||||
starterBoxContainer.add(pokemonContainer);
|
starterBoxContainer.add(pokemonContainer);
|
||||||
@ -563,19 +579,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
this.getUi().bringToTop(this.starterSelectContainer);
|
this.getUi().bringToTop(this.starterSelectContainer);
|
||||||
|
|
||||||
// Making caught pokemon visible icons, etc
|
this.pokemonContainers.forEach(container => {
|
||||||
this.allSpecies.forEach((species, s) => {
|
const icon = container.icon;
|
||||||
const icon = this.pokemonContainers[s].icon;
|
const species = container.species;
|
||||||
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
|
||||||
|
|
||||||
this.starterPreferences[species.speciesId] = this.initStarterPrefs(species);
|
this.starterPreferences[species.speciesId] = this.initStarterPrefs(species);
|
||||||
|
|
||||||
if ((dexEntry.caughtAttr & species.getFullUnlocksData()) || globalScene.dexForDevs) {
|
|
||||||
icon.clearTint();
|
|
||||||
} else if (dexEntry.seenAttr) {
|
|
||||||
icon.setTint(0x808080);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setUpgradeAnimation(icon, species);
|
this.setUpgradeAnimation(icon, species);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -872,12 +881,11 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const maxColumns = 9;
|
const maxColumns = 9;
|
||||||
const numberOfStarters = this.filteredPokemonContainers.length;
|
const numberOfStarters = this.filteredPokemonData.length;
|
||||||
const numOfRows = Math.ceil(numberOfStarters / maxColumns);
|
const numOfRows = Math.ceil(numberOfStarters / maxColumns);
|
||||||
const currentRow = Math.floor(this.cursor / maxColumns);
|
|
||||||
const onScreenFirstIndex = this.scrollCursor * maxColumns; // this is first index on the screen
|
const onScreenFirstIndex = this.scrollCursor * maxColumns; // this is first index on the screen
|
||||||
|
// TODO: check if in some places we need to use one or the other
|
||||||
// TODO: use the above to let the cursor go to the correct position when switching back.
|
const currentRow = Math.floor((onScreenFirstIndex + this.cursor) / maxColumns);
|
||||||
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
@ -966,9 +974,9 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
const proportion = this.filterBarCursor / Math.max(1, this.filterBar.numFilters - 1);
|
const proportion = this.filterBarCursor / Math.max(1, this.filterBar.numFilters - 1);
|
||||||
const targetCol = Math.min(8, proportion < 0.5 ? Math.floor(proportion * 8) : Math.ceil(proportion * 8));
|
const targetCol = Math.min(8, proportion < 0.5 ? Math.floor(proportion * 8) : Math.ceil(proportion * 8));
|
||||||
if (numberOfStarters % 9 > targetCol) {
|
if (numberOfStarters % 9 > targetCol) {
|
||||||
this.setCursor(numberOfStarters - (numberOfStarters) % 9 + targetCol);
|
this.setCursor(numberOfStarters - (numberOfStarters) % 9 + targetCol - this.scrollCursor * 9);
|
||||||
} else {
|
} else {
|
||||||
this.setCursor(Math.max(numberOfStarters - (numberOfStarters) % 9 + targetCol - 9, 0));
|
this.setCursor(Math.max(numberOfStarters - (numberOfStarters) % 9 + targetCol - 9 - this.scrollCursor * 9, 0));
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -1003,7 +1011,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
if (numberOfStarters > 0) {
|
if (numberOfStarters > 0) {
|
||||||
this.setFilterTextMode(false);
|
this.setFilterTextMode(false);
|
||||||
const rowIndex = this.filterTextCursor;
|
const rowIndex = this.filterTextCursor;
|
||||||
this.setCursor(onScreenFirstIndex + (rowIndex < numOfRows - 1 ? (rowIndex + 1) * maxColumns - 1 : numberOfStarters - 1));
|
this.setCursor(rowIndex < numOfRows - 1 ? (rowIndex + 1) * maxColumns - 1 : numberOfStarters - 1);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1012,7 +1020,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
if (numberOfStarters > 0) {
|
if (numberOfStarters > 0) {
|
||||||
this.setFilterTextMode(false);
|
this.setFilterTextMode(false);
|
||||||
const rowIndex = this.filterTextCursor;
|
const rowIndex = this.filterTextCursor;
|
||||||
this.setCursor(onScreenFirstIndex + (rowIndex < numOfRows ? rowIndex * maxColumns : (numOfRows - 1) * maxColumns));
|
this.setCursor(rowIndex < numOfRows ? rowIndex * maxColumns : (numOfRows - 1) * maxColumns);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1043,10 +1051,10 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
} else {
|
} else {
|
||||||
const numberOfForms = this.trayContainers.length;
|
const numberOfForms = this.trayContainers.length;
|
||||||
const numOfRows = Math.ceil(numberOfForms / maxColumns);
|
const numOfRows = Math.ceil(numberOfForms / maxColumns);
|
||||||
const currentRow = Math.floor(this.trayCursor / maxColumns);
|
const currentTrayRow = Math.floor(this.trayCursor / maxColumns);
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
if (currentRow > 0) {
|
if (currentTrayRow > 0) {
|
||||||
success = this.setTrayCursor(this.trayCursor - 9);
|
success = this.setTrayCursor(this.trayCursor - 9);
|
||||||
} else {
|
} else {
|
||||||
const targetCol = this.trayCursor;
|
const targetCol = this.trayCursor;
|
||||||
@ -1058,7 +1066,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
if (currentRow < numOfRows - 1) {
|
if (currentTrayRow < numOfRows - 1) {
|
||||||
success = this.setTrayCursor(this.trayCursor + 9);
|
success = this.setTrayCursor(this.trayCursor + 9);
|
||||||
} else {
|
} else {
|
||||||
success = this.setTrayCursor(this.trayCursor % 9);
|
success = this.setTrayCursor(this.trayCursor % 9);
|
||||||
@ -1068,14 +1076,14 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
if (this.trayCursor % 9 !== 0) {
|
if (this.trayCursor % 9 !== 0) {
|
||||||
success = this.setTrayCursor(this.trayCursor - 1);
|
success = this.setTrayCursor(this.trayCursor - 1);
|
||||||
} else {
|
} else {
|
||||||
success = this.setTrayCursor(currentRow < numOfRows - 1 ? (currentRow + 1) * maxColumns - 1 : numberOfForms - 1);
|
success = this.setTrayCursor(currentTrayRow < numOfRows - 1 ? (currentTrayRow + 1) * maxColumns - 1 : numberOfForms - 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
if (this.trayCursor % 9 < (currentRow < numOfRows - 1 ? 8 : (numberOfForms - 1) % 9)) {
|
if (this.trayCursor % 9 < (currentTrayRow < numOfRows - 1 ? 8 : (numberOfForms - 1) % 9)) {
|
||||||
success = this.setTrayCursor(this.trayCursor + 1);
|
success = this.setTrayCursor(this.trayCursor + 1);
|
||||||
} else {
|
} else {
|
||||||
success = this.setTrayCursor(currentRow * 9);
|
success = this.setTrayCursor(currentTrayRow * 9);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.CYCLE_FORM:
|
case Button.CYCLE_FORM:
|
||||||
@ -1094,10 +1102,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
if (this.scrollCursor > 0 && currentRow - this.scrollCursor === 0) {
|
if (this.scrollCursor > 0 && currentRow - this.scrollCursor === 0) {
|
||||||
this.scrollCursor--;
|
this.scrollCursor--;
|
||||||
this.updateScroll();
|
this.updateScroll();
|
||||||
|
success = this.setCursor(this.cursor);
|
||||||
|
} else {
|
||||||
|
success = this.setCursor(this.cursor - 9);
|
||||||
}
|
}
|
||||||
success = this.setCursor(this.cursor - 9);
|
|
||||||
} else {
|
} else {
|
||||||
this.filterBarCursor = this.filterBar.getNearestFilter(this.filteredPokemonContainers[this.cursor]);
|
this.filterBarCursor = this.filterBar.getNearestFilter(this.pokemonContainers[this.cursor]);
|
||||||
this.setFilterMode(true);
|
this.setFilterMode(true);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -1106,9 +1116,11 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
if (currentRow < numOfRows - 1) { // not last row
|
if (currentRow < numOfRows - 1) { // not last row
|
||||||
if (currentRow - this.scrollCursor === 8) { // last row of visible pokemon
|
if (currentRow - this.scrollCursor === 8) { // last row of visible pokemon
|
||||||
this.scrollCursor++;
|
this.scrollCursor++;
|
||||||
|
this.updateScroll();
|
||||||
|
success = this.setCursor(this.cursor);
|
||||||
|
} else {
|
||||||
|
success = this.setCursor(this.cursor + 9);
|
||||||
}
|
}
|
||||||
success = this.setCursor(this.cursor + 9);
|
|
||||||
this.updateScroll();
|
|
||||||
} else if (numOfRows > 1) {
|
} else if (numOfRows > 1) {
|
||||||
// DOWN from last row of pokemon > Wrap around to first row
|
// DOWN from last row of pokemon > Wrap around to first row
|
||||||
this.scrollCursor = 0;
|
this.scrollCursor = 0;
|
||||||
@ -1116,7 +1128,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
success = this.setCursor(this.cursor % 9);
|
success = this.setCursor(this.cursor % 9);
|
||||||
} else {
|
} else {
|
||||||
// DOWN from single row of pokemon > Go to filters
|
// DOWN from single row of pokemon > Go to filters
|
||||||
this.filterBarCursor = this.filterBar.getNearestFilter(this.filteredPokemonContainers[this.cursor]);
|
this.filterBarCursor = this.filterBar.getNearestFilter(this.pokemonContainers[this.cursor]);
|
||||||
this.setFilterMode(true);
|
this.setFilterMode(true);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -1126,7 +1138,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
} else {
|
} else {
|
||||||
// LEFT from filtered pokemon, on the left edge
|
// LEFT from filtered pokemon, on the left edge
|
||||||
this.filterTextCursor = this.filterText.getNearestFilter(this.filteredPokemonContainers[this.cursor]);
|
this.filterTextCursor = this.filterText.getNearestFilter(this.pokemonContainers[this.cursor]);
|
||||||
this.setFilterTextMode(true);
|
this.setFilterTextMode(true);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -1137,13 +1149,13 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
} else {
|
} else {
|
||||||
// RIGHT from filtered pokemon, on the right edge
|
// RIGHT from filtered pokemon, on the right edge
|
||||||
this.filterTextCursor = this.filterText.getNearestFilter(this.filteredPokemonContainers[this.cursor]);
|
this.filterTextCursor = this.filterText.getNearestFilter(this.pokemonContainers[this.cursor]);
|
||||||
this.setFilterTextMode(true);
|
this.setFilterTextMode(true);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.CYCLE_FORM:
|
case Button.CYCLE_FORM:
|
||||||
const species = this.filteredPokemonContainers[this.cursor].species;
|
const species = this.pokemonContainers[this.cursor].species;
|
||||||
if (this.canShowFormTray) {
|
if (this.canShowFormTray) {
|
||||||
success = this.openFormTray(species);
|
success = this.openFormTray(species);
|
||||||
}
|
}
|
||||||
@ -1225,60 +1237,48 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
updateStarters = () => {
|
updateStarters = () => {
|
||||||
this.scrollCursor = 0;
|
this.scrollCursor = 0;
|
||||||
this.filteredPokemonContainers = [];
|
this.filteredPokemonData = [];
|
||||||
this.validPokemonContainers = [];
|
|
||||||
|
|
||||||
this.pokerusCursorObjs.forEach(cursor => cursor.setVisible(false));
|
this.pokerusCursorObjs.forEach(cursor => cursor.setVisible(false));
|
||||||
|
|
||||||
this.filterBar.updateFilterLabels();
|
this.filterBar.updateFilterLabels();
|
||||||
this.filterText.updateFilterLabels();
|
this.filterText.updateFilterLabels();
|
||||||
|
|
||||||
this.validPokemonContainers = this.pokemonContainers;
|
this.filteredPokemonData = [];
|
||||||
|
|
||||||
// this updates icons for previously saved pokemon
|
this.allSpecies.forEach(species => {
|
||||||
for (let i = 0; i < this.validPokemonContainers.length; i++) {
|
|
||||||
const currentFilteredContainer = this.validPokemonContainers[i];
|
|
||||||
const starterSprite = currentFilteredContainer.icon as Phaser.GameObjects.Sprite;
|
|
||||||
|
|
||||||
const currentDexAttr = this.getCurrentDexProps(currentFilteredContainer.species.speciesId);
|
const starterId = this.getStarterSpeciesId(species.speciesId);
|
||||||
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(currentFilteredContainer.species, currentDexAttr));
|
|
||||||
|
|
||||||
starterSprite.setTexture(currentFilteredContainer.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), currentFilteredContainer.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant));
|
const currentDexAttr = this.getCurrentDexProps(species.speciesId);
|
||||||
currentFilteredContainer.checkIconId(props.female, props.formIndex, props.shiny, props.variant);
|
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(species, currentDexAttr));
|
||||||
}
|
|
||||||
|
|
||||||
// filter
|
const data: ContainerData = { species: species, cost: globalScene.gameData.getSpeciesStarterValue(starterId), props: props };
|
||||||
this.validPokemonContainers.forEach(container => {
|
|
||||||
container.setVisible(false);
|
|
||||||
|
|
||||||
const starterId = this.getStarterSpeciesId(container.species.speciesId);
|
|
||||||
|
|
||||||
container.cost = globalScene.gameData.getSpeciesStarterValue(starterId);
|
|
||||||
|
|
||||||
// First, ensure you have the caught attributes for the species else default to bigint 0
|
// First, ensure you have the caught attributes for the species else default to bigint 0
|
||||||
// TODO: This might be removed depending on how accessible we want the pokedex function to be
|
// TODO: This might be removed depending on how accessible we want the pokedex function to be
|
||||||
const caughtAttr = (globalScene.gameData.dexData[container.species.speciesId]?.caughtAttr || BigInt(0)) &
|
const caughtAttr = (globalScene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0)) &
|
||||||
(globalScene.gameData.dexData[this.getStarterSpeciesId(container.species.speciesId)]?.caughtAttr || BigInt(0)) &
|
(globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)]?.caughtAttr || BigInt(0)) &
|
||||||
container.species.getFullUnlocksData();
|
species.getFullUnlocksData();
|
||||||
const starterData = globalScene.gameData.starterData[starterId];
|
const starterData = globalScene.gameData.starterData[starterId];
|
||||||
const isStarterProgressable = speciesEggMoves.hasOwnProperty(starterId);
|
const isStarterProgressable = speciesEggMoves.hasOwnProperty(starterId);
|
||||||
|
|
||||||
// Name filter
|
// Name filter
|
||||||
const selectedName = this.filterText.getValue(FilterTextRow.NAME);
|
const selectedName = this.filterText.getValue(FilterTextRow.NAME);
|
||||||
const fitsName = container.species.name === selectedName || selectedName === this.filterText.defaultText;
|
const fitsName = species.name === selectedName || selectedName === this.filterText.defaultText;
|
||||||
|
|
||||||
// Move filter
|
// Move filter
|
||||||
// TODO: There can be fringe cases where the two moves belong to mutually exclusive forms, these must be handled separately (Pikachu);
|
// TODO: There can be fringe cases where the two moves belong to mutually exclusive forms, these must be handled separately (Pikachu);
|
||||||
// On the other hand, in some cases it is possible to switch between different forms and combine (Deoxys)
|
// On the other hand, in some cases it is possible to switch between different forms and combine (Deoxys)
|
||||||
const levelMoves = pokemonSpeciesLevelMoves[container.species.speciesId].map(m => allMoves[m[1]].name);
|
const levelMoves = pokemonSpeciesLevelMoves[species.speciesId].map(m => allMoves[m[1]].name);
|
||||||
// This always gets egg moves from the starter
|
// This always gets egg moves from the starter
|
||||||
const eggMoves = speciesEggMoves[starterId]?.map(m => allMoves[m].name) ?? [];
|
const eggMoves = speciesEggMoves[starterId]?.map(m => allMoves[m].name) ?? [];
|
||||||
const tmMoves = speciesTmMoves[starterId]?.map(m => allMoves[Array.isArray(m) ? m[1] : m].name) ?? [];
|
const tmMoves = speciesTmMoves[starterId]?.map(m => allMoves[Array.isArray(m) ? m[1] : m].name) ?? [];
|
||||||
const selectedMove1 = this.filterText.getValue(FilterTextRow.MOVE_1);
|
const selectedMove1 = this.filterText.getValue(FilterTextRow.MOVE_1);
|
||||||
const selectedMove2 = this.filterText.getValue(FilterTextRow.MOVE_2);
|
const selectedMove2 = this.filterText.getValue(FilterTextRow.MOVE_2);
|
||||||
|
|
||||||
const fitsFormMove1 = container.species.forms.some(form => this.hasFormLevelMove(form, selectedMove1));
|
const fitsFormMove1 = species.forms.some(form => this.hasFormLevelMove(form, selectedMove1));
|
||||||
const fitsFormMove2 = container.species.forms.some(form => this.hasFormLevelMove(form, selectedMove2));
|
const fitsFormMove2 = species.forms.some(form => this.hasFormLevelMove(form, selectedMove2));
|
||||||
const fitsLevelMove1 = levelMoves.includes(selectedMove1) || fitsFormMove1;
|
const fitsLevelMove1 = levelMoves.includes(selectedMove1) || fitsFormMove1;
|
||||||
const fitsEggMove1 = eggMoves.includes(selectedMove1);
|
const fitsEggMove1 = eggMoves.includes(selectedMove1);
|
||||||
const fitsTmMove1 = tmMoves.includes(selectedMove1);
|
const fitsTmMove1 = tmMoves.includes(selectedMove1);
|
||||||
@ -1289,44 +1289,38 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
const fitsMove2 = fitsLevelMove2 || fitsEggMove2 || fitsTmMove2 || selectedMove2 === this.filterText.defaultText;
|
const fitsMove2 = fitsLevelMove2 || fitsEggMove2 || fitsTmMove2 || selectedMove2 === this.filterText.defaultText;
|
||||||
const fitsMoves = fitsMove1 && fitsMove2;
|
const fitsMoves = fitsMove1 && fitsMove2;
|
||||||
|
|
||||||
container.eggMove1Icon.setVisible(false);
|
|
||||||
container.tmMove1Icon.setVisible(false);
|
|
||||||
container.eggMove2Icon.setVisible(false);
|
|
||||||
container.tmMove2Icon.setVisible(false);
|
|
||||||
if (fitsEggMove1 && !fitsLevelMove1) {
|
if (fitsEggMove1 && !fitsLevelMove1) {
|
||||||
container.eggMove1Icon.setVisible(true);
|
|
||||||
const em1 = eggMoves.findIndex(name => name === selectedMove1);
|
const em1 = eggMoves.findIndex(name => name === selectedMove1);
|
||||||
if ((starterData.eggMoves & (1 << em1)) === 0) {
|
if ((starterData.eggMoves & (1 << em1)) === 0) {
|
||||||
container.eggMove1Icon.setTint(0x808080);
|
data.eggMove1 = false;
|
||||||
} else {
|
} else {
|
||||||
container.eggMove1Icon.clearTint();
|
data.eggMove1 = true;
|
||||||
}
|
}
|
||||||
} else if (fitsTmMove1 && !fitsLevelMove1) {
|
} else if (fitsTmMove1 && !fitsLevelMove1) {
|
||||||
container.tmMove1Icon.setVisible(true);
|
data.tmMove1 = true;
|
||||||
}
|
}
|
||||||
if (fitsEggMove2 && !fitsLevelMove2) {
|
if (fitsEggMove2 && !fitsLevelMove2) {
|
||||||
container.eggMove2Icon.setVisible(true);
|
|
||||||
const em2 = eggMoves.findIndex(name => name === selectedMove2);
|
const em2 = eggMoves.findIndex(name => name === selectedMove2);
|
||||||
if ((starterData.eggMoves & (1 << em2)) === 0) {
|
if ((starterData.eggMoves & (1 << em2)) === 0) {
|
||||||
container.eggMove2Icon.setTint(0x808080);
|
data.eggMove2 = false;
|
||||||
} else {
|
} else {
|
||||||
container.eggMove2Icon.clearTint();
|
data.eggMove2 = true;
|
||||||
}
|
}
|
||||||
} else if (fitsTmMove2 && !fitsLevelMove2) {
|
} else if (fitsTmMove2 && !fitsLevelMove2) {
|
||||||
container.tmMove2Icon.setVisible(true);
|
data.tmMove2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ability filter
|
// Ability filter
|
||||||
const abilities = [ container.species.ability1, container.species.ability2, container.species.abilityHidden ].map(a => allAbilities[a].name);
|
const abilities = [ species.ability1, species.ability2, species.abilityHidden ].map(a => allAbilities[a].name);
|
||||||
const passives = starterPassiveAbilities[starterId] ?? {} as PassiveAbilities;
|
const passives = starterPassiveAbilities[starterId] ?? {} as PassiveAbilities;
|
||||||
|
|
||||||
const selectedAbility1 = this.filterText.getValue(FilterTextRow.ABILITY_1);
|
const selectedAbility1 = this.filterText.getValue(FilterTextRow.ABILITY_1);
|
||||||
const fitsFormAbility1 = container.species.forms.some(form => [ form.ability1, form.ability2, form.abilityHidden ].map(a => allAbilities[a].name).includes(selectedAbility1));
|
const fitsFormAbility1 = species.forms.some(form => [ form.ability1, form.ability2, form.abilityHidden ].map(a => allAbilities[a].name).includes(selectedAbility1));
|
||||||
const fitsAbility1 = abilities.includes(selectedAbility1) || fitsFormAbility1 || selectedAbility1 === this.filterText.defaultText;
|
const fitsAbility1 = abilities.includes(selectedAbility1) || fitsFormAbility1 || selectedAbility1 === this.filterText.defaultText;
|
||||||
const fitsPassive1 = Object.values(passives).some(p => allAbilities[p].name === selectedAbility1);
|
const fitsPassive1 = Object.values(passives).some(p => allAbilities[p].name === selectedAbility1);
|
||||||
|
|
||||||
const selectedAbility2 = this.filterText.getValue(FilterTextRow.ABILITY_2);
|
const selectedAbility2 = this.filterText.getValue(FilterTextRow.ABILITY_2);
|
||||||
const fitsFormAbility2 = container.species.forms.some(form => [ form.ability1, form.ability2, form.abilityHidden ].map(a => allAbilities[a].name).includes(selectedAbility2));
|
const fitsFormAbility2 = species.forms.some(form => [ form.ability1, form.ability2, form.abilityHidden ].map(a => allAbilities[a].name).includes(selectedAbility2));
|
||||||
const fitsAbility2 = abilities.includes(selectedAbility2) || fitsFormAbility2 || selectedAbility2 === this.filterText.defaultText;
|
const fitsAbility2 = abilities.includes(selectedAbility2) || fitsFormAbility2 || selectedAbility2 === this.filterText.defaultText;
|
||||||
const fitsPassive2 = Object.values(passives).some(p => allAbilities[p].name === selectedAbility2);
|
const fitsPassive2 = Object.values(passives).some(p => allAbilities[p].name === selectedAbility2);
|
||||||
|
|
||||||
@ -1334,35 +1328,27 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
const fitsAbilities = (fitsAbility1 && (fitsPassive2 || selectedAbility2 === this.filterText.defaultText)) ||
|
const fitsAbilities = (fitsAbility1 && (fitsPassive2 || selectedAbility2 === this.filterText.defaultText)) ||
|
||||||
(fitsAbility2 && (fitsPassive1 || selectedAbility1 === this.filterText.defaultText));
|
(fitsAbility2 && (fitsPassive1 || selectedAbility1 === this.filterText.defaultText));
|
||||||
|
|
||||||
container.passive1Icon.setVisible(false);
|
|
||||||
container.passive2Icon.setVisible(false);
|
|
||||||
if (fitsPassive1 || fitsPassive2) {
|
if (fitsPassive1 || fitsPassive2) {
|
||||||
if (fitsPassive1) {
|
if (fitsPassive1) {
|
||||||
if (starterData.passiveAttr > 0) {
|
if (starterData.passiveAttr > 0) {
|
||||||
container.passive1Icon.clearTint();
|
data.passive1 = true;
|
||||||
container.passive1OverlayIcon.clearTint();
|
|
||||||
} else {
|
} else {
|
||||||
container.passive1Icon.setTint(0x808080);
|
data.passive1 = false;
|
||||||
container.passive1OverlayIcon.setTint(0x808080);
|
|
||||||
}
|
}
|
||||||
container.passive1Icon.setVisible(true);
|
|
||||||
} else {
|
} else {
|
||||||
if (starterData.passiveAttr > 0) {
|
if (starterData.passiveAttr > 0) {
|
||||||
container.passive2Icon.clearTint();
|
data.passive2 = true;
|
||||||
container.passive2OverlayIcon.clearTint();
|
|
||||||
} else {
|
} else {
|
||||||
container.passive2Icon.setTint(0x808080);
|
data.passive2 = false;
|
||||||
container.passive2OverlayIcon.setTint(0x808080);
|
|
||||||
}
|
}
|
||||||
container.passive2Icon.setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gen filter
|
// Gen filter
|
||||||
const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation);
|
const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(species.generation);
|
||||||
|
|
||||||
// Type filter
|
// Type filter
|
||||||
const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => container.species.isOfType((type as number) - 1));
|
const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => species.isOfType((type as number) - 1));
|
||||||
|
|
||||||
// Biome filter
|
// Biome filter
|
||||||
const indexToBiome = new Map(
|
const indexToBiome = new Map(
|
||||||
@ -1374,7 +1360,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
// We get biomes for both the mon and its starters to ensure that evolutions get the correct filters.
|
// We get biomes for both the mon and its starters to ensure that evolutions get the correct filters.
|
||||||
// TODO: We might also need to do it the other way around.
|
// TODO: We might also need to do it the other way around.
|
||||||
const biomes = catchableSpecies[container.species.speciesId].concat(catchableSpecies[starterId]).map(b => Biome[b.biome]);
|
const biomes = catchableSpecies[species.speciesId].concat(catchableSpecies[starterId]).map(b => Biome[b.biome]);
|
||||||
if (biomes.length === 0) {
|
if (biomes.length === 0) {
|
||||||
biomes.push("Uncatchable");
|
biomes.push("Uncatchable");
|
||||||
}
|
}
|
||||||
@ -1405,7 +1391,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
// Passive Filter
|
// Passive Filter
|
||||||
const isPassiveUnlocked = starterData.passiveAttr > 0;
|
const isPassiveUnlocked = starterData.passiveAttr > 0;
|
||||||
const isPassiveUnlockable = this.isPassiveAvailable(container.species.speciesId) && !isPassiveUnlocked;
|
const isPassiveUnlockable = this.isPassiveAvailable(species.speciesId) && !isPassiveUnlocked;
|
||||||
const fitsPassive = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => {
|
const fitsPassive = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => {
|
||||||
if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.ON) {
|
if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.ON) {
|
||||||
return isPassiveUnlocked;
|
return isPassiveUnlocked;
|
||||||
@ -1421,7 +1407,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
// Cost Reduction Filter
|
// Cost Reduction Filter
|
||||||
const isCostReducedByOne = starterData.valueReduction === 1;
|
const isCostReducedByOne = starterData.valueReduction === 1;
|
||||||
const isCostReducedByTwo = starterData.valueReduction === 2;
|
const isCostReducedByTwo = starterData.valueReduction === 2;
|
||||||
const isCostReductionUnlockable = this.isValueReductionAvailable(container.species.speciesId);
|
const isCostReductionUnlockable = this.isValueReductionAvailable(species.speciesId);
|
||||||
const fitsCostReduction = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => {
|
const fitsCostReduction = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => {
|
||||||
if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ON) {
|
if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ON) {
|
||||||
return isCostReducedByOne || isCostReducedByTwo;
|
return isCostReducedByOne || isCostReducedByTwo;
|
||||||
@ -1439,7 +1425,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Starter Filter
|
// Starter Filter
|
||||||
const isStarter = this.getStarterSpeciesId(container.species.speciesId) === container.species.speciesId;
|
const isStarter = this.getStarterSpeciesId(species.speciesId) === species.speciesId;
|
||||||
const fitsStarter = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
const fitsStarter = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
||||||
if (misc.val === "STARTER" && misc.state === DropDownState.ON) {
|
if (misc.val === "STARTER" && misc.state === DropDownState.ON) {
|
||||||
return isStarter;
|
return isStarter;
|
||||||
@ -1453,7 +1439,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Favorite Filter
|
// Favorite Filter
|
||||||
const isFavorite = this.starterPreferences[container.species.speciesId]?.favorite ?? false;
|
const isFavorite = this.starterPreferences[species.speciesId]?.favorite ?? false;
|
||||||
const fitsFavorite = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
const fitsFavorite = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
||||||
if (misc.val === "FAVORITE" && misc.state === DropDownState.ON) {
|
if (misc.val === "FAVORITE" && misc.state === DropDownState.ON) {
|
||||||
return isFavorite;
|
return isFavorite;
|
||||||
@ -1481,7 +1467,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// HA Filter
|
// HA Filter
|
||||||
const speciesHasHiddenAbility = container.species.abilityHidden !== container.species.ability1 && container.species.abilityHidden !== Abilities.NONE;
|
const speciesHasHiddenAbility = species.abilityHidden !== species.ability1 && species.abilityHidden !== Abilities.NONE;
|
||||||
const hasHA = starterData.abilityAttr & AbilityAttr.ABILITY_HIDDEN;
|
const hasHA = starterData.abilityAttr & AbilityAttr.ABILITY_HIDDEN;
|
||||||
const fitsHA = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
const fitsHA = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
||||||
if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.ON) {
|
if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.ON) {
|
||||||
@ -1494,7 +1480,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Egg Purchasable Filter
|
// Egg Purchasable Filter
|
||||||
const isEggPurchasable = this.isSameSpeciesEggAvailable(container.species.speciesId);
|
const isEggPurchasable = this.isSameSpeciesEggAvailable(species.speciesId);
|
||||||
const fitsEgg = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
const fitsEgg = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
||||||
if (misc.val === "EGG" && misc.state === DropDownState.ON) {
|
if (misc.val === "EGG" && misc.state === DropDownState.ON) {
|
||||||
return isEggPurchasable;
|
return isEggPurchasable;
|
||||||
@ -1508,25 +1494,25 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
// Pokerus Filter
|
// Pokerus Filter
|
||||||
const fitsPokerus = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
const fitsPokerus = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
||||||
if (misc.val === "POKERUS" && misc.state === DropDownState.ON) {
|
if (misc.val === "POKERUS" && misc.state === DropDownState.ON) {
|
||||||
return this.pokerusSpecies.includes(container.species);
|
return this.pokerusSpecies.includes(species);
|
||||||
} else if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) {
|
} else if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) {
|
||||||
return !this.pokerusSpecies.includes(container.species);
|
return !this.pokerusSpecies.includes(species);
|
||||||
} else if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) {
|
} else if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fitsName && fitsAbilities && fitsMoves && fitsGen && fitsBiome && fitsType && fitsCaught && fitsPassive && fitsCostReduction && fitsStarter && fitsFavorite && fitsWin && fitsHA && fitsEgg && fitsPokerus) {
|
if (fitsName && fitsAbilities && fitsMoves && fitsGen && fitsBiome && fitsType && fitsCaught && fitsPassive && fitsCostReduction && fitsStarter && fitsFavorite && fitsWin && fitsHA && fitsEgg && fitsPokerus) {
|
||||||
this.filteredPokemonContainers.push(container);
|
this.filteredPokemonData.push(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.starterSelectScrollBar.setTotalRows(Math.max(Math.ceil(this.filteredPokemonContainers.length / 9), 1));
|
this.starterSelectScrollBar.setTotalRows(Math.max(Math.ceil(this.filteredPokemonData.length / 9), 1));
|
||||||
this.starterSelectScrollBar.setScrollCursor(0);
|
this.starterSelectScrollBar.setScrollCursor(0);
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
const sort = this.filterBar.getVals(DropDownColumn.SORT)[0];
|
const sort = this.filterBar.getVals(DropDownColumn.SORT)[0];
|
||||||
this.filteredPokemonContainers.sort((a, b) => {
|
this.filteredPokemonData.sort((a, b) => {
|
||||||
switch (sort.val) {
|
switch (sort.val) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1559,34 +1545,51 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
updateScroll = () => {
|
updateScroll = () => {
|
||||||
const maxColumns = 9;
|
const maxColumns = 9;
|
||||||
const maxRows = 9;
|
|
||||||
const onScreenFirstIndex = this.scrollCursor * maxColumns;
|
const onScreenFirstIndex = this.scrollCursor * maxColumns;
|
||||||
const onScreenLastIndex = Math.min(this.filteredPokemonContainers.length - 1, onScreenFirstIndex + maxRows * maxColumns - 1);
|
|
||||||
|
|
||||||
this.starterSelectScrollBar.setScrollCursor(this.scrollCursor);
|
this.starterSelectScrollBar.setScrollCursor(this.scrollCursor);
|
||||||
|
|
||||||
this.pokerusCursorObjs.forEach(cursorObj => cursorObj.setVisible(false));
|
this.pokerusCursorObjs.forEach(cursorObj => cursorObj.setVisible(false));
|
||||||
|
|
||||||
let pokerusCursorIndex = 0;
|
let pokerusCursorIndex = 0;
|
||||||
this.filteredPokemonContainers.forEach((container, i) => {
|
this.pokemonContainers.forEach((container, i) => {
|
||||||
const pos = calcStarterPosition(i, this.scrollCursor);
|
|
||||||
container.setPosition(pos.x, pos.y);
|
const i_data = i + onScreenFirstIndex;
|
||||||
if (i < onScreenFirstIndex || i > onScreenLastIndex) {
|
|
||||||
|
if (i_data >= this.filteredPokemonData.length) {
|
||||||
container.setVisible(false);
|
container.setVisible(false);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
container.setVisible(true);
|
container.setVisible(true);
|
||||||
|
|
||||||
|
const data = this.filteredPokemonData[i_data];
|
||||||
|
const props = data.props;
|
||||||
|
|
||||||
|
container.setSpecies(data.species, props);
|
||||||
|
|
||||||
|
const starterSprite = container.icon as Phaser.GameObjects.Sprite;
|
||||||
|
starterSprite.setTexture(data.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), container.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant));
|
||||||
|
container.checkIconId(props.female, props.formIndex, props.shiny, props.variant);
|
||||||
|
|
||||||
|
const speciesId = data.species.speciesId;
|
||||||
|
const dexEntry = globalScene.gameData.dexData[speciesId];
|
||||||
|
const caughtAttr = dexEntry.caughtAttr & globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & data.species.getFullUnlocksData();
|
||||||
|
|
||||||
|
if ((caughtAttr & data.species.getFullUnlocksData()) || globalScene.dexForDevs) {
|
||||||
|
container.icon.clearTint();
|
||||||
|
} else if (dexEntry.seenAttr) {
|
||||||
|
container.icon.setTint(0x808080);
|
||||||
|
} else {
|
||||||
|
container.icon.setTint(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.showDecorations) {
|
if (this.showDecorations) {
|
||||||
|
|
||||||
if (this.pokerusSpecies.includes(container.species)) {
|
if (this.pokerusSpecies.includes(data.species)) {
|
||||||
this.pokerusCursorObjs[pokerusCursorIndex].setPosition(pos.x - 1, pos.y + 1);
|
this.pokerusCursorObjs[pokerusCursorIndex].setPosition(container.x - 1, container.y + 1);
|
||||||
this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true);
|
this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true);
|
||||||
pokerusCursorIndex++;
|
pokerusCursorIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const speciesId = container.species.speciesId;
|
|
||||||
const caughtAttr = globalScene.gameData.dexData[speciesId].caughtAttr & globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & container.species.getFullUnlocksData();
|
|
||||||
this.updateStarterValueLabel(container);
|
this.updateStarterValueLabel(container);
|
||||||
|
|
||||||
container.label.setVisible(true);
|
container.label.setVisible(true);
|
||||||
@ -1641,6 +1644,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
setCursor(cursor: number): boolean {
|
setCursor(cursor: number): boolean {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
this.oldCursor = this.cursor;
|
||||||
|
|
||||||
if (this.filterMode) {
|
if (this.filterMode) {
|
||||||
changed = this.filterBarCursor !== cursor;
|
changed = this.filterBarCursor !== cursor;
|
||||||
@ -1651,16 +1655,17 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
this.filterTextCursor = cursor;
|
this.filterTextCursor = cursor;
|
||||||
this.filterText.setCursor(cursor);
|
this.filterText.setCursor(cursor);
|
||||||
} else {
|
} else {
|
||||||
cursor = Math.max(Math.min(this.filteredPokemonContainers.length - 1, cursor), 0);
|
cursor = Math.max(Math.min(this.pokemonContainers.length - 1, cursor), 0);
|
||||||
changed = super.setCursor(cursor);
|
changed = super.setCursor(cursor);
|
||||||
|
|
||||||
const pos = calcStarterPosition(cursor, this.scrollCursor);
|
const pos = calcStarterPosition(cursor);
|
||||||
this.cursorObj.setPosition(pos.x - 1, pos.y + 1);
|
this.cursorObj.setPosition(pos.x - 1, pos.y + 1);
|
||||||
|
|
||||||
const species = this.filteredPokemonContainers[cursor]?.species;
|
const species = this.pokemonContainers[cursor]?.species;
|
||||||
|
|
||||||
if (species) {
|
if (species) {
|
||||||
this.setSpecies(species);
|
this.setSpecies(species);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1712,13 +1717,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
this.trayColumns = Math.min(this.trayNumIcons, 9);
|
this.trayColumns = Math.min(this.trayNumIcons, 9);
|
||||||
|
|
||||||
const maxColumns = 9;
|
const maxColumns = 9;
|
||||||
const onScreenFirstIndex = this.scrollCursor * maxColumns;
|
const boxCursor = this.cursor;
|
||||||
const boxCursor = this.cursor - onScreenFirstIndex;
|
|
||||||
const boxCursorY = Math.floor(boxCursor / maxColumns);
|
const boxCursorY = Math.floor(boxCursor / maxColumns);
|
||||||
const boxCursorX = boxCursor - boxCursorY * 9;
|
const boxCursorX = boxCursor - boxCursorY * 9;
|
||||||
const spaceBelow = 9 - 1 - boxCursorY;
|
const spaceBelow = 9 - 1 - boxCursorY;
|
||||||
const spaceRight = 9 - boxCursorX;
|
const spaceRight = 9 - boxCursorX;
|
||||||
const boxPos = calcStarterPosition(this.cursor, this.scrollCursor);
|
const boxPos = calcStarterPosition(this.cursor);
|
||||||
const goUp = this.trayRows <= spaceBelow - 1 ? 0 : 1;
|
const goUp = this.trayRows <= spaceBelow - 1 ? 0 : 1;
|
||||||
const goLeft = this.trayColumns <= spaceRight ? 0 : 1;
|
const goLeft = this.trayColumns <= spaceRight ? 0 : 1;
|
||||||
|
|
||||||
@ -1745,6 +1749,8 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
formContainer.icon.clearTint();
|
formContainer.icon.clearTint();
|
||||||
} else if (isFormSeen) {
|
} else if (isFormSeen) {
|
||||||
formContainer.icon.setTint(0x808080);
|
formContainer.icon.setTint(0x808080);
|
||||||
|
} else {
|
||||||
|
formContainer.icon.setTint(0);
|
||||||
}
|
}
|
||||||
formContainer.setPosition(5 + (index % 9) * 18, 4 + Math.floor(index / 9) * 17);
|
formContainer.setPosition(5 + (index % 9) * 18, 4 + Math.floor(index / 9) * 17);
|
||||||
this.formTrayContainer.add(formContainer);
|
this.formTrayContainer.add(formContainer);
|
||||||
@ -1809,6 +1815,32 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
return { currentFriendship, friendshipCap };
|
return { currentFriendship, friendshipCap };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startIconAnimation(cursor: number) {
|
||||||
|
const container = this.pokemonContainers[cursor];
|
||||||
|
const icon = container.icon;
|
||||||
|
if (this.isUpgradeAnimationEnabled()) {
|
||||||
|
globalScene.tweens.getTweensOf(icon).forEach(tween => tween.pause());
|
||||||
|
// Reset the position of the icon
|
||||||
|
icon.x = -2;
|
||||||
|
icon.y = 2;
|
||||||
|
}
|
||||||
|
// Initiates the small up and down idle animation
|
||||||
|
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
stopIconAnimation(cursor: number) {
|
||||||
|
const container = this.pokemonContainers[cursor];
|
||||||
|
if (container) {
|
||||||
|
const lastSpeciesIcon = container.icon;
|
||||||
|
const dexAttr = this.getCurrentDexProps(container.species.speciesId);
|
||||||
|
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(container.species, dexAttr));
|
||||||
|
this.checkIconId(lastSpeciesIcon, container.species, props.female, props.formIndex, props.shiny, props.variant);
|
||||||
|
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
||||||
|
// Resume the animation for the previously selected species
|
||||||
|
globalScene.tweens.getTweensOf(lastSpeciesIcon).forEach(tween => tween.resume());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setSpecies(species: PokemonSpecies | null) {
|
setSpecies(species: PokemonSpecies | null) {
|
||||||
|
|
||||||
this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
|
this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
|
||||||
@ -1818,19 +1850,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.lastSpecies) {
|
if (this.lastSpecies) {
|
||||||
const dexAttr = this.getCurrentDexProps(this.lastSpecies.speciesId);
|
this.stopIconAnimation(this.oldCursor);
|
||||||
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr));
|
|
||||||
const speciesIndex = this.allSpecies.indexOf(this.lastSpecies);
|
|
||||||
const lastSpeciesIcon = this.pokemonContainers[speciesIndex].icon;
|
|
||||||
this.checkIconId(lastSpeciesIcon, this.lastSpecies, props.female, props.formIndex, props.shiny, props.variant);
|
|
||||||
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
|
||||||
|
|
||||||
// Resume the animation for the previously selected species
|
|
||||||
const icon = this.pokemonContainers[speciesIndex].icon;
|
|
||||||
globalScene.tweens.getTweensOf(icon).forEach(tween => tween.resume());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastSpecies = species!; // TODO: is this bang correct?
|
if (species) {
|
||||||
|
this.lastSpecies = species;
|
||||||
|
}
|
||||||
|
|
||||||
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs)) {
|
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs)) {
|
||||||
|
|
||||||
@ -1840,19 +1865,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
if (this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs) {
|
if (this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs) {
|
||||||
|
|
||||||
// Pause the animation when the species is selected
|
this.startIconAnimation(this.cursor);
|
||||||
const speciesIndex = this.allSpecies.indexOf(species);
|
|
||||||
const icon = this.pokemonContainers[speciesIndex].icon;
|
|
||||||
|
|
||||||
if (this.isUpgradeAnimationEnabled()) {
|
|
||||||
globalScene.tweens.getTweensOf(icon).forEach(tween => tween.pause());
|
|
||||||
// Reset the position of the icon
|
|
||||||
icon.x = -2;
|
|
||||||
icon.y = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initiates the small up and down idle animation
|
|
||||||
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
|
|
||||||
|
|
||||||
const speciesForm = getPokemonSpeciesForm(species.speciesId, 0);
|
const speciesForm = getPokemonSpeciesForm(species.speciesId, 0);
|
||||||
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
||||||
@ -2115,6 +2128,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
override destroy(): void {
|
override destroy(): void {
|
||||||
this.pokemonContainers = [];
|
this.pokemonContainers = [];
|
||||||
|
this.filteredPokemonData = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
clearText() {
|
clearText() {
|
||||||
@ -2126,6 +2140,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||||||
super.clear();
|
super.clear();
|
||||||
|
|
||||||
this.cursor = -1;
|
this.cursor = -1;
|
||||||
|
this.oldCursor = -1;
|
||||||
globalScene.ui.hideTooltip();
|
globalScene.ui.hideTooltip();
|
||||||
|
|
||||||
this.starterSelectContainer.setVisible(false);
|
this.starterSelectContainer.setVisible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user