ubisoft game executables
This commit is contained in:
parent
4b6572d398
commit
f66844d8d0
2 changed files with 24 additions and 11 deletions
|
@ -121,7 +121,9 @@ internal partial class SelectForm : CustomForm
|
||||||
selection.Id = "PL";
|
selection.Id = "PL";
|
||||||
selection.Name = "Paradox Launcher";
|
selection.Name = "Paradox Launcher";
|
||||||
selection.RootDirectory = ParadoxLauncher.InstallPath;
|
selection.RootDirectory = ParadoxLauncher.InstallPath;
|
||||||
selection.ExecutableDirectories = await selection.RootDirectory.GetExecutableDirectories(d => !d.Contains("bootstrapper"));
|
selection.ExecutableDirectories = (await selection.RootDirectory
|
||||||
|
.GetExecutables(d => !Path.GetFileName(d).Contains("bootstrapper")))
|
||||||
|
.Select(e => e = Path.GetDirectoryName(e)).Distinct().ToList();
|
||||||
selection.DllDirectories = dllDirectories;
|
selection.DllDirectories = dllDirectories;
|
||||||
selection.Platform = Platform.Paradox;
|
selection.Platform = Platform.Paradox;
|
||||||
|
|
||||||
|
@ -430,7 +432,17 @@ internal partial class SelectForm : CustomForm
|
||||||
selection.Id = gameId;
|
selection.Id = gameId;
|
||||||
selection.Name = name;
|
selection.Name = name;
|
||||||
selection.RootDirectory = gameDirectory;
|
selection.RootDirectory = gameDirectory;
|
||||||
selection.ExecutableDirectories = new() { selection.RootDirectory };
|
// need a better method for obtaining ubisoft game executables
|
||||||
|
// for now, I just get the largest (file size) single executable
|
||||||
|
string largestExecutableDirectory = null;
|
||||||
|
long largestExecutableDirectorySize = 0;
|
||||||
|
foreach (string path in await selection.RootDirectory.GetExecutables())
|
||||||
|
if (new FileInfo(path).Length is long executableSize && executableSize > largestExecutableDirectorySize)
|
||||||
|
{
|
||||||
|
largestExecutableDirectory = Path.GetDirectoryName(path);
|
||||||
|
largestExecutableDirectorySize = executableSize;
|
||||||
|
}
|
||||||
|
selection.ExecutableDirectories = new() { largestExecutableDirectory ?? selection.RootDirectory };
|
||||||
selection.DllDirectories = dllDirectories;
|
selection.DllDirectories = dllDirectories;
|
||||||
selection.Platform = Platform.Ubisoft;
|
selection.Platform = Platform.Ubisoft;
|
||||||
selection.IconUrl = IconGrabber.GetDomainFaviconUrl("store.ubi.com");
|
selection.IconUrl = IconGrabber.GetDomainFaviconUrl("store.ubi.com");
|
||||||
|
|
|
@ -56,25 +56,26 @@ internal static class Resources
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<List<string>> GetExecutableDirectories(this string rootDirectory, Func<string, bool> validFunc = null) => await Task.Run(async () =>
|
internal static async Task<List<string>> GetExecutables(this string rootDirectory, Func<string, bool> validFunc = null) => await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
List<string> executableDirectories = new();
|
List<string> executables = new();
|
||||||
if (Program.Canceled || !Directory.Exists(rootDirectory)) return null;
|
if (Program.Canceled || !Directory.Exists(rootDirectory)) return null;
|
||||||
if (Directory.GetFiles(rootDirectory, "*.exe").Any(d => validFunc(d)))
|
foreach (string path in Directory.GetFiles(rootDirectory, "*.exe"))
|
||||||
executableDirectories.Add(rootDirectory);
|
if (validFunc is null || validFunc(path))
|
||||||
|
executables.Add(path);
|
||||||
string[] directories = Directory.GetDirectories(rootDirectory);
|
string[] directories = Directory.GetDirectories(rootDirectory);
|
||||||
foreach (string _directory in directories)
|
foreach (string directory in directories)
|
||||||
{
|
{
|
||||||
if (Program.Canceled) return null;
|
if (Program.Canceled) return null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<string> moreExecutableDirectories = await _directory.GetExecutableDirectories(validFunc);
|
List<string> moreExecutables = await directory.GetExecutables(validFunc);
|
||||||
if (moreExecutableDirectories is not null)
|
if (moreExecutables is not null)
|
||||||
executableDirectories.AddRange(moreExecutableDirectories);
|
executables.AddRange(moreExecutables);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
return !executableDirectories.Any() ? null : executableDirectories;
|
return !executables.Any() ? null : executables;
|
||||||
});
|
});
|
||||||
|
|
||||||
internal static void GetCreamApiComponents(
|
internal static void GetCreamApiComponents(
|
||||||
|
|
Loading…
Reference in a new issue