SproutyDialogsDialogueData
Inherits: Resource
Description
This resource stores the dialogue data from the graph editor. It includes the graph data, character references, dialogues and a reference to a CSV file for translations.
Properties
| Type | Name | Default |
|---|---|---|
| Dictionary | graph_data | {} |
| Dictionary | dialogs | {} |
| Dictionary | characters | {} |
Methods
| Return Type | Method |
|---|---|
| Array[String] | get_start_ids() |
| Dictionary | get_portraits_on_dialog(start_id: String) |
| Dictionary | get_all_character_references() |
| bool | sync_character_references() |
Property Descriptions
var graph_data : Dictionary = {}
The dialogue data from the graph editor. This is a dictionary where each key is the ID (start id) of a dialogue branch and its value is a nested dictionary containing the nodes of that branch.
This dictionary is structured as follows:
{
"dialogue_id_1": {
"node_1": { ... },
"node_2": { ... },
},
"dialogue_id_2": {
"node_1": { ... },
"node_2": { ... },
},
...
}
var dialogs : Dictionary = {}
A dictionary containing the dialogues for each dialogue ID.
This dictionary is structured as follows:
{
"dialogue_id_1": {
"locale_code_1": "Translated text in locale 1",
"locale_code_2": "Translated text in locale 2",
...
},
...
}
var characters : Dictionary = {}
A dictionary containing the characters for each dialogue ID. This is a dictionary where each key is the dialogue ID and its value is a dictionary with each character key name and its reference, stored as a subdictionary with the UID and the file path of the character resource, so the character can still be loaded by its path when the UID is no longer valid.
This dictionary is structured as follows:
{
"dialogue_id_1": {
"character_key_name_1": {
"uid": UID of the character resource,
"path": "res://path_to_the/character_file.tres",
},
"character_key_name_2": { ... },
...
},
...
}
Method Descriptions
func get_start_ids() -> Array[String]
Returns a list of the start IDs from the graph data.
func get_portraits_on_dialog(start_id: String) -> Dictionary
Returns a dictionary of the characters and their portraits for a given start ID. The start ID is the ID of the dialogue branch to get the characters from.
The dictionary is structured as follows:
{
"character_name_1": [portrait_name_1, portrait_name_2, ...],
"character_name_2": [portrait_name_1, portrait_name_2, ...],
...
}
func get_all_character_references() -> Dictionary
Return all the character references count from the dialogue file.
func sync_character_references() -> bool
Synchronizes the character references with the current key name of each character file. This updates:
- The legacy references that stored the character UID only, migrating them to the current reference format (a subdictionary with "uid" and "path").
- The stored UID and file path of every reference with its current values (e.g. when the stored file path is no longer the current location).
- The characters dictionary keys and the 'character' reference on the dialogue nodes data with the current file name of every character file referenced by UID or by path (key name to file name renaming).
Call it every time the dialogue file is loaded, and save the dialogue file again if this returns true, so the file is saved with the updated values. Returns true if any character reference was renamed or updated.