[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;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
abstract getWindowWidth(): integer;
|
||||
|
@ -60,7 +60,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler {
|
|||
const ui = this.getUi();
|
||||
|
||||
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);
|
||||
ui.add(this.optionSelectContainer);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ export default class AchvsUiHandler extends MessageUiHandler {
|
|||
|
||||
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
|
|
@ -8,7 +8,7 @@ export default abstract class AwaitableUiHandler extends UiHandler {
|
|||
protected onActionInput: Function | null;
|
||||
public tutorialActive: boolean = false;
|
||||
|
||||
constructor(scene: BattleScene, mode: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ export default class GameChallengesUiHandler extends UiHandler {
|
|||
|
||||
private startCursor: Phaser.GameObjects.NineSlice;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
|
|
@ -20,7 +20,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
|
|||
protected submitAction: Function | null;
|
||||
protected tween: Phaser.Tweens.Tween;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.editing = false;
|
||||
|
|
|
@ -218,8 +218,8 @@ export default class GameStatsUiHandler extends UiHandler {
|
|||
private statLabels: Phaser.GameObjects.Text[];
|
||||
private statValues: Phaser.GameObjects.Text[];
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.statLabels = [];
|
||||
this.statValues = [];
|
||||
|
|
|
@ -5,7 +5,7 @@ import { addTextObject, TextStyle } from "./text";
|
|||
import { Mode } from "./ui";
|
||||
|
||||
export default class LoadingModalUiHandler extends ModalUiHandler {
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
|
|||
private externalPartyContainer: Phaser.GameObjects.Container;
|
||||
private externalPartyBg: Phaser.GameObjects.NineSlice;
|
||||
private externalPartyTitle: Phaser.GameObjects.Text;
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ export default class MenuUiHandler extends MessageUiHandler {
|
|||
public bgmBar: BgmBar;
|
||||
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.excludedMenus = () => [
|
||||
{ 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 prompt: Phaser.GameObjects.Sprite;
|
||||
|
||||
constructor(scene: BattleScene, mode: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.pendingPrompt = false;
|
||||
|
|
|
@ -16,8 +16,8 @@ export abstract class ModalUiHandler extends UiHandler {
|
|||
protected buttonContainers: Phaser.GameObjects.Container[];
|
||||
protected buttonBgs: Phaser.GameObjects.NineSlice[];
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.buttonContainers = [];
|
||||
this.buttonBgs = [];
|
||||
|
|
|
@ -4,7 +4,7 @@ import { addTextObject, TextStyle } from "./text";
|
|||
import { Mode } from "./ui";
|
||||
|
||||
export default class OutdatedModalUiHandler extends ModalUiHandler {
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { addTextObject, TextStyle } from "./text";
|
|||
import { Mode } from "./ui";
|
||||
|
||||
export default class SessionReloadModalUiHandler extends ModalUiHandler {
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ export default abstract class AbstractBindingUiHandler extends UiHandler {
|
|||
* @param scene - The BattleScene instance.
|
||||
* @param mode - The UI mode.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,8 +73,8 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler
|
|||
* @param scene - The BattleScene instance.
|
||||
* @param mode - The UI mode.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.rowsToDisplay = 8;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ export default class AbstractSettingsUiHandler extends UiHandler {
|
|||
protected settings: Array<Setting>;
|
||||
protected localStorageKey: string;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.reloadRequired = false;
|
||||
this.rowsToDisplay = 8;
|
||||
|
|
|
@ -8,7 +8,7 @@ import {addTextObject, TextStyle} from "#app/ui/text";
|
|||
|
||||
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
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 {
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
// Listen to gamepad button down events to initiate binding.
|
||||
scene.input.keyboard?.on("keydown", this.onKeyDown, this);
|
||||
}
|
||||
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class SettingsAudioUiHandler extends AbstractSettingsUiHandler {
|
|||
* @param scene - The BattleScene instance.
|
||||
* @param mode - The UI mode, optional.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.title = "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 mode - The UI mode, optional.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.title = "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 mode - The UI mode, optional.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.titleSelected = "Gamepad";
|
||||
this.setting = SettingGamepad;
|
||||
|
|
|
@ -29,7 +29,7 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi
|
|||
* @param scene - The BattleScene instance.
|
||||
* @param mode - The UI mode, optional.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.titleSelected = "Keyboard";
|
||||
this.setting = SettingKeyboard;
|
||||
|
|
|
@ -10,7 +10,7 @@ export default class SettingsUiHandler extends AbstractSettingsUiHandler {
|
|||
* @param scene - The BattleScene instance.
|
||||
* @param mode - The UI mode, optional.
|
||||
*/
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.title = "General";
|
||||
this.settings = Setting.filter(s => s.type === SettingType.GENERAL);
|
||||
|
|
|
@ -8,7 +8,7 @@ import {Button} from "#enums/buttons";
|
|||
*/
|
||||
export default abstract class UiHandler {
|
||||
protected scene: BattleScene;
|
||||
protected mode: integer;
|
||||
protected mode: integer | null;
|
||||
protected cursor: integer = 0;
|
||||
public active: boolean = false;
|
||||
|
||||
|
@ -16,7 +16,7 @@ export default abstract class UiHandler {
|
|||
* @param {BattleScene} scene The same scene as everything else.
|
||||
* @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.mode = mode;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class UnavailableModalUiHandler extends ModalUiHandler {
|
|||
|
||||
private readonly randVarianceTime = 1000 * 10;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
this.reconnectDuration = this.minTime;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ export default class VouchersUiHandler extends MessageUiHandler {
|
|||
|
||||
private cursorObj: Phaser.GameObjects.NineSlice | null;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode!); // TODO: is this bang correct?
|
||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
||||
super(scene, mode);
|
||||
|
||||
this.itemsTotal = Object.keys(vouchers).length;
|
||||
this.scrollCursor = 0;
|
||||
|
|
Loading…
Reference in New Issue