diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj
index 5ff1515..4dc65be 100644
--- a/CreamInstaller/CreamInstaller.csproj
+++ b/CreamInstaller/CreamInstaller.csproj
@@ -5,7 +5,7 @@
true
Resources\ini.ico
true
- 2.0.5.0
+ 2.1.0.0
Resources\ini.ico
Automatically generates and installs CreamAPI files for Steam games on the user's computer. It can also generate and install CreamAPI for the Paradox Launcher should the user select a Paradox Interactive game.
diff --git a/CreamInstaller/Forms/InstallForm.cs b/CreamInstaller/Forms/InstallForm.cs
index b4815b4..eda2e03 100644
--- a/CreamInstaller/Forms/InstallForm.cs
+++ b/CreamInstaller/Forms/InstallForm.cs
@@ -13,8 +13,9 @@ namespace CreamInstaller
public partial class InstallForm : Form
{
public bool Reselecting = false;
+ public bool Uninstalling = false;
- public InstallForm(IWin32Window owner)
+ public InstallForm(IWin32Window owner, bool uninstall = false)
{
Owner = owner as Form;
InitializeComponent();
@@ -22,6 +23,7 @@ namespace CreamInstaller
Text = Program.ApplicationName;
Icon = Properties.Resources.Icon;
logTextBox.BackColor = InstallationLog.Background;
+ Uninstalling = uninstall;
}
private int OperationsCount;
@@ -58,72 +60,102 @@ namespace CreamInstaller
int cur = 0;
foreach (string directory in selection.SteamApiDllDirectories)
{
- UpdateUser("Installing CreamAPI for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
+ UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")} CreamAPI for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
if (!Program.IsProgramRunningDialog(this, selection))
{
throw new OperationCanceledException();
}
-
string api = directory + @"\steam_api.dll";
string api_o = directory + @"\steam_api_o.dll";
- if (File.Exists(api) && !File.Exists(api_o))
- {
- File.Move(api, api_o);
- UpdateUser($"Renamed file: {api} -> steam_api_o.dll", InstallationLog.Resource);
- }
- if (File.Exists(api_o))
- {
- Properties.Resources.API.Write(api);
- UpdateUser($"Wrote resource to file: {api}", InstallationLog.Resource);
- }
string api64 = directory + @"\steam_api64.dll";
string api64_o = directory + @"\steam_api64_o.dll";
- if (File.Exists(api64) && !File.Exists(api64_o))
- {
- File.Move(api64, api64_o);
- UpdateUser($"Renamed file: {api64} -> steam_api64_o.dll", InstallationLog.Resource);
- }
- if (File.Exists(api64_o))
- {
- Properties.Resources.API64.Write(api64);
- UpdateUser($"Wrote resource to file: {api64}", InstallationLog.Resource);
- }
- UpdateUser("Generating CreamAPI for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
string cApi = directory + @"\cream_api.ini";
- File.Create(cApi).Close();
- StreamWriter writer = new(cApi, true, Encoding.UTF8);
- writer.WriteLine("; " + Application.CompanyName + " v" + Application.ProductVersion);
- if (selection.SteamAppId > 0)
+ if (Uninstalling)
{
- writer.WriteLine();
- writer.WriteLine($"; {selection.Name}");
- writer.WriteLine("[steam]");
- writer.WriteLine($"appid = {selection.SteamAppId}");
- writer.WriteLine();
- writer.WriteLine("[dlc]");
- UpdateUser($"Added game to cream_api.ini with appid {selection.SteamAppId} ({selection.Name})", InstallationLog.Resource);
- foreach (KeyValuePair dlcApp in selection.SelectedSteamDlc)
+ if (File.Exists(api_o))
{
- writer.WriteLine($"{dlcApp.Key} = {dlcApp.Value}");
- UpdateUser($"Added DLC to cream_api.ini with appid {dlcApp.Key} ({dlcApp.Value})", InstallationLog.Resource);
+ if (File.Exists(api))
+ {
+ File.Delete(api);
+ UpdateUser($"Deleted file: {Path.GetFileName(api)}", InstallationLog.Resource);
+ }
+ File.Move(api_o, api);
+ UpdateUser($"Renamed file: {Path.GetFileName(api_o)} -> {Path.GetFileName(api)}", InstallationLog.Resource);
+ }
+ if (File.Exists(api64_o))
+ {
+ if (File.Exists(api64))
+ {
+ File.Delete(api64);
+ UpdateUser($"Deleted file: {Path.GetFileName(api64)}", InstallationLog.Resource);
+ }
+ File.Move(api64_o, api64);
+ UpdateUser($"Renamed file: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", InstallationLog.Resource);
+ }
+ if (File.Exists(cApi))
+ {
+ File.Delete(cApi);
+ UpdateUser($"Deleted file: {Path.GetFileName(cApi)}", InstallationLog.Resource);
}
}
- foreach (Tuple> extraAppDlc in selection.ExtraSteamAppIdDlc)
+ else
{
- writer.WriteLine();
- writer.WriteLine("[steam]");
- writer.WriteLine($"appid = {extraAppDlc.Item1}");
- writer.WriteLine();
- writer.WriteLine("[dlc]");
- UpdateUser($"Added game to cream_api.ini with appid {extraAppDlc.Item1} ({extraAppDlc.Item2})", InstallationLog.Resource);
- foreach (KeyValuePair dlcApp in extraAppDlc.Item3)
+ if (File.Exists(api) && !File.Exists(api_o))
{
- writer.WriteLine($"{dlcApp.Key} = {dlcApp.Value}");
- UpdateUser($"Added DLC to cream_api.ini with appid {dlcApp.Key} ({dlcApp.Value})", InstallationLog.Resource);
+ File.Move(api, api_o);
+ UpdateUser($"Renamed file: {Path.GetFileName(api)} -> {Path.GetFileName(api_o)}", InstallationLog.Resource);
}
+ if (File.Exists(api_o))
+ {
+ Properties.Resources.API.Write(api);
+ UpdateUser($"Wrote resource to file: {Path.GetFileName(api)}", InstallationLog.Resource);
+ }
+ if (File.Exists(api64) && !File.Exists(api64_o))
+ {
+ File.Move(api64, api64_o);
+ UpdateUser($"Renamed file: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", InstallationLog.Resource);
+ }
+ if (File.Exists(api64_o))
+ {
+ Properties.Resources.API64.Write(api64);
+ UpdateUser($"Wrote resource to file: {Path.GetFileName(api64)}", InstallationLog.Resource);
+ }
+ UpdateUser("Generating CreamAPI for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
+ File.Create(cApi).Close();
+ StreamWriter writer = new(cApi, true, Encoding.UTF8);
+ writer.WriteLine("; " + Application.CompanyName + " v" + Application.ProductVersion);
+ if (selection.SteamAppId > 0)
+ {
+ writer.WriteLine();
+ writer.WriteLine($"; {selection.Name}");
+ writer.WriteLine("[steam]");
+ writer.WriteLine($"appid = {selection.SteamAppId}");
+ writer.WriteLine();
+ writer.WriteLine("[dlc]");
+ UpdateUser($"Added game to cream_api.ini with appid {selection.SteamAppId} ({selection.Name})", InstallationLog.Resource);
+ foreach (KeyValuePair dlcApp in selection.SelectedSteamDlc)
+ {
+ writer.WriteLine($"{dlcApp.Key} = {dlcApp.Value}");
+ UpdateUser($"Added DLC to cream_api.ini with appid {dlcApp.Key} ({dlcApp.Value})", InstallationLog.Resource);
+ }
+ }
+ foreach (Tuple> extraAppDlc in selection.ExtraSteamAppIdDlc)
+ {
+ writer.WriteLine();
+ writer.WriteLine("[steam]");
+ writer.WriteLine($"appid = {extraAppDlc.Item1}");
+ writer.WriteLine();
+ writer.WriteLine("[dlc]");
+ UpdateUser($"Added game to cream_api.ini with appid {extraAppDlc.Item1} ({extraAppDlc.Item2})", InstallationLog.Resource);
+ foreach (KeyValuePair dlcApp in extraAppDlc.Item3)
+ {
+ writer.WriteLine($"{dlcApp.Key} = {dlcApp.Value}");
+ UpdateUser($"Added DLC to cream_api.ini with appid {dlcApp.Key} ({dlcApp.Value})", InstallationLog.Resource);
+ }
+ }
+ writer.Flush();
+ writer.Close();
}
- writer.Flush();
- writer.Close();
await Task.Run(() => Thread.Sleep(10)); // to keep the text box control from glitching
UpdateProgress(++cur / count * 100);
}
diff --git a/CreamInstaller/Forms/SelectForm.Designer.cs b/CreamInstaller/Forms/SelectForm.Designer.cs
index 870d10f..eed9cfb 100644
--- a/CreamInstaller/Forms/SelectForm.Designer.cs
+++ b/CreamInstaller/Forms/SelectForm.Designer.cs
@@ -31,7 +31,7 @@ namespace CreamInstaller
///
private void InitializeComponent()
{
- this.acceptButton = new System.Windows.Forms.Button();
+ this.installButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
@@ -45,22 +45,23 @@ namespace CreamInstaller
this.scanButton = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
+ this.uninstallButton = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
this.SuspendLayout();
//
- // acceptButton
+ // installButton
//
- this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.acceptButton.Enabled = false;
- this.acceptButton.Location = new System.Drawing.Point(422, 326);
- this.acceptButton.Name = "acceptButton";
- this.acceptButton.Size = new System.Drawing.Size(150, 23);
- this.acceptButton.TabIndex = 10002;
- this.acceptButton.Text = "Generate and Install";
- this.acceptButton.UseVisualStyleBackColor = true;
- this.acceptButton.Click += new System.EventHandler(this.OnAccept);
+ this.installButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.installButton.Enabled = false;
+ this.installButton.Location = new System.Drawing.Point(422, 326);
+ this.installButton.Name = "installButton";
+ this.installButton.Size = new System.Drawing.Size(150, 23);
+ this.installButton.TabIndex = 10003;
+ this.installButton.Text = "Generate and Install";
+ this.installButton.UseVisualStyleBackColor = true;
+ this.installButton.Click += new System.EventHandler(this.OnInstall);
//
// cancelButton
//
@@ -189,7 +190,7 @@ namespace CreamInstaller
//
this.scanButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.scanButton.Enabled = false;
- this.scanButton.Location = new System.Drawing.Point(236, 326);
+ this.scanButton.Location = new System.Drawing.Point(155, 326);
this.scanButton.Name = "scanButton";
this.scanButton.Size = new System.Drawing.Size(180, 23);
this.scanButton.TabIndex = 10001;
@@ -220,11 +221,24 @@ namespace CreamInstaller
this.flowLayoutPanel2.Size = new System.Drawing.Size(43, 25);
this.flowLayoutPanel2.TabIndex = 1006;
//
+ // uninstallButton
+ //
+ this.uninstallButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.uninstallButton.Enabled = false;
+ this.uninstallButton.Location = new System.Drawing.Point(341, 326);
+ this.uninstallButton.Name = "uninstallButton";
+ this.uninstallButton.Size = new System.Drawing.Size(75, 23);
+ this.uninstallButton.TabIndex = 10002;
+ this.uninstallButton.Text = "Uninstall";
+ this.uninstallButton.UseVisualStyleBackColor = true;
+ this.uninstallButton.Click += new System.EventHandler(this.OnUninstall);
+ //
// SelectForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 361);
+ this.Controls.Add(this.uninstallButton);
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.scanButton);
this.Controls.Add(this.flowLayoutPanel2);
@@ -232,7 +246,7 @@ namespace CreamInstaller
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.label1);
this.Controls.Add(this.cancelButton);
- this.Controls.Add(this.acceptButton);
+ this.Controls.Add(this.installButton);
this.Controls.Add(this.label2);
this.DoubleBuffered = true;
this.MaximizeBox = false;
@@ -256,7 +270,7 @@ namespace CreamInstaller
#endregion
- private System.Windows.Forms.Button acceptButton;
+ private System.Windows.Forms.Button installButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
@@ -270,6 +284,7 @@ namespace CreamInstaller
private Button blockProtectedHelpButton;
private FlowLayoutPanel flowLayoutPanel1;
private FlowLayoutPanel flowLayoutPanel2;
+ private Button uninstallButton;
}
}
diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs
index daff1e0..2f851ab 100644
--- a/CreamInstaller/Forms/SelectForm.cs
+++ b/CreamInstaller/Forms/SelectForm.cs
@@ -412,7 +412,8 @@ namespace CreamInstaller
scanButton.Enabled = false;
noneFoundLabel.Visible = false;
allCheckBox.Enabled = false;
- acceptButton.Enabled = false;
+ installButton.Enabled = false;
+ uninstallButton.Enabled = installButton.Enabled;
selectionTreeView.Enabled = false;
label2.Visible = true;
@@ -503,7 +504,8 @@ namespace CreamInstaller
allCheckBox.Enabled = selectionTreeView.Enabled;
noneFoundLabel.Visible = !selectionTreeView.Enabled;
- acceptButton.Enabled = ProgramSelection.AllSafeEnabled.Any();
+ installButton.Enabled = ProgramSelection.AllSafeEnabled.Any();
+ uninstallButton.Enabled = installButton.Enabled;
cancelButton.Enabled = false;
scanButton.Enabled = true;
@@ -575,7 +577,8 @@ namespace CreamInstaller
allCheckBox.Checked = treeNodes.TrueForAll(treeNode => treeNode.Checked);
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
}
- acceptButton.Enabled = ProgramSelection.AllSafeEnabled.Any();
+ installButton.Enabled = ProgramSelection.AllSafeEnabled.Any();
+ uninstallButton.Enabled = installButton.Enabled;
}
private class TreeNodeSorter : IComparer
@@ -686,7 +689,7 @@ namespace CreamInstaller
return false;
}
- private void OnAccept(object sender, EventArgs e)
+ private void OnAccept(bool uninstall = false)
{
if (ProgramSelection.All.Count > 0)
{
@@ -704,7 +707,7 @@ namespace CreamInstaller
}
Hide();
- InstallForm installForm = new(this);
+ InstallForm installForm = new(this, uninstall);
installForm.ShowDialog();
if (installForm.Reselecting)
{
@@ -719,6 +722,16 @@ namespace CreamInstaller
}
}
+ private void OnInstall(object sender, EventArgs e)
+ {
+ OnAccept(false);
+ }
+
+ private void OnUninstall(object sender, EventArgs e)
+ {
+ OnAccept(true);
+ }
+
private void OnScan(object sender, EventArgs e)
{
OnLoad();