@@ -64,11 +64,13 @@ func initialize_ui() -> void:
6464
6565 # Expand Button
6666 % ToggleBodyVisibilityButton .icon = get_theme_icon ("CodeFoldedRightArrow" , "EditorIcons" )
67+ % ToggleBodyVisibilityButton .begin_bulk_theme_override ()
6768 % ToggleBodyVisibilityButton .set ("theme_override_colors/icon_normal_color" , get_theme_color ("contrast_color_2" , "Editor" ))
6869 % ToggleBodyVisibilityButton .set ("theme_override_colors/icon_hover_color" , get_theme_color ("accent_color" , "Editor" ))
6970 % ToggleBodyVisibilityButton .set ("theme_override_colors/icon_pressed_color" , get_theme_color ("contrast_color_2" , "Editor" ))
7071 % ToggleBodyVisibilityButton .set ("theme_override_colors/icon_hover_pressed_color" , get_theme_color ("accent_color" , "Editor" ))
7172 % ToggleBodyVisibilityButton .add_theme_stylebox_override ('hover_pressed' , StyleBoxEmpty .new ())
73+ % ToggleBodyVisibilityButton .end_bulk_theme_override ()
7274
7375 # Icon Panel
7476 % IconPanel .tooltip_text = resource .event_name
@@ -153,31 +155,31 @@ func set_indent(indent: int) -> void:
153155#region EVENT FIELDS
154156## ##############################################################################
155157
156- var FIELD_SCENES := {
157- DialogicEvent .ValueType .MULTILINE_TEXT : "res://addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn" ,
158- DialogicEvent .ValueType .SINGLELINE_TEXT : "res://addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn" ,
159- DialogicEvent .ValueType .FILE : "res://addons/dialogic/Editor/Events/Fields/field_file.tscn" ,
160- DialogicEvent .ValueType .BOOL : "res://addons/dialogic/Editor/Events/Fields/field_bool_check.tscn" ,
161- DialogicEvent .ValueType .BOOL_BUTTON : "res://addons/dialogic/Editor/Events/Fields/field_bool_button.tscn" ,
162- DialogicEvent .ValueType .CONDITION : "res://addons/dialogic/Editor/Events/Fields/field_condition.tscn" ,
163- DialogicEvent .ValueType .ARRAY : "res://addons/dialogic/Editor/Events/Fields/field_array.tscn" ,
164- DialogicEvent .ValueType .DICTIONARY : "res://addons/dialogic/Editor/Events/Fields/field_dictionary.tscn" ,
165- DialogicEvent .ValueType .DYNAMIC_OPTIONS : "res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" ,
166- DialogicEvent .ValueType .FIXED_OPTIONS : "res://addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn" ,
167- DialogicEvent .ValueType .NUMBER : "res://addons/dialogic/Editor/Events/Fields/field_number.tscn" ,
168- DialogicEvent .ValueType .VECTOR2 : "res://addons/dialogic/Editor/Events/Fields/field_vector2.tscn" ,
169- DialogicEvent .ValueType .VECTOR3 : "res://addons/dialogic/Editor/Events/Fields/field_vector3.tscn" ,
170- DialogicEvent .ValueType .VECTOR4 : "res://addons/dialogic/Editor/Events/Fields/field_vector4.tscn" ,
171- DialogicEvent .ValueType .COLOR : "res://addons/dialogic/Editor/Events/Fields/field_color.tscn" ,
172- DialogicEvent .ValueType .AUDIO_PREVIEW : "res://addons/dialogic/Editor/Events/Fields/field_audio_preview.tscn" ,
173- DialogicEvent .ValueType .IMAGE_PREVIEW : "res://addons/dialogic/Editor/Events/Fields/field_image_preview.tscn" ,
158+ static var FIELD_SCENES := {
159+ DialogicEvent .ValueType .MULTILINE_TEXT : preload ( "res://addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn" ) ,
160+ DialogicEvent .ValueType .SINGLELINE_TEXT : preload ( "res://addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn" ) ,
161+ DialogicEvent .ValueType .FILE : preload ( "res://addons/dialogic/Editor/Events/Fields/field_file.tscn" ) ,
162+ DialogicEvent .ValueType .BOOL : preload ( "res://addons/dialogic/Editor/Events/Fields/field_bool_check.tscn" ) ,
163+ DialogicEvent .ValueType .BOOL_BUTTON : preload ( "res://addons/dialogic/Editor/Events/Fields/field_bool_button.tscn" ) ,
164+ DialogicEvent .ValueType .CONDITION : preload ( "res://addons/dialogic/Editor/Events/Fields/field_condition.tscn" ) ,
165+ DialogicEvent .ValueType .ARRAY : preload ( "res://addons/dialogic/Editor/Events/Fields/field_array.tscn" ) ,
166+ DialogicEvent .ValueType .DICTIONARY : preload ( "res://addons/dialogic/Editor/Events/Fields/field_dictionary.tscn" ) ,
167+ DialogicEvent .ValueType .DYNAMIC_OPTIONS : preload ( "res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" ) ,
168+ DialogicEvent .ValueType .FIXED_OPTIONS : preload ( "res://addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn" ) ,
169+ DialogicEvent .ValueType .NUMBER : preload ( "res://addons/dialogic/Editor/Events/Fields/field_number.tscn" ) ,
170+ DialogicEvent .ValueType .VECTOR2 : preload ( "res://addons/dialogic/Editor/Events/Fields/field_vector2.tscn" ) ,
171+ DialogicEvent .ValueType .VECTOR3 : preload ( "res://addons/dialogic/Editor/Events/Fields/field_vector3.tscn" ) ,
172+ DialogicEvent .ValueType .VECTOR4 : preload ( "res://addons/dialogic/Editor/Events/Fields/field_vector4.tscn" ) ,
173+ DialogicEvent .ValueType .COLOR : preload ( "res://addons/dialogic/Editor/Events/Fields/field_color.tscn" ) ,
174+ DialogicEvent .ValueType .AUDIO_PREVIEW : preload ( "res://addons/dialogic/Editor/Events/Fields/field_audio_preview.tscn" ) ,
175+ DialogicEvent .ValueType .IMAGE_PREVIEW : preload ( "res://addons/dialogic/Editor/Events/Fields/field_image_preview.tscn" ) ,
174176 }
175177
176178
177179func build_editor (build_header :bool = true , build_body :bool = false ) -> void :
178- var debug := true
180+ # var debug := false
181+ # var start_time := Time.get_unix_time_from_system()
179182
180- var start_time := Time .get_unix_time_from_system ()
181183 var current_body_container : HFlowContainer = null
182184
183185 if build_body and body_was_build :
@@ -190,19 +192,19 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
190192 % BodyContent .add_child (current_body_container )
191193 body_was_build = true
192194
193- if debug : printt ("" ,"Preloop: " , Time .get_unix_time_from_system ()- start_time )
195+ # if debug: printt("","Preloop: ", Time.get_unix_time_from_system()-start_time)
194196
195197 for p in resource .get_event_editor_info ():
196198 field_list .append ({'node' :null , 'location' :p .location })
197199 if p .has ('condition' ):
198200 field_list [- 1 ]['condition' ] = p .condition
199201
200- if debug : printt ("" ,"Element: " , p .name , Time .get_unix_time_from_system ()- start_time )
201- var element_start := Time .get_unix_time_from_system ()
202- var prev := Time .get_unix_time_from_system ()
203- if ! build_body and p .location == 1 :
202+ # if debug: printt("","Element: ", p.name, Time.get_unix_time_from_system()-start_time)
203+ # var element_start := Time.get_unix_time_from_system()
204+ # var prev := Time.get_unix_time_from_system()
205+ if not build_body and p .location == 1 :
204206 continue
205- elif ! build_header and p .location == 0 :
207+ elif not build_header and p .location == 0 :
206208 continue
207209
208210 ## # --------------------------------------------------------------------
@@ -212,14 +214,14 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
212214 ## # LINEBREAK
213215 if p .name == "linebreak" :
214216 field_list .remove_at (field_list .size ()- 1 )
215- if ! current_body_container .get_child_count ():
217+ if not current_body_container .get_child_count ():
216218 current_body_container .queue_free ()
217219 current_body_container = HFlowContainer .new ()
218220 % BodyContent .add_child (current_body_container )
219221 continue
220222
221223 elif p .field_type in FIELD_SCENES :
222- editor_node = load ( FIELD_SCENES [p .field_type ]) .instantiate ()
224+ editor_node = FIELD_SCENES [p .field_type ].instantiate ()
223225
224226 elif p .field_type == resource .ValueType .LABEL :
225227 editor_node = Label .new ()
@@ -251,27 +253,29 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
251253 editor_node .text = p .name
252254 editor_node .add_theme_color_override ('font_color' , resource .event_color .lerp (get_theme_color ("font_color" , "Editor" ), 0.8 ))
253255
254- if debug : printt ("" ,"" ,"A: " , Time .get_unix_time_from_system ()- prev )
255- prev = Time .get_unix_time_from_system ()
256+ # if debug: printt("","","A: ", Time.get_unix_time_from_system()-prev)
257+ # prev = Time.get_unix_time_from_system()
256258 field_list [- 1 ]['node' ] = editor_node
259+ editor_node .name = p .name .to_pascal_case ()
257260 ## # --------------------------------------------------------------------
258261 # Some things need to be called BEFORE the field is added to the tree
259262 if editor_node is DialogicVisualEditorField :
260263 editor_node .event_resource = resource
261264
262265 editor_node .property_name = p .name
266+
263267 field_list [- 1 ]['property' ] = p .name
264268
265269 editor_node ._load_display_info (p .display_info )
266270
267- if debug : printt ("" ,"" ,"B: " , Time .get_unix_time_from_system ()- prev )
268- prev = Time .get_unix_time_from_system ()
271+ # if debug: printt("","","B: ", Time.get_unix_time_from_system()-prev)
272+ # prev = Time.get_unix_time_from_system()
269273 var location : Control = % HeaderContent
270274 if p .location == 1 :
271275 location = current_body_container
272276 location .add_child (editor_node )
273- if debug : printt ("" ,"" ,"C: " , Time .get_unix_time_from_system ()- prev )
274- prev = Time .get_unix_time_from_system ()
277+ # if debug: printt("","","C: ", Time.get_unix_time_from_system()-prev)
278+ # prev = Time.get_unix_time_from_system()
275279 # Some things need to be called AFTER the field is added to the tree
276280 if editor_node is DialogicVisualEditorField :
277281 ## Only set the value if the field is visible
@@ -293,28 +297,28 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
293297 # Apply autofocus
294298 if resource .created_by_button and p .display_info .get ('autofocus' , false ):
295299 editor_node .call_deferred ('take_autofocus' )
296- if debug : printt ("" ,"" ,"D: " , Time .get_unix_time_from_system ()- prev )
297- prev = Time .get_unix_time_from_system ()
300+ # if debug: printt("","","D: ", Time.get_unix_time_from_system()-prev)
301+ # prev = Time.get_unix_time_from_system()
298302 ## # --------------------------------------------------------------------
299303 ## # 4. ADD LEFT AND RIGHT TEXT
300304 var left_label : Label = null
301305 var right_label : Label = null
302- if ! p .get ('left_text' , '' ).is_empty ():
306+ if not p .get ('left_text' , '' ).is_empty ():
303307 left_label = Label .new ()
304308 left_label .text = p .get ('left_text' )
305309 left_label .vertical_alignment = VERTICAL_ALIGNMENT_CENTER
306310 left_label .add_theme_color_override ('font_color' , resource .event_color .lerp (get_theme_color ("font_color" , "Editor" ), 0.8 ))
307311 location .add_child (left_label )
308312 location .move_child (left_label , editor_node .get_index ())
309- if ! p .get ('right_text' , '' ).is_empty ():
313+ if not p .get ('right_text' , '' ).is_empty ():
310314 right_label = Label .new ()
311315 right_label .text = p .get ('right_text' )
312316 right_label .vertical_alignment = VERTICAL_ALIGNMENT_CENTER
313317 right_label .add_theme_color_override ('font_color' , resource .event_color .lerp (get_theme_color ("font_color" , "Editor" ), 0.8 ))
314318 location .add_child (right_label )
315319 location .move_child (right_label , editor_node .get_index ()+ 1 )
316- if debug : printt ("" ,"" ,"E: " , Time .get_unix_time_from_system ()- prev )
317- prev = Time .get_unix_time_from_system ()
320+ # if debug: printt("","","E: ", Time.get_unix_time_from_system()-prev)
321+ # prev = Time.get_unix_time_from_system()
318322 ## # --------------------------------------------------------------------
319323 ## # 5. REGISTER CONDITION
320324 if p .has ('condition' ):
@@ -324,25 +328,27 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
324328 if right_label :
325329 field_list .append ({'node' : right_label , 'condition' :p .condition , 'location' :p .location })
326330
327- if debug : printt ("" ,"" ,"Z: " , Time .get_unix_time_from_system ()- prev )
328- if debug : printt ("" ,"" ,"Full: " , Time .get_unix_time_from_system ()- element_start )
331+ # if debug: printt("","","Z: ", Time.get_unix_time_from_system()-prev)
332+ # if debug: printt("","","Full: ", Time.get_unix_time_from_system()-element_start)
329333
330- if debug : printt ("" , "BlockB: " , Time .get_unix_time_from_system ()- start_time )
334+ # if debug: printt("", "BlockB: ", Time.get_unix_time_from_system()-start_time)
331335
332336 if build_body :
333337 if current_body_container .get_child_count () == 0 :
334338 % Body .visible = false
335- if debug : printt ("" , "BlockC: " , Time .get_unix_time_from_system ()- start_time )
339+ # if debug: printt("", "BlockC: ", Time.get_unix_time_from_system()-start_time)
336340
337341 recalculate_field_visibility ()
338342
339- if debug : printt ("" , "BlockFull: " , Time .get_unix_time_from_system ()- start_time )
343+ # if debug: printt("", "BlockFull: ", Time.get_unix_time_from_system()-start_time)
340344
341345
342346func recalculate_field_visibility () -> void :
343347 has_any_enabled_body_content = false
344348 for field in field_list :
345- if field .get ("condition" , "" ).is_empty () or _evaluate_visibility_condition (field ):
349+ if not field .node and has_any_enabled_body_content :
350+ continue
351+ if _evaluate_visibility_condition (field ):
346352 if field .node :
347353 if field .has ("condition" ) and (not field .node .visible ) and field .has ("property" ):
348354 field .node ._set_value (resource .get (field .property ))
@@ -356,25 +362,6 @@ func recalculate_field_visibility() -> void:
356362 if field .node != null :
357363 field .node .hide ()
358364
359- # for p in field_list:
360- # if not p.has('condition') or p.condition.is_empty():
361- # if p.node != null:
362- # p.node.show()
363- # if p.location == 1:
364- # has_any_enabled_body_content = true
365- #
366- # else:
367- # if _evaluate_visibility_condition(p):
368- # if p.node != null:
369- # if p.node.visible == false and p.has("property"):
370- # p.node._set_value(resource.get(p.property))
371- # p.node.show()
372- # if p.location == 1:
373- # has_any_enabled_body_content = true
374- # else:
375- # if p.node != null:
376- # p.node.hide()
377-
378365 % ToggleBodyVisibilityButton .visible = has_any_enabled_body_content
379366
380367
@@ -386,8 +373,9 @@ func set_property(property_name:String, value:Variant) -> void:
386373
387374
388375func _evaluate_visibility_condition (field : Dictionary ) -> bool :
389- # if
390- #
376+ if field .get ("condition" , "" ).is_empty ():
377+ return true
378+
391379 var expr : Expression
392380 var cache : Dictionary = Engine .get_meta ("dialogic_visibility_condition_cache" , {})
393381 if field .condition in cache :
@@ -423,11 +411,9 @@ func _on_resource_ui_update_needed() -> void:
423411 # This prevents events with varied value types (event_setting, event_variable)
424412 # from injecting incorrect types into hidden fields, which then throw errors
425413 # in the console.
426- if node_info .has ('condition' ) and not node_info .condition .is_empty ():
427- if _evaluate_visibility_condition (node_info ):
428- node_info .node .set_value (resource .get (node_info .property ))
429- else :
414+ if _evaluate_visibility_condition (node_info ):
430415 node_info .node .set_value (resource .get (node_info .property ))
416+
431417 recalculate_field_visibility ()
432418
433419
0 commit comments