Options
All
  • Public
  • Public/Protected
  • All
Menu

A dialog can be divided in N windows. Each division has a step index. To set a dialog, call the DialogManager.set_dialog function and pass the entire dialog text. To advance the dialog (call next window), call the DialogManager.next function.

Hierarchy

  • DialogManager

Index

Constructors

constructor

Properties

Private avatar

avatar: string

Private avatar_inside_window

avatar_inside_window: boolean

Private avatar_window

avatar_window: Window

Private data

data: GoldenSun

Private dialog_crystal

dialog_crystal: Sprite

Private dialog_crystal_anim_key

dialog_crystal_anim_key: string

Private dialog_crystal_sprite_base

dialog_crystal_sprite_base: SpriteBase

Private dialog_crystal_tween

dialog_crystal_tween: Tween

Private finished

finished: boolean

Private game

game: Game

Private hero_direction

hero_direction: directions

Private italic_font

italic_font: boolean

Private parts

parts: { colors: number[][]; height: number; lines: string[]; width: number }[]

Private show_crystal

show_crystal: boolean

Private step

step: number

Private voice_key

voice_key: string

Private window

window: Window

Static Private Readonly COLOR_END

COLOR_END: RegExp = ...

Static Private Readonly COLOR_START

COLOR_START: RegExp = ...

Static Private Readonly COLOR_START_GLOB

COLOR_START_GLOB: RegExp = ...

Static Private Readonly DIALOG_CRYSTAL_KEY

DIALOG_CRYSTAL_KEY: "dialog_crystal" = "dialog_crystal"

Static Private Readonly VOICE_MIN_INTERVAL

VOICE_MIN_INTERVAL: number = 50

Accessors

current_height

  • get current_height(): number

current_width

  • get current_width(): number

is_finished

  • get is_finished(): boolean

Methods

destroy

  • destroy(): void

Private format_text

  • format_text(text: string): string
  • Replaces custom tokens in text with their actual values. Use ${HERO} to replace by hero name. Use ${BREAK} to start a new window. Use ${BREAK_LINE} to break line. Use ${STORAGE:storage_key} to replace by by a storage value with the given key. Place your text between ${COLOR:hex_value} and ${COLOR:/} to change its color.

    Parameters

    • text: string

      The text to be formatted.

    Returns string

    Returns the text formetted.

Private get_avatar_position

  • get_avatar_position(win_pos: { x?: number; y?: number }): { x: number; y: any }
  • Tries to calculate the position of the avatar window

    Parameters

    • win_pos: { x?: number; y?: number }

      the window position object.

      • Optional x?: number
      • Optional y?: number

    Returns { x: number; y: any }

    Returns the avatar position.

    • x: number
    • y: any

Private get_dialog_window_position

  • get_dialog_window_position(width: number, height: number): { x: number; y: number }
  • Tries to calculate the position of the dialog window.

    Parameters

    • width: number

      the window width.

    • height: number

      the window height.

    Returns { x: number; y: number }

    Returns the window position.

    • x: number
    • y: number

kill_dialog

  • kill_dialog(callback: () => void, dialog_only?: boolean, destroy_crystal?: boolean): void
  • If you started a dialog with quick_next, calls this function to kill it.

    Parameters

    • callback: () => void

      on dialog kill callback.

        • (): void
        • Returns void

    • dialog_only: boolean = false

      if true, destroys only the dialog window and keeps the avatar window.

    • destroy_crystal: boolean = false

      if true, destroys the dialog crystal.

    Returns void

Private mount_window

  • mount_window(callback: (finished: boolean) => void, custom_pos: { x?: number; y?: number }, custom_avatar_pos: { x?: number; y?: number }): void
  • Mounts and shows the dialog.

    Parameters

    • callback: (finished: boolean) => void

      On window mount callback

        • (finished: boolean): void
        • Parameters

          • finished: boolean

          Returns void

    • custom_pos: { x?: number; y?: number }

      Custom dialog window position object.

      • Optional x?: number
      • Optional y?: number
    • custom_avatar_pos: { x?: number; y?: number }

      Custom avatar window position object.

      • Optional x?: number
      • Optional y?: number

    Returns void

next

  • next(callback: (finished: boolean) => void, custom_pos?: { x?: number; y?: number }, custom_avatar_pos?: { x?: number; y?: number }): void
  • Calls the next dialog window. If the dialog is finished, this function passes true to the callback.

    Parameters

    • callback: (finished: boolean) => void

      Every time a dialog section is shown, this function is called. If it's the last section, passes true to it.

        • (finished: boolean): void
        • Parameters

          • finished: boolean

          Returns void

    • Optional custom_pos: { x?: number; y?: number }

      Custom dialog window position object.

      • Optional x?: number
      • Optional y?: number
    • Optional custom_avatar_pos: { x?: number; y?: number }

      Custom avatar window position.

      • Optional x?: number
      • Optional y?: number

    Returns void

quick_next

  • quick_next(text: string, callback: (finished: boolean) => void, options?: { avatar?: string; custom_avatar_pos?: { x?: number; y?: number }; custom_pos?: { x?: number; y?: number }; hero_direction?: directions; show_crystal?: boolean; voice_key?: string }): void
  • This is an optional way to invoke a dialog instead of set_dialog. It calls a window and let it open till you call quick_next again or call kill_dialog. It's expected that the given text fits in one window.

    Parameters

    • text: string

      The text to be shown.

    • callback: (finished: boolean) => void

      The on window ready callback.

        • (finished: boolean): void
        • Parameters

          • finished: boolean

          Returns void

    • Optional options: { avatar?: string; custom_avatar_pos?: { x?: number; y?: number }; custom_pos?: { x?: number; y?: number }; hero_direction?: directions; show_crystal?: boolean; voice_key?: string }

      The dialog options.

      • Optional avatar?: string

        The avatar key name.

      • Optional custom_avatar_pos?: { x?: number; y?: number }

        Custom avatar window position object.

        • Optional x?: number
        • Optional y?: number
      • Optional custom_pos?: { x?: number; y?: number }

        Custom dialog window position object.

        • Optional x?: number
        • Optional y?: number
      • Optional hero_direction?: directions

        The current hero direction in order to better calculate window position.

      • Optional show_crystal?: boolean

        Whether the dialog crystall will be shown or not.

      • Optional voice_key?: string

        The voice key sfx in order to be played while the text is shown.

    Returns void

set_dialog

  • set_dialog(text: string, options?: { avatar?: string; avatar_inside_window?: boolean; custom_max_dialog_width?: number; hero_direction?: directions; voice_key?: string }): void
  • Receives a text string and mounts the the dialog sections that will go to each window of the dialog.

    Parameters

    • text: string

      the dialog text.

    • Optional options: { avatar?: string; avatar_inside_window?: boolean; custom_max_dialog_width?: number; hero_direction?: directions; voice_key?: string }

      the dialog options.

      • Optional avatar?: string

        The avatar key name.

      • Optional avatar_inside_window?: boolean

        Whether the avatar is going to be inside the dialog window or not.

      • Optional custom_max_dialog_width?: number

        A custom max dialog width.

      • Optional hero_direction?: directions

        The current hero direction in order to better calculate window position.

      • Optional voice_key?: string

        The voice key sfx in order to be played while the text is shown.

    Returns void

Private set_dialog_crystal

  • set_dialog_crystal(): void

Private set_hero_direction

  • set_hero_direction(hero_direction: directions): void

update_position

  • update_position(): void

Generated using TypeDoc