@@ -6,6 +6,8 @@ onready var master_tree = get_node('../MasterTreeContainer/MasterTree')
66onready var settings_editor = get_node ('../SettingsEditor' )
77var current_theme : String = ''
88
9+ var use_advanced_themes := false
10+
911# When loading the variables to the input fields in the
1012# load_theme function, every element thinks the value was updated
1113# so it has to perform a "saving" of that property.
@@ -17,6 +19,14 @@ var loading : bool = true
1719# complain because "that is not how you are supposed to work". If there was only
1820# a way to set an id and then access that node via id...
1921# Here you have paths in all its glory. Praise the paths (っ´ω`c)♡
22+
23+ onready var advanced_containers := {
24+ 'buttons' : {
25+ 'container' : $ "VBoxContainer/TabContainer/Choice Buttons/Column3/GridContainer" ,
26+ 'disabled_text' : $ "VBoxContainer/TabContainer/Choice Buttons/Column3/Label"
27+ }
28+ }
29+
2030onready var n : Dictionary = {
2131 # Dialog Text
2232 'theme_text_shadow' : $ "VBoxContainer/TabContainer/Dialog Text/Column/GridContainer/HBoxContainer2/CheckBoxShadow" ,
@@ -71,6 +81,8 @@ onready var n : Dictionary = {
7181 'button_modulation' : $ "VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer6/CheckBox" ,
7282 'button_modulation_color' : $ "VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/HBoxContainer6/ColorPickerButton" ,
7383 'button_use_native' : $ "VBoxContainer/TabContainer/Choice Buttons/Column/GridContainer/CheckBox" ,
84+ 'button_use_custom' : $ "VBoxContainer/TabContainer/Choice Buttons/Column3/GridContainer/HBoxContainer5/CustomButtonsCheckBox" ,
85+ 'button_custom_path' : $ "VBoxContainer/TabContainer/Choice Buttons/Column3/GridContainer/HBoxContainer5/CustomButtonsButton" ,
7486 'button_offset_x' : $ "VBoxContainer/TabContainer/Choice Buttons/Column2/GridContainer/HBoxContainer/TextOffsetH" ,
7587 'button_offset_y' : $ "VBoxContainer/TabContainer/Choice Buttons/Column2/GridContainer/HBoxContainer/TextOffsetV" ,
7688 'button_separation' : $ "VBoxContainer/TabContainer/Choice Buttons/Column2/GridContainer/VerticalSeparation" ,
@@ -106,10 +118,24 @@ func _ready() -> void:
106118 _on_visibility_changed ()
107119
108120
121+ func setup_advanced_containers ():
122+ use_advanced_themes = DialogicResources .get_settings_config ().get_value ('dialog' , 'advanced_themes' , false )
123+
124+ for key in advanced_containers :
125+ var c = advanced_containers [key ]
126+ if use_advanced_themes :
127+ c ["container" ].show ()
128+ c ["disabled_text" ].hide ()
129+ else :
130+ c ["container" ].hide ()
131+ c ["disabled_text" ].show ()
132+
133+
109134func load_theme (filename ):
110135 loading = true
111136 current_theme = filename
112137 var theme = DialogicResources .get_theme_config (filename )
138+ setup_advanced_containers ()
113139 # Settings
114140 n ['theme_action_key' ].text = theme .get_value ('settings' , 'action_key' , 'ui_accept' )
115141
@@ -142,6 +168,8 @@ func load_theme(filename):
142168 n ['button_image' ].text = DialogicResources .get_filename_from_path (theme .get_value ('buttons' , 'image' , 'res://addons/dialogic/Example Assets/backgrounds/background-2.png' ))
143169 n ['button_image_visible' ].pressed = theme .get_value ('buttons' , 'use_image' , true )
144170 n ['button_use_native' ].pressed = theme .get_value ('buttons' , 'use_native' , false )
171+ n ['button_use_custom' ].pressed = theme .get_value ('buttons' , 'use_custom' , false )
172+ n ['button_custom_path' ].text = DialogicResources .get_filename_from_path (theme .get_value ('buttons' , 'custom_path' , "" ))
145173 n ['button_offset_x' ].value = theme .get_value ('buttons' , 'padding' , Vector2 (5 ,5 )).x
146174 n ['button_offset_y' ].value = theme .get_value ('buttons' , 'padding' , Vector2 (5 ,5 )).y
147175 n ['button_separation' ].value = theme .get_value ('buttons' , 'gap' , 5 )
@@ -151,7 +179,7 @@ func load_theme(filename):
151179 n ['button_fixed_x' ].value = theme .get_value ('buttons' , 'fixed_size' , Vector2 (130 ,40 )).x
152180 n ['button_fixed_y' ].value = theme .get_value ('buttons' , 'fixed_size' , Vector2 (130 ,40 )).y
153181
154- toggle_button_customization_fields (not theme .get_value ('buttons' , 'use_native' , false ))
182+ toggle_button_customization_fields (theme .get_value ('buttons' , 'use_native' , false ), theme . get_value ( 'buttons' , 'use_custom ' , false ))
155183
156184 # Definitions
157185 n ['glossary_color' ].color = Color (theme .get_value ('definitions' , 'color' , "#ffffffff" ))
@@ -461,20 +489,42 @@ func _on_native_button_toggled(button_pressed) -> void:
461489 if loading :
462490 return
463491 DialogicResources .set_theme_value (current_theme , 'buttons' , 'use_native' , button_pressed )
464- toggle_button_customization_fields (not button_pressed )
465-
466- func toggle_button_customization_fields (enabled ) -> void :
467- var disabled = not enabled
468- n ['button_text_color_enabled' ].disabled = disabled
469- n ['button_text_color' ].disabled = disabled
470- n ['button_background' ].disabled = disabled
471- n ['button_background_visible' ].disabled = disabled
472- n ['button_image' ].disabled = disabled
473- n ['button_image_visible' ].disabled = disabled
474- n ['button_modulation' ].disabled = disabled
475- n ['button_modulation_color' ].disabled = disabled
476- n ['button_offset_x' ].editable = enabled
477- n ['button_offset_y' ].editable = enabled
492+ toggle_button_customization_fields (button_pressed , false )
493+
494+
495+ func toggle_button_customization_fields (native_enabled : bool , custom_enabled : bool ) -> void :
496+ var customization_disabled = native_enabled or custom_enabled
497+ n ['button_text_color_enabled' ].disabled = customization_disabled
498+ n ['button_text_color' ].disabled = customization_disabled
499+ n ['button_background' ].disabled = customization_disabled
500+ n ['button_background_visible' ].disabled = customization_disabled
501+ n ['button_image' ].disabled = customization_disabled
502+ n ['button_image_visible' ].disabled = customization_disabled
503+ n ['button_modulation' ].disabled = customization_disabled
504+ n ['button_modulation_color' ].disabled = customization_disabled
505+ n ['button_use_native' ].disabled = custom_enabled
506+ n ['button_use_custom' ].disabled = native_enabled
507+ n ['button_custom_path' ].disabled = native_enabled
508+ n ['button_offset_x' ].editable = not customization_disabled
509+ n ['button_offset_y' ].editable = not customization_disabled
510+
511+
512+ func _on_CustomButtonsCheckBox_toggled (button_pressed ):
513+ if loading :
514+ return
515+ DialogicResources .set_theme_value (current_theme , 'buttons' , 'use_custom' , button_pressed )
516+ toggle_button_customization_fields (false , button_pressed )
517+
518+
519+ func _on_CustomButtonsButton_pressed ():
520+ editor_reference .godot_dialog ("*.tscn" )
521+ editor_reference .godot_dialog_connect (self , "_on_custom_button_selected" )
522+
523+ func _on_custom_button_selected (path , target ) -> void :
524+ if loading :
525+ return
526+ DialogicResources .set_theme_value (current_theme , 'buttons' , 'custom_path' , path )
527+ n ['button_custom_path' ].text = DialogicResources .get_filename_from_path (path )
478528
479529
480530func _on_GlossaryColorPicker_color_changed (color ) -> void :
0 commit comments