- Fixed all check box not getting automatically checked when unknown DLC were present
- Added a save & load feature for DLC selections
- Added a button to reset DLC selections to default
- Optimized koaloader proxy saving & loading
- Added a button to reset koaloader proxies to default
- Minor refactoring
This commit is contained in:
pointfeev 2022-09-24 04:10:43 -04:00
parent b540d06dc5
commit 9a1d92239b
8 changed files with 360 additions and 167 deletions

View file

@ -155,12 +155,13 @@ internal class CustomTreeView : TreeView
this.checkBoxBounds[selection] = RectangleToClient(checkBoxBounds); this.checkBoxBounds[selection] = RectangleToClient(checkBoxBounds);
if (selection.Koaloader && selection.KoaloaderProxy is not null) string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy;
if (selection.Koaloader && proxy is not null)
{ {
comboBoxFont ??= new(font.FontFamily, 6, font.Style, font.Unit, font.GdiCharSet, font.GdiVerticalFont); comboBoxFont ??= new(font.FontFamily, 6, font.Style, font.Unit, font.GdiCharSet, font.GdiVerticalFont);
ComboBoxState comboBoxState = Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled; ComboBoxState comboBoxState = Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled;
text = selection.KoaloaderProxy + ".dll"; text = proxy + ".dll";
size = TextRenderer.MeasureText(graphics, text, comboBoxFont) + new Size(6, 0); size = TextRenderer.MeasureText(graphics, text, comboBoxFont) + new Size(6, 0);
int padding = 2; int padding = 2;
bounds = new(bounds.X + bounds.Width, bounds.Y + padding / 2, size.Width, bounds.Height - padding); bounds = new(bounds.X + bounds.Width, bounds.Y + padding / 2, size.Width, bounds.Height - padding);
@ -237,7 +238,7 @@ internal class CustomTreeView : TreeView
if (canUse) if (canUse)
_ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (s, e) => _ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (s, e) =>
{ {
pair.Key.KoaloaderProxy = proxy; pair.Key.KoaloaderProxy = proxy == ProgramSelection.DefaultKoaloaderProxy ? null : proxy;
ProgramData.UpdateKoaloaderProxyChoices(); ProgramData.UpdateKoaloaderProxyChoices();
Invalidate(); Invalidate();
}) })

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.5.2</Version> <Version>4.2.0.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

@ -4,7 +4,6 @@ using CreamInstaller.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
@ -41,7 +40,7 @@ internal partial class SelectDialogForm : CustomForm
allCheckBox.Enabled = true; allCheckBox.Enabled = true;
acceptButton.Enabled = selected.Any(); acceptButton.Enabled = selected.Any();
saveButton.Enabled = acceptButton.Enabled; saveButton.Enabled = acceptButton.Enabled;
loadButton.Enabled = ProgramData.ReadChoices() is not null; loadButton.Enabled = ProgramData.ReadProgramChoices() is not null;
OnResize(null, null); OnResize(null, null);
Resize += OnResize; Resize += OnResize;
return ShowDialog() == DialogResult.OK ? selected : null; return ShowDialog() == DialogResult.OK ? selected : null;
@ -92,7 +91,7 @@ internal partial class SelectDialogForm : CustomForm
private void OnLoad(object sender, EventArgs e) private void OnLoad(object sender, EventArgs e)
{ {
List<(Platform platform, string id)> choices = ProgramData.ReadChoices(); List<(Platform platform, string id)> choices = ProgramData.ReadProgramChoices();
if (choices is null) return; if (choices is null) return;
foreach (TreeNode node in selectionTreeView.Nodes) foreach (TreeNode node in selectionTreeView.Nodes)
{ {
@ -106,7 +105,7 @@ internal partial class SelectDialogForm : CustomForm
List<(Platform platform, string id)> choices = new(); List<(Platform platform, string id)> choices = new();
foreach (TreeNode node in selectionTreeView.Nodes.Cast<TreeNode>().Where(n => n.Checked)) foreach (TreeNode node in selectionTreeView.Nodes.Cast<TreeNode>().Where(n => n.Checked))
choices.Add(((Platform)node.Tag, node.Name)); choices.Add(((Platform)node.Tag, node.Name));
ProgramData.WriteChoices(choices); ProgramData.WriteProgramChoices(choices);
loadButton.Enabled = File.Exists(ProgramData.ChoicesPath); loadButton.Enabled = ProgramData.ReadProgramChoices() is not null;
} }
} }

View file

@ -20,25 +20,29 @@ namespace CreamInstaller
private void InitializeComponent() private void InitializeComponent()
{ {
this.installButton = new(); this.installButton = new System.Windows.Forms.Button();
this.cancelButton = new(); this.cancelButton = new System.Windows.Forms.Button();
this.programsGroupBox = new(); this.programsGroupBox = new System.Windows.Forms.GroupBox();
this.koaloaderFlowPanel = new(); this.koaloaderFlowPanel = new System.Windows.Forms.FlowLayoutPanel();
this.koaloaderAllCheckBox = new(); this.koaloaderAllCheckBox = new System.Windows.Forms.CheckBox();
this.noneFoundLabel = new(); this.noneFoundLabel = new System.Windows.Forms.Label();
this.blockedGamesFlowPanel = new(); this.blockedGamesFlowPanel = new System.Windows.Forms.FlowLayoutPanel();
this.blockedGamesCheckBox = new(); this.blockedGamesCheckBox = new System.Windows.Forms.CheckBox();
this.blockProtectedHelpButton = new(); this.blockProtectedHelpButton = new System.Windows.Forms.Button();
this.selectionTreeView = new(); this.selectionTreeView = new CreamInstaller.Components.CustomTreeView();
this.allCheckBoxLayoutPanel = new(); this.allCheckBoxLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.allCheckBox = new(); this.allCheckBox = new System.Windows.Forms.CheckBox();
this.progressBar = new(); this.progressBar = new System.Windows.Forms.ProgressBar();
this.progressLabel = new(); this.progressLabel = new System.Windows.Forms.Label();
this.scanButton = new(); this.scanButton = new System.Windows.Forms.Button();
this.uninstallButton = new(); this.uninstallButton = new System.Windows.Forms.Button();
this.progressLabelGames = new(); this.progressLabelGames = new System.Windows.Forms.Label();
this.progressLabelDLCs = new(); this.progressLabelDLCs = new System.Windows.Forms.Label();
this.sortCheckBox = new(); this.sortCheckBox = new System.Windows.Forms.CheckBox();
this.saveButton = new System.Windows.Forms.Button();
this.loadButton = new System.Windows.Forms.Button();
this.resetKoaloaderButton = new System.Windows.Forms.Button();
this.resetButton = new System.Windows.Forms.Button();
this.programsGroupBox.SuspendLayout(); this.programsGroupBox.SuspendLayout();
this.koaloaderFlowPanel.SuspendLayout(); this.koaloaderFlowPanel.SuspendLayout();
this.blockedGamesFlowPanel.SuspendLayout(); this.blockedGamesFlowPanel.SuspendLayout();
@ -47,85 +51,87 @@ namespace CreamInstaller
// //
// installButton // installButton
// //
this.installButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right))); this.installButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.installButton.AutoSize = true; this.installButton.AutoSize = true;
this.installButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.installButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.installButton.Enabled = false; this.installButton.Enabled = false;
this.installButton.FlatStyle = FlatStyle.System; this.installButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.installButton.Location = new Point(420, 325); this.installButton.Location = new System.Drawing.Point(423, 325);
this.installButton.Name = "installButton"; this.installButton.Name = "installButton";
this.installButton.Padding = new(12, 0, 12, 0); this.installButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.installButton.Size = new Size(149, 24); this.installButton.Size = new System.Drawing.Size(149, 24);
this.installButton.TabIndex = 10004; this.installButton.TabIndex = 10004;
this.installButton.Text = "Generate and Install"; this.installButton.Text = "Generate and Install";
this.installButton.UseVisualStyleBackColor = true; this.installButton.UseVisualStyleBackColor = true;
this.installButton.Click += this.OnInstall; this.installButton.Click += new System.EventHandler(this.OnInstall);
// //
// cancelButton // cancelButton
// //
this.cancelButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Left))); this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cancelButton.AutoSize = true; this.cancelButton.AutoSize = true;
this.cancelButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.cancelButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.cancelButton.FlatStyle = FlatStyle.System; this.cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cancelButton.Location = new Point(12, 325); this.cancelButton.Location = new System.Drawing.Point(12, 325);
this.cancelButton.Name = "cancelButton"; this.cancelButton.Name = "cancelButton";
this.cancelButton.Padding = new(12, 0, 12, 0); this.cancelButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.cancelButton.Size = new Size(81, 24); this.cancelButton.Size = new System.Drawing.Size(81, 24);
this.cancelButton.TabIndex = 10000; this.cancelButton.TabIndex = 10000;
this.cancelButton.Text = "Cancel"; this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true; this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += this.OnCancel; this.cancelButton.Click += new System.EventHandler(this.OnCancel);
// //
// programsGroupBox // programsGroupBox
// //
this.programsGroupBox.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))); this.programsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.programsGroupBox.Controls.Add(this.koaloaderFlowPanel); this.programsGroupBox.Controls.Add(this.koaloaderFlowPanel);
this.programsGroupBox.Controls.Add(this.noneFoundLabel); this.programsGroupBox.Controls.Add(this.noneFoundLabel);
this.programsGroupBox.Controls.Add(this.blockedGamesFlowPanel); this.programsGroupBox.Controls.Add(this.blockedGamesFlowPanel);
this.programsGroupBox.Controls.Add(this.selectionTreeView); this.programsGroupBox.Controls.Add(this.selectionTreeView);
this.programsGroupBox.Controls.Add(this.allCheckBoxLayoutPanel); this.programsGroupBox.Controls.Add(this.allCheckBoxLayoutPanel);
this.programsGroupBox.FlatStyle = FlatStyle.System; this.programsGroupBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.programsGroupBox.Location = new Point(12, 12); this.programsGroupBox.Location = new System.Drawing.Point(12, 12);
this.programsGroupBox.Name = "programsGroupBox"; this.programsGroupBox.Name = "programsGroupBox";
this.programsGroupBox.Size = new Size(560, 239); this.programsGroupBox.Size = new System.Drawing.Size(560, 209);
this.programsGroupBox.TabIndex = 8; this.programsGroupBox.TabIndex = 8;
this.programsGroupBox.TabStop = false; this.programsGroupBox.TabStop = false;
this.programsGroupBox.Text = "Programs / Games"; this.programsGroupBox.Text = "Programs / Games";
// //
// koaloaderFlowPanel // koaloaderFlowPanel
// //
this.koaloaderFlowPanel.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right))); this.koaloaderFlowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.koaloaderFlowPanel.AutoSize = true; this.koaloaderFlowPanel.AutoSize = true;
this.koaloaderFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.koaloaderFlowPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.koaloaderFlowPanel.Controls.Add(this.koaloaderAllCheckBox); this.koaloaderFlowPanel.Controls.Add(this.koaloaderAllCheckBox);
this.koaloaderFlowPanel.Location = new Point(430, -1); this.koaloaderFlowPanel.Location = new System.Drawing.Point(430, -1);
this.koaloaderFlowPanel.Margin = new(0); this.koaloaderFlowPanel.Margin = new System.Windows.Forms.Padding(0);
this.koaloaderFlowPanel.Name = "koaloaderFlowPanel"; this.koaloaderFlowPanel.Name = "koaloaderFlowPanel";
this.koaloaderFlowPanel.Size = new Size(73, 19); this.koaloaderFlowPanel.Size = new System.Drawing.Size(73, 19);
this.koaloaderFlowPanel.TabIndex = 10005; this.koaloaderFlowPanel.TabIndex = 10005;
this.koaloaderFlowPanel.WrapContents = false; this.koaloaderFlowPanel.WrapContents = false;
// //
// koaloaderAllCheckBox // koaloaderAllCheckBox
// //
this.koaloaderAllCheckBox.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right))); this.koaloaderAllCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.koaloaderAllCheckBox.Checked = true; this.koaloaderAllCheckBox.Checked = true;
this.koaloaderAllCheckBox.CheckState = CheckState.Checked; this.koaloaderAllCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.koaloaderAllCheckBox.Enabled = false; this.koaloaderAllCheckBox.Enabled = false;
this.koaloaderAllCheckBox.FlatStyle = FlatStyle.System; this.koaloaderAllCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.koaloaderAllCheckBox.Location = new Point(2, 0); this.koaloaderAllCheckBox.Location = new System.Drawing.Point(2, 0);
this.koaloaderAllCheckBox.Margin = new(2, 0, 0, 0); this.koaloaderAllCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
this.koaloaderAllCheckBox.Name = "koaloaderAllCheckBox"; this.koaloaderAllCheckBox.Name = "koaloaderAllCheckBox";
this.koaloaderAllCheckBox.Size = new Size(71, 19); this.koaloaderAllCheckBox.Size = new System.Drawing.Size(71, 19);
this.koaloaderAllCheckBox.TabIndex = 4; this.koaloaderAllCheckBox.TabIndex = 4;
this.koaloaderAllCheckBox.Text = "Koaloader"; this.koaloaderAllCheckBox.Text = "Koaloader";
this.koaloaderAllCheckBox.CheckedChanged += this.OnKoaloaderAllCheckBoxChanged; this.koaloaderAllCheckBox.CheckedChanged += new System.EventHandler(this.OnKoaloaderAllCheckBoxChanged);
// //
// noneFoundLabel // noneFoundLabel
// //
this.noneFoundLabel.Dock = DockStyle.Fill; this.noneFoundLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.noneFoundLabel.Location = new Point(3, 19); this.noneFoundLabel.Location = new System.Drawing.Point(3, 19);
this.noneFoundLabel.Name = "noneFoundLabel"; this.noneFoundLabel.Name = "noneFoundLabel";
this.noneFoundLabel.Size = new Size(554, 217); this.noneFoundLabel.Size = new System.Drawing.Size(554, 187);
this.noneFoundLabel.TabIndex = 1002; this.noneFoundLabel.TabIndex = 1002;
this.noneFoundLabel.Text = "No applicable programs nor games were found on your computer!"; this.noneFoundLabel.Text = "No applicable programs nor games were found on your computer!";
this.noneFoundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.noneFoundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -133,46 +139,46 @@ namespace CreamInstaller
// //
// blockedGamesFlowPanel // blockedGamesFlowPanel
// //
this.blockedGamesFlowPanel.Anchor = AnchorStyles.Top; this.blockedGamesFlowPanel.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.blockedGamesFlowPanel.AutoSize = true; this.blockedGamesFlowPanel.AutoSize = true;
this.blockedGamesFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.blockedGamesFlowPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.blockedGamesFlowPanel.Controls.Add(this.blockedGamesCheckBox); this.blockedGamesFlowPanel.Controls.Add(this.blockedGamesCheckBox);
this.blockedGamesFlowPanel.Controls.Add(this.blockProtectedHelpButton); this.blockedGamesFlowPanel.Controls.Add(this.blockProtectedHelpButton);
this.blockedGamesFlowPanel.Location = new Point(125, -1); this.blockedGamesFlowPanel.Location = new System.Drawing.Point(125, -1);
this.blockedGamesFlowPanel.Margin = new(0); this.blockedGamesFlowPanel.Margin = new System.Windows.Forms.Padding(0);
this.blockedGamesFlowPanel.Name = "blockedGamesFlowPanel"; this.blockedGamesFlowPanel.Name = "blockedGamesFlowPanel";
this.blockedGamesFlowPanel.Size = new Size(162, 20); this.blockedGamesFlowPanel.Size = new System.Drawing.Size(162, 20);
this.blockedGamesFlowPanel.TabIndex = 1005; this.blockedGamesFlowPanel.TabIndex = 1005;
this.blockedGamesFlowPanel.WrapContents = false; this.blockedGamesFlowPanel.WrapContents = false;
// //
// blockedGamesCheckBox // blockedGamesCheckBox
// //
this.blockedGamesCheckBox.Checked = true; this.blockedGamesCheckBox.Checked = true;
this.blockedGamesCheckBox.CheckState = CheckState.Checked; this.blockedGamesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.blockedGamesCheckBox.Enabled = false; this.blockedGamesCheckBox.Enabled = false;
this.blockedGamesCheckBox.FlatStyle = FlatStyle.System; this.blockedGamesCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.blockedGamesCheckBox.Location = new Point(2, 0); this.blockedGamesCheckBox.Location = new System.Drawing.Point(2, 0);
this.blockedGamesCheckBox.Margin = new(2, 0, 0, 0); this.blockedGamesCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
this.blockedGamesCheckBox.Name = "blockedGamesCheckBox"; this.blockedGamesCheckBox.Name = "blockedGamesCheckBox";
this.blockedGamesCheckBox.Size = new Size(140, 20); this.blockedGamesCheckBox.Size = new System.Drawing.Size(140, 20);
this.blockedGamesCheckBox.TabIndex = 1; this.blockedGamesCheckBox.TabIndex = 1;
this.blockedGamesCheckBox.Text = "Block Protected Games"; this.blockedGamesCheckBox.Text = "Block Protected Games";
this.blockedGamesCheckBox.UseVisualStyleBackColor = true; this.blockedGamesCheckBox.UseVisualStyleBackColor = true;
this.blockedGamesCheckBox.CheckedChanged += this.OnBlockProtectedGamesCheckBoxChanged; this.blockedGamesCheckBox.CheckedChanged += new System.EventHandler(this.OnBlockProtectedGamesCheckBoxChanged);
// //
// blockProtectedHelpButton // blockProtectedHelpButton
// //
this.blockProtectedHelpButton.Enabled = false; this.blockProtectedHelpButton.Enabled = false;
this.blockProtectedHelpButton.FlatStyle = FlatStyle.System; this.blockProtectedHelpButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.blockProtectedHelpButton.Font = new Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.blockProtectedHelpButton.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.blockProtectedHelpButton.Location = new Point(142, 0); this.blockProtectedHelpButton.Location = new System.Drawing.Point(142, 0);
this.blockProtectedHelpButton.Margin = new(0, 0, 1, 0); this.blockProtectedHelpButton.Margin = new System.Windows.Forms.Padding(0, 0, 1, 0);
this.blockProtectedHelpButton.Name = "blockProtectedHelpButton"; this.blockProtectedHelpButton.Name = "blockProtectedHelpButton";
this.blockProtectedHelpButton.Size = new Size(19, 19); this.blockProtectedHelpButton.Size = new System.Drawing.Size(19, 19);
this.blockProtectedHelpButton.TabIndex = 2; this.blockProtectedHelpButton.TabIndex = 2;
this.blockProtectedHelpButton.Text = "?"; this.blockProtectedHelpButton.Text = "?";
this.blockProtectedHelpButton.UseVisualStyleBackColor = true; this.blockProtectedHelpButton.UseVisualStyleBackColor = true;
this.blockProtectedHelpButton.Click += this.OnBlockProtectedGamesHelpButtonClicked; this.blockProtectedHelpButton.Click += new System.EventHandler(this.OnBlockProtectedGamesHelpButtonClicked);
// //
// selectionTreeView // selectionTreeView
// //
@ -191,121 +197,193 @@ namespace CreamInstaller
// //
// allCheckBoxLayoutPanel // allCheckBoxLayoutPanel
// //
this.allCheckBoxLayoutPanel.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right))); this.allCheckBoxLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.allCheckBoxLayoutPanel.AutoSize = true; this.allCheckBoxLayoutPanel.AutoSize = true;
this.allCheckBoxLayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.allCheckBoxLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.allCheckBoxLayoutPanel.Controls.Add(this.allCheckBox); this.allCheckBoxLayoutPanel.Controls.Add(this.allCheckBox);
this.allCheckBoxLayoutPanel.Location = new Point(520, -1); this.allCheckBoxLayoutPanel.Location = new System.Drawing.Point(520, -1);
this.allCheckBoxLayoutPanel.Margin = new(0); this.allCheckBoxLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
this.allCheckBoxLayoutPanel.Name = "allCheckBoxLayoutPanel"; this.allCheckBoxLayoutPanel.Name = "allCheckBoxLayoutPanel";
this.allCheckBoxLayoutPanel.Size = new Size(34, 19); this.allCheckBoxLayoutPanel.Size = new System.Drawing.Size(34, 19);
this.allCheckBoxLayoutPanel.TabIndex = 1006; this.allCheckBoxLayoutPanel.TabIndex = 1006;
this.allCheckBoxLayoutPanel.WrapContents = false; this.allCheckBoxLayoutPanel.WrapContents = false;
// //
// allCheckBox // allCheckBox
// //
this.allCheckBox.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right))); this.allCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.allCheckBox.Checked = true; this.allCheckBox.Checked = true;
this.allCheckBox.CheckState = CheckState.Checked; this.allCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.allCheckBox.Enabled = false; this.allCheckBox.Enabled = false;
this.allCheckBox.FlatStyle = FlatStyle.System; this.allCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.allCheckBox.Location = new Point(2, 0); this.allCheckBox.Location = new System.Drawing.Point(2, 0);
this.allCheckBox.Margin = new(2, 0, 0, 0); this.allCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
this.allCheckBox.Name = "allCheckBox"; this.allCheckBox.Name = "allCheckBox";
this.allCheckBox.Size = new Size(32, 19); this.allCheckBox.Size = new System.Drawing.Size(32, 19);
this.allCheckBox.TabIndex = 4; this.allCheckBox.TabIndex = 4;
this.allCheckBox.Text = "All"; this.allCheckBox.Text = "All";
this.allCheckBox.CheckedChanged += this.OnAllCheckBoxChanged; this.allCheckBox.CheckedChanged += new System.EventHandler(this.OnAllCheckBoxChanged);
// //
// progressBar // progressBar
// //
this.progressBar.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right))); this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.progressBar.Location = new Point(12, 296); | System.Windows.Forms.AnchorStyles.Right)));
this.progressBar.Location = new System.Drawing.Point(12, 266);
this.progressBar.Name = "progressBar"; this.progressBar.Name = "progressBar";
this.progressBar.Size = new Size(560, 23); this.progressBar.Size = new System.Drawing.Size(560, 23);
this.progressBar.TabIndex = 9; this.progressBar.TabIndex = 9;
// //
// progressLabel // progressLabel
// //
this.progressLabel.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right))); this.progressLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.progressLabel.Location = new Point(12, 254); | System.Windows.Forms.AnchorStyles.Right)));
this.progressLabel.Location = new System.Drawing.Point(12, 224);
this.progressLabel.Name = "progressLabel"; this.progressLabel.Name = "progressLabel";
this.progressLabel.Size = new Size(560, 15); this.progressLabel.Size = new System.Drawing.Size(560, 15);
this.progressLabel.TabIndex = 10; this.progressLabel.TabIndex = 10;
this.progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . 0%"; this.progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . 0%";
// //
// scanButton // scanButton
// //
this.scanButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right))); this.scanButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.scanButton.AutoSize = true; this.scanButton.AutoSize = true;
this.scanButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.scanButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.scanButton.Enabled = false; this.scanButton.Enabled = false;
this.scanButton.FlatStyle = FlatStyle.System; this.scanButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.scanButton.Location = new Point(235, 325); this.scanButton.Location = new System.Drawing.Point(238, 325);
this.scanButton.Name = "scanButton"; this.scanButton.Name = "scanButton";
this.scanButton.Padding = new(12, 0, 12, 0); this.scanButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.scanButton.Size = new Size(82, 24); this.scanButton.Size = new System.Drawing.Size(82, 24);
this.scanButton.TabIndex = 10002; this.scanButton.TabIndex = 10002;
this.scanButton.Text = "Rescan"; this.scanButton.Text = "Rescan";
this.scanButton.UseVisualStyleBackColor = true; this.scanButton.UseVisualStyleBackColor = true;
this.scanButton.Click += this.OnScan; this.scanButton.Click += new System.EventHandler(this.OnScan);
// //
// uninstallButton // uninstallButton
// //
this.uninstallButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Right))); this.uninstallButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.uninstallButton.AutoSize = true; this.uninstallButton.AutoSize = true;
this.uninstallButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.uninstallButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.uninstallButton.Enabled = false; this.uninstallButton.Enabled = false;
this.uninstallButton.FlatStyle = FlatStyle.System; this.uninstallButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.uninstallButton.Location = new Point(323, 325); this.uninstallButton.Location = new System.Drawing.Point(326, 325);
this.uninstallButton.Name = "uninstallButton"; this.uninstallButton.Name = "uninstallButton";
this.uninstallButton.Padding = new(12, 0, 12, 0); this.uninstallButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.uninstallButton.Size = new Size(91, 24); this.uninstallButton.Size = new System.Drawing.Size(91, 24);
this.uninstallButton.TabIndex = 10003; this.uninstallButton.TabIndex = 10003;
this.uninstallButton.Text = "Uninstall"; this.uninstallButton.Text = "Uninstall";
this.uninstallButton.UseVisualStyleBackColor = true; this.uninstallButton.UseVisualStyleBackColor = true;
this.uninstallButton.Click += this.OnUninstall; this.uninstallButton.Click += new System.EventHandler(this.OnUninstall);
// //
// progressLabelGames // progressLabelGames
// //
this.progressLabelGames.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right))); this.progressLabelGames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.progressLabelGames.Font = new Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); | System.Windows.Forms.AnchorStyles.Right)));
this.progressLabelGames.Location = new Point(12, 269); this.progressLabelGames.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.progressLabelGames.Location = new System.Drawing.Point(12, 239);
this.progressLabelGames.Name = "progressLabelGames"; this.progressLabelGames.Name = "progressLabelGames";
this.progressLabelGames.Size = new Size(560, 12); this.progressLabelGames.Size = new System.Drawing.Size(560, 12);
this.progressLabelGames.TabIndex = 11; this.progressLabelGames.TabIndex = 11;
this.progressLabelGames.Text = "Remaining games (2): Game 1, Game 2"; this.progressLabelGames.Text = "Remaining games (2): Game 1, Game 2";
// //
// progressLabelDLCs // progressLabelDLCs
// //
this.progressLabelDLCs.Anchor = ((AnchorStyles)(((AnchorStyles.Bottom | AnchorStyles.Left) | AnchorStyles.Right))); this.progressLabelDLCs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.progressLabelDLCs.Font = new Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); | System.Windows.Forms.AnchorStyles.Right)));
this.progressLabelDLCs.Location = new Point(12, 281); this.progressLabelDLCs.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.progressLabelDLCs.Location = new System.Drawing.Point(12, 251);
this.progressLabelDLCs.Name = "progressLabelDLCs"; this.progressLabelDLCs.Name = "progressLabelDLCs";
this.progressLabelDLCs.Size = new Size(560, 12); this.progressLabelDLCs.Size = new System.Drawing.Size(560, 12);
this.progressLabelDLCs.TabIndex = 12; this.progressLabelDLCs.TabIndex = 12;
this.progressLabelDLCs.Text = "Remaining DLC (2): 123456, 654321"; this.progressLabelDLCs.Text = "Remaining DLC (2): 123456, 654321";
// //
// sortCheckBox // sortCheckBox
// //
this.sortCheckBox.Anchor = ((AnchorStyles)((AnchorStyles.Bottom | AnchorStyles.Left))); this.sortCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.sortCheckBox.AutoSize = true; this.sortCheckBox.AutoSize = true;
this.sortCheckBox.FlatStyle = FlatStyle.System; this.sortCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.sortCheckBox.Location = new Point(120, 328); this.sortCheckBox.Location = new System.Drawing.Point(120, 328);
this.sortCheckBox.Margin = new(3, 0, 0, 0); this.sortCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.sortCheckBox.Name = "sortCheckBox"; this.sortCheckBox.Name = "sortCheckBox";
this.sortCheckBox.Size = new Size(104, 20); this.sortCheckBox.Size = new System.Drawing.Size(104, 20);
this.sortCheckBox.TabIndex = 10001; this.sortCheckBox.TabIndex = 10001;
this.sortCheckBox.Text = "Sort By Name"; this.sortCheckBox.Text = "Sort By Name";
this.sortCheckBox.CheckedChanged += this.OnSortCheckBoxChanged; this.sortCheckBox.CheckedChanged += new System.EventHandler(this.OnSortCheckBoxChanged);
//
// saveButton
//
this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.saveButton.AutoSize = true;
this.saveButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.saveButton.Enabled = false;
this.saveButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.saveButton.Location = new System.Drawing.Point(376, 295);
this.saveButton.Name = "saveButton";
this.saveButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.saveButton.Size = new System.Drawing.Size(94, 24);
this.saveButton.TabIndex = 10005;
this.saveButton.Text = "Save DLC";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.OnSaveDlc);
//
// loadButton
//
this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.loadButton.AutoSize = true;
this.loadButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.loadButton.Enabled = false;
this.loadButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.loadButton.Location = new System.Drawing.Point(476, 295);
this.loadButton.Name = "loadButton";
this.loadButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.loadButton.Size = new System.Drawing.Size(96, 24);
this.loadButton.TabIndex = 10006;
this.loadButton.Text = "Load DLC";
this.loadButton.UseVisualStyleBackColor = true;
this.loadButton.Click += new System.EventHandler(this.OnLoadDlc);
//
// resetKoaloaderButton
//
this.resetKoaloaderButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.resetKoaloaderButton.AutoSize = true;
this.resetKoaloaderButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.resetKoaloaderButton.Enabled = false;
this.resetKoaloaderButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.resetKoaloaderButton.Location = new System.Drawing.Point(12, 295);
this.resetKoaloaderButton.Name = "resetKoaloaderButton";
this.resetKoaloaderButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.resetKoaloaderButton.Size = new System.Drawing.Size(129, 24);
this.resetKoaloaderButton.TabIndex = 10007;
this.resetKoaloaderButton.Text = "Reset Koaloader";
this.resetKoaloaderButton.UseVisualStyleBackColor = true;
this.resetKoaloaderButton.Click += new System.EventHandler(this.OnResetKoaloader);
//
// resetButton
//
this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.resetButton.AutoSize = true;
this.resetButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.resetButton.Enabled = false;
this.resetButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.resetButton.Location = new System.Drawing.Point(272, 295);
this.resetButton.Name = "resetButton";
this.resetButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
this.resetButton.Size = new System.Drawing.Size(98, 24);
this.resetButton.TabIndex = 10008;
this.resetButton.Text = "Reset DLC";
this.resetButton.UseVisualStyleBackColor = true;
this.resetButton.Click += new System.EventHandler(this.OnResetDlc);
// //
// SelectForm // SelectForm
// //
this.AutoScaleDimensions = new SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true; this.AutoSize = true;
this.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new Size(584, 361); this.ClientSize = new System.Drawing.Size(584, 361);
this.Controls.Add(this.resetButton);
this.Controls.Add(this.resetKoaloaderButton);
this.Controls.Add(this.loadButton);
this.Controls.Add(this.saveButton);
this.Controls.Add(this.sortCheckBox); this.Controls.Add(this.sortCheckBox);
this.Controls.Add(this.progressLabelDLCs); this.Controls.Add(this.progressLabelDLCs);
this.Controls.Add(this.progressLabelGames); this.Controls.Add(this.progressLabelGames);
@ -317,13 +395,13 @@ namespace CreamInstaller
this.Controls.Add(this.installButton); this.Controls.Add(this.installButton);
this.Controls.Add(this.progressLabel); this.Controls.Add(this.progressLabel);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.FormBorderStyle = FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "SelectForm"; this.Name = "SelectForm";
this.StartPosition = FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "SelectForm"; this.Text = "SelectForm";
this.Load += this.OnLoad; this.Load += new System.EventHandler(this.OnLoad);
this.programsGroupBox.ResumeLayout(false); this.programsGroupBox.ResumeLayout(false);
this.programsGroupBox.PerformLayout(); this.programsGroupBox.PerformLayout();
this.koaloaderFlowPanel.ResumeLayout(false); this.koaloaderFlowPanel.ResumeLayout(false);
@ -355,6 +433,10 @@ namespace CreamInstaller
private CheckBox sortCheckBox; private CheckBox sortCheckBox;
private FlowLayoutPanel koaloaderFlowPanel; private FlowLayoutPanel koaloaderFlowPanel;
private CheckBox koaloaderAllCheckBox; private CheckBox koaloaderAllCheckBox;
private Button saveButton;
private Button loadButton;
private Button resetKoaloaderButton;
private Button resetButton;
} }
} }

View file

@ -462,6 +462,10 @@ internal partial class SelectForm : CustomForm
installButton.Enabled = false; installButton.Enabled = false;
uninstallButton.Enabled = installButton.Enabled; uninstallButton.Enabled = installButton.Enabled;
selectionTreeView.Enabled = false; selectionTreeView.Enabled = false;
saveButton.Enabled = false;
loadButton.Enabled = false;
resetButton.Enabled = false;
resetKoaloaderButton.Enabled = false;
progressLabel.Text = "Waiting for user to select which programs/games to scan . . ."; progressLabel.Text = "Waiting for user to select which programs/games to scan . . .";
ShowProgressBar(); ShowProgressBar();
@ -537,7 +541,8 @@ internal partial class SelectForm : CustomForm
await SteamCMD.Cleanup(); await SteamCMD.Cleanup();
} }
ProgramData.UpdateKoaloaderProxyChoices(); ProgramData.UpdateKoaloaderProxyChoices(initial: true);
OnLoadDlc(null, null);
HideProgressBar(); HideProgressBar();
selectionTreeView.Enabled = ProgramSelection.All.Any(); selectionTreeView.Enabled = ProgramSelection.All.Any();
@ -546,6 +551,9 @@ internal partial class SelectForm : CustomForm
noneFoundLabel.Visible = !selectionTreeView.Enabled; noneFoundLabel.Visible = !selectionTreeView.Enabled;
installButton.Enabled = ProgramSelection.AllEnabled.Any(); installButton.Enabled = ProgramSelection.AllEnabled.Any();
uninstallButton.Enabled = installButton.Enabled; uninstallButton.Enabled = installButton.Enabled;
saveButton.Enabled = CanSaveDlc();
loadButton.Enabled = ProgramData.ReadDlcChoices() is not null;
resetButton.Enabled = CanResetDlc();
cancelButton.Enabled = false; cancelButton.Enabled = false;
scanButton.Enabled = true; scanButton.Enabled = true;
blockedGamesCheckBox.Enabled = true; blockedGamesCheckBox.Enabled = true;
@ -561,10 +569,12 @@ internal partial class SelectForm : CustomForm
SyncNodeAncestors(node); SyncNodeAncestors(node);
SyncNodeDescendants(node); SyncNodeDescendants(node);
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged; allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
allCheckBox.Checked = TreeNodes.TrueForAll(treeNode => treeNode.Checked); allCheckBox.Checked = TreeNodes.TrueForAll(node => node.Text == "Unknown" || node.Checked);
allCheckBox.CheckedChanged += OnAllCheckBoxChanged; allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
installButton.Enabled = ProgramSelection.AllEnabled.Any(); installButton.Enabled = ProgramSelection.AllEnabled.Any();
uninstallButton.Enabled = installButton.Enabled; uninstallButton.Enabled = installButton.Enabled;
saveButton.Enabled = CanSaveDlc();
resetButton.Enabled = CanResetDlc();
} }
private static void SyncNodeAncestors(TreeNode node) private static void SyncNodeAncestors(TreeNode node)
@ -893,6 +903,60 @@ internal partial class SelectForm : CustomForm
allCheckBox.CheckedChanged += OnAllCheckBoxChanged; allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
} }
private bool AreSelectionsDefault()
{
foreach (TreeNode node in TreeNodes)
if (node.Parent is not null && node.Tag is Platform && (node.Text == "Unknown" ? node.Checked : !node.Checked))
return false;
return true;
}
private bool CanSaveDlc() => installButton.Enabled && (ProgramData.ReadDlcChoices() is not null || !AreSelectionsDefault());
private void OnSaveDlc(object sender, EventArgs e)
{
List<(Platform platform, string gameId, string dlcId)> choices = ProgramData.ReadDlcChoices() ?? new();
foreach (TreeNode node in TreeNodes)
if (node.Parent is TreeNode parent && node.Tag is Platform platform)
{
if (node.Text == "Unknown" ? node.Checked : !node.Checked)
choices.Add((platform, node.Parent.Name, node.Name));
else
choices.RemoveAll(n => n.platform == platform && n.gameId == parent.Name && n.dlcId == node.Name);
}
choices = choices.Distinct().ToList();
ProgramData.WriteDlcChoices(choices);
loadButton.Enabled = ProgramData.ReadDlcChoices() is not null;
saveButton.Enabled = CanSaveDlc();
}
private void OnLoadDlc(object sender, EventArgs e)
{
List<(Platform platform, string gameId, string dlcId)> choices = ProgramData.ReadDlcChoices();
if (choices is null) return;
foreach (TreeNode node in TreeNodes)
if (node.Parent is TreeNode parent && node.Tag is Platform platform)
{
node.Checked = choices.Any(choice => choice.platform == platform && choice.gameId == parent.Name && choice.dlcId == node.Name)
? node.Text == "Unknown"
: node.Text != "Unknown";
OnTreeViewNodeCheckedChanged(null, new(node, TreeViewAction.ByMouse));
}
}
private bool CanResetDlc() => !AreSelectionsDefault();
private void OnResetDlc(object sender, EventArgs e)
{
foreach (TreeNode node in TreeNodes)
if (node.Parent is not null && node.Tag is Platform)
{
node.Checked = node.Text != "Unknown";
OnTreeViewNodeCheckedChanged(null, new(node, TreeViewAction.ByMouse));
}
resetButton.Enabled = CanResetDlc();
}
internal CheckBox KoaloaderAllCheckBox() => koaloaderAllCheckBox; internal CheckBox KoaloaderAllCheckBox() => koaloaderAllCheckBox;
internal void OnKoaloaderAllCheckBoxChanged(object sender, EventArgs e) internal void OnKoaloaderAllCheckBoxChanged(object sender, EventArgs e)
{ {
@ -911,6 +975,16 @@ internal partial class SelectForm : CustomForm
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged; koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged;
} }
private static bool CanResetKoaloader() => File.Exists(ProgramData.KoaloaderProxyChoicesPath);
private void OnResetKoaloader(object sender, EventArgs e) => ProgramData.ResetKoaloaderProxyChoices();
internal void OnKoaloaderProxiesChanged()
{
selectionTreeView.Invalidate();
resetKoaloaderButton.Enabled = CanResetKoaloader();
}
private void OnBlockProtectedGamesCheckBoxChanged(object sender, EventArgs e) private void OnBlockProtectedGamesCheckBoxChanged(object sender, EventArgs e)
{ {
Program.BlockProtectedGames = blockedGamesCheckBox.Checked; Program.BlockProtectedGames = blockedGamesCheckBox.Checked;

View file

@ -30,6 +30,7 @@ internal class ProgramSelection
{ {
internal bool Enabled; internal bool Enabled;
internal bool Koaloader; internal bool Koaloader;
internal const string DefaultKoaloaderProxy = "version";
internal string KoaloaderProxy; internal string KoaloaderProxy;
internal Platform Platform; internal Platform Platform;

View file

@ -157,7 +157,8 @@ internal static class Koaloader
internal static async Task Install(string directory, BinaryType binaryType, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() => internal static async Task Install(string directory, BinaryType binaryType, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() =>
{ {
directory.GetKoaloaderComponents(out List<string> proxies, out string config); directory.GetKoaloaderComponents(out List<string> proxies, out string config);
string path = directory + @"\" + selection.KoaloaderProxy + ".dll"; string proxy = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy;
string path = directory + @"\" + proxy + ".dll";
foreach (string _path in proxies.Where(p => p != path && File.Exists(p) && p.IsResourceFile(ResourceIdentifier.Koaloader))) foreach (string _path in proxies.Where(p => p != path && File.Exists(p) && p.IsResourceFile(ResourceIdentifier.Koaloader)))
{ {
File.Delete(_path); File.Delete(_path);
@ -165,8 +166,8 @@ internal static class Koaloader
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, info: false);
} }
if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader)) if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader))
throw new CustomMessageException("A non-Koaloader DLL named " + selection.KoaloaderProxy + ".dll already exists in this directory!"); throw new CustomMessageException("A non-Koaloader DLL named " + proxy + ".dll already exists in this directory!");
path.WriteProxy(selection.KoaloaderProxy, binaryType); path.WriteProxy(proxy, binaryType);
if (installForm is not null) if (installForm is not null)
installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action, info: false); installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
bool bit32 = false, bit64 = false; bool bit32 = false, bit64 = false;

View file

@ -8,6 +8,7 @@ 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;
@ -23,9 +24,9 @@ internal static class ProgramData
internal static readonly string CooldownPath = DirectoryPath + @"\cooldown"; internal static readonly string CooldownPath = DirectoryPath + @"\cooldown";
internal static readonly string OldChoicesPath = DirectoryPath + @"\choices.txt"; internal static readonly string OldProgramChoicesPath = DirectoryPath + @"\choices.txt";
internal static readonly string ChoicesPath = DirectoryPath + @"\choices.json"; internal static readonly string ProgramChoicesPath = DirectoryPath + @"\choices.json";
internal static readonly string DlcChoicesPath = DirectoryPath + @"\dlc.json";
internal static readonly string KoaloaderProxyChoicesPath = DirectoryPath + @"\proxies.json"; internal static readonly string KoaloaderProxyChoicesPath = DirectoryPath + @"\proxies.json";
internal static async Task Setup() => await Task.Run(() => internal static async Task Setup() => await Task.Run(() =>
@ -44,8 +45,8 @@ internal static class ProgramData
} }
if (!Directory.Exists(CooldownPath)) if (!Directory.Exists(CooldownPath))
_ = Directory.CreateDirectory(CooldownPath); _ = Directory.CreateDirectory(CooldownPath);
if (File.Exists(OldChoicesPath)) if (File.Exists(OldProgramChoicesPath))
File.Delete(OldChoicesPath); File.Delete(OldProgramChoicesPath);
}); });
internal static bool CheckCooldown(string identifier, int cooldown) internal static bool CheckCooldown(string identifier, int cooldown)
@ -86,12 +87,12 @@ internal static class ProgramData
catch { } catch { }
} }
internal static List<(Platform platform, string id)> ReadChoices() internal static List<(Platform platform, string id)> ReadProgramChoices()
{ {
if (!File.Exists(ChoicesPath)) return null; if (!File.Exists(ProgramChoicesPath)) return null;
try try
{ {
return JsonConvert.DeserializeObject(File.ReadAllText(ChoicesPath), return JsonConvert.DeserializeObject(File.ReadAllText(ProgramChoicesPath),
typeof(List<(Platform platform, string id)>)) as List<(Platform platform, string id)>; typeof(List<(Platform platform, string id)>)) as List<(Platform platform, string id)>;
} }
catch catch
@ -99,11 +100,39 @@ internal static class ProgramData
return new(); return new();
} }
} }
internal static void WriteChoices(List<(Platform platform, string id)> choices) internal static void WriteProgramChoices(List<(Platform platform, string id)> choices)
{ {
try try
{ {
File.WriteAllText(ChoicesPath, JsonConvert.SerializeObject(choices)); if (choices is null || !choices.Any())
File.Delete(ProgramChoicesPath);
else
File.WriteAllText(ProgramChoicesPath, JsonConvert.SerializeObject(choices));
}
catch { }
}
internal static List<(Platform platform, string gameId, string dlcId)> ReadDlcChoices()
{
if (!File.Exists(DlcChoicesPath)) return null;
try
{
return JsonConvert.DeserializeObject(File.ReadAllText(DlcChoicesPath),
typeof(List<(Platform platform, string gameId, string dlcId)>)) as List<(Platform platform, string gameId, string dlcId)>;
}
catch
{
return new();
}
}
internal static void WriteDlcChoices(List<(Platform platform, string gameId, string dlcId)> choices)
{
try
{
if (choices is null || !choices.Any())
File.Delete(DlcChoicesPath);
else
File.WriteAllText(DlcChoicesPath, JsonConvert.SerializeObject(choices));
} }
catch { } catch { }
} }
@ -126,40 +155,46 @@ internal static class ProgramData
{ {
try try
{ {
if (choices is null || !choices.Any())
File.Delete(KoaloaderProxyChoicesPath);
else
File.WriteAllText(KoaloaderProxyChoicesPath, JsonConvert.SerializeObject(choices)); File.WriteAllText(KoaloaderProxyChoicesPath, JsonConvert.SerializeObject(choices));
} }
catch { } catch { }
} }
internal static void UpdateKoaloaderProxyChoices() internal static void UpdateKoaloaderProxyChoices(bool initial = false)
{ {
string defaultProxy = "version";
List<(Platform platform, string id, string proxy)> choices = ReadKoaloaderProxyChoices() ?? new(); List<(Platform platform, string id, string proxy)> choices = ReadKoaloaderProxyChoices() ?? new();
if (!initial)
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
{
_ = choices.RemoveAll(c => c.platform == selection.Platform && c.id == selection.Id);
if (selection.KoaloaderProxy is not null and not ProgramSelection.DefaultKoaloaderProxy)
choices.Add((selection.Platform, selection.Id, selection.KoaloaderProxy));
}
foreach ((Platform platform, string id, string proxy) choice in choices.ToList()) foreach ((Platform platform, string id, string proxy) choice in choices.ToList())
if (ProgramSelection.FromPlatformId(choice.platform, choice.id) is ProgramSelection selection)
{ {
string proxy = choice.proxy; string proxy = choice.proxy;
if (proxy.Contains('.')) // convert pre-v4.1.0.0 choices if (proxy is not null && proxy.Contains('.')) // convert pre-v4.1.0.0 choices
proxy.GetProxyInfoFromIdentifier(out proxy, out _); proxy.GetProxyInfoFromIdentifier(out proxy, out _);
if (selection.KoaloaderProxy is null) if (choice.proxy != proxy && choices.Remove(choice)) // convert pre-v4.1.0.0 choices
choices.Add((choice.platform, choice.id, proxy));
if (proxy is null or ProgramSelection.DefaultKoaloaderProxy)
_ = choices.RemoveAll(c => c.platform == choice.platform && c.id == choice.id);
else if (ProgramSelection.FromPlatformId(choice.platform, choice.id) is ProgramSelection selection)
selection.KoaloaderProxy = proxy; selection.KoaloaderProxy = proxy;
else if (selection.KoaloaderProxy != proxy && choices.Remove(choice))
choices.Add((selection.Platform, selection.Id, selection.KoaloaderProxy));
} }
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
if (selection.KoaloaderProxy is null)
{
selection.KoaloaderProxy = defaultProxy;
choices.Add((selection.Platform, selection.Id, selection.KoaloaderProxy));
}
if (choices.Any())
WriteKoaloaderProxyChoices(choices); WriteKoaloaderProxyChoices(choices);
foreach (Form form in Application.OpenForms)
if (form is SelectForm selectForm)
selectForm.OnKoaloaderProxiesChanged();
} }
internal static void ResetKoaloaderProxyChoices() internal static void ResetKoaloaderProxyChoices()
{ {
if (File.Exists(KoaloaderProxyChoicesPath)) foreach (ProgramSelection selection in ProgramSelection.AllSafe)
File.Delete(KoaloaderProxyChoicesPath); selection.KoaloaderProxy = null;
UpdateKoaloaderProxyChoices(); UpdateKoaloaderProxyChoices();
} }
} }