Added functionality to order items by name
This commit is contained in:
@@ -219,8 +219,9 @@ namespace FlaxEditor.Content.GUI
|
||||
/// </summary>
|
||||
/// <param name="items">The items to show.</param>
|
||||
/// <param name="additive">If set to <c>true</c> items will be added to the current selection. Otherwise selection will be cleared before.</param>
|
||||
public void ShowItems(List<ContentItem> items, bool additive = false)
|
||||
public void ShowItems(List<ContentItem> 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;
|
||||
|
||||
@@ -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<ContentItem> items, bool[] filters)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows popup dialog with UI to rename content item.
|
||||
/// </summary>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user