Fix entity sorting
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -13,6 +14,7 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using Torch.Collections;
|
||||||
using Torch.Server.ViewModels;
|
using Torch.Server.ViewModels;
|
||||||
using Torch.Server.ViewModels.Blocks;
|
using Torch.Server.ViewModels.Blocks;
|
||||||
using Torch.Server.ViewModels.Entities;
|
using Torch.Server.ViewModels.Entities;
|
||||||
@@ -29,6 +31,8 @@ namespace Torch.Server.Views
|
|||||||
{
|
{
|
||||||
public EntityTreeViewModel Entities { get; set; }
|
public EntityTreeViewModel Entities { get; set; }
|
||||||
|
|
||||||
|
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public EntitiesControl()
|
public EntitiesControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -37,7 +41,7 @@ namespace Torch.Server.Views
|
|||||||
Entities.Init();
|
Entities.Init();
|
||||||
SortCombo.ItemsSource = Enum.GetNames(typeof(EntityTreeViewModel.SortEnum));
|
SortCombo.ItemsSource = Enum.GetNames(typeof(EntityTreeViewModel.SortEnum));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
private void TreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
||||||
{
|
{
|
||||||
if (e.NewValue is EntityViewModel vm)
|
if (e.NewValue is EntityViewModel vm)
|
||||||
@@ -82,16 +86,16 @@ namespace Torch.Server.Views
|
|||||||
private void SortCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void SortCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var sort = (EntityTreeViewModel.SortEnum)SortCombo.SelectedIndex;
|
var sort = (EntityTreeViewModel.SortEnum)SortCombo.SelectedIndex;
|
||||||
|
|
||||||
var comparer = new EntityViewModel.Comparer(sort);
|
var comparer = new EntityViewModel.Comparer(sort);
|
||||||
|
|
||||||
Task[] sortTasks = new Task[4];
|
Task[] sortTasks = new Task[4];
|
||||||
|
|
||||||
Entities.CurrentSort = sort;
|
Entities.CurrentSort = sort;
|
||||||
Entities.SortedCharacters.Sort(comparer);
|
Entities.SortedCharacters.SetComparer(comparer);
|
||||||
Entities.SortedFloatingObjects.Sort(comparer);
|
Entities.SortedFloatingObjects.SetComparer(comparer);
|
||||||
Entities.SortedGrids.Sort(comparer);
|
Entities.SortedGrids.SetComparer(comparer);
|
||||||
Entities.SortedVoxelMaps.Sort(comparer);
|
Entities.SortedVoxelMaps.SetComparer(comparer);
|
||||||
|
|
||||||
foreach (var i in Entities.SortedCharacters)
|
foreach (var i in Entities.SortedCharacters)
|
||||||
i.DescriptiveName = i.GetSortedName(sort);
|
i.DescriptiveName = i.GetSortedName(sort);
|
||||||
|
@@ -48,7 +48,7 @@ namespace Torch.Collections
|
|||||||
|
|
||||||
public IEnumerator<T> GetEnumerator()
|
public IEnumerator<T> GetEnumerator()
|
||||||
{
|
{
|
||||||
return _backing.GetEnumerator();
|
return _store.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
@@ -100,6 +100,7 @@ namespace Torch.Collections
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_store.Sort(comparer);
|
_store.Sort(comparer);
|
||||||
|
|
||||||
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user