mirror of
https://github.com/4sval/FModel.git
synced 2026-03-21 17:24:26 -05:00
pulled c4p
This commit is contained in:
parent
1449f78665
commit
344b40361f
|
|
@ -1 +1 @@
|
|||
Subproject commit 65d2cc0ba1a2abd86c46c4721cd1372843731c2e
|
||||
Subproject commit 1b82397777d33851781e96134e5afef03028b557
|
||||
|
|
@ -3,8 +3,10 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.UE4.VirtualFileSystem;
|
||||
using FModel.Framework;
|
||||
|
||||
namespace FModel.ViewModels;
|
||||
|
|
@ -64,7 +66,7 @@ public class SearchViewModel : ViewModel
|
|||
SearchResultsView.Refresh();
|
||||
}
|
||||
|
||||
public void CycleSortSizeMode()
|
||||
public async Task CycleSortSizeMode()
|
||||
{
|
||||
CurrentSortSizeMode = CurrentSortSizeMode switch
|
||||
{
|
||||
|
|
@ -73,18 +75,37 @@ public class SearchViewModel : ViewModel
|
|||
_ => ESortSizeMode.None
|
||||
};
|
||||
|
||||
using (SearchResultsView.DeferRefresh())
|
||||
var sorted = await Task.Run(() =>
|
||||
{
|
||||
SearchResultsView.SortDescriptions.Clear();
|
||||
if (CurrentSortSizeMode != ESortSizeMode.None)
|
||||
{
|
||||
var sort = CurrentSortSizeMode == ESortSizeMode.Ascending
|
||||
? ListSortDirection.Ascending
|
||||
: ListSortDirection.Descending;
|
||||
var archiveDict = SearchResults
|
||||
.OfType<VfsEntry>()
|
||||
.Select(f => f.Vfs.Name)
|
||||
.Distinct()
|
||||
.Select((name, idx) => (name, idx))
|
||||
.ToDictionary(x => x.name, x => x.idx);
|
||||
|
||||
SearchResultsView.SortDescriptions.Add(new SortDescription(nameof(GameFile.Size), sort));
|
||||
}
|
||||
}
|
||||
var keyed = SearchResults.Select(f =>
|
||||
{
|
||||
int archiveKey = f is VfsEntry ve && archiveDict.TryGetValue(ve.Vfs.Name, out var key) ? key : -1;
|
||||
return (File: f, f.Size, ArchiveKey: archiveKey);
|
||||
});
|
||||
|
||||
return CurrentSortSizeMode switch
|
||||
{
|
||||
ESortSizeMode.Ascending => keyed
|
||||
.OrderBy(x => x.Size).ThenBy(x => x.ArchiveKey)
|
||||
.Select(x => x.File).ToList(),
|
||||
ESortSizeMode.Descending => keyed
|
||||
.OrderByDescending(x => x.Size).ThenBy(x => x.ArchiveKey)
|
||||
.Select(x => x.File).ToList(),
|
||||
_ => keyed
|
||||
.OrderBy(x => x.ArchiveKey).ThenBy(x => x.File.Path, StringComparer.OrdinalIgnoreCase)
|
||||
.Select(x => x.File).ToList()
|
||||
};
|
||||
});
|
||||
|
||||
SearchResults.Clear();
|
||||
SearchResults.AddRange(sorted.ToList());
|
||||
}
|
||||
|
||||
private bool ItemFilter(object item, IEnumerable<string> filters)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,11 @@
|
|||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<ListView Grid.Row="1" x:Name="SearchListView" VirtualizingPanel.IsVirtualizing="True" ItemsSource="{Binding CUE4Parse.SearchVm.SearchResultsView, IsAsync=True}">
|
||||
<ListView Grid.Row="1" x:Name="SearchListView"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
ItemsSource="{Binding CUE4Parse.SearchVm.SearchResultsView, IsAsync=True}">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ public partial class SearchView
|
|||
_applicationView.CUE4Parse.SearchVm.RefreshFilter();
|
||||
}
|
||||
|
||||
private void OnSortClick(object sender, RoutedEventArgs e)
|
||||
private async void OnSortClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_applicationView.CUE4Parse.SearchVm.CycleSortSizeMode();
|
||||
await _applicationView.CUE4Parse.SearchVm.CycleSortSizeMode();
|
||||
}
|
||||
|
||||
private async void OnAssetDoubleClick(object sender, RoutedEventArgs e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user