8 var item: TreeItem = null
11 func _ready() -> void:
13 %Character.resource_icon = load("res://addons/dialogic/Editor/Images/Resources/character.svg")
14 %Character.get_suggestions_func = get_character_suggestions
16 %WholeWords.icon = get_theme_icon("FontItem", "EditorIcons")
17 %MatchCase.icon = get_theme_icon("MatchCase", "EditorIcons")
19 func _on_add_pressed() -> void:
24 elif mode == Modes.EDIT:
27 %AddButton.text = "Add"
31 _on_type_item_selected(0)
33 _on_where_item_selected(2)
38 func open_existing(_item:TreeItem, info:Dictionary):
42 %AddButton.text = "Update"
43 %Type.selected = info.type
44 _on_type_item_selected(info.type)
45 if !info.character_names.is_empty():
47 %Character.set_value(info.character_names[0])
50 _on_where_item_selected(%Where.selected)
53 %New.text = info.forwhat
55 func _on_type_item_selected(index:int) -> void:
59 %Where.set_item_disabled(0, false)
60 %Where.set_item_disabled(1, false)
61 %Where.set_item_disabled(2, true)
64 %Where.set_item_disabled(0, false)
65 %Where.set_item_disabled(1, false)
66 %Where.set_item_disabled(2, true)
69 %Where.set_item_disabled(0, true)
70 %Where.set_item_disabled(1, false)
71 %Where.set_item_disabled(2, true)
74 %Where.set_item_disabled(0, false)
75 %Where.set_item_disabled(1, true)
76 %Where.set_item_disabled(2, true)
77 %PureTextFlags.visible = index == 0
78 _on_where_item_selected(%Where.selected)
81 func _on_where_item_selected(index:int) -> void:
82 %Character.visible = index == 1
85 func get_character_suggestions(search_text:String) -> Dictionary:
88 #override the previous _character_directory with the meta, specifically for searching otherwise new nodes wont work
89 var _character_directory := DialogicResourceUtil.get_character_directory()
91 var icon := load("res://addons/dialogic/Editor/Images/Resources/character.svg")
92 suggestions['(No one)'] = {'value':null, 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]}
94 for resource in _character_directory.keys():
95 suggestions[resource] = {
97 'tooltip' : _character_directory[resource],
98 'icon' : icon.duplicate()}
103 if %Old.text.is_empty() or %New.text.is_empty():
105 if %Where.selected == 1 and %Character.current_value == null:
109 if mode == Modes.EDIT:
110 previous = item.get_metadata(0)
114 var ref_manager := find_parent('ReferenceManager')
115 var character_names := []
116 if %Character.current_value != null:
117 character_names = [%Character.current_value]
118 ref_manager.add_ref_change(%Old.text, %New.text, %Type.selected, %Where.selected, character_names, %WholeWords.button_pressed, %MatchCase.button_pressed, previous)