mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-23 15:59:26 +02:00
[ui] partially revert loading behavior introduced with save preview
This commit is contained in:
parent
6ad5ba972c
commit
334962ee2d
@ -12,7 +12,7 @@ import { Mode } from "./ui";
|
|||||||
import { addWindow } from "./ui-theme";
|
import { addWindow } from "./ui-theme";
|
||||||
import { RunDisplayMode } from "#app/ui/run-info-ui-handler";
|
import { RunDisplayMode } from "#app/ui/run-info-ui-handler";
|
||||||
|
|
||||||
const sessionSlotCount = 5;
|
const SESSION_SLOTS_COUNT = 5;
|
||||||
|
|
||||||
export enum SaveSlotUiMode {
|
export enum SaveSlotUiMode {
|
||||||
LOAD,
|
LOAD,
|
||||||
@ -84,12 +84,10 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
|||||||
this.saveSlotSelectCallback = args[1] as SaveSlotSelectCallback;
|
this.saveSlotSelectCallback = args[1] as SaveSlotSelectCallback;
|
||||||
|
|
||||||
this.saveSlotSelectContainer.setVisible(true);
|
this.saveSlotSelectContainer.setVisible(true);
|
||||||
this.populateSessionSlots()
|
this.populateSessionSlots();
|
||||||
.then(() => {
|
|
||||||
this.setScrollCursor(0);
|
this.setScrollCursor(0);
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +161,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
|||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
if (this.cursor < 2) {
|
if (this.cursor < 2) {
|
||||||
success = this.setCursor(this.cursor + 1, this.cursor);
|
success = this.setCursor(this.cursor + 1, this.cursor);
|
||||||
} else if (this.scrollCursor < sessionSlotCount - 3) {
|
} else if (this.scrollCursor < SESSION_SLOTS_COUNT - 3) {
|
||||||
success = this.setScrollCursor(this.scrollCursor + 1, cursorPosition);
|
success = this.setScrollCursor(this.scrollCursor + 1, cursorPosition);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -184,13 +182,19 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
|||||||
return success || error;
|
return success || error;
|
||||||
}
|
}
|
||||||
|
|
||||||
async populateSessionSlots() {
|
populateSessionSlots() {
|
||||||
for (let s = 0; s < sessionSlotCount; s++) {
|
for (let s = 0; s < SESSION_SLOTS_COUNT; s++) {
|
||||||
const sessionSlot = new SessionSlot(this.scene, s);
|
const sessionSlot = new SessionSlot(this.scene, s);
|
||||||
await sessionSlot.load();
|
|
||||||
this.scene.add.existing(sessionSlot);
|
this.scene.add.existing(sessionSlot);
|
||||||
this.sessionSlotsContainer.add(sessionSlot);
|
this.sessionSlotsContainer.add(sessionSlot);
|
||||||
this.sessionSlots.push(sessionSlot);
|
this.sessionSlots.push(sessionSlot);
|
||||||
|
sessionSlot.load().then((success) => {
|
||||||
|
// If the cursor was moved to this slot while the session was loading
|
||||||
|
// call setCursor again to shift the slot position and show the arrow for save preview
|
||||||
|
if (success && (this.cursor + this.scrollCursor) === s) {
|
||||||
|
this.setCursor(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +395,10 @@ class SessionSlot extends Phaser.GameObjects.Container {
|
|||||||
load(): Promise<boolean> {
|
load(): Promise<boolean> {
|
||||||
return new Promise<boolean>(resolve => {
|
return new Promise<boolean>(resolve => {
|
||||||
this.scene.gameData.getSession(this.slotId).then(async sessionData => {
|
this.scene.gameData.getSession(this.slotId).then(async sessionData => {
|
||||||
|
// Ignore the results if the view was exited
|
||||||
|
if (!this.active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!sessionData) {
|
if (!sessionData) {
|
||||||
this.hasData = false;
|
this.hasData = false;
|
||||||
this.loadingLabel.setText(i18next.t("saveSlotSelectUiHandler:empty"));
|
this.loadingLabel.setText(i18next.t("saveSlotSelectUiHandler:empty"));
|
||||||
|
Loading…
Reference in New Issue
Block a user