Skip to main content

EditorSproutyDialogsGraphEditor

Inherits: GraphEdit

Description

This module is the graph editor where the dialog trees are edited in the Sprouty Dialogs plugin. It handles the nodes, connections, and graph data. Provides a visual interface for creating and managing dialogue flow with support for multiple node types, drag-and-drop, copy/paste operations, and undo/redo functionality.

Properties

TypeNameDefault
EditorUndoRedoManagerundo_redonull

Methods

Return TypeMethod
voidon_locales_changed()
voidon_translation_enabled_changed(enabled: bool)
Dictionaryget_graph_data()
voidload_graph_data(data: SproutyDialogsDialogueData, dialogs: Dictionary)
voiddelete_node(node: GraphNode, from_request: bool)
Arrayget_node_connections(node: String, all: bool, out: bool)
Arrayget_node_output_connections(node: String, port: int)
voiddisconnect_node_on_port(node: String, port: int, as_action: bool)
boolis_graph_empty()
voidclear_graph()

Signals

signal modified(modified: bool)

Triggered when the graph is modified.


signal nodes_loaded

Triggered when all the nodes are loaded.


signal open_character_file_request(path: String)

Emitted when is requesting to open a character file.


signal play_dialog_request(start_id: String)

Emitted when is requesting to play a dialog from a start node.


signal open_text_editor(text_box: TextEdit)

Emitted when an expand button to open the text editor is pressed.


signal update_text_editor(text_box: TextEdit)

Emitted when change the focus to another text box while the text editor is open.


signal locales_changed

Emitted when the locales are changed.


signal translation_enabled_changed(enabled: bool)

Emitted when the translation enabled state is changed.


Property Descriptions

var undo_redo : EditorUndoRedoManager

UndoRedo manager for handling undo/redo operations in the graph editor.


Method Descriptions

func on_locales_changed() -> void

Notify the nodes that the locales have changed in the project settings.


func on_translation_enabled_changed(enabled: bool) -> void

Notify the nodes that the translation enabled state has changed.


func get_graph_data() -> Dictionary

Return the graph data in a dictionary, including nodes data, dialogs, and characters. Each one is stored in a separate sub-dictionary. The nodes data has the graph data organized by start node ID and unplugged nodes.


func load_graph_data(data: SproutyDialogsDialogueData, dialogs: Dictionary) -> void

Load graph data from a SproutyDialogsDialogueData resource and dialogs dictionary. Creates all nodes and establishes connections based on the provided data.


func delete_node(node: GraphNode, from_request: bool = false) -> void

Delete a node from graph. Disconnects all connections and removes the node. If from_request is false, creates an undo/redo action.


func get_node_connections(node: String, all: bool = false, out: bool = true) -> Array

Return the output or input connections of a given node. If all is true, returns both input and output connections. If out is true, returns only output connections, otherwise input connections.


func get_node_output_connections(node: String, port: int) -> Array

Return the connections from a node on the given output port.


func disconnect_node_on_port(node: String, port: int, as_action: bool = false) -> void

Disconnect an output connection from a node on the given port. If as_action is true, creates an undo/redo action.


func is_graph_empty() -> bool

Check if graph does not have any nodes.


func clear_graph() -> void

Clear graph removing all current nodes.