Skip to main content

DialogBox

Inherits: Control

Description

Node that displays dialogue text on screen. Provides basic functionality for displaying text with writing effects, character names, portraits, and options.

You can customize your own dialog boxes nodes and extend their functionality by inheriting from this class.

Important

You should not use this node directly to play a dialogue. You should use a DialogPlayer node to play dialogues, which will process it and use a DialogBox to display it.

Properties

TypeNameDefault
floattyping_speeddefault_typing_speed from settings
intmax_charactersmax_characters from settings
RichTextLabeldialog_displaynull
RichTextLabelname_displaynull
Controlcontinue_indicatornull
Nodeportrait_displaynull
Containeroptions_containernull
Controloption_templatenull

Methods

Return TypeMethod
void_on_dialog_box_start() (virtual)
void_on_dialog_box_close() (virtual)
void_on_options_displayed() (virtual)
void_on_options_hidden() (virtual)
voidplay_dialog(character_name: String, dialog: String)
voidpause_dialog()
voidresume_dialog()
voidstop_dialog(close_dialog: bool = false)
boolis_displaying_portrait()
voiddisplay_portrait(character_parent: Node, portrait_node: Node)
voiddisplay_options(options: Array)
voidhide_options()

Signals

signal dialog_starts

Emitted when the dialog is started.


signal dialog_typing_ends

Emitted when the dialog ends typing.


signal dialog_ends

Emitted when the dialog is ended.


signal continue_dialog

Emitted when the player press the continue button to continue the dialog tree.


signal meta_clicked(meta: String)

Emitted when a meta tag is clicked in the dialog.


signal option_selected(option_index: int)

Emitted when the player selects an option.


Property Descriptions

var typing_speed : float

Typing speed of the dialog text in seconds.


var max_characters : int

Maximum number of characters to be displayed in the dialog box. The dialogue will be split according to this limit and displayed in parts if the split_dialog_by_max_characters setting is active.


var dialog_display : RichTextLabel *

RichTextLabel where dialogue will be displayed. This component is required to display the dialogue text in it.


var name_display : RichTextLabel

RichTextLabel where character name will be displayed. If you want to display the character name in the dialog box, you need to set this property.


var continue_indicator : Control

Visual indicator to indicate press for continue the dialogue (e.g. an arrow). If you want to display a continue indicator in the dialog box, you need to set this property.


var portrait_display : Node

Node where the character portrait will be displayed (parent node). If you want to display the portrait in the dialog box, you need to set this property.


var options_container : Container *

Container where the options will be displayed in the dialog box. It is recommended to use a VBoxContainer or GridContainer to display the options. This component is required to display the dialog options in it.


var option_template : Control *

Node that will be used as a template for the options in the dialog box. It should be a DialogOption node or another node that extends it. This component is required to display the dialog options.


Method Descriptions

func _on_dialog_box_start() -> void (virtual)

Called when the dialog box starts at the beginning of the dialog. Override this method to customize the behavior of the dialog box when starts.


func _on_dialog_box_close() -> void (virtual)

Called when the dialog box when is closed at the end of the dialog. Override this method to customize the behavior of the dialog box when is closed.


func _on_options_displayed() -> void (virtual)

Called when the dialog options are displayed. Override this method to customize the behavior of the dialog box when options are displayed.


func _on_options_hidden() -> void (virtual)

Called when the dialog options are hidden. Override this method to customize the behavior of the dialog box when options are hidden.


func play_dialog(character_name: String, dialog: String) -> void

Play a dialog on dialog box. Displays the character name and dialog text with typing animation.


func pause_dialog() -> void

Pause the dialog.


func resume_dialog() -> void

Resume the dialog.


func stop_dialog(close_dialog: bool = false) -> void

Stop the dialog. If close_dialog is true, the dialog box will be closed.


func is_displaying_portrait() -> bool

Return if the dialog box is displaying a portrait.


func display_portrait(character_parent: Node, portrait_node: Node) -> void

Set a portrait to be displayed in the dialog box.


func display_options(options: Array) -> void

Display the dialog options.


func hide_options() -> void

Hide the dialog options.