framework for a quick uninstall all option
This commit is contained in:
parent
62b5a53909
commit
39e5ba06ad
3 changed files with 103 additions and 43 deletions
|
@ -12,16 +12,17 @@ internal sealed partial class SelectDialogForm : CustomForm
|
||||||
private readonly List<(Platform platform, string id, string name)> selected = new();
|
private readonly List<(Platform platform, string id, string name)> selected = new();
|
||||||
internal SelectDialogForm(IWin32Window owner) : base(owner) => InitializeComponent();
|
internal SelectDialogForm(IWin32Window owner) : base(owner) => InitializeComponent();
|
||||||
|
|
||||||
internal List<(Platform platform, string id, string name)> QueryUser(string groupBoxText,
|
internal DialogResult QueryUser(string groupBoxText, List<(Platform platform, string id, string name, bool alreadySelected)> potentialChoices,
|
||||||
List<(Platform platform, string id, string name, bool alreadySelected)> choices)
|
out List<(Platform platform, string id, string name)> choices)
|
||||||
{
|
{
|
||||||
if (!choices.Any())
|
choices = null;
|
||||||
return null;
|
if (!potentialChoices.Any())
|
||||||
|
return DialogResult.Cancel;
|
||||||
groupBox.Text = groupBoxText;
|
groupBox.Text = groupBoxText;
|
||||||
allCheckBox.Enabled = false;
|
allCheckBox.Enabled = false;
|
||||||
acceptButton.Enabled = false;
|
acceptButton.Enabled = false;
|
||||||
selectionTreeView.AfterCheck += OnTreeNodeChecked;
|
selectionTreeView.AfterCheck += OnTreeNodeChecked;
|
||||||
foreach ((Platform platform, string id, string name, bool alreadySelected) in choices)
|
foreach ((Platform platform, string id, string name, bool alreadySelected) in potentialChoices)
|
||||||
{
|
{
|
||||||
TreeNode node = new() { Tag = platform, Name = id, Text = name, Checked = alreadySelected };
|
TreeNode node = new() { Tag = platform, Name = id, Text = name, Checked = alreadySelected };
|
||||||
OnTreeNodeChecked(node);
|
OnTreeNodeChecked(node);
|
||||||
|
@ -38,7 +39,8 @@ internal sealed partial class SelectDialogForm : CustomForm
|
||||||
loadButton.Enabled = ProgramData.ReadProgramChoices() 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;
|
choices = selected;
|
||||||
|
return ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTreeNodeChecked(object sender, TreeViewEventArgs e)
|
private void OnTreeNodeChecked(object sender, TreeViewEventArgs e)
|
||||||
|
|
|
@ -100,7 +100,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GetApplicablePrograms(IProgress<int> progress)
|
private async Task GetApplicablePrograms(IProgress<int> progress, bool uninstallAll = false)
|
||||||
{
|
{
|
||||||
if (programsToScan is null || !programsToScan.Any())
|
if (programsToScan is null || !programsToScan.Any())
|
||||||
return;
|
return;
|
||||||
|
@ -128,25 +128,37 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
List<string> dllDirectories = await ParadoxLauncher.InstallPath.GetDllDirectoriesFromGameDirectory(Platform.Paradox, this);
|
List<string> dllDirectories = await ParadoxLauncher.InstallPath.GetDllDirectoriesFromGameDirectory(Platform.Paradox, this);
|
||||||
if (dllDirectories is not null)
|
if (dllDirectories is not null)
|
||||||
{
|
{
|
||||||
ProgramSelection selection = ProgramSelection.FromPlatformId(Platform.Paradox, "PL");
|
if (uninstallAll)
|
||||||
selection ??= new();
|
{
|
||||||
if (allCheckBox.Checked)
|
ProgramSelection bareSelection = ProgramSelection.FromPlatformId(Platform.Paradox, "PL") ?? new();
|
||||||
selection.Enabled = true;
|
bareSelection.Id = "PL";
|
||||||
if (koaloaderAllCheckBox.Checked)
|
bareSelection.Name = "Paradox Launcher";
|
||||||
selection.Koaloader = true;
|
bareSelection.RootDirectory = ParadoxLauncher.InstallPath;
|
||||||
selection.Id = "PL";
|
bareSelection.ExecutableDirectories = await ParadoxLauncher.GetExecutableDirectories(bareSelection.RootDirectory);
|
||||||
selection.Name = "Paradox Launcher";
|
bareSelection.DllDirectories = dllDirectories;
|
||||||
selection.RootDirectory = ParadoxLauncher.InstallPath;
|
bareSelection.Platform = Platform.Paradox;
|
||||||
selection.ExecutableDirectories = await ParadoxLauncher.GetExecutableDirectories(selection.RootDirectory);
|
}
|
||||||
selection.DllDirectories = dllDirectories;
|
else
|
||||||
selection.Platform = Platform.Paradox;
|
{
|
||||||
TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Paradox && s.Name == selection.Id) ?? new TreeNode();
|
ProgramSelection selection = ProgramSelection.FromPlatformId(Platform.Paradox, "PL") ?? new();
|
||||||
programNode.Tag = selection.Platform;
|
if (allCheckBox.Checked)
|
||||||
programNode.Name = selection.Id;
|
selection.Enabled = true;
|
||||||
programNode.Text = selection.Name;
|
if (koaloaderAllCheckBox.Checked)
|
||||||
programNode.Checked = selection.Enabled;
|
selection.Koaloader = true;
|
||||||
if (programNode.TreeView is null)
|
selection.Id = "PL";
|
||||||
_ = selectionTreeView.Nodes.Add(programNode);
|
selection.Name = "Paradox Launcher";
|
||||||
|
selection.RootDirectory = ParadoxLauncher.InstallPath;
|
||||||
|
selection.ExecutableDirectories = await ParadoxLauncher.GetExecutableDirectories(selection.RootDirectory);
|
||||||
|
selection.DllDirectories = dllDirectories;
|
||||||
|
selection.Platform = Platform.Paradox;
|
||||||
|
TreeNode programNode = treeNodes.Find(s => s.Tag is Platform.Paradox && s.Name == selection.Id) ?? new TreeNode();
|
||||||
|
programNode.Tag = selection.Platform;
|
||||||
|
programNode.Name = selection.Id;
|
||||||
|
programNode.Text = selection.Name;
|
||||||
|
programNode.Checked = selection.Enabled;
|
||||||
|
if (programNode.TreeView is null)
|
||||||
|
_ = selectionTreeView.Nodes.Add(programNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int steamGamesToCheck;
|
int steamGamesToCheck;
|
||||||
|
@ -158,7 +170,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return;
|
return;
|
||||||
if (Program.IsGameBlocked(name, gameDirectory) || !programsToScan.Any(c => c.platform is Platform.Steam && c.id == appId))
|
if (!uninstallAll && (Program.IsGameBlocked(name, gameDirectory) || !programsToScan.Any(c => c.platform is Platform.Steam && c.id == appId)))
|
||||||
{
|
{
|
||||||
Interlocked.Decrement(ref steamGamesToCheck);
|
Interlocked.Decrement(ref steamGamesToCheck);
|
||||||
continue;
|
continue;
|
||||||
|
@ -175,6 +187,20 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
RemoveFromRemainingGames(name);
|
RemoveFromRemainingGames(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (uninstallAll)
|
||||||
|
{
|
||||||
|
ProgramSelection bareSelection = ProgramSelection.FromPlatformId(Platform.Steam, appId) ?? new ProgramSelection();
|
||||||
|
bareSelection.Enabled = true;
|
||||||
|
bareSelection.Id = appId;
|
||||||
|
bareSelection.Name = name;
|
||||||
|
bareSelection.RootDirectory = gameDirectory;
|
||||||
|
bareSelection.ExecutableDirectories = await SteamLibrary.GetExecutableDirectories(bareSelection.RootDirectory);
|
||||||
|
bareSelection.DllDirectories = dllDirectories;
|
||||||
|
bareSelection.Platform = Platform.Steam;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Program.Canceled)
|
||||||
|
return;
|
||||||
AppData appData = await SteamStore.QueryStoreAPI(appId);
|
AppData appData = await SteamStore.QueryStoreAPI(appId);
|
||||||
Interlocked.Decrement(ref steamGamesToCheck);
|
Interlocked.Decrement(ref steamGamesToCheck);
|
||||||
VProperty appInfo = await SteamCMD.GetAppInfo(appId, branch, buildId);
|
VProperty appInfo = await SteamCMD.GetAppInfo(appId, branch, buildId);
|
||||||
|
@ -316,12 +342,10 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
programNode.Checked = selection.Enabled;
|
programNode.Checked = selection.Enabled;
|
||||||
if (programNode.TreeView is null)
|
if (programNode.TreeView is null)
|
||||||
_ = selectionTreeView.Nodes.Add(programNode);
|
_ = selectionTreeView.Nodes.Add(programNode);
|
||||||
foreach (KeyValuePair<string, (DlcType type, string name, string icon)> pair in dlc)
|
foreach ((string appId, (DlcType type, string name, string icon) dlcApp) in dlc)
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return;
|
return;
|
||||||
string appId = pair.Key;
|
|
||||||
(DlcType type, string name, string icon) dlcApp = pair.Value;
|
|
||||||
selection.AllDlc[appId] = dlcApp;
|
selection.AllDlc[appId] = dlcApp;
|
||||||
if (allCheckBox.Checked && dlcApp.name != "Unknown")
|
if (allCheckBox.Checked && dlcApp.name != "Unknown")
|
||||||
selection.SelectedDlc[appId] = dlcApp;
|
selection.SelectedDlc[appId] = dlcApp;
|
||||||
|
@ -351,7 +375,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
string directory = manifest.InstallLocation;
|
string directory = manifest.InstallLocation;
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return;
|
return;
|
||||||
if (Program.IsGameBlocked(name, directory) || !programsToScan.Any(c => c.platform is Platform.Epic && c.id == @namespace))
|
if (!uninstallAll && (Program.IsGameBlocked(name, directory) || !programsToScan.Any(c => c.platform is Platform.Epic && c.id == @namespace)))
|
||||||
continue;
|
continue;
|
||||||
AddToRemainingGames(name);
|
AddToRemainingGames(name);
|
||||||
Task task = Task.Run(async () =>
|
Task task = Task.Run(async () =>
|
||||||
|
@ -364,6 +388,18 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
RemoveFromRemainingGames(name);
|
RemoveFromRemainingGames(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (uninstallAll)
|
||||||
|
{
|
||||||
|
ProgramSelection bareSelection = ProgramSelection.FromPlatformId(Platform.Epic, @namespace) ?? new ProgramSelection();
|
||||||
|
bareSelection.Enabled = true;
|
||||||
|
bareSelection.Id = @namespace;
|
||||||
|
bareSelection.Name = name;
|
||||||
|
bareSelection.RootDirectory = directory;
|
||||||
|
bareSelection.ExecutableDirectories = await EpicLibrary.GetExecutableDirectories(bareSelection.RootDirectory);
|
||||||
|
bareSelection.DllDirectories = dllDirectories;
|
||||||
|
bareSelection.Platform = Platform.Epic;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return;
|
return;
|
||||||
ConcurrentDictionary<string, (string name, string product, string icon, string developer)> entitlements = new();
|
ConcurrentDictionary<string, (string name, string product, string icon, string developer)> entitlements = new();
|
||||||
|
@ -443,10 +479,9 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
entitlementsNode.Checked = selection.SelectedDlc.Any(pair => pair.Value.type == DlcType.Entitlement);
|
entitlementsNode.Checked = selection.SelectedDlc.Any(pair => pair.Value.type == DlcType.Entitlement);
|
||||||
if (entitlementsNode.Parent is null)
|
if (entitlementsNode.Parent is null)
|
||||||
programNode.Nodes.Add(entitlementsNode);*/
|
programNode.Nodes.Add(entitlementsNode);*/
|
||||||
foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in entitlements)
|
foreach ((string dlcId, (string name, string product, string icon, string developer) value) in entitlements)
|
||||||
{
|
{
|
||||||
string dlcId = pair.Key;
|
(DlcType type, string name, string icon) dlcApp = (DlcType.EpicEntitlement, value.name, value.icon);
|
||||||
(DlcType type, string name, string icon) dlcApp = (DlcType.EpicEntitlement, pair.Value.name, pair.Value.icon);
|
|
||||||
selection.AllDlc[dlcId] = dlcApp;
|
selection.AllDlc[dlcId] = dlcApp;
|
||||||
if (allCheckBox.Checked)
|
if (allCheckBox.Checked)
|
||||||
selection.SelectedDlc[dlcId] = dlcApp;
|
selection.SelectedDlc[dlcId] = dlcApp;
|
||||||
|
@ -486,6 +521,18 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
RemoveFromRemainingGames(name);
|
RemoveFromRemainingGames(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (uninstallAll)
|
||||||
|
{
|
||||||
|
ProgramSelection bareSelection = ProgramSelection.FromPlatformId(Platform.Ubisoft, gameId) ?? new ProgramSelection();
|
||||||
|
bareSelection.Enabled = true;
|
||||||
|
bareSelection.Id = gameId;
|
||||||
|
bareSelection.Name = name;
|
||||||
|
bareSelection.RootDirectory = gameDirectory;
|
||||||
|
bareSelection.ExecutableDirectories = await UbisoftLibrary.GetExecutableDirectories(bareSelection.RootDirectory);
|
||||||
|
bareSelection.DllDirectories = dllDirectories;
|
||||||
|
bareSelection.Platform = Platform.Ubisoft;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Program.Canceled)
|
if (Program.Canceled)
|
||||||
return;
|
return;
|
||||||
ProgramSelection selection = ProgramSelection.FromPlatformId(Platform.Ubisoft, gameId) ?? new ProgramSelection();
|
ProgramSelection selection = ProgramSelection.FromPlatformId(Platform.Ubisoft, gameId) ?? new ProgramSelection();
|
||||||
|
@ -571,16 +618,29 @@ internal sealed partial class SelectForm : CustomForm
|
||||||
if (gameChoices.Any())
|
if (gameChoices.Any())
|
||||||
{
|
{
|
||||||
using SelectDialogForm form = new(this);
|
using SelectDialogForm form = new(this);
|
||||||
List<(Platform platform, string id, string name)> choices = form.QueryUser("Choose which programs and/or games to scan for DLC:", gameChoices);
|
DialogResult selectResult = form.QueryUser("Choose which programs and/or games to scan:", gameChoices,
|
||||||
scan = choices is not null && choices.Any();
|
out List<(Platform platform, string id, string name)> choices);
|
||||||
const string retry = "\n\nPress the \"Rescan\" button to re-choose.";
|
if (selectResult == DialogResult.Abort) // will be an uninstall all button
|
||||||
if (scan)
|
|
||||||
{
|
{
|
||||||
|
choices = new();
|
||||||
|
foreach ((Platform platform, string id, string name, bool alreadySelected) in gameChoices)
|
||||||
|
choices.Add((platform, id, name));
|
||||||
programsToScan = choices;
|
programsToScan = choices;
|
||||||
noneFoundLabel.Text = "None of the chosen programs nor games were applicable!" + retry;
|
await GetApplicablePrograms(new Progress<int>(), true);
|
||||||
|
OnUninstall(null, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
noneFoundLabel.Text = "You didn't choose any programs nor games!" + retry;
|
{
|
||||||
|
scan = selectResult == DialogResult.OK && choices is not null && choices.Any();
|
||||||
|
const string retry = "\n\nPress the \"Rescan\" button to re-choose.";
|
||||||
|
if (scan)
|
||||||
|
{
|
||||||
|
programsToScan = choices;
|
||||||
|
noneFoundLabel.Text = "None of the chosen programs nor games were applicable!" + retry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
noneFoundLabel.Text = "You didn't choose any programs nor games!" + retry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
noneFoundLabel.Text = "No applicable programs nor games were found on your computer!";
|
noneFoundLabel.Text = "No applicable programs nor games were found on your computer!";
|
||||||
|
|
|
@ -114,10 +114,8 @@ internal sealed class ProgramSelection
|
||||||
|
|
||||||
internal void ToggleDlc(string dlcId, bool enabled)
|
internal void ToggleDlc(string dlcId, bool enabled)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, (DlcType type, string name, string icon)> pair in AllDlc)
|
foreach ((string appId, (DlcType type, string name, string icon) dlcApp) in AllDlc)
|
||||||
{
|
{
|
||||||
string appId = pair.Key;
|
|
||||||
(DlcType type, string name, string icon) dlcApp = pair.Value;
|
|
||||||
if (appId != dlcId)
|
if (appId != dlcId)
|
||||||
continue;
|
continue;
|
||||||
Toggle(appId, dlcApp, enabled);
|
Toggle(appId, dlcApp, enabled);
|
||||||
|
|
Loading…
Reference in a new issue