From 43a1c8d248e52880d10d15eb0c688960c4487002 Mon Sep 17 00:00:00 2001 From: pointfeev Date: Thu, 22 Sep 2022 18:30:42 -0400 Subject: [PATCH] v4.1.5.0 - Minor refactoring - Added a "help" button to all forms that provides some general information and links --- CreamInstaller/Components/CustomForm.cs | 39 +++++++++++++++++---- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Forms/DebugForm.cs | 2 +- CreamInstaller/Forms/DialogForm.Designer.cs | 8 +++-- CreamInstaller/Forms/DialogForm.cs | 39 +++++++++++++++++---- CreamInstaller/Forms/SelectDialogForm.cs | 6 +--- CreamInstaller/Utility/HttpClientManager.cs | 1 - CreamInstaller/Utility/ProgramData.cs | 1 - 8 files changed, 74 insertions(+), 24 deletions(-) diff --git a/CreamInstaller/Components/CustomForm.cs b/CreamInstaller/Components/CustomForm.cs index 0d7e264..33c45eb 100644 --- a/CreamInstaller/Components/CustomForm.cs +++ b/CreamInstaller/Components/CustomForm.cs @@ -15,6 +15,32 @@ internal class CustomForm : Form KeyPreview = true; KeyPress += OnKeyPress; ResizeRedraw = true; + HelpButton = true; + HelpButtonClicked += OnHelpButtonClicked; + } + + internal void OnHelpButtonClicked(object sender, EventArgs args) + { + using DialogForm helpDialog = new(this); + helpDialog.HelpButton = false; + _ = helpDialog.Show(SystemIcons.Information, + "Automatically finds all installed Steam, Epic and Ubisoft games with their respective DLC-related DLL locations on the user's computer,\n" + + "parses SteamCMD, Steam Store and Epic Games Store for user-selected games' DLCs, then provides a very simple graphical interface\n" + + "utilizing the gathered information for the maintenance of DLC unlockers." + + "\n\n" + + "The program utilizes the latest versions of [Koaloader](https://github.com/acidicoala/Koaloader), [SmokeAPI](https://github.com/acidicoala/SmokeAPI), [ScreamAPI](https://github.com/acidicoala/ScreamAPI), [Uplay R1 Unlocker](https://github.com/acidicoala/UplayR1Unlocker) and [Uplay R2 Unlocker](https://github.com/acidicoala/UplayR2Unlocker), all by\n" + + "the wonderful [acidicoala](https://github.com/acidicoala), and all downloaded and embedded into the program itself; no further downloads necessary on your part!" + + "\n\n" + + "NOTE: This program does not automatically download nor install actual DLC files for you. As the title of the program says, it's\n" + + "only a DLC Unlocker installer. Should the game you wish to unlock DLC for not already come with the DLCs installed (very many\n" + + "do not), you have to find, download, and install those yourself. Preferably, you should be referring to the proper cs.rin.ru post for\n" + + "the game(s) you're tinkering with; you'll usually find any answer to your problems there." + + "\n\n" + + "For reliable and quick assistance, all bugs, crashes and other issues should be referred to the [GitHub Issues](https://github.com/pointfeev/CreamInstaller/issues) page!" + + "\n\n" + + "SteamCMD installation and appinfo cache can be found at [C:\\ProgramData\\CreamInstaller]().\n" + + "The program automatically and very quickly updates from [GitHub](https://github.com/pointfeev/CreamInstaller) using [Onova](https://github.com/Tyrrrz/Onova).\n" + + "The program source and other information can be found on [GitHub](https://github.com/pointfeev/CreamInstaller)."); } internal CustomForm(IWin32Window owner) : this() @@ -26,17 +52,18 @@ internal class CustomForm : Form SizeChanged += (s, e) => InheritLocation(form); form.Activated += OnActivation; FormClosing += (s, e) => form.Activated -= OnActivation; + TopLevel = true; } } 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; + internal static readonly IntPtr HWND_NOTOPMOST = new(-2); + internal static readonly IntPtr HWND_TOPMOST = new(-1); + internal const short SWP_NOACTIVATE = 0x0010; + internal const short SWP_SHOWWINDOW = 0x0040; + internal const short SWP_NOMOVE = 0x0002; + internal const short SWP_NOSIZE = 0x0001; [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 7126a3f..5bf8c67 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 4.1.4.0 + 4.1.5.0 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) diff --git a/CreamInstaller/Forms/DebugForm.cs b/CreamInstaller/Forms/DebugForm.cs index 3096cf7..27429de 100644 --- a/CreamInstaller/Forms/DebugForm.cs +++ b/CreamInstaller/Forms/DebugForm.cs @@ -21,7 +21,7 @@ internal partial class DebugForm : CustomForm set => current = value; } - internal DebugForm() + internal DebugForm() : base() { InitializeComponent(); debugTextBox.BackColor = LogTextBox.Background; diff --git a/CreamInstaller/Forms/DialogForm.Designer.cs b/CreamInstaller/Forms/DialogForm.Designer.cs index f1e76d3..d051fd3 100644 --- a/CreamInstaller/Forms/DialogForm.Designer.cs +++ b/CreamInstaller/Forms/DialogForm.Designer.cs @@ -24,7 +24,7 @@ namespace CreamInstaller { this.cancelButton = new System.Windows.Forms.Button(); this.acceptButton = new System.Windows.Forms.Button(); - this.descriptionLabel = new System.Windows.Forms.Label(); + this.descriptionLabel = new System.Windows.Forms.LinkLabel(); this.icon = new System.Windows.Forms.PictureBox(); this.descriptionPanel = new System.Windows.Forms.FlowLayoutPanel(); this.buttonPanel = new System.Windows.Forms.FlowLayoutPanel(); @@ -67,7 +67,9 @@ namespace CreamInstaller // this.descriptionLabel.AutoSize = true; this.descriptionLabel.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.descriptionLabel.Location = new System.Drawing.Point(69, 12); + this.descriptionLabel.LinkArea = new System.Windows.Forms.LinkArea(0, 0); + this.descriptionLabel.Location = new System.Drawing.Point(75, 12); + this.descriptionLabel.Margin = new System.Windows.Forms.Padding(9, 0, 3, 0); this.descriptionLabel.Name = "descriptionLabel"; this.descriptionLabel.Size = new System.Drawing.Size(94, 15); this.descriptionLabel.TabIndex = 2; @@ -142,9 +144,9 @@ namespace CreamInstaller private Button cancelButton; private Button acceptButton; - private Label descriptionLabel; private PictureBox icon; private FlowLayoutPanel descriptionPanel; private FlowLayoutPanel buttonPanel; + private LinkLabel descriptionLabel; } } \ No newline at end of file diff --git a/CreamInstaller/Forms/DialogForm.cs b/CreamInstaller/Forms/DialogForm.cs index fe5136f..13f9c44 100644 --- a/CreamInstaller/Forms/DialogForm.cs +++ b/CreamInstaller/Forms/DialogForm.cs @@ -1,23 +1,42 @@ using CreamInstaller.Components; using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; +using System.Linq; using System.Windows.Forms; namespace CreamInstaller; internal partial class DialogForm : CustomForm { - internal DialogForm(IWin32Window owner) : base(owner) - { - InitializeComponent(); - TopLevel = true; - } + internal DialogForm(IWin32Window owner) : base(owner) => InitializeComponent(); internal DialogResult Show(Icon descriptionIcon, string descriptionText, string acceptButtonText = "OK", string cancelButtonText = null, string customFormText = null, Icon customFormIcon = null) { descriptionIcon ??= Icon; icon.Image = descriptionIcon.ToBitmap(); + List links = new(); + for (int i = 0; i < descriptionText.Length; i++) + { + if (descriptionText[i] == '[') + { + int textLeft = descriptionText.IndexOf("[", i); + int textRight = descriptionText.IndexOf("]", textLeft == -1 ? i : textLeft); + int linkLeft = descriptionText.IndexOf("(", textRight == -1 ? i : textRight); + int linkRight = descriptionText.IndexOf(")", linkLeft == -1 ? i : linkLeft); + if (textLeft != -1 && textRight == linkLeft - 1 && linkRight != -1) + { + string text = descriptionText[(textLeft + 1)..textRight]; + string link = descriptionText[(linkLeft + 1)..linkRight]; + if (string.IsNullOrWhiteSpace(link)) + link = text; + descriptionText = descriptionText.Remove(i, linkRight + 1 - i).Insert(i, text); + links.Add(new LinkLabel.Link(i, text.Length, link)); + } + } + } descriptionLabel.Text = descriptionText; acceptButton.Text = acceptButtonText; if (cancelButtonText is null) @@ -35,11 +54,19 @@ internal partial class DialogForm : CustomForm } if (customFormIcon is not null) Icon = customFormIcon; + if (links.Any()) + { + foreach (LinkLabel.Link link in links) + _ = descriptionLabel.Links.Add(link); + descriptionLabel.LinkClicked += (s, e) => Process.Start(new ProcessStartInfo((string)e.Link.LinkData) { UseShellExecute = true }); + } return ShowDialog(); } private void OnResize(object s, EventArgs e) => Text = TextRenderer.MeasureText(Program.ApplicationName, Font).Width > Size.Width - 100 - ? Program.ApplicationNameShort + ? TextRenderer.MeasureText(Program.ApplicationNameShort, Font).Width > Size.Width - 100 + ? Program.Name + : Program.ApplicationNameShort : Program.ApplicationName; } diff --git a/CreamInstaller/Forms/SelectDialogForm.cs b/CreamInstaller/Forms/SelectDialogForm.cs index 66e6e65..295c1cb 100644 --- a/CreamInstaller/Forms/SelectDialogForm.cs +++ b/CreamInstaller/Forms/SelectDialogForm.cs @@ -12,11 +12,7 @@ namespace CreamInstaller; internal partial class SelectDialogForm : CustomForm { - internal SelectDialogForm(IWin32Window owner) : base(owner) - { - InitializeComponent(); - TopLevel = true; - } + internal SelectDialogForm(IWin32Window owner) : base(owner) => InitializeComponent(); 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) diff --git a/CreamInstaller/Utility/HttpClientManager.cs b/CreamInstaller/Utility/HttpClientManager.cs index 13400c7..fa568c2 100644 --- a/CreamInstaller/Utility/HttpClientManager.cs +++ b/CreamInstaller/Utility/HttpClientManager.cs @@ -4,7 +4,6 @@ using System; using System.Drawing; using System.Net.Http; using System.Threading.Tasks; -using System.Windows.Forms; namespace CreamInstaller.Utility; diff --git a/CreamInstaller/Utility/ProgramData.cs b/CreamInstaller/Utility/ProgramData.cs index 52fb4e9..6f785de 100644 --- a/CreamInstaller/Utility/ProgramData.cs +++ b/CreamInstaller/Utility/ProgramData.cs @@ -8,7 +8,6 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Windows.Forms; namespace CreamInstaller.Utility;