diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index 6cfdea210..3eeb18f51 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -219,8 +219,9 @@ namespace FlaxEditor.Content.GUI /// /// The items to show. /// If set to true items will be added to the current selection. Otherwise selection will be cleared before. - public void ShowItems(List items, bool additive = false) + public void ShowItems(List items, string sortMethod, bool additive = false) { + Console.WriteLine("GROS CON"); if (items == null) throw new ArgumentNullException(); @@ -250,7 +251,26 @@ namespace FlaxEditor.Content.GUI } // Sort items - _children.Sort(); + ContentItem oui = (ContentItem) _children[0]; + Console.WriteLine("Ici " + oui); + _children.Sort(((control, control1) => + { + if (sortMethod == "Alphabetic Reverse") + { + if (((ContentItem)control).CompareTo((ContentItem)control1) > 0) + return -1; + if (((ContentItem)control).CompareTo((ContentItem)control1) == 0) + return 0; + + + return 1; + } + + return (((ContentItem)control).CompareTo((ContentItem)control1)); + + })); + + // Unload and perform UI layout IsLayoutLocked = wasLayoutLocked; diff --git a/Source/Editor/Windows/ContentWindow.Search.cs b/Source/Editor/Windows/ContentWindow.Search.cs index e8ef60e23..b89bfff89 100644 --- a/Source/Editor/Windows/ContentWindow.Search.cs +++ b/Source/Editor/Windows/ContentWindow.Search.cs @@ -230,7 +230,7 @@ namespace FlaxEditor.Windows } _view.IsSearching = true; - _view.ShowItems(items); + _view.ShowItems(items, Editor.Windows.ContentWin._sortBy); } private void UpdateItemsSearchFilter(ContentFolder folder, List items, bool[] filters) diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 8a4db3789..a9ce2a367 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -39,6 +39,7 @@ namespace FlaxEditor.Windows private TextBox _foldersSearchBox; private TextBox _itemsSearchBox; private ViewDropdown _viewDropdown; + private string _sortBy; private RootContentTreeNode _root; @@ -215,6 +216,11 @@ namespace FlaxEditor.Windows filterButton.Checked = _viewDropdown.IsSelected(filterButton.Text); } }; + + var sortBy = menu.AddChildMenu("Sort by"); + sortBy.ContextMenu.AddButton("Alphabetic Order", OnSortByButtonClicked); + sortBy.ContextMenu.AddButton("Alphabetic Reverse", OnSortByButtonClicked); + sortBy.ContextMenu.AddButton("Last Modified", OnSortByButtonClicked); return menu; } @@ -230,6 +236,13 @@ namespace FlaxEditor.Windows _viewDropdown.OnClicked(i); } + private void OnSortByButtonClicked(ContextMenuButton button) + { + Editor.Windows.ContentWin._sortBy = button.Text; + RefreshView(SelectedNode); + Console.WriteLine(Editor.Windows.ContentWin._sortBy); + } + /// /// Shows popup dialog with UI to rename content item. /// @@ -701,12 +714,12 @@ namespace FlaxEditor.Windows items.Add(node.Folder); } } - _view.ShowItems(items); + _view.ShowItems(items, Editor.Windows.ContentWin._sortBy); } else { // Show folder contents - _view.ShowItems(target.Folder.Children); + _view.ShowItems(target.Folder.Children, Editor.Windows.ContentWin._sortBy); } }