From be2ecd60e7504bdacb4f8eae35b89b501a42edce Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Wed, 19 Jun 2024 02:31:11 -0700 Subject: [PATCH 01/15] Better Character Suggestions! - Character Events now suggest characters already in the timeline first. - Text Events now suggest characters already in the timeline first. - Text Events now place the most character from the most recent (relative to the text event) character event in the timeline first. --- .../Modules/Character/event_character.gd | 10 +++++++ addons/dialogic/Modules/Text/event_text.gd | 27 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 78b803650..135a9ab6e 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -458,7 +458,17 @@ func get_character_suggestions(_search_text:String) -> Dictionary: var character_directory = DialogicResourceUtil.get_character_directory() if action == Actions.LEAVE: suggestions['ALL'] = {'value':'--All--', 'tooltip':'All currently joined characters leave', 'editor_icon':["GuiEllipsis", "EditorIcons"]} + # Get characters in the current timeline and place them at the top of suggestions. + var timeline_node = editor_node.get_parent().find_parent("Timeline") as DialogicEditor + if timeline_node.current_resource is DialogicTimeline: + var timeline := timeline_node.current_resource as DialogicTimeline + var character_events := timeline.events.filter(func (event): return event is DialogicCharacterEvent) + var characters_in_timeline := character_events.map(func (event): return event.character) + for character in characters_in_timeline: + suggestions[character.get_character_name()] = {'value': character.get_character_name(), 'tooltip': character.resource_path, 'icon': icon.duplicate()} for resource in character_directory.keys(): + if suggestions.has(resource): + continue suggestions[resource] = {'value': resource, 'tooltip': character_directory[resource], 'icon': icon.duplicate()} return suggestions diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index 4c905361b..073626b9a 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -386,9 +386,34 @@ func get_character_suggestions(_search_text:String) -> Dictionary: var icon = load("res://addons/dialogic/Editor/Images/Resources/character.svg") suggestions['(No one)'] = {'value':null, 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]} - var character_directory := DialogicResourceUtil.get_character_directory() + # Get characters in the current timeline and place them at the top of suggestions. + var timeline_node = editor_node.get_parent().find_parent("Timeline") as DialogicEditor + if timeline_node.current_resource is DialogicTimeline: + var timeline := timeline_node.current_resource as DialogicTimeline + var this_event_idx := timeline.events.find(self) + var character_events := {} + for i in range(0, timeline.events.size()): + if timeline.events[i] is DialogicCharacterEvent: + character_events[i] = timeline.events[i] + # Find the closest character event before this text event, and place it at the top of suggestions. + var closest_character_event_idx := -1 + for i in range(this_event_idx, -1, -1): + if character_events.has(i): + closest_character_event_idx = i + break + if closest_character_event_idx != -1: + var character_event := character_events[closest_character_event_idx] as DialogicCharacterEvent + var event_character := character_event.character + suggestions[character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} + for _character in character_events.values(): + var event_character = _character.event_character + if suggestions.has(event_character.get_character_name()): + continue + suggestions[character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} for resource in character_directory.keys(): + if suggestions.has(resource): + continue suggestions[resource] = { 'value' : resource, 'tooltip' : character_directory[resource], From 2514487def886d912770800472c5c07e8c43746a Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Wed, 19 Jun 2024 02:41:22 -0700 Subject: [PATCH 02/15] Fixed shadowed variable in event_text.gd - character was shadowing from the outer scope, updated to event_character - More descriptive and less likely to shadow --- addons/dialogic/Modules/Text/event_text.gd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index 073626b9a..cbf4b7b4c 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -405,12 +405,12 @@ func get_character_suggestions(_search_text:String) -> Dictionary: if closest_character_event_idx != -1: var character_event := character_events[closest_character_event_idx] as DialogicCharacterEvent var event_character := character_event.character - suggestions[character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} + suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} for _character in character_events.values(): - var event_character = _character.event_character + var event_character = _character.character if suggestions.has(event_character.get_character_name()): continue - suggestions[character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} + suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} for resource in character_directory.keys(): if suggestions.has(resource): continue From 79f35971168dc3870c9835d1a17bc26eaea830b9 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Wed, 19 Jun 2024 18:27:05 +0200 Subject: [PATCH 03/15] Small fixes - make character.get_character_name() return Unique Identifier if possible - add check to avoid error when a character event doesn't have a character set --- addons/dialogic/Modules/Character/event_character.gd | 2 ++ addons/dialogic/Resources/character.gd | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 135a9ab6e..976099379 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -465,6 +465,8 @@ func get_character_suggestions(_search_text:String) -> Dictionary: var character_events := timeline.events.filter(func (event): return event is DialogicCharacterEvent) var characters_in_timeline := character_events.map(func (event): return event.character) for character in characters_in_timeline: + if not character: + continue suggestions[character.get_character_name()] = {'value': character.get_character_name(), 'tooltip': character.resource_path, 'icon': icon.duplicate()} for resource in character_directory.keys(): if suggestions.has(resource): diff --git a/addons/dialogic/Resources/character.gd b/addons/dialogic/Resources/character.gd index 529d97468..229d15efd 100644 --- a/addons/dialogic/Resources/character.gd +++ b/addons/dialogic/Resources/character.gd @@ -123,11 +123,14 @@ func get_display_name_translated() -> String: return _get_property_translated(TranslatedProperties.NAME) -## Returns the name of the file (without the extension). +## Returns the best name for this character. func get_character_name() -> String: - if !resource_path.is_empty(): + var unique_identifier := DialogicResourceUtil.get_unique_identifier(resource_path) + if not unique_identifier.is_empty(): + return unique_identifier + if not resource_path.is_empty(): return resource_path.get_file().trim_suffix('.dch') - elif !display_name.is_empty(): + elif not display_name.is_empty(): return display_name.validate_node_name() else: return "UnnamedCharacter" From 0df8b4df06356fb469865a738995aab9d3b43636 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Wed, 19 Jun 2024 10:32:06 -0700 Subject: [PATCH 04/15] Clean up and improve - Now acknowleges character and text events. - Live updates! - Ignores null values in characters and text events. - Only searches up the timeline relevant to the current event. --- .../Modules/Character/event_character.gd | 16 ++++++---- addons/dialogic/Modules/Text/event_text.gd | 32 ++++++------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 135a9ab6e..fc2503cac 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -460,12 +460,16 @@ func get_character_suggestions(_search_text:String) -> Dictionary: suggestions['ALL'] = {'value':'--All--', 'tooltip':'All currently joined characters leave', 'editor_icon':["GuiEllipsis", "EditorIcons"]} # Get characters in the current timeline and place them at the top of suggestions. var timeline_node = editor_node.get_parent().find_parent("Timeline") as DialogicEditor - if timeline_node.current_resource is DialogicTimeline: - var timeline := timeline_node.current_resource as DialogicTimeline - var character_events := timeline.events.filter(func (event): return event is DialogicCharacterEvent) - var characters_in_timeline := character_events.map(func (event): return event.character) - for character in characters_in_timeline: - suggestions[character.get_character_name()] = {'value': character.get_character_name(), 'tooltip': character.resource_path, 'icon': icon.duplicate()} + var event_nodes = timeline_node.find_child("Timeline").get_children() + event_nodes.reverse() + var this_event_idx := event_nodes.find(editor_node) + event_nodes = event_nodes.slice(this_event_idx, event_nodes.size()) + for event_node in event_nodes: + var event = event_node.resource + if event is DialogicCharacterEvent: + var event_character = event.character + if event_character: + suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} for resource in character_directory.keys(): if suggestions.has(resource): continue diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index cbf4b7b4c..ab05597b1 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -389,28 +389,16 @@ func get_character_suggestions(_search_text:String) -> Dictionary: var character_directory := DialogicResourceUtil.get_character_directory() # Get characters in the current timeline and place them at the top of suggestions. var timeline_node = editor_node.get_parent().find_parent("Timeline") as DialogicEditor - if timeline_node.current_resource is DialogicTimeline: - var timeline := timeline_node.current_resource as DialogicTimeline - var this_event_idx := timeline.events.find(self) - var character_events := {} - for i in range(0, timeline.events.size()): - if timeline.events[i] is DialogicCharacterEvent: - character_events[i] = timeline.events[i] - # Find the closest character event before this text event, and place it at the top of suggestions. - var closest_character_event_idx := -1 - for i in range(this_event_idx, -1, -1): - if character_events.has(i): - closest_character_event_idx = i - break - if closest_character_event_idx != -1: - var character_event := character_events[closest_character_event_idx] as DialogicCharacterEvent - var event_character := character_event.character - suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} - for _character in character_events.values(): - var event_character = _character.character - if suggestions.has(event_character.get_character_name()): - continue - suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} + var event_nodes = timeline_node.find_child("Timeline").get_children() + event_nodes.reverse() + var this_event_idx := event_nodes.find(editor_node) + event_nodes = event_nodes.slice(this_event_idx, event_nodes.size()) + for event_node in event_nodes: + var event = event_node.resource + if event is DialogicCharacterEvent or event is DialogicTextEvent: + var event_character = event.character + if event_character: + suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} for resource in character_directory.keys(): if suggestions.has(resource): continue From 28b8f04876323940f020c7c83a4ba50907098453 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Thu, 20 Jun 2024 18:40:15 +0200 Subject: [PATCH 05/15] Cleanup suggestions code --- .../Modules/Character/event_character.gd | 25 +++++++++-------- addons/dialogic/Modules/Text/event_text.gd | 27 ++++++++++--------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index fc2503cac..162300567 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -458,18 +458,21 @@ func get_character_suggestions(_search_text:String) -> Dictionary: var character_directory = DialogicResourceUtil.get_character_directory() if action == Actions.LEAVE: suggestions['ALL'] = {'value':'--All--', 'tooltip':'All currently joined characters leave', 'editor_icon':["GuiEllipsis", "EditorIcons"]} + # Get characters in the current timeline and place them at the top of suggestions. - var timeline_node = editor_node.get_parent().find_parent("Timeline") as DialogicEditor - var event_nodes = timeline_node.find_child("Timeline").get_children() - event_nodes.reverse() - var this_event_idx := event_nodes.find(editor_node) - event_nodes = event_nodes.slice(this_event_idx, event_nodes.size()) - for event_node in event_nodes: - var event = event_node.resource - if event is DialogicCharacterEvent: - var event_character = event.character - if event_character: - suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} + var recent_characters := [] + var timeline_node := editor_node.get_parent().find_parent("Timeline") as DialogicEditor + for event_node in timeline_node.find_child("Timeline").get_children(): + if event_node == editor_node: + break + if event_node.resource is DialogicCharacterEvent: + recent_characters.append(event_node.resource.character) + + recent_characters.reverse() + for character in recent_characters: + if character and not character.get_character_name() in suggestions: + suggestions[character.get_character_name()] = {'value': character.get_character_name(), 'tooltip': character.resource_path, 'icon': icon.duplicate()} + for resource in character_directory.keys(): if suggestions.has(resource): continue diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index ab05597b1..277542b04 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -386,19 +386,22 @@ func get_character_suggestions(_search_text:String) -> Dictionary: var icon = load("res://addons/dialogic/Editor/Images/Resources/character.svg") suggestions['(No one)'] = {'value':null, 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]} - var character_directory := DialogicResourceUtil.get_character_directory() + # Get characters in the current timeline and place them at the top of suggestions. - var timeline_node = editor_node.get_parent().find_parent("Timeline") as DialogicEditor - var event_nodes = timeline_node.find_child("Timeline").get_children() - event_nodes.reverse() - var this_event_idx := event_nodes.find(editor_node) - event_nodes = event_nodes.slice(this_event_idx, event_nodes.size()) - for event_node in event_nodes: - var event = event_node.resource - if event is DialogicCharacterEvent or event is DialogicTextEvent: - var event_character = event.character - if event_character: - suggestions[event_character.get_character_name()] = {'value': event_character.get_character_name(), 'tooltip': event_character.resource_path, 'icon': icon.duplicate()} + var recent_characters := [] + var timeline_node := editor_node.get_parent().find_parent("Timeline") as DialogicEditor + for event_node in timeline_node.find_child("Timeline").get_children(): + if event_node == editor_node: + break + if event_node.resource is DialogicCharacterEvent or event_node.resource is DialogicTextEvent: + recent_characters.append(event_node.resource.character) + + recent_characters.reverse() + for character in recent_characters: + if character and not character.get_character_name() in suggestions: + suggestions[character.get_character_name()] = {'value': character.get_character_name(), 'tooltip': character.resource_path, 'icon': icon.duplicate()} + + var character_directory := DialogicResourceUtil.get_character_directory() for resource in character_directory.keys(): if suggestions.has(resource): continue From 53b16f918d5d189a1c7bd10a706a1adb24624157 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Wed, 24 Jul 2024 10:04:22 -0700 Subject: [PATCH 06/15] Work in progress --- .../Editor/Common/ResourceItemList.gd | 21 ++ addons/dialogic/Editor/Common/side_bar.tscn | 84 ++++- addons/dialogic/Editor/Common/sidebar.gd | 243 +++++++++++---- .../Editor/Images/Pieces/close-icon.svg | 1 + .../Images/Pieces/close-icon.svg.import | 38 +++ addons/dialogic/Editor/editor_main.gd | 286 +++++++++++------- addons/dialogic/Editor/editor_main.tscn | 28 +- 7 files changed, 503 insertions(+), 198 deletions(-) create mode 100644 addons/dialogic/Editor/Common/ResourceItemList.gd create mode 100644 addons/dialogic/Editor/Images/Pieces/close-icon.svg create mode 100644 addons/dialogic/Editor/Images/Pieces/close-icon.svg.import diff --git a/addons/dialogic/Editor/Common/ResourceItemList.gd b/addons/dialogic/Editor/Common/ResourceItemList.gd new file mode 100644 index 000000000..b8d7bfecc --- /dev/null +++ b/addons/dialogic/Editor/Common/ResourceItemList.gd @@ -0,0 +1,21 @@ +class_name ResourceListItem extends Object +var text: String +var index: int = -1 +var icon: Texture +var metadata: String +var tooltip: String + + +func add_to_item_list(item_list: ItemList, current_file: String) -> void: + item_list.add_item(text, icon) + item_list.set_item_metadata(item_list.item_count - 1, metadata) + item_list.set_item_tooltip(item_list.item_count - 1, tooltip) + + +func current_file(sidebar: Control, resource_list: ItemList, current_file: String) -> void: + if metadata == current_file: + resource_list.select(index) + resource_list.set_item_custom_fg_color( + index, resource_list.get_theme_color("accent_color", "Editor") + ) + sidebar.find_child("CurrentResource").text = metadata.get_file() diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index f37f54532..dd72e4312 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://cwe3r2tbh2og1"] +[gd_scene load_steps=7 format=3 uid="uid://cwe3r2tbh2og1"] [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/sidebar.gd" id="1_jnq65"] +[ext_resource type="Texture2D" uid="uid://bff65e82555qr" path="res://addons/dialogic/Editor/Images/Pieces/close-icon.svg" id="2_54pks"] +[ext_resource type="Texture2D" uid="uid://dx3o2ild56i76" path="res://addons/dialogic/Editor/Images/Pieces/closed-icon.svg" id="2_ilyps"] [sub_resource type="Theme" id="Theme_pn0f4"] VBoxContainer/constants/separation = 4 @@ -20,24 +22,42 @@ theme = SubResource("Theme_pn0f4") split_offset = 100 script = ExtResource("1_jnq65") -[node name="VBox" type="VBoxContainer" parent="."] +[node name="VBoxHidden" type="VBoxContainer" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 2 + +[node name="OpenButton" type="Button" parent="VBoxHidden"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 3 +tooltip_text = "Show Sidebar" +text = " " +icon = ExtResource("2_ilyps") +flat = true +icon_alignment = 1 +expand_icon = true + +[node name="VBoxPrimary" type="VBoxContainer" parent="."] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 -[node name="Margin" type="MarginContainer" parent="VBox"] +[node name="Margin" type="MarginContainer" parent="VBoxPrimary"] layout_mode = 2 size_flags_vertical = 3 theme_override_constants/margin_left = 5 theme_override_constants/margin_bottom = 5 -[node name="VSplitContainer" type="VSplitContainer" parent="VBox/Margin"] +[node name="VSplitContainer" type="VSplitContainer" parent="VBoxPrimary/Margin"] layout_mode = 2 -[node name="VBox" type="VBoxContainer" parent="VBox/Margin/VSplitContainer"] +[node name="VBox" type="VBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer"] layout_mode = 2 size_flags_vertical = 3 -[node name="Logo" type="TextureRect" parent="VBox/Margin/VSplitContainer/VBox"] +[node name="Logo" type="TextureRect" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true modulate = Color(1, 1, 1, 0.623529) texture_filter = 6 @@ -46,7 +66,10 @@ layout_mode = 2 expand_mode = 3 stretch_mode = 4 -[node name="CurrentResource" type="LineEdit" parent="VBox/Margin/VSplitContainer/VBox"] +[node name="HBox" type="HBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] +layout_mode = 2 + +[node name="CurrentResource" type="LineEdit" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBox"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 @@ -54,25 +77,54 @@ text = "No resource" alignment = 1 editable = false -[node name="Search" type="LineEdit" parent="VBox/Margin/VSplitContainer/VBox"] +[node name="CloseButton" type="Button" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBox"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Hide Sidebar" +text = " " +icon = ExtResource("2_54pks") +flat = true +icon_alignment = 1 +expand_icon = true + +[node name="Search" type="LineEdit" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true layout_mode = 2 placeholder_text = "Filter Resources" caret_blink = true caret_blink_interval = 0.5 -[node name="ResourcesList" type="ItemList" parent="VBox/Margin/VSplitContainer/VBox"] +[node name="ResourceTree" type="Tree" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 -same_column_width = true +allow_rmb_select = true +hide_root = true +scroll_horizontal_enabled = false + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] +visible = false +layout_mode = 2 + +[node name="Label" type="Label" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxContainer"] +layout_mode = 2 +size_flags_vertical = 1 +text = "Sort Order" +vertical_alignment = 1 + +[node name="SortOption" type="OptionButton" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +selected = 0 +item_count = 1 +popup/item_0/text = "Alphabetical (All)" -[node name="ContentListSection" type="VBoxContainer" parent="VBox/Margin/VSplitContainer"] +[node name="ContentListSection" type="VBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 -[node name="ContentList" type="ItemList" parent="VBox/Margin/VSplitContainer/ContentListSection"] +[node name="ContentList" type="ItemList" parent="VBoxPrimary/Margin/VSplitContainer/ContentListSection"] unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 @@ -82,7 +134,7 @@ theme_override_styles/selected_focus = SubResource("StyleBoxEmpty_n8rql") allow_reselect = true same_column_width = true -[node name="CurrentVersion" type="Button" parent="VBox"] +[node name="CurrentVersion" type="Button" parent="VBoxPrimary"] unique_name_in_owner = true layout_mode = 2 text = "Some Version" @@ -93,7 +145,7 @@ clip_text = true unique_name_in_owner = true size = Vector2i(164, 100) -[connection signal="gui_input" from="VBox/Margin/VSplitContainer/VBox/Logo" to="." method="_on_logo_gui_input"] -[connection signal="text_changed" from="VBox/Margin/VSplitContainer/VBox/Search" to="." method="_on_search_text_changed"] -[connection signal="pressed" from="VBox/CurrentVersion" to="." method="_on_current_version_pressed"] +[connection signal="gui_input" from="VBoxPrimary/Margin/VSplitContainer/VBox/Logo" to="." method="_on_logo_gui_input"] +[connection signal="text_changed" from="VBoxPrimary/Margin/VSplitContainer/VBox/Search" to="." method="_on_search_text_changed"] +[connection signal="pressed" from="VBoxPrimary/CurrentVersion" to="." method="_on_current_version_pressed"] [connection signal="id_pressed" from="RightClickMenu" to="." method="_on_right_click_menu_id_pressed"] diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index a86274513..1f553ff83 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -7,7 +7,11 @@ signal file_activated(file_path) signal content_item_activated(item_name) +signal show_sidebar(show: bool) + @onready var editors_manager = get_parent().get_parent() +@onready var resource_tree: Tree = %ResourceTree +var current_resource_list: Array = [] func _ready() -> void: @@ -15,12 +19,19 @@ func _ready() -> void: return ## CONNECTIONS - %ResourcesList.item_selected.connect(_on_resources_list_item_selected) - %ResourcesList.item_clicked.connect(_on_resources_list_item_clicked) + editors_manager.resource_opened.connect(_on_editors_resource_opened) editors_manager.editor_changed.connect(_on_editors_editor_changed) - %ContentList.item_selected.connect(func (idx:int): content_item_activated.emit(%ContentList.get_item_text(idx))) + resource_tree.item_selected.connect(_on_resources_tree_item_selected) + resource_tree.item_mouse_selected.connect(_on_resources_tree_item_clicked) + + %ContentList.item_selected.connect( + func(idx: int): content_item_activated.emit(%ContentList.get_item_text(idx)) + ) + + (%OpenButton as Button).pressed.connect(_show_sidebar) + (%CloseButton as Button).pressed.connect(_hide_sidebar) var editor_scale := DialogicUtil.get_editor_scale() ## ICONS @@ -28,41 +39,73 @@ func _ready() -> void: %Logo.custom_minimum_size.y = 30 * editor_scale %Search.right_icon = get_theme_icon("Search", "EditorIcons") - - %ContentList.add_theme_color_override("font_hovered_color", get_theme_color("warning_color", "Editor")) - %ContentList.add_theme_color_override("font_selected_color", get_theme_color("property_color_z", "Editor")) + %ContentList.add_theme_color_override( + "font_hovered_color", get_theme_color("warning_color", "Editor") + ) + %ContentList.add_theme_color_override( + "font_selected_color", get_theme_color("property_color_z", "Editor") + ) ## MARGINS - $VBox/Margin.set("theme_override_constants/margin_left", get_theme_constant("base_margin", "Editor") * editor_scale) - $VBox/Margin.set("theme_override_constants/margin_bottom", get_theme_constant("base_margin", "Editor") * editor_scale) + %VBoxPrimary/Margin.set( + "theme_override_constants/margin_left", + get_theme_constant("base_margin", "Editor") * editor_scale + ) + %VBoxPrimary/Margin.set( + "theme_override_constants/margin_bottom", + get_theme_constant("base_margin", "Editor") * editor_scale + ) ## RIGHT CLICK MENU %RightClickMenu.clear() %RightClickMenu.add_icon_item(get_theme_icon("Remove", "EditorIcons"), "Remove From List", 1) %RightClickMenu.add_separator() - %RightClickMenu.add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), "Show in FileSystem", 2) - %RightClickMenu.add_icon_item(get_theme_icon("ExternalLink", "EditorIcons"), "Open in External Program", 3) + %RightClickMenu.add_icon_item( + get_theme_icon("Filesystem", "EditorIcons"), "Show in FileSystem", 2 + ) + %RightClickMenu.add_icon_item( + get_theme_icon("ExternalLink", "EditorIcons"), "Open in External Program", 3 + ) + + +################################################################################ +## SHOW/HIDE SIDEBAR +################################################################################ + + +func _show_sidebar() -> void: + %VBoxPrimary.show() + %VBoxHidden.hide() + show_sidebar.emit(true) + + +func _hide_sidebar() -> void: + %VBoxPrimary.hide() + %VBoxHidden.show() + show_sidebar.emit(false) ################################################################################ ## RESOURCE LIST ################################################################################ -func _on_editors_resource_opened(resource:Resource) -> void: - update_resource_list() +func _on_editors_resource_opened(resource: Resource) -> void: + # update_resource_list() + pass -func _on_editors_editor_changed(previous:DialogicEditor, current:DialogicEditor) -> void: + +func _on_editors_editor_changed(previous: DialogicEditor, current: DialogicEditor) -> void: %ContentListSection.visible = current.current_resource is DialogicTimeline update_resource_list() -func clean_resource_list(resources_list:Array = []) -> PackedStringArray: +func clean_resource_list(resources_list: Array = []) -> PackedStringArray: return PackedStringArray(resources_list.filter(func(x): return ResourceLoader.exists(x))) -func update_resource_list(resources_list:PackedStringArray = []) -> void: - var filter :String = %Search.text +func update_resource_list(resources_list: PackedStringArray = []) -> void: + var filter: String = %Search.text var current_file := "" if editors_manager.current_editor and editors_manager.current_editor.current_resource: current_file = editors_manager.current_editor.current_resource.resource_path @@ -70,88 +113,148 @@ func update_resource_list(resources_list:PackedStringArray = []) -> void: var character_directory: Dictionary = DialogicResourceUtil.get_character_directory() var timeline_directory: Dictionary = DialogicResourceUtil.get_timeline_directory() if resources_list.is_empty(): - resources_list = DialogicUtil.get_editor_setting('last_resources', []) + resources_list = DialogicUtil.get_editor_setting("last_resources", []) if !current_file in resources_list: resources_list.append(current_file) resources_list = clean_resource_list(resources_list) - %CurrentResource.text = "No Resource" - %CurrentResource.add_theme_color_override("font_uneditable_color", get_theme_color("disabled_font_color", "Editor")) - %ResourcesList.clear() - var idx := 0 + %CurrentResource.text = "No Resource" + %CurrentResource.add_theme_color_override( + "font_uneditable_color", get_theme_color("disabled_font_color", "Editor") + ) + resource_tree.clear() + #TODO: This is still super broken. + var resource_list_items = [] + + var character_items = [] for character_name in character_directory: if character_directory[character_name] in resources_list: if filter.is_empty() or filter.to_lower() in character_name.to_lower(): - %ResourcesList.add_item( - character_name, - load("res://addons/dialogic/Editor/Images/Resources/character.svg")) - %ResourcesList.set_item_metadata(idx, character_directory[character_name]) - %ResourcesList.set_item_tooltip(idx, character_directory[character_name]) - if character_directory[character_name] == current_file: - %ResourcesList.select(idx) - %ResourcesList.set_item_custom_fg_color(idx, get_theme_color("accent_color", "Editor")) - %CurrentResource.text = character_directory[character_name].get_file() - idx += 1 + var item = ResourceListItem.new() + item.text = character_name + item.icon = load("res://addons/dialogic/Editor/Images/Resources/character.svg") + item.metadata = character_directory[character_name] + item.tooltip = character_directory[character_name] + character_items.append(item) + + var timeline_items = [] for timeline_name in timeline_directory: if timeline_directory[timeline_name] in resources_list: if filter.is_empty() or filter.to_lower() in timeline_name.to_lower(): - %ResourcesList.add_item(timeline_name, get_theme_icon("TripleBar", "EditorIcons")) - %ResourcesList.set_item_metadata(idx, timeline_directory[timeline_name]) - if timeline_directory[timeline_name] == current_file: - %ResourcesList.select(idx) - %ResourcesList.set_item_custom_fg_color(idx, get_theme_color("accent_color", "Editor")) - %CurrentResource.text = timeline_name+'.dtl' - idx += 1 + var item = ResourceListItem.new() + item.text = timeline_name + item.icon = get_theme_icon("TripleBar", "EditorIcons") + item.metadata = timeline_directory[timeline_name] + item.tooltip = timeline_directory[timeline_name] + timeline_items.append(item) + + character_items.sort_custom(_sort_by_item_text) + timeline_items.sort_custom(_sort_by_item_text) + + # TREE + var root: TreeItem = resource_tree.create_item() + var debug_string = "[b]Tree: [/b]\n\t%s\n[b]TreeRoot: [/b]\n\t%s\n[b]Root: [/b]\n\t%s" % [resource_tree,resource_tree.get_root(), root] + print_rich(debug_string) + if root == null: + return + + if character_items.size() > 0: + var character_tree = resource_tree.create_item(root) + character_tree.set_text(0, "Characters") + character_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + character_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + for item in character_items: + var character_item = resource_tree.create_item(character_tree) + character_item.set_text(0, item.text) + character_item.set_icon(0, item.icon) + character_item.set_metadata(0, item.metadata) + character_item.set_tooltip_text(0, item.tooltip) + if timeline_items.size() > 0: + var timeline_tree = resource_tree.create_item(root) as TreeItem + timeline_tree.set_text(0, "Timelines") + timeline_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + timeline_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + for item in timeline_items: + var timeline_item = resource_tree.create_item(timeline_tree) as TreeItem + timeline_item.set_text(0, item.text) + timeline_item.set_icon(0, item.icon) + timeline_item.set_metadata(0, item.metadata) + timeline_item.set_tooltip_text(0, item.tooltip) + if %CurrentResource.text != "No Resource": - %CurrentResource.add_theme_color_override("font_uneditable_color", get_theme_color("font_color", "Editor")) - %ResourcesList.sort_items_by_text() - DialogicUtil.set_editor_setting('last_resources', resources_list) + %CurrentResource.add_theme_color_override( + "font_uneditable_color", get_theme_color("font_color", "Editor") + ) + DialogicUtil.set_editor_setting("last_resources", resources_list) + #TODO: Implement the " When searching the first item should be focused so enter actually opens that item." -func _on_resources_list_item_selected(index:int) -> void: +func _on_resources_list_item_selected(index: int) -> void: if %ResourcesList.get_item_metadata(index) == null: return editors_manager.edit_resource(load(%ResourcesList.get_item_metadata(index))) -func _on_resources_list_item_clicked(index: int, at_position: Vector2, mouse_button_index: int) -> void: +func _on_resources_list_item_clicked( + index: int, at_position: Vector2, mouse_button_index: int +) -> void: # If clicked with the middle mouse button, remove the item from the list if mouse_button_index == MOUSE_BUTTON_MIDDLE: remove_item_from_list(index) if mouse_button_index == MOUSE_BUTTON_RIGHT: %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) - %RightClickMenu.set_meta('item_index', index) + %RightClickMenu.set_meta("item_index", index) + + +func _on_resources_tree_item_selected() -> void: + print("Selected\n\t{%s}" % resource_tree.get_selected()) + if resource_tree.get_selected() == null: + return + var item := resource_tree.get_selected() + if item.get_metadata(0) == null: + return + editors_manager.edit_resource(load(item.get_metadata(0))) -func _on_search_text_changed(new_text:String) -> void: +func _on_resources_tree_item_clicked(_pos: Vector2, mouse_button_index: int) -> void: + print("Clicked, mouse_button_index: ", mouse_button_index) + if mouse_button_index == MOUSE_BUTTON_MIDDLE: + remove_item_from_list(resource_tree.get_selected()) + if mouse_button_index == MOUSE_BUTTON_RIGHT: + %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) + %RightClickMenu.set_meta("item_index", resource_tree.get_selected()) + + +func _on_search_text_changed(new_text: String) -> void: update_resource_list() -func set_unsaved_indicator(saved:bool = true) -> void: - if saved and %CurrentResource.text.ends_with('(*)'): - %CurrentResource.text = %CurrentResource.text.trim_suffix('(*)') - if not saved and not %CurrentResource.text.ends_with('(*)'): - %CurrentResource.text = %CurrentResource.text+"(*)" +func set_unsaved_indicator(saved: bool = true) -> void: + if saved and %CurrentResource.text.ends_with("(*)"): + %CurrentResource.text = %CurrentResource.text.trim_suffix("(*)") + if not saved and not %CurrentResource.text.ends_with("(*)"): + %CurrentResource.text = %CurrentResource.text + "(*)" -func _on_logo_gui_input(event:InputEvent) -> void: +func _on_logo_gui_input(event: InputEvent) -> void: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: - editors_manager.open_editor(editors_manager.editors['HomePage'].node) + editors_manager.open_editor(editors_manager.editors["HomePage"].node) -func update_content_list(list:PackedStringArray) -> void: +func update_content_list(list: PackedStringArray) -> void: var prev_selected := "" if %ContentList.is_anything_selected(): prev_selected = %ContentList.get_item_text(%ContentList.get_selected_items()[0]) %ContentList.clear() - %ContentList.add_item('~ Top') + %ContentList.add_item("~ Top") for i in list: - if i.is_empty(): continue + if i.is_empty(): + continue %ContentList.add_item(i) if i == prev_selected: - %ContentList.select(%ContentList.item_count-1) + %ContentList.select(%ContentList.item_count - 1) if list.is_empty(): return @@ -169,19 +272,31 @@ func update_content_list(list:PackedStringArray) -> void: DialogicResourceUtil.set_label_cache(label_directory) + func remove_item_from_list(index) -> void: var new_list := [] - for entry in DialogicUtil.get_editor_setting('last_resources', []): + for entry in DialogicUtil.get_editor_setting("last_resources", []): if entry != %ResourcesList.get_item_metadata(index): new_list.append(entry) - DialogicUtil.set_editor_setting('last_resources', new_list) + DialogicUtil.set_editor_setting("last_resources", new_list) %ResourcesList.remove_item(index) -func _on_right_click_menu_id_pressed(id:int) -> void: + +func _on_right_click_menu_id_pressed(id: int) -> void: match id: - 1: # REMOVE ITEM FROM LIST + 1: # REMOVE ITEM FROM LIST remove_item_from_list(%RightClickMenu.get_meta("item_index")) - 2: # OPEN IN FILESYSTEM - EditorInterface.get_file_system_dock().navigate_to_path(%ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_index"))) - 3: # OPEN IN EXTERNAL EDITOR - OS.shell_open(ProjectSettings.globalize_path(%ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_index")))) + 2: # OPEN IN FILESYSTEM + EditorInterface.get_file_system_dock().navigate_to_path( + %ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_index")) + ) + 3: # OPEN IN EXTERNAL EDITOR + OS.shell_open( + ProjectSettings.globalize_path( + %ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_index")) + ) + ) + + +func _sort_by_item_text(a: ResourceListItem, b: ResourceListItem) -> bool: + return a.text < b.text diff --git a/addons/dialogic/Editor/Images/Pieces/close-icon.svg b/addons/dialogic/Editor/Images/Pieces/close-icon.svg new file mode 100644 index 000000000..3e3f7af3b --- /dev/null +++ b/addons/dialogic/Editor/Images/Pieces/close-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/addons/dialogic/Editor/Images/Pieces/close-icon.svg.import b/addons/dialogic/Editor/Images/Pieces/close-icon.svg.import new file mode 100644 index 000000000..cbc36f218 --- /dev/null +++ b/addons/dialogic/Editor/Images/Pieces/close-icon.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bff65e82555qr" +path="res://.godot/imported/close-icon.svg-c630c93ada599b08938f4854f5376f2f.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/dialogic/Editor/Images/Pieces/close-icon.svg" +dest_files=["res://.godot/imported/close-icon.svg-c630c93ada599b08938f4854f5376f2f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=true diff --git a/addons/dialogic/Editor/editor_main.gd b/addons/dialogic/Editor/editor_main.gd index f5c60d6e1..ea4573a45 100644 --- a/addons/dialogic/Editor/editor_main.gd +++ b/addons/dialogic/Editor/editor_main.gd @@ -13,9 +13,25 @@ func _ready() -> void: if get_parent() is SubViewport: return + ## CONNECTIONS + %Sidebar.show_sidebar.connect( + func(show: bool): + var h_split = (%HSplit as HSplitContainer) + if show: + h_split.dragger_visibility = SplitContainer.DRAGGER_VISIBLE + h_split.split_offset = 150 + h_split.collapsed = false + else: + h_split.dragger_visibility = SplitContainer.DRAGGER_HIDDEN_COLLAPSED + h_split.split_offset = 0 + h_split.collapsed = true + ) + ## REFERENCES editors_manager = $EditorsManager - var button :Button = editors_manager.add_icon_button(get_theme_icon("MakeFloating", "EditorIcons"), 'Make floating') + var button: Button = editors_manager.add_icon_button( + get_theme_icon("MakeFloating", "EditorIcons"), "Make floating" + ) button.pressed.connect(toggle_floating_window) # File dialog @@ -23,70 +39,97 @@ func _ready() -> void: add_child(editor_file_dialog) var info_message := Label.new() - info_message.add_theme_color_override('font_color', get_theme_color("warning_color", "Editor")) + info_message.add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")) editor_file_dialog.get_line_edit().get_parent().add_sibling(info_message) - info_message.get_parent().move_child(info_message, info_message.get_index()-1) - editor_file_dialog.set_meta('info_message_label', info_message) + info_message.get_parent().move_child(info_message, info_message.get_index() - 1) + editor_file_dialog.set_meta("info_message_label", info_message) - $SaveConfirmationDialog.add_button('No Saving Please!', true, 'nosave') + $SaveConfirmationDialog.add_button("No Saving Please!", true, "nosave") $SaveConfirmationDialog.hide() update_theme_additions() EditorInterface.get_base_control().theme_changed.connect(update_theme_additions) func update_theme_additions() -> void: - add_theme_stylebox_override("panel", DCSS.inline({ - 'background': get_theme_color("base_color", "Editor"), - 'padding': [5*DialogicUtil.get_editor_scale(), 5*DialogicUtil.get_editor_scale()], - })) - var holder_panel := DCSS.inline({ - 'border-radius':5, - #'border': 2, - #'border-color': get_theme_color("base_color", "Editor"), - 'background': get_theme_color("dark_color_2", "Editor"), - 'padding': [5*DialogicUtil.get_editor_scale(), 5*DialogicUtil.get_editor_scale()], - }) + add_theme_stylebox_override( + "panel", + ( + DCSS + . inline( + { + "background": get_theme_color("base_color", "Editor"), + "padding": + [5 * DialogicUtil.get_editor_scale(), 5 * DialogicUtil.get_editor_scale()], + } + ) + ) + ) + var holder_panel := ( + DCSS + . inline( + { + "border-radius": 5, + #'border': 2, + #'border-color': get_theme_color("base_color", "Editor"), + "background": get_theme_color("dark_color_2", "Editor"), + "padding": + [5 * DialogicUtil.get_editor_scale(), 5 * DialogicUtil.get_editor_scale()], + } + ) + ) holder_panel.border_width_top = 0 holder_panel.corner_radius_top_left = 0 - editors_manager.editors_holder.add_theme_stylebox_override('panel', holder_panel) + editors_manager.editors_holder.add_theme_stylebox_override("panel", holder_panel) if theme == null: theme = Theme.new() theme.clear() - theme.set_type_variation('DialogicTitle', 'Label') - theme.set_font('font', 'DialogicTitle', get_theme_font("title", "EditorFonts")) - theme.set_color('font_color', 'DialogicTitle', get_theme_color('warning_color', 'Editor')) - theme.set_color('font_uneditable_color', 'DialogicTitle', get_theme_color('warning_color', 'Editor')) - theme.set_color('font_selected_color', 'DialogicTitle', get_theme_color('warning_color', 'Editor')) - theme.set_font_size('font_size', 'DialogicTitle', get_theme_font_size("doc_size", "EditorFonts")) - - theme.set_type_variation('DialogicSubTitle', 'Label') - theme.set_font('font', 'DialogicSubTitle', get_theme_font("title", "EditorFonts")) - theme.set_font_size('font_size', 'DialogicSubTitle', get_theme_font_size("doc_size", "EditorFonts")) - theme.set_color('font_color', 'DialogicSubTitle', get_theme_color('accent_color', 'Editor')) - - theme.set_type_variation('DialogicPanelA', 'PanelContainer') - var panel_style := DCSS.inline({ - 'border-radius': 10, - 'background': get_theme_color("base_color", "Editor"), - 'padding': [5, 5], - }) - theme.set_stylebox('panel', 'DialogicPanelA', panel_style) - theme.set_stylebox('normal', 'DialogicPanelA', panel_style) + theme.set_type_variation("DialogicTitle", "Label") + theme.set_font("font", "DialogicTitle", get_theme_font("title", "EditorFonts")) + theme.set_color("font_color", "DialogicTitle", get_theme_color("warning_color", "Editor")) + theme.set_color( + "font_uneditable_color", "DialogicTitle", get_theme_color("warning_color", "Editor") + ) + theme.set_color( + "font_selected_color", "DialogicTitle", get_theme_color("warning_color", "Editor") + ) + theme.set_font_size( + "font_size", "DialogicTitle", get_theme_font_size("doc_size", "EditorFonts") + ) + + theme.set_type_variation("DialogicSubTitle", "Label") + theme.set_font("font", "DialogicSubTitle", get_theme_font("title", "EditorFonts")) + theme.set_font_size( + "font_size", "DialogicSubTitle", get_theme_font_size("doc_size", "EditorFonts") + ) + theme.set_color("font_color", "DialogicSubTitle", get_theme_color("accent_color", "Editor")) + + theme.set_type_variation("DialogicPanelA", "PanelContainer") + var panel_style := ( + DCSS + . inline( + { + "border-radius": 10, + "background": get_theme_color("base_color", "Editor"), + "padding": [5, 5], + } + ) + ) + theme.set_stylebox("panel", "DialogicPanelA", panel_style) + theme.set_stylebox("normal", "DialogicPanelA", panel_style) var dark_panel := panel_style.duplicate() dark_panel.bg_color = get_theme_color("dark_color_3", "Editor") - theme.set_stylebox('panel', 'DialogicPanelDarkA', dark_panel) + theme.set_stylebox("panel", "DialogicPanelDarkA", dark_panel) var cornerless_panel := panel_style.duplicate() cornerless_panel.corner_radius_top_left = 0 - theme.set_stylebox('panel', 'DialogicPanelA_cornerless', cornerless_panel) - + theme.set_stylebox("panel", "DialogicPanelA_cornerless", cornerless_panel) # panel used for example for portrait previews in character editor - theme.set_type_variation('DialogicPanelB', 'PanelContainer') - var side_panel :StyleBoxFlat= panel_style.duplicate() + theme.set_type_variation("DialogicPanelB", "PanelContainer") + var side_panel: StyleBoxFlat = panel_style.duplicate() side_panel.corner_radius_top_left = 0 side_panel.corner_radius_bottom_left = 0 side_panel.expand_margin_left = 8 @@ -94,82 +137,114 @@ func update_theme_additions() -> void: side_panel.set_border_width_all(1) side_panel.border_width_left = 0 side_panel.border_color = get_theme_color("contrast_color_2", "Editor") - theme.set_stylebox('panel', 'DialogicPanelB', side_panel) + theme.set_stylebox("panel", "DialogicPanelB", side_panel) - - theme.set_type_variation('DialogicEventEdit', 'Control') + theme.set_type_variation("DialogicEventEdit", "Control") var edit_panel := StyleBoxFlat.new() edit_panel.draw_center = true edit_panel.bg_color = get_theme_color("accent_color", "Editor") edit_panel.bg_color.a = 0.05 edit_panel.border_width_bottom = 2 - edit_panel.border_color = get_theme_color("accent_color", "Editor").lerp(get_theme_color("dark_color_2", "Editor"), 0.4) + edit_panel.border_color = get_theme_color("accent_color", "Editor").lerp( + get_theme_color("dark_color_2", "Editor"), 0.4 + ) edit_panel.content_margin_left = 5 edit_panel.content_margin_right = 5 edit_panel.set_corner_radius_all(1) - theme.set_stylebox('panel', 'DialogicEventEdit', edit_panel) - theme.set_stylebox('normal', 'DialogicEventEdit', edit_panel) + theme.set_stylebox("panel", "DialogicEventEdit", edit_panel) + theme.set_stylebox("normal", "DialogicEventEdit", edit_panel) var focus_edit := edit_panel.duplicate() focus_edit.border_color = get_theme_color("property_color_z", "Editor") focus_edit.draw_center = false - theme.set_stylebox('focus', 'DialogicEventEdit', focus_edit) + theme.set_stylebox("focus", "DialogicEventEdit", focus_edit) var hover_edit := edit_panel.duplicate() hover_edit.border_color = get_theme_color("warning_color", "Editor") - theme.set_stylebox('hover', 'DialogicEventEdit', hover_edit) + theme.set_stylebox("hover", "DialogicEventEdit", hover_edit) var disabled_edit := edit_panel.duplicate() disabled_edit.border_color = get_theme_color("property_color", "Editor") - theme.set_stylebox('disabled', 'DialogicEventEdit', disabled_edit) - - theme.set_type_variation('DialogicHintText', 'Label') - theme.set_color('font_color', 'DialogicHintText', get_theme_color("readonly_color", "Editor")) - theme.set_font('font', 'DialogicHintText', get_theme_font("doc_italic", "EditorFonts")) - - theme.set_type_variation('DialogicHintText2', 'Label') - theme.set_color('font_color', 'DialogicHintText2', get_theme_color("property_color_w", "Editor")) - theme.set_font('font', 'DialogicHintText2', get_theme_font("doc_italic", "EditorFonts")) - - theme.set_type_variation('DialogicSection', 'Label') - theme.set_font('font', 'DialogicSection', get_theme_font("main_msdf", "EditorFonts")) - theme.set_color('font_color', 'DialogicSection', get_theme_color("property_color_z", "Editor")) - theme.set_font_size('font_size', 'DialogicSection', get_theme_font_size("doc_size", "EditorFonts")) - - theme.set_type_variation('DialogicSettingsSection', 'DialogicSection') - theme.set_font('font', 'DialogicSettingsSection', get_theme_font("main_msdf", "EditorFonts")) - theme.set_color('font_color', 'DialogicSettingsSection', get_theme_color("property_color_z", "Editor")) - theme.set_font_size('font_size', 'DialogicSettingsSection', get_theme_font_size("doc_size", "EditorFonts")) - - theme.set_type_variation('DialogicSectionBig', 'DialogicSection') - theme.set_color('font_color', 'DialogicSectionBig', get_theme_color("accent_color", "Editor")) - theme.set_font_size('font_size', 'DialogicSectionBig', get_theme_font_size("doc_title_size", "EditorFonts")) - - theme.set_type_variation('DialogicLink', 'LinkButton') - theme.set_color('font_hover_color', 'DialogicLink', get_theme_color("warning_color", "Editor")) - - theme.set_type_variation('DialogicMegaSeparator', 'HSeparator') - theme.set_stylebox('separator', 'DialogicMegaSeparator', DCSS.inline({ - 'border-radius': 10, - 'border': 0, - 'background': get_theme_color("accent_color", "Editor"), - 'padding': [5, 5], - })) - theme.set_constant('separation', 'DialogicMegaSeparator', 50) - - theme.set_type_variation('DialogicTextEventTextEdit', 'CodeEdit') + theme.set_stylebox("disabled", "DialogicEventEdit", disabled_edit) + + theme.set_type_variation("DialogicHintText", "Label") + theme.set_color("font_color", "DialogicHintText", get_theme_color("readonly_color", "Editor")) + theme.set_font("font", "DialogicHintText", get_theme_font("doc_italic", "EditorFonts")) + + theme.set_type_variation("DialogicHintText2", "Label") + theme.set_color( + "font_color", "DialogicHintText2", get_theme_color("property_color_w", "Editor") + ) + theme.set_font("font", "DialogicHintText2", get_theme_font("doc_italic", "EditorFonts")) + + theme.set_type_variation("DialogicSection", "Label") + theme.set_font("font", "DialogicSection", get_theme_font("main_msdf", "EditorFonts")) + theme.set_color("font_color", "DialogicSection", get_theme_color("property_color_z", "Editor")) + theme.set_font_size( + "font_size", "DialogicSection", get_theme_font_size("doc_size", "EditorFonts") + ) + + theme.set_type_variation("DialogicSettingsSection", "DialogicSection") + theme.set_font("font", "DialogicSettingsSection", get_theme_font("main_msdf", "EditorFonts")) + theme.set_color( + "font_color", "DialogicSettingsSection", get_theme_color("property_color_z", "Editor") + ) + theme.set_font_size( + "font_size", "DialogicSettingsSection", get_theme_font_size("doc_size", "EditorFonts") + ) + + theme.set_type_variation("DialogicSectionBig", "DialogicSection") + theme.set_color("font_color", "DialogicSectionBig", get_theme_color("accent_color", "Editor")) + theme.set_font_size( + "font_size", "DialogicSectionBig", get_theme_font_size("doc_title_size", "EditorFonts") + ) + + theme.set_type_variation("DialogicLink", "LinkButton") + theme.set_color("font_hover_color", "DialogicLink", get_theme_color("warning_color", "Editor")) + + theme.set_type_variation("DialogicMegaSeparator", "HSeparator") + ( + theme + . set_stylebox( + "separator", + "DialogicMegaSeparator", + ( + DCSS + . inline( + { + "border-radius": 10, + "border": 0, + "background": get_theme_color("accent_color", "Editor"), + "padding": [5, 5], + } + ) + ) + ) + ) + theme.set_constant("separation", "DialogicMegaSeparator", 50) + + theme.set_type_variation("DialogicTextEventTextEdit", "CodeEdit") var editor_settings := plugin_reference.get_editor_interface().get_editor_settings() - var text_panel := DCSS.inline({ - 'border-radius': 8, - 'background': editor_settings.get_setting("text_editor/theme/highlighting/background_color").lerp( - editor_settings.get_setting("text_editor/theme/highlighting/text_color"), 0.05), - 'padding': [8, 8], - }) + var text_panel := ( + DCSS + . inline( + { + "border-radius": 8, + "background": + editor_settings.get_setting("text_editor/theme/highlighting/background_color").lerp( + editor_settings.get_setting("text_editor/theme/highlighting/text_color"), 0.05 + ), + "padding": [8, 8], + } + ) + ) text_panel.content_margin_bottom = 5 text_panel.content_margin_left = 13 - theme.set_stylebox('normal', 'DialogicTextEventTextEdit', text_panel) + theme.set_stylebox("normal", "DialogicTextEventTextEdit", text_panel) - theme.set_icon('Plugin', 'Dialogic', load("res://addons/dialogic/Editor/Images/plugin-icon.svg")) + theme.set_icon( + "Plugin", "Dialogic", load("res://addons/dialogic/Editor/Images/plugin-icon.svg") + ) ## Switches from floating window mode to embedded mode based on current mode @@ -200,7 +275,7 @@ func swap_to_floating_window() -> void: window.disable_3d = true window.wrap_controls = true window.popup_centered() - plugin_reference.get_editor_interface().set_main_screen_editor('2D') + plugin_reference.get_editor_interface().set_main_screen_editor("2D") ## Removes the main control from the window node and adds it to it's grandparent @@ -211,12 +286,20 @@ func swap_to_embedded_editor() -> void: var window := get_parent() get_parent().remove_child(self) - plugin_reference.get_editor_interface().set_main_screen_editor('Dialogic') + plugin_reference.get_editor_interface().set_main_screen_editor("Dialogic") window.get_parent().add_child(self) window.queue_free() -func godot_file_dialog(callable:Callable, filter:String, mode := EditorFileDialog.FILE_MODE_OPEN_FILE, window_title := "Save", current_file_name := 'New_File', saving_something := false, extra_message:String = "") -> EditorFileDialog: +func godot_file_dialog( + callable: Callable, + filter: String, + mode := EditorFileDialog.FILE_MODE_OPEN_FILE, + window_title := "Save", + current_file_name := "New_File", + saving_something := false, + extra_message: String = "" +) -> EditorFileDialog: for connection in editor_file_dialog.file_selected.get_connections(): editor_file_dialog.file_selected.disconnect(connection.callable) for connection in editor_file_dialog.dir_selected.get_connections(): @@ -229,10 +312,10 @@ func godot_file_dialog(callable:Callable, filter:String, mode := EditorFileDialo editor_file_dialog.current_file = current_file_name editor_file_dialog.disable_overwrite_warning = !saving_something if extra_message: - editor_file_dialog.get_meta('info_message_label').show() - editor_file_dialog.get_meta('info_message_label').text = extra_message + editor_file_dialog.get_meta("info_message_label").show() + editor_file_dialog.get_meta("info_message_label").text = extra_message else: - editor_file_dialog.get_meta('info_message_label').hide() + editor_file_dialog.get_meta("info_message_label").hide() if mode == EditorFileDialog.FILE_MODE_OPEN_FILE or mode == EditorFileDialog.FILE_MODE_SAVE_FILE: editor_file_dialog.file_selected.connect(callable) @@ -242,4 +325,3 @@ func godot_file_dialog(callable:Callable, filter:String, mode := EditorFileDialo editor_file_dialog.dir_selected.connect(callable) editor_file_dialog.file_selected.connect(callable) return editor_file_dialog - diff --git a/addons/dialogic/Editor/editor_main.tscn b/addons/dialogic/Editor/editor_main.tscn index 79465bd1b..e3390f8f1 100644 --- a/addons/dialogic/Editor/editor_main.tscn +++ b/addons/dialogic/Editor/editor_main.tscn @@ -15,7 +15,7 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/update_manager.gd" id="14_l6b1p"] [ext_resource type="PackedScene" uid="uid://vv3m5m68fwg7" path="res://addons/dialogic/Editor/Common/update_install_window.tscn" id="15_cu4xj"] -[sub_resource type="Image" id="Image_80r2n"] +[sub_resource type="Image" id="Image_fmy01"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -25,20 +25,16 @@ data = { } [sub_resource type="ImageTexture" id="ImageTexture_drcn6"] -image = SubResource("Image_80r2n") - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0gy47"] -content_margin_left = 4.0 -content_margin_top = 4.0 -content_margin_right = 4.0 -content_margin_bottom = 4.0 -bg_color = Color(1, 0.365, 0.365, 1) -draw_center = false -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 +image = SubResource("Image_fmy01") + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_danxo"] +content_margin_left = 8.0 +content_margin_top = 8.0 +content_margin_right = 8.0 +content_margin_bottom = 8.0 +bg_color = Color(0.1155, 0.132, 0.1595, 1) corner_detail = 1 +anti_aliasing = false [node name="EditorView" type="ScrollContainer"] anchors_preset = 15 @@ -57,6 +53,7 @@ size_flags_vertical = 3 script = ExtResource("2_pe2tl") [node name="HSplit" type="HSplitContainer" parent="EditorsManager"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -89,7 +86,6 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 8 tab_count = 7 -tab_0/title = "" tab_0/icon = ExtResource("2_scwcl") tab_1/title = "Timeline" tab_1/icon = SubResource("ImageTexture_drcn6") @@ -138,7 +134,7 @@ content_scale_aspect = 4 script = ExtResource("10_xbkrt") [node name="Manager" parent="ReferenceManager" instance=ExtResource("10_l1rf8")] -theme_override_styles/panel = SubResource("StyleBoxFlat_0gy47") +theme_override_styles/panel = SubResource("StyleBoxFlat_danxo") [node name="UpdateManager" type="Node" parent="."] script = ExtResource("14_l6b1p") From 224d8e9a3cda6b2fcfdb91f0040f800167806423 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Wed, 24 Jul 2024 13:32:54 -0700 Subject: [PATCH 07/15] Siderbar-upgrade ready for testing. --- addons/dialogic/Editor/Common/side_bar.tscn | 6 +- addons/dialogic/Editor/Common/sidebar.gd | 74 +++++++++++---------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index dd72e4312..6799800fe 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -24,7 +24,6 @@ script = ExtResource("1_jnq65") [node name="VBoxHidden" type="VBoxContainer" parent="."] unique_name_in_owner = true -visible = false layout_mode = 2 [node name="OpenButton" type="Button" parent="VBoxHidden"] @@ -33,14 +32,14 @@ layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 3 tooltip_text = "Show Sidebar" -text = " " +theme_override_constants/icon_max_width = 20 icon = ExtResource("2_ilyps") flat = true icon_alignment = 1 -expand_icon = true [node name="VBoxPrimary" type="VBoxContainer" parent="."] unique_name_in_owner = true +visible = false layout_mode = 2 size_flags_vertical = 3 @@ -147,5 +146,6 @@ size = Vector2i(164, 100) [connection signal="gui_input" from="VBoxPrimary/Margin/VSplitContainer/VBox/Logo" to="." method="_on_logo_gui_input"] [connection signal="text_changed" from="VBoxPrimary/Margin/VSplitContainer/VBox/Search" to="." method="_on_search_text_changed"] +[connection signal="text_submitted" from="VBoxPrimary/Margin/VSplitContainer/VBox/Search" to="." method="_on_search_text_submitted"] [connection signal="pressed" from="VBoxPrimary/CurrentVersion" to="." method="_on_current_version_pressed"] [connection signal="id_pressed" from="RightClickMenu" to="." method="_on_right_click_menu_id_pressed"] diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index 1f553ff83..f82c6f184 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -23,7 +23,7 @@ func _ready() -> void: editors_manager.resource_opened.connect(_on_editors_resource_opened) editors_manager.editor_changed.connect(_on_editors_editor_changed) - resource_tree.item_selected.connect(_on_resources_tree_item_selected) + resource_tree.item_activated.connect(_on_resources_tree_item_activated) resource_tree.item_mouse_selected.connect(_on_resources_tree_item_clicked) %ContentList.item_selected.connect( @@ -91,7 +91,7 @@ func _hide_sidebar() -> void: func _on_editors_resource_opened(resource: Resource) -> void: - # update_resource_list() + update_resource_list() pass @@ -119,13 +119,12 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: resources_list = clean_resource_list(resources_list) - %CurrentResource.text = "No Resource" %CurrentResource.add_theme_color_override( "font_uneditable_color", get_theme_color("disabled_font_color", "Editor") ) + resource_tree.clear() - #TODO: This is still super broken. var resource_list_items = [] var character_items = [] @@ -155,10 +154,6 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: # TREE var root: TreeItem = resource_tree.create_item() - var debug_string = "[b]Tree: [/b]\n\t%s\n[b]TreeRoot: [/b]\n\t%s\n[b]Root: [/b]\n\t%s" % [resource_tree,resource_tree.get_root(), root] - print_rich(debug_string) - if root == null: - return if character_items.size() > 0: var character_tree = resource_tree.create_item(root) @@ -171,6 +166,9 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: character_item.set_icon(0, item.icon) character_item.set_metadata(0, item.metadata) character_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(character_item, 0) if timeline_items.size() > 0: var timeline_tree = resource_tree.create_item(root) as TreeItem timeline_tree.set_text(0, "Timelines") @@ -182,34 +180,18 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: timeline_item.set_icon(0, item.icon) timeline_item.set_metadata(0, item.metadata) timeline_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(timeline_item, 0) if %CurrentResource.text != "No Resource": %CurrentResource.add_theme_color_override( "font_uneditable_color", get_theme_color("font_color", "Editor") ) DialogicUtil.set_editor_setting("last_resources", resources_list) - #TODO: Implement the " When searching the first item should be focused so enter actually opens that item." - - -func _on_resources_list_item_selected(index: int) -> void: - if %ResourcesList.get_item_metadata(index) == null: - return - editors_manager.edit_resource(load(%ResourcesList.get_item_metadata(index))) - - -func _on_resources_list_item_clicked( - index: int, at_position: Vector2, mouse_button_index: int -) -> void: - # If clicked with the middle mouse button, remove the item from the list - if mouse_button_index == MOUSE_BUTTON_MIDDLE: - remove_item_from_list(index) - if mouse_button_index == MOUSE_BUTTON_RIGHT: - %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) - %RightClickMenu.set_meta("item_index", index) -func _on_resources_tree_item_selected() -> void: - print("Selected\n\t{%s}" % resource_tree.get_selected()) +func _on_resources_tree_item_activated() -> void: if resource_tree.get_selected() == null: return var item := resource_tree.get_selected() @@ -219,16 +201,36 @@ func _on_resources_tree_item_selected() -> void: func _on_resources_tree_item_clicked(_pos: Vector2, mouse_button_index: int) -> void: - print("Clicked, mouse_button_index: ", mouse_button_index) + if mouse_button_index == MOUSE_BUTTON_LEFT: + return if mouse_button_index == MOUSE_BUTTON_MIDDLE: remove_item_from_list(resource_tree.get_selected()) if mouse_button_index == MOUSE_BUTTON_RIGHT: %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) - %RightClickMenu.set_meta("item_index", resource_tree.get_selected()) + (%RightClickMenu as PopupMenu).set_meta("item_clicked", resource_tree.get_selected()) + # %RightClickMenu.set_meta("item_index", resource_tree.get_selected()) func _on_search_text_changed(new_text: String) -> void: update_resource_list() + var tree_root := resource_tree.get_root() + var tree_items := tree_root.get_children() + if tree_items.size() == 0: + return + for item in tree_items: + if item.get_children().size() > 0: + resource_tree.set_selected(item.get_child(0), 0) + break + + +func _on_search_text_submitted(new_text: String) -> void: + if resource_tree.get_selected() == null: + return + var item := resource_tree.get_selected() + if item.get_metadata(0) == null: + return + editors_manager.edit_resource(load(item.get_metadata(0))) + %Search.clear() func set_unsaved_indicator(saved: bool = true) -> void: @@ -273,27 +275,27 @@ func update_content_list(list: PackedStringArray) -> void: DialogicResourceUtil.set_label_cache(label_directory) -func remove_item_from_list(index) -> void: +func remove_item_from_list(item) -> void: var new_list := [] for entry in DialogicUtil.get_editor_setting("last_resources", []): - if entry != %ResourcesList.get_item_metadata(index): + if entry != item.get_metadata(0): new_list.append(entry) DialogicUtil.set_editor_setting("last_resources", new_list) - %ResourcesList.remove_item(index) + update_resource_list(new_list) func _on_right_click_menu_id_pressed(id: int) -> void: match id: 1: # REMOVE ITEM FROM LIST - remove_item_from_list(%RightClickMenu.get_meta("item_index")) + remove_item_from_list(%RightClickMenu.get_meta("item_clicked")) 2: # OPEN IN FILESYSTEM EditorInterface.get_file_system_dock().navigate_to_path( - %ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_index")) + %RightClickMenu.get_meta("item_clicked").get_metadata(0) ) 3: # OPEN IN EXTERNAL EDITOR OS.shell_open( ProjectSettings.globalize_path( - %ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_index")) + %RightClickMenu.get_meta("item_clicked").get_metadata(0) ) ) From 0f40cfa4f4fc056591d056d571edd77a0cfd36d9 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Fri, 26 Jul 2024 10:43:40 +0200 Subject: [PATCH 08/15] Small bug-fix after merge --- addons/dialogic/Editor/Common/sidebar.gd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index d87526ef5..cc703e5e8 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -273,7 +273,7 @@ func update_content_list(list: PackedStringArray) -> void: DialogicResourceUtil.set_label_cache(label_directory) -func remove_item_from_list(item) -> void: +func remove_item_from_list(item:TreeItem) -> void: var new_list := [] for entry in DialogicUtil.get_editor_setting("last_resources", []): if entry != item.get_metadata(0): @@ -298,10 +298,10 @@ func _on_right_click_menu_id_pressed(id: int) -> void: ) 4: # COPY IDENTIFIER DisplayServer.clipboard_set( - DialogicResourceUtil.get_unique_identifier( - %ResourcesList.get_item_metadata(%RightClickMenu.get_meta("item_clicked")) - ) - ) + DialogicResourceUtil.get_unique_identifier( + %RightClickMenu.get_meta("item_clicked").get_metadata(0) + ) + ) func _sort_by_item_text(a: ResourceListItem, b: ResourceListItem) -> bool: From 1a24c5461ae906b1964c5d43672094d2665088ab Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Fri, 26 Jul 2024 10:59:45 +0200 Subject: [PATCH 09/15] Some code cleanup + save sidebar collapsing Whether the sidebar is collapsed is now saved to editor state. Simplifies ResourceListItem class into a contained class (avoids the public class name). Also uses RefCounted to avoid having to free them manually. Some code cleanup. --- .../Editor/Common/ResourceItemList.gd | 21 ---------- addons/dialogic/Editor/Common/side_bar.tscn | 4 +- addons/dialogic/Editor/Common/sidebar.gd | 41 ++++++++++++++++--- addons/dialogic/Editor/editor_main.gd | 25 +++++------ 4 files changed, 50 insertions(+), 41 deletions(-) delete mode 100644 addons/dialogic/Editor/Common/ResourceItemList.gd diff --git a/addons/dialogic/Editor/Common/ResourceItemList.gd b/addons/dialogic/Editor/Common/ResourceItemList.gd deleted file mode 100644 index b8d7bfecc..000000000 --- a/addons/dialogic/Editor/Common/ResourceItemList.gd +++ /dev/null @@ -1,21 +0,0 @@ -class_name ResourceListItem extends Object -var text: String -var index: int = -1 -var icon: Texture -var metadata: String -var tooltip: String - - -func add_to_item_list(item_list: ItemList, current_file: String) -> void: - item_list.add_item(text, icon) - item_list.set_item_metadata(item_list.item_count - 1, metadata) - item_list.set_item_tooltip(item_list.item_count - 1, tooltip) - - -func current_file(sidebar: Control, resource_list: ItemList, current_file: String) -> void: - if metadata == current_file: - resource_list.select(index) - resource_list.set_item_custom_fg_color( - index, resource_list.get_theme_color("accent_color", "Editor") - ) - sidebar.find_child("CurrentResource").text = metadata.get_file() diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index 6799800fe..fc0ce0539 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -24,6 +24,7 @@ script = ExtResource("1_jnq65") [node name="VBoxHidden" type="VBoxContainer" parent="."] unique_name_in_owner = true +visible = false layout_mode = 2 [node name="OpenButton" type="Button" parent="VBoxHidden"] @@ -39,7 +40,6 @@ icon_alignment = 1 [node name="VBoxPrimary" type="VBoxContainer" parent="."] unique_name_in_owner = true -visible = false layout_mode = 2 size_flags_vertical = 3 @@ -114,9 +114,9 @@ vertical_alignment = 1 [node name="SortOption" type="OptionButton" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 -selected = 0 item_count = 1 popup/item_0/text = "Alphabetical (All)" +popup/item_0/id = 0 [node name="ContentListSection" type="VBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer"] unique_name_in_owner = true diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index cc703e5e8..1e999496f 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -65,6 +65,10 @@ func _ready() -> void: %RightClickMenu.add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), "Show in FileSystem", 2) %RightClickMenu.add_icon_item(get_theme_icon("ExternalLink", "EditorIcons"), "Open in External Program", 3) + await get_tree().process_frame + if DialogicUtil.get_editor_setting("sidebar_collapsed", false): + _hide_sidebar() + ################################################################################ ## SHOW/HIDE SIDEBAR @@ -74,12 +78,14 @@ func _ready() -> void: func _show_sidebar() -> void: %VBoxPrimary.show() %VBoxHidden.hide() + DialogicUtil.set_editor_setting("sidebar_collapsed", false) show_sidebar.emit(true) func _hide_sidebar() -> void: %VBoxPrimary.hide() %VBoxHidden.show() + DialogicUtil.set_editor_setting("sidebar_collapsed", true) show_sidebar.emit(false) @@ -123,24 +129,24 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: ) resource_tree.clear() - var resource_list_items = [] + var resource_list_items := [] - var character_items = [] + var character_items := [] for character_name in character_directory: if character_directory[character_name] in resources_list: if filter.is_empty() or filter.to_lower() in character_name.to_lower(): - var item = ResourceListItem.new() + var item := ResourceListItem.new() item.text = character_name item.icon = load("res://addons/dialogic/Editor/Images/Resources/character.svg") item.metadata = character_directory[character_name] item.tooltip = character_directory[character_name] character_items.append(item) - var timeline_items = [] + var timeline_items := [] for timeline_name in timeline_directory: if timeline_directory[timeline_name] in resources_list: if filter.is_empty() or filter.to_lower() in timeline_name.to_lower(): - var item = ResourceListItem.new() + var item := ResourceListItem.new() item.text = timeline_name item.icon = get_theme_icon("TripleBar", "EditorIcons") item.metadata = timeline_directory[timeline_name] @@ -206,7 +212,6 @@ func _on_resources_tree_item_clicked(_pos: Vector2, mouse_button_index: int) -> if mouse_button_index == MOUSE_BUTTON_RIGHT: %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) (%RightClickMenu as PopupMenu).set_meta("item_clicked", resource_tree.get_selected()) - # %RightClickMenu.set_meta("item_index", resource_tree.get_selected()) func _on_search_text_changed(new_text: String) -> void: @@ -306,3 +311,27 @@ func _on_right_click_menu_id_pressed(id: int) -> void: func _sort_by_item_text(a: ResourceListItem, b: ResourceListItem) -> bool: return a.text < b.text + + +class ResourceListItem: + extends Object + var text: String + var index: int = -1 + var icon: Texture + var metadata: String + var tooltip: String + + + func add_to_item_list(item_list: ItemList, current_file: String) -> void: + item_list.add_item(text, icon) + item_list.set_item_metadata(item_list.item_count - 1, metadata) + item_list.set_item_tooltip(item_list.item_count - 1, tooltip) + + + func current_file(sidebar: Control, resource_list: ItemList, current_file: String) -> void: + if metadata == current_file: + resource_list.select(index) + resource_list.set_item_custom_fg_color( + index, resource_list.get_theme_color("accent_color", "Editor") + ) + sidebar.find_child("CurrentResource").text = metadata.get_file() diff --git a/addons/dialogic/Editor/editor_main.gd b/addons/dialogic/Editor/editor_main.gd index c59258941..4d8a5092f 100644 --- a/addons/dialogic/Editor/editor_main.gd +++ b/addons/dialogic/Editor/editor_main.gd @@ -14,18 +14,7 @@ func _ready() -> void: return ## CONNECTIONS - %Sidebar.show_sidebar.connect( - func(show: bool): - var h_split = (%HSplit as HSplitContainer) - if show: - h_split.dragger_visibility = SplitContainer.DRAGGER_VISIBLE - h_split.split_offset = 150 - h_split.collapsed = false - else: - h_split.dragger_visibility = SplitContainer.DRAGGER_HIDDEN_COLLAPSED - h_split.split_offset = 0 - h_split.collapsed = true - ) + %Sidebar.show_sidebar.connect(_on_sidebar_toggled) ## REFERENCES editors_manager = $EditorsManager @@ -50,6 +39,18 @@ func _ready() -> void: EditorInterface.get_base_control().theme_changed.connect(update_theme_additions) +func _on_sidebar_toggled(sidebar_shown: bool) -> void: + var h_split := (%HSplit as HSplitContainer) + if sidebar_shown: + h_split.dragger_visibility = SplitContainer.DRAGGER_VISIBLE + h_split.split_offset = 150 + h_split.collapsed = false + else: + h_split.dragger_visibility = SplitContainer.DRAGGER_HIDDEN_COLLAPSED + h_split.split_offset = 0 + h_split.collapsed = true + + func update_theme_additions() -> void: add_theme_stylebox_override( "panel", From a312db7e15e5f5dfd011aaeeb8f4d1c950c88f67 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Tue, 30 Jul 2024 12:40:32 -0700 Subject: [PATCH 10/15] Allow single click to open resource from sidebar --- addons/dialogic/Editor/Common/sidebar.gd | 37 +++++++++++++++++++----- addons/dialogic/Editor/editor_main.tscn | 8 ++--- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index 1e999496f..cd17ffa6d 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -1,5 +1,5 @@ @tool -extends Control +class_name DialogicEditorSidebar extends Control ## Script that handles the editor sidebar. @@ -62,8 +62,12 @@ func _ready() -> void: %RightClickMenu.add_separator() %RightClickMenu.add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), "Copy Identifier", 4) %RightClickMenu.add_separator() - %RightClickMenu.add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), "Show in FileSystem", 2) - %RightClickMenu.add_icon_item(get_theme_icon("ExternalLink", "EditorIcons"), "Open in External Program", 3) + %RightClickMenu.add_icon_item( + get_theme_icon("Filesystem", "EditorIcons"), "Show in FileSystem", 2 + ) + %RightClickMenu.add_icon_item( + get_theme_icon("ExternalLink", "EditorIcons"), "Open in External Program", 3 + ) await get_tree().process_frame if DialogicUtil.get_editor_setting("sidebar_collapsed", false): @@ -161,6 +165,8 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: if character_items.size() > 0: var character_tree = resource_tree.create_item(root) + if character_tree == null: + return character_tree.set_text(0, "Characters") character_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) character_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) @@ -201,17 +207,27 @@ func _on_resources_tree_item_activated() -> void: var item := resource_tree.get_selected() if item.get_metadata(0) == null: return - editors_manager.edit_resource(load(item.get_metadata(0))) + # editors_manager.edit_resource(load(item.get_metadata(0))) + edit_resource(item.get_metadata(0)) func _on_resources_tree_item_clicked(_pos: Vector2, mouse_button_index: int) -> void: if mouse_button_index == MOUSE_BUTTON_LEFT: + var selected_item := resource_tree.get_selected() + if selected_item == null: + return + if selected_item.get_metadata(0) == null: + return + var resource_item := load(selected_item.get_metadata(0)) + call_deferred("edit_resource", resource_item) return if mouse_button_index == MOUSE_BUTTON_MIDDLE: remove_item_from_list(resource_tree.get_selected()) + return if mouse_button_index == MOUSE_BUTTON_RIGHT: %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) (%RightClickMenu as PopupMenu).set_meta("item_clicked", resource_tree.get_selected()) + return func _on_search_text_changed(new_text: String) -> void: @@ -232,7 +248,7 @@ func _on_search_text_submitted(new_text: String) -> void: var item := resource_tree.get_selected() if item.get_metadata(0) == null: return - editors_manager.edit_resource(load(item.get_metadata(0))) + edit_resource(item.get_metadata(0)) %Search.clear() @@ -278,7 +294,7 @@ func update_content_list(list: PackedStringArray) -> void: DialogicResourceUtil.set_label_cache(label_directory) -func remove_item_from_list(item:TreeItem) -> void: +func remove_item_from_list(item: TreeItem) -> void: var new_list := [] for entry in DialogicUtil.get_editor_setting("last_resources", []): if entry != item.get_metadata(0): @@ -313,6 +329,13 @@ func _sort_by_item_text(a: ResourceListItem, b: ResourceListItem) -> bool: return a.text < b.text +func edit_resource(resource_item: Variant) -> void: + if resource_item is Resource: + editors_manager.edit_resource(resource_item) + else: + editors_manager.edit_resource(load(resource_item)) + + class ResourceListItem: extends Object var text: String @@ -321,13 +344,11 @@ class ResourceListItem: var metadata: String var tooltip: String - func add_to_item_list(item_list: ItemList, current_file: String) -> void: item_list.add_item(text, icon) item_list.set_item_metadata(item_list.item_count - 1, metadata) item_list.set_item_tooltip(item_list.item_count - 1, tooltip) - func current_file(sidebar: Control, resource_list: ItemList, current_file: String) -> void: if metadata == current_file: resource_list.select(index) diff --git a/addons/dialogic/Editor/editor_main.tscn b/addons/dialogic/Editor/editor_main.tscn index e3390f8f1..551524c21 100644 --- a/addons/dialogic/Editor/editor_main.tscn +++ b/addons/dialogic/Editor/editor_main.tscn @@ -15,7 +15,7 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/update_manager.gd" id="14_l6b1p"] [ext_resource type="PackedScene" uid="uid://vv3m5m68fwg7" path="res://addons/dialogic/Editor/Common/update_install_window.tscn" id="15_cu4xj"] -[sub_resource type="Image" id="Image_fmy01"] +[sub_resource type="Image" id="Image_0ofnu"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -25,9 +25,9 @@ data = { } [sub_resource type="ImageTexture" id="ImageTexture_drcn6"] -image = SubResource("Image_fmy01") +image = SubResource("Image_0ofnu") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_danxo"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hrkym"] content_margin_left = 8.0 content_margin_top = 8.0 content_margin_right = 8.0 @@ -134,7 +134,7 @@ content_scale_aspect = 4 script = ExtResource("10_xbkrt") [node name="Manager" parent="ReferenceManager" instance=ExtResource("10_l1rf8")] -theme_override_styles/panel = SubResource("StyleBoxFlat_danxo") +theme_override_styles/panel = SubResource("StyleBoxFlat_hrkym") [node name="UpdateManager" type="Node" parent="."] script = ExtResource("14_l6b1p") From be989fdc9ae80ab1d2c615d6e282e26c335b784b Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Wed, 31 Jul 2024 17:20:49 -0700 Subject: [PATCH 11/15] Added support for folder and none sorting. --- addons/dialogic/Editor/Common/side_bar.tscn | 27 +++- addons/dialogic/Editor/Common/sidebar.gd | 159 +++++++++++++++----- addons/dialogic/Editor/editor_main.gd | 3 +- addons/dialogic/Editor/editor_main.tscn | 8 +- 4 files changed, 151 insertions(+), 46 deletions(-) diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index fc0ce0539..884c4f6b5 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -86,13 +86,33 @@ flat = true icon_alignment = 1 expand_icon = true -[node name="Search" type="LineEdit" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] +[node name="HBoxSearchSort" type="HBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] +layout_mode = 2 + +[node name="Search" type="LineEdit" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxSearchSort"] unique_name_in_owner = true layout_mode = 2 +size_flags_horizontal = 3 +tooltip_text = "Filter Resources" placeholder_text = "Filter Resources" caret_blink = true caret_blink_interval = 0.5 +[node name="SortOption" type="OptionButton" parent="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxSearchSort"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Sort +- Default: Sort alphabetically split into Characters & Timeilnes. +- Folder: Sort alphabetically by parent directory. +- None: Sort alphabetically with no categories." +selected = 0 +item_count = 3 +popup/item_0/text = "Default" +popup/item_1/text = "Folder" +popup/item_1/id = 1 +popup/item_2/text = "None" +popup/item_2/id = 2 + [node name="ResourceTree" type="Tree" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true layout_mode = 2 @@ -116,7 +136,6 @@ layout_mode = 2 size_flags_horizontal = 3 item_count = 1 popup/item_0/text = "Alphabetical (All)" -popup/item_0/id = 0 [node name="ContentListSection" type="VBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer"] unique_name_in_owner = true @@ -145,7 +164,7 @@ unique_name_in_owner = true size = Vector2i(164, 100) [connection signal="gui_input" from="VBoxPrimary/Margin/VSplitContainer/VBox/Logo" to="." method="_on_logo_gui_input"] -[connection signal="text_changed" from="VBoxPrimary/Margin/VSplitContainer/VBox/Search" to="." method="_on_search_text_changed"] -[connection signal="text_submitted" from="VBoxPrimary/Margin/VSplitContainer/VBox/Search" to="." method="_on_search_text_submitted"] +[connection signal="text_changed" from="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxSearchSort/Search" to="." method="_on_search_text_changed"] +[connection signal="text_submitted" from="VBoxPrimary/Margin/VSplitContainer/VBox/HBoxSearchSort/Search" to="." method="_on_search_text_submitted"] [connection signal="pressed" from="VBoxPrimary/CurrentVersion" to="." method="_on_current_version_pressed"] [connection signal="id_pressed" from="RightClickMenu" to="." method="_on_right_click_menu_id_pressed"] diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index cd17ffa6d..e536367c3 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -1,5 +1,5 @@ @tool -class_name DialogicEditorSidebar extends Control +class_name DialogicSidebar extends Control ## Script that handles the editor sidebar. @@ -11,13 +11,16 @@ signal show_sidebar(show: bool) @onready var editors_manager = get_parent().get_parent() @onready var resource_tree: Tree = %ResourceTree +@onready var sort_option: OptionButton = %SortOption var current_resource_list: Array = [] +var sort_mode: SortMode = SortMode.Default func _ready() -> void: - if owner.get_parent() is SubViewport: + if owner != null and owner.get_parent() is SubViewport: + return + if editors_manager is SubViewportContainer: return - ## CONNECTIONS editors_manager.resource_opened.connect(_on_editors_resource_opened) @@ -26,6 +29,8 @@ func _ready() -> void: resource_tree.item_activated.connect(_on_resources_tree_item_activated) resource_tree.item_mouse_selected.connect(_on_resources_tree_item_clicked) + sort_option.item_selected.connect(_on_sort_changed) + %ContentList.item_selected.connect( func(idx: int): content_item_activated.emit(%ContentList.get_item_text(idx)) ) @@ -72,6 +77,10 @@ func _ready() -> void: await get_tree().process_frame if DialogicUtil.get_editor_setting("sidebar_collapsed", false): _hide_sidebar() + if DialogicUtil.get_editor_setting("sidebar_sort_mode", 0) != 0: + sort_option.select(DialogicUtil.get_editor_setting("sidebar_sort_mode", 0)) + sort_mode = DialogicUtil.get_editor_setting("sidebar_sort_mode", 0) + update_resource_list() ################################################################################ @@ -113,6 +122,13 @@ func clean_resource_list(resources_list: Array = []) -> PackedStringArray: func update_resource_list(resources_list: PackedStringArray = []) -> void: + print_rich( + ( + "[b]Updating resource list[/b]:\n\t [i]Resource List: [/i]%s\n\t[i]Resource List D: [/i]%s" + % [resources_list, DialogicUtil.get_editor_setting("last_resources", [])] + ) + ) + var filter: String = %Search.text var current_file := "" if editors_manager.current_editor and editors_manager.current_editor.current_resource: @@ -153,47 +169,81 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: var item := ResourceListItem.new() item.text = timeline_name item.icon = get_theme_icon("TripleBar", "EditorIcons") + # item.icon = load("res://addons/dialogic/Editor/Images/Resources/timeline.svg") item.metadata = timeline_directory[timeline_name] item.tooltip = timeline_directory[timeline_name] timeline_items.append(item) - character_items.sort_custom(_sort_by_item_text) - timeline_items.sort_custom(_sort_by_item_text) - # TREE var root: TreeItem = resource_tree.create_item() - - if character_items.size() > 0: - var character_tree = resource_tree.create_item(root) - if character_tree == null: - return - character_tree.set_text(0, "Characters") - character_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) - character_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) - for item in character_items: - var character_item = resource_tree.create_item(character_tree) - character_item.set_text(0, item.text) - character_item.set_icon(0, item.icon) - character_item.set_metadata(0, item.metadata) - character_item.set_tooltip_text(0, item.tooltip) - if item.metadata == current_file: - %CurrentResource.text = item.metadata.get_file() - resource_tree.set_selected(character_item, 0) - if timeline_items.size() > 0: - var timeline_tree = resource_tree.create_item(root) as TreeItem - timeline_tree.set_text(0, "Timelines") - timeline_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) - timeline_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) - for item in timeline_items: - var timeline_item = resource_tree.create_item(timeline_tree) as TreeItem - timeline_item.set_text(0, item.text) - timeline_item.set_icon(0, item.icon) - timeline_item.set_metadata(0, item.metadata) - timeline_item.set_tooltip_text(0, item.tooltip) + if sort_mode == SortMode.Default: + character_items.sort_custom(_sort_by_item_text) + timeline_items.sort_custom(_sort_by_item_text) + if character_items.size() > 0: + var character_tree = resource_tree.create_item(root) + if character_tree == null: + return + character_tree.set_text(0, "Characters") + character_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + character_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + for item in character_items: + var character_item = resource_tree.create_item(character_tree) + character_item.set_text(0, item.text) + character_item.set_icon(0, item.icon) + character_item.set_metadata(0, item.metadata) + character_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(character_item, 0) + if timeline_items.size() > 0: + var timeline_tree = resource_tree.create_item(root) as TreeItem + timeline_tree.set_text(0, "Timelines") + timeline_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + timeline_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + for item in timeline_items: + var timeline_item = resource_tree.create_item(timeline_tree) as TreeItem + timeline_item.set_text(0, item.text) + timeline_item.set_icon(0, item.icon) + timeline_item.set_metadata(0, item.metadata) + timeline_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(timeline_item, 0) + + if sort_mode == SortMode.None: + var all_items := character_items + timeline_items + all_items.sort_custom(_sort_by_item_text) + for item in all_items: + var tree_item = resource_tree.create_item(root) + tree_item.set_text(0, item.text) + tree_item.set_icon(0, item.icon) + tree_item.set_metadata(0, item.metadata) + tree_item.set_tooltip_text(0, item.tooltip) if item.metadata == current_file: %CurrentResource.text = item.metadata.get_file() - resource_tree.set_selected(timeline_item, 0) - + resource_tree.set_selected(tree_item, 0) + if sort_mode == SortMode.Folder: + var all_items := character_items + timeline_items + var dirs := {} + for item in all_items: + var dir := item.get_parent_directory() as String + if !dirs.has(dir): + dirs[dir] = [] + dirs[dir].append(item) + for dir in dirs: + var dir_item = resource_tree.create_item(root) + dir_item.set_text(0, dir) + dir_item.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + dir_item.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + for item in dirs[dir]: + var tree_item = resource_tree.create_item(dir_item) + tree_item.set_text(0, item.text) + tree_item.set_icon(0, item.icon) + tree_item.set_metadata(0, item.metadata) + tree_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(tree_item, 0) if %CurrentResource.text != "No Resource": %CurrentResource.add_theme_color_override( "font_uneditable_color", get_theme_color("font_color", "Editor") @@ -207,7 +257,6 @@ func _on_resources_tree_item_activated() -> void: var item := resource_tree.get_selected() if item.get_metadata(0) == null: return - # editors_manager.edit_resource(load(item.get_metadata(0))) edit_resource(item.get_metadata(0)) @@ -227,6 +276,7 @@ func _on_resources_tree_item_clicked(_pos: Vector2, mouse_button_index: int) -> if mouse_button_index == MOUSE_BUTTON_RIGHT: %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) (%RightClickMenu as PopupMenu).set_meta("item_clicked", resource_tree.get_selected()) + return @@ -325,6 +375,16 @@ func _on_right_click_menu_id_pressed(id: int) -> void: ) +func _on_sort_changed(idx: int) -> void: + if (SortMode as Dictionary).values().has(idx): + sort_mode = idx + DialogicUtil.set_editor_setting("sidebar_sort_mode", idx) + update_resource_list() + else: + sort_mode = SortMode.Default + print("Invalid sort mode: ", idx) + + func _sort_by_item_text(a: ResourceListItem, b: ResourceListItem) -> bool: return a.text < b.text @@ -336,19 +396,44 @@ func edit_resource(resource_item: Variant) -> void: editors_manager.edit_resource(load(resource_item)) +enum SortMode { + Default, + Folder, + None, +} + + class ResourceListItem: extends Object + var text: String var index: int = -1 var icon: Texture var metadata: String var tooltip: String + func _to_string() -> String: + return JSON.stringify( + { + "text": text, + "index": index, + "icon": icon.resource_path, + "metadata": metadata, + "tooltip": tooltip, + "parent_dir": get_parent_directory() + }, + "\t", + false + ) + func add_to_item_list(item_list: ItemList, current_file: String) -> void: item_list.add_item(text, icon) item_list.set_item_metadata(item_list.item_count - 1, metadata) item_list.set_item_tooltip(item_list.item_count - 1, tooltip) + func get_parent_directory() -> String: + return (metadata.get_base_dir() as String).split("/")[-1] + func current_file(sidebar: Control, resource_list: ItemList, current_file: String) -> void: if metadata == current_file: resource_list.select(index) diff --git a/addons/dialogic/Editor/editor_main.gd b/addons/dialogic/Editor/editor_main.gd index 4d8a5092f..b95ef6e26 100644 --- a/addons/dialogic/Editor/editor_main.gd +++ b/addons/dialogic/Editor/editor_main.gd @@ -8,13 +8,14 @@ var editors_manager: Control = null var editor_file_dialog: EditorFileDialog +@onready var sidebar := %Sidebar as DialogicSidebar func _ready() -> void: if get_parent() is SubViewport: return ## CONNECTIONS - %Sidebar.show_sidebar.connect(_on_sidebar_toggled) + sidebar.show_sidebar.connect(_on_sidebar_toggled) ## REFERENCES editors_manager = $EditorsManager diff --git a/addons/dialogic/Editor/editor_main.tscn b/addons/dialogic/Editor/editor_main.tscn index 551524c21..849ad796b 100644 --- a/addons/dialogic/Editor/editor_main.tscn +++ b/addons/dialogic/Editor/editor_main.tscn @@ -15,7 +15,7 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/update_manager.gd" id="14_l6b1p"] [ext_resource type="PackedScene" uid="uid://vv3m5m68fwg7" path="res://addons/dialogic/Editor/Common/update_install_window.tscn" id="15_cu4xj"] -[sub_resource type="Image" id="Image_0ofnu"] +[sub_resource type="Image" id="Image_uqxml"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -25,9 +25,9 @@ data = { } [sub_resource type="ImageTexture" id="ImageTexture_drcn6"] -image = SubResource("Image_0ofnu") +image = SubResource("Image_uqxml") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hrkym"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5bs7k"] content_margin_left = 8.0 content_margin_top = 8.0 content_margin_right = 8.0 @@ -134,7 +134,7 @@ content_scale_aspect = 4 script = ExtResource("10_xbkrt") [node name="Manager" parent="ReferenceManager" instance=ExtResource("10_l1rf8")] -theme_override_styles/panel = SubResource("StyleBoxFlat_hrkym") +theme_override_styles/panel = SubResource("StyleBoxFlat_5bs7k") [node name="UpdateManager" type="Node" parent="."] script = ExtResource("14_l6b1p") From fc6ab2191562bdc750fbf08f2c075df3a9188733 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Sun, 4 Aug 2024 13:03:21 +0200 Subject: [PATCH 12/15] Some improvements - Add icons to the SortMode dropdown - Simplify sorting code - Don't show right-click menu on "folder" items --- addons/dialogic/Editor/Common/side_bar.tscn | 11 +- addons/dialogic/Editor/Common/sidebar.gd | 169 +++++++++----------- 2 files changed, 82 insertions(+), 98 deletions(-) diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index 884c4f6b5..8da328a04 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -105,13 +105,9 @@ tooltip_text = "Sort - Default: Sort alphabetically split into Characters & Timeilnes. - Folder: Sort alphabetically by parent directory. - None: Sort alphabetically with no categories." -selected = 0 -item_count = 3 -popup/item_0/text = "Default" -popup/item_1/text = "Folder" -popup/item_1/id = 1 -popup/item_2/text = "None" -popup/item_2/id = 2 +text_overrun_behavior = 1 +clip_text = true +fit_to_longest_item = false [node name="ResourceTree" type="Tree" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true @@ -136,6 +132,7 @@ layout_mode = 2 size_flags_horizontal = 3 item_count = 1 popup/item_0/text = "Alphabetical (All)" +popup/item_0/id = 0 [node name="ContentListSection" type="VBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer"] unique_name_in_owner = true diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index e536367c3..1b0095488 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -11,9 +11,15 @@ signal show_sidebar(show: bool) @onready var editors_manager = get_parent().get_parent() @onready var resource_tree: Tree = %ResourceTree -@onready var sort_option: OptionButton = %SortOption var current_resource_list: Array = [] -var sort_mode: SortMode = SortMode.Default + +enum SortMode { + DEFAULT, + FOLDER, + NONE, +} + +var sort_mode: SortMode = SortMode.DEFAULT func _ready() -> void: @@ -29,7 +35,7 @@ func _ready() -> void: resource_tree.item_activated.connect(_on_resources_tree_item_activated) resource_tree.item_mouse_selected.connect(_on_resources_tree_item_clicked) - sort_option.item_selected.connect(_on_sort_changed) + %ContentList.item_selected.connect( func(idx: int): content_item_activated.emit(%ContentList.get_item_text(idx)) @@ -74,13 +80,20 @@ func _ready() -> void: get_theme_icon("ExternalLink", "EditorIcons"), "Open in External Program", 3 ) + ## SORT MENU + %SortOption.clear() + %SortOption.add_icon_item(get_theme_icon("AnimationTrackGroup", "EditorIcons"), "Type", 0) + %SortOption.add_icon_item(get_theme_icon("Folder", "EditorIcons"), "Folder", 1) + %SortOption.add_icon_item(get_theme_icon("AnimationTrackList", "EditorIcons"), "None", 2) + %SortOption.item_selected.connect(_on_sort_changed) + await get_tree().process_frame if DialogicUtil.get_editor_setting("sidebar_collapsed", false): _hide_sidebar() - if DialogicUtil.get_editor_setting("sidebar_sort_mode", 0) != 0: - sort_option.select(DialogicUtil.get_editor_setting("sidebar_sort_mode", 0)) - sort_mode = DialogicUtil.get_editor_setting("sidebar_sort_mode", 0) - update_resource_list() + + %SortOption.select(DialogicUtil.get_editor_setting("sidebar_sort_mode", 0)) + sort_mode = DialogicUtil.get_editor_setting("sidebar_sort_mode", 0) + update_resource_list() ################################################################################ @@ -151,106 +164,86 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: resource_tree.clear() var resource_list_items := [] - var character_items := [] - for character_name in character_directory: - if character_directory[character_name] in resources_list: - if filter.is_empty() or filter.to_lower() in character_name.to_lower(): - var item := ResourceListItem.new() - item.text = character_name - item.icon = load("res://addons/dialogic/Editor/Images/Resources/character.svg") - item.metadata = character_directory[character_name] - item.tooltip = character_directory[character_name] - character_items.append(item) - - var timeline_items := [] - for timeline_name in timeline_directory: - if timeline_directory[timeline_name] in resources_list: - if filter.is_empty() or filter.to_lower() in timeline_name.to_lower(): + var get_directory_items := func(directory:Dictionary, filter:String, icon:Texture2D) -> Array: + var items := [] + for item_name in directory: + if (directory[item_name] in resources_list) and (filter.is_empty() or filter.to_lower() in item_name.to_lower()): var item := ResourceListItem.new() - item.text = timeline_name - item.icon = get_theme_icon("TripleBar", "EditorIcons") - # item.icon = load("res://addons/dialogic/Editor/Images/Resources/timeline.svg") - item.metadata = timeline_directory[timeline_name] - item.tooltip = timeline_directory[timeline_name] - timeline_items.append(item) - - # TREE + item.text = item_name + item.icon = icon + item.metadata = directory[item_name] + item.tooltip = directory[item_name] + items.append(item) + return items + + var character_items: Array = get_directory_items.call(character_directory, filter, load("res://addons/dialogic/Editor/Images/Resources/character.svg")) + var timeline_items: Array = get_directory_items.call(timeline_directory, filter, get_theme_icon("TripleBar", "EditorIcons")) + + + # BUILD TREE var root: TreeItem = resource_tree.create_item() - if sort_mode == SortMode.Default: + if sort_mode == SortMode.DEFAULT: character_items.sort_custom(_sort_by_item_text) timeline_items.sort_custom(_sort_by_item_text) if character_items.size() > 0: - var character_tree = resource_tree.create_item(root) - if character_tree == null: - return - character_tree.set_text(0, "Characters") - character_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) - character_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + var character_tree := add_folder_item("Characters", root) for item in character_items: - var character_item = resource_tree.create_item(character_tree) - character_item.set_text(0, item.text) - character_item.set_icon(0, item.icon) - character_item.set_metadata(0, item.metadata) - character_item.set_tooltip_text(0, item.tooltip) - if item.metadata == current_file: - %CurrentResource.text = item.metadata.get_file() - resource_tree.set_selected(character_item, 0) + add_item(item, character_tree, current_file) + if timeline_items.size() > 0: - var timeline_tree = resource_tree.create_item(root) as TreeItem - timeline_tree.set_text(0, "Timelines") - timeline_tree.set_icon(0, get_theme_icon("Folder", "EditorIcons")) - timeline_tree.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + var timeline_tree := add_folder_item("Timelines", root) for item in timeline_items: - var timeline_item = resource_tree.create_item(timeline_tree) as TreeItem - timeline_item.set_text(0, item.text) - timeline_item.set_icon(0, item.icon) - timeline_item.set_metadata(0, item.metadata) - timeline_item.set_tooltip_text(0, item.tooltip) - if item.metadata == current_file: - %CurrentResource.text = item.metadata.get_file() - resource_tree.set_selected(timeline_item, 0) - - if sort_mode == SortMode.None: + add_item(item, timeline_tree, current_file) + + if sort_mode == SortMode.NONE: var all_items := character_items + timeline_items all_items.sort_custom(_sort_by_item_text) for item in all_items: - var tree_item = resource_tree.create_item(root) - tree_item.set_text(0, item.text) - tree_item.set_icon(0, item.icon) - tree_item.set_metadata(0, item.metadata) - tree_item.set_tooltip_text(0, item.tooltip) - if item.metadata == current_file: - %CurrentResource.text = item.metadata.get_file() - resource_tree.set_selected(tree_item, 0) - if sort_mode == SortMode.Folder: + add_item(item, root, current_file) + + if sort_mode == SortMode.FOLDER: var all_items := character_items + timeline_items var dirs := {} + for item in all_items: var dir := item.get_parent_directory() as String if !dirs.has(dir): dirs[dir] = [] dirs[dir].append(item) + for dir in dirs: - var dir_item = resource_tree.create_item(root) - dir_item.set_text(0, dir) - dir_item.set_icon(0, get_theme_icon("Folder", "EditorIcons")) - dir_item.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + var dir_item := add_folder_item(dir, root) for item in dirs[dir]: - var tree_item = resource_tree.create_item(dir_item) - tree_item.set_text(0, item.text) - tree_item.set_icon(0, item.icon) - tree_item.set_metadata(0, item.metadata) - tree_item.set_tooltip_text(0, item.tooltip) - if item.metadata == current_file: - %CurrentResource.text = item.metadata.get_file() - resource_tree.set_selected(tree_item, 0) + add_item(item, dir_item, current_file) + if %CurrentResource.text != "No Resource": %CurrentResource.add_theme_color_override( "font_uneditable_color", get_theme_color("font_color", "Editor") ) + DialogicUtil.set_editor_setting("last_resources", resources_list) +func add_item(item:ResourceListItem, parent:TreeItem, current_file := "") -> TreeItem: + var tree_item := resource_tree.create_item(parent) + tree_item.set_text(0, item.text) + tree_item.set_icon(0, item.icon) + tree_item.set_metadata(0, item.metadata) + tree_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(tree_item, 0) + return tree_item + + +func add_folder_item(label: String, parent:TreeItem) -> TreeItem: + var folder_item := resource_tree.create_item(parent) + folder_item.set_text(0, label) + folder_item.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + folder_item.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + return folder_item + + func _on_resources_tree_item_activated() -> void: if resource_tree.get_selected() == null: return @@ -274,10 +267,10 @@ func _on_resources_tree_item_clicked(_pos: Vector2, mouse_button_index: int) -> remove_item_from_list(resource_tree.get_selected()) return if mouse_button_index == MOUSE_BUTTON_RIGHT: - %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) - (%RightClickMenu as PopupMenu).set_meta("item_clicked", resource_tree.get_selected()) - - return + if resource_tree.get_selected().get_metadata(0): + %RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) + (%RightClickMenu as PopupMenu).set_meta("item_clicked", resource_tree.get_selected()) + return func _on_search_text_changed(new_text: String) -> void: @@ -381,7 +374,7 @@ func _on_sort_changed(idx: int) -> void: DialogicUtil.set_editor_setting("sidebar_sort_mode", idx) update_resource_list() else: - sort_mode = SortMode.Default + sort_mode = SortMode.DEFAULT print("Invalid sort mode: ", idx) @@ -396,12 +389,6 @@ func edit_resource(resource_item: Variant) -> void: editors_manager.edit_resource(load(resource_item)) -enum SortMode { - Default, - Folder, - None, -} - class ResourceListItem: extends Object From 131623c826380aadcb67a5f962e6d58525f80294 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Sun, 18 Aug 2024 15:20:57 -0700 Subject: [PATCH 13/15] Added Path sorting option. --- addons/dialogic/Editor/Common/side_bar.tscn | 6 ++-- addons/dialogic/Editor/Common/sidebar.gd | 33 ++++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index 884c4f6b5..09e34085b 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -106,12 +106,14 @@ tooltip_text = "Sort - Folder: Sort alphabetically by parent directory. - None: Sort alphabetically with no categories." selected = 0 -item_count = 3 +item_count = 4 popup/item_0/text = "Default" popup/item_1/text = "Folder" popup/item_1/id = 1 -popup/item_2/text = "None" +popup/item_2/text = "Path" popup/item_2/id = 2 +popup/item_3/text = "None" +popup/item_3/id = 3 [node name="ResourceTree" type="Tree" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index e536367c3..4bc3184d9 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -21,8 +21,8 @@ func _ready() -> void: return if editors_manager is SubViewportContainer: return - ## CONNECTIONS + ## CONNECTIONS editors_manager.resource_opened.connect(_on_editors_resource_opened) editors_manager.editor_changed.connect(_on_editors_editor_changed) @@ -122,13 +122,6 @@ func clean_resource_list(resources_list: Array = []) -> PackedStringArray: func update_resource_list(resources_list: PackedStringArray = []) -> void: - print_rich( - ( - "[b]Updating resource list[/b]:\n\t [i]Resource List: [/i]%s\n\t[i]Resource List D: [/i]%s" - % [resources_list, DialogicUtil.get_editor_setting("last_resources", [])] - ) - ) - var filter: String = %Search.text var current_file := "" if editors_manager.current_editor and editors_manager.current_editor.current_resource: @@ -244,6 +237,29 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: if item.metadata == current_file: %CurrentResource.text = item.metadata.get_file() resource_tree.set_selected(tree_item, 0) + if sort_mode == SortMode.Path: + var all_items := character_items + timeline_items + var dirs := {} + for item in all_items: + var path := (item.metadata.get_base_dir() as String).replace("res://", "") + if !dirs.has(path): + dirs[path] = [] + dirs[path].append(item) + for dir in dirs: + var dir_item = resource_tree.create_item(root) + dir_item.set_text(0, dir) + dir_item.set_icon(0, get_theme_icon("Folder", "EditorIcons")) + dir_item.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + for item in dirs[dir]: + var tree_item = resource_tree.create_item(dir_item) + tree_item.set_text(0, item.text) + tree_item.set_icon(0, item.icon) + tree_item.set_metadata(0, item.metadata) + tree_item.set_tooltip_text(0, item.tooltip) + if item.metadata == current_file: + %CurrentResource.text = item.metadata.get_file() + resource_tree.set_selected(tree_item, 0) + if %CurrentResource.text != "No Resource": %CurrentResource.add_theme_color_override( "font_uneditable_color", get_theme_color("font_color", "Editor") @@ -399,6 +415,7 @@ func edit_resource(resource_item: Variant) -> void: enum SortMode { Default, Folder, + Path, None, } From a7181169622cda8fe57129ea35cb76d6caa2ac62 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Sun, 18 Aug 2024 16:08:35 -0700 Subject: [PATCH 14/15] Fixed sider_bar.tscn merge error. --- addons/dialogic/Editor/Common/side_bar.tscn | 10 +++------- addons/dialogic/Editor/Common/sidebar.gd | 8 ++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index 356ada44d..0873abf43 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -104,8 +104,10 @@ layout_mode = 2 tooltip_text = "Sort - Default: Sort alphabetically split into Characters & Timeilnes. - Folder: Sort alphabetically by parent directory. +- Path: Display full path relative to res://. - None: Sort alphabetically with no categories." -<<<<<<< HEAD +text_overrun_behavior = 1 +clip_text = true selected = 0 item_count = 4 popup/item_0/text = "Default" @@ -115,11 +117,6 @@ popup/item_2/text = "Path" popup/item_2/id = 2 popup/item_3/text = "None" popup/item_3/id = 3 -======= -text_overrun_behavior = 1 -clip_text = true -fit_to_longest_item = false ->>>>>>> fc6ab2191562bdc750fbf08f2c075df3a9188733 [node name="ResourceTree" type="Tree" parent="VBoxPrimary/Margin/VSplitContainer/VBox"] unique_name_in_owner = true @@ -144,7 +141,6 @@ layout_mode = 2 size_flags_horizontal = 3 item_count = 1 popup/item_0/text = "Alphabetical (All)" -popup/item_0/id = 0 [node name="ContentListSection" type="VBoxContainer" parent="VBoxPrimary/Margin/VSplitContainer"] unique_name_in_owner = true diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index 09b833fc2..a1c50a4eb 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -82,10 +82,10 @@ func _ready() -> void: ) ## SORT MENU - %SortOption.clear() - %SortOption.add_icon_item(get_theme_icon("AnimationTrackGroup", "EditorIcons"), "Type", 0) - %SortOption.add_icon_item(get_theme_icon("Folder", "EditorIcons"), "Folder", 1) - %SortOption.add_icon_item(get_theme_icon("AnimationTrackList", "EditorIcons"), "None", 2) + %SortOption.set_item_icon(0, get_theme_icon("AnimationTrackGroup", "EditorIcons")) + %SortOption.set_item_icon(1, get_theme_icon("Folder", "EditorIcons")) + %SortOption.set_item_icon(2, get_theme_icon("FolderBrowse", "EditorIcons")) + %SortOption.set_item_icon(3, get_theme_icon("AnimationTrackList", "EditorIcons")) %SortOption.item_selected.connect(_on_sort_changed) await get_tree().process_frame From 6a53b3641baf44d62a501a996c6a3478e543c352 Mon Sep 17 00:00:00 2001 From: Pasquale Crea Date: Mon, 16 Sep 2024 11:48:33 -0700 Subject: [PATCH 15/15] Added folder color, updated Default to Types. --- addons/dialogic/Editor/Common/side_bar.tscn | 2 +- addons/dialogic/Editor/Common/sidebar.gd | 31 +++++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/addons/dialogic/Editor/Common/side_bar.tscn b/addons/dialogic/Editor/Common/side_bar.tscn index 0873abf43..72f82cd45 100644 --- a/addons/dialogic/Editor/Common/side_bar.tscn +++ b/addons/dialogic/Editor/Common/side_bar.tscn @@ -110,7 +110,7 @@ text_overrun_behavior = 1 clip_text = true selected = 0 item_count = 4 -popup/item_0/text = "Default" +popup/item_0/text = "Type" popup/item_1/text = "Folder" popup/item_1/id = 1 popup/item_2/text = "Path" diff --git a/addons/dialogic/Editor/Common/sidebar.gd b/addons/dialogic/Editor/Common/sidebar.gd index a1c50a4eb..339b6181d 100644 --- a/addons/dialogic/Editor/Common/sidebar.gd +++ b/addons/dialogic/Editor/Common/sidebar.gd @@ -13,14 +13,14 @@ signal show_sidebar(show: bool) @onready var resource_tree: Tree = %ResourceTree var current_resource_list: Array = [] enum SortMode { - DEFAULT, + TYPE, FOLDER, PATH, NONE, } -var sort_mode: SortMode = SortMode.DEFAULT +var sort_mode: SortMode = SortMode.TYPE func _ready() -> void: @@ -176,7 +176,8 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: # BUILD TREE var root: TreeItem = resource_tree.create_item() - if sort_mode == SortMode.DEFAULT: + + if sort_mode == SortMode.TYPE: character_items.sort_custom(_sort_by_item_text) timeline_items.sort_custom(_sort_by_item_text) if character_items.size() > 0: @@ -201,6 +202,7 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: if item.metadata == current_file: %CurrentResource.text = item.metadata.get_file() resource_tree.set_selected(tree_item, 0) + if sort_mode == SortMode.FOLDER: var all_items := character_items + timeline_items var dirs := {} @@ -223,24 +225,41 @@ func update_resource_list(resources_list: PackedStringArray = []) -> void: if item.metadata == current_file: %CurrentResource.text = item.metadata.get_file() resource_tree.set_selected(tree_item, 0) + if sort_mode == SortMode.PATH: var all_items := character_items + timeline_items var dirs := {} + var regex := RegEx.new() for item in all_items: var path := (item.metadata.get_base_dir() as String).replace("res://", "") + regex.compile("(\\w+\\/)?\\w+$") if !dirs.has(path): dirs[path] = [] dirs[path].append(item) + for dir in dirs: + var dir_display := regex.search(dir).get_string(0) var dir_item = resource_tree.create_item(root) - dir_item.set_text(0, dir) + var dir_color = ProjectSettings.get_setting("file_customization/folder_colors").get("res://" + dir + "/", get_theme_color("base_color", "Editor")) + var default_color_used = true; + if dir_color as Color != null and Color(dir_color) != get_theme_color("base_color", "Editor"): + dir_color = Color(dir_color) + dir_color.a = 0.2 + dir_color = (dir_color as Color).to_html(true) + default_color_used = false + dir_item.set_text(0, dir_display) dir_item.set_icon(0, get_theme_icon("Folder", "EditorIcons")) - dir_item.set_custom_bg_color(0, get_theme_color("base_color", "Editor")) + dir_item.set_custom_bg_color(0, dir_color) for item in dirs[dir]: var tree_item = resource_tree.create_item(dir_item) tree_item.set_text(0, item.text) tree_item.set_icon(0, item.icon) tree_item.set_metadata(0, item.metadata) + if !default_color_used: + dir_color = Color(dir_color) + dir_color.a = 0.1 + dir_color = (dir_color as Color).to_html(true) + tree_item.set_custom_bg_color(0, dir_color) tree_item.set_tooltip_text(0, item.tooltip) if item.metadata == current_file: %CurrentResource.text = item.metadata.get_file() @@ -404,7 +423,7 @@ func _on_sort_changed(idx: int) -> void: DialogicUtil.set_editor_setting("sidebar_sort_mode", idx) update_resource_list() else: - sort_mode = SortMode.DEFAULT + sort_mode = SortMode.TYPE print("Invalid sort mode: ", idx)