mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Added LOADING mode to prevent spamming from SAVE_AND_QUIT and LOG_OUT buttons, and added option to set black background for LOADING mode
This commit is contained in:
parent
2c975fb60b
commit
848cc1d23f
@ -441,19 +441,28 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
case MenuOptions.SAVE_AND_QUIT:
|
||||
if (this.scene.currentBattle) {
|
||||
success = true;
|
||||
const doSaveQuit = () => {
|
||||
ui.setMode(Mode.LOADING, {
|
||||
buttonActions: [], fadeOut: () =>
|
||||
this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => {
|
||||
|
||||
this.scene.reset(true);
|
||||
})
|
||||
});
|
||||
};
|
||||
if (this.scene.currentBattle.turn > 1) {
|
||||
ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => {
|
||||
if (!this.active) {
|
||||
this.showText("", 0);
|
||||
return;
|
||||
}
|
||||
ui.setOverlayMode(Mode.CONFIRM, () => this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)), () => {
|
||||
ui.setOverlayMode(Mode.CONFIRM, doSaveQuit, () => {
|
||||
ui.revertMode();
|
||||
this.showText("", 0);
|
||||
}, false, -98);
|
||||
});
|
||||
} else {
|
||||
this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true));
|
||||
doSaveQuit();
|
||||
}
|
||||
} else {
|
||||
error = true;
|
||||
@ -462,12 +471,14 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
case MenuOptions.LOG_OUT:
|
||||
success = true;
|
||||
const doLogout = () => {
|
||||
Utils.apiFetch("account/logout", true).then(res => {
|
||||
ui.setMode(Mode.LOADING, {
|
||||
buttonActions: [], fadeOut: () => Utils.apiFetch("account/logout", true).then(res => {
|
||||
if (!res.ok) {
|
||||
console.error(`Log out failed (${res.status}: ${res.statusText})`);
|
||||
}
|
||||
Utils.removeCookie(Utils.sessionIdKey);
|
||||
updateUserInfo().then(() => this.scene.reset(true, true));
|
||||
})
|
||||
});
|
||||
};
|
||||
if (this.scene.currentBattle) {
|
||||
|
@ -83,6 +83,20 @@ export abstract class ModalUiHandler extends UiHandler {
|
||||
show(args: any[]): boolean {
|
||||
if (args.length >= 1 && "buttonActions" in args[0]) {
|
||||
super.show(args);
|
||||
if ("fadeOut" in args[0]) {
|
||||
const overlay = this.scene.add.rectangle((( (this.getWidth() + (this.getMargin()[0] - this.getMargin()[3]))) / 2), ((this.getHeight() + (this.getMargin()[1] - this.getMargin()[2])) / 2),this.scene.game.canvas.width ,this.scene.game.canvas.height , 0);
|
||||
overlay.setName("rect-ui-overlay-modal");
|
||||
overlay.setAlpha(0);
|
||||
this.modalContainer.add(overlay);
|
||||
this.modalContainer.moveTo(overlay,0);
|
||||
this.scene.tweens.add({
|
||||
targets: overlay,
|
||||
alpha: 1,
|
||||
duration: 250,
|
||||
ease: "Sine.easeOut",
|
||||
onComplete: args[0].fadeOut
|
||||
});
|
||||
}
|
||||
|
||||
const config = args[0] as ModalConfig;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user