Update 1.0.6.0

- The cancel button during program selection will now cancel scanning instead of closing the form
- Added a rescan button to the program selection form
- Fixed tabbing on the install form
- Fixed accuracy of program selections list
This commit is contained in:
pointfeev 2021-08-08 19:52:13 -05:00
parent 730d96a473
commit 43dfcc51cb
6 changed files with 135 additions and 96 deletions

View file

@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>1.0.5.2</Version>
<Version>1.0.6.0</Version>
<PackageIcon>ini.ico</PackageIcon>
<PackageIconUrl />
<Description>Automatically downloads and installs CreamAPI files for programs/games.</Description>

View file

@ -65,7 +65,7 @@ namespace CreamInstaller
this.acceptButton.Location = new System.Drawing.Point(437, 286);
this.acceptButton.Name = "acceptButton";
this.acceptButton.Size = new System.Drawing.Size(75, 23);
this.acceptButton.TabIndex = 3;
this.acceptButton.TabIndex = 4;
this.acceptButton.Text = "OK";
this.acceptButton.UseVisualStyleBackColor = true;
this.acceptButton.Click += new System.EventHandler(this.OnAccept);
@ -77,7 +77,7 @@ namespace CreamInstaller
this.retryButton.Location = new System.Drawing.Point(356, 286);
this.retryButton.Name = "retryButton";
this.retryButton.Size = new System.Drawing.Size(75, 23);
this.retryButton.TabIndex = 2;
this.retryButton.TabIndex = 3;
this.retryButton.Text = "Retry";
this.retryButton.UseVisualStyleBackColor = true;
this.retryButton.Click += new System.EventHandler(this.OnRetry);
@ -115,7 +115,7 @@ namespace CreamInstaller
this.reselectButton.Location = new System.Drawing.Point(135, 286);
this.reselectButton.Name = "reselectButton";
this.reselectButton.Size = new System.Drawing.Size(175, 23);
this.reselectButton.TabIndex = 5;
this.reselectButton.TabIndex = 2;
this.reselectButton.Text = "Reselect Programs / Games";
this.reselectButton.UseVisualStyleBackColor = true;
this.reselectButton.Click += new System.EventHandler(this.OnReselect);

View file

@ -181,6 +181,8 @@ namespace CreamInstaller
break;
}
if (!selection.Enabled) { continue; }
Program.Cleanup(cancel: false, logout: false);
if (!Program.IsProgramRunningDialog(this, selection))
@ -193,7 +195,7 @@ namespace CreamInstaller
await OperateFor(selection);
UpdateUser($"Operation succeeded for {selection.ProgramName}.", LogColor.Success);
selection.Remove();
selection.Toggle(false);
}
catch (Exception exception)
{
@ -203,17 +205,21 @@ namespace CreamInstaller
Program.Cleanup(logout: false);
if (Program.ProgramSelections.Count == 1)
List<ProgramSelection> FailedSelections = Program.ProgramSelections.FindAll(selection => selection.Enabled);
if (FailedSelections.Any())
{
throw new Exception($"Operation failed for {Program.ProgramSelections.First().ProgramName}.");
}
else if (Program.ProgramSelections.Count > 1)
{
throw new Exception($"Operation failed for {Program.ProgramSelections.Count} programs.");
if (FailedSelections.Count == 1)
{
throw new Exception($"Operation failed for {FailedSelections.First().ProgramName}.");
}
else
{
throw new Exception($"Operation failed for {FailedSelections.Count} programs.");
}
}
}
private readonly int ProgramCount = Program.ProgramSelections.Count;
private readonly int ProgramCount = Program.ProgramSelections.FindAll(selection => selection.Enabled).Count;
private async void Start()
{

View file

@ -5,6 +5,8 @@ namespace CreamInstaller
{
public class ProgramSelection
{
public bool Enabled = true;
public string ProgramName;
public string ProgramDirectory;
public List<string> SteamApiDllDirectories;
@ -31,20 +33,9 @@ namespace CreamInstaller
Program.ProgramSelections.Add(this);
}
public void Add()
public void Toggle(bool Enabled)
{
if (!Program.ProgramSelections.Contains(this))
{
Program.ProgramSelections.Add(this);
}
}
public void Remove()
{
if (Program.ProgramSelections.Contains(this))
{
Program.ProgramSelections.Remove(this);
}
this.Enabled = Enabled;
}
}
}

View file

@ -42,6 +42,7 @@ namespace CreamInstaller
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label2 = new System.Windows.Forms.Label();
this.scanButton = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
@ -52,7 +53,7 @@ namespace CreamInstaller
this.acceptButton.Location = new System.Drawing.Point(322, 254);
this.acceptButton.Name = "acceptButton";
this.acceptButton.Size = new System.Drawing.Size(150, 23);
this.acceptButton.TabIndex = 101;
this.acceptButton.TabIndex = 102;
this.acceptButton.Text = "Download and Install";
this.acceptButton.UseVisualStyleBackColor = true;
this.acceptButton.Click += new System.EventHandler(this.OnAccept);
@ -85,7 +86,7 @@ namespace CreamInstaller
this.groupBox1.Controls.Add(this.flowLayoutPanel1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(460, 192);
this.groupBox1.Size = new System.Drawing.Size(460, 236);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Programs / Games";
@ -111,7 +112,7 @@ namespace CreamInstaller
this.noneFoundLabel.Enabled = false;
this.noneFoundLabel.Location = new System.Drawing.Point(3, 19);
this.noneFoundLabel.Name = "noneFoundLabel";
this.noneFoundLabel.Size = new System.Drawing.Size(454, 170);
this.noneFoundLabel.Size = new System.Drawing.Size(454, 214);
this.noneFoundLabel.TabIndex = 0;
this.noneFoundLabel.Text = "No CreamAPI-applicable programs or games were found on your computer!";
this.noneFoundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -123,7 +124,7 @@ namespace CreamInstaller
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 19);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(454, 170);
this.flowLayoutPanel1.Size = new System.Drawing.Size(454, 214);
this.flowLayoutPanel1.TabIndex = 1000;
//
// progressBar1
@ -145,17 +146,30 @@ namespace CreamInstaller
this.label2.TabIndex = 10;
this.label2.Text = "Loading . . .";
//
// scanButton
//
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(110, 254);
this.scanButton.Name = "scanButton";
this.scanButton.Size = new System.Drawing.Size(190, 23);
this.scanButton.TabIndex = 101;
this.scanButton.Text = "Rescan for Programs / Games";
this.scanButton.UseVisualStyleBackColor = true;
this.scanButton.Click += new System.EventHandler(this.OnScan);
//
// SelectForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(484, 289);
this.Controls.Add(this.label2);
this.Controls.Add(this.scanButton);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.label1);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.acceptButton);
this.Controls.Add(this.label2);
this.DoubleBuffered = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
@ -184,6 +198,7 @@ namespace CreamInstaller
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox allCheckBox;
private Label noneFoundLabel;
private Button scanButton;
}
}

View file

@ -22,16 +22,12 @@ namespace CreamInstaller
Text = Program.ApplicationName;
}
private List<string> gameLibraryDirectories;
private List<string> GameLibraryDirectories
{
get
{
if (gameLibraryDirectories != null)
{
return gameLibraryDirectories;
}
List<string> gameDirectories = new List<string>();
if (Program.Canceled) { return gameDirectories; }
string steamInstallPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Valve\\Steam", "InstallPath", null) as string;
if (steamInstallPath == null)
{
@ -51,38 +47,37 @@ namespace CreamInstaller
}
}
}
gameLibraryDirectories = gameDirectories;
return gameDirectories;
}
}
private List<string> GetSteamApiDllDirectoriesFromGameDirectory(string gameDirectory, List<string> steamApiDllDirectories = null)
{
if (Program.Canceled) { return null; }
if (steamApiDllDirectories is null)
{
steamApiDllDirectories = new();
}
string file = gameDirectory + "\\steam_api64.dll";
if (File.Exists(file))
{
steamApiDllDirectories.Add(gameDirectory);
}
foreach (string _directory in Directory.GetDirectories(gameDirectory))
{
if (Program.Canceled) { return null; }
GetSteamApiDllDirectoriesFromGameDirectory(_directory, steamApiDllDirectories);
}
if (!steamApiDllDirectories.Any())
{
return null;
}
return steamApiDllDirectories;
}
private string GetGameDirectoryFromLibraryDirectory(string gameName, string libraryDirectory)
{
if (Program.Canceled) { return null; }
if (Path.GetFileName(libraryDirectory) == gameName)
{
return libraryDirectory;
@ -91,6 +86,7 @@ namespace CreamInstaller
{
foreach (string _directory in Directory.GetDirectories(libraryDirectory))
{
if (Program.Canceled) { return null; }
string dir = GetGameDirectoryFromLibraryDirectory(gameName, _directory);
if (dir != null)
{
@ -105,10 +101,12 @@ namespace CreamInstaller
private readonly List<CheckBox> checkBoxes = new();
private void GetCreamApiApplicablePrograms(IProgress<int> progress)
{
if (Program.Canceled) { return; }
int maxProgress = 0;
IEnumerable<INode> fileNodes = Program.MegaApiClient.GetNodesFromLink(new Uri("https://mega.nz/folder/45YBwIxZ#fsZNZZu9twY2PVLgrB86fA"));
foreach (INode node in fileNodes)
{
if (Program.Canceled) { return; }
if (node.Type == NodeType.Directory && node.Name != "CreamAPI" && node.Name != "Outdated")
{
++maxProgress;
@ -119,9 +117,11 @@ namespace CreamInstaller
progress.Report(curProgress);
foreach (INode node in fileNodes)
{
if (Program.Canceled) { return; }
if (node.Type == NodeType.Directory && node.Name != "CreamAPI" && node.Name != "Outdated")
{
progress.Report(++curProgress);
if (Program.ProgramSelections.Any(selection => selection.ProgramName == node.Name)) { continue; }
string rootDirectory;
List<string> directories = null;
if (node.Name == "Paradox Launcher")
@ -139,6 +139,7 @@ namespace CreamInstaller
directories = null;
foreach (string libraryDirectory in GameLibraryDirectories)
{
if (Program.Canceled) { return; }
rootDirectory = GetGameDirectoryFromLibraryDirectory(node.Name, libraryDirectory);
if (rootDirectory != null)
{
@ -149,60 +150,67 @@ namespace CreamInstaller
}
if (!(directories is null))
{
if (Program.Canceled) { return; }
flowLayoutPanel1.Invoke((MethodInvoker)delegate
{
ProgramSelection selection = new();
selection.ProgramName = node.Name;
selection.ProgramDirectory = rootDirectory;
selection.SteamApiDllDirectories = new();
selection.SteamApiDllDirectories.AddRange(directories);
foreach (INode _node in fileNodes)
{
if (_node.Type == NodeType.File && _node.ParentId == node.Id)
{
selection.DownloadNode = _node;
break;
}
}
CheckBox checkBox = new();
checkBoxes.Add(checkBox);
checkBox.AutoSize = true;
checkBox.Parent = flowLayoutPanel1;
checkBox.Text = node.Name;
checkBox.Checked = true;
checkBox.Enabled = false;
checkBox.TabStop = true;
checkBox.TabIndex = 1 + checkBoxes.Count;
checkBox.CheckedChanged += (sender, e) =>
{
if (checkBox.Checked)
{
selection.Add();
}
else
{
selection.Remove();
}
acceptButton.Enabled = Program.ProgramSelections.Count > 0;
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
allCheckBox.Checked = checkBoxes.TrueForAll(checkBox => checkBox.Checked);
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
};
});
{
if (Program.Canceled) { return; }
ProgramSelection selection = new();
selection.ProgramName = node.Name;
selection.ProgramDirectory = rootDirectory;
selection.SteamApiDllDirectories = new();
selection.SteamApiDllDirectories.AddRange(directories);
foreach (INode _node in fileNodes)
{
if (_node.Type == NodeType.File && _node.ParentId == node.Id)
{
selection.DownloadNode = _node;
break;
}
}
CheckBox checkBox = new();
checkBoxes.Add(checkBox);
checkBox.AutoSize = true;
checkBox.Parent = flowLayoutPanel1;
checkBox.Text = node.Name;
checkBox.Checked = true;
checkBox.Enabled = false;
checkBox.TabStop = true;
checkBox.TabIndex = 1 + checkBoxes.Count;
checkBox.CheckedChanged += (sender, e) =>
{
selection.Toggle(checkBox.Checked);
acceptButton.Enabled = Program.ProgramSelections.Any(selection => selection.Enabled);
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
allCheckBox.Checked = checkBoxes.TrueForAll(checkBox => checkBox.Checked);
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
};
});
}
}
}
progress.Report(maxProgress);
}
private async void OnLoad(object sender, EventArgs e)
private async void OnLoad()
{
label2.Text = "Finding CreamAPI-applicable programs on your computer . . . ";
Program.Canceled = false;
cancelButton.Enabled = true;
scanButton.Enabled = false;
noneFoundLabel.Visible = false;
allCheckBox.Enabled = false;
acceptButton.Enabled = false;
checkBoxes.ForEach(checkBox => checkBox.Enabled = false);
label2.Visible = true;
progressBar1.Visible = true;
progressBar1.Value = 0;
groupBox1.Size = new Size(groupBox1.Size.Width, groupBox1.Size.Height - 44);
label2.Text = "Scanning for CreamAPI-applicable programs on your computer . . . ";
int maxProgress = 0;
Progress<int> progress = new();
progress.ProgressChanged += (sender, _progress) =>
@ -214,32 +222,48 @@ namespace CreamInstaller
else
{
int p = (int)((float)(_progress / (float)maxProgress) * 100);
label2.Text = "Finding CreamAPI-applicable programs on your computer . . . " + p + "% (" + _progress + "/" + maxProgress + ")";
label2.Text = "Scanning for CreamAPI-applicable programs on your computer . . . " + p + "% (" + _progress + "/" + maxProgress + ")";
progressBar1.Value = p;
}
};
await Task.Run(() => GetCreamApiApplicablePrograms(progress));
groupBox1.Size = new Size(groupBox1.Size.Width, groupBox1.Size.Height + 44);
Program.ProgramSelections.ForEach(selection => selection.SteamApiDllDirectories.RemoveAll(directory => !Directory.Exists(directory)));
Program.ProgramSelections.RemoveAll(selection => !Directory.Exists(selection.ProgramDirectory) || !selection.SteamApiDllDirectories.Any());
foreach (CheckBox checkBox in checkBoxes)
{
if (!Program.ProgramSelections.Any(selection => selection.ProgramName == checkBox.Text))
{
checkBox.Dispose();
}
}
label2.Hide();
progressBar1.Hide();
progressBar1.Value = 100;
groupBox1.Size = new Size(groupBox1.Size.Width, groupBox1.Size.Height + 44);
label2.Visible = false;
progressBar1.Visible = false;
if (Program.ProgramSelections.Any())
{
allCheckBox.Enabled = true;
foreach (CheckBox checkBox in checkBoxes)
checkBoxes.ForEach(checkBox => checkBox.Enabled = true);
if (Program.ProgramSelections.Any(selection => selection.Enabled))
{
checkBox.Enabled = true;
acceptButton.Enabled = true;
}
acceptButton.Enabled = true;
}
else
{
noneFoundLabel.Visible = true;
}
cancelButton.Enabled = false;
scanButton.Enabled = true;
}
private void OnLoad(object sender, EventArgs e)
{
OnLoad();
}
private void OnAccept(object sender, EventArgs e)
@ -276,9 +300,14 @@ namespace CreamInstaller
}
}
private void OnScan(object sender, EventArgs e)
{
OnLoad();
}
private void OnCancel(object sender, EventArgs e)
{
Close();
Program.Cleanup(logout: false);
}
private void OnAllCheckBoxChanged(object sender, EventArgs e)
@ -291,12 +320,10 @@ namespace CreamInstaller
shouldCheck = true;
}
}
foreach (CheckBox checkBox in checkBoxes)
{
checkBox.Checked = shouldCheck;
}
allCheckBox.Checked = shouldCheck;
}
}