- Minor refactoring for clarification
- Refreshing queries through the context menu will now also refresh the query cooldown as well
This commit is contained in:
pointfeev 2022-03-16 02:02:56 -04:00
parent 2ad39f6d62
commit 28773bca50
2 changed files with 14 additions and 8 deletions

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>3.3.0.1</Version> <Version>3.3.0.2</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

@ -471,8 +471,8 @@ internal partial class SelectForm : CustomForm
if (e.Action == TreeViewAction.Unknown) return; if (e.Action == TreeViewAction.Unknown) return;
TreeNode node = e.Node; TreeNode node = e.Node;
if (node is null) return; if (node is null) return;
CheckNode(node); SyncNode(node);
SyncNodeParents(node); SyncNodeAncestors(node);
SyncNodeDescendants(node); SyncNodeDescendants(node);
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged; allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
allCheckBox.Checked = TreeNodes.TrueForAll(treeNode => treeNode.Checked); allCheckBox.Checked = TreeNodes.TrueForAll(treeNode => treeNode.Checked);
@ -481,13 +481,13 @@ internal partial class SelectForm : CustomForm
uninstallButton.Enabled = installButton.Enabled; uninstallButton.Enabled = installButton.Enabled;
} }
private static void SyncNodeParents(TreeNode node) private static void SyncNodeAncestors(TreeNode node)
{ {
TreeNode parentNode = node.Parent; TreeNode parentNode = node.Parent;
if (parentNode is not null) if (parentNode is not null)
{ {
parentNode.Checked = parentNode.Nodes.Cast<TreeNode>().ToList().Any(childNode => childNode.Checked); parentNode.Checked = parentNode.Nodes.Cast<TreeNode>().Any(childNode => childNode.Checked);
SyncNodeParents(parentNode); SyncNodeAncestors(parentNode);
} }
} }
@ -495,11 +495,11 @@ internal partial class SelectForm : CustomForm
node.Nodes.Cast<TreeNode>().ToList().ForEach(childNode => node.Nodes.Cast<TreeNode>().ToList().ForEach(childNode =>
{ {
childNode.Checked = node.Checked; childNode.Checked = node.Checked;
CheckNode(childNode); SyncNode(childNode);
SyncNodeDescendants(childNode); SyncNodeDescendants(childNode);
}); });
private static void CheckNode(TreeNode node) private static void SyncNode(TreeNode node)
{ {
(string gameId, (DlcType type, string name, string icon) app)? dlc = ProgramSelection.GetDlcFromId(node.Name); (string gameId, (DlcType type, string name, string icon) app)? dlc = ProgramSelection.GetDlcFromId(node.Name);
if (dlc.HasValue) if (dlc.HasValue)
@ -591,6 +591,7 @@ internal partial class SelectForm : CustomForm
contextMenuStrip.Items.Add(header ?? new ContextMenuItem(node.Text)); contextMenuStrip.Items.Add(header ?? new ContextMenuItem(node.Text));
string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf"; string appInfoVDF = $@"{SteamCMD.AppInfoPath}\{id}.vdf";
string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json"; string appInfoJSON = $@"{SteamCMD.AppInfoPath}\{id}.json";
string cooldown = $@"{ProgramData.CooldownPath}\{id}.txt";
if (Directory.Exists(Directory.GetDirectoryRoot(appInfoVDF)) && (File.Exists(appInfoVDF) || File.Exists(appInfoJSON))) if (Directory.Exists(Directory.GetDirectoryRoot(appInfoVDF)) && (File.Exists(appInfoVDF) || File.Exists(appInfoJSON)))
{ {
List<ContextMenuItem> queries = new(); List<ContextMenuItem> queries = new();
@ -618,6 +619,11 @@ internal partial class SelectForm : CustomForm
File.Delete(appInfoJSON); File.Delete(appInfoJSON);
} }
catch { } catch { }
try
{
File.Delete(cooldown);
}
catch { }
OnLoad(); OnLoad();
}))); })));
} }