proper executable directories for all but ubisoft

This commit is contained in:
pointfeev 2022-08-23 23:48:43 -04:00
parent 1fa39a3885
commit 600e6e71f9
13 changed files with 66 additions and 44 deletions

View file

@ -148,7 +148,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Gameloop.Vdf" Version="0.6.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.43" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.45" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Onova" Version="2.6.2" />
</ItemGroup>

View file

@ -1,4 +1,5 @@
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Microsoft.Win32;
@ -22,7 +23,7 @@ internal static class EpicLibrary
epicManifestsPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Epic Games\EpicGamesLauncher", "AppDataPath", null) as string;
epicManifestsPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Epic Games\EpicGamesLauncher", "AppDataPath", null) as string;
if (epicManifestsPath is not null && epicManifestsPath.EndsWith(@"\Data")) epicManifestsPath += @"\Manifests";
return epicManifestsPath;
return epicManifestsPath.BeautifyPath();
}
}
@ -57,7 +58,7 @@ internal static class EpicLibrary
|| File.Exists(api64)
|| File.Exists(api64_o)
|| File.Exists(config))
dllDirectories.Add(gameDirectory);
dllDirectories.Add(gameDirectory.BeautifyPath());
string[] directories = Directory.GetDirectories(gameDirectory);
foreach (string _directory in directories)
{

View file

@ -6,6 +6,8 @@ public class Manifest
public string InstallLocation { get; set; }
public string LaunchExecutable { get; set; }
public string CatalogNamespace { get; set; }
public string CatalogItemId { get; set; }

View file

@ -65,7 +65,7 @@ internal partial class InstallForm : CustomForm
}
if (selection.Koaloader && !Uninstalling)
{
foreach (string directory in await selection.GetKoaloaderDirectories())
foreach (string directory in selection.ExecutableDirectories)
{
UpdateUser("Installing Koaloader to " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
await Koaloader.Install(directory, selection, this);
@ -75,7 +75,7 @@ internal partial class InstallForm : CustomForm
{
if (Uninstalling)
{
foreach (string directory in await selection.GetKoaloaderDirectories())
foreach (string directory in selection.ExecutableDirectories)
{
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(Resources.Resources.ResourceIdentifier.Koaloader))

View file

@ -72,8 +72,8 @@ internal partial class MainForm : CustomForm
if (checkForUpdatesResult.CanUpdate)
{
#endif
latestVersion = checkForUpdatesResult.LastVersion;
versions = checkForUpdatesResult.Versions;
latestVersion = checkForUpdatesResult.LastVersion;
versions = checkForUpdatesResult.Versions;
#if !DEBUG
}
#endif

View file

@ -122,6 +122,7 @@ internal partial class SelectForm : CustomForm
selection.Id = "PL";
selection.Name = "Paradox Launcher";
selection.RootDirectory = ParadoxLauncher.InstallPath;
selection.ExecutableDirectories = await selection.RootDirectory.GetExecutableDirectories(d => !d.Contains("bootstrapper"));
selection.DllDirectories = dllDirectories;
selection.Platform = Platform.Paradox;
@ -233,6 +234,16 @@ internal partial class SelectForm : CustomForm
selection.Id = appId;
selection.Name = appData?.name ?? name;
selection.RootDirectory = gameDirectory;
selection.ExecutableDirectories = new();
VToken launch = appInfo?.Value?.GetChild("config")?.GetChild("launch");
if (launch is not null)
foreach (VToken token in launch.Children())
if (token?.GetChild("executable")?.ToString() is string executable
&& (selection.RootDirectory + @"\" + Path.GetDirectoryName(executable)).BeautifyPath() is string path
&& !selection.ExecutableDirectories.Contains(path))
selection.ExecutableDirectories.Add(path);
if (!selection.ExecutableDirectories.Any())
selection.ExecutableDirectories.Add(selection.RootDirectory);
selection.DllDirectories = dllDirectories;
selection.Platform = Platform.Steam;
selection.ProductUrl = "https://store.steampowered.com/app/" + appId;
@ -330,6 +341,11 @@ internal partial class SelectForm : CustomForm
selection.Id = @namespace;
selection.Name = name;
selection.RootDirectory = directory;
selection.ExecutableDirectories = new();
if (manifest.LaunchExecutable is string executable && (selection.RootDirectory + @"\" + Path.GetDirectoryName(executable)).BeautifyPath() is string path)
selection.ExecutableDirectories.Add(path);
else
selection.ExecutableDirectories.Add(selection.RootDirectory);
selection.DllDirectories = dllDirectories;
selection.Platform = Platform.Epic;
foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in entitlements.Where(p => p.Value.name == selection.Name))
@ -411,6 +427,7 @@ internal partial class SelectForm : CustomForm
selection.Id = gameId;
selection.Name = name;
selection.RootDirectory = gameDirectory;
selection.ExecutableDirectories = new() { selection.RootDirectory };
selection.DllDirectories = dllDirectories;
selection.Platform = Platform.Ubisoft;
selection.IconUrl = IconGrabber.GetDomainFaviconUrl("store.ubi.com");

View file

@ -22,7 +22,7 @@ internal static class ParadoxLauncher
{
installPath ??= Registry.GetValue(@"HKEY_CURRENT_USER\Software\Paradox Interactive\Paradox Launcher v2", "LauncherInstallation", null) as string;
installPath ??= Registry.GetValue(@"HKEY_CURRENT_USER\Software\Wow6432Node\Paradox Interactive\Paradox Launcher v2", "LauncherInstallation", null) as string;
return installPath;
return installPath.BeautifyPath();
}
}

View file

@ -4,7 +4,6 @@ using CreamInstaller.Resources;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace CreamInstaller;
@ -43,6 +42,7 @@ internal class ProgramSelection
internal string WebsiteUrl;
internal string RootDirectory;
internal List<string> ExecutableDirectories;
internal List<string> DllDirectories;
internal readonly SortedList<string, (DlcType type, string name, string icon)> AllDlc = new(PlatformIdComparer.String);
@ -51,9 +51,6 @@ internal class ProgramSelection
internal readonly List<(string id, string name, SortedList<string, (DlcType type, string name, string icon)> dlc)> ExtraDlc = new(); // for Paradox Launcher
internal readonly List<(string id, string name, SortedList<string, (DlcType type, string name, string icon)> dlc)> ExtraSelectedDlc = new(); // for Paradox Launcher
private List<string> koaloaderDirectories;
internal async Task<List<string>> GetKoaloaderDirectories() => koaloaderDirectories ??= await RootDirectory.GetKoaloaderDirectories();
internal bool AreDllsLocked
{
get

View file

@ -30,7 +30,7 @@ internal static class Koaloader
{
("SmokeAPI", "SmokeAPI32.dll"), ("SmokeAPI", "SmokeAPI64.dll"),
("ScreamAPI", "ScreamAPI32.dll"), ("ScreamAPI", "ScreamAPI64.dll"),
("Uplay R2 Unlocker", "UplayR2Unlocker32.dll"), ("Uplay R2 Unlocker", "UplayR2Unlocker64.dll"),
("Uplay R1 Unlocker", "UplayR1Unlocker32.dll"), ("Uplay R1 Unlocker", "UplayR1Unlocker64.dll"),
("Uplay R2 Unlocker", "UplayR2Unlocker32.dll"), ("Uplay R2 Unlocker", "UplayR2Unlocker64.dll")
};
@ -43,8 +43,8 @@ internal static class Koaloader
if (targets.Any())
{
writer.WriteLine(" \"targets\": [");
System.Collections.Generic.KeyValuePair<string, string> lastTarget = targets.Last();
foreach (System.Collections.Generic.KeyValuePair<string, string> pair in targets)
KeyValuePair<string, string> lastTarget = targets.Last();
foreach (KeyValuePair<string, string> pair in targets)
{
string path = pair.Value;
writer.WriteLine($" \"{path}\"{(pair.Equals(lastTarget) ? "" : ",")}");
@ -58,8 +58,8 @@ internal static class Koaloader
if (modules.Any())
{
writer.WriteLine(" \"modules\": [");
System.Collections.Generic.KeyValuePair<string, string> lastModule = modules.Last();
foreach (System.Collections.Generic.KeyValuePair<string, string> pair in modules)
KeyValuePair<string, string> lastModule = modules.Last();
foreach (KeyValuePair<string, string> pair in modules)
{
string path = pair.Value;
writer.WriteLine(" {");
@ -76,27 +76,6 @@ internal static class Koaloader
writer.WriteLine("}");
}
internal static async Task<List<string>> GetKoaloaderDirectories(this string rootDirectory) => await Task.Run(async () =>
{
List<string> executableDirectories = new();
if (Program.Canceled || !Directory.Exists(rootDirectory)) return null;
if (Directory.GetFiles(rootDirectory, "*.exe").Any())
executableDirectories.Add(rootDirectory);
string[] directories = Directory.GetDirectories(rootDirectory);
foreach (string _directory in directories)
{
if (Program.Canceled) return null;
try
{
List<string> moreExecutableDirectories = await _directory.GetKoaloaderDirectories();
if (moreExecutableDirectories is not null)
executableDirectories.AddRange(moreExecutableDirectories);
}
catch { }
}
return !executableDirectories.Any() ? null : executableDirectories;
});
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() =>
{
directory.GetKoaloaderComponents(out List<string> proxies, out string config);

View file

@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace CreamInstaller.Resources;
@ -55,6 +56,27 @@ internal static class Resources
return false;
}
internal static async Task<List<string>> GetExecutableDirectories(this string rootDirectory, Func<string, bool> validFunc = null) => await Task.Run(async () =>
{
List<string> executableDirectories = new();
if (Program.Canceled || !Directory.Exists(rootDirectory)) return null;
if (Directory.GetFiles(rootDirectory, "*.exe").Any(d => validFunc(d)))
executableDirectories.Add(rootDirectory);
string[] directories = Directory.GetDirectories(rootDirectory);
foreach (string _directory in directories)
{
if (Program.Canceled) return null;
try
{
List<string> moreExecutableDirectories = await _directory.GetExecutableDirectories(validFunc);
if (moreExecutableDirectories is not null)
executableDirectories.AddRange(moreExecutableDirectories);
}
catch { }
}
return !executableDirectories.Any() ? null : executableDirectories;
});
internal static void GetCreamApiComponents(
this string directory,
out string api32, out string api32_o,

View file

@ -1,4 +1,5 @@
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Gameloop.Vdf.Linq;
@ -21,7 +22,7 @@ internal static class SteamLibrary
{
installPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", null) as string;
installPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Valve\Steam", "InstallPath", null) as string;
return installPath;
return installPath.BeautifyPath();
}
}
@ -52,7 +53,7 @@ internal static class SteamLibrary
|| File.Exists(api64_o)
|| File.Exists(config)
|| File.Exists(cache))
dllDirectories.Add(gameDirectory);
dllDirectories.Add(gameDirectory.BeautifyPath());
string[] directories = Directory.GetDirectories(gameDirectory);
foreach (string _directory in directories)
{
@ -91,7 +92,7 @@ internal static class SteamLibrary
string gameDirectory = libraryDirectory + @"\common\" + installdir;
if (!int.TryParse(appId, out int appIdInt)) continue;
if (!int.TryParse(buildId, out int buildIdInt)) continue;
games.Add((appId, name, branch, buildIdInt, gameDirectory));
games.Add((appId, name, branch, buildIdInt, gameDirectory.BeautifyPath()));
}
}
return !games.Any() ? null : games;

View file

@ -1,4 +1,5 @@
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Microsoft.Win32;
@ -32,7 +33,7 @@ internal static class UbisoftLibrary
RegistryKey installKey = installsKey.OpenSubKey(gameId);
string installDir = installKey?.GetValue("InstallDir")?.ToString();
if (installDir is not null)
games.Add((gameId, new DirectoryInfo(installDir).Name, Path.GetFullPath(installDir)));
games.Add((gameId, new DirectoryInfo(installDir).Name, installDir.BeautifyPath()));
}
return games;
});
@ -47,7 +48,7 @@ internal static class UbisoftLibrary
|| File.Exists(api64)
|| File.Exists(api64_o)
|| File.Exists(config))
dllDirectories.Add(gameDirectory);
dllDirectories.Add(gameDirectory.BeautifyPath());
else
{
gameDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config);
@ -58,7 +59,7 @@ internal static class UbisoftLibrary
|| File.Exists(api64)
|| File.Exists(api64_o)
|| File.Exists(config))
dllDirectories.Add(gameDirectory);
dllDirectories.Add(gameDirectory.BeautifyPath());
}
string[] directories = Directory.GetDirectories(gameDirectory);
foreach (string _directory in directories)

View file

@ -57,4 +57,6 @@ internal static class Diagnostics
FileName = url,
UseShellExecute = true
});
internal static string BeautifyPath(this string path) => path is null ? null : Path.TrimEndingDirectorySeparator(Path.GetFullPath(path));
}