From a56c773f594670717d773304ca4e90a09dca48cc Mon Sep 17 00:00:00 2001 From: erri120 Date: Mon, 7 Oct 2019 17:52:31 +0200 Subject: [PATCH] Added checkbox to enable NSFW contents in slideshow --- Wabbajack/AppState.cs | 47 ++++++++++++++++++++++----------------- Wabbajack/MainWindow.xaml | 4 +++- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Wabbajack/AppState.cs b/Wabbajack/AppState.cs index cfd5bb41..2710a7cd 100644 --- a/Wabbajack/AppState.cs +++ b/Wabbajack/AppState.cs @@ -231,6 +231,8 @@ namespace Wabbajack private string _SplashScreenSummary; public string SplashScreenSummary { get => _SplashScreenSummary; set => this.RaiseAndSetIfChanged(ref _SplashScreenSummary, value); } + private bool _splashShowNSFW = true; + public bool SplashShowNSFW { get => _splashShowNSFW; set => this.RaiseAndSetIfChanged(ref _splashShowNSFW, value); } public string Error => "Error"; @@ -297,29 +299,31 @@ namespace Wabbajack try { var element = SlideShowElements[idx]; - - var data = new MemoryStream(); - using (var stream = new HttpClient().GetStreamSync("asdas" + element.ImageURL)) - stream.CopyTo(data); - data.Seek(0, SeekOrigin.Begin); - - - dispatcher.Invoke(() => + if(!element.Adult || (element.Adult && SplashShowNSFW)) { - var bitmap = new BitmapImage(); - bitmap.BeginInit(); - bitmap.CacheOption = BitmapCacheOption.OnLoad; - bitmap.StreamSource = data; - bitmap.EndInit(); + var data = new MemoryStream(); + using (var stream = new HttpClient().GetStreamSync("asdas" + element.ImageURL)) + stream.CopyTo(data); + data.Seek(0, SeekOrigin.Begin); - SplashScreenImage = bitmap; - SplashScreenModName = element.ModName; - SplashScreenAuthorName = element.AuthorName; - SplashScreenSummary = element.ModSummary; - _nexusSiteURL = element.ModURL; - _lastSlideShowUpdate = DateTime.Now; - }); + dispatcher.Invoke(() => + { + var bitmap = new BitmapImage(); + bitmap.BeginInit(); + bitmap.CacheOption = BitmapCacheOption.OnLoad; + bitmap.StreamSource = data; + bitmap.EndInit(); + + SplashScreenImage = bitmap; + SplashScreenModName = element.ModName; + SplashScreenAuthorName = element.AuthorName; + SplashScreenSummary = element.ModSummary; + _nexusSiteURL = element.ModURL; + + _lastSlideShowUpdate = DateTime.Now; + }); + } } catch (Exception ex) { @@ -347,7 +351,7 @@ namespace Wabbajack SplashScreenAuthorName = modlist.Author; _nexusSiteURL = modlist.Website; SplashScreenSummary = modlist.Description; - //if(modlist.Image != null) SplashScreenImage = modlist.Image; + //TODO: if(modlist.Image != null) SplashScreenImage = modlist.Image; SlideShowElements = modlist.Archives.OfType().Select(m => new SlideShowItem { @@ -356,6 +360,7 @@ namespace Wabbajack ModSummary = NexusApiUtils.FixupSummary(m.Summary), ImageURL = m.SlideShowPic, ModURL = m.NexusURL, + Adult = m.Adult }).ToList(); } diff --git a/Wabbajack/MainWindow.xaml b/Wabbajack/MainWindow.xaml index c3636d0e..0436bace 100644 --- a/Wabbajack/MainWindow.xaml +++ b/Wabbajack/MainWindow.xaml @@ -57,11 +57,13 @@ + -