]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Style/character_settings_style.gd
Squashed commit of the following:
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Style / character_settings_style.gd
1 @tool
2 extends DialogicCharacterEditorMainSection
3
4 ## Character editor tab that allows setting a custom style fot the character.
5
6 func _init() -> void:
7         hint_text = 'If a character style is set, dialogic will switch to this style, whenever the character speaks. \nFor this it\'s best to use a variation of the same layout to avoid instancing a lot.'
8
9 func _get_title() -> String:
10         return "Style"
11
12
13 func _ready() -> void:
14         %StyleName.resource_icon = get_theme_icon("PopupMenu", "EditorIcons")
15         %StyleName.get_suggestions_func = get_style_suggestions
16
17
18 func _load_character(character:DialogicCharacter) -> void:
19         %StyleName.set_value(character.custom_info.get('style', ''))
20
21
22 func _save_changes(character:DialogicCharacter) -> DialogicCharacter:
23         character.custom_info['style'] = %StyleName.current_value
24         return character
25
26
27 func get_style_suggestions(filter:String="") -> Dictionary:
28         var styles: Array = ProjectSettings.get_setting('dialogic/layout/style_list', [])
29         var suggestions := {}
30         suggestions["No Style"] = {'value': "", 'editor_icon': ["EditorHandleDisabled", "EditorIcons"]}
31         for i in styles:
32                 var style: DialogicStyle = load(i)
33                 suggestions[style.name] = {'value': style.name, 'editor_icon': ["PopupMenu", "EditorIcons"]}
34         return suggestions