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",