Merge pull request #16 from Synirrr/RandomCustomBackground
Added randomized CustomBackground Selection
This commit is contained in:
@@ -250,6 +250,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
{
|
{
|
||||||
File = null;
|
File = null;
|
||||||
string WorkshopDir = MyFileSystem.ModsPath;
|
string WorkshopDir = MyFileSystem.ModsPath;
|
||||||
|
List<string> backgrounds = new List<string>();
|
||||||
|
Random r = new Random();
|
||||||
SeamlessClient.TryShow(WorkshopDir);
|
SeamlessClient.TryShow(WorkshopDir);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -261,19 +263,23 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
if (!Directory.Exists(SearchDir))
|
if (!Directory.Exists(SearchDir))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var files = Directory.GetFiles(SearchDir, "*.dds", SearchOption.TopDirectoryOnly);
|
var files = Directory.GetFiles(SearchDir, "CustomLoadingBackground*.dds", SearchOption.TopDirectoryOnly);
|
||||||
foreach (var file in files)
|
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!");
|
SeamlessClient.TryShow(Mod.FriendlyName + " contains a custom loading background!");
|
||||||
File = file;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SeamlessClient.TryShow(ex.ToString());
|
SeamlessClient.TryShow(ex.ToString());
|
||||||
|
Reference in New Issue
Block a user