mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-19 18:57:37 +00:00
* Adding code to allow use of a testing dialogue translation menu * Updated to include autocomplete functionality * Added multiple inputs * Added locales for other languages as well as checks to make this only available on local/beta * Updated a few things to try get the dialogue to work for full length of the window * Fixed issue with message box not taking up full length of the screen (thanks Moka!) and some minor bugs * Whoops, forgot to stage a file * Updated locale files * Fixed broken tests and docs * Removed keys from json * Reordered and reorganised some things * Put admin enum at end to match handlers * Removed old unneeded line of code * Updated to include the ability to handle cases where i18 keys are null in the locales json
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { Button } from "#enums/buttons";
|
|
import BattleScene from "../battle-scene";
|
|
import AbstractOptionSelectUiHandler from "./abstact-option-select-ui-handler";
|
|
import { Mode } from "./ui";
|
|
|
|
export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler {
|
|
modalContainer: Phaser.GameObjects.Container;
|
|
constructor(scene: BattleScene, mode: Mode = Mode.OPTION_SELECT) {
|
|
super(scene, mode);
|
|
}
|
|
|
|
getWindowWidth(): integer {
|
|
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;
|
|
}
|
|
}
|