mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-29 18:26:09 +00:00
[Refactor] allow null
for ui mode constructor argument (#3407)
This commit is contained in:
parent
3698f13f49
commit
f9d7b71fd6
@ -46,8 +46,8 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||||||
|
|
||||||
private cursorObj: Phaser.GameObjects.Image | null;
|
private cursorObj: Phaser.GameObjects.Image | null;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getWindowWidth(): integer;
|
abstract getWindowWidth(): integer;
|
||||||
@ -60,7 +60,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
this.optionSelectContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 1, -48);
|
this.optionSelectContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 1, -48);
|
||||||
this.optionSelectContainer.setName(`option-select-${Mode[this.mode]}`);
|
this.optionSelectContainer.setName(`option-select-${this.mode ? Mode[this.mode] : "UNKNOWN"}`);
|
||||||
this.optionSelectContainer.setVisible(false);
|
this.optionSelectContainer.setVisible(false);
|
||||||
ui.add(this.optionSelectContainer);
|
ui.add(this.optionSelectContainer);
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ export default class AchvsUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -8,7 +8,7 @@ export default abstract class AwaitableUiHandler extends UiHandler {
|
|||||||
protected onActionInput: Function | null;
|
protected onActionInput: Function | null;
|
||||||
public tutorialActive: boolean = false;
|
public tutorialActive: boolean = false;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ export default class GameChallengesUiHandler extends UiHandler {
|
|||||||
|
|
||||||
private startCursor: Phaser.GameObjects.NineSlice;
|
private startCursor: Phaser.GameObjects.NineSlice;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -20,7 +20,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
|
|||||||
protected submitAction: Function | null;
|
protected submitAction: Function | null;
|
||||||
protected tween: Phaser.Tweens.Tween;
|
protected tween: Phaser.Tweens.Tween;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
|
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
|
@ -218,8 +218,8 @@ export default class GameStatsUiHandler extends UiHandler {
|
|||||||
private statLabels: Phaser.GameObjects.Text[];
|
private statLabels: Phaser.GameObjects.Text[];
|
||||||
private statValues: Phaser.GameObjects.Text[];
|
private statValues: Phaser.GameObjects.Text[];
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
|
|
||||||
this.statLabels = [];
|
this.statLabels = [];
|
||||||
this.statValues = [];
|
this.statValues = [];
|
||||||
|
@ -5,7 +5,7 @@ import { addTextObject, TextStyle } from "./text";
|
|||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
|
|
||||||
export default class LoadingModalUiHandler extends ModalUiHandler {
|
export default class LoadingModalUiHandler extends ModalUiHandler {
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
|
|||||||
private externalPartyContainer: Phaser.GameObjects.Container;
|
private externalPartyContainer: Phaser.GameObjects.Container;
|
||||||
private externalPartyBg: Phaser.GameObjects.NineSlice;
|
private externalPartyBg: Phaser.GameObjects.NineSlice;
|
||||||
private externalPartyTitle: Phaser.GameObjects.Text;
|
private externalPartyTitle: Phaser.GameObjects.Text;
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||||||
public bgmBar: BgmBar;
|
public bgmBar: BgmBar;
|
||||||
|
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
|
|
||||||
this.excludedMenus = () => [
|
this.excludedMenus = () => [
|
||||||
{ condition: [Mode.COMMAND, Mode.TITLE].includes(mode ?? Mode.TITLE), options: [ MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST] },
|
{ condition: [Mode.COMMAND, Mode.TITLE].includes(mode ?? Mode.TITLE), options: [ MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST] },
|
||||||
|
@ -11,7 +11,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
|||||||
public message: Phaser.GameObjects.Text;
|
public message: Phaser.GameObjects.Text;
|
||||||
public prompt: Phaser.GameObjects.Sprite;
|
public prompt: Phaser.GameObjects.Sprite;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
|
|
||||||
this.pendingPrompt = false;
|
this.pendingPrompt = false;
|
||||||
|
@ -16,8 +16,8 @@ export abstract class ModalUiHandler extends UiHandler {
|
|||||||
protected buttonContainers: Phaser.GameObjects.Container[];
|
protected buttonContainers: Phaser.GameObjects.Container[];
|
||||||
protected buttonBgs: Phaser.GameObjects.NineSlice[];
|
protected buttonBgs: Phaser.GameObjects.NineSlice[];
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
|
|
||||||
this.buttonContainers = [];
|
this.buttonContainers = [];
|
||||||
this.buttonBgs = [];
|
this.buttonBgs = [];
|
||||||
|
@ -4,7 +4,7 @@ import { addTextObject, TextStyle } from "./text";
|
|||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
|
|
||||||
export default class OutdatedModalUiHandler extends ModalUiHandler {
|
export default class OutdatedModalUiHandler extends ModalUiHandler {
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { addTextObject, TextStyle } from "./text";
|
|||||||
import { Mode } from "./ui";
|
import { Mode } from "./ui";
|
||||||
|
|
||||||
export default class SessionReloadModalUiHandler extends ModalUiHandler {
|
export default class SessionReloadModalUiHandler extends ModalUiHandler {
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ export default abstract class AbstractBindingUiHandler extends UiHandler {
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode.
|
* @param mode - The UI mode.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,8 +73,8 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode.
|
* @param mode - The UI mode.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
this.rowsToDisplay = 8;
|
this.rowsToDisplay = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ export default class AbstractSettingsUiHandler extends UiHandler {
|
|||||||
protected settings: Array<Setting>;
|
protected settings: Array<Setting>;
|
||||||
protected localStorageKey: string;
|
protected localStorageKey: string;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
|
|
||||||
this.reloadRequired = false;
|
this.reloadRequired = false;
|
||||||
this.rowsToDisplay = 8;
|
this.rowsToDisplay = 8;
|
||||||
|
@ -8,7 +8,7 @@ import {addTextObject, TextStyle} from "#app/ui/text";
|
|||||||
|
|
||||||
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.scene.input.gamepad?.on("down", this.gamepadButtonDown, this);
|
this.scene.input.gamepad?.on("down", this.gamepadButtonDown, this);
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,12 @@ import {addTextObject, TextStyle} from "#app/ui/text";
|
|||||||
|
|
||||||
export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
|
export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
// Listen to gamepad button down events to initiate binding.
|
// Listen to gamepad button down events to initiate binding.
|
||||||
scene.input.keyboard?.on("keydown", this.onKeyDown, this);
|
scene.input.keyboard?.on("keydown", this.onKeyDown, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export default class SettingsAudioUiHandler extends AbstractSettingsUiHandler {
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode, optional.
|
* @param mode - The UI mode, optional.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.title = "Audio";
|
this.title = "Audio";
|
||||||
this.settings = Setting.filter(s => s.type === SettingType.AUDIO);
|
this.settings = Setting.filter(s => s.type === SettingType.AUDIO);
|
||||||
|
@ -11,7 +11,7 @@ export default class SettingsDisplayUiHandler extends AbstractSettingsUiHandler
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode, optional.
|
* @param mode - The UI mode, optional.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.title = "Display";
|
this.title = "Display";
|
||||||
this.settings = Setting.filter(s => s.type === SettingType.DISPLAY);
|
this.settings = Setting.filter(s => s.type === SettingType.DISPLAY);
|
||||||
|
@ -31,7 +31,7 @@ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiH
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode, optional.
|
* @param mode - The UI mode, optional.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.titleSelected = "Gamepad";
|
this.titleSelected = "Gamepad";
|
||||||
this.setting = SettingGamepad;
|
this.setting = SettingGamepad;
|
||||||
|
@ -29,7 +29,7 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode, optional.
|
* @param mode - The UI mode, optional.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.titleSelected = "Keyboard";
|
this.titleSelected = "Keyboard";
|
||||||
this.setting = SettingKeyboard;
|
this.setting = SettingKeyboard;
|
||||||
|
@ -10,7 +10,7 @@ export default class SettingsUiHandler extends AbstractSettingsUiHandler {
|
|||||||
* @param scene - The BattleScene instance.
|
* @param scene - The BattleScene instance.
|
||||||
* @param mode - The UI mode, optional.
|
* @param mode - The UI mode, optional.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.title = "General";
|
this.title = "General";
|
||||||
this.settings = Setting.filter(s => s.type === SettingType.GENERAL);
|
this.settings = Setting.filter(s => s.type === SettingType.GENERAL);
|
||||||
|
@ -8,7 +8,7 @@ import {Button} from "#enums/buttons";
|
|||||||
*/
|
*/
|
||||||
export default abstract class UiHandler {
|
export default abstract class UiHandler {
|
||||||
protected scene: BattleScene;
|
protected scene: BattleScene;
|
||||||
protected mode: integer;
|
protected mode: integer | null;
|
||||||
protected cursor: integer = 0;
|
protected cursor: integer = 0;
|
||||||
public active: boolean = false;
|
public active: boolean = false;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ export default abstract class UiHandler {
|
|||||||
* @param {BattleScene} scene The same scene as everything else.
|
* @param {BattleScene} scene The same scene as everything else.
|
||||||
* @param {Mode} mode The mode of the UI element. These should be unique.
|
* @param {Mode} mode The mode of the UI element. These should be unique.
|
||||||
*/
|
*/
|
||||||
constructor(scene: BattleScene, mode: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ export default class UnavailableModalUiHandler extends ModalUiHandler {
|
|||||||
|
|
||||||
private readonly randVarianceTime = 1000 * 10;
|
private readonly randVarianceTime = 1000 * 10;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.reconnectDuration = this.minTime;
|
this.reconnectDuration = this.minTime;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ export default class VouchersUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
||||||
|
|
||||||
constructor(scene: BattleScene, mode?: Mode) {
|
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||||
super(scene, mode!); // TODO: is this bang correct?
|
super(scene, mode);
|
||||||
|
|
||||||
this.itemsTotal = Object.keys(vouchers).length;
|
this.itemsTotal = Object.keys(vouchers).length;
|
||||||
this.scrollCursor = 0;
|
this.scrollCursor = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user