WIP Start to Settings Menu / UI Adjustments

- Remove the MainForm cancel button > it doesn't really serve a purpose and it breaks the UI cause I suck.
- Add the start to a settings dialog, relocated several settings from the top bar into the new setttings dialog
- Add a custom Toggle Switch, change the CheckBox for SmokeAPI/CreamAPI to a Toggle Switch
- Relocate Uninstall All button to main form (Currently disabled)
This commit is contained in:
Frog
2026-07-20 01:41:55 -07:00
parent 513dcbb599
commit 71d17031b9
9 changed files with 465 additions and 325 deletions
+113
View File
@@ -0,0 +1,113 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace CreamInstaller.Components;
internal sealed class ToggleSwitch : Control
{
private bool _checked;
private const int TrackPadding = 1;
private const int ThumbDiameter = 18;
private static readonly Color DarkOffTrack = ColorTranslator.FromHtml("#3A3A3D");
private static readonly Color DarkOnTrack = ColorTranslator.FromHtml("#0E639C");
private static readonly Color LightOffTrack = ColorTranslator.FromHtml("#CCCCCC");
private static readonly Color LightOnTrack = SystemColors.Highlight;
private static readonly Color ThumbColor = Color.White;
public ToggleSwitch()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
Size = new Size(44, 22);
TabStop = true;
Cursor = Cursors.Hand;
}
public bool Checked
{
get => _checked;
set
{
if (_checked == value)
return;
_checked = value;
Invalidate();
CheckedChanged?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler CheckedChanged;
protected override void OnClick(EventArgs e)
{
Checked = !Checked;
base.OnClick(e);
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode is Keys.Space or Keys.Enter)
{
Checked = !Checked;
e.Handled = true;
return;
}
base.OnKeyDown(e);
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
bool isDarkMode = Program.DarkModeEnabled;
int trackHeight = Height - (TrackPadding * 2);
int trackWidth = Width - (TrackPadding * 2);
// Draw track (rounded)
Color trackColor = _checked
? (isDarkMode ? DarkOnTrack : LightOnTrack)
: (isDarkMode ? DarkOffTrack : LightOffTrack);
int cornerRadius = trackHeight / 2;
Rectangle trackRect = new(TrackPadding, TrackPadding, trackWidth, trackHeight);
using GraphicsPath trackPath = CreateRoundedRect(trackRect, cornerRadius);
using SolidBrush trackBrush = new(trackColor);
g.FillPath(trackBrush, trackPath);
// Draw track border
using Pen trackPen = new(isDarkMode ? ColorTranslator.FromHtml("#555555") : ColorTranslator.FromHtml("#A0A0A0"), 1);
g.DrawPath(trackPen, trackPath);
// Draw thumb
int thumbX = _checked
? Width - TrackPadding - ThumbDiameter
: TrackPadding;
int thumbY = (Height - ThumbDiameter) / 2;
using SolidBrush thumbBrush = new(ThumbColor);
g.FillEllipse(thumbBrush, thumbX, thumbY, ThumbDiameter, ThumbDiameter);
// Draw thumb shadow
using Pen thumbShadowPen = new(Color.FromArgb(60, 0, 0, 0), 1);
g.DrawEllipse(thumbShadowPen, thumbX, thumbY, ThumbDiameter, ThumbDiameter);
}
private static GraphicsPath CreateRoundedRect(Rectangle rect, int radius)
{
int d = radius * 2;
GraphicsPath path = new();
path.StartFigure();
path.AddArc(rect.X, rect.Y, d, d, 180, 90);
path.AddArc(rect.Right - d, rect.Y, d, d, 270, 90);
path.AddArc(rect.Right - d, rect.Bottom - d, d, d, 0, 90);
path.AddArc(rect.X, rect.Bottom - d, d, d, 90, 90);
path.CloseFigure();
return path;
}
}
+98 -222
View File
@@ -20,19 +20,12 @@ namespace CreamInstaller.Forms
private void InitializeComponent()
{
installButton = new Button();
cancelButton = new Button();
programsGroupBox = new GroupBox();
proxyFlowPanel = new FlowLayoutPanel();
proxyAllCheckBox = new CheckBox();
noneFoundLabel = new Label();
blockedGamesFlowPanel = new FlowLayoutPanel();
blockedGamesCheckBox = new CheckBox();
blockProtectedHelpButton = new Button();
useSmokeAPILayoutPanel = new FlowLayoutPanel();
useSmokeAPICheckBox = new CheckBox();
useSmokeApiToggle = new ToggleSwitch();
useSmokeApiLabel = new Label();
useSmokeAPIHelpButton = new Button();
darkModeFlowPanel = new FlowLayoutPanel();
darkModeCheckBox = new CheckBox();
allCheckBoxLayoutPanel = new FlowLayoutPanel();
allCheckBox = new CheckBox();
progressBar = new ProgressBar();
@@ -42,15 +35,12 @@ namespace CreamInstaller.Forms
uninstallButton = new Button();
progressLabelGames = new Label();
progressLabelDLCs = new Label();
sortCheckBox = new CheckBox();
saveFlowPanel = new FlowLayoutPanel();
settingsButton = new Button();
selectionTreeView = new CustomTreeView();
topOptionsTable = new TableLayoutPanel();
programsGroupBox.SuspendLayout();
proxyFlowPanel.SuspendLayout();
blockedGamesFlowPanel.SuspendLayout();
useSmokeAPILayoutPanel.SuspendLayout();
darkModeFlowPanel.SuspendLayout();
allCheckBoxLayoutPanel.SuspendLayout();
saveFlowPanel.SuspendLayout();
SuspendLayout();
@@ -61,7 +51,7 @@ namespace CreamInstaller.Forms
installButton.AutoSize = true;
installButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
installButton.Enabled = false;
installButton.Location = new System.Drawing.Point(495, 376);
installButton.Location = new System.Drawing.Point(541, 382);
installButton.Name = "installButton";
installButton.Padding = new Padding(3, 0, 3, 0);
installButton.Size = new System.Drawing.Size(127, 25);
@@ -70,139 +60,67 @@ namespace CreamInstaller.Forms
installButton.UseVisualStyleBackColor = true;
installButton.Click += OnInstall;
//
// cancelButton
//
cancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
cancelButton.AutoSize = true;
cancelButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
cancelButton.Location = new System.Drawing.Point(12, 376);
cancelButton.Name = "cancelButton";
cancelButton.Padding = new Padding(3, 0, 3, 0);
cancelButton.Size = new System.Drawing.Size(59, 25);
cancelButton.TabIndex = 10004;
cancelButton.Text = "Cancel";
cancelButton.UseVisualStyleBackColor = true;
cancelButton.Click += OnCancel;
//
// programsGroupBox
//
programsGroupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
programsGroupBox.Controls.Add(noneFoundLabel);
programsGroupBox.Controls.Add(selectionTreeView);
programsGroupBox.Location = new System.Drawing.Point(12, 47);
programsGroupBox.Location = new System.Drawing.Point(12, 43);
programsGroupBox.Name = "programsGroupBox";
programsGroupBox.Size = new System.Drawing.Size(610, 252);
programsGroupBox.TabIndex = 8;
programsGroupBox.Size = new System.Drawing.Size(656, 252);
programsGroupBox.TabIndex = 1000;
programsGroupBox.TabStop = false;
programsGroupBox.Text = "Programs / Games";
//
// proxyFlowPanel
//
proxyFlowPanel.AutoSize = true;
proxyFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
proxyFlowPanel.Controls.Add(proxyAllCheckBox);
proxyFlowPanel.Margin = new Padding(0);
proxyFlowPanel.Name = "proxyFlowPanel";
proxyFlowPanel.Size = new System.Drawing.Size(75, 19);
proxyFlowPanel.TabIndex = 10005;
proxyFlowPanel.WrapContents = false;
//
// proxyAllCheckBox
//
proxyAllCheckBox.AutoSize = true;
proxyAllCheckBox.Enabled = false;
proxyAllCheckBox.Location = new System.Drawing.Point(2, 0);
proxyAllCheckBox.Margin = new Padding(2, 0, 0, 0);
proxyAllCheckBox.Name = "proxyAllCheckBox";
proxyAllCheckBox.Size = new System.Drawing.Size(73, 19);
proxyAllCheckBox.TabIndex = 4;
proxyAllCheckBox.Text = "Proxy All";
proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
programsGroupBox.Text = "Programs && Games";
programsGroupBox.Enter += programsGroupBox_Enter;
//
// noneFoundLabel
//
noneFoundLabel.Dock = DockStyle.Fill;
noneFoundLabel.Location = new System.Drawing.Point(3, 19);
noneFoundLabel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
noneFoundLabel.Location = new System.Drawing.Point(12, 321);
noneFoundLabel.Name = "noneFoundLabel";
noneFoundLabel.Size = new System.Drawing.Size(604, 230);
noneFoundLabel.TabIndex = 1002;
noneFoundLabel.Text = "No applicable programs nor games were found on your computer!";
noneFoundLabel.Size = new System.Drawing.Size(656, 18);
noneFoundLabel.TabIndex = 1003;
noneFoundLabel.Text = "No applicable programs and/or games found.";
noneFoundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
noneFoundLabel.Visible = false;
//
// blockedGamesFlowPanel
//
blockedGamesFlowPanel.AutoSize = true;
blockedGamesFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
blockedGamesFlowPanel.Controls.Add(blockedGamesCheckBox);
blockedGamesFlowPanel.Controls.Add(blockProtectedHelpButton);
blockedGamesFlowPanel.Margin = new Padding(0);
blockedGamesFlowPanel.Name = "blockedGamesFlowPanel";
blockedGamesFlowPanel.Size = new System.Drawing.Size(170, 19);
blockedGamesFlowPanel.TabIndex = 1005;
blockedGamesFlowPanel.WrapContents = false;
//
// blockedGamesCheckBox
//
blockedGamesCheckBox.AutoSize = true;
blockedGamesCheckBox.Checked = true;
blockedGamesCheckBox.CheckState = CheckState.Checked;
blockedGamesCheckBox.Enabled = false;
blockedGamesCheckBox.Location = new System.Drawing.Point(2, 0);
blockedGamesCheckBox.Margin = new Padding(2, 0, 0, 0);
blockedGamesCheckBox.Name = "blockedGamesCheckBox";
blockedGamesCheckBox.Size = new System.Drawing.Size(148, 19);
blockedGamesCheckBox.TabIndex = 1;
blockedGamesCheckBox.Text = "Block Protected Games";
blockedGamesCheckBox.UseVisualStyleBackColor = true;
blockedGamesCheckBox.CheckedChanged += OnBlockProtectedGamesCheckBoxChanged;
//
// blockProtectedHelpButton
//
blockProtectedHelpButton.Enabled = false;
blockProtectedHelpButton.Font = new System.Drawing.Font("Segoe UI", 7F);
blockProtectedHelpButton.Location = new System.Drawing.Point(150, 0);
blockProtectedHelpButton.Margin = new Padding(0, 0, 1, 0);
blockProtectedHelpButton.Name = "blockProtectedHelpButton";
blockProtectedHelpButton.Size = new System.Drawing.Size(19, 19);
blockProtectedHelpButton.TabIndex = 2;
blockProtectedHelpButton.Text = "?";
blockProtectedHelpButton.UseVisualStyleBackColor = true;
blockProtectedHelpButton.Click += OnBlockProtectedGamesHelpButtonClicked;
//
// useSmokeAPILayoutPanel
//
useSmokeAPILayoutPanel.AutoSize = true;
useSmokeAPILayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
useSmokeAPILayoutPanel.Controls.Add(useSmokeAPICheckBox);
useSmokeAPILayoutPanel.Controls.Add(useSmokeApiToggle);
useSmokeAPILayoutPanel.Controls.Add(useSmokeApiLabel);
useSmokeAPILayoutPanel.Controls.Add(useSmokeAPIHelpButton);
useSmokeAPILayoutPanel.Margin = new Padding(12, 0, 0, 0);
useSmokeAPILayoutPanel.Margin = new Padding(0);
useSmokeAPILayoutPanel.Name = "useSmokeAPILayoutPanel";
useSmokeAPILayoutPanel.Size = new System.Drawing.Size(124, 19);
useSmokeAPILayoutPanel.Size = new System.Drawing.Size(150, 22);
useSmokeAPILayoutPanel.TabIndex = 1006;
useSmokeAPILayoutPanel.WrapContents = false;
//
// useSmokeAPICheckBox
// useSmokeApiToggle
//
useSmokeAPICheckBox.AutoSize = true;
useSmokeAPICheckBox.Checked = true;
useSmokeAPICheckBox.CheckState = CheckState.Checked;
useSmokeAPICheckBox.Enabled = false;
useSmokeAPICheckBox.Location = new System.Drawing.Point(2, 0);
useSmokeAPICheckBox.Margin = new Padding(2, 0, 0, 0);
useSmokeAPICheckBox.Name = "useSmokeAPICheckBox";
useSmokeAPICheckBox.Size = new System.Drawing.Size(102, 19);
useSmokeAPICheckBox.TabIndex = 1;
useSmokeAPICheckBox.Text = "Use SmokeAPI";
useSmokeAPICheckBox.UseVisualStyleBackColor = true;
useSmokeAPICheckBox.CheckedChanged += OnUseSmokeAPICheckBoxChanged;
useSmokeApiToggle.Location = new System.Drawing.Point(0, 0);
useSmokeApiToggle.Name = "useSmokeApiToggle";
useSmokeApiToggle.Size = new System.Drawing.Size(44, 22);
useSmokeApiToggle.TabIndex = 1;
useSmokeApiToggle.CheckedChanged += OnUseSmokeApiToggleChanged;
//
// useSmokeApiLabel
//
useSmokeApiLabel.AutoSize = true;
useSmokeApiLabel.Location = new System.Drawing.Point(47, 2);
useSmokeApiLabel.Margin = new Padding(3, 2, 0, 0);
useSmokeApiLabel.Name = "useSmokeApiLabel";
useSmokeApiLabel.Size = new System.Drawing.Size(70, 15);
useSmokeApiLabel.TabIndex = 3;
useSmokeApiLabel.Text = "SmokeAPI";
useSmokeApiLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// useSmokeAPIHelpButton
//
useSmokeAPIHelpButton.Enabled = false;
useSmokeAPIHelpButton.Font = new System.Drawing.Font("Segoe UI", 7F);
useSmokeAPIHelpButton.Location = new System.Drawing.Point(104, 0);
useSmokeAPIHelpButton.Margin = new Padding(0, 0, 1, 0);
useSmokeAPIHelpButton.Location = new System.Drawing.Point(120, 0);
useSmokeAPIHelpButton.Margin = new Padding(2, 0, 1, 0);
useSmokeAPIHelpButton.Name = "useSmokeAPIHelpButton";
useSmokeAPIHelpButton.Size = new System.Drawing.Size(19, 19);
useSmokeAPIHelpButton.TabIndex = 2;
@@ -210,30 +128,6 @@ namespace CreamInstaller.Forms
useSmokeAPIHelpButton.UseVisualStyleBackColor = true;
useSmokeAPIHelpButton.Click += OnUseSmokeAPIHelpButtonClicked;
//
// darkModeFlowPanel
//
darkModeFlowPanel.AutoSize = true;
darkModeFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
darkModeFlowPanel.Margin = new Padding(12, 0, 0, 0);
darkModeFlowPanel.Name = "darkModeFlowPanel";
darkModeFlowPanel.Size = new System.Drawing.Size(98, 19);
darkModeFlowPanel.TabIndex = 10011;
darkModeFlowPanel.WrapContents = false;
//
// darkModeCheckBox
//
darkModeCheckBox.AutoSize = true;
darkModeCheckBox.Enabled = true;
darkModeCheckBox.Location = new System.Drawing.Point(2, 0);
darkModeCheckBox.Margin = new Padding(2, 0, 0, 0);
darkModeCheckBox.Name = "darkModeCheckBox";
darkModeCheckBox.Size = new System.Drawing.Size(96, 19);
darkModeCheckBox.TabIndex = 1;
darkModeCheckBox.Text = "Enable Dark Mode";
darkModeCheckBox.UseVisualStyleBackColor = true;
darkModeCheckBox.CheckedChanged += OnDarkModeCheckBoxChanged;
darkModeFlowPanel.Controls.Add(darkModeCheckBox);
//
// allCheckBoxLayoutPanel
//
allCheckBoxLayoutPanel.AutoSize = true;
@@ -278,7 +172,7 @@ namespace CreamInstaller.Forms
progressBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
progressBar.Location = new System.Drawing.Point(12, 352);
progressBar.Name = "progressBar";
progressBar.Size = new System.Drawing.Size(610, 23);
progressBar.Size = new System.Drawing.Size(656, 23);
progressBar.TabIndex = 9;
//
// progressLabel
@@ -286,108 +180,105 @@ namespace CreamInstaller.Forms
progressLabel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
progressLabel.Location = new System.Drawing.Point(12, 302);
progressLabel.Name = "progressLabel";
progressLabel.Size = new System.Drawing.Size(610, 23);
progressLabel.Size = new System.Drawing.Size(656, 23);
progressLabel.TabIndex = 10;
progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . 0%";
progressLabel.Text = "Gathering and caching programs . . .";
progressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
progressLabel.Visible = false;
//
// scanButton
//
scanButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
scanButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
scanButton.AutoSize = true;
scanButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
scanButton.Enabled = false;
scanButton.Location = new System.Drawing.Point(186, 376);
scanButton.Location = new System.Drawing.Point(450, 382);
scanButton.Name = "scanButton";
scanButton.Padding = new Padding(3, 0, 3, 0);
scanButton.Size = new System.Drawing.Size(60, 25);
scanButton.TabIndex = 10002;
scanButton.Size = new System.Drawing.Size(85, 25);
scanButton.TabIndex = 10004;
scanButton.Text = "Rescan";
scanButton.UseVisualStyleBackColor = true;
scanButton.Click += OnScan;
//
// uninstallAllButton
//
uninstallAllButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
uninstallAllButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
uninstallAllButton.AutoSize = true;
uninstallAllButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
uninstallAllButton.Location = new System.Drawing.Point(327, 376);
uninstallAllButton.Enabled = false;
uninstallAllButton.Location = new System.Drawing.Point(12, 382);
uninstallAllButton.Name = "uninstallAllButton";
uninstallAllButton.Padding = new Padding(3, 0, 3, 0);
uninstallAllButton.Size = new System.Drawing.Size(87, 25);
uninstallAllButton.TabIndex = 10003;
uninstallAllButton.Size = new System.Drawing.Size(85, 25);
uninstallAllButton.TabIndex = 10006;
uninstallAllButton.Text = "Uninstall All";
uninstallAllButton.UseVisualStyleBackColor = true;
uninstallAllButton.Click += OnUninstallAll;
//
// uninstallButton
//
uninstallButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
uninstallButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
uninstallButton.AutoSize = true;
uninstallButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
uninstallButton.Enabled = false;
uninstallButton.Location = new System.Drawing.Point(420, 376);
uninstallButton.Location = new System.Drawing.Point(100, 382);
uninstallButton.Name = "uninstallButton";
uninstallButton.Padding = new Padding(3, 0, 3, 0);
uninstallButton.Size = new System.Drawing.Size(69, 25);
uninstallButton.TabIndex = 10001;
uninstallButton.Text = "Uninstall";
uninstallButton.Size = new System.Drawing.Size(174, 25);
uninstallButton.TabIndex = 10005;
uninstallButton.Text = "Uninstall Selected";
uninstallButton.UseVisualStyleBackColor = true;
uninstallButton.Click += OnUninstall;
//
// progressLabelGames
//
progressLabelGames.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
progressLabelGames.Font = new System.Drawing.Font("Segoe UI", 7F);
progressLabelGames.Location = new System.Drawing.Point(12, 325);
progressLabelGames.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
progressLabelGames.Location = new System.Drawing.Point(12, 328);
progressLabelGames.Name = "progressLabelGames";
progressLabelGames.Size = new System.Drawing.Size(610, 12);
progressLabelGames.TabIndex = 11;
progressLabelGames.Text = "Remaining games (2): Game 1, Game 2";
progressLabelGames.Size = new System.Drawing.Size(375, 18);
progressLabelGames.TabIndex = 10007;
progressLabelGames.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// progressLabelDLCs
//
progressLabelDLCs.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
progressLabelDLCs.Font = new System.Drawing.Font("Segoe UI", 7F);
progressLabelDLCs.Location = new System.Drawing.Point(12, 337);
progressLabelDLCs.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
progressLabelDLCs.Location = new System.Drawing.Point(393, 328);
progressLabelDLCs.Name = "progressLabelDLCs";
progressLabelDLCs.Size = new System.Drawing.Size(610, 12);
progressLabelDLCs.TabIndex = 12;
progressLabelDLCs.Text = "Remaining DLC (2): 123456, 654321";
//
// sortCheckBox
//
sortCheckBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
sortCheckBox.AutoSize = true;
sortCheckBox.Checked = true; // Enable Sort By Name by default
sortCheckBox.Location = new System.Drawing.Point(84, 380);
sortCheckBox.Margin = new Padding(3, 0, 0, 0);
sortCheckBox.Name = "sortCheckBox";
sortCheckBox.Size = new System.Drawing.Size(98, 19);
sortCheckBox.TabIndex = 10003;
sortCheckBox.Text = "Sort By Name";
sortCheckBox.CheckedChanged += OnSortCheckBoxChanged;
progressLabelDLCs.Size = new System.Drawing.Size(329, 18);
progressLabelDLCs.TabIndex = 10008;
progressLabelDLCs.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// saveFlowPanel
//
saveFlowPanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
saveFlowPanel.AutoSize = true;
saveFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
saveFlowPanel.Location = new System.Drawing.Point(263, 376);
saveFlowPanel.Location = new System.Drawing.Point(380, 382);
saveFlowPanel.Name = "saveFlowPanel";
saveFlowPanel.Size = new System.Drawing.Size(141, 25);
saveFlowPanel.TabIndex = 10008;
saveFlowPanel.TabIndex = 10009;
saveFlowPanel.WrapContents = false;
//
// settingsButton
//
settingsButton.AutoSize = true;
settingsButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
settingsButton.Location = new System.Drawing.Point(0, 0);
settingsButton.Name = "settingsButton";
settingsButton.Size = new System.Drawing.Size(60, 25);
settingsButton.TabIndex = 10010;
settingsButton.Text = "Settings";
settingsButton.UseVisualStyleBackColor = true;
settingsButton.Click += OnSettingsButtonClick;
//
// topOptionsTable
//
topOptionsTable.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
topOptionsTable.AutoSize = true;
topOptionsTable.AutoSizeMode = AutoSizeMode.GrowAndShrink;
topOptionsTable.ColumnCount = 6;
topOptionsTable.ColumnCount = 4;
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); // spacer
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
topOptionsTable.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
topOptionsTable.Location = new System.Drawing.Point(12, 12);
@@ -395,36 +286,35 @@ namespace CreamInstaller.Forms
topOptionsTable.Name = "topOptionsTable";
topOptionsTable.RowCount = 1;
topOptionsTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
topOptionsTable.Size = new System.Drawing.Size(610, 25);
topOptionsTable.Size = new System.Drawing.Size(656, 25);
topOptionsTable.TabIndex = 10009;
topOptionsTable.Controls.Clear();
topOptionsTable.Controls.Add(blockedGamesFlowPanel, 0, 0);
topOptionsTable.Controls.Add(useSmokeAPILayoutPanel, 1, 0);
topOptionsTable.Controls.Add(darkModeFlowPanel, 2, 0);
topOptionsTable.Controls.Add(proxyFlowPanel, 4, 0);
topOptionsTable.Controls.Add(allCheckBoxLayoutPanel, 5, 0);
topOptionsTable.Controls.Add(useSmokeAPILayoutPanel, 0, 0);
topOptionsTable.Controls.Add(settingsButton, 2, 0);
topOptionsTable.Controls.Add(allCheckBoxLayoutPanel, 3, 0);
//
// SelectForm
//
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
ClientSize = new System.Drawing.Size(634, 411);
ClientSize = new System.Drawing.Size(680, 417);
Controls.Add(topOptionsTable);
Controls.Add(saveFlowPanel);
Controls.Add(sortCheckBox);
Controls.Add(progressLabelDLCs);
Controls.Add(progressLabelGames);
Controls.Add(progressLabel);
Controls.Add(progressBar);
Controls.Add(noneFoundLabel);
Controls.Add(programsGroupBox);
Controls.Add(uninstallAllButton);
Controls.Add(uninstallButton);
Controls.Add(scanButton);
Controls.Add(programsGroupBox);
Controls.Add(progressBar);
Controls.Add(cancelButton);
Controls.Add(installButton);
Controls.Add(progressLabel);
DoubleBuffered = true;
FormBorderStyle = FormBorderStyle.FixedSingle;
FormBorderStyle = FormBorderStyle.FixedDialog;
HelpButton = true;
Icon = Properties.Resources.Icon;
Margin = new Padding(4, 3, 4, 3);
MaximizeBox = false;
MinimizeBox = false;
Name = "SelectForm";
@@ -432,14 +322,8 @@ namespace CreamInstaller.Forms
Text = "SelectForm";
Load += OnLoad;
programsGroupBox.ResumeLayout(false);
proxyFlowPanel.ResumeLayout(false);
proxyFlowPanel.PerformLayout();
blockedGamesFlowPanel.ResumeLayout(false);
blockedGamesFlowPanel.PerformLayout();
useSmokeAPILayoutPanel.ResumeLayout(false);
useSmokeAPILayoutPanel.PerformLayout();
darkModeFlowPanel.ResumeLayout(false);
darkModeFlowPanel.PerformLayout();
allCheckBoxLayoutPanel.ResumeLayout(false);
allCheckBoxLayoutPanel.PerformLayout();
saveFlowPanel.ResumeLayout(false);
@@ -451,7 +335,6 @@ namespace CreamInstaller.Forms
#endregion
private Button installButton;
private Button cancelButton;
private GroupBox programsGroupBox;
private ProgressBar progressBar;
private Label progressLabel;
@@ -459,24 +342,17 @@ namespace CreamInstaller.Forms
private Button scanButton;
private Label noneFoundLabel;
private CustomTreeView selectionTreeView;
private CheckBox blockedGamesCheckBox;
private Button blockProtectedHelpButton;
private CheckBox useSmokeAPICheckBox;
private ToggleSwitch useSmokeApiToggle;
private Label useSmokeApiLabel;
private Button useSmokeAPIHelpButton;
private FlowLayoutPanel blockedGamesFlowPanel;
private FlowLayoutPanel useSmokeAPILayoutPanel;
private FlowLayoutPanel darkModeFlowPanel;
private FlowLayoutPanel allCheckBoxLayoutPanel;
private Button uninstallButton;
private Button uninstallAllButton;
private Label progressLabelGames;
private Label progressLabelDLCs;
private CheckBox sortCheckBox;
private FlowLayoutPanel proxyFlowPanel;
internal CheckBox proxyAllCheckBox;
private FlowLayoutPanel saveFlowPanel;
private Button settingsButton;
private TableLayoutPanel topOptionsTable;
private CheckBox darkModeCheckBox;
}
}
+22 -91
View File
@@ -39,7 +39,7 @@ internal sealed partial class SelectForm : CustomForm
private SelectForm()
{
InitializeComponent();
selectionTreeView.TreeViewNodeSorter = sortCheckBox.Checked ? PlatformIdComparer.NodeText : PlatformIdComparer.NodeName;
selectionTreeView.TreeViewNodeSorter = Program.SortByName ? PlatformIdComparer.NodeText : PlatformIdComparer.NodeName;
Text = Program.ApplicationName;
}
@@ -681,15 +681,11 @@ internal sealed partial class SelectForm : CustomForm
try
{
Program.Canceled = false;
blockedGamesCheckBox.Enabled = false;
blockProtectedHelpButton.Enabled = false;
useSmokeAPICheckBox.Enabled = false;
useSmokeApiToggle.Enabled = false;
useSmokeAPIHelpButton.Enabled = false;
cancelButton.Enabled = true;
scanButton.Enabled = false;
noneFoundLabel.Visible = false;
allCheckBox.Enabled = false;
proxyAllCheckBox.Enabled = false;
installButton.Enabled = false;
uninstallButton.Enabled = installButton.Enabled;
selectionTreeView.Enabled = false;
@@ -803,18 +799,14 @@ internal sealed partial class SelectForm : CustomForm
if (!scan && Selection.All.Keys.Any(s => s.InstalledUnlocker != InstalledUnlocker.None))
RefreshNewDLCsForInstalledGames();
HideProgressBar();
selectionTreeView.Enabled = !Selection.All.IsEmpty;
allCheckBox.Enabled = selectionTreeView.Enabled;
proxyAllCheckBox.Enabled = selectionTreeView.Enabled;
noneFoundLabel.Visible = !selectionTreeView.Enabled;
installButton.Enabled = Selection.AllEnabled.Any();
uninstallButton.Enabled = installButton.Enabled;
cancelButton.Enabled = false;
scanButton.Enabled = true;
blockedGamesCheckBox.Enabled = true;
blockProtectedHelpButton.Enabled = true;
useSmokeAPICheckBox.Enabled = true;
useSmokeAPIHelpButton.Enabled = true;
selectionTreeView.Enabled = !Selection.All.IsEmpty;
allCheckBox.Enabled = selectionTreeView.Enabled;
noneFoundLabel.Visible = !selectionTreeView.Enabled;
installButton.Enabled = Selection.AllEnabled.Any();
uninstallButton.Enabled = installButton.Enabled;
scanButton.Enabled = true;
useSmokeApiToggle.Enabled = true;
useSmokeAPIHelpButton.Enabled = true;
}
catch (Exception ex)
{
@@ -822,11 +814,8 @@ internal sealed partial class SelectForm : CustomForm
// Show error and clean up
ex.HandleException(this);
HideProgressBar();
cancelButton.Enabled = false;
scanButton.Enabled = true;
blockedGamesCheckBox.Enabled = true;
blockProtectedHelpButton.Enabled = true;
useSmokeAPICheckBox.Enabled = true;
useSmokeApiToggle.Enabled = true;
useSmokeAPIHelpButton.Enabled = true;
}
}
@@ -1356,7 +1345,6 @@ internal sealed partial class SelectForm : CustomForm
"Are you sure you want to uninstall everything?\n\nThis will remove all DLC unlockers, CreamAPI, SmokeAPI, ScreamAPI, and proxy DLLs from all games.",
acceptButtonText: "Uninstall All", cancelButtonText: "Cancel", customFormText: "Uninstall All") != DialogResult.OK)
return;
cancelButton.Enabled = true;
scanButton.Enabled = false;
installButton.Enabled = false;
uninstallButton.Enabled = false;
@@ -1390,12 +1378,6 @@ internal sealed partial class SelectForm : CustomForm
private void OnScan(object sender, EventArgs e) => OnLoad(forceProvideChoices: true);
private void OnCancel(object sender, EventArgs e)
{
progressLabel.Text = "Cancelling . . . ";
Program.Cleanup();
}
private void OnAllCheckBoxChanged(object sender, EventArgs e)
{
bool shouldEnable = Selection.All.Keys.Any(s => !s.Enabled);
@@ -1410,17 +1392,6 @@ internal sealed partial class SelectForm : CustomForm
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
}
private void OnProxyAllCheckBoxChanged(object sender, EventArgs e)
{
bool shouldEnable = Selection.All.Keys.Any(selection => !selection.UseProxy);
foreach (Selection selection in Selection.All.Keys)
selection.UseProxy = shouldEnable;
selectionTreeView.Invalidate();
proxyAllCheckBox.CheckedChanged -= OnProxyAllCheckBoxChanged;
proxyAllCheckBox.Checked = shouldEnable;
proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
}
private void LoadSelections()
{
List<(Platform platform, string id, string proxy, bool enabled)> proxyChoices =
@@ -1557,9 +1528,6 @@ internal sealed partial class SelectForm : CustomForm
internal void OnProxyChanged()
{
selectionTreeView.Invalidate();
proxyAllCheckBox.CheckedChanged -= OnProxyAllCheckBoxChanged;
proxyAllCheckBox.Checked = Selection.All.Keys.Count != 0 && Selection.All.Keys.All(selection => selection.UseProxy);
proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
}
internal void OnExtraProtectionChanged()
@@ -1567,40 +1535,10 @@ internal sealed partial class SelectForm : CustomForm
selectionTreeView.Invalidate();
}
private void OnBlockProtectedGamesCheckBoxChanged(object sender, EventArgs e)
private void OnUseSmokeApiToggleChanged(object sender, EventArgs e)
{
Program.BlockProtectedGames = blockedGamesCheckBox.Checked;
OnLoad(forceProvideChoices: true);
}
private void OnBlockProtectedGamesHelpButtonClicked(object sender, EventArgs e)
{
StringBuilder blockedGames = new();
foreach (string name in Program.ProtectedGames)
_ = blockedGames.Append(HelpButtonListPrefix + name);
StringBuilder blockedDirectories = new();
foreach (string path in Program.ProtectedGameDirectories)
_ = blockedDirectories.Append(HelpButtonListPrefix + path);
StringBuilder blockedDirectoryExceptions = new();
foreach (string name in Program.ProtectedGameDirectoryExceptions)
_ = blockedDirectoryExceptions.Append(HelpButtonListPrefix + name);
using DialogForm form = new(this);
_ = form.Show(SystemIcons.Information,
"Blocks the program from caching and displaying games protected by anti-cheats."
+ "\nYou disable this option and install DLC unlockers to protected games at your own risk!" +
"\n\nBlocked games: "
+ (string.IsNullOrWhiteSpace(blockedGames.ToString()) ? "(none)" : blockedGames) +
"\n\nBlocked game sub-directories: "
+ (string.IsNullOrWhiteSpace(blockedDirectories.ToString()) ? "(none)" : blockedDirectories) +
"\n\nBlocked game sub-directory exceptions: "
+ (string.IsNullOrWhiteSpace(blockedDirectoryExceptions.ToString())
? "(none)"
: blockedDirectoryExceptions),
customFormText: "Block Protected Games");
}
private void OnUseSmokeAPICheckBoxChanged(object sender, EventArgs e)
{
Program.UseSmokeAPI = useSmokeAPICheckBox.Checked;
Program.UseSmokeAPI = useSmokeApiToggle.Checked;
useSmokeApiLabel.Text = useSmokeApiToggle.Checked ? "SmokeAPI" : "CreamAPI";
selectionTreeView.Invalidate();
}
@@ -1614,26 +1552,19 @@ internal sealed partial class SelectForm : CustomForm
customFormText: "Use SmokeAPI");
}
private void OnSortCheckBoxChanged(object sender, EventArgs e)
=> selectionTreeView.TreeViewNodeSorter =
sortCheckBox.Checked ? PlatformIdComparer.NodeText : PlatformIdComparer.NodeName;
private void programsGroupBox_Enter(object sender, EventArgs e) { }
private void programsGroupBox_Enter(object sender, EventArgs e)
{
}
private void OnDarkModeCheckBoxChanged(object sender, EventArgs e)
{
Program.DarkModeEnabled = darkModeCheckBox.Checked;
ThemeManager.ApplyToAllOpenForms();
}
private void OnSettingsButtonClick(object sender, EventArgs e)
=> SettingsForm.Show(this);
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
ThemeManager.Apply(this);
if (darkModeCheckBox is not null)
darkModeCheckBox.Checked = Program.DarkModeEnabled;
if (useSmokeApiToggle is not null)
{
useSmokeApiToggle.Checked = Program.UseSmokeAPI;
useSmokeApiLabel.Text = Program.UseSmokeAPI ? "SmokeAPI" : "CreamAPI";
}
}
}
+105
View File
@@ -0,0 +1,105 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace CreamInstaller.Forms;
partial class SettingsForm
{
private IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && components is not null)
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
darkModeCheckBox = new CheckBox();
blockedGamesCheckBox = new CheckBox();
sortByNameCheckBox = new CheckBox();
saveButton = new Button();
cancelButton = new Button();
SuspendLayout();
//
// darkModeCheckBox
//
darkModeCheckBox.AutoSize = true;
darkModeCheckBox.Location = new Point(20, 20);
darkModeCheckBox.Name = "darkModeCheckBox";
darkModeCheckBox.Size = new Size(120, 19);
darkModeCheckBox.TabIndex = 0;
darkModeCheckBox.Text = "Enable Dark Mode";
darkModeCheckBox.UseVisualStyleBackColor = true;
//
// blockedGamesCheckBox
//
blockedGamesCheckBox.AutoSize = true;
blockedGamesCheckBox.Location = new Point(20, 50);
blockedGamesCheckBox.Name = "blockedGamesCheckBox";
blockedGamesCheckBox.Size = new Size(148, 19);
blockedGamesCheckBox.TabIndex = 1;
blockedGamesCheckBox.Text = "Block Protected Games";
blockedGamesCheckBox.UseVisualStyleBackColor = true;
//
// sortByNameCheckBox
//
sortByNameCheckBox.AutoSize = true;
sortByNameCheckBox.Location = new Point(20, 80);
sortByNameCheckBox.Name = "sortByNameCheckBox";
sortByNameCheckBox.Size = new Size(160, 19);
sortByNameCheckBox.TabIndex = 2;
sortByNameCheckBox.Text = "Sort game list by name";
sortByNameCheckBox.UseVisualStyleBackColor = true;
//
// saveButton
//
saveButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
saveButton.AutoSize = true;
saveButton.Location = new Point(198, 115);
saveButton.Name = "saveButton";
saveButton.Size = new Size(75, 25);
saveButton.TabIndex = 3;
saveButton.Text = "Save";
saveButton.UseVisualStyleBackColor = true;
saveButton.Click += OnSaveClick;
//
// cancelButton
//
cancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
cancelButton.AutoSize = true;
cancelButton.Location = new Point(279, 115);
cancelButton.Name = "cancelButton";
cancelButton.Size = new Size(75, 25);
cancelButton.TabIndex = 4;
cancelButton.Text = "Cancel";
cancelButton.UseVisualStyleBackColor = true;
cancelButton.Click += OnCancelClick;
//
// SettingsForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(370, 155);
Controls.Add(cancelButton);
Controls.Add(saveButton);
Controls.Add(sortByNameCheckBox);
Controls.Add(blockedGamesCheckBox);
Controls.Add(darkModeCheckBox);
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
Name = "SettingsForm";
StartPosition = FormStartPosition.CenterParent;
ResumeLayout(false);
PerformLayout();
}
private CheckBox darkModeCheckBox;
private CheckBox blockedGamesCheckBox;
private CheckBox sortByNameCheckBox;
private Button saveButton;
private Button cancelButton;
}
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using CreamInstaller.Components;
using CreamInstaller.Utility;
namespace CreamInstaller.Forms;
internal sealed partial class SettingsForm : CustomForm
{
private bool wasDarkModeEnabled;
private SettingsForm()
{
InitializeComponent();
Text = "Settings";
}
internal static void Show(Form owner)
{
using SettingsForm form = new();
form.Owner = owner;
form.StartPosition = FormStartPosition.CenterParent;
form.LoadSettings();
form.ShowDialog(owner);
}
private void LoadSettings()
{
darkModeCheckBox.Checked = Program.DarkModeEnabled;
blockedGamesCheckBox.Checked = Program.BlockProtectedGames;
sortByNameCheckBox.Checked = Program.SortByName;
wasDarkModeEnabled = Program.DarkModeEnabled;
}
private void OnSaveClick(object sender, EventArgs e)
{
Program.DarkModeEnabled = darkModeCheckBox.Checked;
Program.BlockProtectedGames = blockedGamesCheckBox.Checked;
Program.SortByName = sortByNameCheckBox.Checked;
ProgramData.SaveSettings(Program.AppSettings);
if (wasDarkModeEnabled != darkModeCheckBox.Checked)
ThemeManager.ApplyToAllOpenForms();
DialogResult = DialogResult.OK;
Close();
}
private void OnCancelClick(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
+33 -11
View File
@@ -38,17 +38,37 @@ internal static class Program
internal static readonly string CurrentProcessFilePath = CurrentProcess.MainModule?.FileName ?? "";
internal static readonly int CurrentProcessId = CurrentProcess.Id;
// Setting is now toggleable. Huzzah!
internal static bool UseSmokeAPI = true;
// Settings loaded from ProgramData on startup — persisted across sessions
internal static SettingsModel AppSettings { get; private set; } = new();
internal static bool UseSmokeAPI
{
get => AppSettings.UseSmokeAPI;
set => AppSettings.UseSmokeAPI = value;
}
internal static bool BlockProtectedGames
{
get => AppSettings.BlockProtectedGames;
set => AppSettings.BlockProtectedGames = value;
}
internal static bool DarkModeEnabled
{
get => AppSettings.DarkModeEnabled;
set => AppSettings.DarkModeEnabled = value;
}
internal static bool SortByName
{
get => AppSettings.SortByName;
set => AppSettings.SortByName = value;
}
internal static bool BlockProtectedGames = true;
internal static readonly string[] ProtectedGames = ["PAYDAY 2"];
internal static readonly string[] ProtectedGameDirectories = [@"\EasyAntiCheat", @"\BattlEye"];
internal static readonly string[] ProtectedGameDirectoryExceptions = [];
// Dark mode enabled by default
internal static bool DarkModeEnabled = true;
internal static bool IsGameBlocked(string name, string? directory = null)
=> GetGameBlockedReason(name, directory) is not null;
@@ -83,13 +103,14 @@ internal static class Program
{
try
{
HttpClientManager.Setup();
using UpdateForm form = new();
HttpClientManager.Setup();
AppSettings = ProgramData.LoadSettings(); // load persisted settings
using UpdateForm form = new();
#if DEBUG
DebugForm.Current.Attach(form);
DebugForm.Current.Attach(form);
#endif
// Apply initial theme (dark by default)
Utility.ThemeManager.Apply(form);
// Apply initial theme (dark by default)
Utility.ThemeManager.Apply(form);
Application.Run(form);
retry = false;
}
@@ -167,6 +188,7 @@ internal static class Program
}
finally
{
ProgramData.SaveSettings(AppSettings);
HttpClientManager.Dispose();
}
}
+1 -1
View File
@@ -75,7 +75,7 @@ internal sealed class Selection : IEquatable<Selection>
if (selectForm is null)
return;
Enabled = selectForm.allCheckBox.Checked;
UseProxy = selectForm.proxyAllCheckBox.Checked;
UseProxy = false;
}
internal static IEnumerable<Selection> AllEnabled => All.Keys.Where(s => s.Enabled);
+28
View File
@@ -79,6 +79,7 @@ internal static class ProgramData
private static readonly string KoaloaderProxyChoicesPath = CachePath + @"\proxies.json";
private static readonly string ExtraProtectionChoicesPath = CachePath + @"\extraprotection.json";
private static readonly string InstalledGamesPath = CachePath + @"\installed.json";
private static readonly string SettingsPath = CachePath + @"\settings.json";
private static readonly string LogsPath = DirectoryPath + @"\Logs";
internal static readonly string ScanLogPath = LogsPath + @"\game-scan.log";
@@ -473,4 +474,31 @@ internal static event Action<LogEventArgs> OnLog;
if (records.RemoveAll(r => r.Platform == platform && r.Id == id) > 0)
WriteInstalledGames(records);
}
internal static SettingsModel LoadSettings()
{
try
{
if (JsonConvert.DeserializeObject<SettingsModel>(SettingsPath.ReadFile()) is SettingsModel settings)
return settings;
}
catch
{
// ignored
}
return new SettingsModel();
}
internal static void SaveSettings(SettingsModel settings)
{
try
{
SettingsPath.WriteFile(JsonConvert.SerializeObject(settings, Formatting.Indented));
}
catch
{
// ignored
}
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace CreamInstaller.Utility;
internal sealed class SettingsModel
{
public bool UseSmokeAPI { get; set; } = true;
public bool BlockProtectedGames { get; set; } = true;
public bool DarkModeEnabled { get; set; } = true;
public bool SortByName { get; set; } = true;
}