- Improved the responsiveness and performance of the program
- Fixed the changelog tree view garbling when clicking update
- Dialog forms no longer clutter the taskbar
- Added a debug form (this is really just for me)
- Fixed rescan lag caused by keeping nodes
- Minor refactoring
This commit is contained in:
pointfeev 2022-09-20 00:55:24 -04:00
parent 89f42ed35d
commit 1998bdef9b
24 changed files with 532 additions and 274 deletions

View file

@ -1,22 +1,55 @@
using System.Drawing; using System;
using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
namespace CreamInstaller.Components; namespace CreamInstaller.Components;
internal class CustomForm : Form internal class CustomForm : Form
{ {
internal CustomForm() : base() => Icon = Properties.Resources.Icon; internal CustomForm() : base()
internal CustomForm(IWin32Window owner) : this()
{ {
Owner = (owner as Form) ?? ActiveForm; Icon = Properties.Resources.Icon;
KeyPreview = true; KeyPreview = true;
KeyPress += OnKeyPress; KeyPress += OnKeyPress;
ResizeRedraw = true; ResizeRedraw = true;
} }
internal CustomForm(IWin32Window owner) : this()
{
if (owner is Form form)
{
Owner = form;
InheritLocation(form);
SizeChanged += (s, e) => InheritLocation(form);
form.Activated += OnActivation;
FormClosing += (s, e) => form.Activated -= OnActivation;
}
}
internal void OnActivation(object sender, EventArgs args) => Activate();
public static readonly IntPtr HWND_NOTOPMOST = new(-2);
public static readonly IntPtr HWND_TOPMOST = new(-1);
public const short SWP_NOACTIVATE = 0x0010;
public const short SWP_SHOWWINDOW = 0x0040;
public const short SWP_NOMOVE = 0x0002;
public const short SWP_NOSIZE = 0x0001;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern void SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
internal void BringToFrontWithoutActivation()
{
bool topMost = TopMost;
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
if (!topMost)
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
}
protected override CreateParams CreateParams // Double buffering for all controls protected override CreateParams CreateParams // Double buffering for all controls
{ {
get get
@ -29,6 +62,8 @@ internal class CustomForm : Form
internal void InheritLocation(Form fromForm) internal void InheritLocation(Form fromForm)
{ {
if (fromForm is null)
return;
int X = fromForm.Location.X + fromForm.Size.Width / 2 - Size.Width / 2; int X = fromForm.Location.X + fromForm.Size.Width / 2 - Size.Width / 2;
int Y = fromForm.Location.Y + fromForm.Size.Height / 2 - Size.Height / 2; int Y = fromForm.Location.Y + fromForm.Size.Height / 2 - Size.Height / 2;
Location = new(X, Y); Location = new(X, Y);

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>4.1.3.1</Version> <Version>4.1.4.0</Version>
<PackageIcon>Resources\ini.ico</PackageIcon> <PackageIcon>Resources\ini.ico</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>

View file

@ -0,0 +1,69 @@
namespace CreamInstaller;
partial class DebugForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.debugTextBox = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// debugTextBox
//
this.debugTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.debugTextBox.Location = new System.Drawing.Point(10, 10);
this.debugTextBox.Name = "debugTextBox";
this.debugTextBox.ReadOnly = true;
this.debugTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth;
this.debugTextBox.Size = new System.Drawing.Size(544, 321);
this.debugTextBox.TabIndex = 0;
this.debugTextBox.TabStop = false;
this.debugTextBox.Text = "";
//
// DebugForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(564, 341);
this.ControlBox = false;
this.Controls.Add(this.debugTextBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DebugForm";
this.Padding = new System.Windows.Forms.Padding(10);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Debug";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox debugTextBox;
}

View file

@ -0,0 +1,84 @@
using CreamInstaller.Components;
using CreamInstaller.Utility;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace CreamInstaller;
internal partial class DebugForm : CustomForm
{
internal static DebugForm current;
internal static DebugForm Current
{
get
{
if (current is not null && (current.Disposing || current.IsDisposed))
current = null;
return current ??= new();
}
set => current = value;
}
internal DebugForm()
{
InitializeComponent();
debugTextBox.BackColor = LogTextBox.Background;
}
protected override void WndProc(ref Message message) // make form immovable by user
{
if (message.Msg == 0x0112) // WM_SYSCOMMAND
{
int command = message.WParam.ToInt32() & 0xFFF0;
if (command == 0xF010) // SC_MOVE
return;
}
base.WndProc(ref message);
}
private Form attachedForm;
internal void Attach(Form form)
{
if (attachedForm is not null)
{
attachedForm.Activated -= OnChange;
attachedForm.LocationChanged -= OnChange;
attachedForm.SizeChanged -= OnChange;
}
attachedForm = form;
attachedForm.Activated += OnChange;
attachedForm.LocationChanged += OnChange;
attachedForm.SizeChanged += OnChange;
UpdateAttachment();
}
internal void OnChange(object sender, EventArgs args) => UpdateAttachment();
internal void UpdateAttachment()
{
if (attachedForm is null)
return;
Size = new(Size.Width, attachedForm.Size.Height);
Location = new(attachedForm.Right, attachedForm.Top);
Show();
BringToFrontWithoutActivation();
}
internal void Log(string text) => Log(text, LogTextBox.Error);
internal void Log(string text, Color color)
{
if (!debugTextBox.Disposing && !debugTextBox.IsDisposed)
{
debugTextBox.Invoke(() =>
{
if (debugTextBox.Text.Length > 0)
debugTextBox.AppendText(Environment.NewLine, color, scroll: true);
debugTextBox.AppendText(text, color, scroll: true);
});
}
}
}

View file

@ -0,0 +1,63 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View file

@ -125,6 +125,7 @@ namespace CreamInstaller
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "DialogForm"; this.Name = "DialogForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "DialogForm"; this.Text = "DialogForm";
((System.ComponentModel.ISupportInitialize)(this.icon)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.icon)).EndInit();

View file

@ -8,7 +8,11 @@ namespace CreamInstaller;
internal partial class DialogForm : CustomForm internal partial class DialogForm : CustomForm
{ {
internal DialogForm(IWin32Window owner) : base(owner) => InitializeComponent(); internal DialogForm(IWin32Window owner) : base(owner)
{
InitializeComponent();
TopLevel = true;
}
internal DialogResult Show(Icon descriptionIcon, string descriptionText, string acceptButtonText = "OK", string cancelButtonText = null, string customFormText = null, Icon customFormIcon = null) internal DialogResult Show(Icon descriptionIcon, string descriptionText, string acceptButtonText = "OK", string cancelButtonText = null, string customFormText = null, Icon customFormIcon = null)
{ {

View file

@ -136,7 +136,7 @@ namespace CreamInstaller
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "InstallForm"; this.Name = "InstallForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "InstallForm"; this.Text = "InstallForm";
this.Load += new System.EventHandler(this.OnLoad); this.Load += new System.EventHandler(this.OnLoad);
this.ResumeLayout(false); this.ResumeLayout(false);

View file

@ -9,7 +9,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
using static CreamInstaller.Paradox.ParadoxLauncher; using static CreamInstaller.Paradox.ParadoxLauncher;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
@ -21,11 +20,11 @@ internal partial class InstallForm : CustomForm
internal bool Reselecting; internal bool Reselecting;
internal readonly bool Uninstalling; internal readonly bool Uninstalling;
internal InstallForm(IWin32Window owner, bool uninstall = false) : base(owner) internal InstallForm(bool uninstall = false) : base()
{ {
InitializeComponent(); InitializeComponent();
Text = Program.ApplicationName; Text = Program.ApplicationName;
logTextBox.BackColor = InstallationLog.Background; logTextBox.BackColor = LogTextBox.Background;
Uninstalling = uninstall; Uninstalling = uninstall;
} }
@ -62,46 +61,51 @@ internal partial class InstallForm : CustomForm
UpdateProgress(0); UpdateProgress(0);
if (selection.Id == "PL") if (selection.Id == "PL")
{ {
UpdateUser($"Repairing Paradox Launcher . . . ", InstallationLog.Operation); UpdateUser($"Repairing Paradox Launcher . . . ", LogTextBox.Operation);
_ = await Repair(this, selection); _ = await Repair(this, selection);
} }
UpdateUser($"Checking directories for {selection.Name} . . . ", InstallationLog.Operation); UpdateUser($"Checking directories for {selection.Name} . . . ", LogTextBox.Operation);
IEnumerable<string> invalidDirectories = (await selection.RootDirectory.GetExecutables()) IEnumerable<string> invalidDirectories = (await selection.RootDirectory.GetExecutables())
.Where(d => !selection.ExecutableDirectories.Any(s => d.path.Contains(s.directory))) ?.Where(d => !selection.ExecutableDirectories.Any(s => d.path.Contains(s.directory)))
.Select(d => Path.GetDirectoryName(d.path)); ?.Select(d => Path.GetDirectoryName(d.path));
if (!selection.ExecutableDirectories.Any(s => s.directory == selection.RootDirectory)) if (!selection.ExecutableDirectories.Any(s => s.directory == selection.RootDirectory))
invalidDirectories = invalidDirectories.Append(selection.RootDirectory); invalidDirectories = invalidDirectories?.Append(selection.RootDirectory);
invalidDirectories = invalidDirectories.Distinct(); invalidDirectories = invalidDirectories?.Distinct();
foreach (string directory in invalidDirectories) if (invalidDirectories is not null)
{ foreach (string directory in invalidDirectories)
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|| Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll))
|| File.Exists(config))
{
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", InstallationLog.Operation);
await Koaloader.Uninstall(directory, this);
}
Thread.Sleep(0);
}
if (Uninstalling || !selection.Koaloader)
{
foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories)
{ {
if (Program.Canceled) throw new CustomMessageException("The operation was canceled.");
directory.GetKoaloaderComponents(out List<string> proxies, out string config); directory.GetKoaloaderComponents(out List<string> proxies, out string config);
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader)) if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|| Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll)) || Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll))
|| File.Exists(config)) || File.Exists(config))
{ {
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in incorrect directory \"{directory}\" . . . ", LogTextBox.Operation);
await Koaloader.Uninstall(directory, this); await Koaloader.Uninstall(directory, this);
} }
Thread.Sleep(1);
}
if (Uninstalling || !selection.Koaloader)
{
foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories)
{
if (Program.Canceled) throw new CustomMessageException("The operation was canceled.");
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(ResourceIdentifier.Koaloader))
|| Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll))
|| File.Exists(config))
{
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
await Koaloader.Uninstall(directory, this);
}
Thread.Sleep(1);
} }
} }
bool uninstallProxy = Uninstalling || selection.Koaloader; bool uninstallProxy = Uninstalling || selection.Koaloader;
int count = selection.DllDirectories.Count, cur = 0; int count = selection.DllDirectories.Count, cur = 0;
foreach (string directory in selection.DllDirectories) foreach (string directory in selection.DllDirectories)
{ {
if (Program.Canceled) throw new CustomMessageException("The operation was canceled.");
if (selection.Platform is Platform.Steam or Platform.Paradox if (selection.Platform is Platform.Steam or Platform.Paradox
&& (selection.SelectedDlc.Any(d => d.Value.type is DlcType.Steam or DlcType.SteamHidden) && (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)))) || selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.Steam or DlcType.SteamHidden))))
@ -112,7 +116,7 @@ internal partial class InstallForm : CustomForm
|| !selection.Koaloader && (File.Exists(config) || File.Exists(cache)))) || !selection.Koaloader && (File.Exists(config) || File.Exists(cache))))
{ {
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} SmokeAPI" + UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} SmokeAPI" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); $" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallProxy)
await SmokeAPI.Uninstall(directory, this); await SmokeAPI.Uninstall(directory, this);
else else
@ -129,7 +133,7 @@ internal partial class InstallForm : CustomForm
|| !selection.Koaloader && File.Exists(config))) || !selection.Koaloader && File.Exists(config)))
{ {
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} ScreamAPI" + UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} ScreamAPI" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); $" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallProxy)
await ScreamAPI.Uninstall(directory, this); await ScreamAPI.Uninstall(directory, this);
else else
@ -144,7 +148,7 @@ internal partial class InstallForm : CustomForm
|| !selection.Koaloader && File.Exists(config))) || !selection.Koaloader && File.Exists(config)))
{ {
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" + UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); $" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallProxy)
await UplayR1.Uninstall(directory, this); await UplayR1.Uninstall(directory, this);
else else
@ -156,7 +160,7 @@ internal partial class InstallForm : CustomForm
|| !selection.Koaloader && File.Exists(config))) || !selection.Koaloader && File.Exists(config)))
{ {
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" + UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); $" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallProxy)
await UplayR2.Uninstall(directory, this); await UplayR2.Uninstall(directory, this);
else else
@ -164,13 +168,16 @@ internal partial class InstallForm : CustomForm
} }
} }
UpdateProgress(++cur / count * 100); UpdateProgress(++cur / count * 100);
Thread.Sleep(1);
} }
if (selection.Koaloader && !Uninstalling) if (selection.Koaloader && !Uninstalling)
{ {
foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories) foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories)
{ {
UpdateUser("Installing Koaloader to " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); 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, this);
Thread.Sleep(1);
} }
} }
UpdateProgress(100); UpdateProgress(100);
@ -189,13 +196,13 @@ internal partial class InstallForm : CustomForm
try try
{ {
await OperateFor(selection); await OperateFor(selection);
UpdateUser($"Operation succeeded for {selection.Name}.", InstallationLog.Success); UpdateUser($"Operation succeeded for {selection.Name}.", LogTextBox.Success);
selection.Enabled = false; selection.Enabled = false;
DisabledSelections.Add(selection); DisabledSelections.Add(selection);
} }
catch (Exception exception) catch (Exception exception)
{ {
UpdateUser($"Operation failed for {selection.Name}: " + exception, InstallationLog.Error); UpdateUser($"Operation failed for {selection.Name}: " + exception, LogTextBox.Error);
} }
++CompleteOperationsCount; ++CompleteOperationsCount;
} }
@ -224,11 +231,11 @@ internal partial class InstallForm : CustomForm
try try
{ {
await Operate(); await Operate();
UpdateUser($"DLC unlocker(s) successfully {(Uninstalling ? "uninstalled" : "installed and generated")} for " + ProgramCount + " program(s).", InstallationLog.Success); UpdateUser($"DLC unlocker(s) successfully {(Uninstalling ? "uninstalled" : "installed and generated")} for " + ProgramCount + " program(s).", LogTextBox.Success);
} }
catch (Exception exception) catch (Exception exception)
{ {
UpdateUser($"DLC unlocker {(Uninstalling ? "uninstallation" : "installation and/or generation")} failed: " + exception, InstallationLog.Error); UpdateUser($"DLC unlocker {(Uninstalling ? "uninstallation" : "installation and/or generation")} failed: " + exception, LogTextBox.Error);
retryButton.Enabled = true; retryButton.Enabled = true;
} }
userProgressBar.Value = userProgressBar.Maximum; userProgressBar.Value = userProgressBar.Maximum;

View file

@ -37,10 +37,16 @@ internal partial class MainForm : CustomForm
cancellationTokenSource.Dispose(); cancellationTokenSource.Dispose();
cancellationTokenSource = null; cancellationTokenSource = null;
} }
#pragma warning disable CA2000 // Dispose objects before losing scope
SelectForm form = new();
#pragma warning restore CA2000 // Dispose objects before losing scope
form.InheritLocation(this);
form.FormClosing += (s, e) => Close();
form.Show();
Hide(); Hide();
using SelectForm form = new(this); #if DEBUG
_ = form.ShowDialog(); DebugForm.Current.Attach(form);
Close(); #endif
} }
private UpdateManager updateManager; private UpdateManager updateManager;
@ -56,8 +62,10 @@ internal partial class MainForm : CustomForm
progressLabel.Text = "Checking for updates . . ."; progressLabel.Text = "Checking for updates . . .";
changelogTreeView.Visible = false; changelogTreeView.Visible = false;
changelogTreeView.Location = new(progressLabel.Location.X, progressLabel.Location.Y + progressLabel.Size.Height + 13); changelogTreeView.Location = new(progressLabel.Location.X, progressLabel.Location.Y + progressLabel.Size.Height + 13);
Invalidate(); Refresh();
#if DEBUG
DebugForm.Current.Attach(this);
#endif
GithubPackageResolver resolver = new("pointfeev", "CreamInstaller", "CreamInstaller.zip"); GithubPackageResolver resolver = new("pointfeev", "CreamInstaller", "CreamInstaller.zip");
ZipPackageExtractor extractor = new(); ZipPackageExtractor extractor = new();
updateManager = new(AssemblyMetadata.FromAssembly(Program.EntryAssembly, Program.CurrentProcessFilePath), resolver, extractor); updateManager = new(AssemblyMetadata.FromAssembly(Program.EntryAssembly, Program.CurrentProcessFilePath), resolver, extractor);
@ -72,16 +80,17 @@ internal partial class MainForm : CustomForm
if (checkForUpdatesResult.CanUpdate) if (checkForUpdatesResult.CanUpdate)
{ {
#endif #endif
latestVersion = checkForUpdatesResult.LastVersion; latestVersion = checkForUpdatesResult.LastVersion;
versions = checkForUpdatesResult.Versions; versions = checkForUpdatesResult.Versions;
#if !DEBUG #if !DEBUG
} }
#endif #endif
} }
#if DEBUG #if DEBUG
catch (TaskCanceledException) { }
catch (Exception e) catch (Exception e)
{ {
e.HandleException(form: this, caption: "Debug exception", acceptButtonText: "OK", cancelButtonText: null); DebugForm.Current.Log($"Exception while checking for updates: {e.GetType()} ({e.Message})", LogTextBox.Warning);
} }
#else #else
catch { } catch { }
@ -124,10 +133,12 @@ internal partial class MainForm : CustomForm
HtmlNodeCollection nodes = await HttpClientManager.GetDocumentNodes( HtmlNodeCollection nodes = await HttpClientManager.GetDocumentNodes(
$"https://github.com/pointfeev/CreamInstaller/releases/tag/v{version}", $"https://github.com/pointfeev/CreamInstaller/releases/tag/v{version}",
"//div[@data-test-selector='body-content']/ul/li"); "//div[@data-test-selector='body-content']/ul/li");
if (nodes is null) changelogTreeView.Nodes.Remove(root); if (nodes is null)
else foreach (HtmlNode node in nodes) changelogTreeView.Nodes.Remove(root);
else
foreach (HtmlNode node in nodes)
{ {
Program.Invoke(changelogTreeView, delegate changelogTreeView.Invoke(delegate
{ {
TreeNode change = new() TreeNode change = new()
{ {
@ -181,7 +192,7 @@ internal partial class MainForm : CustomForm
updateButton.Click -= OnUpdate; updateButton.Click -= OnUpdate;
updateButton.Click += new(OnUpdateCancel); updateButton.Click += new(OnUpdateCancel);
changelogTreeView.Location = new(progressBar.Location.X, progressBar.Location.Y + progressBar.Size.Height + 6); changelogTreeView.Location = new(progressBar.Location.X, progressBar.Location.Y + progressBar.Size.Height + 6);
Invalidate(); Refresh();
Progress<double> progress = new(); Progress<double> progress = new();
progress.ProgressChanged += new(delegate (object sender, double _progress) progress.ProgressChanged += new(delegate (object sender, double _progress)
@ -197,9 +208,10 @@ internal partial class MainForm : CustomForm
await updateManager.PrepareUpdateAsync(latestVersion, progress, cancellationTokenSource.Token); await updateManager.PrepareUpdateAsync(latestVersion, progress, cancellationTokenSource.Token);
} }
#if DEBUG #if DEBUG
catch (TaskCanceledException) { }
catch (Exception ex) catch (Exception ex)
{ {
ex.HandleException(form: this, caption: "Debug exception", acceptButtonText: "OK", cancelButtonText: null); DebugForm.Current.Log($"Exception while preparing update: {ex.GetType()} ({ex.Message})", LogTextBox.Warning);
} }
#else #else
catch { } catch { }

View file

@ -185,7 +185,8 @@ namespace CreamInstaller
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "SelectDialogForm"; this.Name = "SelectDialogForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "SelectDialogForm"; this.Text = "SelectDialogForm";
this.groupBox.ResumeLayout(false); this.groupBox.ResumeLayout(false);
this.groupBox.PerformLayout(); this.groupBox.PerformLayout();

View file

@ -12,7 +12,11 @@ namespace CreamInstaller;
internal partial class SelectDialogForm : CustomForm internal partial class SelectDialogForm : CustomForm
{ {
internal SelectDialogForm(IWin32Window owner) : base(owner) => InitializeComponent(); internal SelectDialogForm(IWin32Window owner) : base(owner)
{
InitializeComponent();
TopLevel = true;
}
private readonly List<(Platform platform, string id, string name)> selected = new(); private readonly List<(Platform platform, string id, string name)> selected = new();
internal List<(Platform platform, string id, string name)> QueryUser(string groupBoxText, List<(Platform platform, string id, string name, bool alreadySelected)> choices) internal List<(Platform platform, string id, string name)> QueryUser(string groupBoxText, List<(Platform platform, string id, string name, bool alreadySelected)> choices)

View file

@ -321,7 +321,7 @@ namespace CreamInstaller
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "SelectForm"; this.Name = "SelectForm";
this.StartPosition = FormStartPosition.CenterParent; this.StartPosition = FormStartPosition.Manual;
this.Text = "SelectForm"; this.Text = "SelectForm";
this.Load += this.OnLoad; this.Load += this.OnLoad;
this.programsGroupBox.ResumeLayout(false); this.programsGroupBox.ResumeLayout(false);

View file

@ -27,7 +27,7 @@ namespace CreamInstaller;
internal partial class SelectForm : CustomForm internal partial class SelectForm : CustomForm
{ {
internal SelectForm(IWin32Window owner) : base(owner) internal SelectForm() : base()
{ {
InitializeComponent(); InitializeComponent();
Text = Program.ApplicationName; Text = Program.ApplicationName;
@ -43,7 +43,7 @@ internal partial class SelectForm : CustomForm
private void AddToRemainingGames(string gameName) private void AddToRemainingGames(string gameName)
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(progressLabelGames, delegate progressLabelGames.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
if (!RemainingGames.Contains(gameName)) if (!RemainingGames.Contains(gameName))
@ -54,7 +54,7 @@ internal partial class SelectForm : CustomForm
private void RemoveFromRemainingGames(string gameName) private void RemoveFromRemainingGames(string gameName)
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(progressLabelGames, delegate progressLabelGames.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
RemainingGames.Remove(gameName); RemainingGames.Remove(gameName);
@ -67,7 +67,7 @@ internal partial class SelectForm : CustomForm
private void AddToRemainingDLCs(string dlcId) private void AddToRemainingDLCs(string dlcId)
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(progressLabelDLCs, delegate progressLabelDLCs.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
if (!RemainingDLCs.Contains(dlcId)) if (!RemainingDLCs.Contains(dlcId))
@ -78,7 +78,7 @@ internal partial class SelectForm : CustomForm
private void RemoveFromRemainingDLCs(string dlcId) private void RemoveFromRemainingDLCs(string dlcId)
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(progressLabelDLCs, delegate progressLabelDLCs.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
RemainingDLCs.Remove(dlcId); RemainingDLCs.Remove(dlcId);
@ -128,8 +128,8 @@ internal partial class SelectForm : CustomForm
programNode.Name = selection.Id; programNode.Name = selection.Id;
programNode.Text = selection.Name; programNode.Text = selection.Name;
programNode.Checked = selection.Enabled; programNode.Checked = selection.Enabled;
programNode.Remove(); if (programNode.TreeView is null)
_ = selectionTreeView.Nodes.Add(programNode); _ = selectionTreeView.Nodes.Add(programNode);
} }
} }
int steamGamesToCheck; int steamGamesToCheck;
@ -244,7 +244,7 @@ internal partial class SelectForm : CustomForm
selection.WebsiteUrl = appData?.website; selection.WebsiteUrl = appData?.website;
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(selectionTreeView, delegate selectionTreeView.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Steam && s.Name == appId) ?? new(); TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Steam && s.Name == appId) ?? new();
@ -252,8 +252,8 @@ internal partial class SelectForm : CustomForm
programNode.Name = appId; programNode.Name = appId;
programNode.Text = appData?.name ?? name; programNode.Text = appData?.name ?? name;
programNode.Checked = selection.Enabled; programNode.Checked = selection.Enabled;
programNode.Remove(); if (programNode.TreeView is null)
_ = selectionTreeView.Nodes.Add(programNode); _ = selectionTreeView.Nodes.Add(programNode);
foreach (KeyValuePair<string, (DlcType type, string name, string icon)> pair in dlc) foreach (KeyValuePair<string, (DlcType type, string name, string icon)> pair in dlc)
{ {
if (Program.Canceled || programNode is null) return; if (Program.Canceled || programNode is null) return;
@ -266,8 +266,8 @@ internal partial class SelectForm : CustomForm
dlcNode.Name = appId; dlcNode.Name = appId;
dlcNode.Text = dlcApp.name; dlcNode.Text = dlcApp.name;
dlcNode.Checked = selection.SelectedDlc.ContainsKey(appId); dlcNode.Checked = selection.SelectedDlc.ContainsKey(appId);
dlcNode.Remove(); if (dlcNode.Parent is null)
_ = programNode.Nodes.Add(dlcNode); _ = programNode.Nodes.Add(dlcNode);
} }
}); });
if (Program.Canceled) return; if (Program.Canceled) return;
@ -344,7 +344,7 @@ internal partial class SelectForm : CustomForm
} }
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(selectionTreeView, delegate selectionTreeView.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Epic && s.Name == @namespace) ?? new(); TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Epic && s.Name == @namespace) ?? new();
@ -352,15 +352,15 @@ internal partial class SelectForm : CustomForm
programNode.Name = @namespace; programNode.Name = @namespace;
programNode.Text = name; programNode.Text = name;
programNode.Checked = selection.Enabled; programNode.Checked = selection.Enabled;
programNode.Remove(); if (programNode.TreeView is null)
_ = selectionTreeView.Nodes.Add(programNode); _ = selectionTreeView.Nodes.Add(programNode);
/*TreeNode catalogItemsNode = treeNodes.Find(s => s.Tag is Platform.Epic && s.Name == @namespace + "_catalogItems") ?? new(); /*TreeNode catalogItemsNode = treeNodes.Find(s => s.Tag is Platform.Epic && s.Name == @namespace + "_catalogItems") ?? new();
catalogItemsNode.Tag = selection.Platform; catalogItemsNode.Tag = selection.Platform;
catalogItemsNode.Name = @namespace + "_catalogItems"; catalogItemsNode.Name = @namespace + "_catalogItems";
catalogItemsNode.Text = "Catalog Items"; catalogItemsNode.Text = "Catalog Items";
catalogItemsNode.Checked = selection.SelectedDlc.Any(pair => pair.Value.type == DlcType.CatalogItem); catalogItemsNode.Checked = selection.SelectedDlc.Any(pair => pair.Value.type == DlcType.CatalogItem);
catalogItemsNode.Remove(); if (catalogItemsNode.Parent is null)
programNode.Nodes.Add(catalogItemsNode);*/ programNode.Nodes.Add(catalogItemsNode);*/
if (entitlements.Any()) if (entitlements.Any())
{ {
/*TreeNode entitlementsNode = treeNodes.Find(s => s.Tag is Platform.Epic && s.Name == @namespace + "_entitlements") ?? new(); /*TreeNode entitlementsNode = treeNodes.Find(s => s.Tag is Platform.Epic && s.Name == @namespace + "_entitlements") ?? new();
@ -368,8 +368,8 @@ internal partial class SelectForm : CustomForm
entitlementsNode.Name = @namespace + "_entitlements"; entitlementsNode.Name = @namespace + "_entitlements";
entitlementsNode.Text = "Entitlements"; entitlementsNode.Text = "Entitlements";
entitlementsNode.Checked = selection.SelectedDlc.Any(pair => pair.Value.type == DlcType.Entitlement); entitlementsNode.Checked = selection.SelectedDlc.Any(pair => pair.Value.type == DlcType.Entitlement);
entitlementsNode.Remove(); if (entitlementsNode.Parent is null)
programNode.Nodes.Add(entitlementsNode);*/ programNode.Nodes.Add(entitlementsNode);*/
foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in entitlements) foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in entitlements)
{ {
if (programNode is null/* || entitlementsNode is null*/) return; if (programNode is null/* || entitlementsNode is null*/) return;
@ -382,8 +382,8 @@ internal partial class SelectForm : CustomForm
dlcNode.Name = dlcId; dlcNode.Name = dlcId;
dlcNode.Text = dlcApp.name; dlcNode.Text = dlcApp.name;
dlcNode.Checked = selection.SelectedDlc.ContainsKey(dlcId); dlcNode.Checked = selection.SelectedDlc.ContainsKey(dlcId);
dlcNode.Remove(); if (dlcNode.Parent is null)
_ = programNode.Nodes.Add(dlcNode); //entitlementsNode.Nodes.Add(dlcNode); _ = programNode.Nodes.Add(dlcNode); //entitlementsNode.Nodes.Add(dlcNode);
} }
} }
}); });
@ -423,7 +423,7 @@ internal partial class SelectForm : CustomForm
selection.Platform = Platform.Ubisoft; selection.Platform = Platform.Ubisoft;
selection.IconUrl = IconGrabber.GetDomainFaviconUrl("store.ubi.com"); selection.IconUrl = IconGrabber.GetDomainFaviconUrl("store.ubi.com");
Program.Invoke(selectionTreeView, delegate selectionTreeView.Invoke(delegate
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Ubisoft && s.Name == gameId) ?? new(); TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Ubisoft && s.Name == gameId) ?? new();
@ -431,8 +431,8 @@ internal partial class SelectForm : CustomForm
programNode.Name = gameId; programNode.Name = gameId;
programNode.Text = name; programNode.Text = name;
programNode.Checked = selection.Enabled; programNode.Checked = selection.Enabled;
programNode.Remove(); if (programNode.TreeView is null)
_ = selectionTreeView.Nodes.Add(programNode); _ = selectionTreeView.Nodes.Add(programNode);
}); });
if (Program.Canceled) return; if (Program.Canceled) return;
RemoveFromRemainingGames(name); RemoveFromRemainingGames(name);
@ -524,14 +524,15 @@ internal partial class SelectForm : CustomForm
setup = false; setup = false;
progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . "; progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . ";
ProgramSelection.ValidateAll(ProgramsToScan); ProgramSelection.ValidateAll(ProgramsToScan);
TreeNodes.ForEach(node => /*TreeNodes.ForEach(node =>
{ {
if (node.Tag is not Platform platform if (node.Tag is not Platform platform
|| node.Name is not string platformId || node.Name is not string platformId
|| ProgramSelection.FromPlatformId(platform, platformId) is null || ProgramSelection.FromPlatformId(platform, platformId) is null
&& ProgramSelection.GetDlcFromPlatformId(platform, platformId) is null) && ProgramSelection.GetDlcFromPlatformId(platform, platformId) is null)
node.Remove(); node.Remove();
}); });*/
TreeNodes.ForEach(node => node.Remove()); // nodes cause lots of lag during rescan for now
await GetApplicablePrograms(iProgress); await GetApplicablePrograms(iProgress);
await SteamCMD.Cleanup(); await SteamCMD.Cleanup();
} }
@ -835,15 +836,28 @@ internal partial class SelectForm : CustomForm
if (!Program.IsProgramRunningDialog(this, selection)) return; if (!Program.IsProgramRunningDialog(this, selection)) return;
if (!uninstall && ParadoxLauncher.DlcDialog(this)) return; if (!uninstall && ParadoxLauncher.DlcDialog(this)) return;
Hide(); Hide();
using InstallForm installForm = new(this, uninstall); #pragma warning disable CA2000 // Dispose objects before losing scope
_ = installForm.ShowDialog(); InstallForm form = new(uninstall);
if (installForm.Reselecting) #pragma warning restore CA2000 // Dispose objects before losing scope
form.InheritLocation(this);
form.FormClosing += (s, e) =>
{ {
InheritLocation(installForm); if (form.Reselecting)
Show(); {
OnLoad(); InheritLocation(form);
} Show();
else Close(); #if DEBUG
DebugForm.Current.Attach(this);
#endif
OnLoad();
}
else Close();
};
form.Show();
Hide();
#if DEBUG
DebugForm.Current.Attach(form);
#endif
} }
} }

View file

@ -120,14 +120,14 @@ internal static class ParadoxLauncher
{ {
steamOriginalSdk32.Write(api32); steamOriginalSdk32.Write(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Corrected Steamworks: " + api32, InstallationLog.Action); installForm.UpdateUser("Corrected Steamworks: " + api32, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (steamOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.Steamworks64)) if (steamOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.Steamworks64))
{ {
steamOriginalSdk64.Write(api64); steamOriginalSdk64.Write(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Corrected Steamworks: " + api64, InstallationLog.Action); installForm.UpdateUser("Corrected Steamworks: " + api64, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (!selection.Koaloader && smokeConfig) if (!selection.Koaloader && smokeConfig)
@ -138,14 +138,14 @@ internal static class ParadoxLauncher
{ {
epicOriginalSdk32.Write(api32); epicOriginalSdk32.Write(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Corrected Epic Online Services: " + api32, InstallationLog.Action); installForm.UpdateUser("Corrected Epic Online Services: " + api32, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (epicOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64)) if (epicOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
{ {
epicOriginalSdk64.Write(api64); epicOriginalSdk64.Write(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Corrected Epic Online Services: " + api64, InstallationLog.Action); installForm.UpdateUser("Corrected Epic Online Services: " + api64, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (!selection.Koaloader && screamConfig) if (!selection.Koaloader && screamConfig)
@ -154,7 +154,7 @@ internal static class ParadoxLauncher
if (neededRepair) if (neededRepair)
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Paradox Launcher successfully repaired!", InstallationLog.Success); installForm.UpdateUser("Paradox Launcher successfully repaired!", LogTextBox.Success);
else else
_ = dialogForm.Show(form.Icon, "Paradox Launcher successfully repaired!", "OK", customFormText: "Paradox Launcher"); _ = dialogForm.Show(form.Icon, "Paradox Launcher successfully repaired!", "OK", customFormText: "Paradox Launcher");
return RepairResult.Success; return RepairResult.Success;
@ -162,7 +162,7 @@ internal static class ParadoxLauncher
else else
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Paradox Launcher did not need to be repaired.", InstallationLog.Success); installForm.UpdateUser("Paradox Launcher did not need to be repaired.", LogTextBox.Success);
else else
_ = dialogForm.Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK", customFormText: "Paradox Launcher"); _ = dialogForm.Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK", customFormText: "Paradox Launcher");
return RepairResult.Unnecessary; return RepairResult.Unnecessary;

View file

@ -74,6 +74,9 @@ internal static class Program
{ {
HttpClientManager.Setup(); HttpClientManager.Setup();
using MainForm form = new(); using MainForm form = new();
#if DEBUG
DebugForm.Current.Attach(form);
#endif
Application.Run(form); Application.Run(form);
} }
catch (Exception e) catch (Exception e)
@ -86,8 +89,6 @@ internal static class Program
mutex.Close(); mutex.Close();
} }
internal static void Invoke(this Control control, MethodInvoker methodInvoker) => control.Invoke(methodInvoker);
internal static bool Canceled; internal static bool Canceled;
internal static async void Cleanup(bool cancel = true) internal static async void Cleanup(bool cancel = true)
{ {

View file

@ -68,7 +68,7 @@ internal static class Koaloader
if (targets.Any() || modules.Any()) if (targets.Any() || modules.Any())
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); installForm.UpdateUser("Generating Koaloader configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, targets, modules, installForm); WriteConfig(writer, targets, modules, installForm);
@ -79,7 +79,7 @@ internal static class Koaloader
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -98,7 +98,7 @@ internal static class Koaloader
string path = pair.Value; string path = pair.Value;
writer.WriteLine($" \"{path}\"{(pair.Equals(lastTarget) ? "" : ",")}"); writer.WriteLine($" \"{path}\"{(pair.Equals(lastTarget) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added target to Koaloader.json with path {path}", InstallationLog.Action, info: false); installForm.UpdateUser($"Added target to Koaloader.json with path {path}", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -116,7 +116,7 @@ internal static class Koaloader
writer.WriteLine($" \"required\": true"); writer.WriteLine($" \"required\": true");
writer.WriteLine(" }" + (pair.Equals(lastModule) ? "" : ",")); writer.WriteLine(" }" + (pair.Equals(lastModule) ? "" : ","));
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added module to Koaloader.json with path {path}", InstallationLog.Action, info: false); installForm.UpdateUser($"Added module to Koaloader.json with path {path}", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -132,7 +132,7 @@ internal static class Koaloader
{ {
File.Delete(proxyPath); File.Delete(proxyPath);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxyPath)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxyPath)}", LogTextBox.Action, info: false);
} }
foreach ((string unlocker, string path) in AutoLoadDlls foreach ((string unlocker, string path) in AutoLoadDlls
.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll)) .Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
@ -140,13 +140,13 @@ internal static class Koaloader
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
await SmokeAPI.Uninstall(directory, installForm, deleteConfig); await SmokeAPI.Uninstall(directory, installForm, deleteConfig);
await ScreamAPI.Uninstall(directory, installForm, deleteConfig); await ScreamAPI.Uninstall(directory, installForm, deleteConfig);
@ -162,13 +162,13 @@ internal static class Koaloader
{ {
File.Delete(_path); File.Delete(_path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, info: false);
} }
if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader)) if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader))
throw new CustomMessageException("A non-Koaloader DLL named " + selection.KoaloaderProxy + ".dll already exists in this directory!"); throw new CustomMessageException("A non-Koaloader DLL named " + selection.KoaloaderProxy + ".dll already exists in this directory!");
path.WriteProxy(selection.KoaloaderProxy, binaryType); path.WriteProxy(selection.KoaloaderProxy, binaryType);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
bool bit32 = false, bit64 = false; bool bit32 = false, bit64 = false;
foreach (string executable in Directory.EnumerateFiles(directory, "*.exe")) foreach (string executable in Directory.EnumerateFiles(directory, "*.exe"))
if (executable.TryGetFileBinaryType(out BinaryType binaryType)) if (executable.TryGetFileBinaryType(out BinaryType binaryType))
@ -187,14 +187,14 @@ internal static class Koaloader
path = directory + @"\SmokeAPI32.dll"; path = directory + @"\SmokeAPI32.dll";
"SmokeAPI.steam_api.dll".Write(path); "SmokeAPI.steam_api.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\SmokeAPI64.dll"; path = directory + @"\SmokeAPI64.dll";
"SmokeAPI.steam_api64.dll".Write(path); "SmokeAPI.steam_api64.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
SmokeAPI.CheckConfig(directory, selection, installForm); SmokeAPI.CheckConfig(directory, selection, installForm);
} }
@ -205,14 +205,14 @@ internal static class Koaloader
path = directory + @"\ScreamAPI32.dll"; path = directory + @"\ScreamAPI32.dll";
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\ScreamAPI64.dll"; path = directory + @"\ScreamAPI64.dll";
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
ScreamAPI.CheckConfig(directory, selection, installForm); ScreamAPI.CheckConfig(directory, selection, installForm);
} }
@ -223,14 +223,14 @@ internal static class Koaloader
path = directory + @"\UplayR1Unlocker32.dll"; path = directory + @"\UplayR1Unlocker32.dll";
"UplayR1.uplay_r1_loader.dll".Write(path); "UplayR1.uplay_r1_loader.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\UplayR1Unlocker64.dll"; path = directory + @"\UplayR1Unlocker64.dll";
"UplayR1.uplay_r1_loader64.dll".Write(path); "UplayR1.uplay_r1_loader64.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
UplayR1.CheckConfig(directory, selection, installForm); UplayR1.CheckConfig(directory, selection, installForm);
if (bit32) if (bit32)
@ -238,14 +238,14 @@ internal static class Koaloader
path = directory + @"\UplayR2Unlocker32.dll"; path = directory + @"\UplayR2Unlocker32.dll";
"UplayR2.upc_r2_loader.dll".Write(path); "UplayR2.upc_r2_loader.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
path = directory + @"\UplayR2Unlocker64.dll"; path = directory + @"\UplayR2Unlocker64.dll";
"UplayR2.upc_r2_loader64.dll".Write(path); "UplayR2.upc_r2_loader64.dll".Write(path);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
UplayR2.CheckConfig(directory, selection, installForm); UplayR2.CheckConfig(directory, selection, installForm);
} }

View file

@ -78,36 +78,35 @@ internal static class Resources
internal static bool TryGetFileBinaryType(this string path, out BinaryType binaryType) => GetBinaryType(path, out binaryType); internal static bool TryGetFileBinaryType(this string path, out BinaryType binaryType) => GetBinaryType(path, out binaryType);
internal static async Task<List<(string directory, BinaryType binaryType)>> GetExecutableDirectories(this string rootDirectory, bool filterCommon = false, Func<string, bool> validFunc = null) => internal static async Task<List<(string directory, BinaryType binaryType)>> GetExecutableDirectories(this string rootDirectory, bool filterCommon = false, Func<string, bool> validFunc = null) =>
await Task.Run(async () => (await rootDirectory.GetExecutables(filterCommon: filterCommon, validFunc: validFunc) ?? await rootDirectory.GetExecutables()).Select(e => await Task.Run(async () => (await rootDirectory.GetExecutables(filterCommon: filterCommon, validFunc: validFunc) ?? await rootDirectory.GetExecutables())?.Select(e =>
{ {
e.path = Path.GetDirectoryName(e.path); e.path = Path.GetDirectoryName(e.path);
return e; return e;
}).DistinctBy(e => e.path).ToList()); })?.DistinctBy(e => e.path).ToList());
internal static async Task<List<(string path, BinaryType binaryType)>> GetExecutables(this string rootDirectory, bool filterCommon = false, Func<string, bool> validFunc = null) => await Task.Run(() => internal static async Task<List<(string path, BinaryType binaryType)>> GetExecutables(this string rootDirectory, bool filterCommon = false, Func<string, bool> validFunc = null) => await Task.Run(() =>
{ {
List<(string path, BinaryType binaryType)> executables = new(); List<(string path, BinaryType binaryType)> executables = new();
if (Program.Canceled || !Directory.Exists(rootDirectory)) return null; if (Program.Canceled || !Directory.Exists(rootDirectory)) return null;
List<string> files = new(Directory.EnumerateFiles(rootDirectory, "*.exe", new EnumerationOptions() { RecurseSubdirectories = true })); foreach (string path in Directory.EnumerateFiles(rootDirectory, "*.exe", new EnumerationOptions() { RecurseSubdirectories = true }))
foreach (string path in files)
{ {
if (Program.Canceled) return null; if (Program.Canceled) return null;
Thread.Sleep(0);
if (!executables.Any(e => e.path == path) if (!executables.Any(e => e.path == path)
&& (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path)) && (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path))
&& (validFunc is null || validFunc(path)) && (validFunc is null || validFunc(path))
&& path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT64) && path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT64)
executables.Add((path, binaryType)); executables.Add((path, binaryType));
Thread.Sleep(1);
} }
foreach (string path in files) foreach (string path in Directory.EnumerateFiles(rootDirectory, "*.exe", new EnumerationOptions() { RecurseSubdirectories = true }))
{ {
if (Program.Canceled) return null; if (Program.Canceled) return null;
Thread.Sleep(0);
if (!executables.Any(e => e.path == path) if (!executables.Any(e => e.path == path)
&& (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path)) && (!filterCommon || !rootDirectory.IsCommonIncorrectExecutable(path))
&& (validFunc is null || validFunc(path)) && (validFunc is null || validFunc(path))
&& path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT32) && path.TryGetFileBinaryType(out BinaryType binaryType) && binaryType is BinaryType.BIT32)
executables.Add((path, binaryType)); executables.Add((path, binaryType));
Thread.Sleep(1);
} }
return !executables.Any() ? null : executables; return !executables.Any() ? null : executables;
}); });
@ -115,7 +114,7 @@ internal static class Resources
internal static bool IsCommonIncorrectExecutable(this string rootDirectory, string path) internal static bool IsCommonIncorrectExecutable(this string rootDirectory, string path)
{ {
string subPath = path[rootDirectory.Length..].ToUpperInvariant().BeautifyPath(); string subPath = path[rootDirectory.Length..].ToUpperInvariant().BeautifyPath();
return subPath.Contains("SETUP") || subPath.Contains("REDIST") return subPath.Contains("SETUP") || subPath.Contains("REDIST") //|| subPath.Contains("SUPPORT")
|| subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT")); || subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT"));
} }
@ -123,52 +122,55 @@ internal static class Resources
{ {
List<string> dllDirectories = new(); List<string> dllDirectories = new();
if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; if (Program.Canceled || !Directory.Exists(gameDirectory)) return null;
foreach (string subDirectory in new List<string>(Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true })) { gameDirectory }) foreach (string directory in Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true }).Append(gameDirectory))
{ {
if (Program.Canceled) return null; if (Program.Canceled) return null;
Thread.Sleep(0); string subDirectory = directory.BeautifyPath();
if (platform is Platform.Steam or Platform.Paradox) if (!dllDirectories.Contains(subDirectory))
{ {
subDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string config, out string cache); if (platform is Platform.Steam or Platform.Paradox)
if (File.Exists(api) {
|| File.Exists(api_o) subDirectory.GetSmokeApiComponents(out string api, out string api_o, out string api64, out string api64_o, out string config, out string cache);
|| File.Exists(api64) if (File.Exists(api)
|| File.Exists(api64_o) || File.Exists(api_o)
|| File.Exists(config) || File.Exists(api64)
|| File.Exists(cache)) || File.Exists(api64_o)
dllDirectories.Add(subDirectory.BeautifyPath()); || File.Exists(config)
} || File.Exists(cache))
if (platform is Platform.Epic or Platform.Paradox) dllDirectories.Add(subDirectory);
{ }
subDirectory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config); if (platform is Platform.Epic or Platform.Paradox)
if (File.Exists(api32) {
|| File.Exists(api32_o) subDirectory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
|| File.Exists(api64) if (File.Exists(api32)
|| File.Exists(api64_o) || File.Exists(api32_o)
|| File.Exists(config)) || File.Exists(api64)
dllDirectories.Add(subDirectory.BeautifyPath()); || File.Exists(api64_o)
} || File.Exists(config))
if (platform is Platform.Ubisoft) dllDirectories.Add(subDirectory);
{ }
subDirectory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config); if (platform is Platform.Ubisoft)
if (File.Exists(api32) {
|| File.Exists(api32_o) subDirectory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
|| File.Exists(api64) if (File.Exists(api32)
|| File.Exists(api64_o) || File.Exists(api32_o)
|| File.Exists(config)) || File.Exists(api64)
dllDirectories.Add(subDirectory.BeautifyPath()); || File.Exists(api64_o)
subDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config); || File.Exists(config))
if (File.Exists(old_api32) dllDirectories.Add(subDirectory);
|| File.Exists(old_api64) subDirectory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config);
|| File.Exists(api32) if (File.Exists(old_api32)
|| File.Exists(api32_o) || File.Exists(old_api64)
|| File.Exists(api64) || File.Exists(api32)
|| File.Exists(api64_o) || File.Exists(api32_o)
|| File.Exists(config)) || File.Exists(api64)
dllDirectories.Add(subDirectory.BeautifyPath()); || File.Exists(api64_o)
|| File.Exists(config))
dllDirectories.Add(subDirectory);
}
} }
} }
return !dllDirectories.Any() ? null : new List<string>(dllDirectories.Distinct()); return !dllDirectories.Any() ? null : dllDirectories;
}); });
internal static void GetCreamApiComponents( internal static void GetCreamApiComponents(

View file

@ -37,7 +37,7 @@ internal static class ScreamAPI
if (overrideCatalogItems.Any() || entitlements.Any()) if (overrideCatalogItems.Any() || entitlements.Any())
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, WriteConfig(writer,
@ -51,7 +51,7 @@ internal static class ScreamAPI
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -74,7 +74,7 @@ internal static class ScreamAPI
(_, string name, _) = pair.Value; (_, string name, _) = pair.Value;
writer.WriteLine($" \"{id}\"{(pair.Equals(lastOverrideCatalogItem) ? "" : ",")}"); writer.WriteLine($" \"{id}\"{(pair.Equals(lastOverrideCatalogItem) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added override catalog item to ScreamAPI.json with id {id} ({name})", InstallationLog.Action, info: false); installForm.UpdateUser($"Added override catalog item to ScreamAPI.json with id {id} ({name})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -94,7 +94,7 @@ internal static class ScreamAPI
(_, string name, _) = pair.Value; (_, string name, _) = pair.Value;
writer.WriteLine($" \"{id}\"{(pair.Equals(lastEntitlement) ? "" : ",")}"); writer.WriteLine($" \"{id}\"{(pair.Equals(lastEntitlement) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added entitlement to ScreamAPI.json with id {id} ({name})", InstallationLog.Action, info: false); installForm.UpdateUser($"Added entitlement to ScreamAPI.json with id {id} ({name})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -113,11 +113,11 @@ internal static class ScreamAPI
{ {
File.Delete(api32); File.Delete(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Epic Online Services: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Epic Online Services: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
@ -125,17 +125,17 @@ internal static class ScreamAPI
{ {
File.Delete(api64); File.Delete(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Epic Online Services: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Epic Online Services: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
}); });
@ -146,25 +146,25 @@ internal static class ScreamAPI
{ {
File.Move(api32, api32_o); File.Move(api32, api32_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Epic Online Services: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Epic Online Services: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(api32); "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64) && !File.Exists(api64_o)) if (File.Exists(api64) && !File.Exists(api64_o))
{ {
File.Move(api64, api64_o); File.Move(api64, api64_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Epic Online Services: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Epic Online Services: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(api64); "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -43,7 +43,7 @@ internal static class SmokeAPI
if (overrideDlc.Any() || injectDlc.Any()) if (overrideDlc.Any() || injectDlc.Any())
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, WriteConfig(writer,
@ -57,7 +57,7 @@ internal static class SmokeAPI
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -78,7 +78,7 @@ internal static class SmokeAPI
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastOverrideDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastOverrideDlc) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added override DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false); installForm.UpdateUser($"Added override DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -94,7 +94,7 @@ internal static class SmokeAPI
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastInjectDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastInjectDlc) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added inject DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false); installForm.UpdateUser($"Added inject DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -114,11 +114,11 @@ internal static class SmokeAPI
{ {
File.Delete(api32); File.Delete(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
@ -126,23 +126,23 @@ internal static class SmokeAPI
{ {
File.Delete(api64); File.Delete(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(cache)) if (deleteConfig && File.Exists(cache))
{ {
File.Delete(cache); File.Delete(cache);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", LogTextBox.Action, info: false);
} }
}); });
@ -153,32 +153,32 @@ internal static class SmokeAPI
{ {
File.Delete(oldConfig); File.Delete(oldConfig);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, info: false);
} }
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out _); directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out _);
if (File.Exists(api32) && !File.Exists(api32_o)) if (File.Exists(api32) && !File.Exists(api32_o))
{ {
File.Move(api32, api32_o); File.Move(api32, api32_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"SmokeAPI.steam_api.dll".Write(api32); "SmokeAPI.steam_api.dll".Write(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64) && !File.Exists(api64_o)) if (File.Exists(api64) && !File.Exists(api64_o))
{ {
File.Move(api64, api64_o); File.Move(api64, api64_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"SmokeAPI.steam_api64.dll".Write(api64); "SmokeAPI.steam_api64.dll".Write(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -34,7 +34,7 @@ internal static class UplayR1
if (blacklistDlc.Any()) if (blacklistDlc.Any())
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); installForm.UpdateUser("Generating Uplay R1 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm); WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
@ -45,7 +45,7 @@ internal static class UplayR1
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -65,7 +65,7 @@ internal static class UplayR1
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added blacklist DLC to UplayR1Unlocker.jsonc with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false); installForm.UpdateUser($"Added blacklist DLC to UplayR1Unlocker.jsonc with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -83,11 +83,11 @@ internal static class UplayR1
{ {
File.Delete(api32); File.Delete(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
@ -95,17 +95,17 @@ internal static class UplayR1
{ {
File.Delete(api64); File.Delete(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
}); });
@ -116,25 +116,25 @@ internal static class UplayR1
{ {
File.Move(api32, api32_o); File.Move(api32, api32_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"UplayR1.uplay_r1_loader.dll".Write(api32); "UplayR1.uplay_r1_loader.dll".Write(api32);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64) && !File.Exists(api64_o)) if (File.Exists(api64) && !File.Exists(api64_o))
{ {
File.Move(api64, api64_o); File.Move(api64, api64_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"UplayR1.uplay_r1_loader64.dll".Write(api64); "UplayR1.uplay_r1_loader64.dll".Write(api64);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -36,7 +36,7 @@ internal static class UplayR2
if (blacklistDlc.Any()) if (blacklistDlc.Any())
{ {
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); installForm.UpdateUser("Generating Uplay R2 Unlocker configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
File.Create(config).Close(); File.Create(config).Close();
StreamWriter writer = new(config, true, Encoding.UTF8); StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm); WriteConfig(writer, new(blacklistDlc.ToDictionary(pair => pair.Key, pair => pair.Value), PlatformIdComparer.String), installForm);
@ -47,7 +47,7 @@ internal static class UplayR2
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -69,7 +69,7 @@ internal static class UplayR2
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}");
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Added blacklist DLC to UplayR2Unlocker.jsonc with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false); installForm.UpdateUser($"Added blacklist DLC to UplayR2Unlocker.jsonc with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -88,11 +88,11 @@ internal static class UplayR2
{ {
File.Delete(api); File.Delete(api);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api); File.Move(api32_o, api);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
@ -101,17 +101,17 @@ internal static class UplayR2
{ {
File.Delete(api); File.Delete(api);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api); File.Move(api64_o, api);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
}); });
@ -123,26 +123,26 @@ internal static class UplayR2
{ {
File.Move(api, api32_o); File.Move(api, api32_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"UplayR2.upc_r2_loader.dll".Write(api); "UplayR2.upc_r2_loader.dll".Write(api);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
api = File.Exists(old_api64) ? old_api64 : api64; api = File.Exists(old_api64) ? old_api64 : api64;
if (File.Exists(api) && !File.Exists(api64_o)) if (File.Exists(api) && !File.Exists(api64_o))
{ {
File.Move(api, api64_o); File.Move(api, api64_o);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"UplayR2.upc_r2_loader64.dll".Write(api); "UplayR2.upc_r2_loader64.dll".Write(api);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", InstallationLog.Action, info: false); installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -10,8 +10,6 @@ using System.Threading.Tasks;
#if DEBUG #if DEBUG
using System; using System;
using System.Drawing;
using System.Windows.Forms;
#endif #endif
namespace CreamInstaller.Steam; namespace CreamInstaller.Steam;
@ -54,11 +52,7 @@ internal static class SteamStore
if (!appDetails.success) if (!appDetails.success)
{ {
#if DEBUG #if DEBUG
Form.ActiveForm.Invoke(() => DebugForm.Current.Log($"Query unsuccessful for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}", LogTextBox.Warning);
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Query unsuccessful for appid: " + appId + $"\nisDlc: {isDlc}\ndata is null: {data is null}\n\n" + app.Value.ToString());
});
#endif #endif
if (data is null) if (data is null)
return null; return null;
@ -73,11 +67,7 @@ internal static class SteamStore
#if DEBUG #if DEBUG
(Exception e) (Exception e)
{ {
Form.ActiveForm.Invoke(() => DebugForm.Current.Log($"Unsuccessful serialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString());
});
} }
#else #else
{ } { }
@ -85,36 +75,18 @@ internal static class SteamStore
return data; return data;
} }
#if DEBUG #if DEBUG
else else DebugForm.Current.Log($"Response data null for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}");
{
Form.ActiveForm.Invoke(() =>
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Response data null for appid: " + appId + "\n\n" + app.Value.ToString());
});
}
#endif #endif
} }
#if DEBUG #if DEBUG
else else DebugForm.Current.Log($"Response details null for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}");
{
Form.ActiveForm.Invoke(() =>
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Response details null for appid: " + appId + "\n\n" + app.Value.ToString());
});
}
#endif #endif
} }
catch catch
#if DEBUG #if DEBUG
(Exception e) (Exception e)
{ {
Form.ActiveForm.Invoke(() => DebugForm.Current.Log($"Unsuccessful deserialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString());
});
} }
#else #else
{ } { }
@ -122,25 +94,11 @@ internal static class SteamStore
} }
} }
#if DEBUG #if DEBUG
else else DebugForm.Current.Log("Response deserialization null for appid " + appId);
{
Form.ActiveForm.Invoke(() =>
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Response deserialization null for appid: " + appId);
});
}
#endif #endif
} }
#if DEBUG #if DEBUG
else else DebugForm.Current.Log("Response null for appid " + appId, LogTextBox.Warning);
{
Form.ActiveForm.Invoke(() =>
{
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Response null for appid: " + appId);
});
}
#endif #endif
} }
if (cachedExists) if (cachedExists)

View file

@ -3,7 +3,7 @@ using System.Windows.Forms;
namespace CreamInstaller.Utility; namespace CreamInstaller.Utility;
internal static class InstallationLog internal static class LogTextBox
{ {
internal static readonly Color Background = Color.DarkSlateGray; internal static readonly Color Background = Color.DarkSlateGray;
internal static readonly Color Operation = Color.LightGray; internal static readonly Color Operation = Color.LightGray;
@ -13,12 +13,15 @@ internal static class InstallationLog
internal static readonly Color Warning = Color.Yellow; internal static readonly Color Warning = Color.Yellow;
internal static readonly Color Error = Color.DarkOrange; internal static readonly Color Error = Color.DarkOrange;
internal static void AppendText(this RichTextBox logTextBox, string text, Color color) internal static void AppendText(this RichTextBox textBox, string text, Color color, bool scroll = false)
{ {
logTextBox.SelectionStart = logTextBox.TextLength; textBox.SelectionStart = textBox.TextLength;
logTextBox.SelectionLength = 0; textBox.SelectionLength = 0;
logTextBox.SelectionColor = color; textBox.SelectionColor = color;
logTextBox.AppendText(text); if (scroll) textBox.ScrollToCaret();
logTextBox.SelectionColor = logTextBox.ForeColor; textBox.AppendText(text);
if (scroll) textBox.ScrollToCaret();
textBox.SelectionColor = textBox.ForeColor;
textBox.Invalidate();
} }
} }