From bd86fc645904659d729742737e64423e09da9e3f Mon Sep 17 00:00:00 2001 From: Frutescens Date: Sun, 9 Jun 2024 23:13:41 -0700 Subject: [PATCH 1/7] Option to view Summary before adding new Pokemon to party --- src/phases.ts | 11 ++++++++-- src/ui/confirm-ui-handler.ts | 41 ++++++++++++++++++++++++++++++++++-- src/ui/summary-ui-handler.ts | 6 +++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index e976b133fea..e2852e87c75 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4819,7 +4819,9 @@ export class AttemptCapturePhase extends PokemonPhase { }); } }, - onComplete: () => this.catch() + onComplete: () => { + this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.catch(); + } }); }; @@ -4860,7 +4862,6 @@ export class AttemptCapturePhase extends PokemonPhase { catch() { const pokemon = this.getPokemon() as EnemyPokemon; - this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm(); @@ -4920,6 +4921,12 @@ export class AttemptCapturePhase extends PokemonPhase { this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.name }), null, () => { this.scene.pokemonInfoContainer.makeRoomForConfirmUi(); this.scene.ui.setMode(Mode.CONFIRM, () => { + const newPokemon = this.scene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon); + this.scene.ui.setMode(Mode.SUMMARY, newPokemon).then(() => { + this.catch(); + return; + }); + }, () => { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (slotIndex < 6) { diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index 953ed4972ac..49c4782a8a7 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -20,7 +20,45 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { } show(args: any[]): boolean { - if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) { + if (args.length === 3 && args[0].toString().includes("newPokemon")) { + const config: OptionSelectConfig = { + options: [ + { + label: i18next.t("partyUiHandler:SUMMARY"), + handler: () => { + args[0](); + return false; + }, + }, { + label: i18next.t("menu:yes"), + handler: () => { + args[1](); + return true; + } + }, { + label: i18next.t("menu:no"), + handler: () => { + args[2](); + return true; + } + } + ], + delay: args.length >= 7 && args[6] !== null ? args[6] as integer : 0 + }; + + super.show([ config ]); + + this.switchCheck = args.length >= 4 && args[3] !== null && args[3] as boolean; + + const xOffset = (args.length >= 5 && args[4] !== null ? args[4] as number : 0); + const yOffset = (args.length >= 6 && args[5] !== null ? args[5] as number : 0); + + this.optionSelectContainer.setPosition((this.scene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset); + + this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); + + return true; + } else if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) { const config: OptionSelectConfig = { options: [ { @@ -54,7 +92,6 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { return true; } - return false; } diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 5b4dc2cf84f..704ce40791f 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -485,7 +485,11 @@ export default class SummaryUiHandler extends UiHandler { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { this.hideMoveSelect(); } else { - ui.setMode(Mode.PARTY); + if (!ui.getMessageHandler().onActionInput) { + ui.setMode(Mode.PARTY); + } else { + ui.setMode(Mode.MESSAGE); + } } success = true; } else { From 14ff290b74bfdcbb32e4bcf6e3a6b18db2913c29 Mon Sep 17 00:00:00 2001 From: Frutescens Date: Mon, 10 Jun 2024 13:04:16 -0700 Subject: [PATCH 2/7] Fixed issues described by HopsWas --- src/phases.ts | 4 ++-- src/ui/summary-ui-handler.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index e2852e87c75..6956b004669 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4820,7 +4820,7 @@ export class AttemptCapturePhase extends PokemonPhase { } }, onComplete: () => { - this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.catch(); + this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.scene.gameData.setPokemonCaught(pokemon); this.catch(); } }); }; @@ -4915,7 +4915,7 @@ export class AttemptCapturePhase extends PokemonPhase { } }); }; - Promise.all([ pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon) ]).then(() => { + Promise.all([ pokemon.hideInfo() ]).then(() => { if (this.scene.getParty().length === 6) { const promptRelease = () => { this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.name }), null, () => { diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 704ce40791f..ab94610ecb5 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -485,10 +485,10 @@ export default class SummaryUiHandler extends UiHandler { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { this.hideMoveSelect(); } else { - if (!ui.getMessageHandler().onActionInput) { - ui.setMode(Mode.PARTY); - } else { + if (ui.getMessageHandler().onActionInput) { ui.setMode(Mode.MESSAGE); + } else { + ui.setMode(Mode.PARTY); } } success = true; @@ -499,6 +499,8 @@ export default class SummaryUiHandler extends UiHandler { case Button.DOWN: if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { break; + } else if (ui.getMessageHandler().onActionInput) { + break; } const isDown = button === Button.DOWN; const party = this.scene.getParty(); From 5dd2c43f51bb7af7bea7a69a72a500ecd79d5b48 Mon Sep 17 00:00:00 2001 From: Frutescens Date: Fri, 14 Jun 2024 09:39:49 -0700 Subject: [PATCH 3/7] Adjusted makeRoomForConfirmUi to improve window spacing --- src/phases.ts | 2 +- src/ui/pokemon-info-container.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 6956b004669..45fcc106c61 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4919,7 +4919,7 @@ export class AttemptCapturePhase extends PokemonPhase { if (this.scene.getParty().length === 6) { const promptRelease = () => { this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.name }), null, () => { - this.scene.pokemonInfoContainer.makeRoomForConfirmUi(); + this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); this.scene.ui.setMode(Mode.CONFIRM, () => { const newPokemon = this.scene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon); this.scene.ui.setMode(Mode.SUMMARY, newPokemon).then(() => { diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index f28cf2e8a48..78e6b934d79 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -364,13 +364,14 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { }); } - makeRoomForConfirmUi(speedMultiplier: number = 1): Promise { + makeRoomForConfirmUi(speedMultiplier: number = 1, fromCatch: boolean = false): Promise { + const xPosition = fromCatch ? this.initialX - this.infoWindowWidth - 65 : this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth; return new Promise(resolve => { this.scene.tweens.add({ targets: this, duration: Utils.fixedInt(Math.floor(150 / speedMultiplier)), ease: "Cubic.easeInOut", - x: this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth, + x: xPosition, onComplete: () => { resolve(); } From c283877d7fc6cc9b361ed1169253e73681610072 Mon Sep 17 00:00:00 2001 From: Frutescens Date: Tue, 2 Jul 2024 14:54:31 -0700 Subject: [PATCH 4/7] Fixed ESLint issue + addressed OrangeRed review --- src/phases.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 9f069a60dc5..8732faedb9c 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4890,7 +4890,11 @@ export class AttemptCapturePhase extends PokemonPhase { }); } }, - onComplete: () => this.catch() + onComplete: () => { + this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); + this.scene.gameData.setPokemonCaught(pokemon); + this.catch(); + } }); }; @@ -4985,12 +4989,18 @@ export class AttemptCapturePhase extends PokemonPhase { } }); }; - Promise.all([pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon)]).then(() => { + Promise.all([pokemon.hideInfo()]).then(() => { if (this.scene.getParty().length === 6) { const promptRelease = () => { this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.name }), null, () => { - this.scene.pokemonInfoContainer.makeRoomForConfirmUi(); + this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); this.scene.ui.setMode(Mode.CONFIRM, () => { + const newPokemon = this.scene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon); + this.scene.ui.setMode(Mode.SUMMARY, newPokemon).then(() => { + this.catch(); + return; + }); + }, () => { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (slotIndex < 6) { From 2309a0ed9883007cdc57e47e77f5436bb72c65f8 Mon Sep 17 00:00:00 2001 From: Frutescens Date: Tue, 2 Jul 2024 15:53:37 -0700 Subject: [PATCH 5/7] Fixed Github pages issue --- src/ui/summary-ui-handler.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 17012182496..b6525ae325d 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -397,7 +397,7 @@ export default class SummaryUiHandler extends UiHandler { } const ui = this.getUi(); - + const fromPartyMode = ui.handlers[Mode.PARTY].active; let success = false; let error = false; @@ -485,7 +485,8 @@ export default class SummaryUiHandler extends UiHandler { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { this.hideMoveSelect(); } else { - if (ui.getMessageHandler().onActionInput) { + + if (!fromPartyMode) { ui.setMode(Mode.MESSAGE); } else { ui.setMode(Mode.PARTY); @@ -499,7 +500,7 @@ export default class SummaryUiHandler extends UiHandler { case Button.DOWN: if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { break; - } else if (ui.getMessageHandler().onActionInput) { + } else if (!fromPartyMode) { break; } const isDown = button === Button.DOWN; From fec04e8f60d266f825f1e0924203132824552afe Mon Sep 17 00:00:00 2001 From: Frutescens Date: Tue, 2 Jul 2024 20:38:24 -0700 Subject: [PATCH 6/7] Removed duplicate unshiftPhase --- src/phases.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index 8732faedb9c..4b98944c603 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4935,7 +4935,6 @@ export class AttemptCapturePhase extends PokemonPhase { catch() { const pokemon = this.getPokemon() as EnemyPokemon; - this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm(); From 7a69808f80bf44e4662532d3d421868c02ae0dc2 Mon Sep 17 00:00:00 2001 From: Frutescens Date: Tue, 2 Jul 2024 21:09:14 -0700 Subject: [PATCH 7/7] Fixed phase order --- src/phases.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index 4b98944c603..76d66f3a2d0 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4891,7 +4891,6 @@ export class AttemptCapturePhase extends PokemonPhase { } }, onComplete: () => { - this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.scene.gameData.setPokemonCaught(pokemon); this.catch(); } @@ -4960,6 +4959,7 @@ export class AttemptCapturePhase extends PokemonPhase { this.scene.ui.showText(i18next.t("battle:pokemonCaught", { pokemonName: pokemon.name }), null, () => { const end = () => { + this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex)); this.scene.pokemonInfoContainer.hide(); this.removePb(); this.end();