mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-28 19:22:29 +02:00
Added button to show back sprites
This commit is contained in:
parent
df1cdd265d
commit
dabc275bdf
@ -298,8 +298,8 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpriteAtlasPath(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string {
|
getSpriteAtlasPath(female: boolean, formIndex?: number, shiny?: boolean, variant?: number, back?: boolean): string {
|
||||||
const spriteId = this.getSpriteId(female, formIndex, shiny, variant).replace(/\_{2}/g, "/");
|
const spriteId = this.getSpriteId(female, formIndex, shiny, variant, back).replace(/\_{2}/g, "/");
|
||||||
return `${/_[1-3]$/.test(spriteId) ? "variant/" : ""}${spriteId}`;
|
return `${/_[1-3]$/.test(spriteId) ? "variant/" : ""}${spriteId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,8 +320,8 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return `${back ? "back__" : ""}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? "shiny__" : ""}${baseSpriteKey}${shiny && variantSet && variantSet[variant] === 2 ? `_${variant + 1}` : ""}`;
|
return `${back ? "back__" : ""}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? "shiny__" : ""}${baseSpriteKey}${shiny && variantSet && variantSet[variant] === 2 ? `_${variant + 1}` : ""}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpriteKey(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string {
|
getSpriteKey(female: boolean, formIndex?: number, shiny?: boolean, variant?: number, back?: boolean): string {
|
||||||
return `pkmn__${this.getSpriteId(female, formIndex, shiny, variant)}`;
|
return `pkmn__${this.getSpriteId(female, formIndex, shiny, variant, back)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getFormSpriteKey(formIndex?: number): string;
|
abstract getFormSpriteKey(formIndex?: number): string;
|
||||||
@ -494,10 +494,10 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAssets(female: boolean, formIndex?: number, shiny?: boolean, variant?: Variant, startLoad?: boolean): Promise<void> {
|
loadAssets(female: boolean, formIndex?: number, shiny?: boolean, variant?: Variant, startLoad?: boolean, back?: boolean): Promise<void> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant);
|
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant, back);
|
||||||
globalScene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant));
|
globalScene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant, back));
|
||||||
globalScene.load.audio(`${this.getCryKey(formIndex)}`, `audio/${this.getCryKey(formIndex)}.m4a`);
|
globalScene.load.audio(`${this.getCryKey(formIndex)}`, `audio/${this.getCryKey(formIndex)}.m4a`);
|
||||||
globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => {
|
globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => {
|
||||||
const originalWarn = console.warn;
|
const originalWarn = console.warn;
|
||||||
@ -507,7 +507,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
console.warn = originalWarn;
|
console.warn = originalWarn;
|
||||||
if (!(globalScene.anims.exists(spriteKey))) {
|
if (!(globalScene.anims.exists(spriteKey))) {
|
||||||
globalScene.anims.create({
|
globalScene.anims.create({
|
||||||
key: this.getSpriteKey(female, formIndex, shiny, variant),
|
key: this.getSpriteKey(female, formIndex, shiny, variant, back),
|
||||||
frames: frameNames,
|
frames: frameNames,
|
||||||
frameRate: 10,
|
frameRate: 10,
|
||||||
repeat: -1
|
repeat: -1
|
||||||
@ -515,7 +515,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
} else {
|
} else {
|
||||||
globalScene.anims.get(spriteKey).frameRate = 10;
|
globalScene.anims.get(spriteKey).frameRate = 10;
|
||||||
}
|
}
|
||||||
const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, "");
|
const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant, back).replace("variant/", "").replace(/_[1-3]$/, "");
|
||||||
globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant).then(() => resolve());
|
globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant).then(() => resolve());
|
||||||
});
|
});
|
||||||
if (startLoad) {
|
if (startLoad) {
|
||||||
|
@ -185,6 +185,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
private variantLabel: Phaser.GameObjects.Text;
|
private variantLabel: Phaser.GameObjects.Text;
|
||||||
private candyUpgradeIconElement: Phaser.GameObjects.Sprite;
|
private candyUpgradeIconElement: Phaser.GameObjects.Sprite;
|
||||||
private candyUpgradeLabel: Phaser.GameObjects.Text;
|
private candyUpgradeLabel: Phaser.GameObjects.Text;
|
||||||
|
private showBackSpriteIconElement: Phaser.GameObjects.Sprite;
|
||||||
|
private showBackSpriteLabel: Phaser.GameObjects.Text;
|
||||||
|
|
||||||
private starterSelectMessageBox: Phaser.GameObjects.NineSlice;
|
private starterSelectMessageBox: Phaser.GameObjects.NineSlice;
|
||||||
private starterSelectMessageBoxContainer: Phaser.GameObjects.Container;
|
private starterSelectMessageBoxContainer: Phaser.GameObjects.Container;
|
||||||
@ -239,6 +241,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
protected blockInput: boolean = false;
|
protected blockInput: boolean = false;
|
||||||
protected blockInputOverlay: boolean = false;
|
protected blockInputOverlay: boolean = false;
|
||||||
|
|
||||||
|
private showBackSprite: boolean = false;
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
private menuContainer: Phaser.GameObjects.Container;
|
private menuContainer: Phaser.GameObjects.Container;
|
||||||
private menuBg: Phaser.GameObjects.NineSlice;
|
private menuBg: Phaser.GameObjects.NineSlice;
|
||||||
@ -441,6 +445,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.variantLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleVariant"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
this.variantLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleVariant"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
||||||
this.variantLabel.setName("text-variant-label");
|
this.variantLabel.setName("text-variant-label");
|
||||||
|
|
||||||
|
this.showBackSpriteIconElement = new Phaser.GameObjects.Sprite(globalScene, 50, 7, "keyboard", "E.png");
|
||||||
|
this.showBackSpriteIconElement.setName("show-backSprite-icon-element");
|
||||||
|
this.showBackSpriteIconElement.setScale(0.675);
|
||||||
|
this.showBackSpriteIconElement.setOrigin(0.0, 0.0);
|
||||||
|
this.showBackSpriteLabel = addTextObject(60, 7, i18next.t("pokedexUiHandler:showBackSprite"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
||||||
|
this.showBackSpriteLabel.setName("show-backSprite-label");
|
||||||
|
this.starterSelectContainer.add(this.showBackSpriteIconElement);
|
||||||
|
this.starterSelectContainer.add(this.showBackSpriteLabel);
|
||||||
|
|
||||||
this.hideInstructions();
|
this.hideInstructions();
|
||||||
|
|
||||||
this.filterInstructionsContainer = globalScene.add.container(50, 5);
|
this.filterInstructionsContainer = globalScene.add.container(50, 5);
|
||||||
@ -1720,6 +1733,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Button.CYCLE_ABILITY:
|
||||||
|
this.showBackSprite = !this.showBackSprite;
|
||||||
|
if (this.showBackSprite) {
|
||||||
|
this.showBackSpriteLabel.setText(i18next.t("pokedexUiHandler:showFrontSprite"));
|
||||||
|
} else {
|
||||||
|
this.showBackSpriteLabel.setText(i18next.t("pokedexUiHandler:showBackSprite"));
|
||||||
|
}
|
||||||
|
this.setSpeciesDetails(this.species, {}, true);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
if (this.cursor) {
|
if (this.cursor) {
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
@ -1798,6 +1821,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
case SettingKeyboard.Button_Cycle_Variant:
|
case SettingKeyboard.Button_Cycle_Variant:
|
||||||
iconPath = "V.png";
|
iconPath = "V.png";
|
||||||
break;
|
break;
|
||||||
|
case SettingKeyboard.Button_Cycle_Ability:
|
||||||
|
iconPath = "E.png";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2087,7 +2113,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSpeciesDetails(species: PokemonSpecies, options: SpeciesDetails = {}): void {
|
setSpeciesDetails(species: PokemonSpecies, options: SpeciesDetails = {}, forceUpdate?: boolean): void {
|
||||||
let { shiny, formIndex, female, variant } = options;
|
let { shiny, formIndex, female, variant } = options;
|
||||||
const forSeen: boolean = options.forSeen ?? false;
|
const forSeen: boolean = options.forSeen ?? false;
|
||||||
const oldProps = species ? this.starterAttributes : null;
|
const oldProps = species ? this.starterAttributes : null;
|
||||||
@ -2095,7 +2121,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
// We will only update the sprite if there is a change to form, shiny/variant
|
// We will only update the sprite if there is a change to form, shiny/variant
|
||||||
// or gender for species with gender sprite differences
|
// or gender for species with gender sprite differences
|
||||||
const shouldUpdateSprite = (species?.genderDiffs && !isNullOrUndefined(female))
|
const shouldUpdateSprite = (species?.genderDiffs && !isNullOrUndefined(female))
|
||||||
|| !isNullOrUndefined(formIndex) || !isNullOrUndefined(shiny) || !isNullOrUndefined(variant);
|
|| !isNullOrUndefined(formIndex) || !isNullOrUndefined(shiny) || !isNullOrUndefined(variant) || forceUpdate;
|
||||||
|
|
||||||
if (this.activeTooltip === "CANDY") {
|
if (this.activeTooltip === "CANDY") {
|
||||||
if (this.species && this.pokemonCandyContainer.visible) {
|
if (this.species && this.pokemonCandyContainer.visible) {
|
||||||
@ -2170,16 +2196,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.assetLoadCancelled = assetLoadCancelled;
|
this.assetLoadCancelled = assetLoadCancelled;
|
||||||
|
|
||||||
if (shouldUpdateSprite) {
|
if (shouldUpdateSprite) {
|
||||||
species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => { // TODO: is this bang correct?
|
const back = this.showBackSprite ? true : false;
|
||||||
|
species.loadAssets(female!, formIndex, shiny, variant as Variant, true, back).then(() => { // TODO: is this bang correct?
|
||||||
if (assetLoadCancelled.value) {
|
if (assetLoadCancelled.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.assetLoadCancelled = null;
|
this.assetLoadCancelled = null;
|
||||||
this.speciesLoaded.set(species.speciesId, true);
|
this.speciesLoaded.set(species.speciesId, true);
|
||||||
this.pokemonSprite.play(species.getSpriteKey(female!, formIndex, shiny, variant)); // TODO: is this bang correct?
|
this.pokemonSprite.play(species.getSpriteKey(female!, formIndex, shiny, variant, back)); // TODO: is this bang correct?
|
||||||
this.pokemonSprite.setPipelineData("shiny", shiny);
|
this.pokemonSprite.setPipelineData("shiny", shiny);
|
||||||
this.pokemonSprite.setPipelineData("variant", variant);
|
this.pokemonSprite.setPipelineData("variant", variant);
|
||||||
this.pokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female!, formIndex, shiny, variant)); // TODO: is this bang correct?
|
this.pokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female!, formIndex, shiny, variant, back)); // TODO: is this bang correct?
|
||||||
this.pokemonSprite.setVisible(!this.statsMode);
|
this.pokemonSprite.setVisible(!this.statsMode);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -2374,6 +2401,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.starterSelectContainer.setVisible(false);
|
this.starterSelectContainer.setVisible(false);
|
||||||
this.blockInput = false;
|
this.blockInput = false;
|
||||||
|
|
||||||
|
this.showBackSprite = false;
|
||||||
|
this.showBackSpriteLabel.setText(i18next.t("pokedexUiHandler:showBackSprite"));
|
||||||
|
|
||||||
if (this.statsMode) {
|
if (this.statsMode) {
|
||||||
this.toggleStatsMode(false);
|
this.toggleStatsMode(false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user