diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 87da551..28fbde1 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 3.5.4.1 + 3.5.4.2 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) diff --git a/CreamInstaller/Epic/EpicLibrary.cs b/CreamInstaller/Epic/EpicLibrary.cs index b4b3ba8..b4adf22 100644 --- a/CreamInstaller/Epic/EpicLibrary.cs +++ b/CreamInstaller/Epic/EpicLibrary.cs @@ -53,12 +53,13 @@ internal static class EpicLibrary { List dllDirectories = new(); if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; - gameDirectory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); + gameDirectory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) - || File.Exists(config)) + || File.Exists(config) + || File.Exists(cache)) dllDirectories.Add(gameDirectory); string[] directories = Directory.GetDirectories(gameDirectory); foreach (string _directory in directories) diff --git a/CreamInstaller/Forms/InstallForm.cs b/CreamInstaller/Forms/InstallForm.cs index 9daba60..b355b30 100644 --- a/CreamInstaller/Forms/InstallForm.cs +++ b/CreamInstaller/Forms/InstallForm.cs @@ -9,10 +9,11 @@ using System.Threading.Tasks; using System.Windows.Forms; using CreamInstaller.Components; -using CreamInstaller.Paradox; using CreamInstaller.Resources; using CreamInstaller.Utility; +using static CreamInstaller.Paradox.ParadoxLauncher; + namespace CreamInstaller; internal partial class InstallForm : CustomForm @@ -103,9 +104,9 @@ internal partial class InstallForm : CustomForm writer.WriteLine("}"); } - internal static async Task UninstallSmokeAPI(string directory, InstallForm installForm = null) => await Task.Run(() => + internal static async Task UninstallSmokeAPI(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() => { - directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); + directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); if (File.Exists(sdk32_o)) { if (File.Exists(sdk32)) @@ -130,15 +131,21 @@ internal partial class InstallForm : CustomForm if (installForm is not null) installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(sdk64_o)} -> {Path.GetFileName(sdk64)}", InstallationLog.Action, info: false); } - if (File.Exists(config)) + if (deleteConfig && File.Exists(config)) { File.Delete(config); if (installForm is not null) installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); } + if (deleteConfig && File.Exists(cache)) + { + File.Delete(cache); + if (installForm is not null) + installForm.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", InstallationLog.Action, info: false); + } }); - internal static async Task InstallSmokeAPI(string directory, ProgramSelection selection, InstallForm installForm = null) => await Task.Run(() => + internal static async Task InstallSmokeAPI(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() => { directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig); if (File.Exists(oldConfig)) @@ -147,7 +154,7 @@ internal partial class InstallForm : CustomForm if (installForm is not null) installForm.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", InstallationLog.Action, info: false); } - directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); + directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out _); if (File.Exists(sdk32) && !File.Exists(sdk32_o)) { File.Move(sdk32, sdk32_o); @@ -172,35 +179,38 @@ internal partial class InstallForm : CustomForm if (installForm is not null) installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(sdk64)}", InstallationLog.Action, info: false); } - IEnumerable> overrideDlc = selection.AllDlc.Except(selection.SelectedDlc); - foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) - overrideDlc = overrideDlc.Except(extraDlc); - IEnumerable> injectDlc = new List>(); - if (selection.AllDlc.Count > 64 || selection.ExtraDlc.Any(e => e.dlc.Count > 64)) + if (generateConfig) { - injectDlc = injectDlc.Concat(selection.SelectedDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); + IEnumerable> overrideDlc = selection.AllDlc.Except(selection.SelectedDlc); foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) - if (selection.ExtraDlc.Where(e => e.id == id).Single().dlc.Count > 64) - injectDlc = injectDlc.Concat(extraDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); - } - if (overrideDlc.Any() || injectDlc.Any()) - { - if (installForm is not null) - installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); - File.Create(config).Close(); - StreamWriter writer = new(config, true, Encoding.UTF8); - WriteSmokeConfiguration(writer, - new(overrideDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), - new(injectDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), - installForm); - writer.Flush(); - writer.Close(); - } - else if (File.Exists(config)) - { - File.Delete(config); - if (installForm is not null) - installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); + overrideDlc = overrideDlc.Except(extraDlc); + IEnumerable> injectDlc = new List>(); + if (selection.AllDlc.Count > 64 || selection.ExtraDlc.Any(e => e.dlc.Count > 64)) + { + injectDlc = injectDlc.Concat(selection.SelectedDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); + foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) + if (selection.ExtraDlc.Where(e => e.id == id).Single().dlc.Count > 64) + injectDlc = injectDlc.Concat(extraDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); + } + if (overrideDlc.Any() || injectDlc.Any()) + { + if (installForm is not null) + installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); + File.Create(config).Close(); + StreamWriter writer = new(config, true, Encoding.UTF8); + WriteSmokeConfiguration(writer, + new(overrideDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + new(injectDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + installForm); + writer.Flush(); + writer.Close(); + } + else if (File.Exists(config)) + { + File.Delete(config); + if (installForm is not null) + installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); + } } }); @@ -256,9 +266,9 @@ internal partial class InstallForm : CustomForm writer.WriteLine("}"); } - internal static async Task UninstallScreamAPI(string directory, InstallForm installForm = null) => await Task.Run(() => + internal static async Task UninstallScreamAPI(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() => { - directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); + directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); if (File.Exists(sdk32_o)) { if (File.Exists(sdk32)) @@ -283,17 +293,23 @@ internal partial class InstallForm : CustomForm if (installForm is not null) installForm.UpdateUser($"Restored Epic Online Services: {Path.GetFileName(sdk64_o)} -> {Path.GetFileName(sdk64)}", InstallationLog.Action, info: false); } - if (File.Exists(config)) + if (deleteConfig && File.Exists(config)) { File.Delete(config); if (installForm is not null) installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); } + if (deleteConfig && File.Exists(cache)) + { + File.Delete(cache); + if (installForm is not null) + installForm.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", InstallationLog.Action, info: false); + } }); - internal static async Task InstallScreamAPI(string directory, ProgramSelection selection, InstallForm installForm = null) => await Task.Run(() => + internal static async Task InstallScreamAPI(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() => { - directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); + directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out _); if (File.Exists(sdk32) && !File.Exists(sdk32_o)) { File.Move(sdk32, sdk32_o); @@ -318,30 +334,33 @@ internal partial class InstallForm : CustomForm if (installForm is not null) installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(sdk64)}", InstallationLog.Action, info: false); } - IEnumerable> overrideCatalogItems = selection.AllDlc.Where(pair => pair.Value.type is DlcType.EpicCatalogItem).Except(selection.SelectedDlc); - foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) - overrideCatalogItems = overrideCatalogItems.Except(extraDlc); - IEnumerable> entitlements = selection.SelectedDlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement); - foreach ((string id, string name, SortedList _dlc) in selection.ExtraSelectedDlc) - entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement)); - if (overrideCatalogItems.Any() || entitlements.Any()) + if (generateConfig) { - if (installForm is not null) - installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); - File.Create(config).Close(); - StreamWriter writer = new(config, true, Encoding.UTF8); - WriteScreamConfiguration(writer, - new(overrideCatalogItems.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), - new(entitlements.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), - installForm); - writer.Flush(); - writer.Close(); - } - else if (File.Exists(config)) - { - File.Delete(config); - if (installForm is not null) - installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); + IEnumerable> overrideCatalogItems = selection.AllDlc.Where(pair => pair.Value.type is DlcType.EpicCatalogItem).Except(selection.SelectedDlc); + foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) + overrideCatalogItems = overrideCatalogItems.Except(extraDlc); + IEnumerable> entitlements = selection.SelectedDlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement); + foreach ((string id, string name, SortedList _dlc) in selection.ExtraSelectedDlc) + entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement)); + if (overrideCatalogItems.Any() || entitlements.Any()) + { + if (installForm is not null) + installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); + File.Create(config).Close(); + StreamWriter writer = new(config, true, Encoding.UTF8); + WriteScreamConfiguration(writer, + new(overrideCatalogItems.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + new(entitlements.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + installForm); + writer.Flush(); + writer.Close(); + } + else if (File.Exists(config)) + { + File.Delete(config); + if (installForm is not null) + installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); + } } }); @@ -350,36 +369,19 @@ internal partial class InstallForm : CustomForm UpdateProgress(0); int count = selection.DllDirectories.Count; int cur = 0; - int code = 0; if (selection.Id == "ParadoxLauncher") { UpdateUser($"Repairing Paradox Launcher . . . ", InstallationLog.Operation); - code = await ParadoxLauncher.Repair(this, selection); - switch (code) - { - case -2: - throw new CustomMessageException("Repair failed! The Paradox Launcher is currently running!"); - case -1: - throw new CustomMessageException("Repair failed! " + - "An original Steamworks/Epic Online Services SDK file could not be found. " + - "You must reinstall Paradox Launcher to fix this issue."); - case 0: - UpdateUser("Paradox Launcher does not need to be repaired.", InstallationLog.Action); - break; - case 1: - UpdateUser("Paradox Launcher successfully repaired!", InstallationLog.Success); - break; - } + await Repair(this, selection); } - if (code < 0) throw new CustomMessageException("Repair failed!"); foreach (string directory in selection.DllDirectories) { Thread.Sleep(0); if (selection.IsSteam && selection.SelectedDlc.Any(d => d.Value.type is DlcType.Steam or DlcType.SteamHidden) || selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.Steam or DlcType.SteamHidden))) { - directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); - if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config)) + directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); + if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config) || File.Exists(cache)) { UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")} SmokeAPI" + $" {(Uninstalling ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); @@ -392,8 +394,8 @@ internal partial class InstallForm : CustomForm if (selection.IsEpic && selection.SelectedDlc.Any(d => d.Value.type is DlcType.EpicCatalogItem or DlcType.EpicEntitlement) || selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.EpicCatalogItem or DlcType.EpicEntitlement))) { - directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); - if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config)) + directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); + if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config) || File.Exists(cache)) { UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")} ScreamAPI" + $" {(Uninstalling ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 62c4b46..2aafe0f 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -672,8 +672,8 @@ internal partial class SelectForm : CustomForm for (int i = 0; i < directories.Count; i++) { string directory = directories[i]; - directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); - if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config)) + directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); + if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config) || File.Exists(cache)) { contextMenuStrip.Items.Add(new ContextMenuItem($"Open Steamworks SDK Directory #{i + 1}", "File Explorer", new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory)))); @@ -683,8 +683,8 @@ internal partial class SelectForm : CustomForm for (int i = 0; i < directories.Count; i++) { string directory = directories[i]; - directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); - if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config)) + directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); + if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config) || File.Exists(cache)) { contextMenuStrip.Items.Add(new ContextMenuItem($"Open Epic Online Services SDK Directory #{i + 1}", "File Explorer", new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory)))); diff --git a/CreamInstaller/Paradox/ParadoxLauncher.cs b/CreamInstaller/Paradox/ParadoxLauncher.cs index 97a7a66..1194c16 100644 --- a/CreamInstaller/Paradox/ParadoxLauncher.cs +++ b/CreamInstaller/Paradox/ParadoxLauncher.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using CreamInstaller.Resources; +using CreamInstaller.Utility; using Microsoft.Win32; @@ -66,29 +67,39 @@ internal static class ParadoxLauncher return false; } - internal static async Task Repair(Form form, ProgramSelection selection) + public enum RepairResult { - if (!Program.IsProgramRunningDialog(form, selection)) return -2; - byte[] smokeConfig = null; + ProgramRunning = -2, + Failure, + Unnecessary = 0, + Success + } + + internal static async Task Repair(Form form, ProgramSelection selection) + { + InstallForm installForm = form as InstallForm; + if (!Program.IsProgramRunningDialog(form, selection)) + return form is InstallForm ? throw new CustomMessageException("Repair failed! The launcher is currently running!") + : RepairResult.ProgramRunning; + bool smokeConfig = false; byte[] steamOriginalSdk32 = null; byte[] steamOriginalSdk64 = null; - byte[] screamConfig = null; + bool screamConfig = false; byte[] epicOriginalSdk32 = null; byte[] epicOriginalSdk64 = null; foreach (string directory in selection.DllDirectories) { - directory.GetSmokeApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config); - if (smokeConfig is null && File.Exists(config)) - smokeConfig = File.ReadAllBytes(config); - await InstallForm.UninstallSmokeAPI(directory); + directory.GetSmokeApiComponents(out string sdk32, out _, out string sdk64, out _, out string config, out _); + smokeConfig = smokeConfig || File.Exists(config); + await InstallForm.UninstallSmokeAPI(directory, deleteConfig: false); if (steamOriginalSdk32 is null && File.Exists(sdk32) && !sdk32.IsResourceFile(ResourceIdentifier.Steamworks32)) steamOriginalSdk32 = File.ReadAllBytes(sdk32); if (steamOriginalSdk64 is null && File.Exists(sdk64) && !sdk64.IsResourceFile(ResourceIdentifier.Steamworks64)) steamOriginalSdk64 = File.ReadAllBytes(sdk64); - directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config); - if (screamConfig is null && File.Exists(config)) - screamConfig = File.ReadAllBytes(config); - await InstallForm.UninstallScreamAPI(directory); + + directory.GetScreamApiComponents(out sdk32, out _, out sdk64, out _, out config, out _); + screamConfig = screamConfig || File.Exists(config); + await InstallForm.UninstallScreamAPI(directory, deleteConfig: false); if (epicOriginalSdk32 is null && File.Exists(sdk32) && !sdk32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)) epicOriginalSdk32 = File.ReadAllBytes(sdk32); if (epicOriginalSdk64 is null && File.Exists(sdk64) && !sdk64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64)) @@ -100,57 +111,70 @@ internal static class ParadoxLauncher bool neededRepair = false; foreach (string directory in selection.DllDirectories) { - directory.GetSmokeApiComponents(out string sdk32, out string _, out string sdk64, out string _, out string config); + directory.GetSmokeApiComponents(out string sdk32, out _, out string sdk64, out _, out _, out _); if (steamOriginalSdk32 is not null && sdk32.IsResourceFile(ResourceIdentifier.Steamworks32)) { steamOriginalSdk32.Write(sdk32); + if (installForm is not null) + installForm.UpdateUser("Corrected Steamworks: " + sdk32, InstallationLog.Action); neededRepair = true; } if (steamOriginalSdk64 is not null && sdk64.IsResourceFile(ResourceIdentifier.Steamworks64)) { steamOriginalSdk64.Write(sdk64); + if (installForm is not null) + installForm.UpdateUser("Corrected Steamworks: " + sdk64, InstallationLog.Action); neededRepair = true; } - if (smokeConfig is not null) - { - await InstallForm.InstallSmokeAPI(directory, selection); - smokeConfig.Write(config); - } + if (smokeConfig) + await InstallForm.InstallSmokeAPI(directory, selection, generateConfig: false); - directory.GetScreamApiComponents(out sdk32, out string _, out sdk64, out string _, out config); + directory.GetScreamApiComponents(out sdk32, out _, out sdk64, out _, out _, out _); if (epicOriginalSdk32 is not null && sdk32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)) { epicOriginalSdk32.Write(sdk32); + if (installForm is not null) + installForm.UpdateUser("Corrected Epic Online Services: " + sdk32, InstallationLog.Action); neededRepair = true; } if (epicOriginalSdk64 is not null && sdk64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64)) { epicOriginalSdk64.Write(sdk64); + if (installForm is not null) + installForm.UpdateUser("Corrected Epic Online Services: " + sdk64, InstallationLog.Action); neededRepair = true; } - if (screamConfig is not null) - { - await InstallForm.InstallScreamAPI(directory, selection); - screamConfig.Write(config); - } + if (screamConfig) + await InstallForm.InstallScreamAPI(directory, selection, generateConfig: false); } if (neededRepair) { - if (form is not InstallForm) dialogForm.Show(form.Icon, "Paradox Launcher successfully repaired!", "OK", customFormText: "Paradox Launcher"); - return 1; + if (installForm is not null) + installForm.UpdateUser("Paradox Launcher successfully repaired!", InstallationLog.Success); + else + dialogForm.Show(form.Icon, "Paradox Launcher successfully repaired!", "OK", customFormText: "Paradox Launcher"); + return RepairResult.Success; } else { - if (form is not InstallForm) dialogForm.Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK", customFormText: "Paradox Launcher"); - return 0; + if (installForm is not null) + installForm.UpdateUser("Paradox Launcher did not need to be repaired.", InstallationLog.Success); + else + dialogForm.Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK", customFormText: "Paradox Launcher"); + return RepairResult.Unnecessary; } } else { - if (form is not InstallForm) dialogForm.Show(SystemIcons.Error, "Paradox Launcher repair failed!" - + "\n\nAn original Steamworks/Epic Online Services SDK file could not be found." - + "\nYou must reinstall Paradox Launcher to fix this issue.", "OK", customFormText: "Paradox Launcher"); - return -1; + if (form is InstallForm) + throw new CustomMessageException("Repair failed! " + + "An original Steamworks/Epic Online Services SDK file could not be found. " + + "You will likely have to reinstall Paradox Launcher to fix this issue."); + else + dialogForm.Show(SystemIcons.Error, "Paradox Launcher repair failed!" + + "\n\nAn original Steamworks/Epic Online Services SDK file could not be found." + + "\nYou will likely have to reinstall Paradox Launcher to fix this issue.", "OK", customFormText: "Paradox Launcher"); + return RepairResult.Failure; } } } diff --git a/CreamInstaller/ProgramSelection.cs b/CreamInstaller/ProgramSelection.cs index 28c69cc..93f8c42 100644 --- a/CreamInstaller/ProgramSelection.cs +++ b/CreamInstaller/ProgramSelection.cs @@ -9,10 +9,10 @@ namespace CreamInstaller; public enum DlcType { - Steam = 0, - SteamHidden = 1, - EpicCatalogItem = 2, - EpicEntitlement = 3 + Steam, + SteamHidden, + EpicCatalogItem, + EpicEntitlement } internal class ProgramSelection @@ -48,19 +48,21 @@ internal class ProgramSelection { foreach (string directory in DllDirectories) { - directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); + directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache); if (sdk32.IsFilePathLocked() || sdk32_o.IsFilePathLocked() || sdk64.IsFilePathLocked() || sdk64_o.IsFilePathLocked() - || config.IsFilePathLocked()) + || config.IsFilePathLocked() + || cache.IsFilePathLocked()) return true; - directory.GetScreamApiComponents(out sdk32, out sdk32_o, out sdk64, out sdk64_o, out config); + directory.GetScreamApiComponents(out sdk32, out sdk32_o, out sdk64, out sdk64_o, out config, out cache); if (sdk32.IsFilePathLocked() || sdk32_o.IsFilePathLocked() || sdk64.IsFilePathLocked() || sdk64_o.IsFilePathLocked() - || config.IsFilePathLocked()) + || config.IsFilePathLocked() + || cache.IsFilePathLocked()) return true; } return false; diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs index 2fc4294..611cce5 100644 --- a/CreamInstaller/Resources/Resources.cs +++ b/CreamInstaller/Resources/Resources.cs @@ -40,22 +40,24 @@ internal static class Resources config = directory + @"\cream_api.ini"; } - internal static void GetSmokeApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config) + internal static void GetSmokeApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache) { sdk32 = directory + @"\steam_api.dll"; sdk32_o = directory + @"\steam_api_o.dll"; sdk64 = directory + @"\steam_api64.dll"; sdk64_o = directory + @"\steam_api64_o.dll"; config = directory + @"\SmokeAPI.json"; + cache = directory + @"\SmokeAPI.cache.json"; } - internal static void GetScreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config) + internal static void GetScreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache) { sdk32 = directory + @"\EOSSDK-Win32-Shipping.dll"; sdk32_o = directory + @"\EOSSDK-Win32-Shipping_o.dll"; sdk64 = directory + @"\EOSSDK-Win64-Shipping.dll"; sdk64_o = directory + @"\EOSSDK-Win64-Shipping_o.dll"; config = directory + @"\ScreamAPI.json"; + cache = directory + @"\ScreamAPI.cache.json"; } public enum ResourceIdentifier @@ -110,6 +112,7 @@ internal static class Resources internal static string ComputeMD5(this string filePath) { + if (!File.Exists(filePath)) return null; #pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms using MD5 md5 = MD5.Create(); #pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms diff --git a/CreamInstaller/Steam/SteamLibrary.cs b/CreamInstaller/Steam/SteamLibrary.cs index 731fae7..ba1f1a2 100644 --- a/CreamInstaller/Steam/SteamLibrary.cs +++ b/CreamInstaller/Steam/SteamLibrary.cs @@ -47,12 +47,13 @@ internal static class SteamLibrary { List dllDirectories = new(); if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; - gameDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string cApi); + gameDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string config, out string cache); if (File.Exists(api) || File.Exists(api_o) || File.Exists(api64) || File.Exists(api64_o) - || File.Exists(cApi)) + || File.Exists(config) + || File.Exists(cache)) dllDirectories.Add(gameDirectory); string[] directories = Directory.GetDirectories(gameDirectory); foreach (string _directory in directories)