From abdf90d675e89a6a57a1f1bd2b369facfedadb10 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 18 Jun 2021 12:57:07 -0600 Subject: [PATCH 1/3] Added randomized CustomBackground Selection --- Utilities/Patches.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Utilities/Patches.cs b/Utilities/Patches.cs index 3abb77b..6267210 100644 --- a/Utilities/Patches.cs +++ b/Utilities/Patches.cs @@ -185,6 +185,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer { File = null; string WorkshopDir = MyFileSystem.ModsPath; + List backgrounds = new List(); + Random r = new Random(); SeamlessClient.TryShow(WorkshopDir); try { @@ -196,18 +198,21 @@ namespace SeamlessClientPlugin.SeamlessTransfer if (!Directory.Exists(SearchDir)) continue; - var files = Directory.GetFiles(SearchDir, "*.dds", SearchOption.TopDirectoryOnly); + var files = Directory.GetFiles(SearchDir, "CustomLoadingBackground-*.dds", SearchOption.TopDirectoryOnly); foreach (var file in files) { - if (Path.GetFileNameWithoutExtension(file) == "CustomLoadingBackground") + // Adds all files containing CustomLoadingBackground to a list for later randomisation + if (Path.GetFileNameWithoutExtension(file).Contains("CustomLoadingBackground")) { - SeamlessClient.TryShow(Mod.FriendlyName + " contains a custom loading background!"); - File = file; - return true; + backgrounds.Add(file); } } } - + // Randomly pick a loading screen from the available backgrounds + var numberOfItems = backgrounds.Count(); + var rInt = r.Next(0, numberOfItems - 1); + File = backgrounds[rInt]; + return true; } catch (Exception ex) { From f1332b9aab04825a02774fea65d8bfcc7109f881 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 18 Jun 2021 13:08:14 -0600 Subject: [PATCH 2/3] Re-added deleted line. --- Utilities/Patches.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/Patches.cs b/Utilities/Patches.cs index 6267210..3b900fc 100644 --- a/Utilities/Patches.cs +++ b/Utilities/Patches.cs @@ -204,6 +204,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer // Adds all files containing CustomLoadingBackground to a list for later randomisation if (Path.GetFileNameWithoutExtension(file).Contains("CustomLoadingBackground")) { + SeamlessClient.TryShow(Mod.FriendlyName + " contains a custom loading background!"); backgrounds.Add(file); } } From d490fe78dfacd5d3f346247b664e8f66034ff035 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 18 Jun 2021 22:03:51 -0600 Subject: [PATCH 3/3] Changed wildcard search --- Utilities/Patches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/Patches.cs b/Utilities/Patches.cs index 3b900fc..2160cf1 100644 --- a/Utilities/Patches.cs +++ b/Utilities/Patches.cs @@ -198,7 +198,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer if (!Directory.Exists(SearchDir)) continue; - var files = Directory.GetFiles(SearchDir, "CustomLoadingBackground-*.dds", SearchOption.TopDirectoryOnly); + var files = Directory.GetFiles(SearchDir, "CustomLoadingBackground*.dds", SearchOption.TopDirectoryOnly); foreach (var file in files) { // Adds all files containing CustomLoadingBackground to a list for later randomisation