mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-20 12:05:50 +02:00
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
import { Button } from "#enums/buttons";
|
|
import AbstractOptionSelectUiHandler from "./abstact-option-select-ui-handler";
|
|
import { Mode } from "./ui";
|
|
|
|
export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler {
|
|
modalContainer: Phaser.GameObjects.Container;
|
|
constructor(mode: Mode = Mode.OPTION_SELECT) {
|
|
super(mode);
|
|
}
|
|
|
|
getWindowWidth(): number {
|
|
return 64;
|
|
}
|
|
|
|
show(args: any[]): boolean {
|
|
if (args[0].modalContainer) {
|
|
const { modalContainer } = args[0];
|
|
const show = super.show(args);
|
|
this.modalContainer = modalContainer;
|
|
this.setupOptions();
|
|
|
|
return show;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected setupOptions() {
|
|
super.setupOptions();
|
|
if (this.modalContainer) {
|
|
this.optionSelectContainer.setSize(this.optionSelectContainer.height, Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth()));
|
|
this.optionSelectContainer.setPositionRelative(this.modalContainer, this.optionSelectBg.width, this.optionSelectBg.height + 50);
|
|
}
|
|
}
|
|
|
|
processInput(button: Button): boolean {
|
|
// the cancel and action button are here because if you're typing, x and z are used for cancel/action. This means you could be typing something and accidentally cancel/select when you don't mean to
|
|
// the submit button is therefore used to select a choice (the enter button), though this does not work on my local dev testing for phones, as for my phone/keyboard combo, the enter and z key are both
|
|
// bound to Button.ACTION, which makes this not work on mobile
|
|
if (button !== Button.CANCEL && button !== Button.ACTION) {
|
|
return super.processInput(button);
|
|
}
|
|
return false;
|
|
}
|
|
}
|