Added NSFW filter to the gallery

This commit is contained in:
erri120 2020-04-27 12:18:08 +02:00
parent 0d07319ac8
commit edf2645d0e
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
5 changed files with 28 additions and 9 deletions

View File

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

View File

@ -34,6 +34,9 @@ namespace Wabbajack
[Reactive]
public bool OnlyInstalled { get; set; }
[Reactive]
public bool ShowNSFW { get; set; }
private readonly ObservableAsPropertyHelper<bool> _Loaded;
public bool Loaded => _Loaded.Value;
@ -49,6 +52,7 @@ namespace Wabbajack
() =>
{
OnlyInstalled = false;
ShowNSFW = false;
Search = string.Empty;
});
@ -91,7 +95,7 @@ namespace Wabbajack
.Transform(m => new ModListMetadataVM(this, m))
.DisposeMany()
// Filter only installed
.Filter(predicateChanged: this.WhenAny(x => x.OnlyInstalled)
.Filter(this.WhenAny(x => x.OnlyInstalled)
.Select<bool, Func<ModListMetadataVM, bool>>(onlyInstalled => (vm) =>
{
if (!onlyInstalled) return true;
@ -99,13 +103,19 @@ namespace Wabbajack
return gameMeta.IsInstalled;
}))
// Filter on search box
.Filter(predicateChanged: this.WhenAny(x => x.Search)
.Filter(this.WhenAny(x => x.Search)
.Debounce(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler)
.Select<string, Func<ModListMetadataVM, bool>>(search => (vm) =>
{
if (string.IsNullOrWhiteSpace(search)) return true;
return vm.Metadata.Title.ContainsCaseInsensitive(search);
}))
.Filter(this.WhenAny(x => x.ShowNSFW)
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
{
if (!vm.Metadata.NSFW) return true;
return vm.Metadata.NSFW && showNSFW;
}))
// Put broken lists at bottom
.Sort(Comparer<ModListMetadataVM>.Create((a, b) => a.IsBroken.CompareTo(b.IsBroken)))
.Bind(ModLists)

View File

@ -147,11 +147,9 @@
Text="Readme"
ToolTip="Link to the Readme." />
<TextBox x:Name="ReadmeSetting" Style="{StaticResource ValueStyle}"/>
<StackPanel Orientation="Horizontal" Margin="0 6 0 0">
<TextBlock>NSFW:</TextBlock>
<CheckBox x:Name="NSFWSetting" Margin="8 1 0 0"
ToolTip="Select this if your Modlist has adult themed content such as SexLab or other mods involving sexual acts. Nude body replacer do not fall under this category neither do slutty outfits or gore."/>
</StackPanel>
<CheckBox x:Name="NSFWSetting"
Content="NSFW"
ToolTip="Select this if your Modlist has adult themed content such as SexLab or other mods involving sexual acts. Nude body replacer do not fall under this category neither do revealing outfits or gore."/>
</StackPanel>
</ScrollViewer>
<Border

View File

@ -106,6 +106,12 @@
x:Name="SearchBox"
Width="160"
VerticalContentAlignment="Center" />
<CheckBox
x:Name="ShowNSFW"
Margin="20,0,10,0"
VerticalAlignment="Center"
Content="Show NSFW"
Foreground="{StaticResource ForegroundBrush}"/>
<CheckBox
x:Name="OnlyInstalledCheckbox"
Margin="20,0,10,0"

View File

@ -56,10 +56,12 @@ namespace Wabbajack
.BindToStrict(this, x => x.ErrorIcon.Visibility)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, vm => vm.Search, x => x.SearchBox.Text)
this.BindStrict(ViewModel, vm => vm.Search, x => x.SearchBox.Text)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, vm => vm.OnlyInstalled, x => x.OnlyInstalledCheckbox.IsChecked)
this.BindStrict(ViewModel, vm => vm.OnlyInstalled, x => x.OnlyInstalledCheckbox.IsChecked)
.DisposeWith(dispose);
this.BindStrict(ViewModel, vm => vm.ShowNSFW, x => x.ShowNSFW.IsChecked)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.ClearFiltersCommand)