mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
[P3Bug][UI] Fix run history scrolling and other small bugs (#4326)
This commit is contained in:
parent
2610a64980
commit
4feb45f532
@ -13,7 +13,7 @@ import { RunEntry } from "../system/game-data";
|
|||||||
import { PlayerGender } from "#enums/player-gender";
|
import { PlayerGender } from "#enums/player-gender";
|
||||||
import { TrainerVariant } from "../field/trainer";
|
import { TrainerVariant } from "../field/trainer";
|
||||||
|
|
||||||
export type RunSelectCallback = (cursor: integer) => void;
|
export type RunSelectCallback = (cursor: number) => void;
|
||||||
|
|
||||||
export const RUN_HISTORY_LIMIT: number = 25;
|
export const RUN_HISTORY_LIMIT: number = 25;
|
||||||
|
|
||||||
@ -25,15 +25,15 @@ export const RUN_HISTORY_LIMIT: number = 25;
|
|||||||
*/
|
*/
|
||||||
export default class RunHistoryUiHandler extends MessageUiHandler {
|
export default class RunHistoryUiHandler extends MessageUiHandler {
|
||||||
|
|
||||||
|
private readonly maxRows = 3;
|
||||||
|
|
||||||
private runSelectContainer: Phaser.GameObjects.Container;
|
private runSelectContainer: Phaser.GameObjects.Container;
|
||||||
private runsContainer: Phaser.GameObjects.Container;
|
private runsContainer: Phaser.GameObjects.Container;
|
||||||
private runSelectMessageBox: Phaser.GameObjects.NineSlice;
|
|
||||||
private runSelectMessageBoxContainer: Phaser.GameObjects.Container;
|
|
||||||
private runs: RunEntryContainer[];
|
private runs: RunEntryContainer[];
|
||||||
|
|
||||||
private runSelectCallback: RunSelectCallback | null;
|
private runSelectCallback: RunSelectCallback | null;
|
||||||
|
|
||||||
private scrollCursor: integer = 0;
|
private scrollCursor: number = 0;
|
||||||
|
|
||||||
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
||||||
|
|
||||||
@ -74,8 +74,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
this.getUi().bringToTop(this.runSelectContainer);
|
this.getUi().bringToTop(this.runSelectContainer);
|
||||||
this.runSelectContainer.setVisible(true);
|
this.runSelectContainer.setVisible(true);
|
||||||
this.populateRuns(this.scene);
|
this.populateRuns(this.scene).then(() => {
|
||||||
|
|
||||||
this.setScrollCursor(0);
|
this.setScrollCursor(0);
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
|
|
||||||
@ -83,6 +82,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
|
|||||||
if (this.runs.length === 0) {
|
if (this.runs.length === 0) {
|
||||||
this.clearCursor();
|
this.clearCursor();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -122,13 +122,21 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
|
|||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
} else if (this.scrollCursor) {
|
} else if (this.scrollCursor) {
|
||||||
success = this.setScrollCursor(this.scrollCursor - 1);
|
success = this.setScrollCursor(this.scrollCursor - 1);
|
||||||
|
} else if (this.runs.length > 1) {
|
||||||
|
// wrap around to the bottom
|
||||||
|
success = this.setCursor(Math.min(this.runs.length - 1, this.maxRows - 1));
|
||||||
|
success = this.setScrollCursor(Math.max(0, this.runs.length - this.maxRows)) || success;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
if (this.cursor < 2) {
|
if (this.cursor < Math.min(this.maxRows - 1, this.runs.length - this.scrollCursor - 1)) {
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
} else if (this.scrollCursor < this.runs.length - 3) {
|
} else if (this.scrollCursor < this.runs.length - this.maxRows) {
|
||||||
success = this.setScrollCursor(this.scrollCursor + 1);
|
success = this.setScrollCursor(this.scrollCursor + 1);
|
||||||
|
} else if (this.runs.length > 1) {
|
||||||
|
// wrap around to the top
|
||||||
|
success = this.setCursor(0);
|
||||||
|
success = this.setScrollCursor(0) || success;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -218,6 +226,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler {
|
|||||||
override clear() {
|
override clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
this.runSelectContainer.setVisible(false);
|
this.runSelectContainer.setVisible(false);
|
||||||
|
this.setScrollCursor(0);
|
||||||
this.clearCursor();
|
this.clearCursor();
|
||||||
this.runSelectCallback = null;
|
this.runSelectCallback = null;
|
||||||
this.clearRuns();
|
this.clearRuns();
|
||||||
@ -360,7 +369,7 @@ class RunEntryContainer extends Phaser.GameObjects.Container {
|
|||||||
// The code here does not account for icon weirdness.
|
// The code here does not account for icon weirdness.
|
||||||
const pokemonIconsContainer = this.scene.add.container(140, 17);
|
const pokemonIconsContainer = this.scene.add.container(140, 17);
|
||||||
|
|
||||||
data.party.forEach((p: PokemonData, i: integer) => {
|
data.party.forEach((p: PokemonData, i: number) => {
|
||||||
const iconContainer = this.scene.add.container(26 * i, 0);
|
const iconContainer = this.scene.add.container(26 * i, 0);
|
||||||
iconContainer.setScale(0.75);
|
iconContainer.setScale(0.75);
|
||||||
const pokemon = p.toPokemon(this.scene);
|
const pokemon = p.toPokemon(this.scene);
|
||||||
|
@ -49,15 +49,11 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||||||
private runResultContainer: Phaser.GameObjects.Container;
|
private runResultContainer: Phaser.GameObjects.Container;
|
||||||
private runInfoContainer: Phaser.GameObjects.Container;
|
private runInfoContainer: Phaser.GameObjects.Container;
|
||||||
private partyContainer: Phaser.GameObjects.Container;
|
private partyContainer: Phaser.GameObjects.Container;
|
||||||
private partyHeldItemsContainer: Phaser.GameObjects.Container;
|
|
||||||
private statsBgWidth: integer;
|
private statsBgWidth: integer;
|
||||||
private partyContainerHeight: integer;
|
|
||||||
private partyContainerWidth: integer;
|
|
||||||
|
|
||||||
private hallofFameContainer: Phaser.GameObjects.Container;
|
private hallofFameContainer: Phaser.GameObjects.Container;
|
||||||
private endCardContainer: Phaser.GameObjects.Container;
|
private endCardContainer: Phaser.GameObjects.Container;
|
||||||
|
|
||||||
private partyInfo: Phaser.GameObjects.Container[];
|
|
||||||
private partyVisibility: Boolean;
|
private partyVisibility: Boolean;
|
||||||
private modifiersModule: any;
|
private modifiersModule: any;
|
||||||
|
|
||||||
@ -863,7 +859,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||||||
private buttonCycleOption(button: Button) {
|
private buttonCycleOption(button: Button) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case Button.CYCLE_FORM:
|
case Button.CYCLE_FORM:
|
||||||
if (this.isVictory) {
|
if (this.isVictory && this.pageMode !== RunInfoUiMode.HALL_OF_FAME) {
|
||||||
if (!this.endCardContainer || !this.endCardContainer.visible) {
|
if (!this.endCardContainer || !this.endCardContainer.visible) {
|
||||||
this.createVictorySplash();
|
this.createVictorySplash();
|
||||||
this.endCardContainer.setVisible(true);
|
this.endCardContainer.setVisible(true);
|
||||||
@ -877,7 +873,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.CYCLE_SHINY:
|
case Button.CYCLE_SHINY:
|
||||||
if (this.isVictory) {
|
if (this.isVictory && this.pageMode !== RunInfoUiMode.ENDING_ART) {
|
||||||
if (!this.hallofFameContainer.visible) {
|
if (!this.hallofFameContainer.visible) {
|
||||||
this.hallofFameContainer.setVisible(true);
|
this.hallofFameContainer.setVisible(true);
|
||||||
this.pageMode = RunInfoUiMode.HALL_OF_FAME;
|
this.pageMode = RunInfoUiMode.HALL_OF_FAME;
|
||||||
@ -888,7 +884,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.CYCLE_ABILITY:
|
case Button.CYCLE_ABILITY:
|
||||||
if (this.runInfo.modifiers.length !== 0) {
|
if (this.runInfo.modifiers.length !== 0 && this.pageMode === RunInfoUiMode.MAIN) {
|
||||||
if (this.partyVisibility) {
|
if (this.partyVisibility) {
|
||||||
this.showParty(false);
|
this.showParty(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,7 +139,8 @@ const noTransitionModes = [
|
|||||||
Mode.TEST_DIALOGUE,
|
Mode.TEST_DIALOGUE,
|
||||||
Mode.AUTO_COMPLETE,
|
Mode.AUTO_COMPLETE,
|
||||||
Mode.ADMIN,
|
Mode.ADMIN,
|
||||||
Mode.MYSTERY_ENCOUNTER
|
Mode.MYSTERY_ENCOUNTER,
|
||||||
|
Mode.RUN_INFO
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class UI extends Phaser.GameObjects.Container {
|
export default class UI extends Phaser.GameObjects.Container {
|
||||||
|
Loading…
Reference in New Issue
Block a user