more refactoring & optimization

This commit is contained in:
pointfeev 2023-01-13 16:48:34 -05:00
parent d67b29d48b
commit a9a701a988
18 changed files with 140 additions and 133 deletions

View file

@ -30,15 +30,14 @@ internal class CustomForm : Form
internal CustomForm(IWin32Window owner) : this() internal CustomForm(IWin32Window owner) : this()
{ {
if (owner is Form form) if (owner is not Form form)
{ return;
Owner = form; Owner = form;
InheritLocation(form); InheritLocation(form);
SizeChanged += (s, e) => InheritLocation(form); SizeChanged += (_, _) => InheritLocation(form);
form.Activated += OnActivation; form.Activated += OnActivation;
FormClosing += (s, e) => form.Activated -= OnActivation; FormClosing += (_, _) => form.Activated -= OnActivation;
TopLevel = true; TopLevel = true;
}
} }
protected override CreateParams CreateParams // Double buffering for all controls protected override CreateParams CreateParams // Double buffering for all controls
@ -51,7 +50,7 @@ internal class CustomForm : Form
} }
} }
internal void OnHelpButtonClicked(object sender, EventArgs args) private void OnHelpButtonClicked(object sender, EventArgs args)
{ {
using DialogForm helpDialog = new(this); using DialogForm helpDialog = new(this);
helpDialog.HelpButton = false; helpDialog.HelpButton = false;
@ -85,11 +84,11 @@ internal class CustomForm : Form
+ $"The program source and other information can be found on [GitHub]({repository})."); + $"The program source and other information can be found on [GitHub]({repository}).");
} }
internal void OnActivation(object sender, EventArgs args) => Activate(); private void OnActivation(object sender, EventArgs args) => Activate();
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)] [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern void SetWindowPos(nint hWnd, nint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); private static extern void SetWindowPos(nint hWnd, nint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
internal void BringToFrontWithoutActivation() internal void BringToFrontWithoutActivation()
{ {

View file

@ -206,7 +206,7 @@ internal sealed class CustomTreeView : TreeView
foreach (string proxy in proxies) foreach (string proxy in proxies)
{ {
bool canUse = true; bool canUse = true;
foreach ((string directory, BinaryType binaryType) in pair.Key.ExecutableDirectories) foreach ((string directory, BinaryType _) in pair.Key.ExecutableDirectories)
{ {
string path = directory + @"\" + proxy + ".dll"; string path = directory + @"\" + proxy + ".dll";
if (!File.Exists(path) || path.IsResourceFile(ResourceIdentifier.Koaloader)) if (!File.Exists(path) || path.IsResourceFile(ResourceIdentifier.Koaloader))
@ -215,7 +215,7 @@ internal sealed class CustomTreeView : TreeView
break; break;
} }
if (canUse) if (canUse)
_ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (s, e) => _ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (_, _) =>
{ {
pair.Key.KoaloaderProxy = proxy == ProgramSelection.DefaultKoaloaderProxy ? null : proxy; pair.Key.KoaloaderProxy = proxy == ProgramSelection.DefaultKoaloaderProxy ? null : proxy;
selectForm.OnKoaloaderChanged(); selectForm.OnKoaloaderChanged();

View file

@ -39,9 +39,9 @@ internal sealed class StringComparer : IComparer<string>
internal sealed class NodeComparer : IComparer<TreeNode> internal sealed class NodeComparer : IComparer<TreeNode>
{ {
public int Compare(TreeNode a, TreeNode b) public int Compare(TreeNode a, TreeNode b)
=> a.Tag is not Platform A => a?.Tag is not Platform A
? 1 ? 1
: b.Tag is not Platform B : b?.Tag is not Platform B
? -1 ? -1
: A > B : A > B
? 1 ? 1
@ -57,7 +57,7 @@ internal sealed class NodeNameComparer : IComparer
? 1 ? 1
: b is not TreeNode B : b is not TreeNode B
? -1 ? -1
: PlatformIdComparer.Node.Compare(A, B) is int c && c != 0 : PlatformIdComparer.Node.Compare(A, B) is var c && c != 0
? c ? c
: PlatformIdComparer.String.Compare(A.Name, B.Name); : PlatformIdComparer.String.Compare(A.Name, B.Name);
} }
@ -69,7 +69,7 @@ internal sealed class NodeTextComparer : IComparer
? 1 ? 1
: b is not TreeNode B : b is not TreeNode B
? -1 ? -1
: PlatformIdComparer.Node.Compare(A, B) is int c && c != 0 : PlatformIdComparer.Node.Compare(A, B) is var c && c != 0
? c ? c
: PlatformIdComparer.String.Compare(A.Text, B.Text); : PlatformIdComparer.String.Compare(A.Text, B.Text);
} }

View file

@ -56,7 +56,11 @@ internal sealed partial class DialogForm : CustomForm
return ShowDialog(); return ShowDialog();
foreach (LinkLabel.Link link in links) foreach (LinkLabel.Link link in links)
_ = descriptionLabel.Links.Add(link); _ = descriptionLabel.Links.Add(link);
descriptionLabel.LinkClicked += (s, e) => Process.Start(new ProcessStartInfo((string)e.Link.LinkData) { UseShellExecute = true }); descriptionLabel.LinkClicked += (_, e) =>
{
if (e.Link != null)
Process.Start(new ProcessStartInfo((string)e.Link.LinkData) { UseShellExecute = true });
};
return ShowDialog(); return ShowDialog();
} }

View file

@ -71,7 +71,7 @@ internal sealed partial class InstallForm : CustomForm
+ $" with root directory \"{selection.RootDirectory}\" . . . ", LogTextBox.Operation); + $" with root directory \"{selection.RootDirectory}\" . . . ", LogTextBox.Operation);
IEnumerable<string> invalidDirectories = (await selection.RootDirectory.GetExecutables()) IEnumerable<string> invalidDirectories = (await selection.RootDirectory.GetExecutables())
?.Where(d => selection.ExecutableDirectories.All(s => s.directory != Path.GetDirectoryName(d.path))) ?.Where(d => selection.ExecutableDirectories.All(s => s.directory != Path.GetDirectoryName(d.path)))
?.Select(d => Path.GetDirectoryName(d.path)); .Select(d => Path.GetDirectoryName(d.path));
if (selection.ExecutableDirectories.All(s => s.directory != selection.RootDirectory)) if (selection.ExecutableDirectories.All(s => s.directory != selection.RootDirectory))
invalidDirectories = invalidDirectories?.Append(selection.RootDirectory); invalidDirectories = invalidDirectories?.Append(selection.RootDirectory);
invalidDirectories = invalidDirectories?.Distinct(); invalidDirectories = invalidDirectories?.Distinct();
@ -91,7 +91,7 @@ internal sealed partial class InstallForm : CustomForm
Thread.Sleep(1); Thread.Sleep(1);
} }
if (uninstalling || !selection.Koaloader) if (uninstalling || !selection.Koaloader)
foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories) foreach ((string directory, BinaryType _) in selection.ExecutableDirectories)
{ {
if (Program.Canceled) if (Program.Canceled)
throw new CustomMessageException("The operation was canceled."); throw new CustomMessageException("The operation was canceled.");

View file

@ -42,7 +42,7 @@ internal sealed partial class MainForm : CustomForm
SelectForm form = new(); SelectForm form = new();
#pragma warning restore CA2000 // Dispose objects before losing scope #pragma warning restore CA2000 // Dispose objects before losing scope
form.InheritLocation(this); form.InheritLocation(this);
form.FormClosing += (s, e) => Close(); form.FormClosing += (_, _) => Close();
form.Show(); form.Show();
Hide(); Hide();
#if DEBUG #if DEBUG
@ -89,7 +89,10 @@ internal sealed partial class MainForm : CustomForm
DebugForm.Current.Log($"Exception while checking for updates: {e.GetType()} ({e.Message})", LogTextBox.Warning); DebugForm.Current.Log($"Exception while checking for updates: {e.GetType()} ({e.Message})", LogTextBox.Warning);
} }
#else #else
catch { } catch
{
// ignored
}
#endif #endif
finally finally
{ {
@ -182,7 +185,7 @@ internal sealed partial class MainForm : CustomForm
changelogTreeView.Location = progressBar.Location with { Y = progressBar.Location.Y + progressBar.Size.Height + 6 }; changelogTreeView.Location = progressBar.Location with { Y = progressBar.Location.Y + progressBar.Size.Height + 6 };
Refresh(); Refresh();
Progress<double> progress = new(); Progress<double> progress = new();
progress.ProgressChanged += delegate(object sender, double _progress) progress.ProgressChanged += delegate(object _, double _progress)
{ {
progressLabel.Text = $"Updating . . . {(int)_progress}%"; progressLabel.Text = $"Updating . . . {(int)_progress}%";
progressBar.Value = (int)_progress; progressBar.Value = (int)_progress;
@ -200,7 +203,10 @@ internal sealed partial class MainForm : CustomForm
DebugForm.Current.Log($"Exception while preparing update: {ex.GetType()} ({ex.Message})", LogTextBox.Warning); DebugForm.Current.Log($"Exception while preparing update: {ex.GetType()} ({ex.Message})", LogTextBox.Warning);
} }
#else #else
catch { } catch
{
// ignored
}
#endif #endif
finally finally
{ {

View file

@ -223,10 +223,10 @@ internal sealed partial class SelectForm : CustomForm
VProperty dlcAppInfo = await SteamCMD.GetAppInfo(dlcAppId); VProperty dlcAppInfo = await SteamCMD.GetAppInfo(dlcAppId);
if (dlcAppInfo is not null) if (dlcAppInfo is not null)
{ {
dlcName = dlcAppInfo.Value?.GetChild("common")?.GetChild("name")?.ToString(); dlcName = dlcAppInfo.Value.GetChild("common")?.GetChild("name")?.ToString();
string dlcIconStaticId = dlcAppInfo.Value?.GetChild("common")?.GetChild("icon")?.ToString(); string dlcIconStaticId = dlcAppInfo.Value.GetChild("common")?.GetChild("icon")?.ToString();
dlcIconStaticId ??= dlcAppInfo.Value?.GetChild("common")?.GetChild("logo_small")?.ToString(); dlcIconStaticId ??= dlcAppInfo.Value.GetChild("common")?.GetChild("logo_small")?.ToString();
dlcIconStaticId ??= dlcAppInfo.Value?.GetChild("common")?.GetChild("logo")?.ToString(); dlcIconStaticId ??= dlcAppInfo.Value.GetChild("common")?.GetChild("logo")?.ToString();
if (dlcIconStaticId is not null) if (dlcIconStaticId is not null)
dlcIcon = IconGrabber.SteamAppImagesPath + @$"\{dlcAppId}\{dlcIconStaticId}.jpg"; dlcIcon = IconGrabber.SteamAppImagesPath + @$"\{dlcAppId}\{dlcIconStaticId}.jpg";
} }
@ -265,10 +265,10 @@ internal sealed partial class SelectForm : CustomForm
selection.DllDirectories = dllDirectories; selection.DllDirectories = dllDirectories;
selection.Platform = Platform.Steam; selection.Platform = Platform.Steam;
selection.ProductUrl = "https://store.steampowered.com/app/" + appId; selection.ProductUrl = "https://store.steampowered.com/app/" + appId;
selection.IconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("icon")}.jpg"; selection.IconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value.GetChild("common")?.GetChild("icon")}.jpg";
selection.SubIconUrl = appData?.header_image ?? IconGrabber.SteamAppImagesPath selection.SubIconUrl = appData?.header_image ?? IconGrabber.SteamAppImagesPath
+ @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("clienticon")}.ico"; + @$"\{appId}\{appInfo?.Value.GetChild("common")?.GetChild("clienticon")}.ico";
selection.Publisher = appData?.publishers[0] ?? appInfo?.Value?.GetChild("extended")?.GetChild("publisher")?.ToString(); selection.Publisher = appData?.publishers[0] ?? appInfo?.Value.GetChild("extended")?.GetChild("publisher")?.ToString();
selection.WebsiteUrl = appData?.website; selection.WebsiteUrl = appData?.website;
if (Program.Canceled) if (Program.Canceled)
return; return;
@ -412,8 +412,6 @@ internal sealed partial class SelectForm : CustomForm
programNode.Nodes.Add(entitlementsNode);*/ programNode.Nodes.Add(entitlementsNode);*/
foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in entitlements) foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in entitlements)
{ {
if (programNode is null /* || entitlementsNode is null*/)
return;
string dlcId = pair.Key; string dlcId = pair.Key;
(DlcType type, string name, string icon) dlcApp = (DlcType.EpicEntitlement, pair.Value.name, pair.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;
@ -526,7 +524,7 @@ internal sealed partial class SelectForm : CustomForm
gameChoices.Add((Platform.Paradox, "PL", "Paradox Launcher", gameChoices.Add((Platform.Paradox, "PL", "Paradox Launcher",
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Paradox && p.id == "PL"))); programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Paradox && p.id == "PL")));
if (Directory.Exists(SteamLibrary.InstallPath)) if (Directory.Exists(SteamLibrary.InstallPath))
foreach ((string appId, string name, string branch, int buildId, string gameDirectory) in (await SteamLibrary.GetGames()).Where(g foreach ((string appId, string name, string _, int _, string _) in (await SteamLibrary.GetGames()).Where(g
=> !Program.IsGameBlocked(g.name, g.gameDirectory))) => !Program.IsGameBlocked(g.name, g.gameDirectory)))
gameChoices.Add((Platform.Steam, appId, name, gameChoices.Add((Platform.Steam, appId, name,
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Steam && p.id == appId))); programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Steam && p.id == appId)));
@ -534,8 +532,7 @@ internal sealed partial class SelectForm : CustomForm
foreach (Manifest manifest in (await EpicLibrary.GetGames()).Where(m => !Program.IsGameBlocked(m.DisplayName, m.InstallLocation))) foreach (Manifest manifest in (await EpicLibrary.GetGames()).Where(m => !Program.IsGameBlocked(m.DisplayName, m.InstallLocation)))
gameChoices.Add((Platform.Epic, manifest.CatalogNamespace, manifest.DisplayName, gameChoices.Add((Platform.Epic, manifest.CatalogNamespace, manifest.DisplayName,
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Epic && p.id == manifest.CatalogNamespace))); programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Epic && p.id == manifest.CatalogNamespace)));
foreach ((string gameId, string name, string gameDirectory) in (await UbisoftLibrary.GetGames()).Where(g foreach ((string gameId, string name, string _) in (await UbisoftLibrary.GetGames()).Where(g => !Program.IsGameBlocked(g.name, g.gameDirectory)))
=> !Program.IsGameBlocked(g.name, g.gameDirectory)))
gameChoices.Add((Platform.Ubisoft, gameId, name, gameChoices.Add((Platform.Ubisoft, gameId, name,
programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Ubisoft && p.id == gameId))); programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Ubisoft && p.id == gameId)));
if (gameChoices.Any()) if (gameChoices.Any())
@ -562,7 +559,7 @@ internal sealed partial class SelectForm : CustomForm
int curProgress = 0; int curProgress = 0;
Progress<int> progress = new(); Progress<int> progress = new();
IProgress<int> iProgress = progress; IProgress<int> iProgress = progress;
progress.ProgressChanged += (sender, _progress) => progress.ProgressChanged += (_, _progress) =>
{ {
if (Program.Canceled) if (Program.Canceled)
return; return;
@ -761,16 +758,16 @@ internal sealed partial class SelectForm : CustomForm
: selection.Platform is Platform.Epic : selection.Platform is Platform.Epic
? "Epic GraphQL " ? "Epic GraphQL "
: ""; : "";
queries.Add(new($"Open {platformString}Query", "Notepad", (sender, e) => Diagnostics.OpenFileInNotepad(appInfoJSON))); queries.Add(new($"Open {platformString}Query", "Notepad", (_, _) => Diagnostics.OpenFileInNotepad(appInfoJSON)));
} }
if (File.Exists(appInfoVDF)) if (File.Exists(appInfoVDF))
queries.Add(new("Open SteamCMD Query", "Notepad", (sender, e) => Diagnostics.OpenFileInNotepad(appInfoVDF))); queries.Add(new("Open SteamCMD Query", "Notepad", (_, _) => Diagnostics.OpenFileInNotepad(appInfoVDF)));
if (queries.Any()) if (queries.Any())
{ {
items.Add(new ToolStripSeparator()); items.Add(new ToolStripSeparator());
foreach (ContextMenuItem query in queries) foreach (ContextMenuItem query in queries)
items.Add(query); items.Add(query);
items.Add(new ContextMenuItem("Refresh Queries", "Command Prompt", (sender, e) => items.Add(new ContextMenuItem("Refresh Queries", "Command Prompt", (_, _) =>
{ {
try try
{ {
@ -810,11 +807,11 @@ internal sealed partial class SelectForm : CustomForm
} }
items.Add(new ToolStripSeparator()); items.Add(new ToolStripSeparator());
items.Add(new ContextMenuItem("Open Root Directory", "File Explorer", items.Add(new ContextMenuItem("Open Root Directory", "File Explorer",
(sender, e) => Diagnostics.OpenDirectoryInFileExplorer(selection.RootDirectory))); (_, _) => Diagnostics.OpenDirectoryInFileExplorer(selection.RootDirectory)));
int executables = 0; int executables = 0;
foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories.ToList()) foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories.ToList())
items.Add(new ContextMenuItem($"Open Executable Directory #{++executables} ({(binaryType == BinaryType.BIT32 ? "32" : "64")}-bit)", items.Add(new ContextMenuItem($"Open Executable Directory #{++executables} ({(binaryType == BinaryType.BIT32 ? "32" : "64")}-bit)",
"File Explorer", (sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))); "File Explorer", (_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
List<string> directories = selection.DllDirectories.ToList(); List<string> directories = selection.DllDirectories.ToList();
int steam = 0, epic = 0, r1 = 0, r2 = 0; int steam = 0, epic = 0, r1 = 0, r2 = 0;
if (selection.Platform is Platform.Steam or Platform.Paradox) if (selection.Platform is Platform.Steam or Platform.Paradox)
@ -825,7 +822,7 @@ internal sealed partial class SelectForm : CustomForm
if (File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) || File.Exists(api64_o) || File.Exists(old_config) if (File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) || File.Exists(api64_o) || File.Exists(old_config)
|| File.Exists(config) || File.Exists(cache)) || File.Exists(config) || File.Exists(cache))
items.Add(new ContextMenuItem($"Open Steamworks Directory #{++steam}", "File Explorer", items.Add(new ContextMenuItem($"Open Steamworks Directory #{++steam}", "File Explorer",
(sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))); (_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
} }
if (selection.Platform is Platform.Epic or Platform.Paradox) if (selection.Platform is Platform.Epic or Platform.Paradox)
foreach (string directory in directories) foreach (string directory in directories)
@ -833,7 +830,7 @@ internal sealed partial class SelectForm : CustomForm
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config); directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
if (File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) || File.Exists(api64_o) || File.Exists(config)) if (File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) || File.Exists(api64_o) || File.Exists(config))
items.Add(new ContextMenuItem($"Open EOS Directory #{++epic}", "File Explorer", items.Add(new ContextMenuItem($"Open EOS Directory #{++epic}", "File Explorer",
(sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))); (_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
} }
if (selection.Platform is Platform.Ubisoft) if (selection.Platform is Platform.Ubisoft)
foreach (string directory in directories) foreach (string directory in directories)
@ -841,12 +838,12 @@ internal sealed partial class SelectForm : CustomForm
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config); directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
if (File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) || File.Exists(api64_o) || File.Exists(config)) if (File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) || File.Exists(api64_o) || File.Exists(config))
items.Add(new ContextMenuItem($"Open Uplay R1 Directory #{++r1}", "File Explorer", items.Add(new ContextMenuItem($"Open Uplay R1 Directory #{++r1}", "File Explorer",
(sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))); (_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config); directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config);
if (File.Exists(old_api32) || File.Exists(old_api64) || File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64) if (File.Exists(old_api32) || File.Exists(old_api64) || File.Exists(api32) || File.Exists(api32_o) || File.Exists(api64)
|| File.Exists(api64_o) || File.Exists(config)) || File.Exists(api64_o) || File.Exists(config))
items.Add(new ContextMenuItem($"Open Uplay R2 Directory #{++r2}", "File Explorer", items.Add(new ContextMenuItem($"Open Uplay R2 Directory #{++r2}", "File Explorer",
(sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))); (_, _) => Diagnostics.OpenDirectoryInFileExplorer(directory)));
} }
} }
if (id != "PL") if (id != "PL")
@ -854,36 +851,35 @@ internal sealed partial class SelectForm : CustomForm
if (selection?.Platform is Platform.Steam || dlcParentSelection?.Platform is Platform.Steam) if (selection?.Platform is Platform.Steam || dlcParentSelection?.Platform is Platform.Steam)
{ {
items.Add(new ToolStripSeparator()); items.Add(new ToolStripSeparator());
items.Add(new ContextMenuItem("Open SteamDB", "SteamDB", items.Add(new ContextMenuItem("Open SteamDB", "SteamDB", (_, _) => Diagnostics.OpenUrlInInternetBrowser("https://steamdb.info/app/" + id)));
(sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamdb.info/app/" + id)));
} }
if (selection is not null) if (selection is not null)
switch (selection.Platform) switch (selection.Platform)
{ {
case Platform.Steam: case Platform.Steam:
items.Add(new ContextMenuItem("Open Steam Store", "Steam Store", items.Add(new ContextMenuItem("Open Steam Store", "Steam Store",
(sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))); (_, _) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl)));
items.Add(new ContextMenuItem("Open Steam Community", ("Sub_" + id, selection.SubIconUrl), "Steam Community", items.Add(new ContextMenuItem("Open Steam Community", ("Sub_" + id, selection.SubIconUrl), "Steam Community",
(sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://steamcommunity.com/app/" + id))); (_, _) => Diagnostics.OpenUrlInInternetBrowser("https://steamcommunity.com/app/" + id)));
break; break;
case Platform.Epic: case Platform.Epic:
items.Add(new ToolStripSeparator()); items.Add(new ToolStripSeparator());
items.Add(new ContextMenuItem("Open ScreamDB", "ScreamDB", items.Add(new ContextMenuItem("Open ScreamDB", "ScreamDB",
(sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://scream-db.web.app/offers/" + id))); (_, _) => Diagnostics.OpenUrlInInternetBrowser("https://scream-db.web.app/offers/" + id)));
items.Add(new ContextMenuItem("Open Epic Games Store", "Epic Games", items.Add(new ContextMenuItem("Open Epic Games Store", "Epic Games",
(sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl))); (_, _) => Diagnostics.OpenUrlInInternetBrowser(selection.ProductUrl)));
break; break;
case Platform.Ubisoft: case Platform.Ubisoft:
items.Add(new ToolStripSeparator()); items.Add(new ToolStripSeparator());
items.Add(new ContextMenuItem("Open Ubisoft Store", "Ubisoft Store", items.Add(new ContextMenuItem("Open Ubisoft Store", "Ubisoft Store",
(sender, e) => Diagnostics.OpenUrlInInternetBrowser("https://store.ubi.com/us/" (_, _) => Diagnostics.OpenUrlInInternetBrowser(
+ selection.Name.Replace(" ", "-").ToLowerInvariant()))); "https://store.ubi.com/us/" + selection.Name.Replace(" ", "-").ToLowerInvariant())));
break; break;
} }
} }
if (selection?.WebsiteUrl != null) if (selection?.WebsiteUrl != null)
items.Add(new ContextMenuItem("Open Official Website", ("Web_" + id, IconGrabber.GetDomainFaviconUrl(selection.WebsiteUrl)), items.Add(new ContextMenuItem("Open Official Website", ("Web_" + id, IconGrabber.GetDomainFaviconUrl(selection.WebsiteUrl)),
(sender, e) => Diagnostics.OpenUrlInInternetBrowser(selection.WebsiteUrl))); (_, _) => Diagnostics.OpenUrlInInternetBrowser(selection.WebsiteUrl)));
contextMenuStrip.Show(selectionTreeView, location); contextMenuStrip.Show(selectionTreeView, location);
contextMenuStrip.Refresh(); contextMenuStrip.Refresh();
ContextMenuStrip.Tag = null; ContextMenuStrip.Tag = null;
@ -917,7 +913,7 @@ internal sealed partial class SelectForm : CustomForm
Hide(); Hide();
InstallForm form = new(uninstall); InstallForm form = new(uninstall);
form.InheritLocation(this); form.InheritLocation(this);
form.FormClosing += (s, e) => form.FormClosing += (_, _) =>
{ {
if (form.Reselecting) if (form.Reselecting)
{ {

View file

@ -100,8 +100,7 @@ internal static class ParadoxLauncher
{ {
bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll)) bool koaloaderInstalled = Koaloader.AutoLoadDLLs.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
.Any(pair => File.Exists(pair.path) && pair.path.IsResourceFile()); .Any(pair => File.Exists(pair.path) && pair.path.IsResourceFile());
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string old_config, directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string _, out string config, out _);
out string config, out _);
smokeInstalled = smokeInstalled || File.Exists(api32_o) || File.Exists(api64_o) smokeInstalled = smokeInstalled || File.Exists(api32_o) || File.Exists(api64_o)
|| (File.Exists(config) || File.Exists(config)) && !koaloaderInstalled || (File.Exists(config) || File.Exists(config)) && !koaloaderInstalled
|| File.Exists(api32) && api32.IsResourceFile(ResourceIdentifier.Steamworks32) || File.Exists(api32) && api32.IsResourceFile(ResourceIdentifier.Steamworks32)

View file

@ -141,7 +141,7 @@ internal static class SteamCMD
progress.Report(-1660); // install progress.Report(-1660); // install
int cur = 0; int cur = 0;
progress.Report(cur); progress.Report(cur);
watcher.Changed += (sender, e) => progress.Report(++cur); watcher.Changed += (_, _) => progress.Report(++cur);
_ = await Run(null); _ = await Run(null);
watcher.Dispose(); watcher.Dispose();
} }

View file

@ -44,7 +44,7 @@ internal static class SteamLibrary
return games; return games;
}); });
internal static async Task<List<(string appId, string name, string branch, int buildId, string gameDirectory)>> private static async Task<List<(string appId, string name, string branch, int buildId, string gameDirectory)>>
GetGamesFromLibraryDirectory(string libraryDirectory) GetGamesFromLibraryDirectory(string libraryDirectory)
=> await Task.Run(() => => await Task.Run(() =>
{ {
@ -55,58 +55,55 @@ internal static class SteamLibrary
{ {
if (Program.Canceled) if (Program.Canceled)
return games; return games;
if (ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty result)) if (!ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty result))
{ continue;
string appId = result.Value.GetChild("appid")?.ToString(); string appId = result.Value.GetChild("appid")?.ToString();
string installdir = result.Value.GetChild("installdir")?.ToString(); string installdir = result.Value.GetChild("installdir")?.ToString();
string name = result.Value.GetChild("name")?.ToString(); string name = result.Value.GetChild("name")?.ToString();
string buildId = result.Value.GetChild("buildid")?.ToString(); string buildId = result.Value.GetChild("buildid")?.ToString();
if (string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(installdir) || string.IsNullOrWhiteSpace(name) if (string.IsNullOrWhiteSpace(appId) || string.IsNullOrWhiteSpace(installdir) || string.IsNullOrWhiteSpace(name)
|| string.IsNullOrWhiteSpace(buildId)) || string.IsNullOrWhiteSpace(buildId))
continue; continue;
string gameDirectory = (libraryDirectory + @"\common\" + installdir).BeautifyPath(); string gameDirectory = (libraryDirectory + @"\common\" + installdir).BeautifyPath();
if (games.Any(g => g.appId == appId && g.gameDirectory == gameDirectory)) if (games.Any(g => g.appId == appId && g.gameDirectory == gameDirectory))
continue; continue;
if (!int.TryParse(appId, out int appIdInt)) if (!int.TryParse(appId, out int _))
continue; continue;
if (!int.TryParse(buildId, out int buildIdInt)) if (!int.TryParse(buildId, out int buildIdInt))
continue; continue;
string branch = result.Value.GetChild("UserConfig")?.GetChild("betakey")?.ToString(); string branch = result.Value.GetChild("UserConfig")?.GetChild("betakey")?.ToString();
if (string.IsNullOrWhiteSpace(branch)) if (string.IsNullOrWhiteSpace(branch))
branch = "public"; branch = "public";
games.Add((appId, name, branch, buildIdInt, gameDirectory)); games.Add((appId, name, branch, buildIdInt, gameDirectory));
}
} }
return games; return games;
}); });
internal static async Task<List<string>> GetLibraryDirectories() private static async Task<List<string>> GetLibraryDirectories()
=> await Task.Run(() => => await Task.Run(() =>
{ {
List<string> gameDirectories = new(); List<string> gameDirectories = new();
if (Program.Canceled) if (Program.Canceled)
return gameDirectories; return gameDirectories;
string steamInstallPath = InstallPath; string steamInstallPath = InstallPath;
if (steamInstallPath != null && Directory.Exists(steamInstallPath)) if (steamInstallPath == null || !Directory.Exists(steamInstallPath))
return gameDirectories;
string libraryFolder = steamInstallPath + @"\steamapps";
if (!Directory.Exists(libraryFolder))
return gameDirectories;
gameDirectories.Add(libraryFolder);
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
if (!File.Exists(libraryFolders) || !ValveDataFile.TryDeserialize(File.ReadAllText(libraryFolders, Encoding.UTF8), out VProperty result))
return gameDirectories;
foreach (VToken vToken in result.Value.Where(p => p is VProperty property && int.TryParse(property.Key, out int _)))
{ {
string libraryFolder = steamInstallPath + @"\steamapps"; VProperty property = (VProperty)vToken;
if (Directory.Exists(libraryFolder)) string path = property.Value.GetChild("path")?.ToString();
{ if (string.IsNullOrWhiteSpace(path))
gameDirectories.Add(libraryFolder); continue;
string libraryFolders = libraryFolder + @"\libraryfolders.vdf"; path += @"\steamapps";
if (File.Exists(libraryFolders) && ValveDataFile.TryDeserialize(File.ReadAllText(libraryFolders, Encoding.UTF8), out VProperty result)) if (Directory.Exists(path) && !gameDirectories.Contains(path))
#pragma warning disable IDE0220 // Add explicit cast gameDirectories.Add(path);
foreach (VProperty property in result.Value.Where(p => p is VProperty && int.TryParse((p as VProperty).Key, out int _)))
{
string path = property.Value.GetChild("path")?.ToString();
if (string.IsNullOrWhiteSpace(path))
continue;
path += @"\steamapps";
if (Directory.Exists(path) && !gameDirectories.Contains(path))
gameDirectories.Add(path);
}
#pragma warning restore IDE0220 // Add explicit cast
}
} }
return gameDirectories; return gameDirectories;
}); });

View file

@ -3,12 +3,12 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CreamInstaller.Forms;
using CreamInstaller.Utility; using CreamInstaller.Utility;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
#if DEBUG #if DEBUG
using System; using System;
using CreamInstaller.Forms;
#endif #endif
namespace CreamInstaller.Platforms.Steam; namespace CreamInstaller.Platforms.Steam;

View file

@ -79,9 +79,9 @@ internal static class Program
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.ApplicationExit += OnApplicationExit; Application.ApplicationExit += OnApplicationExit;
Application.ThreadException += (s, e) => e.Exception?.HandleFatalException(); Application.ThreadException += (_, e) => e.Exception.HandleFatalException();
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += (s, e) => (e.ExceptionObject as Exception)?.HandleFatalException(); AppDomain.CurrentDomain.UnhandledException += (_, e) => (e.ExceptionObject as Exception)?.HandleFatalException();
retry: retry:
try try
{ {

View file

@ -53,7 +53,7 @@ internal static class Koaloader
binaryType = bitness switch { "32" => BinaryType.BIT32, "64" => BinaryType.BIT64, _ => BinaryType.Unknown }; binaryType = bitness switch { "32" => BinaryType.BIT32, "64" => BinaryType.BIT64, _ => BinaryType.Unknown };
} }
private static void CheckConfig(string directory, ProgramSelection selection, InstallForm installForm = null) private static void CheckConfig(string directory, InstallForm installForm = null)
{ {
directory.GetKoaloaderComponents(out _, out string old_config, out string config); directory.GetKoaloaderComponents(out _, out string old_config, out string config);
if (File.Exists(old_config)) if (File.Exists(old_config))
@ -345,6 +345,6 @@ internal static class Koaloader
} }
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, installForm);
}); });
} }

View file

@ -432,7 +432,7 @@ internal static class Resources
{ {
e.path = Path.GetDirectoryName(e.path); e.path = Path.GetDirectoryName(e.path);
return e; return e;
})?.DistinctBy(e => e.path).ToList()); }).DistinctBy(e => e.path).ToList());
internal static async Task<List<(string path, BinaryType binaryType)>> GetExecutables(this string rootDirectory, bool filterCommon = false, internal static async Task<List<(string path, BinaryType binaryType)>> GetExecutables(this string rootDirectory, bool filterCommon = false,
Func<string, bool> validFunc = null) Func<string, bool> validFunc = null)

View file

@ -26,12 +26,14 @@ internal static class ScreamAPI
directory.GetScreamApiComponents(out _, out _, out _, out _, out string config); directory.GetScreamApiComponents(out _, out _, out _, out _, out string config);
IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> overrideCatalogItems IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> overrideCatalogItems
= selection.AllDlc.Where(pair => pair.Value.type is DlcType.EpicCatalogItem).Except(selection.SelectedDlc); = selection.AllDlc.Where(pair => pair.Value.type is DlcType.EpicCatalogItem).Except(selection.SelectedDlc);
foreach ((string id, string name, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc) foreach ((string _, string _, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc)
overrideCatalogItems = overrideCatalogItems.Except(extraDlc); overrideCatalogItems = overrideCatalogItems.Except(extraDlc);
IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> entitlements IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> entitlements
= selection.SelectedDlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement); = selection.SelectedDlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement);
foreach ((string id, string name, SortedList<string, (DlcType type, string name, string icon)> _dlc) in selection.ExtraSelectedDlc) foreach ((string _, string _, SortedList<string, (DlcType type, string name, string icon)> _dlc) in selection.ExtraSelectedDlc)
entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement)); entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement));
overrideCatalogItems = overrideCatalogItems.ToList();
entitlements = entitlements.ToList();
if (overrideCatalogItems.Any() || entitlements.Any()) if (overrideCatalogItems.Any() || entitlements.Any())
{ {
/*if (installForm is not null) /*if (installForm is not null)
@ -109,7 +111,7 @@ internal static class ScreamAPI
File.Delete(api32); File.Delete(api32);
installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32!);
installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
@ -119,7 +121,7 @@ internal static class ScreamAPI
File.Delete(api64); File.Delete(api64);
installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64!);
installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
@ -132,10 +134,10 @@ internal static class ScreamAPI
internal static async Task Install(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) internal static async Task Install(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true)
=> await Task.Run(() => => await Task.Run(() =>
{ {
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config); directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string _);
if (File.Exists(api32) && !File.Exists(api32_o)) if (File.Exists(api32) && !File.Exists(api32_o))
{ {
File.Move(api32, api32_o); File.Move(api32, api32_o!);
installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
@ -145,7 +147,7 @@ internal static class ScreamAPI
} }
if (File.Exists(api64) && !File.Exists(api64_o)) if (File.Exists(api64) && !File.Exists(api64_o))
{ {
File.Move(api64, api64_o); File.Move(api64, api64_o!);
installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))

View file

@ -27,17 +27,19 @@ internal static class SmokeAPI
{ {
directory.GetSmokeApiComponents(out _, out _, out _, out _, out string old_config, out _, out _); directory.GetSmokeApiComponents(out _, out _, out _, out _, out string old_config, out _, out _);
IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> overrideDlc = selection.AllDlc.Except(selection.SelectedDlc); IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> overrideDlc = selection.AllDlc.Except(selection.SelectedDlc);
foreach ((string id, string name, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc) foreach ((string _, string _, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc)
overrideDlc = overrideDlc.Except(extraDlc); overrideDlc = overrideDlc.Except(extraDlc);
IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> injectDlc IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> injectDlc
= new List<KeyValuePair<string, (DlcType type, string name, string icon)>>(); = new List<KeyValuePair<string, (DlcType type, string name, string icon)>>();
if (selection.AllDlc.Count > 64 || selection.ExtraDlc.Any(e => e.dlc.Count > 64)) if (selection.AllDlc.Count > 64 || selection.ExtraDlc.Any(e => e.dlc.Count > 64))
{ {
injectDlc = injectDlc.Concat(selection.SelectedDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); injectDlc = injectDlc.Concat(selection.SelectedDlc.Where(pair => pair.Value.type is DlcType.SteamHidden));
foreach ((string id, string name, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc) foreach ((string id, string _, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc)
if (selection.ExtraDlc.Single(e => e.id == id).dlc.Count > 64) if (selection.ExtraDlc.Single(e => e.id == id).dlc.Count > 64)
injectDlc = injectDlc.Concat(extraDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); injectDlc = injectDlc.Concat(extraDlc.Where(pair => pair.Value.type is DlcType.SteamHidden));
} }
overrideDlc = overrideDlc.ToList();
injectDlc = injectDlc.ToList();
if (overrideDlc.Any() || injectDlc.Any()) if (overrideDlc.Any() || injectDlc.Any())
{ {
/*if (installForm is not null) /*if (installForm is not null)
@ -117,7 +119,7 @@ internal static class SmokeAPI
File.Delete(api32); File.Delete(api32);
installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32!);
installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
@ -127,7 +129,7 @@ internal static class SmokeAPI
File.Delete(api64); File.Delete(api64);
installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64!);
installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
} }
if (deleteConfig && File.Exists(old_config)) if (deleteConfig && File.Exists(old_config))
@ -159,7 +161,7 @@ internal static class SmokeAPI
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _, out _); directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out _, out _, out _);
if (File.Exists(api32) && !File.Exists(api32_o)) if (File.Exists(api32) && !File.Exists(api32_o))
{ {
File.Move(api32, api32_o); File.Move(api32, api32_o!);
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
@ -169,7 +171,7 @@ internal static class SmokeAPI
} }
if (File.Exists(api64) && !File.Exists(api64_o)) if (File.Exists(api64) && !File.Exists(api64_o))
{ {
File.Move(api64, api64_o); File.Move(api64, api64_o!);
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))

View file

@ -25,8 +25,9 @@ internal static class UplayR1
{ {
directory.GetUplayR1Components(out _, out _, out _, out _, out string config); directory.GetUplayR1Components(out _, out _, out _, out _, out string config);
IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> blacklistDlc = selection.AllDlc.Except(selection.SelectedDlc); IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> blacklistDlc = selection.AllDlc.Except(selection.SelectedDlc);
foreach ((string id, string name, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc) foreach ((string _, string _, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc)
blacklistDlc = blacklistDlc.Except(extraDlc); blacklistDlc = blacklistDlc.Except(extraDlc);
blacklistDlc = blacklistDlc.ToList();
if (blacklistDlc.Any()) if (blacklistDlc.Any())
{ {
/*if (installForm is not null) /*if (installForm is not null)
@ -80,7 +81,7 @@ internal static class UplayR1
File.Delete(api32); File.Delete(api32);
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32!);
installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
@ -90,7 +91,7 @@ internal static class UplayR1
File.Delete(api64); File.Delete(api64);
installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64!);
installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
@ -103,10 +104,10 @@ internal static class UplayR1
internal static async Task Install(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) internal static async Task Install(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true)
=> await Task.Run(() => => await Task.Run(() =>
{ {
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config); directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string _);
if (File.Exists(api32) && !File.Exists(api32_o)) if (File.Exists(api32) && !File.Exists(api32_o))
{ {
File.Move(api32, api32_o); File.Move(api32, api32_o!);
installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
@ -116,7 +117,7 @@ internal static class UplayR1
} }
if (File.Exists(api64) && !File.Exists(api64_o)) if (File.Exists(api64) && !File.Exists(api64_o))
{ {
File.Move(api64, api64_o); File.Move(api64, api64_o!);
installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))

View file

@ -27,8 +27,9 @@ internal static class UplayR2
{ {
directory.GetUplayR2Components(out _, out _, out _, out _, out _, out _, out string config); directory.GetUplayR2Components(out _, out _, out _, out _, out _, out _, out string config);
IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> blacklistDlc = selection.AllDlc.Except(selection.SelectedDlc); IEnumerable<KeyValuePair<string, (DlcType type, string name, string icon)>> blacklistDlc = selection.AllDlc.Except(selection.SelectedDlc);
foreach ((string id, string name, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc) foreach ((string _, string _, SortedList<string, (DlcType type, string name, string icon)> extraDlc) in selection.ExtraSelectedDlc)
blacklistDlc = blacklistDlc.Except(extraDlc); blacklistDlc = blacklistDlc.Except(extraDlc);
blacklistDlc = blacklistDlc.ToList();
if (blacklistDlc.Any()) if (blacklistDlc.Any())
{ {
/*if (installForm is not null) /*if (installForm is not null)
@ -86,7 +87,7 @@ internal static class UplayR2
File.Delete(api); File.Delete(api);
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
} }
File.Move(api32_o, api); File.Move(api32_o, api!);
installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
@ -97,7 +98,7 @@ internal static class UplayR2
File.Delete(api); File.Delete(api);
installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, false);
} }
File.Move(api64_o, api); File.Move(api64_o, api!);
installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false); installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
@ -111,11 +112,11 @@ internal static class UplayR2
=> await Task.Run(() => => await Task.Run(() =>
{ {
directory.GetUplayR2Components(out string old_api32, out string old_api64, out string api32, out string api32_o, out string api64, directory.GetUplayR2Components(out string old_api32, out string old_api64, out string api32, out string api32_o, out string api64,
out string api64_o, out string config); out string api64_o, out string _);
string api = File.Exists(old_api32) ? old_api32 : api32; string api = File.Exists(old_api32) ? old_api32 : api32;
if (File.Exists(api) && !File.Exists(api32_o)) if (File.Exists(api) && !File.Exists(api32_o))
{ {
File.Move(api, api32_o); File.Move(api, api32_o!);
installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
@ -126,7 +127,7 @@ internal static class UplayR2
api = File.Exists(old_api64) ? old_api64 : api64; api = File.Exists(old_api64) ? old_api64 : api64;
if (File.Exists(api) && !File.Exists(api64_o)) if (File.Exists(api) && !File.Exists(api64_o))
{ {
File.Move(api, api64_o); File.Move(api, api64_o!);
installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false); installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))