- Minor refactoring
- Added a "help" button to all forms that provides some general information and links
This commit is contained in:
pointfeev 2022-09-22 18:30:42 -04:00
parent f4e27471bc
commit 43a1c8d248
8 changed files with 74 additions and 24 deletions

View file

@ -15,6 +15,32 @@ internal class CustomForm : Form
KeyPreview = true; KeyPreview = true;
KeyPress += OnKeyPress; KeyPress += OnKeyPress;
ResizeRedraw = true; 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() internal CustomForm(IWin32Window owner) : this()
@ -26,17 +52,18 @@ internal class CustomForm : Form
SizeChanged += (s, e) => InheritLocation(form); SizeChanged += (s, e) => InheritLocation(form);
form.Activated += OnActivation; form.Activated += OnActivation;
FormClosing += (s, e) => form.Activated -= OnActivation; FormClosing += (s, e) => form.Activated -= OnActivation;
TopLevel = true;
} }
} }
internal void OnActivation(object sender, EventArgs args) => Activate(); internal void OnActivation(object sender, EventArgs args) => Activate();
public static readonly IntPtr HWND_NOTOPMOST = new(-2); internal static readonly IntPtr HWND_NOTOPMOST = new(-2);
public static readonly IntPtr HWND_TOPMOST = new(-1); internal static readonly IntPtr HWND_TOPMOST = new(-1);
public const short SWP_NOACTIVATE = 0x0010; internal const short SWP_NOACTIVATE = 0x0010;
public const short SWP_SHOWWINDOW = 0x0040; internal const short SWP_SHOWWINDOW = 0x0040;
public const short SWP_NOMOVE = 0x0002; internal const short SWP_NOMOVE = 0x0002;
public const short SWP_NOSIZE = 0x0001; internal const short SWP_NOSIZE = 0x0001;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)] [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]

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.4.0</Version> <Version>4.1.5.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

@ -21,7 +21,7 @@ internal partial class DebugForm : CustomForm
set => current = value; set => current = value;
} }
internal DebugForm() internal DebugForm() : base()
{ {
InitializeComponent(); InitializeComponent();
debugTextBox.BackColor = LogTextBox.Background; debugTextBox.BackColor = LogTextBox.Background;

View file

@ -24,7 +24,7 @@ namespace CreamInstaller
{ {
this.cancelButton = new System.Windows.Forms.Button(); this.cancelButton = new System.Windows.Forms.Button();
this.acceptButton = 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.icon = new System.Windows.Forms.PictureBox();
this.descriptionPanel = new System.Windows.Forms.FlowLayoutPanel(); this.descriptionPanel = new System.Windows.Forms.FlowLayoutPanel();
this.buttonPanel = new System.Windows.Forms.FlowLayoutPanel(); this.buttonPanel = new System.Windows.Forms.FlowLayoutPanel();
@ -67,7 +67,9 @@ namespace CreamInstaller
// //
this.descriptionLabel.AutoSize = true; this.descriptionLabel.AutoSize = true;
this.descriptionLabel.FlatStyle = System.Windows.Forms.FlatStyle.System; 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.Name = "descriptionLabel";
this.descriptionLabel.Size = new System.Drawing.Size(94, 15); this.descriptionLabel.Size = new System.Drawing.Size(94, 15);
this.descriptionLabel.TabIndex = 2; this.descriptionLabel.TabIndex = 2;
@ -142,9 +144,9 @@ namespace CreamInstaller
private Button cancelButton; private Button cancelButton;
private Button acceptButton; private Button acceptButton;
private Label descriptionLabel;
private PictureBox icon; private PictureBox icon;
private FlowLayoutPanel descriptionPanel; private FlowLayoutPanel descriptionPanel;
private FlowLayoutPanel buttonPanel; private FlowLayoutPanel buttonPanel;
private LinkLabel descriptionLabel;
} }
} }

View file

@ -1,23 +1,42 @@
using CreamInstaller.Components; using CreamInstaller.Components;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace CreamInstaller; namespace CreamInstaller;
internal partial class DialogForm : CustomForm internal partial class DialogForm : CustomForm
{ {
internal DialogForm(IWin32Window owner) : base(owner) internal DialogForm(IWin32Window owner) : base(owner) => InitializeComponent();
{
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)
{ {
descriptionIcon ??= Icon; descriptionIcon ??= Icon;
icon.Image = descriptionIcon.ToBitmap(); icon.Image = descriptionIcon.ToBitmap();
List<LinkLabel.Link> 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; descriptionLabel.Text = descriptionText;
acceptButton.Text = acceptButtonText; acceptButton.Text = acceptButtonText;
if (cancelButtonText is null) if (cancelButtonText is null)
@ -35,11 +54,19 @@ internal partial class DialogForm : CustomForm
} }
if (customFormIcon is not null) if (customFormIcon is not null)
Icon = customFormIcon; 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(); return ShowDialog();
} }
private void OnResize(object s, EventArgs e) => private void OnResize(object s, EventArgs e) =>
Text = TextRenderer.MeasureText(Program.ApplicationName, Font).Width > Size.Width - 100 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; : Program.ApplicationName;
} }

View file

@ -12,11 +12,7 @@ namespace CreamInstaller;
internal partial class SelectDialogForm : CustomForm internal partial class SelectDialogForm : CustomForm
{ {
internal SelectDialogForm(IWin32Window owner) : base(owner) internal SelectDialogForm(IWin32Window owner) : base(owner) => InitializeComponent();
{
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

@ -4,7 +4,6 @@ using System;
using System.Drawing; using System.Drawing;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace CreamInstaller.Utility; namespace CreamInstaller.Utility;

View file

@ -8,7 +8,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace CreamInstaller.Utility; namespace CreamInstaller.Utility;