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:
|
case MenuOptions.SAVE_AND_QUIT:
|
||||||
if (this.scene.currentBattle) {
|
if (this.scene.currentBattle) {
|
||||||
success = true;
|
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) {
|
if (this.scene.currentBattle.turn > 1) {
|
||||||
ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => {
|
ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => {
|
||||||
if (!this.active) {
|
if (!this.active) {
|
||||||
this.showText("", 0);
|
this.showText("", 0);
|
||||||
return;
|
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();
|
ui.revertMode();
|
||||||
this.showText("", 0);
|
this.showText("", 0);
|
||||||
}, false, -98);
|
}, false, -98);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true));
|
doSaveQuit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error = true;
|
error = true;
|
||||||
@ -462,12 +471,14 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||||||
case MenuOptions.LOG_OUT:
|
case MenuOptions.LOG_OUT:
|
||||||
success = true;
|
success = true;
|
||||||
const doLogout = () => {
|
const doLogout = () => {
|
||||||
Utils.apiFetch("account/logout", true).then(res => {
|
ui.setMode(Mode.LOADING, {
|
||||||
if (!res.ok) {
|
buttonActions: [], fadeOut: () => Utils.apiFetch("account/logout", true).then(res => {
|
||||||
console.error(`Log out failed (${res.status}: ${res.statusText})`);
|
if (!res.ok) {
|
||||||
}
|
console.error(`Log out failed (${res.status}: ${res.statusText})`);
|
||||||
Utils.removeCookie(Utils.sessionIdKey);
|
}
|
||||||
updateUserInfo().then(() => this.scene.reset(true, true));
|
Utils.removeCookie(Utils.sessionIdKey);
|
||||||
|
updateUserInfo().then(() => this.scene.reset(true, true));
|
||||||
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (this.scene.currentBattle) {
|
if (this.scene.currentBattle) {
|
||||||
|
@ -83,6 +83,20 @@ export abstract class ModalUiHandler extends UiHandler {
|
|||||||
show(args: any[]): boolean {
|
show(args: any[]): boolean {
|
||||||
if (args.length >= 1 && "buttonActions" in args[0]) {
|
if (args.length >= 1 && "buttonActions" in args[0]) {
|
||||||
super.show(args);
|
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;
|
const config = args[0] as ModalConfig;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user