4 var field: Control = null
5 var button: Button = null
6 # An internal value of the property.
7 var current_value: DialogicTimeline = null
8 # A guard against internal changes when the property is updated.
13 var hbox := HBoxContainer.new()
16 field = load("res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn").instantiate()
18 field.placeholder_text = "No Timeline"
19 field.size_flags_horizontal = Control.SIZE_EXPAND_FILL
20 field.size_flags_vertical = Control.SIZE_SHRINK_CENTER
21 field.mode = field.Modes.IDENTIFIER
22 field.fit_text_length = false
23 field.valid_file_drop_extension = ".dtl"
24 field.value_changed.connect(_on_field_value_changed)
25 field.get_suggestions_func = get_timeline_suggestions
28 hbox.add_child(button)
30 button.pressed.connect(_on_button_pressed, CONNECT_DEFERRED)
33 func _on_field_value_changed(property:String, value:Variant) -> void:
34 # Ignore the signal if the property is currently being updated.
38 var new_value: DialogicTimeline = null
40 new_value = DialogicResourceUtil.get_timeline_resource(value)
42 if current_value != new_value:
43 current_value = new_value
48 emit_changed(get_edited_property(), current_value)
51 func _update_property() -> void:
52 field.resource_icon = get_theme_icon("TripleBar", "EditorIcons")
53 button.icon = get_theme_icon("ExternalLink", "EditorIcons")
55 # Read the current value from the property.
56 var new_value = get_edited_object()[get_edited_property()]
57 if (new_value == current_value):
60 # Update the control with the new value.
62 current_value = new_value
64 field.set_value(DialogicResourceUtil.get_unique_identifier(current_value.resource_path))
72 func get_timeline_suggestions(filter:String) -> Dictionary:
74 var timeline_directory := DialogicResourceUtil.get_timeline_directory()
75 for identifier in timeline_directory.keys():
76 suggestions[identifier] = {'value': identifier, 'tooltip':timeline_directory[identifier], 'editor_icon': ["TripleBar", "EditorIcons"]}
80 func _on_button_pressed() -> void:
82 EditorInterface.edit_resource(current_value)