[P3] Fix start button cursor not being cleared properly in starter select (#4558)

This commit is contained in:
MokaStitcher 2024-10-04 22:47:12 +02:00 committed by GitHub
parent d362456501
commit 1947472f1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -308,13 +308,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private starterIconsCursorObj: Phaser.GameObjects.Image; private starterIconsCursorObj: Phaser.GameObjects.Image;
private valueLimitLabel: Phaser.GameObjects.Text; private valueLimitLabel: Phaser.GameObjects.Text;
private startCursorObj: Phaser.GameObjects.NineSlice; private startCursorObj: Phaser.GameObjects.NineSlice;
// private starterValueLabels: Phaser.GameObjects.Text[];
// private shinyIcons: Phaser.GameObjects.Image[][];
// private hiddenAbilityIcons: Phaser.GameObjects.Image[];
// private classicWinIcons: Phaser.GameObjects.Image[];
// private candyUpgradeIcon: Phaser.GameObjects.Image[];
// private candyUpgradeOverlayIcon: Phaser.GameObjects.Image[];
//
private iconAnimHandler: PokemonIconAnimHandler; private iconAnimHandler: PokemonIconAnimHandler;
//variables to keep track of the dynamically rendered list of instruction prompts for starter select //variables to keep track of the dynamically rendered list of instruction prompts for starter select
@ -1316,12 +1310,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
break; break;
case Button.UP: case Button.UP:
// UP from start button: go to pokemon in team if any, otherwise filter
this.startCursorObj.setVisible(false); this.startCursorObj.setVisible(false);
if (this.starterSpecies.length > 0) { if (this.starterSpecies.length > 0) {
this.starterIconsCursorIndex = this.starterSpecies.length - 1; this.starterIconsCursorIndex = this.starterSpecies.length - 1;
this.moveStarterIconsCursor(this.starterIconsCursorIndex); this.moveStarterIconsCursor(this.starterIconsCursorIndex);
} else { } else {
// up from start button with no Pokemon in the team > go to filter
this.startCursorObj.setVisible(false); this.startCursorObj.setVisible(false);
this.filterBarCursor = Math.max(1, this.filterBar.numFilters - 1); this.filterBarCursor = Math.max(1, this.filterBar.numFilters - 1);
this.setFilterMode(true); this.setFilterMode(true);
@ -1329,29 +1323,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
success = true; success = true;
break; break;
case Button.DOWN: case Button.DOWN:
// DOWN from start button: Go to filters
this.startCursorObj.setVisible(false); this.startCursorObj.setVisible(false);
if (this.starterSpecies.length > 0) { this.filterBarCursor = Math.max(1, this.filterBar.numFilters - 1);
this.starterIconsCursorIndex = 0; this.setFilterMode(true);
this.moveStarterIconsCursor(this.starterIconsCursorIndex);
} else {
// down from start button with no Pokemon in the team > go to filter
this.startCursorObj.setVisible(false);
this.filterBarCursor = Math.max(1, this.filterBar.numFilters - 1);
this.setFilterMode(true);
}
success = true; success = true;
break; break;
case Button.LEFT: case Button.LEFT:
this.startCursorObj.setVisible(false); if (numberOfStarters > 0) {
this.cursorObj.setVisible(true); this.startCursorObj.setVisible(false);
success = this.setCursor(onScreenFirstIndex + (onScreenNumberOfRows - 1) * 9 + 8); // set last column this.cursorObj.setVisible(true);
success = true; this.setCursor(onScreenFirstIndex + (onScreenNumberOfRows - 1) * 9 + 8); // set last column
success = true;
}
break; break;
case Button.RIGHT: case Button.RIGHT:
this.startCursorObj.setVisible(false); if (numberOfStarters > 0) {
this.cursorObj.setVisible(true); this.startCursorObj.setVisible(false);
success = this.setCursor(onScreenFirstIndex + (onScreenNumberOfRows - 1) * 9); // set first column this.cursorObj.setVisible(true);
success = true; this.setCursor(onScreenFirstIndex + (onScreenNumberOfRows - 1) * 9); // set first column
success = true;
}
break; break;
} }
} else if (this.filterMode) { } else if (this.filterMode) {
@ -1373,7 +1365,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
case Button.UP: case Button.UP:
if (this.filterBar.openDropDown) { if (this.filterBar.openDropDown) {
success = this.filterBar.decDropDownCursor(); success = this.filterBar.decDropDownCursor();
// else if there is filtered starters } else if (this.filterBarCursor === this.filterBar.numFilters - 1 && this.starterSpecies.length > 0) {
// UP from the last filter, move to start button
this.setFilterMode(false);
this.cursorObj.setVisible(false);
this.startCursorObj.setVisible(true);
success = true;
} else if (numberOfStarters > 0) { } else if (numberOfStarters > 0) {
// UP from filter bar to bottom of Pokemon list // UP from filter bar to bottom of Pokemon list
this.setFilterMode(false); this.setFilterMode(false);
@ -1392,6 +1389,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
case Button.DOWN: case Button.DOWN:
if (this.filterBar.openDropDown) { if (this.filterBar.openDropDown) {
success = this.filterBar.incDropDownCursor(); success = this.filterBar.incDropDownCursor();
} else if (this.filterBarCursor === this.filterBar.numFilters - 1 && this.starterSpecies.length > 0) {
// DOWN from the last filter, move to Pokemon in party if any
this.setFilterMode(false);
this.cursorObj.setVisible(false);
this.starterIconsCursorIndex = 0;
this.moveStarterIconsCursor(this.starterIconsCursorIndex);
success = true;
} else if (numberOfStarters > 0) { } else if (numberOfStarters > 0) {
// DOWN from filter bar to top of Pokemon list // DOWN from filter bar to top of Pokemon list
this.setFilterMode(false); this.setFilterMode(false);
@ -2656,9 +2660,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonShinyIcon.setTint(tint); this.pokemonShinyIcon.setTint(tint);
this.setSpecies(species); this.setSpecies(species);
this.updateInstructions(); this.updateInstructions();
} else {
console.warn("Species is undefined for cursor position", cursor);
this.setFilterMode(true);
} }
} }
@ -3326,6 +3327,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
} }
this.moveStarterIconsCursor(this.starterIconsCursorIndex); this.moveStarterIconsCursor(this.starterIconsCursorIndex);
} else if (this.startCursorObj.visible && this.starterSpecies.length === 0) {
// On the start button and no more Pokemon in party
this.startCursorObj.setVisible(false);
if (this.filteredStarterContainers.length > 0) {
// Back to the first Pokemon if there is one
this.cursorObj.setVisible(true);
this.setCursor(0 + this.scrollCursor * 9);
} else {
// Back to filters
this.filterBarCursor = Math.max(1, this.filterBar.numFilters - 1);
this.setFilterMode(true);
}
} }
this.tryUpdateValue(); this.tryUpdateValue();