Fixed some crashes with invalid/no mods on the pc

This commit is contained in:
Bob Da Ross
2021-03-22 01:43:00 -05:00
parent 11dbec75fc
commit 6ee6f7b170

View File

@@ -155,32 +155,34 @@ namespace SeamlessClientPlugin.SeamlessTransfer
private static bool GetCustomLoadingScreenPath(List<MyObjectBuilder_Checkpoint.ModItem> Mods, out string File) private static bool GetCustomLoadingScreenPath(List<MyObjectBuilder_Checkpoint.ModItem> Mods, out string File)
{ {
string WorkshopDir = MyFileSystem.ModsPath;
SeamlessClient.TryShow(WorkshopDir);
File = null; File = null;
SeamlessClient.TryShow("Installed Mods: " + Mods); string WorkshopDir = MyFileSystem.ModsPath;
foreach(var Mod in Mods) SeamlessClient.TryShow(WorkshopDir);
try
{ {
string SearchDir = Mod.GetPath(); SeamlessClient.TryShow("Installed Mods: " + Mods);
var files = Directory.EnumerateFiles(SearchDir, "*.dds", SearchOption.TopDirectoryOnly); foreach (var Mod in Mods)
foreach (var file in files)
{ {
if (Path.GetFileNameWithoutExtension(file) == "CustomLoadingBackground") string SearchDir = Mod.GetPath();
{
SeamlessClient.TryShow(Mod.FriendlyName + " contains a custom loading background!");
File = file;
return true;
}
if (!Directory.Exists(SearchDir))
continue;
var files = Directory.GetFiles(SearchDir, "*.dds", SearchOption.TopDirectoryOnly);
foreach (var file in files)
{
if (Path.GetFileNameWithoutExtension(file) == "CustomLoadingBackground")
{
SeamlessClient.TryShow(Mod.FriendlyName + " contains a custom loading background!");
File = file;
return true;
}
}
} }
}catch(Exception ex)
{
SeamlessClient.TryShow(ex.ToString());
} }
SeamlessClient.TryShow("No installed custom loading screen!"); SeamlessClient.TryShow("No installed custom loading screen!");