]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Style/event_style.gd
Updated export config options
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Style / event_style.gd
1 @tool
2 class_name DialogicStyleEvent
3 extends DialogicEvent
4
5 ## Event that allows changing the currently displayed style.
6
7
8 ### Settings
9
10 ## The name of the style to change to. Can be set on the DialogicNode_Style.
11 var style_name := ""
12
13
14 ################################################################################
15 ##                                              EXECUTE
16 ################################################################################
17
18 func _execute() -> void:
19         dialogic.Styles.change_style(style_name)
20         # we need to wait till the new layout is ready before continuing
21         await dialogic.get_tree().process_frame
22         finish()
23
24
25 ################################################################################
26 ##                                              INITIALIZE
27 ################################################################################
28
29 func _init() -> void:
30         event_name = "Change Style"
31         set_default_color('Color8')
32         event_category = "Visuals"
33         event_sorting_index = 1
34
35
36 ################################################################################
37 ##                                              SAVING/LOADING
38 ################################################################################
39 func get_shortcode() -> String:
40         return "style"
41
42
43 func get_shortcode_parameters() -> Dictionary:
44         return {
45                 #param_name : property_info
46                 "name"          : {"property": "style_name", "default": "", 'suggestions':get_style_suggestions},
47         }
48
49
50 ################################################################################
51 ##                                              EDITOR REPRESENTATION
52 ################################################################################
53
54 func build_event_editor() -> void:
55         add_header_edit('style_name', ValueType.DYNAMIC_OPTIONS, {
56                         'left_text'                     :'Use style',
57                         'placeholder'           : 'Default',
58                         'suggestions_func'      : get_style_suggestions,
59                         'editor_icon'           : ["PopupMenu", "EditorIcons"],
60                         'autofocus'                     : true})
61
62
63 func get_style_suggestions(_filter := "") -> Dictionary:
64         var styles: Array = ProjectSettings.get_setting('dialogic/layout/style_list', [])
65
66         var suggestions := {}
67         suggestions['<Default Style>'] = {'value':'', 'editor_icon':["MenuBar", "EditorIcons"]}
68         for i in styles:
69                 var style: DialogicStyle = load(i)
70                 suggestions[style.name] = {'value': style.name, 'editor_icon': ["PopupMenu", "EditorIcons"]}
71         return suggestions