Add 2 second confirmation delay when overwriting save

pull/55/head
Flashfyre 2024-04-07 10:28:23 -04:00
parent 5437d315c0
commit 689d4700c1
3 changed files with 21 additions and 7 deletions

View File

@ -100,10 +100,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
if (this.config.delay) {
this.blockInput = true;
this.optionSelectText.setAlpha(0.5);
this.scene.time.delayedCall(Utils.fixedInt(this.config.delay), () => {
this.blockInput = false;
this.optionSelectText.setAlpha(1);
});
this.scene.time.delayedCall(Utils.fixedInt(this.config.delay), () => this.unblockInput());
}
return true;
@ -119,8 +116,10 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
let playSound = true;
if (button === Button.ACTION || button === Button.CANCEL) {
if (this.blockInput)
if (this.blockInput) {
ui.playError();
return false;
}
success = true;
if (button === Button.CANCEL) {
@ -156,6 +155,14 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
return success;
}
unblockInput(): void {
if (!this.blockInput)
return;
this.blockInput = false;
this.optionSelectText.setAlpha(1);
}
getOptionsWithScroll(): OptionSelectItem[] {
if (!this.config)
return [];

View File

@ -1,4 +1,4 @@
import BattleScene from "../battle-scene";
import BattleScene, { Button } from "../battle-scene";
import AbstractOptionSelectUiHandler, { OptionSelectConfig } from "./abstact-option-select-ui-handler";
import { Mode } from "./ui";
@ -47,6 +47,13 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
return false;
}
processInput(button: Button): boolean {
if (button === Button.CANCEL && this.blockInput)
this.unblockInput();
return super.processInput(button);
}
setCursor(cursor: integer): boolean {
const ret = super.setCursor(cursor);

View File

@ -112,7 +112,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
ui.setOverlayMode(Mode.CONFIRM, () => saveAndCallback(), () => {
ui.revertMode();
ui.showText(null, 0);
}, false, 0, 19);
}, false, 0, 19, 2000);
});
} else
saveAndCallback();