@@ -3,40 +3,61 @@ extends Control
33
44var editor_reference
55
6+ # The amazing and revolutionary path system that magically works and you can't
7+ # complain because "that is not how you are supposed to work". If there was only
8+ # a way to set an id and then access that node via id...
9+ # Here you have paths in all its glory. Praise the paths (っ´ω`c)♡
10+ onready var nodes = {
11+ 'shadow_bool' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/CheckBoxShadow ,
12+ 'shadow_picker' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/ColorPickerButtonShadow ,
13+ 'color_picker' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/ColorPickerButton ,
14+ 'font_button' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/FontButton ,
15+ 'shadow_offset_x' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/HBoxContainer/ShadowOffsetX ,
16+ 'shadow_offset_y' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/HBoxContainer/ShadowOffsetY ,
17+ 'text_speed' : $ VBoxContainer/HBoxContainer2/Text/GridContainer/TextSpeed ,
18+ 'text_offset_v' : $ VBoxContainer/HBoxContainer2/DialogBox/GridContainer/HBoxContainer/TextOffsetV ,
19+ 'text_offset_h' : $ VBoxContainer/HBoxContainer2/DialogBox/GridContainer/HBoxContainer/TextOffsetH ,
20+ 'background_texture_button' : $ VBoxContainer/HBoxContainer2/DialogBox/GridContainer/BackgroundTextureButton ,
21+ 'next_indicator_button' : $ VBoxContainer/HBoxContainer2/DialogBox/GridContainer/NextIndicatorButton ,
22+ 'next_action_button' : $ VBoxContainer/HBoxContainer2/DialogBox/GridContainer/BoxContainer/ActionOptionButton ,
23+ 'text_preview' : $ VBoxContainer/HBoxContainer3/TextEdit ,
24+ 'preview_panel' : $ VBoxContainer/Panel ,
25+ }
26+
627func _ready ():
728 var settings = DialogicUtil .load_settings ()
829 # Font
930 if settings .has ('theme_font' ):
10- $ VBoxContainer/HBoxContainer6/FontButton .text = settings ['theme_font' ]
31+ nodes [ 'font_button' ] .text = DialogicUtil . get_filename_from_path ( settings ['theme_font' ])
1132 # Text and shadows
1233 if settings .has ('theme_text_color' ):
13- $ VBoxContainer/HBoxContainer6/ColorPickerButton .color = Color ('#' + str (settings ['theme_text_color' ]))
34+ nodes [ 'color_picker' ] .color = Color ('#' + str (settings ['theme_text_color' ]))
1435 if settings .has ('theme_text_shadow' ):
15- $ VBoxContainer/HBoxContainer/CheckBoxShadow .pressed = settings ['theme_text_shadow' ]
36+ nodes [ 'shadow_bool' ] .pressed = settings ['theme_text_shadow' ]
1637 if settings .has ('theme_text_shadow_color' ):
17- $ VBoxContainer/HBoxContainer/ColorPickerButtonShadow .color = Color ('#' + str (settings ['theme_text_shadow_color' ]))
38+ nodes [ 'shadow_picker' ] .color = Color ('#' + str (settings ['theme_text_shadow_color' ]))
1839 if settings .has ('theme_shadow_offset_x' ):
19- $ VBoxContainer/HBoxContainer/ShadowOffsetX .value = settings ['theme_shadow_offset_x' ]
40+ nodes [ 'shadow_offset_x' ] .value = settings ['theme_shadow_offset_x' ]
2041 if settings .has ('theme_shadow_offset_y' ):
21- $ VBoxContainer/HBoxContainer/ShadowOffsetY .value = settings ['theme_shadow_offset_y' ]
42+ nodes [ 'shadow_offset_y' ] .value = settings ['theme_shadow_offset_y' ]
2243 # Text speed
2344 if settings .has ('theme_text_speed' ):
24- $ VBoxContainer/HBoxContainer6/TextSpeed .value = settings ['theme_text_speed' ]
45+ nodes [ 'text_speed' ] .value = settings ['theme_text_speed' ]
2546 # Margin
2647 if settings .has ('theme_text_margin' ):
27- $ VBoxContainer/HBoxContainer/TextMargin .value = settings ['theme_text_margin' ]
48+ nodes [ 'text_offset_v' ] .value = settings ['theme_text_margin' ]
2849 if settings .has ('theme_text_margin_h' ):
29- $ VBoxContainer/HBoxContainer/TextMarginH .value = settings ['theme_text_margin_h' ]
50+ nodes [ 'text_offset_h' ] .value = settings ['theme_text_margin_h' ]
3051
3152 # Images
3253 if settings .has ('theme_background_image' ):
33- $ VBoxContainer/HBoxContainer4/BackgroundTextureButton .text = settings ['theme_background_image' ]
54+ nodes [ 'background_texture_button' ] .text = DialogicUtil . get_filename_from_path ( settings ['theme_background_image' ])
3455 if settings .has ('theme_next_image' ):
35- $ VBoxContainer/HBoxContainer4/NextIndicatorButton .text = settings ['theme_next_image' ]
56+ nodes [ 'next_indicator_button' ] .text = DialogicUtil . get_filename_from_path ( settings ['theme_next_image' ])
3657
3758 # Action
3859 if settings .has ('theme_action_key' ):
39- $ VBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer/ActionOptionButton .text = settings ['theme_action_key' ]
60+ nodes [ 'next_action_button' ] .text = settings ['theme_action_key' ]
4061
4162 # Refreshing the dialog
4263 _on_PreviewButton_pressed ()
@@ -48,7 +69,7 @@ func _on_BackgroundTextureButton_pressed():
4869
4970func _on_background_selected (path , target ):
5071 DialogicUtil .update_setting ('theme_background_image' , path )
51- $ VBoxContainer/HBoxContainer4/BackgroundTextureButton .text = path
72+ nodes [ 'background_texture_button' ] .text = DialogicUtil . get_filename_from_path ( path )
5273
5374
5475func _on_NextIndicatorButton_pressed ():
@@ -58,7 +79,7 @@ func _on_NextIndicatorButton_pressed():
5879
5980func _on_indicator_selected (path , target ):
6081 DialogicUtil .update_setting ('theme_next_image' , path )
61- $ VBoxContainer/HBoxContainer4/NextIndicatorButton .text = path
82+ nodes [ 'next_indicator_button' ] .text = DialogicUtil . get_filename_from_path ( path )
6283
6384
6485func _on_ColorPickerButton_color_changed (color ):
@@ -67,44 +88,43 @@ func _on_ColorPickerButton_color_changed(color):
6788
6889func _on_ColorPickerButtonShadow_color_changed (color ):
6990 DialogicUtil .update_setting ('theme_text_shadow_color' , color .to_html ())
70- $ VBoxContainer/HBoxContainer/CheckBoxShadow .pressed = true
91+ nodes [ 'shadow_bool' ] .pressed = true
7192
7293
7394func _on_CheckBoxShadow_toggled (button_pressed ):
7495 DialogicUtil .update_setting ('theme_text_shadow' , button_pressed )
7596
7697
7798func _on_ShadowOffset_value_changed (_value ):
78- DialogicUtil .update_setting ('theme_shadow_offset_x' , $ VBoxContainer/HBoxContainer/ShadowOffsetX .value )
79- DialogicUtil .update_setting ('theme_shadow_offset_y' , $ VBoxContainer/HBoxContainer/ShadowOffsetY .value )
99+ DialogicUtil .update_setting ('theme_shadow_offset_x' , nodes [ 'shadow_offset_x' ] .value )
100+ DialogicUtil .update_setting ('theme_shadow_offset_y' , nodes [ 'shadow_offset_y' ] .value )
80101
81102
82103func _on_PreviewButton_pressed ():
83- for i in $ VBoxContainer/Panel .get_children ():
104+ for i in nodes [ 'preview_panel' ] .get_children ():
84105 i .free ()
85106 var dialogic_node = load ("res://addons/dialogic/Nodes/Dialog.tscn" )
86107 var preview_dialog = dialogic_node .instance ()
87108 preview_dialog .get_node ('TextBubble/NextIndicator/AnimationPlayer' ).play ('IDLE' )
88109 preview_dialog .dialog_script ['events' ] = [{
89110 "character" :"" ,
90111 "portrait" :"" ,
91- "text" : $ VBoxContainer/HBoxContainer5/TextEdit .text
112+ "text" : nodes [ 'text_preview' ] .text
92113 }]
93- $ VBoxContainer/Panel .add_child (preview_dialog )
114+ nodes [ 'preview_panel' ] .add_child (preview_dialog )
94115
95116
96117func _on_ActionOptionButton_item_selected (index ):
97- DialogicUtil .update_setting ('theme_action_key' , $ VBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer/ActionOptionButton .text )
118+ DialogicUtil .update_setting ('theme_action_key' , nodes [ 'next_action_button' ] .text )
98119
99120
100121func _on_ActionOptionButton_pressed ():
101- var action_option_button = $ VBoxContainer/VBoxContainer/HBoxContainer/VBoxContainer/ActionOptionButton
102- action_option_button .clear ()
103- action_option_button .add_item ('[Select Action]' )
122+ nodes ['next_action_button' ].clear ()
123+ nodes ['next_action_button' ].add_item ('[Select Action]' )
104124 InputMap .load_from_globals ()
105125 print (InputMap .get_actions ())
106126 for a in InputMap .get_actions ():
107- action_option_button .add_item (a )
127+ nodes [ 'next_action_button' ] .add_item (a )
108128
109129
110130func _on_FontButton_pressed ():
@@ -114,7 +134,7 @@ func _on_FontButton_pressed():
114134
115135func _on_Font_selected (path , target ):
116136 DialogicUtil .update_setting ('theme_font' , path )
117- $ VBoxContainer/HBoxContainer6/FontButton .text = path
137+ nodes [ 'font_button' ] .text = DialogicUtil . get_filename_from_path ( path )
118138
119139
120140func _on_textSpeed_value_changed (value ):
0 commit comments