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

    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
    • 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

    • Parameters

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

      Returns void

    • Parameters

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

      Returns void