From 5b4ccb5e9dfa6705c5674451808f4204cc27e46a Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 02:44:54 +0000 Subject: [PATCH 01/15] Tweaked min auto nya value --- Nya/Configuration/PluginConfig.cs | 6 +++--- Nya/UI/Views/NyaSettingsMainView.bsml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Nya/Configuration/PluginConfig.cs b/Nya/Configuration/PluginConfig.cs index abc394e..dfbe325 100644 --- a/Nya/Configuration/PluginConfig.cs +++ b/Nya/Configuration/PluginConfig.cs @@ -31,7 +31,7 @@ internal class PluginConfig public virtual Color BackgroundColor { get; set; } = new Color(0.745f, 0.745f, 0.745f); public virtual bool RainbowBackgroundColor { get; set; } = false; public virtual bool PersistantAutoNya { get; set; } = false; - public virtual int AutoNyaWait { get; set; } = 4; + public virtual int AutoNyaWait { get; set; } = 5; public virtual int ImageScaleValue { get; set; } = 512; // 0 means scaling disabled public virtual bool EasterEggs { get; set; } = true; public virtual string SelectedAPI { get; set; } = ImageSources.Sources.Keys.First(); @@ -68,9 +68,9 @@ public virtual void Changed() /// private void FixConfigIssues() { - if (AutoNyaWait < 4) + if (AutoNyaWait < 3) { - AutoNyaWait = 4; + AutoNyaWait = 3; } if (SelectedEndpoints.Count != ImageSources.Sources.Count) diff --git a/Nya/UI/Views/NyaSettingsMainView.bsml b/Nya/UI/Views/NyaSettingsMainView.bsml index 459f2b3..3561abc 100644 --- a/Nya/UI/Views/NyaSettingsMainView.bsml +++ b/Nya/UI/Views/NyaSettingsMainView.bsml @@ -17,7 +17,7 @@ - + From f997b519dda3201255a81d055e5c6e3452fd201e Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 03:10:15 +0000 Subject: [PATCH 02/15] Changed approach for API endpoint validation --- Nya/Configuration/PluginConfig.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Nya/Configuration/PluginConfig.cs b/Nya/Configuration/PluginConfig.cs index dfbe325..31d5007 100644 --- a/Nya/Configuration/PluginConfig.cs +++ b/Nya/Configuration/PluginConfig.cs @@ -68,30 +68,30 @@ public virtual void Changed() /// private void FixConfigIssues() { + using var _ = ChangeTransaction; + if (AutoNyaWait < 3) { AutoNyaWait = 3; } - - if (SelectedEndpoints.Count != ImageSources.Sources.Count) - { - using var _ = ChangeTransaction; - SelectedEndpoints.Clear(); - foreach (var key in ImageSources.Sources.Keys) - { - SelectedEndpoints.Add(key, new EndpointData - { - SelectedSfwEndpoint = ImageSources.Sources[key].SfwEndpoints.FirstOrDefault() ?? "Empty", - SelectedNsfwEndpoint = ImageSources.Sources[key].NsfwEndpoints.FirstOrDefault() ?? "Empty" - }); - } - } - + if (!ImageSources.Sources.ContainsKey(SelectedAPI)) { SelectedEndpoints.Remove(SelectedAPI); SelectedAPI = ImageSources.Sources.First().Key; } + + var selectedSfwEndpoint = SelectedEndpoints[SelectedAPI].SelectedSfwEndpoint; + if (selectedSfwEndpoint != "Empty" && !ImageSources.Sources[SelectedAPI].SfwEndpoints.Contains(selectedSfwEndpoint)) + { + SelectedEndpoints[SelectedAPI].SelectedSfwEndpoint = ImageSources.Sources[SelectedAPI].SfwEndpoints.FirstOrDefault() ?? "Empty"; + } + + var selectedNsfwEndpoint = SelectedEndpoints[SelectedAPI].SelectedNsfwEndpoint; + if (selectedSfwEndpoint != "Empty" && !ImageSources.Sources[SelectedAPI].SfwEndpoints.Contains(selectedSfwEndpoint)) + { + SelectedEndpoints[SelectedAPI].SelectedNsfwEndpoint = ImageSources.Sources[SelectedAPI].NsfwEndpoints.FirstOrDefault() ?? "Empty"; + } } } } \ No newline at end of file From 68e0874c17bdef6ed02f0761aa79db12a1494ea7 Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 03:40:01 +0000 Subject: [PATCH 03/15] Updated FormatSource to capitalise first letter --- .../ModalControllers/SettingsModalController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs index fa4df23..e3ea8dc 100644 --- a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs +++ b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; @@ -284,7 +285,10 @@ protected void NsfwChange(string value) [UIAction("format-source")] protected string FormatSource(string value) { - return value.Split('/').Last().Replace("_", " "); + value = value.Split('/').Last().Replace("_", " "); + var charArray = value.ToCharArray(); + charArray[0] = char.ToUpper(charArray[0]); + return new string(charArray); } #endregion From bab8c0f0c0859d00f51f6832c424549ebafec7b1 Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 10:39:46 +0000 Subject: [PATCH 04/15] Added global Random endpoint --- Nya/Configuration/PluginConfig.cs | 4 ++-- .../SettingsModalController.cs | 10 +++++++--- Nya/Utils/ImageSources.cs | 17 ++++++++++------- Nya/Utils/ImageUtils.cs | 18 ++++++++++++++---- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/Nya/Configuration/PluginConfig.cs b/Nya/Configuration/PluginConfig.cs index 31d5007..f37ec56 100644 --- a/Nya/Configuration/PluginConfig.cs +++ b/Nya/Configuration/PluginConfig.cs @@ -82,13 +82,13 @@ private void FixConfigIssues() } var selectedSfwEndpoint = SelectedEndpoints[SelectedAPI].SelectedSfwEndpoint; - if (selectedSfwEndpoint != "Empty" && !ImageSources.Sources[SelectedAPI].SfwEndpoints.Contains(selectedSfwEndpoint)) + if (!ImageSources.GlobalEndpoints.Contains(selectedSfwEndpoint) && !ImageSources.Sources[SelectedAPI].SfwEndpoints.Contains(selectedSfwEndpoint)) { SelectedEndpoints[SelectedAPI].SelectedSfwEndpoint = ImageSources.Sources[SelectedAPI].SfwEndpoints.FirstOrDefault() ?? "Empty"; } var selectedNsfwEndpoint = SelectedEndpoints[SelectedAPI].SelectedNsfwEndpoint; - if (selectedSfwEndpoint != "Empty" && !ImageSources.Sources[SelectedAPI].SfwEndpoints.Contains(selectedSfwEndpoint)) + if (!ImageSources.GlobalEndpoints.Contains(selectedNsfwEndpoint) && !ImageSources.Sources[SelectedAPI].SfwEndpoints.Contains(selectedSfwEndpoint)) { SelectedEndpoints[SelectedAPI].SelectedNsfwEndpoint = ImageSources.Sources[SelectedAPI].NsfwEndpoints.FirstOrDefault() ?? "Empty"; } diff --git a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs index e3ea8dc..5f30234 100644 --- a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs +++ b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs @@ -397,9 +397,10 @@ private void UpdateLists() { SfwDropDownListSetting.values.Clear(); SfwDropDownListSetting.values = ImageSources.Sources[APIValue].SfwEndpoints.Cast().ToList(); - SfwDropDownListSetting.UpdateChoices(); + SfwDropDownListSetting.values.Add("Random"); SfwDropDownListSetting.Value = SfwValue; - + SfwDropDownListSetting.UpdateChoices(); + if (CheckNsfwListHasEndpoints()) { if (NsfwDropDownListSetting.interactable == false) @@ -410,6 +411,7 @@ private void UpdateLists() NsfwDropDownListSetting.values.Clear(); NsfwDropDownListSetting.values = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); + NsfwDropDownListSetting.values.Add("Random"); NsfwDropDownListSetting.Value = NsfwValue; NsfwDropDownListSetting.UpdateChoices(); } @@ -419,7 +421,9 @@ public void Initialize() { APIList = ImageSources.Sources.Keys.Cast().ToList(); SfwList = ImageSources.Sources[APIValue].SfwEndpoints.Cast().ToList(); - NsfwList = NsfwList = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); + SfwList.Add("Random"); + NsfwList = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); + NsfwList.Add("Random"); } } } \ No newline at end of file diff --git a/Nya/Utils/ImageSources.cs b/Nya/Utils/ImageSources.cs index 7aa96fa..9b694a8 100644 --- a/Nya/Utils/ImageSources.cs +++ b/Nya/Utils/ImageSources.cs @@ -4,7 +4,7 @@ namespace Nya.Utils { - public class ImageSources + internal sealed class ImageSources { internal static Dictionary Sources { get; } = new Dictionary { @@ -75,12 +75,15 @@ internal struct SourceData internal List SfwEndpoints; internal List NsfwEndpoints; } - } - internal enum DataMode - { - Unsupported, - Json, - Local + // Empty shouldn't really be here but that's an issue I'll fix later :clueless: + internal static readonly string[] GlobalEndpoints = {"Empty", "Random"}; + + internal enum DataMode + { + Unsupported, + Json, + Local + } } } diff --git a/Nya/Utils/ImageUtils.cs b/Nya/Utils/ImageUtils.cs index 815f03d..277d2f0 100644 --- a/Nya/Utils/ImageUtils.cs +++ b/Nya/Utils/ImageUtils.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; @@ -74,6 +75,15 @@ public void DownloadNyaImage() { try { + if (endpoint == "Random") + { + var endpoints = !_pluginConfig.NsfwImages + ? ImageSources.Sources[_pluginConfig.SelectedAPI].SfwEndpoints + : ImageSources.Sources[_pluginConfig.SelectedAPI].NsfwEndpoints; + + endpoint = endpoints[_random.Next(endpoints.Count)]; + } + var path = ImageSources.Sources[_pluginConfig.SelectedAPI].BaseEndpoint + endpoint; _siraLog.Info($"Attempting to get image url from {path}"); var response = await GetWebDataToBytesAsync(path); @@ -108,7 +118,7 @@ public async void LoadNewNyaImage(ImageView image, Action? callback) switch (ImageSources.Sources[_pluginConfig.SelectedAPI].Mode) { - case DataMode.Json: + case ImageSources.DataMode.Json: var newUrl = _nyaImageURL; _nyaImageURL = await GetImageURL(selectedEndpoint); var count = 0; @@ -132,7 +142,7 @@ public async void LoadNewNyaImage(ImageView image, Action? callback) } break; - case DataMode.Local: + case ImageSources.DataMode.Local: var type = _pluginConfig.NsfwImages ? "nsfw" : "sfw"; var oldImageURL = _nyaImageURL; while (_nyaImageURL == oldImageURL) @@ -154,7 +164,7 @@ public async void LoadNewNyaImage(ImageView image, Action? callback) _nyaImageBytes = File.ReadAllBytes(_nyaImageURL!); break; - case DataMode.Unsupported: + case ImageSources.DataMode.Unsupported: default: _siraLog.Warn($"Unsupported data mode for endpoint: {_pluginConfig.SelectedAPI}"); return; @@ -163,7 +173,7 @@ public async void LoadNewNyaImage(ImageView image, Action? callback) _nyaImageBytes = await GetWebDataToBytesAsync(_nyaImageURL!); LoadCurrentNyaImage(image, () => callback?.Invoke()); } - catch (Exception e) // e for dEez nuts + catch (Exception e) { _siraLog.Error(e); LoadErrorSprite(image); From 93a661a39be42f90fe57e0ff6f9ee15d4eb67304 Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 10:44:38 +0000 Subject: [PATCH 05/15] Removed kill endpoint from anime-images --- Nya/Utils/ImageSources.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Nya/Utils/ImageSources.cs b/Nya/Utils/ImageSources.cs index 9b694a8..72fc250 100644 --- a/Nya/Utils/ImageSources.cs +++ b/Nya/Utils/ImageSources.cs @@ -13,13 +13,14 @@ internal sealed class ImageSources { BaseEndpoint = "https://api.waifu.pics/", Mode = DataMode.Json, + // Removed 'kill' endpoint because it makes me sad :( SfwEndpoints = new List { "sfw/neko", "sfw/waifu", "sfw/awoo", "sfw/shinobu", "sfw/megumin", "sfw/cuddle", "sfw/cry", "sfw/hug", "sfw/kiss", "sfw/lick", "sfw/pat", "sfw/smug", "sfw/bonk", "sfw/yeet", "sfw/blush", "sfw/smile", "sfw/wave", "sfw/highfive", "sfw/nom", "sfw/bite", "sfw/glomp", "sfw/slap", "sfw/kick", "sfw/happy", "sfw/wink", "sfw/poke", "sfw/dance" - }, // No 'kill' endpoint because it makes me sad :( + }, NsfwEndpoints = new List { "nsfw/neko", "nsfw/waifu", "nsfw/trap", "nsfw/blowjob" } } }, @@ -41,7 +42,8 @@ internal sealed class ImageSources { BaseEndpoint = "https://anime-api.hisoka17.repl.co/img/", Mode = DataMode.Json, - SfwEndpoints = new List { "hug", "kiss", "slap", "wink", "pat", "kill", "cuddle", "punch", "waifu" }, + // Removed 'kill' endpoint because, once again, it makes me a bit sad :( + SfwEndpoints = new List { "hug", "kiss", "slap", "wink", "pat", "cuddle", "punch", "waifu" }, NsfwEndpoints = new List { "nsfw/hentai", "nsfw/boobs", "nsfw/lesbian" } } }, From 17de69a27a191263484b2d2b30d5ebfae06b7b8a Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 14:58:34 +0000 Subject: [PATCH 06/15] Added support for sub folders with local files --- Nya/Plugin.cs | 10 +++++----- Nya/Utils/ImageSources.cs | 17 +++++++++++++++-- Nya/Utils/ImageUtils.cs | 27 ++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Nya/Plugin.cs b/Nya/Plugin.cs index d2db12b..d83b262 100644 --- a/Nya/Plugin.cs +++ b/Nya/Plugin.cs @@ -16,6 +16,10 @@ public class Plugin [Init] public Plugin(Config config, Logger logger, Zenjector zenjector) { + var folderPath = Path.Combine(UnityGame.UserDataPath, "Nya"); + Directory.CreateDirectory(Path.Combine(folderPath, "sfw")); + Directory.CreateDirectory(Path.Combine(folderPath, "nsfw")); + zenjector.UseLogger(logger); zenjector.UseHttpService(); zenjector.UseMetadataBinder(); @@ -27,14 +31,10 @@ public Plugin(Config config, Logger logger, Zenjector zenjector) { pluginConfig.NsfwImages = false; } - + zenjector.Install(Location.App, pluginConfig); zenjector.Install(Location.Menu); zenjector.Install(Location.Singleplayer); - - var folderPath = Path.Combine(UnityGame.UserDataPath, "Nya"); - Directory.CreateDirectory(Path.Combine(folderPath, "sfw")); - Directory.CreateDirectory(Path.Combine(folderPath, "nsfw")); } } } \ No newline at end of file diff --git a/Nya/Utils/ImageSources.cs b/Nya/Utils/ImageSources.cs index 72fc250..a58f149 100644 --- a/Nya/Utils/ImageSources.cs +++ b/Nya/Utils/ImageSources.cs @@ -64,12 +64,25 @@ internal sealed class ImageSources { BaseEndpoint = Path.Combine(UnityGame.UserDataPath, "Nya"), Mode = DataMode.Local, - SfwEndpoints = new List { "/sfw" }, - NsfwEndpoints = new List { "/nsfw" } + SfwEndpoints = PopulateLocalEndpoints(false), + NsfwEndpoints = PopulateLocalEndpoints(true) } } }; + private static List PopulateLocalEndpoints(bool nsfw) + { + var baseFolder = nsfw ? "nsfw" : "sfw"; + var endpoints = new List {baseFolder}; + + foreach (var folder in Directory.GetDirectories(Path.Combine(UnityGame.UserDataPath, "Nya", baseFolder))) + { + endpoints.Add(Path.GetFileName(folder)); + } + + return endpoints; + } + internal struct SourceData { internal string BaseEndpoint; diff --git a/Nya/Utils/ImageUtils.cs b/Nya/Utils/ImageUtils.cs index 277d2f0..7874201 100644 --- a/Nya/Utils/ImageUtils.cs +++ b/Nya/Utils/ImageUtils.cs @@ -143,18 +143,39 @@ public async void LoadNewNyaImage(ImageView image, Action? callback) break; case ImageSources.DataMode.Local: - var type = _pluginConfig.NsfwImages ? "nsfw" : "sfw"; + string folder; + if (!_pluginConfig.NsfwImages) + { + folder = "sfw"; + var endpoint = _pluginConfig.SelectedEndpoints["Local Files"].SelectedSfwEndpoint; + if (endpoint != "sfw") + { + folder = Path.Combine(folder, endpoint); + } + } + else + { + folder = "nsfw"; + var endpoint = _pluginConfig.SelectedEndpoints["Local Files"].SelectedNsfwEndpoint; + if (endpoint != "nsfw") + { + folder = Path.Combine(folder, endpoint); + } + } var oldImageURL = _nyaImageURL; while (_nyaImageURL == oldImageURL) { - var files = Directory.GetFiles(Path.Combine(ImageSources.Sources[_pluginConfig.SelectedAPI].BaseEndpoint, type)); + var path = Path.Combine(ImageSources.Sources[_pluginConfig.SelectedAPI].BaseEndpoint, folder); + var files = Directory.GetFiles(path).Where(file => file.EndsWith(".png") || file.EndsWith(".jpeg") || file.EndsWith(".jpg") || file.EndsWith(".gif") || file.EndsWith(".apng")).ToArray(); switch (files.Length) { case 0: - _siraLog.Error($"No local files for type: {type}"); + _siraLog.Error($"No suitable files in folder: {path}"); LoadErrorSprite(image); + callback?.Invoke(); return; case 1 when oldImageURL != null: + callback?.Invoke(); return; default: _nyaImageURL = files[_random.Next(files.Length)]; From a688ca373d97601d954a5a9bb3ddf64036f82f52 Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 14:58:49 +0000 Subject: [PATCH 07/15] Only add random endpoint if there's more than 1 endpoint --- .../SettingsModalController.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs index 5f30234..9b52783 100644 --- a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs +++ b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs @@ -397,7 +397,10 @@ private void UpdateLists() { SfwDropDownListSetting.values.Clear(); SfwDropDownListSetting.values = ImageSources.Sources[APIValue].SfwEndpoints.Cast().ToList(); - SfwDropDownListSetting.values.Add("Random"); + if (SfwDropDownListSetting.values.Count < 1) + { + SfwDropDownListSetting.values.Add("Random"); + } SfwDropDownListSetting.Value = SfwValue; SfwDropDownListSetting.UpdateChoices(); @@ -411,7 +414,10 @@ private void UpdateLists() NsfwDropDownListSetting.values.Clear(); NsfwDropDownListSetting.values = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); - NsfwDropDownListSetting.values.Add("Random"); + if (NsfwDropDownListSetting.values.Count < 1) + { + NsfwDropDownListSetting.values.Add("Random"); + } NsfwDropDownListSetting.Value = NsfwValue; NsfwDropDownListSetting.UpdateChoices(); } @@ -421,9 +427,15 @@ public void Initialize() { APIList = ImageSources.Sources.Keys.Cast().ToList(); SfwList = ImageSources.Sources[APIValue].SfwEndpoints.Cast().ToList(); - SfwList.Add("Random"); + if (SfwList.Count < 1) + { + SfwList.Add("Random"); + } NsfwList = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); - NsfwList.Add("Random"); + if (NsfwList.Count < 1) + { + NsfwList.Add("Random"); + } } } } \ No newline at end of file From 0cd62a0f8d1477ae922361c3040dae6227314267 Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Tue, 27 Dec 2022 21:30:32 +0000 Subject: [PATCH 08/15] Whoopsies --- .../ModalControllers/SettingsModalController.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs index 9b52783..bd4c033 100644 --- a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs +++ b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs @@ -397,7 +397,7 @@ private void UpdateLists() { SfwDropDownListSetting.values.Clear(); SfwDropDownListSetting.values = ImageSources.Sources[APIValue].SfwEndpoints.Cast().ToList(); - if (SfwDropDownListSetting.values.Count < 1) + if (SfwDropDownListSetting.values.Count > 1) { SfwDropDownListSetting.values.Add("Random"); } @@ -414,7 +414,7 @@ private void UpdateLists() NsfwDropDownListSetting.values.Clear(); NsfwDropDownListSetting.values = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); - if (NsfwDropDownListSetting.values.Count < 1) + if (NsfwDropDownListSetting.values.Count > 1) { NsfwDropDownListSetting.values.Add("Random"); } @@ -427,12 +427,12 @@ public void Initialize() { APIList = ImageSources.Sources.Keys.Cast().ToList(); SfwList = ImageSources.Sources[APIValue].SfwEndpoints.Cast().ToList(); - if (SfwList.Count < 1) + if (SfwList.Count > 1) { SfwList.Add("Random"); } NsfwList = ImageSources.Sources[APIValue].NsfwEndpoints.Cast().ToList(); - if (NsfwList.Count < 1) + if (NsfwList.Count > 1) { NsfwList.Add("Random"); } From 9422e38e17eaa8f7cd84548977d5f51bf80eb6fe Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Thu, 29 Dec 2022 03:03:30 +0000 Subject: [PATCH 09/15] Tweaked values --- .../EnableNsfwFeaturesModalController.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Nya/UI/ViewControllers/ModalControllers/EnableNsfwFeaturesModalController.cs b/Nya/UI/ViewControllers/ModalControllers/EnableNsfwFeaturesModalController.cs index e2641d8..a5fc021 100644 --- a/Nya/UI/ViewControllers/ModalControllers/EnableNsfwFeaturesModalController.cs +++ b/Nya/UI/ViewControllers/ModalControllers/EnableNsfwFeaturesModalController.cs @@ -55,13 +55,13 @@ public ModalContent(string topText, string midText, string midImagePath, string private readonly ModalContent[] _modalContents = { new ModalContent("Woah There!", "Are you sure you want to enable NSFW features? You have to be 18+ to do this!", "Nya.Resources.Chocola_Surprised.png", "No", "Yes, I'm 18+", true, false), - new ModalContent("Are you sure?", "Are you reallllyyyy certain that your age is 18 or above?", "Nya.Resources.Chocola_Question_Mark.png", "No, I'm not", "Yes, I'm certain", true, true), - new ModalContent("Are you very very sure?", "If you're lying I will find out and tell your parents. \r\n(They will be very disappointed with you)", "Nya.Resources.Chocola_Angry.png", "Sorry, I lied", "Yes, I'm not lying", true, true), + new ModalContent("Are you sure?", "Are you realllyyy sure you're 18 years old or above?", "Nya.Resources.Chocola_Question_Mark.png", "No, I'm not", "Yes, I'm certain", true, true), + new ModalContent("Are you very sure?", "If you're lying I will find out and tell your parents. \r\n(They will be very disappointed with you)", "Nya.Resources.Chocola_Angry.png", "Sorry, I lied", "Yes, I'm not lying", true, true), new ModalContent("Just double checking", "Okay so you're absolutely positive that you're 18+ and want to enable NSFW features?", "Nya.Resources.Chocola_Howdidyoudothat.png", "No", "Yes", true, true), new ModalContent("Surprise math question!", "To confirm that you're really 18, let's do a maths question! \r\nWhat is 6 + 9 * (4 - 2) + 0?", "Nya.Resources.Chocola_Laugh.png", "No", "Yes", true, true, true, true), new ModalContent("Correct!", "If you got that right then you must be a smart and sensible adult!", "Nya.Resources.Chocola_Happy.png", "but I'm not...", "I am! 😃", true, true), - new ModalContent("Wait!", "The NSFW features could be dangerous! \r\nWhy else would they be called Not Safe For Work??", "Nya.Resources.Chocola_Spooked.png", "That sounds risky!", "I am prepared", true, true), - new ModalContent("Last time I'll ask", "So you definitely want to enable NSFW and suffer the consequences which may entail from it?", "Nya.Resources.Chocola_Bashful.png", "No", "Yes", true, true) + new ModalContent("Wait!", "The NSFW features could be dangerous! \r\nWhy else would they be called \"Not Safe For Work??\"", "Nya.Resources.Chocola_Spooked.png", "That sounds risky!", "I am prepared", true, true), + new ModalContent("Last time I'll ask", "So you definitely want to enable the NSFW features and suffer the consequences which may entail from it?", "Nya.Resources.Chocola_Bashful.png", "No", "Yes", true, true) }; private bool _parsed; @@ -264,8 +264,8 @@ async void FinishedCallback() if (modalContent.ButtonIntractabilityCooldown) { #if !DEBUG - IntractabilityCooldown(_mathSlider); - IntractabilityCooldown(_submitButton); + IntractabilityCooldown(_mathSlider); + IntractabilityCooldown(_submitButton); #endif } } @@ -280,8 +280,8 @@ async void FinishedCallback() if (modalContent.ButtonIntractabilityCooldown) { #if !DEBUG - IntractabilityCooldown(_noButton); - IntractabilityCooldown(_yesButton); + IntractabilityCooldown(_noButton); + IntractabilityCooldown(_yesButton); #endif } } @@ -291,14 +291,14 @@ async void FinishedCallback() private static async void IntractabilityCooldown(SliderSetting gameObject) { gameObject.interactable = false; - await AwaitSleep(2500); + await AwaitSleep(2000); gameObject.interactable = true; } private static async void IntractabilityCooldown(Selectable gameObject) { gameObject.interactable = false; - await AwaitSleep(2500); + await AwaitSleep(2000); gameObject.interactable = true; } From e03864c2cd09730577a5038679026a8dff930f2e Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Thu, 29 Dec 2022 03:03:40 +0000 Subject: [PATCH 10/15] Version bump --- Nya/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nya/manifest.json b/Nya/manifest.json index e2fdb45..5fd241d 100644 --- a/Nya/manifest.json +++ b/Nya/manifest.json @@ -3,7 +3,7 @@ "id": "Nya", "name": "Nya", "author": "Sirspam", - "version": "0.5.3", + "version": "0.6.0", "description": "BeatSaber mod for displaying nya-tastic images from various anime themed web APIs", "gameVersion": "1.21.0", "icon": "Nya.Resources.Chocola_Mini_Sitting.png", From 2db7c41e6d53900f0cfb91b0aa6e5e14bd3eeda1 Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Thu, 29 Dec 2022 03:17:36 +0000 Subject: [PATCH 11/15] Updated readme for new features Surely I will remember to add that example image --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c7252b8..65611df 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Beat Saber mod for displaying nya-tastic images from various anime themed web AP ### Accessing Nya's Settings Nya's settings can be accessed from the ⚙️ button, pressing this will bring up a modal for common settings, such as the currently selected API. Further settings can be accessed from the ➕ tab. -Alternatively settings can be accessed from BSML's Mod Settings view. +Alternatively settings can also be accessed from BSML's Mod Settings view. ### Resetting Nya's Floating Screen Position -Nya features a floating screen, allowing Nya to be accessed outside of the gameplay setup panel. In the event that this floating screen gets stuck somewhere inaccessible it's position can be reset from BSML's mod settings panel. The position can also be reset from Nya's settings modal and settings view. +Nya features a floating screen, allowing Nya to be accessed outside of the gameplay setup panel. In the event that this floating screen gets stuck somewhere inaccessible it's position can be reset from Nya's settings. ### Supported Image Sources **Note: I don't own any of these sources so I can't guarantee the images will always be appropriate** * [Waifu.Pics](https://waifu.pics/) @@ -15,9 +15,13 @@ Nya features a floating screen, allowing Nya to be accessed outside of the gamep * [Catboys](https://catboys.com/) * [Local Files](#local-files) ### Local Files -In order for local files to work there must be compatible images in the sfw / nsfw files found in Nya's UserData folder. -The compatible file types are PNG, JPEG, GIF and APNG. -Images which are downloaded via Nya will also be placed in the sfw / nsfw folders. +Nya can load images which are saved within ``Beat Saber\UserData\Nya\sfw`` and ``Beat Saber\UserData\Nya\nsfw``. Additionally Nya will treat any subfolders in these directories as 'endpoints', meaning you can switch from local files saved in different folders. + +# ADD EXAMPLE IMAGE HERE K THX + +Nya will only load images with the file type of `png`, `jpg`, `jpeg`, `gif` or `apng`. + +Images which are downloaded via Nya will be saved in the sfw / nsfw folders. ## Installation [Install](https://bsmg.wiki/pc-modding.html#install-mods) the latest version of [Nya](https://github.com/Sirspam/Nya/releases/latest) and the dependencies listed below. ### Dependencies From ecd6e3c697ac8082b0bd3fbce27eea921ff6ab5b Mon Sep 17 00:00:00 2001 From: Sirspam <71392316+Sirspam@users.noreply.github.com> Date: Thu, 29 Dec 2022 15:09:45 +0000 Subject: [PATCH 12/15] Fixed settings modal dropdowns not fading settings modal --- .../SettingsModalController.cs | 30 ++++++++++++------- Nya/UI/Views/SettingsModalView.bsml | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs index bd4c033..3d056bb 100644 --- a/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs +++ b/Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; @@ -57,9 +56,6 @@ protected SettingsModalController(UIUtils uiUtils, ImageUtils imageUtils, MainCa [UIComponent("modal")] public readonly ModalView ModalView = null!; - [UIComponent("modal")] - protected readonly RectTransform ModalTransform = null!; - [UIComponent("settings-modal-tab-selector")] protected readonly TabSelector TabSelector = null!; @@ -95,7 +91,7 @@ protected SettingsModalController(UIUtils uiUtils, ImageUtils imageUtils, MainCa [UIComponent("api-dropdown")] protected readonly Transform ApiDropDownTransform = null!; - + [UIComponent("sfw-dropdown")] protected readonly Transform SfwDropDownTransform = null!; @@ -139,15 +135,29 @@ private void BaseParse(Component parentTransform, object host) { BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "Nya.UI.Views.SettingsModalView.bsml"), parentTransform.gameObject, host); ModalView.name = "NyaSettingsModal"; - ModalView.SetField("_animateParentCanvas", true); - ApiDropDownTransform.Find("DropdownTableView").GetComponent().SetField("_animateParentCanvas", false); - SfwDropDownTransform.Find("DropdownTableView").GetComponent().SetField("_animateParentCanvas", false); - NsfwDropDownTransform.Find("DropdownTableView").GetComponent().SetField("_animateParentCanvas", false); + ModalView.gameObject.AddComponent(); + Button[] buttons = { ApiDropDownTransform.Find("DropDownButton").GetComponent