v4.2.1.0
- Converted Koaloader settings' automatic updates to save & load buttons similar to those of DLC selections - Improved tab order of selection form
This commit is contained in:
parent
b14da012ff
commit
52e42d847c
6 changed files with 172 additions and 113 deletions
|
@ -1,5 +1,4 @@
|
|||
using CreamInstaller.Resources;
|
||||
using CreamInstaller.Utility;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -206,7 +205,6 @@ internal class CustomTreeView : TreeView
|
|||
}
|
||||
if (e.Button is MouseButtons.Left)
|
||||
{
|
||||
bool invalidate = false;
|
||||
if (comboBoxBounds.Any() && selectForm is not null)
|
||||
foreach (KeyValuePair<ProgramSelection, Rectangle> pair in comboBoxBounds.ToList())
|
||||
{
|
||||
|
@ -239,18 +237,14 @@ internal class CustomTreeView : TreeView
|
|||
_ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (s, e) =>
|
||||
{
|
||||
pair.Key.KoaloaderProxy = proxy == ProgramSelection.DefaultKoaloaderProxy ? null : proxy;
|
||||
ProgramData.UpdateKoaloaderProxyChoices();
|
||||
Invalidate();
|
||||
selectForm.OnKoaloaderChanged();
|
||||
})
|
||||
{ Font = comboBoxFont });
|
||||
}
|
||||
comboBoxDropDown.Show(this, PointToScreen(new(pair.Value.Left, pair.Value.Bottom - 1)));
|
||||
invalidate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!invalidate)
|
||||
{
|
||||
foreach (KeyValuePair<ProgramSelection, Rectangle> pair in checkBoxBounds.ToList())
|
||||
{
|
||||
if (!ProgramSelection.All.Contains(pair.Key))
|
||||
|
@ -258,19 +252,10 @@ internal class CustomTreeView : TreeView
|
|||
else if (pair.Value.Contains(clickPoint))
|
||||
{
|
||||
pair.Key.Koaloader = !pair.Key.Koaloader;
|
||||
invalidate = true;
|
||||
selectForm.OnKoaloaderChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (invalidate && selectForm is not null)
|
||||
{
|
||||
CheckBox koaloaderAllCheckBox = selectForm.KoaloaderAllCheckBox();
|
||||
koaloaderAllCheckBox.CheckedChanged -= selectForm.OnKoaloaderAllCheckBoxChanged;
|
||||
koaloaderAllCheckBox.Checked = ProgramSelection.AllSafe.TrueForAll(selection => selection.Koaloader);
|
||||
koaloaderAllCheckBox.CheckedChanged += selectForm.OnKoaloaderAllCheckBoxChanged;
|
||||
}
|
||||
}
|
||||
if (invalidate) Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<Version>4.2.0.1</Version>
|
||||
<Version>4.2.1.0</Version>
|
||||
<PackageIcon>Resources\ini.ico</PackageIcon>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
|
||||
|
|
84
CreamInstaller/Forms/SelectForm.Designer.cs
generated
84
CreamInstaller/Forms/SelectForm.Designer.cs
generated
|
@ -43,6 +43,8 @@ namespace CreamInstaller
|
|||
this.loadButton = new System.Windows.Forms.Button();
|
||||
this.resetKoaloaderButton = new System.Windows.Forms.Button();
|
||||
this.resetButton = new System.Windows.Forms.Button();
|
||||
this.saveKoaloaderButton = new System.Windows.Forms.Button();
|
||||
this.loadKoaloaderButton = new System.Windows.Forms.Button();
|
||||
this.programsGroupBox.SuspendLayout();
|
||||
this.koaloaderFlowPanel.SuspendLayout();
|
||||
this.blockedGamesFlowPanel.SuspendLayout();
|
||||
|
@ -60,7 +62,7 @@ namespace CreamInstaller
|
|||
this.installButton.Name = "installButton";
|
||||
this.installButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
|
||||
this.installButton.Size = new System.Drawing.Size(149, 24);
|
||||
this.installButton.TabIndex = 10004;
|
||||
this.installButton.TabIndex = 10000;
|
||||
this.installButton.Text = "Generate and Install";
|
||||
this.installButton.UseVisualStyleBackColor = true;
|
||||
this.installButton.Click += new System.EventHandler(this.OnInstall);
|
||||
|
@ -75,7 +77,7 @@ namespace CreamInstaller
|
|||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
|
||||
this.cancelButton.Size = new System.Drawing.Size(81, 24);
|
||||
this.cancelButton.TabIndex = 10000;
|
||||
this.cancelButton.TabIndex = 10004;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.OnCancel);
|
||||
|
@ -183,15 +185,15 @@ namespace CreamInstaller
|
|||
// selectionTreeView
|
||||
//
|
||||
this.selectionTreeView.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.selectionTreeView.BorderStyle = BorderStyle.None;
|
||||
this.selectionTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.selectionTreeView.CheckBoxes = true;
|
||||
this.selectionTreeView.Dock = DockStyle.Fill;
|
||||
this.selectionTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll;
|
||||
this.selectionTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.selectionTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
|
||||
this.selectionTreeView.Enabled = false;
|
||||
this.selectionTreeView.FullRowSelect = true;
|
||||
this.selectionTreeView.Location = new Point(3, 19);
|
||||
this.selectionTreeView.Location = new System.Drawing.Point(3, 19);
|
||||
this.selectionTreeView.Name = "selectionTreeView";
|
||||
this.selectionTreeView.Size = new Size(554, 217);
|
||||
this.selectionTreeView.Size = new System.Drawing.Size(554, 187);
|
||||
this.selectionTreeView.Sorted = true;
|
||||
this.selectionTreeView.TabIndex = 1001;
|
||||
//
|
||||
|
@ -244,7 +246,7 @@ namespace CreamInstaller
|
|||
//
|
||||
// scanButton
|
||||
//
|
||||
this.scanButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.scanButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.scanButton.AutoSize = true;
|
||||
this.scanButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.scanButton.Enabled = false;
|
||||
|
@ -269,7 +271,7 @@ namespace CreamInstaller
|
|||
this.uninstallButton.Name = "uninstallButton";
|
||||
this.uninstallButton.Padding = new System.Windows.Forms.Padding(12, 0, 12, 0);
|
||||
this.uninstallButton.Size = new System.Drawing.Size(91, 24);
|
||||
this.uninstallButton.TabIndex = 10003;
|
||||
this.uninstallButton.TabIndex = 10001;
|
||||
this.uninstallButton.Text = "Uninstall";
|
||||
this.uninstallButton.UseVisualStyleBackColor = true;
|
||||
this.uninstallButton.Click += new System.EventHandler(this.OnUninstall);
|
||||
|
@ -298,14 +300,14 @@ namespace CreamInstaller
|
|||
//
|
||||
// sortCheckBox
|
||||
//
|
||||
this.sortCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.sortCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.sortCheckBox.AutoSize = true;
|
||||
this.sortCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.sortCheckBox.Location = new System.Drawing.Point(120, 328);
|
||||
this.sortCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.sortCheckBox.Name = "sortCheckBox";
|
||||
this.sortCheckBox.Size = new System.Drawing.Size(104, 20);
|
||||
this.sortCheckBox.TabIndex = 10001;
|
||||
this.sortCheckBox.TabIndex = 10003;
|
||||
this.sortCheckBox.Text = "Sort By Name";
|
||||
this.sortCheckBox.CheckedChanged += new System.EventHandler(this.OnSortCheckBoxChanged);
|
||||
//
|
||||
|
@ -316,11 +318,10 @@ namespace CreamInstaller
|
|||
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.Location = new System.Drawing.Point(424, 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.Size = new System.Drawing.Size(70, 24);
|
||||
this.saveButton.TabIndex = 10006;
|
||||
this.saveButton.Text = "Save DLC";
|
||||
this.saveButton.UseVisualStyleBackColor = true;
|
||||
this.saveButton.Click += new System.EventHandler(this.OnSaveDlc);
|
||||
|
@ -332,11 +333,10 @@ namespace CreamInstaller
|
|||
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.Location = new System.Drawing.Point(500, 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.Size = new System.Drawing.Size(72, 24);
|
||||
this.loadButton.TabIndex = 10005;
|
||||
this.loadButton.Text = "Load DLC";
|
||||
this.loadButton.UseVisualStyleBackColor = true;
|
||||
this.loadButton.Click += new System.EventHandler(this.OnLoadDlc);
|
||||
|
@ -350,9 +350,8 @@ namespace CreamInstaller
|
|||
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.Size = new System.Drawing.Size(105, 24);
|
||||
this.resetKoaloaderButton.TabIndex = 10010;
|
||||
this.resetKoaloaderButton.Text = "Reset Koaloader";
|
||||
this.resetKoaloaderButton.UseVisualStyleBackColor = true;
|
||||
this.resetKoaloaderButton.Click += new System.EventHandler(this.OnResetKoaloader);
|
||||
|
@ -364,15 +363,44 @@ namespace CreamInstaller
|
|||
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.Location = new System.Drawing.Point(344, 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.Size = new System.Drawing.Size(74, 24);
|
||||
this.resetButton.TabIndex = 10007;
|
||||
this.resetButton.Text = "Reset DLC";
|
||||
this.resetButton.UseVisualStyleBackColor = true;
|
||||
this.resetButton.Click += new System.EventHandler(this.OnResetDlc);
|
||||
//
|
||||
// saveKoaloaderButton
|
||||
//
|
||||
this.saveKoaloaderButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.saveKoaloaderButton.AutoSize = true;
|
||||
this.saveKoaloaderButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.saveKoaloaderButton.Enabled = false;
|
||||
this.saveKoaloaderButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.saveKoaloaderButton.Location = new System.Drawing.Point(123, 295);
|
||||
this.saveKoaloaderButton.Name = "saveKoaloaderButton";
|
||||
this.saveKoaloaderButton.Size = new System.Drawing.Size(101, 24);
|
||||
this.saveKoaloaderButton.TabIndex = 10009;
|
||||
this.saveKoaloaderButton.Text = "Save Koaloader";
|
||||
this.saveKoaloaderButton.UseVisualStyleBackColor = true;
|
||||
this.saveKoaloaderButton.Click += new System.EventHandler(this.OnSaveKoaloader);
|
||||
//
|
||||
// loadKoaloaderButton
|
||||
//
|
||||
this.loadKoaloaderButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.loadKoaloaderButton.AutoSize = true;
|
||||
this.loadKoaloaderButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.loadKoaloaderButton.Enabled = false;
|
||||
this.loadKoaloaderButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.loadKoaloaderButton.Location = new System.Drawing.Point(230, 295);
|
||||
this.loadKoaloaderButton.Name = "loadKoaloaderButton";
|
||||
this.loadKoaloaderButton.Size = new System.Drawing.Size(103, 24);
|
||||
this.loadKoaloaderButton.TabIndex = 10008;
|
||||
this.loadKoaloaderButton.Text = "Load Koaloader";
|
||||
this.loadKoaloaderButton.UseVisualStyleBackColor = true;
|
||||
this.loadKoaloaderButton.Click += new System.EventHandler(this.OnLoadKoaloader);
|
||||
//
|
||||
// SelectForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
|
@ -380,6 +408,8 @@ namespace CreamInstaller
|
|||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(584, 361);
|
||||
this.Controls.Add(this.loadKoaloaderButton);
|
||||
this.Controls.Add(this.saveKoaloaderButton);
|
||||
this.Controls.Add(this.resetButton);
|
||||
this.Controls.Add(this.resetKoaloaderButton);
|
||||
this.Controls.Add(this.loadButton);
|
||||
|
@ -437,6 +467,8 @@ namespace CreamInstaller
|
|||
private Button loadButton;
|
||||
private Button resetKoaloaderButton;
|
||||
private Button resetButton;
|
||||
private Button saveKoaloaderButton;
|
||||
private Button loadKoaloaderButton;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ using System.Threading.Tasks;
|
|||
using System.Windows.Forms;
|
||||
|
||||
using static CreamInstaller.Resources.Resources;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace CreamInstaller;
|
||||
|
||||
|
@ -465,6 +466,8 @@ internal partial class SelectForm : CustomForm
|
|||
saveButton.Enabled = false;
|
||||
loadButton.Enabled = false;
|
||||
resetButton.Enabled = false;
|
||||
saveKoaloaderButton.Enabled = false;
|
||||
loadKoaloaderButton.Enabled = false;
|
||||
resetKoaloaderButton.Enabled = false;
|
||||
progressLabel.Text = "Waiting for user to select which programs/games to scan . . .";
|
||||
ShowProgressBar();
|
||||
|
@ -541,8 +544,8 @@ internal partial class SelectForm : CustomForm
|
|||
await SteamCMD.Cleanup();
|
||||
}
|
||||
|
||||
ProgramData.UpdateKoaloaderProxyChoices(initial: true);
|
||||
OnLoadDlc(null, null);
|
||||
OnLoadKoaloader(null, null);
|
||||
|
||||
HideProgressBar();
|
||||
selectionTreeView.Enabled = ProgramSelection.All.Any();
|
||||
|
@ -552,8 +555,11 @@ internal partial class SelectForm : CustomForm
|
|||
installButton.Enabled = ProgramSelection.AllEnabled.Any();
|
||||
uninstallButton.Enabled = installButton.Enabled;
|
||||
saveButton.Enabled = CanSaveDlc();
|
||||
loadButton.Enabled = ProgramData.ReadDlcChoices() is not null;
|
||||
loadButton.Enabled = CanLoadDlc();
|
||||
resetButton.Enabled = CanResetDlc();
|
||||
saveKoaloaderButton.Enabled = CanSaveKoaloader();
|
||||
loadKoaloaderButton.Enabled = CanLoadKoaloader();
|
||||
resetKoaloaderButton.Enabled = CanResetKoaloader();
|
||||
cancelButton.Enabled = false;
|
||||
scanButton.Enabled = true;
|
||||
blockedGamesCheckBox.Enabled = true;
|
||||
|
@ -903,6 +909,23 @@ internal partial class SelectForm : CustomForm
|
|||
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
|
||||
}
|
||||
|
||||
internal void OnKoaloaderAllCheckBoxChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool shouldCheck = false;
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
if (!selection.Koaloader)
|
||||
{
|
||||
shouldCheck = true;
|
||||
break;
|
||||
}
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
selection.Koaloader = shouldCheck;
|
||||
selectionTreeView.Invalidate();
|
||||
koaloaderAllCheckBox.CheckedChanged -= OnKoaloaderAllCheckBoxChanged;
|
||||
koaloaderAllCheckBox.Checked = shouldCheck;
|
||||
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged;
|
||||
}
|
||||
|
||||
private bool AreSelectionsDefault()
|
||||
{
|
||||
foreach (TreeNode node in TreeNodes)
|
||||
|
@ -926,10 +949,12 @@ internal partial class SelectForm : CustomForm
|
|||
}
|
||||
choices = choices.Distinct().ToList();
|
||||
ProgramData.WriteDlcChoices(choices);
|
||||
loadButton.Enabled = ProgramData.ReadDlcChoices() is not null;
|
||||
loadButton.Enabled = CanLoadDlc();
|
||||
saveButton.Enabled = CanSaveDlc();
|
||||
}
|
||||
|
||||
private static bool CanLoadDlc() => ProgramData.ReadDlcChoices() is not null;
|
||||
|
||||
private void OnLoadDlc(object sender, EventArgs e)
|
||||
{
|
||||
List<(Platform platform, string gameId, string dlcId)> choices = ProgramData.ReadDlcChoices();
|
||||
|
@ -937,7 +962,7 @@ internal partial class SelectForm : CustomForm
|
|||
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.Checked = choices.Any(c => c.platform == platform && c.gameId == parent.Name && c.dlcId == node.Name)
|
||||
? node.Text == "Unknown"
|
||||
: node.Text != "Unknown";
|
||||
OnTreeViewNodeCheckedChanged(null, new(node, TreeViewAction.ByMouse));
|
||||
|
@ -957,32 +982,87 @@ internal partial class SelectForm : CustomForm
|
|||
resetButton.Enabled = CanResetDlc();
|
||||
}
|
||||
|
||||
internal CheckBox KoaloaderAllCheckBox() => koaloaderAllCheckBox;
|
||||
internal void OnKoaloaderAllCheckBoxChanged(object sender, EventArgs e)
|
||||
private static bool AreKoaloaderSelectionsDefault()
|
||||
{
|
||||
bool shouldCheck = false;
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
if (!selection.Koaloader)
|
||||
{
|
||||
shouldCheck = true;
|
||||
break;
|
||||
}
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
selection.Koaloader = shouldCheck;
|
||||
selectionTreeView.Invalidate();
|
||||
koaloaderAllCheckBox.CheckedChanged -= OnKoaloaderAllCheckBoxChanged;
|
||||
koaloaderAllCheckBox.Checked = shouldCheck;
|
||||
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged;
|
||||
if (!selection.Koaloader || selection.KoaloaderProxy is not null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool CanResetKoaloader() => File.Exists(ProgramData.KoaloaderProxyChoicesPath);
|
||||
private static bool CanSaveKoaloader() => ProgramData.ReadKoaloaderChoices() is not null || !AreKoaloaderSelectionsDefault();
|
||||
|
||||
private void OnResetKoaloader(object sender, EventArgs e) => ProgramData.ResetKoaloaderProxyChoices();
|
||||
private void OnSaveKoaloader(object sender, EventArgs e)
|
||||
{
|
||||
List<(Platform platform, string id, string proxy, bool enabled)> choices = ProgramData.ReadKoaloaderChoices() ?? new();
|
||||
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 || !selection.Koaloader)
|
||||
choices.Add((selection.Platform, selection.Id, selection.KoaloaderProxy == ProgramSelection.DefaultKoaloaderProxy ? null : selection.KoaloaderProxy, selection.Koaloader));
|
||||
}
|
||||
ProgramData.WriteKoaloaderProxyChoices(choices);
|
||||
saveKoaloaderButton.Enabled = CanSaveKoaloader();
|
||||
loadKoaloaderButton.Enabled = CanLoadKoaloader();
|
||||
}
|
||||
|
||||
internal void OnKoaloaderProxiesChanged()
|
||||
private static bool CanLoadKoaloader() => ProgramData.ReadKoaloaderChoices() is not null;
|
||||
|
||||
private void OnLoadKoaloader(object sender, EventArgs e)
|
||||
{
|
||||
List<(Platform platform, string id, string proxy, bool enabled)> choices = ProgramData.ReadKoaloaderChoices();
|
||||
if (choices is null) return;
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
{
|
||||
if (choices.Any(c => c.platform == selection.Platform && c.id == selection.Id))
|
||||
{
|
||||
(Platform platform, string id, string proxy, bool enabled) choice =
|
||||
choices.First(c => c.platform == selection.Platform && c.id == selection.Id);
|
||||
(Platform platform, string id, string proxy, bool enabled) = choice;
|
||||
string currentProxy = proxy;
|
||||
if (proxy is not null && proxy.Contains('.')) // convert pre-v4.1.0.0 choices
|
||||
proxy.GetProxyInfoFromIdentifier(out currentProxy, out _);
|
||||
if (proxy != currentProxy && choices.Remove(choice)) // convert pre-v4.1.0.0 choices
|
||||
choices.Add((platform, id, currentProxy, enabled));
|
||||
if (currentProxy is null or ProgramSelection.DefaultKoaloaderProxy && enabled)
|
||||
_ = choices.RemoveAll(c => c.platform == platform && c.id == id);
|
||||
else
|
||||
{
|
||||
selection.Koaloader = enabled;
|
||||
selection.KoaloaderProxy = currentProxy == ProgramSelection.DefaultKoaloaderProxy ? currentProxy : proxy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selection.Koaloader = true;
|
||||
selection.KoaloaderProxy = null;
|
||||
}
|
||||
}
|
||||
ProgramData.WriteKoaloaderProxyChoices(choices);
|
||||
loadKoaloaderButton.Enabled = CanLoadKoaloader();
|
||||
OnKoaloaderChanged();
|
||||
}
|
||||
|
||||
private static bool CanResetKoaloader() => !AreKoaloaderSelectionsDefault();
|
||||
|
||||
private void OnResetKoaloader(object sender, EventArgs e)
|
||||
{
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
{
|
||||
selection.Koaloader = true;
|
||||
selection.KoaloaderProxy = null;
|
||||
}
|
||||
OnKoaloaderChanged();
|
||||
}
|
||||
|
||||
internal void OnKoaloaderChanged()
|
||||
{
|
||||
selectionTreeView.Invalidate();
|
||||
saveKoaloaderButton.Enabled = CanSaveKoaloader();
|
||||
resetKoaloaderButton.Enabled = CanResetKoaloader();
|
||||
koaloaderAllCheckBox.CheckedChanged -= OnKoaloaderAllCheckBoxChanged;
|
||||
koaloaderAllCheckBox.Checked = ProgramSelection.AllSafe.TrueForAll(selection => selection.Koaloader);
|
||||
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged;
|
||||
}
|
||||
|
||||
private void OnBlockProtectedGamesCheckBoxChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using CreamInstaller.Resources;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -8,7 +6,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller.Utility;
|
||||
|
||||
|
@ -137,13 +134,13 @@ internal static class ProgramData
|
|||
catch { }
|
||||
}
|
||||
|
||||
internal static List<(Platform platform, string id, string proxy)> ReadKoaloaderProxyChoices()
|
||||
internal static List<(Platform platform, string id, string proxy, bool enabled)> ReadKoaloaderChoices()
|
||||
{
|
||||
if (!File.Exists(KoaloaderProxyChoicesPath)) return null;
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(File.ReadAllText(KoaloaderProxyChoicesPath),
|
||||
typeof(List<(Platform platform, string id, string proxy)>)) as List<(Platform platform, string id, string proxy)>;
|
||||
typeof(List<(Platform platform, string id, string proxy, bool enabled)>)) as List<(Platform platform, string id, string proxy, bool enabled)>;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -151,7 +148,7 @@ internal static class ProgramData
|
|||
}
|
||||
}
|
||||
|
||||
internal static void WriteKoaloaderProxyChoices(List<(Platform platform, string id, string proxy)> choices)
|
||||
internal static void WriteKoaloaderProxyChoices(List<(Platform platform, string id, string proxy, bool enabled)> choices)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -162,39 +159,4 @@ internal static class ProgramData
|
|||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
internal static void UpdateKoaloaderProxyChoices(bool initial = false)
|
||||
{
|
||||
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())
|
||||
{
|
||||
string proxy = choice.proxy;
|
||||
if (proxy is not null && proxy.Contains('.')) // convert pre-v4.1.0.0 choices
|
||||
proxy.GetProxyInfoFromIdentifier(out proxy, out _);
|
||||
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;
|
||||
}
|
||||
WriteKoaloaderProxyChoices(choices);
|
||||
foreach (Form form in Application.OpenForms)
|
||||
if (form is SelectForm selectForm)
|
||||
selectForm.OnKoaloaderProxiesChanged();
|
||||
}
|
||||
|
||||
internal static void ResetKoaloaderProxyChoices()
|
||||
{
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllSafe)
|
||||
selection.KoaloaderProxy = null;
|
||||
UpdateKoaloaderProxyChoices();
|
||||
}
|
||||
}
|
||||
|
|
BIN
preview.png
BIN
preview.png
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Loading…
Reference in a new issue