Add 2 second confirmation delay when overwriting save
parent
5437d315c0
commit
689d4700c1
|
@ -100,10 +100,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
||||||
if (this.config.delay) {
|
if (this.config.delay) {
|
||||||
this.blockInput = true;
|
this.blockInput = true;
|
||||||
this.optionSelectText.setAlpha(0.5);
|
this.optionSelectText.setAlpha(0.5);
|
||||||
this.scene.time.delayedCall(Utils.fixedInt(this.config.delay), () => {
|
this.scene.time.delayedCall(Utils.fixedInt(this.config.delay), () => this.unblockInput());
|
||||||
this.blockInput = false;
|
|
||||||
this.optionSelectText.setAlpha(1);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -119,8 +116,10 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
||||||
let playSound = true;
|
let playSound = true;
|
||||||
|
|
||||||
if (button === Button.ACTION || button === Button.CANCEL) {
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||||
if (this.blockInput)
|
if (this.blockInput) {
|
||||||
|
ui.playError();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
if (button === Button.CANCEL) {
|
if (button === Button.CANCEL) {
|
||||||
|
@ -156,6 +155,14 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unblockInput(): void {
|
||||||
|
if (!this.blockInput)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.blockInput = false;
|
||||||
|
this.optionSelectText.setAlpha(1);
|
||||||
|
}
|
||||||
|
|
||||||
getOptionsWithScroll(): OptionSelectItem[] {
|
getOptionsWithScroll(): OptionSelectItem[] {
|
||||||
if (!this.config)
|
if (!this.config)
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -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 AbstractOptionSelectUiHandler, { OptionSelectConfig } from "./abstact-option-select-ui-handler";
|
||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
|
|
||||||
|
@ -47,6 +47,13 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processInput(button: Button): boolean {
|
||||||
|
if (button === Button.CANCEL && this.blockInput)
|
||||||
|
this.unblockInput();
|
||||||
|
|
||||||
|
return super.processInput(button);
|
||||||
|
}
|
||||||
|
|
||||||
setCursor(cursor: integer): boolean {
|
setCursor(cursor: integer): boolean {
|
||||||
const ret = super.setCursor(cursor);
|
const ret = super.setCursor(cursor);
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
||||||
ui.setOverlayMode(Mode.CONFIRM, () => saveAndCallback(), () => {
|
ui.setOverlayMode(Mode.CONFIRM, () => saveAndCallback(), () => {
|
||||||
ui.revertMode();
|
ui.revertMode();
|
||||||
ui.showText(null, 0);
|
ui.showText(null, 0);
|
||||||
}, false, 0, 19);
|
}, false, 0, 19, 2000);
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
saveAndCallback();
|
saveAndCallback();
|
||||||
|
|
Loading…
Reference in New Issue