Delegate Reference

Delegates

Delegates are tables which contain the setup properties for Dialogs; they are essentially templates that determine a Dialog's appearance and behavior based on a set of values, scripts, and widgets.

Values


cancelsonspawn

When the Dialog is spawned, it will cancel all other Dialogs named in the list. (table)

Example

    LibDialog:Register("KillMyOtherDialogsExample", {
        cancels_on_spawn = {
            "MyAwesomeDialog",
            "MyNotSoGreatDialog",
        },
        hide_on_escape = true,
    })

duration

Number of seconds the Dialog will exist before automatically being dismissed. (number)

height

Height for the Dialog (in pixels); if omitted or 0, causes the Dialog's height to be determined automatically based on its contents. (number)

hideonescape

Causes the Dialog to be dismissed when the Escape key is pressed. (boolean)

icon

Assigns an icon to the Dialog found at the given file path. (string)

icon_size

Sets the width and height of the Dialog's icon (in pixels). Defaults to 36. (number)

is_exclusive

Description. (boolean)

nocancelon_escape

Do not cancel this Dialog when the Escape key is pressed. (boolean)

nocancelon_reuse

Do not cancel pre-existing Dialogs of this designation when a new instance is created. (boolean)

showduringcinematic

Do not cancel this Dialog when a Cinematic cut-scene begins. (boolean)

showwhiledead

Allow the Dialog to be shown while the character is dead. (boolean)

sound

Plays an audio file at the given path when the Dialog is shown. (string)

static_size

Sets the Dialog's width to the specified size. Ignores contained widgets for resizing purposes. (number)

text

The text displayed on the Dialog, before its widgets. (string)

textjustifyh

Sets the Dialog's horizontal text alignment style based on the following values: (string)

  • CENTER
  • LEFT
  • RIGHT

textjustifyv

Sets the Dialog's vertical text alignment style based on the following values: (string)

  • BOTTOM
  • MIDDLE
  • TOP

width

Width for the Dialog (in pixels); if omitted or 0, causes the Dialog's height to be determined automatically based on its contents. (number)

Scripts


on_cancel = function(self, data, reason)

Called when the Dialog is canceled.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

  • data - The data passed to the Delegate when the Dialog was instatntated via lib:Spawn() (variable)

  • reason - Reason for cancelation. Not always present. The library will use the following according to circumstance: (string)

    • timeout - Passed when a Dialog's duration has run out.
    • override - Passed when a Dialog is dismissed by either being in the cancelsonspawn list of another Dialog, having its isexclusive value set to true when another Dialog with its isexclusive value set is spawned, or when the same Dialog is spawned again and its nocancelon_reuse value is empty or false.

on_hide = function(self)

Run when the Dialog becomes invisible.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

on_show = function(self)

Run when the Dialog becomes visible.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

on_update = function(self, elapsed)

Run each time the screen is drawn by the game engine. This handler runs for each frame draw.

Arguments

  • self - Reference to the Dialog for which the script was run. (frame)

  • elapsed - Number of seconds since the OnUpdate handlers were last run (likely a fraction of a second). (number)