diff --git a/Wabbajack.App.Wpf/Models/ResourceMonitor.cs b/Wabbajack.App.Wpf/Models/ResourceMonitor.cs index 8b7bf883..5296661b 100644 --- a/Wabbajack.App.Wpf/Models/ResourceMonitor.cs +++ b/Wabbajack.App.Wpf/Models/ResourceMonitor.cs @@ -14,7 +14,7 @@ namespace Wabbajack.Models; public class ResourceMonitor : IDisposable { - private readonly TimeSpan _pollInterval = TimeSpan.FromMilliseconds(250); + private readonly TimeSpan _pollInterval = TimeSpan.FromMilliseconds(1000); private readonly IResource[] _resources; diff --git a/Wabbajack.App.Wpf/Themes/Styles.xaml b/Wabbajack.App.Wpf/Themes/Styles.xaml index ce1351df..a9a10028 100644 --- a/Wabbajack.App.Wpf/Themes/Styles.xaml +++ b/Wabbajack.App.Wpf/Themes/Styles.xaml @@ -87,7 +87,7 @@ + Color="{StaticResource Primary}" /> GameTypeEntries { get; set; } private bool _filteringOnGame; + private bool _filteringOnMinSize; + private bool _filteringOnMaxSize; private GameTypeEntry _selectedGameTypeEntry = null; public GameTypeEntry SelectedGameTypeEntry @@ -170,12 +177,29 @@ namespace Wabbajack }) .StartWith(_ => true); + var minSizeFilter = this.ObservableForProperty(vm => vm.MinSizeFilter) + .Select(v => v.Value) + .Select>(minSize => + { + _filteringOnMinSize = true; + return item => item.Metadata.DownloadMetadata.TotalSize > (minSize * Math.Pow(1024, 3)); + }); + + var maxSizeFilter = this.ObservableForProperty(vm => vm.MaxSizeFilter) + .Select(v => v.Value) + .Select>(maxSize => + { + _filteringOnMaxSize = true; + return item => item.Metadata.DownloadMetadata.TotalSize < (maxSize * Math.Pow(1024, 3)); + }); + + var searchSorter = this.WhenValueChanged(vm => vm.Search) - .Where(s => !string.IsNullOrWhiteSpace(s)) .Throttle(searchThrottle, RxApp.MainThreadScheduler) .Select(s => SortExpressionComparer .Descending(m => m.Metadata.Title.StartsWith(s, StringComparison.InvariantCultureIgnoreCase)) - .ThenByDescending(m => m.Metadata.Title.Contains(s, StringComparison.InvariantCultureIgnoreCase))); + .ThenByDescending(m => m.Metadata.Title.Contains(s, StringComparison.InvariantCultureIgnoreCase)) + .ThenByDescending(m => !m.IsBroken)); _modLists.Connect() .ObserveOn(RxApp.MainThreadScheduler) .Filter(searchTextPredicates) @@ -183,6 +207,8 @@ namespace Wabbajack .Filter(showUnofficial) .Filter(showNSFWFilter) .Filter(gameFilter) + .Filter(minSizeFilter) + .Filter(maxSizeFilter) .Sort(searchSorter) .TreatMovesAsRemoveAdd() .Bind(out _filteredModLists) @@ -196,7 +222,16 @@ namespace Wabbajack var nextEntry = GameTypeEntries.FirstOrDefault(gte => previousGameType == gte.GameIdentifier); SelectedGameTypeEntry = nextEntry != default ? nextEntry : GameTypeEntries.FirstOrDefault(gte => GameType == ALL_GAME_IDENTIFIER); } + /* + if (!_filteringOnMinSize) + MinSizeModlist = ModLists.MinBy(ml => ml.Metadata.DownloadMetadata.TotalSize); + if(!_filteringOnMaxSize) + MaxSizeModlist = ModLists.MaxBy(ml => ml.Metadata.DownloadMetadata.TotalSize); + */ + _filteringOnGame = false; + _filteringOnMinSize = false; + _filteringOnMaxSize = false; }) .DisposeWith(disposables); }); @@ -255,6 +290,8 @@ namespace Wabbajack e.AddOrUpdate(modLists.Select(m => new ModListMetadataVM(_logger, this, m, _maintainer, _wjClient, _cancellationToken))); }); + MinSizeModlist = _modLists.Items.Any() ? _modLists.Items.MinBy(ml => ml.Metadata.DownloadMetadata.TotalSize) : null; + MaxSizeModlist = _modLists.Items.Any() ? _modLists.Items.MaxBy(ml => ml.Metadata.DownloadMetadata.TotalSize) : null; } catch (Exception ex) { diff --git a/Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs b/Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs index a399c132..d50c8cde 100644 --- a/Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs @@ -132,9 +132,7 @@ namespace Wabbajack DownloadSizeText = "Download size : " + UIUtils.FormatBytes(Metadata.DownloadMetadata.SizeOfArchives); InstallSizeText = "Installation size : " + UIUtils.FormatBytes(Metadata.DownloadMetadata.SizeOfInstalledFiles); - TotalSizeRequirementText = "Total size requirement: " + UIUtils.FormatBytes( - Metadata.DownloadMetadata.SizeOfArchives + Metadata.DownloadMetadata.SizeOfInstalledFiles - ); + TotalSizeRequirementText = "Total size requirement: " + UIUtils.FormatBytes( Metadata.DownloadMetadata.TotalSize ); VersionText = "Modlist version : " + Metadata.Version; ImageContainsTitle = Metadata.ImageContainsTitle; DisplayVersionOnlyInInstallerView = Metadata.DisplayVersionOnlyInInstallerView; @@ -181,8 +179,9 @@ namespace Wabbajack }) .ToGuiProperty(this, nameof(Exists)); - var imageObs = Observable.Return(Metadata.ValidationSummary.SmallImage.ToString()) - .DownloadBitmapImage((ex) => _logger.LogError("Error downloading modlist image {Title} from {ImageUri}: {Exception}", Metadata.Title, Metadata.ValidationSummary.SmallImage, ex.Message), LoadingImageLock); + var modlistImageSource = Metadata.ValidationSummary?.SmallImage?.ToString() ?? Metadata.Links.ImageUri; + var imageObs = Observable.Return(modlistImageSource) + .DownloadBitmapImage((ex) => _logger.LogError("Error downloading modlist image {Title} from {ImageUri}: {Exception}", Metadata.Title, modlistImageSource, ex.Message), LoadingImageLock); _Image = imageObs .ToGuiProperty(this, nameof(Image)); diff --git a/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs b/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs index c4381503..1d99549a 100644 --- a/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs @@ -114,7 +114,7 @@ namespace Wabbajack _resourceMonitor.Updates .Select(r => string.Join(", ", r.Where(r => r.Throughput > 0) - .Select(s => $"{s.Name} - {s.Throughput.ToFileSizeString()}/sec"))) + .Select(s => $"{s.Name} - {s.Throughput.ToFileSizeString()}/s"))) .BindToStrict(this, view => view.ResourceStatus); diff --git a/Wabbajack.App.Wpf/Views/ModListGalleryView.xaml b/Wabbajack.App.Wpf/Views/ModListGalleryView.xaml index f1546e02..e74eb102 100644 --- a/Wabbajack.App.Wpf/Views/ModListGalleryView.xaml +++ b/Wabbajack.App.Wpf/Views/ModListGalleryView.xaml @@ -86,6 +86,7 @@ + @@ -136,7 +137,7 @@ - + @@ -188,6 +189,16 @@ + + + + + + + + + +