[UI Bug] Fix HA icon not always showing in egg summary screen (#4150)
This commit is contained in:
parent
a919b9c0af
commit
9c4c19b5fb
|
@ -29,8 +29,10 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
||||||
private summaryContainer: Phaser.GameObjects.Container;
|
private summaryContainer: Phaser.GameObjects.Container;
|
||||||
/** container for the mini pokemon sprites */
|
/** container for the mini pokemon sprites */
|
||||||
private pokemonIconSpritesContainer: Phaser.GameObjects.Container;
|
private pokemonIconSpritesContainer: Phaser.GameObjects.Container;
|
||||||
/** container for the icons displayed alongside the mini icons (e.g. shiny, HA capsule) */
|
/** container for the icons displayed on top of the mini pokemon sprites (e.g. shiny, HA capsule) */
|
||||||
private pokemonIconsContainer: Phaser.GameObjects.Container;
|
private pokemonIconsContainer: Phaser.GameObjects.Container;
|
||||||
|
/** container for the elements displayed behind the mini pokemon sprites (e.g. egg rarity bg) */
|
||||||
|
private pokemonBackgroundContainer: Phaser.GameObjects.Container;
|
||||||
/** hatch info container that displays the current pokemon / hatch (main element on left hand side) */
|
/** hatch info container that displays the current pokemon / hatch (main element on left hand side) */
|
||||||
private infoContainer: PokemonHatchInfoContainer;
|
private infoContainer: PokemonHatchInfoContainer;
|
||||||
/** handles jumping animations for the pokemon sprite icons */
|
/** handles jumping animations for the pokemon sprite icons */
|
||||||
|
@ -71,15 +73,17 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
||||||
this.eggHatchBg.setOrigin(0, 0);
|
this.eggHatchBg.setOrigin(0, 0);
|
||||||
this.eggHatchContainer.add(this.eggHatchBg);
|
this.eggHatchContainer.add(this.eggHatchBg);
|
||||||
|
|
||||||
this.pokemonIconsContainer = this.scene.add.container(iconContainerX, iconContainerY);
|
|
||||||
this.pokemonIconSpritesContainer = this.scene.add.container(iconContainerX, iconContainerY);
|
|
||||||
this.summaryContainer.add(this.pokemonIconsContainer);
|
|
||||||
this.summaryContainer.add(this.pokemonIconSpritesContainer);
|
|
||||||
|
|
||||||
this.cursorObj = this.scene.add.image(0, 0, "select_cursor");
|
this.cursorObj = this.scene.add.image(0, 0, "select_cursor");
|
||||||
this.cursorObj.setOrigin(0, 0);
|
this.cursorObj.setOrigin(0, 0);
|
||||||
this.summaryContainer.add(this.cursorObj);
|
this.summaryContainer.add(this.cursorObj);
|
||||||
|
|
||||||
|
this.pokemonIconSpritesContainer = this.scene.add.container(iconContainerX, iconContainerY);
|
||||||
|
this.pokemonIconsContainer = this.scene.add.container(iconContainerX, iconContainerY);
|
||||||
|
this.pokemonBackgroundContainer = this.scene.add.container(iconContainerX, iconContainerY);
|
||||||
|
this.summaryContainer.add(this.pokemonBackgroundContainer);
|
||||||
|
this.summaryContainer.add(this.pokemonIconSpritesContainer);
|
||||||
|
this.summaryContainer.add(this.pokemonIconsContainer);
|
||||||
|
|
||||||
this.infoContainer = new PokemonHatchInfoContainer(this.scene, this.summaryContainer);
|
this.infoContainer = new PokemonHatchInfoContainer(this.scene, this.summaryContainer);
|
||||||
this.infoContainer.setup();
|
this.infoContainer.setup();
|
||||||
this.infoContainer.changeToEggSummaryLayout();
|
this.infoContainer.changeToEggSummaryLayout();
|
||||||
|
@ -95,6 +99,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
||||||
this.summaryContainer.setVisible(false);
|
this.summaryContainer.setVisible(false);
|
||||||
this.pokemonIconSpritesContainer.removeAll(true);
|
this.pokemonIconSpritesContainer.removeAll(true);
|
||||||
this.pokemonIconsContainer.removeAll(true);
|
this.pokemonIconsContainer.removeAll(true);
|
||||||
|
this.pokemonBackgroundContainer.removeAll(true);
|
||||||
this.eggHatchBg.setVisible(false);
|
this.eggHatchBg.setVisible(false);
|
||||||
this.getUi().hideTooltip();
|
this.getUi().hideTooltip();
|
||||||
// Note: Questions on garbage collection go to @frutescens
|
// Note: Questions on garbage collection go to @frutescens
|
||||||
|
@ -164,25 +169,25 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
||||||
const offset = 2;
|
const offset = 2;
|
||||||
const rightSideX = 12;
|
const rightSideX = 12;
|
||||||
|
|
||||||
const bg = this.scene.add.image(x+2, y+5, "passive_bg");
|
const rarityBg = this.scene.add.image(x + 2, y + 5, "passive_bg");
|
||||||
bg.setOrigin(0, 0);
|
rarityBg.setOrigin(0, 0);
|
||||||
bg.setScale(0.75);
|
rarityBg.setScale(0.75);
|
||||||
bg.setVisible(true);
|
rarityBg.setVisible(true);
|
||||||
this.pokemonIconsContainer.add(bg);
|
this.pokemonBackgroundContainer.add(rarityBg);
|
||||||
|
|
||||||
// set tint for passive bg
|
// set tint for passive bg
|
||||||
switch (getEggTierForSpecies(displayPokemon.species)) {
|
switch (getEggTierForSpecies(displayPokemon.species)) {
|
||||||
case EggTier.COMMON:
|
case EggTier.COMMON:
|
||||||
bg.setVisible(false);
|
rarityBg.setVisible(false);
|
||||||
break;
|
break;
|
||||||
case EggTier.GREAT:
|
case EggTier.GREAT:
|
||||||
bg.setTint(0xabafff);
|
rarityBg.setTint(0xabafff);
|
||||||
break;
|
break;
|
||||||
case EggTier.ULTRA:
|
case EggTier.ULTRA:
|
||||||
bg.setTint(0xffffaa);
|
rarityBg.setTint(0xffffaa);
|
||||||
break;
|
break;
|
||||||
case EggTier.MASTER:
|
case EggTier.MASTER:
|
||||||
bg.setTint(0xdfffaf);
|
rarityBg.setTint(0xdfffaf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const species = displayPokemon.species;
|
const species = displayPokemon.species;
|
||||||
|
@ -192,35 +197,31 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
||||||
const isShiny = displayPokemon.shiny;
|
const isShiny = displayPokemon.shiny;
|
||||||
|
|
||||||
// set pokemon icon (and replace with base sprite if there is a mismatch)
|
// set pokemon icon (and replace with base sprite if there is a mismatch)
|
||||||
const icon = this.scene.add.sprite(x - offset, y + offset, species.getIconAtlasKey(formIndex, isShiny, variant));
|
const pokemonIcon = this.scene.add.sprite(x - offset, y + offset, species.getIconAtlasKey(formIndex, isShiny, variant));
|
||||||
icon.setScale(0.5);
|
pokemonIcon.setScale(0.5);
|
||||||
icon.setOrigin(0, 0);
|
pokemonIcon.setOrigin(0, 0);
|
||||||
icon.setFrame(species.getIconId(female, formIndex, isShiny, variant));
|
pokemonIcon.setFrame(species.getIconId(female, formIndex, isShiny, variant));
|
||||||
|
|
||||||
if (icon.frame.name !== species.getIconId(female, formIndex, isShiny, variant)) {
|
if (pokemonIcon.frame.name !== species.getIconId(female, formIndex, isShiny, variant)) {
|
||||||
console.log(`${species.name}'s variant icon does not exist. Replacing with default.`);
|
console.log(`${species.name}'s variant icon does not exist. Replacing with default.`);
|
||||||
icon.setTexture(species.getIconAtlasKey(formIndex, false, variant));
|
pokemonIcon.setTexture(species.getIconAtlasKey(formIndex, false, variant));
|
||||||
icon.setFrame(species.getIconId(female, formIndex, false, variant));
|
pokemonIcon.setFrame(species.getIconId(female, formIndex, false, variant));
|
||||||
}
|
}
|
||||||
this.pokemonIconSpritesContainer.add(icon);
|
this.pokemonIconSpritesContainer.add(pokemonIcon);
|
||||||
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE);
|
|
||||||
|
|
||||||
const shiny = this.scene.add.image(x + rightSideX, y + offset * 2, "shiny_star_small");
|
const shinyIcon = this.scene.add.image(x + rightSideX, y + offset, "shiny_star_small");
|
||||||
shiny.setScale(0.5);
|
shinyIcon.setOrigin(0, 0);
|
||||||
shiny.setVisible(displayPokemon.shiny);
|
shinyIcon.setScale(0.5);
|
||||||
shiny.setTint(getVariantTint(displayPokemon.variant));
|
shinyIcon.setVisible(displayPokemon.shiny);
|
||||||
this.pokemonIconsContainer.add(shiny);
|
shinyIcon.setTint(getVariantTint(displayPokemon.variant));
|
||||||
|
this.pokemonIconsContainer.add(shinyIcon);
|
||||||
|
|
||||||
const ha = this.scene.add.image(x + rightSideX, y + 7, "ha_capsule");
|
const haIcon = this.scene.add.image(x + rightSideX, y + offset * 4, "ha_capsule");
|
||||||
ha.setScale(0.5);
|
haIcon.setOrigin(0, 0);
|
||||||
ha.setVisible((displayPokemon.hasAbility(displayPokemon.species.abilityHidden)));
|
haIcon.setScale(0.5);
|
||||||
this.pokemonIconsContainer.add(ha);
|
haIcon.setVisible(displayPokemon.abilityIndex === 2);
|
||||||
|
this.pokemonIconsContainer.add(haIcon);
|
||||||
|
|
||||||
const pb = this.scene.add.image(x + rightSideX, y + offset * 7, "icon_owned");
|
|
||||||
pb.setOrigin(0, 0);
|
|
||||||
pb.setScale(0.5);
|
|
||||||
|
|
||||||
// add animation for new unlocks (new catch or new shiny or new form)
|
|
||||||
const dexEntry = value.dexEntryBeforeUpdate;
|
const dexEntry = value.dexEntryBeforeUpdate;
|
||||||
const caughtAttr = dexEntry.caughtAttr;
|
const caughtAttr = dexEntry.caughtAttr;
|
||||||
const newShiny = BigInt(1 << (displayPokemon.shiny ? 1 : 0));
|
const newShiny = BigInt(1 << (displayPokemon.shiny ? 1 : 0));
|
||||||
|
@ -228,17 +229,24 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
||||||
const newShinyOrVariant = ((newShiny & caughtAttr) === BigInt(0)) || ((newVariant & caughtAttr) === BigInt(0));
|
const newShinyOrVariant = ((newShiny & caughtAttr) === BigInt(0)) || ((newVariant & caughtAttr) === BigInt(0));
|
||||||
const newForm = (BigInt(1 << displayPokemon.formIndex) * DexAttr.DEFAULT_FORM & caughtAttr) === BigInt(0);
|
const newForm = (BigInt(1 << displayPokemon.formIndex) * DexAttr.DEFAULT_FORM & caughtAttr) === BigInt(0);
|
||||||
|
|
||||||
pb.setVisible(!caughtAttr || newForm);
|
const pokeballIcon = this.scene.add.image(x + rightSideX, y + offset * 7, "icon_owned");
|
||||||
if (!caughtAttr || newShinyOrVariant || newForm) {
|
pokeballIcon.setOrigin(0, 0);
|
||||||
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
|
pokeballIcon.setScale(0.5);
|
||||||
}
|
pokeballIcon.setVisible(!caughtAttr || newForm);
|
||||||
this.pokemonIconsContainer.add(pb);
|
this.pokemonIconsContainer.add(pokeballIcon);
|
||||||
|
|
||||||
const em = this.scene.add.image(x, y + offset, "icon_egg_move");
|
const eggMoveIcon = this.scene.add.image(x, y + offset, "icon_egg_move");
|
||||||
em.setOrigin(0, 0);
|
eggMoveIcon.setOrigin(0, 0);
|
||||||
em.setScale(0.5);
|
eggMoveIcon.setScale(0.5);
|
||||||
em.setVisible(value.eggMoveUnlocked);
|
eggMoveIcon.setVisible(value.eggMoveUnlocked);
|
||||||
this.pokemonIconsContainer.add(em);
|
this.pokemonIconsContainer.add(eggMoveIcon);
|
||||||
|
|
||||||
|
// add animation to the Pokemon sprite for new unlocks (new catch, new shiny or new form)
|
||||||
|
if (!caughtAttr || newShinyOrVariant || newForm) {
|
||||||
|
this.iconAnimHandler.addOrUpdate(pokemonIcon, PokemonIconAnimMode.PASSIVE);
|
||||||
|
} else {
|
||||||
|
this.iconAnimHandler.addOrUpdate(pokemonIcon, PokemonIconAnimMode.NONE);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
|
|
|
@ -262,7 +262,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
|
||||||
this.pokemonFormText.disableInteractive();
|
this.pokemonFormText.disableInteractive();
|
||||||
}
|
}
|
||||||
|
|
||||||
const abilityTextStyle = pokemon.abilityIndex === (pokemon.species.ability2 ? 2 : 1) ? TextStyle.MONEY : TextStyle.WINDOW;
|
const abilityTextStyle = pokemon.abilityIndex === 2 ? TextStyle.MONEY : TextStyle.WINDOW;
|
||||||
this.pokemonAbilityText.setText(pokemon.getAbility(true).name);
|
this.pokemonAbilityText.setText(pokemon.getAbility(true).name);
|
||||||
this.pokemonAbilityText.setColor(getTextColor(abilityTextStyle, false, this.scene.uiTheme));
|
this.pokemonAbilityText.setColor(getTextColor(abilityTextStyle, false, this.scene.uiTheme));
|
||||||
this.pokemonAbilityText.setShadowColor(getTextColor(abilityTextStyle, true, this.scene.uiTheme));
|
this.pokemonAbilityText.setShadowColor(getTextColor(abilityTextStyle, true, this.scene.uiTheme));
|
||||||
|
|
Loading…
Reference in New Issue