From 10bd823d2b2089d399a633e957633f92c71ac62a Mon Sep 17 00:00:00 2001 From: pointfeev Date: Sat, 8 Oct 2022 05:01:38 -0400 Subject: [PATCH] v4.2.3.0 - Koaloader autoload DLLs are now placed in the root game/program directory - Installation/uninstallation output clarifications - Minor refactoring --- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Forms/InstallForm.cs | 11 +-- CreamInstaller/Forms/SelectForm.cs | 1 - CreamInstaller/Resources/Koaloader.cs | 116 ++++++++++++++++++++++---- CreamInstaller/Resources/ScreamAPI.cs | 4 +- CreamInstaller/Resources/SmokeAPI.cs | 4 +- CreamInstaller/Resources/UplayR1.cs | 4 +- CreamInstaller/Resources/UplayR2.cs | 4 +- 8 files changed, 114 insertions(+), 32 deletions(-) diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 3dd1530..df6d567 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -4,7 +4,7 @@ net6.0-windows10.0.22621.0 True Resources\ini.ico - 4.2.2.0 + 4.2.3.0 2021, pointfeev (https://github.com/pointfeev) CreamInstaller Automatic DLC Unlocker Installer & Configuration Generator diff --git a/CreamInstaller/Forms/InstallForm.cs b/CreamInstaller/Forms/InstallForm.cs index 3c227a1..5e3b8a3 100644 --- a/CreamInstaller/Forms/InstallForm.cs +++ b/CreamInstaller/Forms/InstallForm.cs @@ -64,7 +64,8 @@ internal partial class InstallForm : CustomForm UpdateUser($"Repairing Paradox Launcher . . . ", LogTextBox.Operation); _ = await Repair(this, selection); } - UpdateUser($"Checking directories for {selection.Name} . . . ", LogTextBox.Operation); + UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")}" + + $" {(Uninstalling ? "from" : "for")} " + selection.Name + $" with root directory \"{selection.RootDirectory}\" . . . ", LogTextBox.Operation); IEnumerable invalidDirectories = (await selection.RootDirectory.GetExecutables()) ?.Where(d => !selection.ExecutableDirectories.Any(s => s.directory == Path.GetDirectoryName(d.path))) ?.Select(d => Path.GetDirectoryName(d.path)); @@ -77,11 +78,11 @@ internal partial class InstallForm : CustomForm if (Program.Canceled) throw new CustomMessageException("The operation was canceled."); directory.GetKoaloaderComponents(out List proxies, out string config); if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader)) - || Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll)) + || directory != selection.RootDirectory && Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll)) || File.Exists(config)) { UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", LogTextBox.Operation); - await Koaloader.Uninstall(directory, this); + await Koaloader.Uninstall(directory, rootDirectory: selection.RootDirectory, this); } Thread.Sleep(1); } @@ -96,7 +97,7 @@ internal partial class InstallForm : CustomForm || File.Exists(config)) { UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); - await Koaloader.Uninstall(directory, this); + await Koaloader.Uninstall(directory, rootDirectory: selection.RootDirectory, this); } Thread.Sleep(1); } @@ -164,7 +165,7 @@ internal partial class InstallForm : CustomForm { if (Program.Canceled) throw new CustomMessageException("The operation was canceled."); UpdateUser("Installing Koaloader to " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); - await Koaloader.Install(directory, binaryType, selection, this); + await Koaloader.Install(directory, binaryType, selection, rootDirectory: selection.RootDirectory, this); Thread.Sleep(1); } } diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 8011511..49766e4 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -22,7 +22,6 @@ using System.Threading.Tasks; using System.Windows.Forms; using static CreamInstaller.Resources.Resources; -using static System.ComponentModel.Design.ObjectSelectorEditor; namespace CreamInstaller; diff --git a/CreamInstaller/Resources/Koaloader.cs b/CreamInstaller/Resources/Koaloader.cs index 1395bef..42c59b8 100644 --- a/CreamInstaller/Resources/Koaloader.cs +++ b/CreamInstaller/Resources/Koaloader.cs @@ -67,8 +67,8 @@ internal static class Koaloader SortedList modules = new(PlatformIdComparer.String); if (targets.Any() || modules.Any()) { - if (installForm is not null) - installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + /*if (installForm is not null) + installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/ File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); WriteConfig(writer, targets, modules, installForm); @@ -125,10 +125,10 @@ internal static class Koaloader writer.WriteLine("}"); } - internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(async () => + internal static async Task Uninstall(string directory, string rootDirectory = null, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(async () => { directory.GetKoaloaderComponents(out List proxies, out string config); - foreach (string proxyPath in proxies.Where(proxyPath => File.Exists(proxyPath) && proxyPath.IsResourceFile(Resources.ResourceIdentifier.Koaloader))) + foreach (string proxyPath in proxies.Where(proxyPath => File.Exists(proxyPath) && proxyPath.IsResourceFile(ResourceIdentifier.Koaloader))) { File.Delete(proxyPath); if (installForm is not null) @@ -152,9 +152,11 @@ internal static class Koaloader await ScreamAPI.Uninstall(directory, installForm, deleteConfig); await UplayR1.Uninstall(directory, installForm, deleteConfig); await UplayR2.Uninstall(directory, installForm, deleteConfig); + if (rootDirectory is not null && directory != rootDirectory) + await Uninstall(rootDirectory, null, installForm, deleteConfig); }); - internal static async Task Install(string directory, BinaryType binaryType, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() => + internal static async Task Install(string directory, BinaryType binaryType, ProgramSelection selection, string rootDirectory = null, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() => { directory.GetKoaloaderComponents(out List proxies, out string config); string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy; @@ -186,69 +188,149 @@ internal static class Koaloader if (bit32) { path = directory + @"\SmokeAPI32.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\SmokeAPI32.dll"; + } "SmokeAPI.steam_api.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } if (bit64) { path = directory + @"\SmokeAPI64.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\SmokeAPI64.dll"; + } "SmokeAPI.steam_api64.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } - SmokeAPI.CheckConfig(directory, selection, installForm); + SmokeAPI.CheckConfig(rootDirectory ?? directory, selection, installForm); } if (selection.Platform is Platform.Epic or Platform.Paradox) { if (bit32) { path = directory + @"\ScreamAPI32.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\ScreamAPI32.dll"; + } "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } if (bit64) { path = directory + @"\ScreamAPI64.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\ScreamAPI64.dll"; + } "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } - ScreamAPI.CheckConfig(directory, selection, installForm); + ScreamAPI.CheckConfig(rootDirectory ?? directory, selection, installForm); } if (selection.Platform is Platform.Ubisoft) { if (bit32) { path = directory + @"\UplayR1Unlocker32.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\UplayR1Unlocker32.dll"; + } "UplayR1.uplay_r1_loader.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } if (bit64) { path = directory + @"\UplayR1Unlocker64.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\UplayR1Unlocker64.dll"; + } "UplayR1.uplay_r1_loader64.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } - UplayR1.CheckConfig(directory, selection, installForm); + UplayR1.CheckConfig(rootDirectory ?? directory, selection, installForm); if (bit32) { path = directory + @"\UplayR2Unlocker32.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\UplayR2Unlocker32.dll"; + } "UplayR2.upc_r2_loader.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } if (bit64) { path = directory + @"\UplayR2Unlocker64.dll"; + if (rootDirectory is not null && directory != rootDirectory) + { + if (File.Exists(path)) + { + File.Delete(path); + if (installForm is not null) + installForm.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + } + path = rootDirectory + @"\UplayR2Unlocker64.dll"; + } "UplayR2.upc_r2_loader64.dll".Write(path); if (installForm is not null) - installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false); + installForm.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false); } - UplayR2.CheckConfig(directory, selection, installForm); + UplayR2.CheckConfig(rootDirectory ?? directory, selection, installForm); } if (generateConfig) CheckConfig(directory, selection, installForm); diff --git a/CreamInstaller/Resources/ScreamAPI.cs b/CreamInstaller/Resources/ScreamAPI.cs index e8f24aa..1094b14 100644 --- a/CreamInstaller/Resources/ScreamAPI.cs +++ b/CreamInstaller/Resources/ScreamAPI.cs @@ -36,8 +36,8 @@ internal static class ScreamAPI 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}\" . . . ", LogTextBox.Operation); + /*if (installForm is not null) + installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/ File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); WriteConfig(writer, diff --git a/CreamInstaller/Resources/SmokeAPI.cs b/CreamInstaller/Resources/SmokeAPI.cs index 114a538..763b2ea 100644 --- a/CreamInstaller/Resources/SmokeAPI.cs +++ b/CreamInstaller/Resources/SmokeAPI.cs @@ -42,8 +42,8 @@ internal static class SmokeAPI } if (overrideDlc.Any() || injectDlc.Any()) { - if (installForm is not null) - installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + /*if (installForm is not null) + installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/ File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); WriteConfig(writer, diff --git a/CreamInstaller/Resources/UplayR1.cs b/CreamInstaller/Resources/UplayR1.cs index f0546b3..736d340 100644 --- a/CreamInstaller/Resources/UplayR1.cs +++ b/CreamInstaller/Resources/UplayR1.cs @@ -33,8 +33,8 @@ internal static class UplayR1 blacklistDlc = blacklistDlc.Except(extraDlc); if (blacklistDlc.Any()) { - if (installForm is not null) - installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + /*if (installForm is not null) + installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/ File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm); diff --git a/CreamInstaller/Resources/UplayR2.cs b/CreamInstaller/Resources/UplayR2.cs index cb104bd..1ea3204 100644 --- a/CreamInstaller/Resources/UplayR2.cs +++ b/CreamInstaller/Resources/UplayR2.cs @@ -35,8 +35,8 @@ internal static class UplayR2 blacklistDlc = blacklistDlc.Except(extraDlc); if (blacklistDlc.Any()) { - if (installForm is not null) - installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + /*if (installForm is not null) + installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/ File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);