diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 7d85488..aa9d799 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -9,7 +9,7 @@ 2.0.0.0 ini.ico - Automatically generates and installs CreamAPI files for programs/games. + Automatically installs and generates CreamAPI files for programs/games on the user's computer. LICENSE 2021, pointfeev (https://github.com/pointfeev) true @@ -20,7 +20,7 @@ steam, dlc CreamInstaller CreamInstaller - CreamAPI Generator & Installer + CreamAPI Installer & Generator pointfeev pointfeev.creaminstaller CreamInstaller.Program diff --git a/CreamInstaller/InstallForm.cs b/CreamInstaller/InstallForm.cs index 0e239d8..b5e2682 100644 --- a/CreamInstaller/InstallForm.cs +++ b/CreamInstaller/InstallForm.cs @@ -78,10 +78,11 @@ namespace CreamInstaller Resources.WriteResourceToFile("steam_api64.dll", api64); UpdateUser($"Wrote resource to file: {api64}", LogColor.Resource); } + UpdateUser("Generating CreamAPI for " + selection.Name + $" in directory \"{directory}\" . . . ", LogColor.Operation); string cApi = directory + @"\cream_api.ini"; File.Create(cApi).Close(); StreamWriter writer = File.AppendText(cApi); - writer.WriteLine("; CreamInstaller"); + writer.WriteLine("; " + Application.CompanyName + " v" + Application.ProductVersion); if (selection.SteamAppId > 0) { writer.WriteLine(); @@ -165,11 +166,11 @@ namespace CreamInstaller try { await Operate(); - UpdateUser("CreamAPI successfully installed for " + ProgramCount + " program(s).", LogColor.Success); + UpdateUser("CreamAPI successfully installed and generated for " + ProgramCount + " program(s).", LogColor.Success); } catch (Exception exception) { - UpdateUser("CreamAPI installation failed: " + exception.ToString(), LogColor.Error); + UpdateUser("CreamAPI installation and/or generation failed: " + exception.ToString(), LogColor.Error); retryButton.Enabled = true; } userProgressBar.Value = userProgressBar.Maximum; diff --git a/CreamInstaller/ProgramSelection.cs b/CreamInstaller/ProgramSelection.cs index 4ec1f69..3165063 100644 --- a/CreamInstaller/ProgramSelection.cs +++ b/CreamInstaller/ProgramSelection.cs @@ -63,5 +63,20 @@ namespace CreamInstaller public static List AllSafeEnabled => AllSafe.FindAll(s => s.Enabled); public static ProgramSelection FromName(string displayName) => AllSafe.Find(s => s.Name == displayName); + + public static Tuple GetDlc(string displayName) + { + foreach (ProgramSelection selection in AllSafe) + { + foreach (Tuple app in selection.AllSteamDlc) + { + if (app.Item2 == displayName) + { + return app; + } + } + } + return null; + } } } \ No newline at end of file diff --git a/CreamInstaller/SelectForm.Designer.cs b/CreamInstaller/SelectForm.Designer.cs index 52275d4..4476b95 100644 --- a/CreamInstaller/SelectForm.Designer.cs +++ b/CreamInstaller/SelectForm.Designer.cs @@ -111,6 +111,9 @@ namespace CreamInstaller this.treeView1.BackColor = System.Drawing.SystemColors.Control; this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.treeView1.CheckBoxes = true; + this.treeView1.Enabled = false; + this.treeView1.FullRowSelect = true; + this.treeView1.HotTracking = true; this.treeView1.Location = new System.Drawing.Point(6, 22); this.treeView1.Name = "treeView1"; this.treeView1.Size = new System.Drawing.Size(448, 208); diff --git a/CreamInstaller/SelectForm.cs b/CreamInstaller/SelectForm.cs index f4946f7..b9788be 100644 --- a/CreamInstaller/SelectForm.cs +++ b/CreamInstaller/SelectForm.cs @@ -3,6 +3,7 @@ using Gameloop.Vdf.Linq; using Microsoft.Win32; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -162,10 +163,7 @@ namespace CreamInstaller if (Program.Canceled) return; string dlcName = null; VProperty dlcAppInfo = null; - if (SteamCMD.GetAppInfo(id, 0, out dlcAppInfo) - && !(dlcAppInfo?.Value is VValue) - && !(dlcAppInfo?.Value?["common"] is VValue)) - dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString(); + if (SteamCMD.GetAppInfo(id, 0, out dlcAppInfo)) dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString(); if (Program.Canceled) return; if (string.IsNullOrWhiteSpace(dlcName)) dlcName = $"Unnamed DLC ({id})"; dlc[id] = dlcName; @@ -201,6 +199,7 @@ namespace CreamInstaller if (Program.Canceled) return; TreeNode programNode = treeNodes.Find(s => s.Text == name) ?? new(); programNode.Text = name; + programNode.Checked = true; programNode.Remove(); treeView1.Nodes.Add(programNode); treeNodes.Remove(programNode); @@ -210,6 +209,7 @@ namespace CreamInstaller if (Program.Canceled || programNode is null) return; TreeNode dlcNode = treeNodes.Find(s => s.Text == dlcApp.Value) ?? new(); dlcNode.Text = dlcApp.Value; + dlcNode.Checked = true; dlcNode.Remove(); programNode.Nodes.Add(dlcNode); treeNodes.Remove(dlcNode); @@ -242,7 +242,7 @@ namespace CreamInstaller noneFoundLabel.Visible = false; allCheckBox.Enabled = false; acceptButton.Enabled = false; - treeView1.CheckBoxes = false; + treeView1.Enabled = false; label2.Visible = true; progressBar1.Visible = true; @@ -259,8 +259,8 @@ namespace CreamInstaller if (_progress < 0) maxProgress = -_progress; else curProgress = _progress; int p = Math.Max(Math.Min((int)((float)(curProgress / (float)maxProgress) * 100), 100), 0); - if (setup) label2.Text = "Setting up SteamCMD . . . " + p + "%"; - else label2.Text = "Gathering your CreamAPI-applicable games and their DLCs . . . " + p + "%"; + if (setup) label2.Text = $"Setting up SteamCMD . . . {p}% ({curProgress}/{maxProgress})"; + else label2.Text = $"Gathering and caching your applicable games and their DLCs . . . {p}% ({curProgress}/{maxProgress})"; progressBar1.Value = p; }; @@ -278,7 +278,7 @@ namespace CreamInstaller watcher.Dispose(); setup = false; - label2.Text = "Gathering your CreamAPI-applicable games and their DLCs . . . "; + label2.Text = "Gathering and caching your applicable games and their DLCs . . . "; await Task.Run(() => GetCreamApiApplicablePrograms(iProgress)); ProgramSelection.All.ForEach(selection => selection.SteamApiDllDirectories.RemoveAll(directory => !Directory.Exists(directory))); @@ -295,7 +295,7 @@ namespace CreamInstaller if (ProgramSelection.All.Any()) { allCheckBox.Enabled = true; - treeView1.CheckBoxes = true; + treeView1.Enabled = true; treeNodes.ForEach(node => node.Checked = true); if (ProgramSelection.AllSafeEnabled.Any()) { @@ -338,6 +338,20 @@ namespace CreamInstaller private void OnLoad(object sender, EventArgs e) { treeView1.AfterCheck += OnTreeViewNodeCheckedChanged; + treeView1.NodeMouseClick += (sender, e) => + { + if (e.Button == MouseButtons.Right) + { + ProgramSelection selection = ProgramSelection.FromName(e.Node.Text); + Tuple dlc = ProgramSelection.GetDlc(e.Node.Text); + int appId = selection?.SteamAppId ?? dlc?.Item1 ?? 0; + if (appId > 0) Process.Start(new ProcessStartInfo + { + FileName = "https://steamdb.info/app/" + appId, + UseShellExecute = true + }); + } + }; OnLoad(); } diff --git a/CreamInstaller/SteamCMD.cs b/CreamInstaller/SteamCMD.cs index bcc501b..3595466 100644 --- a/CreamInstaller/SteamCMD.cs +++ b/CreamInstaller/SteamCMD.cs @@ -77,13 +77,11 @@ namespace CreamInstaller } if (Program.Canceled || output is null) return false; appInfo = VdfConvert.Deserialize(output); - if (appInfo?.Value?.Children()?.ToList()?.Count == 0) return true; - VToken type = null; - try { type = appInfo?.Value?["common"]?["type"]; } catch { } + if (!(appInfo.Value is VValue) && appInfo.Value.Children().ToList().Count == 0) return true; + VToken type = appInfo.Value is VValue ? null : appInfo.Value?["common"]?["type"]; if (type is null || type.ToString() == "Game") { - string buildid = null; - try { buildid = appInfo.Value["depots"]["public"]["buildid"].ToString(); } catch { } + string buildid = appInfo.Value is VValue ? null : appInfo.Value["depots"]?["public"]?["buildid"]?.ToString(); if (buildid is null && !(type is null)) return true; if (type is null || int.Parse(buildid) < buildId) {