2023-06-16 09:13:52 -07:00
|
|
|
import BattleScene from "../battle-scene";
|
2024-01-11 09:26:32 -08:00
|
|
|
import AbstractOptionSelectUiHandler, { OptionSelectConfig } from "./abstact-option-select-ui-handler";
|
2023-04-06 19:24:13 -07:00
|
|
|
import { Mode } from "./ui";
|
|
|
|
|
2023-11-13 19:29:03 -08:00
|
|
|
export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler {
|
2023-04-06 19:24:13 -07:00
|
|
|
private switchCheck: boolean;
|
|
|
|
private switchCheckCursor: integer;
|
|
|
|
|
|
|
|
constructor(scene: BattleScene) {
|
|
|
|
super(scene, Mode.CONFIRM);
|
|
|
|
}
|
|
|
|
|
2023-06-16 09:13:52 -07:00
|
|
|
getWindowWidth(): integer {
|
|
|
|
return 48;
|
2023-05-31 16:54:57 -07:00
|
|
|
}
|
2023-04-06 19:24:13 -07:00
|
|
|
|
2023-12-30 15:41:25 -08:00
|
|
|
show(args: any[]): boolean {
|
2023-04-06 19:24:13 -07:00
|
|
|
if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) {
|
2024-01-11 09:26:32 -08:00
|
|
|
const config: OptionSelectConfig = {
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
label: 'Yes',
|
|
|
|
handler: args[0]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'No',
|
|
|
|
handler: args[1]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
super.show([ config ]);
|
2023-04-06 19:24:13 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2023-04-06 19:24:13 -07:00
|
|
|
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);
|
2023-12-30 15:41:25 -08:00
|
|
|
|
|
|
|
return true;
|
2023-04-06 19:24:13 -07:00
|
|
|
}
|
2023-12-30 15:41:25 -08:00
|
|
|
|
|
|
|
return false;
|
2023-04-06 19:24:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
setCursor(cursor: integer): boolean {
|
|
|
|
const ret = super.setCursor(cursor);
|
|
|
|
|
|
|
|
if (ret && this.switchCheck)
|
|
|
|
this.switchCheckCursor = this.cursor;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|