pokerogue/src/ui/egg-hatch-scene-handler.ts
Greenlamp2 d98f7733d4
Rework - Inputs management to include all gamepad mapping V2 (#429)
* 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
2024-05-05 10:30:00 -04:00

55 lines
1.4 KiB
TypeScript

import BattleScene from "../battle-scene";
import { EggHatchPhase } from "../egg-hatch-phase";
import { Mode } from "./ui";
import UiHandler from "./ui-handler";
import {Button} from "../enums/buttons";
export default class EggHatchSceneHandler extends UiHandler {
public eggHatchContainer: Phaser.GameObjects.Container;
constructor(scene: BattleScene) {
super(scene, Mode.EGG_HATCH_SCENE);
}
setup() {
this.eggHatchContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6);
this.scene.fieldUI.add(this.eggHatchContainer);
const eggLightraysAnimFrames = this.scene.anims.generateFrameNames('egg_lightrays', { start: 0, end: 3 });
this.scene.anims.create({
key: 'egg_lightrays',
frames: eggLightraysAnimFrames,
frameRate: 32
});
}
show(_args: any[]): boolean {
super.show(_args);
this.getUi().showText(null, 0);
this.scene.setModifiersVisible(false);
return true;
}
processInput(button: Button): boolean {
if (button === Button.ACTION || button === Button.CANCEL) {
const phase = this.scene.getCurrentPhase();
if (phase instanceof EggHatchPhase && phase.trySkip())
return true;
}
return this.scene.ui.getMessageHandler().processInput(button);
}
setCursor(_cursor: integer): boolean {
return false;
}
clear() {
super.clear();
this.eggHatchContainer.removeAll(true);
this.getUi().hideTooltip();
}
}