pokerogue/src/ui/ui-handler.ts
Greenlamp2 bac6c22973
ESLint - The Essential Linter and Formatter for JavaScript and TypeScript (#1224)
* eslint config + packages

* updated eslint config

* fix the issue eslint adding ;;;; at interfaces

* first round with eslint --fix .

* removed config for unused export

* Revert "first round with eslint --fix ."

This reverts commit 77a88e0895f7c3389cb223651b90d918af778fe9.

* removed config for camelCase

* for real this time, first round of eslint --fix .

* halfway to manual eslint fix

* eslint done

* added "how to setup" the hook to eslint --fix each new file before commit (if wanted)

* removed eslintrc config file duplicat

* fix human error + ignore build folder + merge overrides

* added curly brace style + eslint

* applied double quote linter rule

* added lefthook

* test precommit

* test precommit

* test precommit

* test precommit

* test precommit

* test precommit

* test precommit

* github action to run eslint

* added node_modules to ignore eslint

* different action for typescript

* no need for different glob (default src)

* node 20

* node 20

* removed no longer needed install file

* remove hooks part from README

* eslint fixes

---------

Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
2024-05-23 11:03:10 -04:00

52 lines
1.0 KiB
TypeScript

import BattleScene from "../battle-scene";
import { TextStyle, getTextColor } from "./text";
import { Mode } from "./ui";
import {Button} from "../enums/buttons";
export default abstract class UiHandler {
protected scene: BattleScene;
protected mode: integer;
protected cursor: integer = 0;
public active: boolean = false;
constructor(scene: BattleScene, mode: Mode) {
this.scene = scene;
this.mode = mode;
}
abstract setup(): void;
show(_args: any[]): boolean {
this.active = true;
return true;
}
abstract processInput(button: Button): boolean;
getUi() {
return this.scene.ui;
}
getTextColor(style: TextStyle, shadow: boolean = false): string {
return getTextColor(style, shadow, this.scene.uiTheme);
}
getCursor(): integer {
return this.cursor;
}
setCursor(cursor: integer): boolean {
const changed = this.cursor !== cursor;
if (changed) {
this.cursor = cursor;
}
return changed;
}
clear() {
this.active = false;
}
}