DialogPlayer
Inherits: Node
Description
Node that plays dialog trees from Sprouty Dialogs plugin. It reads a dialog file and processes a dialog tree by ID to play the dialog.
The dialog tree is composed of nodes that represent dialogues and actions. The player processes the nodes and plays the dialogues in DialogBox nodes.
Properties
| Type | Name | Default |
|---|---|---|
| bool | autoplay | false |
| bool | free_on_end | true |
| bool | auto_advance | false |
| bool | text_reveal_skippable | true |
| bool | print_debug | false |
Methods
| Return Type | Method |
|---|---|
| void | play() |
| void | start() |
| void | pause() |
| void | resume() |
| void | stop() |
| bool | is_running() |
| void | play_on_ready(enabled: bool) |
| void | destroy_on_end(enabled: bool) |
| SproutyDialogsDialogueData | get_dialog_data() |
| String | get_start_id() |
| SproutyDialogsCharacterData | get_character_data(key_name: String) |
| DialogPortrait | get_current_portrait() |
| DialogBox | get_current_dialog_box() |
| Node | get_portraits_display_override(character_name: String = "") |
| Node | get_dialog_box_display_override(character_name: String = "") |
| DialogBox | get_dialog_box_override(character_name: String = "") |
| void | set_portraits_display_override(portrait_parent: Node, character_name: String = "") |
| void | set_dialog_box_display_override(dialog_box_parent: Node, character_name: String = "") |
| void | set_dialog_box_override(dialog_box: DialogBox, ignore_display_override: bool = false, character_name: String = "") |
| void | set_dialog(data: SproutyDialogsDialogueData, start_id: String, portrait_parents: Dictionary = {}, dialog_box_parents: Dictionary = {}) |
Signals
signal dialog_started()
Emitted when the dialog starts.
signal dialog_paused()
Emitted when the dialog is paused.
signal dialog_resumed()
Emitted when the dialog is resumed.
signal dialog_ended()
Emitted when the dialog is ended.
signal option_selected(option_index: int, option_dialog: Dictionary)
Emitted when a dialog option is selected.
signal signal_event(signal_id: String, args: Array)
Emitted when a signal event is emitted.
signal dialog_player_stop()
Emitted when the dialog player stops.
Property Descriptions
var autoplay : bool = false
If true, dialog plays when the player node is ready. It's the same as the play_on_ready method. (This was added to follow the Godot conventions, without breaking existing API)
var free_on_end : bool = true
If true, the player will be freed from the scene tree when the dialog ends. If false, the player will remain in the scene tree to be reused later. It's the same as the destroy_on_end method. (This was added to follow the Godot conventions, without breaking existing API)
var auto_advance : bool = false
If true, the player will automatically continue to the next node after a dialog is displayed. If false, the player will wait for the user to press the continue button to display the next dialog.
If the setting Enabled at the start is enabled, the player will start with auto-advance enabled ignoring the value of this property set in the inspector.
var text_reveal_skippable : bool = true
If true, the player will allow skipping the text reveal animation by pressing the continue button. If false, the player will wait for the text reveal animation to finish before continuing.
The setting Allow skip text reveal must be enabled to allow skipping the text reveal animation.
var print_debug : bool = false
If true, the player will print debug messages to the console. This is used to debug the dialog processing flow while is running.
Method Descriptions
func play() -> void
Plays the dialog tree. Need to set the dialogue data and start ID before calling this method. It's the same as start().
func start() -> void
Start processing a dialog tree. Need to set the dialogue data and start ID before calling this method. The resources are loaded on the _ready() method.
Use play() instead.
func pause() -> void
Pause processing the dialog tree.
func resume() -> void
Resume processing the dialog tree.
func stop() -> void
Stop processing the dialog tree.
func is_running() -> bool
Check if the dialog is running.
func play_on_ready(enabled: bool) -> void
Sets whether the dialog will be played when the player node is ready. If true, the dialog will start processing when the dialog player node is ready.
Use the autoplay property instead.
func destroy_on_end(enabled: bool) -> void
Sets whether the player will be destroyed when the dialogue ends. If true, the player will be freed from the scene tree when the dialog ends. If false, the player will remain in the scene tree to be reused later.
Use the free_on_end property instead.
func get_dialog_data() -> SproutyDialogsDialogueData
Returns the DialogueData resource being processed.
func get_start_id() -> String
Returns the start ID of the dialog tree being processed.
func get_character_data(key_name: String) -> SproutyDialogsCharacterData
Returns the CharacterData for a given character key name.
func get_current_portrait() -> DialogPortrait
Returns the current portrait being displayed.
func get_current_dialog_box() -> DialogBox
Returns the current dialog box being displayed.
func get_portraits_display_override(character_name: String = "") -> Node
Returns the parent node where the portraits will be displayed for a given character. If no character name is provided, it returns the default portraits display parent node for all characters (if set, otherwise it returns null).
func get_dialog_box_display_override(character_name: String = "") -> Node
Returns the parent node where the dialog box will be displayed for a given character. If no character name is provided, it returns the default dialog box display parent node for all characters (if set, otherwise it returns null).
func get_dialog_box_override(character_name: String = "") -> DialogBox
Returns the dialog box node to be used for a given character. If no character name is provided, it returns the default overrided dialog box node for all characters (if set, otherwise it returns null).
func set_portraits_display_override(portrait_parent: Node, character_name: String = "") -> void
Sets the parent node where the portraits will be displayed for a given character. If no character name is provided, it sets the default portraits display parent node for all characters.
func set_dialog_box_display_override(dialog_box_parent: Node, character_name: String = "") -> void
Sets the parent node where the dialog box will be displayed for a given character. If no character name is provided, it sets the default dialog box display parent node for all characters.
func set_dialog_box_override(dialog_box: DialogBox, ignore_display_override: bool = false, character_name: String = "") -> void
Sets the dialog box node to be used for a given character. If no character name is provided, it sets the default dialog box override for all characters. If the ignore_display_override flag is set to true, the dialog box will be used as is, without changing its parent node.
func set_dialog(data: SproutyDialogsDialogueData, start_id: String, portrait_parents: Dictionary = {}, dialog_box_parents: Dictionary = {}) -> void
Set the dialogue data and start ID to play a dialog tree. This method loads the dialog resources and prepares the player to process the dialog tree before calling the start() method.