Options
All
  • Public
  • Public/Protected
  • All
Menu

A dialog can be divided in N windows depending on the dialog text size. 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. Optionallly, if you know that the given text fits in one window, you can use DialogManager.next_dialog.

Hierarchy

  • DialogManager

Index

Constructors

  • new DialogManager(game: Game, data: GoldenSun, italic_font?: boolean, mind_read_window?: boolean, pos_relative_to_canvas?: boolean): DialogManager

Properties

_step: number
avatar: string
avatar_inside_window: boolean
avatar_window: Window
data: GoldenSun
dialog_crystal: Sprite
dialog_crystal_anim_key: string
dialog_crystal_sprite_base: SpriteBase
dialog_crystal_tween: Tween
finished: boolean
font_color: number
game: Game
hero_direction: directions
italic_font: boolean
mind_read_window: boolean
parts: { colors: number[][]; height: number; lines: string[]; pauses: {}[]; width: number }[]
pos_relative_to_canvas: boolean
show_crystal: boolean
voice_key: string
window: Window
COLOR_END: RegExp = ...
COLOR_END_G: RegExp = ...
COLOR_START: RegExp = ...
COLOR_START_G: RegExp = ...
COLOR_START_GLOB: RegExp = ...
DIALOG_CRYSTAL_KEY: "dialog_crystal" = "dialog_crystal"
PAUSE_PATTERN: RegExp = ...
PAUSE_PATTERN_G: RegExp = ...
VOICE_MIN_INTERVAL: number = 50

Accessors

  • get current_height(): number
  • get current_width(): number
  • get is_finished(): boolean
  • get size(): number
  • get step(): number
  • get window_x(): number
  • get window_y(): number

Methods

  • close_dialog(callback?: (() => void)): void
  • destroy(): void
  • 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 ${PAUSE:duration_ms} to delay the dialog for the given duration value in ms. 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.

  • 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
  • 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(callback?: (() => void), dialog_only?: boolean, destroy_crystal?: boolean): void
  • If you started a dialog with next_dialog, calls this function to kill it.

    Parameters

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

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

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

  • set_dialog_crystal(): void
  • set_hero_direction(hero_direction: directions): void
  • update_borders(): void
  • update_position(): void

Generated using TypeDoc