2023-04-11 05:24:55 +01:00
|
|
|
import BattleScene, { Button } from "../battle-scene";
|
2023-03-28 19:54:52 +01:00
|
|
|
import UI, { Mode } from "./ui";
|
|
|
|
|
|
|
|
export default abstract class UiHandler {
|
|
|
|
protected scene: BattleScene;
|
|
|
|
protected mode: integer;
|
|
|
|
protected cursor: integer = 0;
|
2023-03-29 05:31:25 +01:00
|
|
|
public active: boolean = false;
|
2023-03-28 19:54:52 +01:00
|
|
|
|
|
|
|
constructor(scene: BattleScene, mode: Mode) {
|
|
|
|
this.scene = scene;
|
|
|
|
this.mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract setup(): void;
|
|
|
|
|
|
|
|
show(_args: any[]): void {
|
|
|
|
this.active = true;
|
|
|
|
}
|
|
|
|
|
2023-04-11 05:24:55 +01:00
|
|
|
abstract processInput(button: Button);
|
2023-03-28 19:54:52 +01:00
|
|
|
|
|
|
|
getUi() {
|
|
|
|
return this.scene.ui;
|
|
|
|
}
|
|
|
|
|
2023-03-31 04:02:35 +01:00
|
|
|
getCursor(): integer {
|
|
|
|
return this.cursor;
|
|
|
|
}
|
|
|
|
|
2023-03-28 19:54:52 +01:00
|
|
|
setCursor(cursor: integer): boolean {
|
|
|
|
const changed = this.cursor !== cursor;
|
|
|
|
if (changed)
|
|
|
|
this.cursor = cursor;
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
clear() {
|
|
|
|
this.active = false;
|
|
|
|
}
|
|
|
|
}
|