Skip to main content

abstractDialogMenu <ModeType, ClickedObj, PropType>

Abstract base class for a simplistic DOM subscreen with three-ish components:

  • A menubar with a set of buttons which are generally heterogeneous in function (e.g. perform arbitrary, unrelated task #1, #2 or #3)
  • A status message of some sort
  • A grid with some type of misc element, generally a set of buttons homogeneous in function (e.g. equip item #1, #2 or #3). See below for more details.

Grid button clicks

Grid button clicks in the ids.grid-referenced element generally involve the following four steps:

  1. The click listener (see eventListeners._ClickButton) performs some basic generic validation, like checking whether the character has been initialized. A validation failure is considered an internal error, and will lead to a premature termination of the click event.
  2. The click listener retrieves some type of underlying object associated with the grid button, like an item or activity (see _GetClickedObject).
  3. The click listener performs more extensive, subscreen-/class-specific validation (see GetClickStatus), like checking whether an item has not been blacklisted. A validation failure here will trigger a soft reload, updating the status message and re-evaluating the enabled/disabled state of all pre-existing grid buttons.
  4. The click listener finally performs a subscreen-/class-specific action based on the grid button click, like equipping an item (see _ClickButton).

Parameters

Hierarchy

Index

Constructors

constructor

  • new DialogMenu<ModeType, ClickedObj, PropType>(mode): DialogMenu<ModeType, ClickedObj, PropType>
  • Parameters

    • mode: ModeType

      The name of the mode associated with this instance

    Returns DialogMenu<ModeType, ClickedObj, PropType>

Properties

_initProperties

_initProperties: PropType = null

An object for storing all of this classes init properties.

Subclasses should generally implement a public getter/setter interface for safely manipulating each property stored herein.

abstractreadonly_initPropertyNames

_initPropertyNames: readonly keyof PropType[]

A list of all init property names as supported by this class. Represents the set of keys that will be stored in _initProperties

abstractreadonlyclickStatusCallbacks

clickStatusCallbacks: Record<string, (C, clickedObj, equippedItem) => string>

An object mapping IDs to DialogMenu.GetClickStatus helper functions. Used for evaluating the error statuses of item clicks.

Additional checks can be freely added here.

readonlydefaultShape

defaultShape: readonly [number, number, number, number] = ...

The default position & shape of the current subscreen as defined by the root element.

See DialogMenu.shape.

readonlyeventListeners

eventListeners: { _ClickButton: (this, ev) => string; _ClickDisabledButton: (this, ev) => string; _ClickPaginateNext: (this, ev) => void; _ClickPaginatePrev: (this, ev) => void; _WheelGrid: (this, event) => void }

An object containing all event listeners referenced in the DialogMenu subclass.


Type declaration

  • _ClickButton: (this, ev) => string
      • (this, ev): string

      • Parameters

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns string

        A status message if an unexpected error is encountered and null otherwise

  • _ClickDisabledButton: (this, ev) => string
      • (this, ev): string

      • Parameters

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns string

        A status message if an expected error is encountered and null otherwise

  • _ClickPaginateNext: (this, ev) => void
      • (this, ev): void
      • Parameters

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns void

  • _ClickPaginatePrev: (this, ev) => void
      • (this, ev): void
      • Parameters

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns void

  • _WheelGrid: (this, event) => void

    Provide more consistent mouse wheel scroll behavior by using browser-independent increments.

      • (this, event): void
      • Parameters

        • this: HTMLDivElement
        • event: WheelEvent

        Returns void

abstractreadonlyids

ids: Readonly<Record<string, string> & { grid?: string; icon?: string; menubar?: string; paginate?: string; root: string; status?: string }>

An object containing all DOM element IDs referenced in the DialogMenu subclass.

readonlymode

mode: ModeType

The name of the mode associated with this instance (see DialogMenuMode).

Accessors

C

  • get C(): PropType[C]
  • set C(value): void
  • Get or set the currently selected character.

    Performs a hard DialogMenu.Reload if a new character is assigned.


    Returns PropType[C]

  • Parameters

    • value: PropType[C]

    Returns void

focusGroup

shape

  • Get or set the position & shape of the current subscreen as defined by the root element.

    Performs a DialogMenu.Resize if a new shape is assigned.


    Returns RectTuple

  • Parameters

    Returns void

Methods

abstract_ClickButton

  • _ClickButton(button, C, clickedObj, equippedItem): void
  • Helper function for handling the clicks of successfully validated grid button clicks.


    Parameters

    • button: HTMLButtonElement

      The clicked button

    • C: Character

      The target character

    • clickedObj: ClickedObj

      The buttons underlying object (item or activity)

    • equippedItem: Item

      The currently equipped item

    Returns void

_ConstructPaginateButtons

  • _ConstructPaginateButtons(id): HTMLDivElement

  • Parameters

    • id: string

    Returns HTMLDivElement

abstract_GetClickedObject

  • _GetClickedObject(button): ClickedObj
  • Return the underlying item or activity object of the passed grid button.


    Parameters

    • button: HTMLButtonElement

      The clicked button

    Returns ClickedObj

    • The button's underlying item or activity object

abstract_Load

  • _Load(): HTMLElement

_Reload

  • _Reload(param, options): boolean

abstract_ReloadButtonGrid

  • _ReloadButtonGrid(root, buttonGrid, properties, options): void

abstract_ReloadIcon

  • _ReloadIcon(root, icon, properties, options): void

abstract_ReloadMenubar

  • _ReloadMenubar(root, menubar, properties, options): void

abstract_ReloadStatus

  • _ReloadStatus(root, status, properties, options): void

_ReloadValidate

  • _ReloadValidate(properties): { param?: never; status: false } | { param: ReloadParam<PropType>; status: true }

  • Parameters

    • properties: Partial<PropType>

    Returns { param?: never; status: false } | { param: ReloadParam<PropType>; status: true }

Click

  • Click(event): void
  • Parameters

    • event: PointerEvent

    Returns void

Draw

  • Draw(): void
  • Returns void

Exit

  • Exit(): void
  • Returns void

GetClickStatus

  • GetClickStatus(C, clickedObj, equippedItem): string
  • Return an error status (if any) for when an item or activity is clicked.

    Error statuses are used for evaluating whether the relevant grid buttons must be disabled or not.


    Parameters

    • C: Character

      The target character

    • clickedObj: ClickedObj

      The item that is clicked

    • equippedItem: Item = null

      The item that is equipped (if any)

    Returns string

    • The error status or null if everything is ok

Init

  • Init(properties, style): HTMLDivElement
  • Initialize the DialogMenu subscreen.

    Serves as a ScreenLoadHandler wrapper with added parameters.


    Parameters

    • properties: PropType

      The to be initialized character and any other properties

    • style: { shape?: RectTuple } = null

      Misc styling for the subscreen

    Returns HTMLDivElement

    The div containing the dialog subscreen root element or null if the screen failed to initialize

KeyDown

  • KeyDown(event): boolean
  • Parameters

    • event: KeyboardEvent

    Returns boolean

Load

  • Load(): Promise<void>
  • Returns Promise<void>

Reload

  • Reload(properties, options): Promise<boolean>
  • Reload the subscreen, updating the DOM elements and, if required, re-assigning the character and focus group.


    Parameters

    • properties: Partial<PropType> = null
    • optionaloptions: ReloadOptions = null

      Further customization options

    Returns Promise<boolean>

    • Whether an update was triggered or aborted

Resize

  • Resize(load): void
  • Parameters

    • load: boolean

    Returns void

Run

  • Run(time): void
  • Parameters

    • time: number

    Returns void

Unload

  • Unload(): void
  • Returns void