From bba7c1610de9b1b5e0c685f9375214a58cca89fd Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Tue, 25 Mar 2025 21:36:12 +0100 Subject: [PATCH] =?UTF-8?q?[UI/UX]=20Option=20to=20see=20Pokedex=20entry?= =?UTF-8?q?=20after=20catching=20wild=20Pok=C3=A9mon=20(#5538)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * pokedex option after catching * Also changing catching for mystery encounters --- .../utils/encounter-pokemon-utils.ts | 20 ++++++++++++++++ src/phases/attempt-capture-phase.ts | 21 ++++++++++++++++ src/ui/confirm-ui-handler.ts | 24 ++++++++++++------- src/ui/pokedex-page-ui-handler.ts | 15 +++++++++++- src/ui/pokemon-info-container.ts | 2 +- 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts index 275078dbace..a4787e819b8 100644 --- a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts @@ -741,6 +741,26 @@ export async function catchPokemon( false, ); }, + () => { + const attributes = { + shiny: pokemon.shiny, + variant: pokemon.variant, + form: pokemon.formIndex, + female: pokemon.gender === Gender.FEMALE, + }; + globalScene.ui.setOverlayMode( + Mode.POKEDEX_PAGE, + pokemon.species, + pokemon.formIndex, + attributes, + null, + () => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + promptRelease(); + }); + }, + ); + }, () => { globalScene.ui.setMode( Mode.PARTY, diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 6b905c2a07f..6e2a2d29af4 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -24,6 +24,7 @@ import type { PokeballType } from "#enums/pokeball"; import { StatusEffect } from "#enums/status-effect"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; +import { Gender } from "#app/data/gender"; export class AttemptCapturePhase extends PokemonPhase { private pokeballType: PokeballType; @@ -321,6 +322,26 @@ export class AttemptCapturePhase extends PokemonPhase { false, ); }, + () => { + const attributes = { + shiny: pokemon.shiny, + variant: pokemon.variant, + form: pokemon.formIndex, + female: pokemon.gender === Gender.FEMALE, + }; + globalScene.ui.setOverlayMode( + Mode.POKEDEX_PAGE, + pokemon.species, + pokemon.formIndex, + attributes, + null, + () => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + promptRelease(); + }); + }, + ); + }, () => { globalScene.ui.setMode( Mode.PARTY, diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index a8710b0ab01..eb7018051b7 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -21,11 +21,12 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { show(args: any[]): boolean { if ( - args.length === 4 && + args.length === 5 && args[0] instanceof Function && args[1] instanceof Function && args[2] instanceof Function && - args[3] === "fullParty" + args[3] instanceof Function && + args[4] === "fullParty" ) { const config: OptionSelectConfig = { options: [ @@ -37,29 +38,36 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { }, }, { - label: i18next.t("menu:yes"), + label: i18next.t("partyUiHandler:POKEDEX"), handler: () => { args[1](); return true; }, }, { - label: i18next.t("menu:no"), + label: i18next.t("menu:yes"), handler: () => { args[2](); return true; }, }, + { + label: i18next.t("menu:no"), + handler: () => { + args[3](); + return true; + }, + }, ], - delay: args.length >= 8 && args[7] !== null ? (args[7] as number) : 0, + delay: args.length >= 9 && args[8] !== null ? (args[8] as number) : 0, }; super.show([config]); - this.switchCheck = args.length >= 5 && args[4] !== null && (args[4] as boolean); + this.switchCheck = args.length >= 6 && args[5] !== null && (args[5] as boolean); - const xOffset = args.length >= 6 && args[5] !== null ? (args[5] as number) : 0; - const yOffset = args.length >= 7 && args[6] !== null ? (args[6] as number) : 0; + const xOffset = args.length >= 7 && args[6] !== null ? (args[6] as number) : 0; + const yOffset = args.length >= 8 && args[7] !== null ? (args[7] as number) : 0; this.optionSelectContainer.setPosition(globalScene.game.canvas.width / 6 - 1 + xOffset, -48 + yOffset); diff --git a/src/ui/pokedex-page-ui-handler.ts b/src/ui/pokedex-page-ui-handler.ts index 86460a24fdc..8f96f1e44c2 100644 --- a/src/ui/pokedex-page-ui-handler.ts +++ b/src/ui/pokedex-page-ui-handler.ts @@ -261,6 +261,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { private unlockedVariants: boolean[]; private canUseCandies: boolean; + private exitCallback; constructor() { super(Mode.POKEDEX_PAGE); @@ -681,6 +682,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.filteredIndices = args[2] ?? null; this.starterSetup(); + if (args[4] instanceof Function) { + this.exitCallback = args[4]; + } + this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers this.infoOverlay.clear(); @@ -1106,7 +1111,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler { }); this.blockInput = false; } else { - ui.revertMode(); + ui.revertMode() + .then(() => { + console.log("exitCallback", this.exitCallback); + if (this.exitCallback instanceof Function) { + const exitCallback = this.exitCallback; + this.exitCallback = null; + exitCallback(); + } + }); success = true; } } else { diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index 64c743ec88d..56201f38748 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -458,7 +458,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { makeRoomForConfirmUi(speedMultiplier = 1, fromCatch = false): Promise { const xPosition = fromCatch - ? this.initialX - this.infoWindowWidth - 65 + ? this.initialX - this.infoWindowWidth - 67 : this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth; return new Promise(resolve => { globalScene.tweens.add({