Binding fixes for utility lists

This commit is contained in:
Timothy Baldridge 2020-11-14 12:30:28 -07:00
parent 73d3168d2c
commit ae358e270d
3 changed files with 6 additions and 17 deletions

View File

@ -107,6 +107,7 @@ namespace Wabbajack
private bool _useCompression = false; private bool _useCompression = false;
public bool UseCompression { get => _useCompression; set => RaiseAndSetIfChanged(ref _useCompression, value); } public bool UseCompression { get => _useCompression; set => RaiseAndSetIfChanged(ref _useCompression, value); }
public bool ShowUtilityLists { get; set; }
} }
[JsonName("PerformanceSettings")] [JsonName("PerformanceSettings")]

View File

@ -64,6 +64,7 @@ namespace Wabbajack
{ {
GameType = !string.IsNullOrEmpty(settings.Game) ? settings.Game : ALL_GAME_TYPE; GameType = !string.IsNullOrEmpty(settings.Game) ? settings.Game : ALL_GAME_TYPE;
ShowNSFW = settings.ShowNSFW; ShowNSFW = settings.ShowNSFW;
ShowUtilityLists = settings.ShowUtilityLists;
OnlyInstalled = settings.OnlyInstalled; OnlyInstalled = settings.OnlyInstalled;
Search = settings.Search; Search = settings.Search;
} }
@ -155,11 +156,7 @@ namespace Wabbajack
return vm.Metadata.NSFW && showNSFW; return vm.Metadata.NSFW && showNSFW;
})) }))
.Filter(this.WhenAny(x => x.ShowUtilityLists) .Filter(this.WhenAny(x => x.ShowUtilityLists)
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm => .Select<bool, Func<ModListMetadataVM, bool>>(showUtilityLists => vm => showUtilityLists ? vm.Metadata.UtilityList : !vm.Metadata.UtilityList))
{
if (!vm.Metadata.UtilityList) return true;
return vm.Metadata.UtilityList && showNSFW;
}))
// Filter by Game // Filter by Game
.Filter(this.WhenAny(x => x.GameType) .Filter(this.WhenAny(x => x.GameType)
.Debounce(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler) .Debounce(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler)
@ -173,18 +170,6 @@ namespace Wabbajack
return GameType == vm.Metadata.Game.GetDescription<Game>().ToString(); return GameType == vm.Metadata.Game.GetDescription<Game>().ToString();
})) }))
.Filter(this.WhenAny(x => x.ShowNSFW)
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
{
if (!vm.Metadata.NSFW) return true;
return vm.Metadata.NSFW && showNSFW;
}))
.Filter(this.WhenAny(x => x.ShowUtilityLists)
.Select<bool, Func<ModListMetadataVM, bool>>(showUtilityLists => vm =>
{
if (!vm.Metadata.UtilityList) return true;
return vm.Metadata.UtilityList && showUtilityLists;
}))
// Put broken lists at bottom // Put broken lists at bottom
.Sort(Comparer<ModListMetadataVM>.Create((a, b) => a.IsBroken.CompareTo(b.IsBroken))) .Sort(Comparer<ModListMetadataVM>.Create((a, b) => a.IsBroken.CompareTo(b.IsBroken)))
.Bind(ModLists) .Bind(ModLists)
@ -220,6 +205,7 @@ namespace Wabbajack
settings.Game = GameType; settings.Game = GameType;
settings.Search = Search; settings.Search = Search;
settings.ShowNSFW = ShowNSFW; settings.ShowNSFW = ShowNSFW;
settings.ShowUtilityLists = ShowUtilityLists;
settings.OnlyInstalled = OnlyInstalled; settings.OnlyInstalled = OnlyInstalled;
} }
} }

View File

@ -63,6 +63,8 @@ namespace Wabbajack
.DisposeWith(dispose); .DisposeWith(dispose);
this.BindStrict(ViewModel, vm => vm.ShowNSFW, x => x.ShowNSFW.IsChecked) this.BindStrict(ViewModel, vm => vm.ShowNSFW, x => x.ShowNSFW.IsChecked)
.DisposeWith(dispose); .DisposeWith(dispose);
this.BindStrict(ViewModel, vm => vm.ShowUtilityLists, x => x.ShowUtilityLists.IsChecked)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.ClearFiltersCommand) this.WhenAny(x => x.ViewModel.ClearFiltersCommand)
.BindToStrict(this, x => x.ClearFiltersButton.Command) .BindToStrict(this, x => x.ClearFiltersButton.Command)