Implement utility list filtering for the UI

This commit is contained in:
Timothy Baldridge 2020-11-14 12:16:11 -07:00
parent 802448c934
commit 73d3168d2c
3 changed files with 27 additions and 0 deletions

View File

@ -34,6 +34,9 @@ namespace Wabbajack.Lib.ModListRegistry
[JsonProperty("nsfw")]
public bool NSFW { get; set; }
[JsonProperty("utility_list")]
public bool UtilityList { get; set; }
[JsonProperty("links")]
public LinksObject Links { get; set; } = new LinksObject();

View File

@ -37,6 +37,9 @@ namespace Wabbajack
[Reactive]
public bool ShowNSFW { get; set; }
[Reactive]
public bool ShowUtilityLists { get; set; }
[Reactive]
public string GameType { get; set; }
@ -77,6 +80,7 @@ namespace Wabbajack
{
OnlyInstalled = false;
ShowNSFW = false;
ShowUtilityLists = false;
Search = string.Empty;
GameType = ALL_GAME_TYPE;
});
@ -150,6 +154,12 @@ namespace Wabbajack
if (!vm.Metadata.NSFW) return true;
return vm.Metadata.NSFW && showNSFW;
}))
.Filter(this.WhenAny(x => x.ShowUtilityLists)
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
{
if (!vm.Metadata.UtilityList) return true;
return vm.Metadata.UtilityList && showNSFW;
}))
// Filter by Game
.Filter(this.WhenAny(x => x.GameType)
.Debounce(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler)
@ -169,6 +179,12 @@ namespace Wabbajack
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
.Sort(Comparer<ModListMetadataVM>.Create((a, b) => a.IsBroken.CompareTo(b.IsBroken)))
.Bind(ModLists)

View File

@ -116,6 +116,14 @@
VerticalAlignment="Center"
Content="Show NSFW"
Foreground="{StaticResource ForegroundBrush}" />
<CheckBox
x:Name="ShowUtilityLists"
Margin="10,0,10,0"
VerticalAlignment="Center"
Content="Show Utility Lists"
Foreground="{StaticResource ForegroundBrush}" />
<CheckBox
x:Name="OnlyInstalledCheckbox"
Margin="10,0,10,0"