mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-04 20:27:14 +02:00
* rework of the input handling, including different gamepad and keyboard * rework of the input handling, including different gamepad and keyboard * first version of a too complex inputHandler based on phaser3-merged-input * removed useless control management and kept it simple for our use case, investigating to put out button_XX() * renamed inputHandler to inputController * aggregate directions and some action into a same method + fix menu return value * added back repeated input feature on keeping down a key * cleanup + return type * fix submit/action doing two things simultaneously, still same behaviour as before * extracted UI inputs out of battle-scene * tab -> spaces * tab -> spaces what about now github ? * tab -> spaces final (maybe) * tried to fix the plugin loading issue on prod * remove Plugins things as it's too uncertain how it works on prod * seems old code source is indented with tab * cleanup * cleanup * cleanup * putting in an enum file the enum buttons * fix repeating stats button + change message in event when the key is repeating * added return type for ui-inputs * added return type for inputs-controller * adapted the code to integrate changes of bennybroseph
50 lines
1020 B
TypeScript
50 lines
1020 B
TypeScript
import BattleScene from "../battle-scene";
|
|
import { TextStyle, getTextColor } from "./text";
|
|
import UI, { 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;
|
|
}
|
|
} |