[QOL] Add input delay for skipping egg summary (#4644)
This commit is contained in:
parent
8981f0e7a8
commit
676322e800
|
@ -33,7 +33,7 @@ export class EggLapsePhase extends Phase {
|
|||
if (eggsToHatchCount > 0) {
|
||||
if (eggsToHatchCount >= this.minEggsToSkip && this.scene.eggSkipPreference === 1) {
|
||||
this.scene.ui.showText(i18next.t("battle:eggHatching"), 0, () => {
|
||||
// show prompt for skip
|
||||
// show prompt for skip, blocking inputs for 1 second
|
||||
this.scene.ui.showText(i18next.t("battle:eggSkipPrompt"), 0);
|
||||
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
||||
this.hatchEggsSkipped(eggsToHatch);
|
||||
|
@ -41,7 +41,8 @@ export class EggLapsePhase extends Phase {
|
|||
}, () => {
|
||||
this.hatchEggsRegular(eggsToHatch);
|
||||
this.end();
|
||||
}
|
||||
},
|
||||
null, null, null, 1000, true
|
||||
);
|
||||
}, 100, true);
|
||||
} else if (eggsToHatchCount >= this.minEggsToSkip && this.scene.eggSkipPreference === 2) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import BattleScene from "#app/battle-scene";
|
||||
import { Phase } from "#app/phase";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import EggHatchSceneHandler from "#app/ui/egg-hatch-scene-handler";
|
||||
import { EggHatchData } from "#app/data/egg-hatch-data";
|
||||
|
||||
/**
|
||||
|
@ -11,7 +10,6 @@ import { EggHatchData } from "#app/data/egg-hatch-data";
|
|||
*/
|
||||
export class EggSummaryPhase extends Phase {
|
||||
private eggHatchData: EggHatchData[];
|
||||
private eggHatchHandler: EggHatchSceneHandler;
|
||||
|
||||
constructor(scene: BattleScene, eggHatchData: EggHatchData[]) {
|
||||
super(scene);
|
||||
|
@ -26,7 +24,6 @@ export class EggSummaryPhase extends Phase {
|
|||
if (i >= this.eggHatchData.length) {
|
||||
this.scene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
|
||||
this.scene.fadeOutBgm(undefined, false);
|
||||
this.eggHatchHandler = this.scene.ui.getHandler() as EggHatchSceneHandler;
|
||||
});
|
||||
|
||||
} else {
|
||||
|
|
|
@ -165,6 +165,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||
if (this.config.delay) {
|
||||
this.blockInput = true;
|
||||
this.optionSelectText.setAlpha(0.5);
|
||||
this.cursorObj?.setAlpha(0.8);
|
||||
this.scene.time.delayedCall(Utils.fixedInt(this.config.delay), () => this.unblockInput());
|
||||
}
|
||||
|
||||
|
@ -256,6 +257,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||
|
||||
this.blockInput = false;
|
||||
this.optionSelectText.setAlpha(1);
|
||||
this.cursorObj?.setAlpha(1);
|
||||
}
|
||||
|
||||
getOptionsWithScroll(): OptionSelectItem[] {
|
||||
|
|
|
@ -76,7 +76,8 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
|
|||
}
|
||||
}
|
||||
],
|
||||
delay: args.length >= 6 && args[5] !== null ? args[5] as integer : 0
|
||||
delay: args.length >= 6 && args[5] !== null ? args[5] as number : 0,
|
||||
noCancel: args.length >= 7 && args[6] !== null ? args[6] as boolean : false,
|
||||
};
|
||||
|
||||
super.show([ config ]);
|
||||
|
@ -96,7 +97,7 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
|
|||
}
|
||||
|
||||
processInput(button: Button): boolean {
|
||||
if (button === Button.CANCEL && this.blockInput) {
|
||||
if (button === Button.CANCEL && this.blockInput && !this.config?.noCancel) {
|
||||
this.unblockInput();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||
private scrollGridHandler : ScrollableGridUiHandler;
|
||||
private cursorObj: Phaser.GameObjects.Image;
|
||||
|
||||
/** used to add a delay before which it is not possible to exit the summary */
|
||||
private blockExit: boolean;
|
||||
|
||||
/**
|
||||
* Allows subscribers to listen for events
|
||||
*
|
||||
|
@ -168,6 +171,13 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||
this.setCursor(0);
|
||||
|
||||
this.scene.playSoundWithoutBgm("evolution_fanfare");
|
||||
|
||||
// Prevent exiting the egg summary for 2 seconds if the egg hatching
|
||||
// was skipped automatically and for 1 second otherwise
|
||||
const exitBlockingDuration = (this.scene.eggSkipPreference === 2) ? 2000 : 1000;
|
||||
this.blockExit = true;
|
||||
this.scene.time.delayedCall(exitBlockingDuration, () => this.blockExit = false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -203,13 +213,17 @@ export default class EggSummaryUiHandler extends MessageUiHandler {
|
|||
const ui = this.getUi();
|
||||
|
||||
let success = false;
|
||||
const error = false;
|
||||
let error = false;
|
||||
if (button === Button.CANCEL) {
|
||||
const phase = this.scene.getCurrentPhase();
|
||||
if (phase instanceof EggSummaryPhase) {
|
||||
phase.end();
|
||||
if (!this.blockExit) {
|
||||
const phase = this.scene.getCurrentPhase();
|
||||
if (phase instanceof EggSummaryPhase) {
|
||||
phase.end();
|
||||
}
|
||||
success = true;
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
success = true;
|
||||
} else {
|
||||
this.scrollGridHandler.processInput(button);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue