pokerogue/src/ui/awaitable-ui-handler.ts
Sirz Benjie 5854b21da0
[Refactor] Remove circular imports part 1 (#5663)
* Extract Mode enum out of UI and into its own file

Reduces circular imports from 909 to 773

* Move around utility files

Reduces cyclical dependencies from 773 to 765

* Remove starterColors and bypassLogin from battle-scene

Reduces cyclical dependencies from 765 to 623

* Fix test runner error

* Update import for bypassLogin in test

* Update mocks for utils in tests

* Fix broken tests

* Update selectWithTera override

* Update path for utils in ab-attr.ts

* Update path for utils in ability-class.ts

* Fix utils import path in healer.test.ts
2025-04-19 11:57:03 +00:00

53 lines
1.5 KiB
TypeScript

import type { UiMode } from "#enums/ui-mode";
import UiHandler from "./ui-handler";
import { Button } from "#enums/buttons";
import { globalScene } from "#app/global-scene";
export default abstract class AwaitableUiHandler extends UiHandler {
protected awaitingActionInput: boolean;
protected onActionInput: Function | null;
public tutorialActive = false;
public tutorialOverlay: Phaser.GameObjects.Rectangle;
constructor(mode: UiMode | null = null) {
super(mode);
}
processTutorialInput(button: Button): boolean {
if ((button === Button.ACTION || button === Button.CANCEL) && this.onActionInput) {
this.getUi().playSelect();
const originalOnActionInput = this.onActionInput;
this.onActionInput = null;
originalOnActionInput();
this.awaitingActionInput = false;
return true;
}
return false;
}
/**
* Create a semi transparent overlay that will get shown during tutorials
* @param container the container to add the overlay to
*/
initTutorialOverlay(container: Phaser.GameObjects.Container) {
if (!this.tutorialOverlay) {
this.tutorialOverlay = new Phaser.GameObjects.Rectangle(
globalScene,
-1,
-1,
globalScene.scaledCanvas.width,
globalScene.scaledCanvas.height,
0x070707,
);
this.tutorialOverlay.setName("tutorial-overlay");
this.tutorialOverlay.setOrigin(0, 0);
this.tutorialOverlay.setAlpha(0);
}
if (container) {
container.add(this.tutorialOverlay);
}
}
}