diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 0f30b9c..af426ef 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -4,7 +4,7 @@ net7.0-windows True Resources\ini.ico - 4.9.2 + 4.9.3 2021, pointfeev (https://github.com/pointfeev) CreamInstaller Automatic DLC Unlocker Installer & Configuration Generator diff --git a/CreamInstaller/Forms/SelectDialogForm.Designer.cs b/CreamInstaller/Forms/SelectDialogForm.Designer.cs index 48c3ced..00d29c2 100644 --- a/CreamInstaller/Forms/SelectDialogForm.Designer.cs +++ b/CreamInstaller/Forms/SelectDialogForm.Designer.cs @@ -1,6 +1,5 @@ using System.ComponentModel; using System.Windows.Forms; - using CreamInstaller.Components; namespace CreamInstaller.Forms diff --git a/CreamInstaller/Platforms/Epic/EpicLibrary.cs b/CreamInstaller/Platforms/Epic/EpicLibrary.cs index 0a009ac..cd7f21a 100644 --- a/CreamInstaller/Platforms/Epic/EpicLibrary.cs +++ b/CreamInstaller/Platforms/Epic/EpicLibrary.cs @@ -21,7 +21,7 @@ internal static class EpicLibrary epicManifestsPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Epic Games\EpicGamesLauncher", "AppDataPath", null) as string; if (epicManifestsPath is not null && epicManifestsPath.EndsWith(@"\Data", StringComparison.Ordinal)) epicManifestsPath += @"\Manifests"; - return epicManifestsPath.BeautifyPath(); + return epicManifestsPath.ResolvePath(); } } @@ -39,8 +39,7 @@ internal static class EpicLibrary try { Manifest manifest = JsonConvert.DeserializeObject(json); - if (manifest is not null && !games.Any(g - => g.CatalogNamespace == manifest.CatalogNamespace && g.InstallLocation == manifest.InstallLocation)) + if (manifest is not null && games.All(g => g.CatalogNamespace != manifest.CatalogNamespace)) games.Add(manifest); } catch diff --git a/CreamInstaller/Platforms/Epic/Heroic/HeroicLibrary.cs b/CreamInstaller/Platforms/Epic/Heroic/HeroicLibrary.cs index 634532e..f7ffeba 100644 --- a/CreamInstaller/Platforms/Epic/Heroic/HeroicLibrary.cs +++ b/CreamInstaller/Platforms/Epic/Heroic/HeroicLibrary.cs @@ -34,7 +34,7 @@ internal static class HeroicLibrary { DisplayName = appData.Title, CatalogNamespace = appData.Namespace, InstallLocation = appData.Install.InstallPath }; - if (!games.Any(g => g.CatalogNamespace == manifest.CatalogNamespace && g.InstallLocation == manifest.InstallLocation)) + if (games.All(g => g.CatalogNamespace != manifest.CatalogNamespace)) games.Add(manifest); } catch diff --git a/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs b/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs index 2b72b63..f06af41 100644 --- a/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs +++ b/CreamInstaller/Platforms/Paradox/ParadoxLauncher.cs @@ -25,7 +25,7 @@ internal static class ParadoxLauncher get { installPath ??= Registry.GetValue(@"HKEY_CURRENT_USER\Software\Paradox Interactive\Paradox Launcher v2", "LauncherInstallation", null) as string; - return installPath.BeautifyPath(); + return installPath.ResolvePath(); } } diff --git a/CreamInstaller/Platforms/Steam/SteamLibrary.cs b/CreamInstaller/Platforms/Steam/SteamLibrary.cs index 9169da5..4084f9c 100644 --- a/CreamInstaller/Platforms/Steam/SteamLibrary.cs +++ b/CreamInstaller/Platforms/Steam/SteamLibrary.cs @@ -17,7 +17,7 @@ internal static class SteamLibrary { installPath ??= Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", null) as string; installPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", null) as string; - return installPath.BeautifyPath(); + return installPath.ResolvePath(); } } @@ -31,7 +31,7 @@ internal static class SteamLibrary if (Program.Canceled) return games; foreach ((string appId, string name, string branch, int buildId, string gameDirectory) game in (await GetGamesFromLibraryDirectory( - libraryDirectory)).Where(game => !games.Any(_game => _game.appId == game.appId && _game.gameDirectory == game.gameDirectory))) + libraryDirectory)).Where(game => games.All(_game => _game.appId != game.appId))) games.Add(game); } return games; @@ -57,12 +57,8 @@ internal static class SteamLibrary if (string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(installdir) || string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(buildId)) continue; - string gameDirectory = (libraryDirectory + @"\common\" + installdir).BeautifyPath(); - if (games.Any(g => g.appId == appId && g.gameDirectory == gameDirectory)) - continue; - if (!int.TryParse(appId, out int _)) - continue; - if (!int.TryParse(buildId, out int buildIdInt)) + string gameDirectory = (libraryDirectory + @"\common\" + installdir).ResolvePath(); + if (gameDirectory is null || !int.TryParse(appId, out int _) || !int.TryParse(buildId, out int buildIdInt) || games.Any(g => g.appId == appId)) continue; VToken userConfig = result.Value.GetChild("UserConfig"); string branch = userConfig?.GetChild("BetaKey")?.ToString(); @@ -108,4 +104,4 @@ internal static class SteamLibrary } return gameDirectories; }); -} +} \ No newline at end of file diff --git a/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs b/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs index b63b4b2..78783e3 100644 --- a/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs +++ b/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs @@ -30,8 +30,8 @@ internal static class UbisoftLibrary foreach (string gameId in installsKey.GetSubKeyNames()) { RegistryKey installKey = installsKey.OpenSubKey(gameId); - string installDir = installKey?.GetValue("InstallDir")?.ToString()?.BeautifyPath(); - if (installDir is not null && !games.Any(g => g.gameId == gameId && g.gameDirectory == installDir)) + string installDir = installKey?.GetValue("InstallDir")?.ToString()?.ResolvePath(); + if (installDir is not null && games.All(g => g.gameId != gameId)) games.Add((gameId, new DirectoryInfo(installDir).Name, installDir)); } return games; diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs index 0ca71df..123e985 100644 --- a/CreamInstaller/Resources/Resources.cs +++ b/CreamInstaller/Resources/Resources.cs @@ -522,8 +522,8 @@ internal static class Resources private static bool IsCommonIncorrectExecutable(this string rootDirectory, string path) { - string subPath = path[rootDirectory.Length..].ToUpperInvariant().BeautifyPath(); - return subPath.Contains("SETUP") || subPath.Contains("REDIST") || subPath.Contains("SUPPORT") + string subPath = path[rootDirectory.Length..].ResolvePath(); + return subPath is null || subPath.Contains("SETUP") || subPath.Contains("REDIST") || subPath.Contains("SUPPORT") || subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT")) || subPath.Contains("HELPER") || subPath.Contains("CEFPROCESS") || subPath.Contains("ZFGAMEBROWSER") || subPath.Contains("MONO") || subPath.Contains("PLUGINS") || subPath.Contains("MODDING") || subPath.Contains("MOD") && subPath.Contains("MANAGER") || subPath.Contains("BATTLEYE") @@ -540,8 +540,8 @@ internal static class Resources { if (Program.Canceled) return null; - string subDirectory = directory.BeautifyPath(); - if (dllDirectories.Contains(subDirectory)) + string subDirectory = directory.ResolvePath(); + if (subDirectory is null || dllDirectories.Contains(subDirectory)) continue; bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll)) .Any(pair => pair.path.FileExists() && pair.path.IsResourceFile()); diff --git a/CreamInstaller/Selection.cs b/CreamInstaller/Selection.cs index 0b8a9aa..c921db0 100644 --- a/CreamInstaller/Selection.cs +++ b/CreamInstaller/Selection.cs @@ -103,8 +103,7 @@ internal sealed class Selection : IEquatable } } - public bool Equals(Selection other) - => other is not null && (ReferenceEquals(this, other) || Id == other.Id && Platform == other.Platform && RootDirectory == other.RootDirectory); + public bool Equals(Selection other) => other is not null && (ReferenceEquals(this, other) || Id == other.Id && Platform == other.Platform); internal static Selection GetOrCreate(Platform platform, string id, string name, string rootDirectory, HashSet dllDirectories, List<(string directory, BinaryType binaryType)> executableDirectories) @@ -150,5 +149,5 @@ internal sealed class Selection : IEquatable public override bool Equals(object obj) => ReferenceEquals(this, obj) || obj is Selection other && Equals(other); - public override int GetHashCode() => HashCode.Combine(Id, (int)Platform, RootDirectory); + public override int GetHashCode() => HashCode.Combine(Id, (int)Platform); } \ No newline at end of file diff --git a/CreamInstaller/Utility/Diagnostics.cs b/CreamInstaller/Utility/Diagnostics.cs index 35a9a89..38203e2 100644 --- a/CreamInstaller/Utility/Diagnostics.cs +++ b/CreamInstaller/Utility/Diagnostics.cs @@ -42,5 +42,15 @@ internal static class Diagnostics internal static void OpenUrlInInternetBrowser(string url) => Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true }); - internal static string BeautifyPath(this string path) => path is null ? null : Path.TrimEndingDirectorySeparator(Path.GetFullPath(path)).ToLowerInvariant(); -} + internal static string ResolvePath(this string path) + { + if (path is null || !path.FileExists() && !path.DirectoryExists()) + return null; + DirectoryInfo info = new(path); + if (info.Parent is null) + return info.Name.ToUpperInvariant(); + string parent = ResolvePath(info.Parent.FullName); + string name = info.Parent.GetFileSystemInfos(info.Name)[0].Name; + return parent is null ? name : Path.Combine(parent, name); + } +} \ No newline at end of file diff --git a/CreamInstaller/Utility/SafeIO.cs b/CreamInstaller/Utility/SafeIO.cs index 49395eb..e60e59a 100644 --- a/CreamInstaller/Utility/SafeIO.cs +++ b/CreamInstaller/Utility/SafeIO.cs @@ -251,7 +251,7 @@ internal static class SafeIO private static DialogResult IOWarnInternal(this string filePath, string message, Exception e, Form form = null) { using DialogForm dialogForm = new(form); - string description = message + ": " + filePath.BeautifyPath() + "\n\n"; + string description = message + ": " + filePath.ResolvePath() + "\n\n"; if (e is IOException && (e.HResult & 0x0000FFFF) == 225) // virus or potentially unwanted software description += "Please resolve your anti-virus and press retry to continue . . . "; else diff --git a/preview.png b/preview.png index 5273640..1296f67 100644 Binary files a/preview.png and b/preview.png differ