pokerogue/src/ui/ui-handler.ts

50 lines
1.0 KiB
TypeScript
Raw Normal View History

import BattleScene from "../battle-scene";
import { TextStyle, getTextColor } from "./text";
2023-03-28 14:54:52 -04:00
import UI, { Mode } from "./ui";
import {Button} from "#app/inputs-controller";
2023-03-28 14:54:52 -04:00
export default abstract class UiHandler {
protected scene: BattleScene;
protected mode: integer;
protected cursor: integer = 0;
2023-03-29 00:31:25 -04:00
public active: boolean = false;
2023-03-28 14:54:52 -04:00
constructor(scene: BattleScene, mode: Mode) {
this.scene = scene;
this.mode = mode;
}
abstract setup(): void;
2023-12-30 18:41:25 -05:00
show(_args: any[]): boolean {
2023-03-28 14:54:52 -04:00
this.active = true;
2023-12-30 18:41:25 -05:00
return true;
2023-03-28 14:54:52 -04:00
}
abstract processInput(button: Button): boolean;
2023-03-28 14:54:52 -04:00
getUi() {
return this.scene.ui;
}
getTextColor(style: TextStyle, shadow: boolean = false): string {
return getTextColor(style, shadow, this.scene.uiTheme);
}
2023-03-30 23:02:35 -04:00
getCursor(): integer {
return this.cursor;
}
2023-03-28 14:54:52 -04:00
setCursor(cursor: integer): boolean {
const changed = this.cursor !== cursor;
if (changed)
this.cursor = cursor;
return changed;
}
clear() {
this.active = false;
}
}