SproutyDialogsCharacterData
Inherits: Resource
Description
This resource stores data for a character in the dialogue system.
It includes the character's key name or identifier, translations of the name, description, dialog box reference and portraits.
Properties
| Type | Name | Default |
|---|---|---|
| Dictionary | display_name | {} |
| String | description | "" |
| String | dialog_box_path | "" |
| bool | portrait_on_dialog_box | false |
| String | default_portrait | "" |
| Dictionary | main_transform_settings | See description |
| Dictionary | portraits | {} |
| Dictionary | typing_sounds | {} |
Methods
| Return Type | Method |
|---|---|
| Variant | get_portrait_from_path_name(path_name: String, group: Dictionary = {"data": portraits}) |
| String | get_csv_name_key() |
| bool | sync_key_name() |
Property Descriptions
var display_name : Dictionary = {}
Name of the character that will be displayed in the dialogue. The display name can be localized to different languages, so it is stored as a dictionary where each key is a locale code (e.g., "en", "fr") and its value is the name translated in that locale. Example:
{
"en": "Name in English",
"es": "Nombre en Español",
...
}
var description : String = ""
Character description. This does nothing, its only for your reference.
var dialog_box_path : String = ""
Path to the dialog box scene to display the character's dialogue. This is stored as a fallback to load the dialog box when its stored UID is no longer valid. This is for reference only, the dialog box is set from the character editor.
var portrait_on_dialog_box : bool = false
Flag to indicate if the character's portrait should be displayed on the dialog box. If true, the character's portrait scene will be shown in the portrait display node of the DialogBox. For this you need to set the portrait display node that will hold the portrait as a parent of the portrait scene.
var default_portrait : String = ""
Name of the default portrait to use for this character. If set, this portrait will be used when no specific portrait is specified in the dialogue.
var main_transform_settings : Dictionary
Transform settings for all the character portraits. This is a dictionary with the following keys:
- scale: the scale of the portrait.
- scale_lock_ratio: whether to lock the aspect ratio of the scale.
- offset: the offset of the portrait.
- rotation: the rotation of the portrait in degrees.
- mirror: whether to mirror the portrait.
Default values:
{
"scale": Vector2.ONE,
"scale_lock_ratio": true,
"offset": Vector2.ZERO,
"rotation": 0.0,
"mirror": false
}
var portraits : Dictionary = {}
Character's portraits. This is a dictionary where each key is a portrait name or a group of portraits and its value is a dictionary containing the portrait data or more portraits.
The dictionary structure is as follows:
{
"portrait_name_1": {
"index" : 0,
"data": SproutyDialogsPortraitData (SubResource)
},
"portrait_group": {
"index" : 1,
"data": {
"portrait_name_2": {
"index" : 0,
"data": SproutyDialogsPortraitData (SubResource)
},
...
},
...
},
...
}
var typing_sounds : Dictionary = {}
Typing sounds for the character. This is a dictionary where each key is the sound name (e.g., "typing_1") and its value is a dictionary containing the sound data.
The dictionary structure is as follows:
{
"sound_1": {
"path": "res://path/to/typing_1.wav",
"volume": 0.5,
"pitch": 1.0
},
"sound_2": {
"path": "res://path/to/typing_2.wav",
"volume": 0.5,
"pitch": 1.0
},
...
}
(Not used yet, typing sounds implementation is pending)!
Method Descriptions
func get_portrait_from_path_name(path_name: String, group: Dictionary = {"data": portraits}) -> Variant
Returns the portrait data for a given portrait path name. The path name can be a portrait name or a path (e.g., "group/portrait"). If the portrait is a group, it will recursively search for the portrait data.
func get_csv_name_key() -> String
Returns the translation key used on the CSV file for this character's display name. Characters created before the CSV name key existed may have it empty, in that case it falls back to the key derived from the key name.
func sync_key_name() -> bool
Updates the key name to match the current file name of this character resource. It should be called every time the character file is loaded so the key name is always the current file name. Returns true if any property was updated (the key name or the CSV name key), so the caller can save the changes to the file.