PokéRogue
    Preparing search index...

    Generic handler for a menu with several options to choose from with a cursor.

    Given the proper OptionSelectModeConfig the handler will:

    • Measure the size of all elements in the menu, including the size of any icon.
    • Apply the required BBCode if an elements asks for a specific color.
    • Create the window of the appropriate size to hold all elements.
    • Handle scrolling through the menu items, resizing as needed.
    • Handle selecting the menu items, or cancelling out of the menu.

    At initialization the size of the first NUM_PRE_COMPUTED_OPTIONS is measured.
    Then the window's size is updated as needed when a non initialized option needs to be displayed.

    Type Parameters

    Hierarchy (View Summary)

    Index
    active: boolean = false
    awaitingActionInput: boolean
    blockInput: boolean
    config: OptionSelectModeConfig<T> | null
    cursor: number = 0
    cursorObj: Image | null
    fullyInitialized: boolean
    maxIconWidth: number = 0
    maxOptions: number
    message: Text
    mode: UiMode

    Used to set the name of optionSelectContainer

    nameBoxContainer?: Container

    The container for the name box

    This will be undefined unless this.initNameBox() was called

    onActionInput: AnyFn<any> | null
    options: (UIOptionSelectItem & T)[] = []
    optionSelectBg: NineSlice
    optionSelectContainer: Container
    optionSelectIcons: Sprite[] = []
    optionSelectText: BBCodeText
    pendingPrompt: boolean = false
    prompt: Sprite
    repeatInput: boolean = false
    scale: number = 0.1666666667
    scrollBar: ScrollBar | null
    scrollCursor: number = 0
    textCallbackTimer: TimerEvent | null
    textTimer: TimerEvent | null
    tutorialActive: boolean = false
    tutorialOverlay: Rectangle
    wordWrapWidth: number = 1780
    • Display the current options based on the cursor and scroll cursor.

      Parameters

      • skipResizing: boolean = false

        (Default false) Whether to skip the automatic resizing step

      Returns void

      Can handle automatic resizing of the menu window as needed.

    • Compute the width required to display all given options and readies them for display.

      Creates temporary sprite and Text objects and set to be able to infer the required space.

      Only considers the options that have not been initialized, and marks them as initialized once done.

      Parameters

      Returns number

      the maximum width that will be taken by those elements

    • Readies the given UIOptionSelectItem for display.

      Parameters

      • option: UIOptionSelectItem & T

        The UIOptionSelectItem to consider

      • singleSpaceWidth: number

        The width of a single space, used to offset the label if there is a icon to show

      • tempSprite: Sprite

        A Sprite object that can be used to measure the needed space of the item's icon, if any

      Returns void

      For options with icon(s), adds the appropriate number of space before the label to give the sprite the space it needs

      For options with color, adds the appropriate BBCode to the label

    • Add the name box shown by showDialogue to the given message container.

      Parameters

      • container: Container

        The container holding the message text

      • x: number = 0

        The x position of the name box

      • y: number = -16

        The y position of the name box

      Returns void

      If this method is not called, the name box will not be displayed.

    • Parameters

      • text: string
      • Optionalname: string
      • Optionaldelay: number | null
      • Optionalcallback: (() => void) | null
      • OptionalcallbackDelay: number | null
      • Optionalprompt: boolean | null
      • OptionalpromptDelay: number | null

      Returns void

    • Show a name above the text.

      Parameters

      • name: string

        The name to show

      • OptionaliconFrame: string

        The frame of the icon to display next to the name

      Returns void

      the icon must be from the items atlas

    • Parameters

      • text: string
      • Optionaldelay: number | null
      • Optionalcallback: (() => void) | null
      • OptionalcallbackDelay: number | null
      • Optionalprompt: boolean | null
      • OptionalpromptDelay: number | null

      Returns void