pokerogue/src/ui/confirm-ui-handler.ts

51 lines
1.2 KiB
TypeScript
Raw Normal View History

import BattleScene from "../battle-scene";
2023-11-13 19:29:03 -08:00
import AbstractOptionSelectUiHandler from "./abstact-option-select-ui-handler";
import { Mode } from "./ui";
2023-11-13 19:29:03 -08:00
export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
private switchCheck: boolean;
private switchCheckCursor: integer;
constructor(scene: BattleScene) {
super(scene, Mode.CONFIRM);
}
getWindowWidth(): integer {
return 48;
}
getWindowHeight(): integer {
return 48;
}
getOptions(): string[] {
return [ 'Yes', 'No' ];
}
2023-12-30 15:41:25 -08:00
show(args: any[]): boolean {
if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) {
super.show(args);
this.switchCheck = args.length >= 3 && args[2] as boolean;
2023-12-26 11:49:23 -08:00
const xOffset = (args.length >= 4 ? -args[3] as number : 0);
this.optionSelectContainer.x = (this.scene.game.canvas.width / 6) - 1 + xOffset;
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);
2023-12-30 15:41:25 -08:00
return true;
}
2023-12-30 15:41:25 -08:00
return false;
}
setCursor(cursor: integer): boolean {
const ret = super.setCursor(cursor);
if (ret && this.switchCheck)
this.switchCheckCursor = this.cursor;
return ret;
}
}