From 2bdf9c9d77f89ba41b676e12f5fcc154adb40db1 Mon Sep 17 00:00:00 2001 From: pointfeev Date: Wed, 14 Sep 2022 17:39:35 -0400 Subject: [PATCH] v4.1.3.0 - Koaloader proxy selection will no longer provide options for DLLs that already exist in the game's directories - Installation will now error when a DLL that already exists is attempting to be installed as Koaloader - Fixed selections not being re-enabled after an installation failure when hitting the Reselect button --- CreamInstaller/Components/CustomTreeView.cs | 24 +++++++++++++++------ CreamInstaller/CreamInstaller.csproj | 4 +++- CreamInstaller/Forms/InstallForm.cs | 18 +++++++++++----- CreamInstaller/Resources/Koaloader.cs | 2 ++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/CreamInstaller/Components/CustomTreeView.cs b/CreamInstaller/Components/CustomTreeView.cs index 28a037b..bec04e8 100644 --- a/CreamInstaller/Components/CustomTreeView.cs +++ b/CreamInstaller/Components/CustomTreeView.cs @@ -4,6 +4,7 @@ using CreamInstaller.Utility; using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Linq; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; @@ -223,13 +224,24 @@ internal class CustomTreeView : TreeView comboBoxDropDown.Items.Clear(); foreach (string proxy in proxies) { - _ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (s, e) => + bool canUse = true; + foreach ((string directory, BinaryType binaryType) in pair.Key.ExecutableDirectories) { - pair.Key.KoaloaderProxy = proxy; - ProgramData.UpdateKoaloaderProxyChoices(); - Invalidate(); - }) - { Font = comboBoxFont }); + string path = directory + @"\" + proxy + ".dll"; + if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader)) + { + canUse = false; + break; + } + } + if (canUse) + _ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (s, e) => + { + pair.Key.KoaloaderProxy = proxy; + ProgramData.UpdateKoaloaderProxyChoices(); + Invalidate(); + }) + { Font = comboBoxFont }); } comboBoxDropDown.Show(this, PointToScreen(new(pair.Value.Left, pair.Value.Bottom - 1))); invalidate = true; diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 97dc9f3..881fb7b 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 4.1.2.0 + 4.1.3.0 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) @@ -25,6 +25,8 @@ False True latest-all + CreamInstaller + Automatic DLC Unlocker Installer & Configuration Generator embedded diff --git a/CreamInstaller/Forms/InstallForm.cs b/CreamInstaller/Forms/InstallForm.cs index e746fff..fd6d48f 100644 --- a/CreamInstaller/Forms/InstallForm.cs +++ b/CreamInstaller/Forms/InstallForm.cs @@ -175,12 +175,13 @@ internal partial class InstallForm : CustomForm UpdateProgress(100); } + private readonly List DisabledSelections = new(); + private async Task Operate() { List programSelections = ProgramSelection.AllEnabled; OperationsCount = programSelections.Count; CompleteOperationsCount = 0; - List disabledSelections = new(); foreach (ProgramSelection selection in programSelections) { if (Program.Canceled || !Program.IsProgramRunningDialog(this, selection)) throw new CustomMessageException("The operation was canceled."); @@ -189,7 +190,7 @@ internal partial class InstallForm : CustomForm await OperateFor(selection); UpdateUser($"Operation succeeded for {selection.Name}.", InstallationLog.Success); selection.Enabled = false; - disabledSelections.Add(selection); + DisabledSelections.Add(selection); } catch (Exception exception) { @@ -200,9 +201,13 @@ internal partial class InstallForm : CustomForm Program.Cleanup(); List FailedSelections = ProgramSelection.AllEnabled; if (FailedSelections.Any()) - if (FailedSelections.Count == 1) throw new CustomMessageException($"Operation failed for {FailedSelections.First().Name}."); - else throw new CustomMessageException($"Operation failed for {FailedSelections.Count} programs."); - foreach (ProgramSelection selection in disabledSelections) selection.Enabled = true; + if (FailedSelections.Count == 1) + throw new CustomMessageException($"Operation failed for {FailedSelections.First().Name}."); + else + throw new CustomMessageException($"Operation failed for {FailedSelections.Count} programs."); + foreach (ProgramSelection selection in DisabledSelections) + selection.Enabled = true; + DisabledSelections.Clear(); } private readonly int ProgramCount = ProgramSelection.AllEnabled.Count; @@ -265,6 +270,9 @@ internal partial class InstallForm : CustomForm { Program.Cleanup(); Reselecting = true; + foreach (ProgramSelection selection in DisabledSelections) + selection.Enabled = true; + DisabledSelections.Clear(); Close(); } } diff --git a/CreamInstaller/Resources/Koaloader.cs b/CreamInstaller/Resources/Koaloader.cs index 8087d9e..3b8aa7e 100644 --- a/CreamInstaller/Resources/Koaloader.cs +++ b/CreamInstaller/Resources/Koaloader.cs @@ -164,6 +164,8 @@ internal static class Koaloader if (installForm is not null) installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", InstallationLog.Action, info: false); } + if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader)) + throw new CustomMessageException("A non-Koaloader DLL named " + selection.KoaloaderProxy + ".dll already exists in this directory!"); path.WriteProxy(selection.KoaloaderProxy, binaryType); if (installForm is not null) installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", InstallationLog.Action, info: false);