mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-20 15:22:19 +02:00
Storing previous pokémon for cancel button
This commit is contained in:
parent
5d2e477744
commit
c633c3bb22
@ -659,6 +659,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
// Filter bar sits above everything, except the message box
|
// Filter bar sits above everything, except the message box
|
||||||
this.starterSelectContainer.bringToTop(this.starterSelectMessageBoxContainer);
|
this.starterSelectContainer.bringToTop(this.starterSelectMessageBoxContainer);
|
||||||
|
|
||||||
|
this.previousSpecies = [];
|
||||||
|
this.previousStarterAttributes = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
show(args: any[]): boolean {
|
show(args: any[]): boolean {
|
||||||
@ -1094,8 +1097,19 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
if (this.statsMode) {
|
if (this.statsMode) {
|
||||||
this.toggleStatsMode(false);
|
this.toggleStatsMode(false);
|
||||||
success = true;
|
success = true;
|
||||||
|
} else if (this.previousSpecies.length > 0) {
|
||||||
|
this.blockInput = true;
|
||||||
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
|
const species = this.previousSpecies.pop();
|
||||||
|
const starterAttributes = this.previousStarterAttributes.pop();
|
||||||
|
this.moveInfoOverlay.clear();
|
||||||
|
this.clearText();
|
||||||
|
ui.setModeForceTransition(Mode.POKEDEX_PAGE, species, starterAttributes);
|
||||||
|
success = true;
|
||||||
|
});
|
||||||
|
this.blockInput = false;
|
||||||
} else {
|
} else {
|
||||||
this.getUi().revertMode();
|
ui.revertMode();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1510,6 +1524,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
? (preSpecies ?? this.species).getFormNameToDisplay(preFormIndex, true)
|
? (preSpecies ?? this.species).getFormNameToDisplay(preFormIndex, true)
|
||||||
: (preSpecies ?? this.species).getExpandedSpeciesName(),
|
: (preSpecies ?? this.species).getExpandedSpeciesName(),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
this.previousSpecies.push(this.species);
|
||||||
|
this.previousStarterAttributes.push({ ...this.savedStarterAttributes });
|
||||||
const newSpecies = allSpecies.find(
|
const newSpecies = allSpecies.find(
|
||||||
species => species.speciesId === pokemonPrevolutions[pre.speciesId],
|
species => species.speciesId === pokemonPrevolutions[pre.speciesId],
|
||||||
);
|
);
|
||||||
@ -1561,6 +1577,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
: (evoSpecies ?? this.species).getExpandedSpeciesName(),
|
: (evoSpecies ?? this.species).getExpandedSpeciesName(),
|
||||||
style: isCaughtEvo && isFormCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
style: isCaughtEvo && isFormCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
this.previousSpecies.push(this.species);
|
||||||
|
this.previousStarterAttributes.push({ ...this.savedStarterAttributes });
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
this.savedStarterAttributes.form = newFormIndex;
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
@ -1601,6 +1619,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
label: label,
|
label: label,
|
||||||
style: isFormCaught ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
style: isFormCaught ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
this.previousSpecies.push(this.species);
|
||||||
|
this.previousStarterAttributes.push({ ...this.savedStarterAttributes });
|
||||||
const newSpecies = this.species;
|
const newSpecies = this.species;
|
||||||
const newFormIndex = this.species.forms.find(f => f.formKey === bf.formKey)?.formIndex;
|
const newFormIndex = this.species.forms.find(f => f.formKey === bf.formKey)?.formIndex;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
@ -1960,6 +1980,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
this.blockInput = true;
|
this.blockInput = true;
|
||||||
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
|
// Always go back to first selection after scrolling around
|
||||||
|
if (this.previousSpecies.length === 0) {
|
||||||
|
this.previousSpecies.push(this.species);
|
||||||
|
this.previousStarterAttributes.push({ ...this.savedStarterAttributes });
|
||||||
|
}
|
||||||
let newSpecies: PokemonSpecies;
|
let newSpecies: PokemonSpecies;
|
||||||
if (this.filteredIndices) {
|
if (this.filteredIndices) {
|
||||||
const index = this.filteredIndices.findIndex(id => id === this.species.speciesId);
|
const index = this.filteredIndices.findIndex(id => id === this.species.speciesId);
|
||||||
@ -1989,6 +2014,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
|
// Always go back to first selection after scrolling around
|
||||||
|
if (this.previousSpecies.length === 0) {
|
||||||
|
this.previousSpecies.push(this.species);
|
||||||
|
this.previousStarterAttributes.push({ ...this.savedStarterAttributes });
|
||||||
|
}
|
||||||
let newSpecies: PokemonSpecies;
|
let newSpecies: PokemonSpecies;
|
||||||
if (this.filteredIndices) {
|
if (this.filteredIndices) {
|
||||||
const index = this.filteredIndices.findIndex(id => id === this.species.speciesId);
|
const index = this.filteredIndices.findIndex(id => id === this.species.speciesId);
|
||||||
|
Loading…
Reference in New Issue
Block a user