Skip to main content

DialogMenu <ModeType, ClickedObj>

Base class for managing various DialogMenu subscreens.

@abstract

Hierarchy

Index

Constructors

constructor

  • new DialogMenu<ModeType, ClickedObj>(mode: ModeType): DialogMenu<ModeType, ClickedObj>
  • Type parameters

    Parameters

    • mode: ModeType

      The name of the mode associated with this instance

    Returns DialogMenu<ModeType, ClickedObj>

Properties

readonlyclickStatusCallbacks

clickStatusCallbacks: Record<string, (C: Character, clickedObj: ClickedObj, equippedItem?: Item) => 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.

@abstract

readonlydefaultShape

defaultShape: readonly [1005, 120, 995, 857] = ...

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

See DialogMenu.shape.

readonlyeventListeners

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

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


Type declaration

  • _ClickButton: (this: HTMLButtonElement, ev: MouseEvent) => string
    @returns

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

      • (this: HTMLButtonElement, ev: MouseEvent): string
      • Parameters

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns string

  • _ClickDisabledButton: (this: HTMLButtonElement, ev: MouseEvent) => string
    @returns

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

      • (this: HTMLButtonElement, ev: MouseEvent): string
      • Parameters

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns string

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

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns void

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

        • this: HTMLButtonElement
        • ev: MouseEvent

        Returns void

readonlyids

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

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

@abstract

readonlymode

mode: ModeType

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

Accessors

C

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

Click

  • Click(event: MouseEvent | TouchEvent): void
  • Called if the user clicks on the canvas


    Parameters

    • event: MouseEvent | TouchEvent

      The event that triggered this

    Returns void

Draw

  • Draw(): void
  • Called each frame when the screen needs to be drawn.


    Returns void

Exit

  • Exit(): void
  • Called when user presses Esc


    Returns void

GetClickStatus

  • GetClickStatus(C: Character, clickedObj: ClickedObj, equippedItem?: Item): 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

  • Initialize the DialogMenu subscreen.

    Serves as a ["Load"] wrapper with added parameters.


    Parameters

    Returns HTMLDivElement

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

KeyDown

  • KeyDown(event: KeyboardEvent): boolean
  • Called if the the user presses any key


    Parameters

    • event: KeyboardEvent

      The event that triggered this

    Returns boolean

Load

  • Load(): void
  • Called when screen is loaded using CommonSetScreen


    Returns void

Reload

  • Reload the subscreen, updating the DOM elements and, if required, re-assigning the character and focus group.


    Parameters

    Returns Promise<boolean>

    • Whether an update was triggered or aborted

Resize

  • Resize(load: boolean): void
  • Called when screen size or position changes or after screen load


    Parameters

    • load: boolean

      If the reason for call was load (true) or window resize (false)

    Returns void

Unload

  • Unload(): void
  • Called when this screen is being replaced


    Returns void

_ClickButton

  • _ClickButton(button: HTMLButtonElement, C: Character, clickedObj: ClickedObj, equippedItem: Item): void
  • Helper function for handling the clicks of succesfully validated grid button clicks.

    @abstract

    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: string): HTMLDivElement

  • Parameters

    • id: string

    Returns HTMLDivElement

_GetClickedObject

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

    @abstract

    Parameters

    • button: HTMLButtonElement

      The clicked button

    Returns ClickedObj

    • The button's underlying item or activity object

_Load

  • _Load(): HTMLElement
  • Construct and return the (unpopulated) DialogMenu.ids.root element.

    @abstract

    Returns HTMLElement

_ReloadButtonGrid

  • _ReloadButtonGrid(root: HTMLElement, buttonGrid: HTMLElement, options: Pick<ReloadOptions, reset | resetScrollbar | resetDialogItems>): void

_ReloadIcon

  • _ReloadIcon(root: HTMLElement, icon: HTMLElement, options: Pick<ReloadOptions, never>): void

_ReloadStatus

  • _ReloadStatus(root: HTMLElement, status: HTMLElement, options: Pick<ReloadOptions, status | statusTimer>): void