Merge pull request #764 from erri120/nsfw-checkbox

NSFW option for Modlists
This commit is contained in:
Timothy Baldridge 2020-04-27 06:03:48 -06:00 committed by GitHub
commit 35419a8a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 11 deletions

View File

@ -18,6 +18,7 @@ namespace Wabbajack.Lib
public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite, ModlistReadme;
public Version? ModlistVersion;
public AbsolutePath ModListImage;
public bool ModlistIsNSFW;
protected Version? WabbajackVersion;
public abstract AbsolutePath VFSCacheName { get; }

View File

@ -108,6 +108,11 @@ namespace Wabbajack.Lib
/// </summary>
public Version Version = new Version(1, 0, 0, 0);
/// <summary>
/// Whether the Modlist is NSFW or not
/// </summary>
public bool IsNSFW;
/// <summary>
/// The size of all the archives once they're downloaded
/// </summary>

View File

@ -303,7 +303,8 @@ namespace Wabbajack.Lib
Description = ModListDescription ?? "",
Readme = ModlistReadme ?? "",
Image = ModListImage != default ? ModListImage.FileName : default,
Website = ModListWebsite != null ? new Uri(ModListWebsite) : null
Website = !string.IsNullOrWhiteSpace(ModListWebsite) ? new Uri(ModListWebsite) : null,
IsNSFW = ModlistIsNSFW
};
UpdateTracker.NextStep("Running Validation");

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

@ -130,6 +130,7 @@ namespace Wabbajack
public string Description { get; set; }
public string Website { get; set; }
public string Readme { get; set; }
public bool IsNSFW { get; set; }
public AbsolutePath SplashScreen { get; set; }
}

View File

@ -20,7 +20,7 @@ namespace Wabbajack
[Reactive]
public string VersionText { get; set; }
private ObservableAsPropertyHelper<Version> _version;
private readonly ObservableAsPropertyHelper<Version> _version;
public Version Version => _version.Value;
[Reactive]
@ -37,6 +37,9 @@ namespace Wabbajack
[Reactive]
public string Website { get; set; }
[Reactive]
public bool IsNSFW { get; set; }
public IObservable<bool> InError { get; }
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
@ -81,6 +84,7 @@ namespace Wabbajack
ImagePath.TargetPath = _settings.SplashScreen;
Website = _settings.Website;
VersionText = _settings.Version;
IsNSFW = _settings.IsNSFW;
}
public void Save()
@ -92,6 +96,7 @@ namespace Wabbajack
_settings.Readme = Readme;
_settings.SplashScreen = ImagePath.TargetPath;
_settings.Website = Website;
_settings.IsNSFW = IsNSFW;
}
}
}

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

@ -22,6 +22,7 @@ namespace Wabbajack
public Uri Website => SourceModList?.Website;
public ModManager ModManager => SourceModList?.ModManager ?? ModManager.MO2;
public Version Version => SourceModList?.Version;
public bool IsNSFW => SourceModList?.IsNSFW ?? false;
// Image isn't exposed as a direct property, but as an observable.
// This acts as a caching mechanism, as interested parties will trigger it to be created,

View File

@ -147,6 +147,9 @@
Text="Readme"
ToolTip="Link to the Readme." />
<TextBox x:Name="ReadmeSetting" Style="{StaticResource ValueStyle}"/>
<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

@ -61,20 +61,22 @@ namespace Wabbajack
.Select(x => !x)
.BindToStrict(this, x => x.SettingsScrollViewer.IsEnabled)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.ModListName, x => x.ModListNameSetting.Text)
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.ModListName, x => x.ModListNameSetting.Text)
.DisposeWith(dispose);
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.VersionText, x => x.VersionSetting.Text)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.AuthorText, x => x.AuthorNameSetting.Text)
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.AuthorText, x => x.AuthorNameSetting.Text)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.Description, x => x.DescriptionSetting.Text)
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.Description, x => x.DescriptionSetting.Text)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.CurrentModlistSettings.ImagePath)
.BindToStrict(this, x => x.ImageFilePicker.PickerVM)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.Website, x => x.WebsiteSetting.Text)
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.Website, x => x.WebsiteSetting.Text)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.Readme, x => x.ReadmeSetting.Text)
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.Readme, x => x.ReadmeSetting.Text)
.DisposeWith(dispose);
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.IsNSFW, x => x.NSFWSetting.IsChecked)
.DisposeWith(dispose);
// Bottom Compiler Settings

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)