Refactoring setSpecies and setSpeciesDetails

This commit is contained in:
Wlowscha 2025-03-28 20:56:21 +01:00
parent 9ec61ce4bf
commit c3b97b244d
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -675,7 +675,9 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.starterSelectMessageBoxContainer.setVisible(!!text?.length); this.starterSelectMessageBoxContainer.setVisible(!!text?.length);
} }
isSeen(species: PokemonSpecies, dexEntry: DexEntry): boolean { isSeen(species: PokemonSpecies): boolean {
const dexEntry = globalScene.gameData.dexData[species.speciesId];
if (dexEntry?.seenAttr) { if (dexEntry?.seenAttr) {
return true; return true;
} }
@ -1629,7 +1631,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
if (caughtAttr & data.species.getFullUnlocksData() || globalScene.dexForDevs) { if (caughtAttr & data.species.getFullUnlocksData() || globalScene.dexForDevs) {
container.icon.clearTint(); container.icon.clearTint();
} else if (this.isSeen(data.species, dexEntry)) { } else if (this.isSeen(data.species)) {
container.icon.setTint(0x808080); container.icon.setTint(0x808080);
} else { } else {
container.icon.setTint(0); container.icon.setTint(0);
@ -1813,7 +1815,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
const dexEntry = globalScene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
this.trayContainers = []; this.trayContainers = [];
const isFormSeen = this.isSeen(species, dexEntry); const isFormSeen = this.isSeen(species);
this.trayForms.map((f, index) => { this.trayForms.map((f, index) => {
const props = this.getDefaultProps(species, f.formIndex); const props = this.getDefaultProps(species, f.formIndex);
const isFormCaught = dexEntry const isFormCaught = dexEntry
@ -1936,47 +1938,16 @@ export default class PokedexUiHandler extends MessageUiHandler {
if (species) { if (species) {
this.lastSpecies = species; this.lastSpecies = species;
}
if (
species &&
(this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs)
) {
this.pokemonNumberText.setText(i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4));
this.pokemonNameText.setText(species.name);
if (this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs) { if (this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs) {
this.startIconAnimation(this.cursor); this.startIconAnimation(this.cursor);
const speciesForm = getPokemonSpeciesForm(species.speciesId, 0);
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
this.setSpeciesDetails(species, formIndex);
this.pokemonSprite.clearTint();
this.type1Icon.clearTint();
this.type2Icon.clearTint();
} else {
this.type1Icon.setVisible(true);
this.type2Icon.setVisible(true);
this.setSpeciesDetails(species, formIndex);
this.pokemonSprite.setTint(0x808080);
} }
// This now handles caught/seen/uncaught
this.setSpeciesDetails(species, formIndex);
} else { } else {
this.pokemonNumberText.setText( this.pokemonNumberText.setText("");
species ? i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4) : "", this.pokemonNameText.setText("");
);
this.pokemonNameText.setText(species ? "???" : "");
this.pokemonFormText.setText(""); this.pokemonFormText.setText("");
this.type1Icon.setVisible(false); this.setTypeIcons(null, null);
this.type2Icon.setVisible(false);
if (species) {
this.pokemonSprite.setTint(0x000000);
this.setSpeciesDetails(species, formIndex);
}
} }
} }
@ -2005,7 +1976,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
const variant = props.variant; const variant = props.variant;
const isFormCaught = dexEntry ? (caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n : false; const isFormCaught = dexEntry ? (caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n : false;
const isFormSeen = this.isSeen(species, dexEntry); const isFormSeen = this.isSeen(species);
const assetLoadCancelled = new BooleanHolder(false); const assetLoadCancelled = new BooleanHolder(false);
this.assetLoadCancelled = assetLoadCancelled; this.assetLoadCancelled = assetLoadCancelled;
@ -2036,14 +2007,18 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.pokemonSprite.setTint(0); this.pokemonSprite.setTint(0);
} }
this.pokemonNumberText.setText(i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4));
if (isFormCaught || isFormSeen || globalScene.dexForDevs) { if (isFormCaught || isFormSeen || globalScene.dexForDevs) {
// TODO: change this once forms are refactored // TODO: change this once forms are refactored
this.pokemonNameText.setText(species.name);
if (normalForm.includes(species.speciesId) && !formIndex) { if (normalForm.includes(species.speciesId) && !formIndex) {
this.pokemonFormText.setText(""); this.pokemonFormText.setText("");
} else { } else {
this.pokemonFormText.setText(species.getFormNameToDisplay(formIndex, false)); this.pokemonFormText.setText(species.getFormNameToDisplay(formIndex, false));
} }
} else { } else {
this.pokemonNameText.setText("???");
this.pokemonFormText.setText(""); this.pokemonFormText.setText("");
} }