- Minor refactoring
- Fixed same-game-same-directory selection duplicates
This commit is contained in:
pointfeev 2022-11-22 13:01:35 -05:00
parent 10bd823d2b
commit d0d8985d4b
23 changed files with 125 additions and 220 deletions

View file

@ -1,4 +1,4 @@
using CreamInstaller.Paradox; using CreamInstaller.Platforms.Paradox;
using CreamInstaller.Utility; using CreamInstaller.Utility;
using System; using System;

View file

@ -40,14 +40,11 @@ internal class CustomTreeView : TreeView
private void OnDisposed(object sender, EventArgs e) private void OnDisposed(object sender, EventArgs e)
{ {
if (backBrush is not null) backBrush?.Dispose();
backBrush.Dispose();
backBrush = null; backBrush = null;
if (comboBoxFont is not null) comboBoxFont?.Dispose();
comboBoxFont.Dispose();
comboBoxFont = null; comboBoxFont = null;
if (comboBoxDropDown is not null) comboBoxDropDown?.Dispose();
comboBoxDropDown.Dispose();
comboBoxDropDown = null; comboBoxDropDown = null;
} }

View file

@ -4,7 +4,7 @@
<TargetFramework>net6.0-windows10.0.22621.0</TargetFramework> <TargetFramework>net6.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<Version>4.2.3.0</Version> <Version>4.2.3.1</Version>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
<Company>CreamInstaller</Company> <Company>CreamInstaller</Company>
<Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product> <Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product>

View file

@ -10,7 +10,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using static CreamInstaller.Paradox.ParadoxLauncher; using static CreamInstaller.Platforms.Paradox.ParadoxLauncher;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
namespace CreamInstaller; namespace CreamInstaller;

View file

@ -1,11 +1,11 @@
#pragma warning disable IDE0058 #pragma warning disable IDE0058
using CreamInstaller.Components; using CreamInstaller.Components;
using CreamInstaller.Epic; using CreamInstaller.Platforms.Epic;
using CreamInstaller.Paradox; using CreamInstaller.Platforms.Paradox;
using CreamInstaller.Platforms.Steam;
using CreamInstaller.Platforms.Ubisoft;
using CreamInstaller.Resources; using CreamInstaller.Resources;
using CreamInstaller.Steam;
using CreamInstaller.Ubisoft;
using CreamInstaller.Utility; using CreamInstaller.Utility;
using Gameloop.Vdf.Linq; using Gameloop.Vdf.Linq;
@ -610,8 +610,7 @@ internal partial class SelectForm : CustomForm
{ {
(string gameId, _) = dlc.Value; (string gameId, _) = dlc.Value;
ProgramSelection selection = ProgramSelection.FromPlatformId(platform, gameId); ProgramSelection selection = ProgramSelection.FromPlatformId(platform, gameId);
if (selection is not null) selection?.ToggleDlc(node.Name, node.Checked);
selection.ToggleDlc(node.Name, node.Checked);
} }
else else
{ {

View file

@ -5,12 +5,13 @@ using Microsoft.Win32;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
namespace CreamInstaller.Epic; namespace CreamInstaller.Platforms.Epic;
internal static class EpicLibrary internal static class EpicLibrary
{ {
@ -43,7 +44,8 @@ internal static class EpicLibrary
try try
{ {
Manifest manifest = JsonSerializer.Deserialize<Manifest>(json); Manifest manifest = JsonSerializer.Deserialize<Manifest>(json);
if (manifest is not null && manifest.CatalogItemId == manifest.MainGameCatalogItemId) if (manifest is not null && manifest.CatalogItemId == manifest.MainGameCatalogItemId
&& !games.Any(g => g.CatalogItemId == manifest.CatalogItemId && g.InstallLocation == manifest.InstallLocation))
games.Add(manifest); games.Add(manifest);
} }
catch { }; catch { };

View file

@ -1,4 +1,4 @@
using CreamInstaller.Epic.GraphQL; using CreamInstaller.Platforms.Epic.GraphQL;
using CreamInstaller.Utility; using CreamInstaller.Utility;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -12,7 +12,7 @@ using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
namespace CreamInstaller.Epic; namespace CreamInstaller.Platforms.Epic;
internal static class EpicStore internal static class EpicStore
{ {
@ -40,7 +40,6 @@ internal static class EpicStore
catch { } catch { }
} }
else if (cachedExists) else if (cachedExists)
{
try try
{ {
response = JsonConvert.DeserializeObject<Response>(File.ReadAllText(cacheFile)); response = JsonConvert.DeserializeObject<Response>(File.ReadAllText(cacheFile));
@ -49,14 +48,13 @@ internal static class EpicStore
{ {
File.Delete(cacheFile); File.Delete(cacheFile);
} }
}
if (response is null) if (response is null)
return dlcIds; return dlcIds;
List<Element> searchStore = new(response.Data.Catalog.SearchStore.Elements); List<Element> searchStore = new(response.Data.Catalog.SearchStore.Elements);
foreach (Element element in searchStore) foreach (Element element in searchStore)
{ {
string title = element.Title; string title = element.Title;
string product = (element.CatalogNs is not null && element.CatalogNs.Mappings.Any()) string product = element.CatalogNs is not null && element.CatalogNs.Mappings.Any()
? element.CatalogNs.Mappings.First().PageSlug : null; ? element.CatalogNs.Mappings.First().PageSlug : null;
string icon = null; string icon = null;
for (int i = 0; i < element.KeyImages?.Length; i++) for (int i = 0; i < element.KeyImages?.Length; i++)
@ -75,7 +73,7 @@ internal static class EpicStore
foreach (Element element in catalogOffers) foreach (Element element in catalogOffers)
{ {
string title = element.Title; string title = element.Title;
string product = (element.CatalogNs is not null && element.CatalogNs.Mappings.Any()) string product = element.CatalogNs is not null && element.CatalogNs.Mappings.Any()
? element.CatalogNs.Mappings.First().PageSlug : null; ? element.CatalogNs.Mappings.First().PageSlug : null;
string icon = null; string icon = null;
for (int i = 0; i < element.KeyImages?.Length; i++) for (int i = 0; i < element.KeyImages?.Length; i++)

View file

@ -5,7 +5,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace CreamInstaller.Epic.GraphQL; namespace CreamInstaller.Platforms.Epic.GraphQL;
internal class Request internal class Request
{ {

View file

@ -4,7 +4,7 @@ using Newtonsoft.Json;
using System; using System;
namespace CreamInstaller.Epic.GraphQL; namespace CreamInstaller.Platforms.Epic.GraphQL;
public class Response public class Response
{ {

View file

@ -1,4 +1,4 @@
namespace CreamInstaller.Epic; namespace CreamInstaller.Platforms.Epic;
public class Manifest public class Manifest
{ {

View file

@ -12,7 +12,7 @@ using System.Windows.Forms;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
namespace CreamInstaller.Paradox; namespace CreamInstaller.Platforms.Paradox;
internal static class ParadoxLauncher internal static class ParadoxLauncher
{ {
@ -43,13 +43,11 @@ internal static class ParadoxLauncher
paradoxLauncher.ExtraSelectedDlc.Add(new(selection.Id, selection.Name, selection.SelectedDlc)); paradoxLauncher.ExtraSelectedDlc.Add(new(selection.Id, selection.Name, selection.SelectedDlc));
} }
if (!paradoxLauncher.ExtraDlc.Any()) if (!paradoxLauncher.ExtraDlc.Any())
{
foreach (ProgramSelection selection in ProgramSelection.AllSafe.Where(s => s != paradoxLauncher && s.Publisher == "Paradox Interactive")) foreach (ProgramSelection selection in ProgramSelection.AllSafe.Where(s => s != paradoxLauncher && s.Publisher == "Paradox Interactive"))
{ {
paradoxLauncher.ExtraDlc.Add(new(selection.Id, selection.Name, selection.AllDlc)); paradoxLauncher.ExtraDlc.Add(new(selection.Id, selection.Name, selection.AllDlc));
paradoxLauncher.ExtraSelectedDlc.Add(new(selection.Id, selection.Name, selection.AllDlc)); paradoxLauncher.ExtraSelectedDlc.Add(new(selection.Id, selection.Name, selection.AllDlc));
} }
}
} }
} }
@ -129,15 +127,13 @@ internal static class ParadoxLauncher
if (steamOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.Steamworks32)) if (steamOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.Steamworks32))
{ {
steamOriginalSdk32.Write(api32); steamOriginalSdk32.Write(api32);
if (installForm is not null) installForm?.UpdateUser("Corrected Steamworks: " + api32, LogTextBox.Action);
installForm.UpdateUser("Corrected Steamworks: " + api32, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (steamOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.Steamworks64)) if (steamOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.Steamworks64))
{ {
steamOriginalSdk64.Write(api64); steamOriginalSdk64.Write(api64);
if (installForm is not null) installForm?.UpdateUser("Corrected Steamworks: " + api64, LogTextBox.Action);
installForm.UpdateUser("Corrected Steamworks: " + api64, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (smokeInstalled) if (smokeInstalled)
@ -146,15 +142,13 @@ internal static class ParadoxLauncher
if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)) if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
{ {
epicOriginalSdk32.Write(api32); epicOriginalSdk32.Write(api32);
if (installForm is not null) installForm?.UpdateUser("Corrected Epic Online Services: " + api32, LogTextBox.Action);
installForm.UpdateUser("Corrected Epic Online Services: " + api32, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (epicOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64)) if (epicOriginalSdk64 is not null && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64))
{ {
epicOriginalSdk64.Write(api64); epicOriginalSdk64.Write(api64);
if (installForm is not null) installForm?.UpdateUser("Corrected Epic Online Services: " + api64, LogTextBox.Action);
installForm.UpdateUser("Corrected Epic Online Services: " + api64, LogTextBox.Action);
neededRepair = true; neededRepair = true;
} }
if (screamInstalled) if (screamInstalled)

View file

@ -5,7 +5,7 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace CreamInstaller.Steam; namespace CreamInstaller.Platforms.Steam;
public class AppData public class AppData
{ {

View file

@ -15,7 +15,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CreamInstaller.Steam; namespace CreamInstaller.Platforms.Steam;
internal static class SteamCMD internal static class SteamCMD
{ {
@ -42,12 +42,10 @@ internal static class SteamCMD
if (Interlocked.CompareExchange(ref locks[i], 1, 0) == 0) if (Interlocked.CompareExchange(ref locks[i], 1, 0) == 0)
{ {
if (appId is not null) if (appId is not null)
{
if (AttemptCount.ContainsKey(appId)) if (AttemptCount.ContainsKey(appId))
AttemptCount[appId]++; AttemptCount[appId]++;
else else
AttemptCount[appId] = 0; AttemptCount[appId] = 0;
}
if (Program.Canceled) return ""; if (Program.Canceled) return "";
ProcessStartInfo processStartInfo = new() ProcessStartInfo processStartInfo = new()
{ {

View file

@ -13,7 +13,7 @@ using System.Threading.Tasks;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
namespace CreamInstaller.Steam; namespace CreamInstaller.Platforms.Steam;
internal static class SteamLibrary internal static class SteamLibrary
{ {
@ -38,11 +38,9 @@ internal static class SteamLibrary
foreach (string libraryDirectory in gameLibraryDirectories) foreach (string libraryDirectory in gameLibraryDirectories)
{ {
if (Program.Canceled) return games; if (Program.Canceled) return games;
List<(string appId, string name, string branch, int buildId, string gameDirectory)> directoryGames = await GetGamesFromLibraryDirectory(libraryDirectory); foreach ((string appId, string name, string branch, int buildId, string gameDirectory) game in (await GetGamesFromLibraryDirectory(libraryDirectory))
if (directoryGames is not null) .Where(game => !games.Any(_game => _game.appId == game.appId && _game.gameDirectory == game.gameDirectory)))
foreach ((string appId, string name, string branch, int buildId, string gameDirectory) game in directoryGames games.Add(game);
.Where(game => !games.Any(_game => _game.appId == game.appId)))
games.Add(game);
} }
return games; return games;
}); });
@ -50,10 +48,10 @@ internal static class SteamLibrary
internal static async Task<List<(string appId, string name, string branch, int buildId, string gameDirectory)>> GetGamesFromLibraryDirectory(string libraryDirectory) => await Task.Run(() => internal static async Task<List<(string appId, string name, string branch, int buildId, string gameDirectory)>> GetGamesFromLibraryDirectory(string libraryDirectory) => await Task.Run(() =>
{ {
List<(string appId, string name, string branch, int buildId, string gameDirectory)> games = new(); List<(string appId, string name, string branch, int buildId, string gameDirectory)> games = new();
if (Program.Canceled || !Directory.Exists(libraryDirectory)) return null; if (Program.Canceled || !Directory.Exists(libraryDirectory)) return games;
foreach (string file in Directory.EnumerateFiles(libraryDirectory, "*.acf")) foreach (string file in Directory.EnumerateFiles(libraryDirectory, "*.acf"))
{ {
if (Program.Canceled) return null; if (Program.Canceled) return games;
if (ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty result)) if (ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty result))
{ {
string appId = result.Value.GetChild("appid")?.ToString(); string appId = result.Value.GetChild("appid")?.ToString();
@ -65,15 +63,16 @@ internal static class SteamLibrary
|| string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(name)
|| string.IsNullOrWhiteSpace(buildId)) || string.IsNullOrWhiteSpace(buildId))
continue; continue;
string branch = result.Value.GetChild("UserConfig")?.GetChild("betakey")?.ToString(); string gameDirectory = (libraryDirectory + @"\common\" + installdir).BeautifyPath();
if (string.IsNullOrWhiteSpace(branch)) branch = "public"; if (games.Any(g => g.appId == appId && g.gameDirectory == gameDirectory)) continue;
string gameDirectory = libraryDirectory + @"\common\" + installdir;
if (!int.TryParse(appId, out int appIdInt)) continue; if (!int.TryParse(appId, out int appIdInt)) continue;
if (!int.TryParse(buildId, out int buildIdInt)) continue; if (!int.TryParse(buildId, out int buildIdInt)) continue;
games.Add((appId, name, branch, buildIdInt, gameDirectory.BeautifyPath())); string branch = result.Value.GetChild("UserConfig")?.GetChild("betakey")?.ToString();
if (string.IsNullOrWhiteSpace(branch)) branch = "public";
games.Add((appId, name, branch, buildIdInt, gameDirectory));
} }
} }
return !games.Any() ? null : games; return games;
}); });
internal static async Task<List<string>> GetLibraryDirectories() => await Task.Run(() => internal static async Task<List<string>> GetLibraryDirectories() => await Task.Run(() =>
@ -95,7 +94,8 @@ internal static class SteamLibrary
string path = property.Value.GetChild("path")?.ToString(); string path = property.Value.GetChild("path")?.ToString();
if (string.IsNullOrWhiteSpace(path)) continue; if (string.IsNullOrWhiteSpace(path)) continue;
path += @"\steamapps"; path += @"\steamapps";
if (Directory.Exists(path) && !gameDirectories.Contains(path)) gameDirectories.Add(path); if (Directory.Exists(path) && !gameDirectories.Contains(path))
gameDirectories.Add(path);
} }
#pragma warning restore IDE0220 // Add explicit cast #pragma warning restore IDE0220 // Add explicit cast
} }

View file

@ -12,7 +12,7 @@ using System.Threading.Tasks;
using System; using System;
#endif #endif
namespace CreamInstaller.Steam; namespace CreamInstaller.Platforms.Steam;
internal static class SteamStore internal static class SteamStore
{ {
@ -40,9 +40,7 @@ internal static class SteamStore
{ {
IDictionary<string, JToken> apps = (IDictionary<string, JToken>)JsonConvert.DeserializeObject(response); IDictionary<string, JToken> apps = (IDictionary<string, JToken>)JsonConvert.DeserializeObject(response);
if (apps is not null) if (apps is not null)
{
foreach (KeyValuePair<string, JToken> app in apps) foreach (KeyValuePair<string, JToken> app in apps)
{
try try
{ {
AppDetails appDetails = JsonConvert.DeserializeObject<AppDetails>(app.Value.ToString()); AppDetails appDetails = JsonConvert.DeserializeObject<AppDetails>(app.Value.ToString());
@ -88,12 +86,6 @@ internal static class SteamStore
{ {
DebugForm.Current.Log($"Unsuccessful deserialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})"); DebugForm.Current.Log($"Unsuccessful deserialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
} }
#else
{ }
#endif
}
}
#if DEBUG
else DebugForm.Current.Log("Response deserialization null for appid " + appId); else DebugForm.Current.Log("Response deserialization null for appid " + appId);
#endif #endif
} }
@ -102,7 +94,6 @@ internal static class SteamStore
#endif #endif
} }
if (cachedExists) if (cachedExists)
{
try try
{ {
return JsonConvert.DeserializeObject<AppData>(File.ReadAllText(cacheFile)); return JsonConvert.DeserializeObject<AppData>(File.ReadAllText(cacheFile));
@ -111,7 +102,6 @@ internal static class SteamStore
{ {
File.Delete(cacheFile); File.Delete(cacheFile);
} }
}
if (!isDlc) if (!isDlc)
{ {
Thread.Sleep(1000); Thread.Sleep(1000);

View file

@ -1,8 +1,7 @@
 using Gameloop.Vdf;
using Gameloop.Vdf;
using Gameloop.Vdf.Linq; using Gameloop.Vdf.Linq;
namespace CreamInstaller.Steam; namespace CreamInstaller.Platforms.Steam;
internal static class ValveDataFile internal static class ValveDataFile
{ {

View file

@ -5,11 +5,12 @@ using Microsoft.Win32;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
namespace CreamInstaller.Ubisoft; namespace CreamInstaller.Platforms.Ubisoft;
internal static class UbisoftLibrary internal static class UbisoftLibrary
{ {
@ -35,9 +36,9 @@ internal static class UbisoftLibrary
foreach (string gameId in installsKey.GetSubKeyNames()) foreach (string gameId in installsKey.GetSubKeyNames())
{ {
RegistryKey installKey = installsKey.OpenSubKey(gameId); RegistryKey installKey = installsKey.OpenSubKey(gameId);
string installDir = installKey?.GetValue("InstallDir")?.ToString(); string installDir = installKey?.GetValue("InstallDir")?.ToString()?.BeautifyPath();
if (installDir is not null) if (installDir is not null && !games.Any(g => g.gameId == gameId && g.gameDirectory == installDir))
games.Add((gameId, new DirectoryInfo(installDir).Name, installDir.BeautifyPath())); games.Add((gameId, new DirectoryInfo(installDir).Name, installDir));
} }
return games; return games;
}); });

View file

@ -1,4 +1,4 @@
using CreamInstaller.Steam; using CreamInstaller.Platforms.Steam;
using CreamInstaller.Utility; using CreamInstaller.Utility;
using System; using System;

View file

@ -78,8 +78,7 @@ internal static class Koaloader
else if (File.Exists(config)) else if (File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -97,8 +96,7 @@ internal static class Koaloader
{ {
string path = pair.Value; string path = pair.Value;
writer.WriteLine($" \"{path}\"{(pair.Equals(lastTarget) ? "" : ",")}"); writer.WriteLine($" \"{path}\"{(pair.Equals(lastTarget) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added target to Koaloader.json with path {path}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added target to Koaloader.json with path {path}", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -115,8 +113,7 @@ internal static class Koaloader
writer.WriteLine($" \"path\": \"" + path + "\","); writer.WriteLine($" \"path\": \"" + path + "\",");
writer.WriteLine($" \"required\": true"); writer.WriteLine($" \"required\": true");
writer.WriteLine(" }" + (pair.Equals(lastModule) ? "" : ",")); writer.WriteLine(" }" + (pair.Equals(lastModule) ? "" : ","));
if (installForm is not null) installForm?.UpdateUser($"Added module to Koaloader.json with path {path}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added module to Koaloader.json with path {path}", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -131,22 +128,19 @@ internal static class Koaloader
foreach (string proxyPath in proxies.Where(proxyPath => File.Exists(proxyPath) && proxyPath.IsResourceFile(ResourceIdentifier.Koaloader))) foreach (string proxyPath in proxies.Where(proxyPath => File.Exists(proxyPath) && proxyPath.IsResourceFile(ResourceIdentifier.Koaloader)))
{ {
File.Delete(proxyPath); File.Delete(proxyPath);
if (installForm is not null) installForm?.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxyPath)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxyPath)}", LogTextBox.Action, info: false);
} }
foreach ((string unlocker, string path) in AutoLoadDlls foreach ((string unlocker, string path) in AutoLoadDlls
.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll)) .Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
.Where(pair => File.Exists(pair.path) && pair.path.IsResourceFile())) .Where(pair => File.Exists(pair.path) && pair.path.IsResourceFile()))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
await SmokeAPI.Uninstall(directory, installForm, deleteConfig); await SmokeAPI.Uninstall(directory, installForm, deleteConfig);
await ScreamAPI.Uninstall(directory, installForm, deleteConfig); await ScreamAPI.Uninstall(directory, installForm, deleteConfig);
@ -164,14 +158,12 @@ internal static class Koaloader
foreach (string _path in proxies.Where(p => p != path && File.Exists(p) && p.IsResourceFile(ResourceIdentifier.Koaloader))) foreach (string _path in proxies.Where(p => p != path && File.Exists(p) && p.IsResourceFile(ResourceIdentifier.Koaloader)))
{ {
File.Delete(_path); File.Delete(_path);
if (installForm is not null) installForm?.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(_path)}", LogTextBox.Action, info: false);
} }
if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader)) if (File.Exists(path) && !path.IsResourceFile(ResourceIdentifier.Koaloader))
throw new CustomMessageException("A non-Koaloader DLL named " + proxy + ".dll already exists in this directory!"); throw new CustomMessageException("A non-Koaloader DLL named " + proxy + ".dll already exists in this directory!");
path.WriteProxy(proxy, binaryType); path.WriteProxy(proxy, binaryType);
if (installForm is not null) installForm?.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote {(binaryType == BinaryType.BIT32 ? "32-bit" : "64-bit")} Koaloader: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
bool bit32 = false, bit64 = false; bool bit32 = false, bit64 = false;
foreach (string executable in Directory.EnumerateFiles(directory, "*.exe")) foreach (string executable in Directory.EnumerateFiles(directory, "*.exe"))
if (executable.TryGetFileBinaryType(out BinaryType binaryType)) if (executable.TryGetFileBinaryType(out BinaryType binaryType))
@ -193,14 +185,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\SmokeAPI32.dll"; path = rootDirectory + @"\SmokeAPI32.dll";
} }
"SmokeAPI.steam_api.dll".Write(path); "SmokeAPI.steam_api.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
@ -210,14 +200,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted SmokeAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\SmokeAPI64.dll"; path = rootDirectory + @"\SmokeAPI64.dll";
} }
"SmokeAPI.steam_api64.dll".Write(path); "SmokeAPI.steam_api64.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote SmokeAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
SmokeAPI.CheckConfig(rootDirectory ?? directory, selection, installForm); SmokeAPI.CheckConfig(rootDirectory ?? directory, selection, installForm);
} }
@ -231,14 +219,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\ScreamAPI32.dll"; path = rootDirectory + @"\ScreamAPI32.dll";
} }
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path); "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
@ -248,14 +234,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted ScreamAPI from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\ScreamAPI64.dll"; path = rootDirectory + @"\ScreamAPI64.dll";
} }
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path); "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote ScreamAPI{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
ScreamAPI.CheckConfig(rootDirectory ?? directory, selection, installForm); ScreamAPI.CheckConfig(rootDirectory ?? directory, selection, installForm);
} }
@ -269,14 +253,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\UplayR1Unlocker32.dll"; path = rootDirectory + @"\UplayR1Unlocker32.dll";
} }
"UplayR1.uplay_r1_loader.dll".Write(path); "UplayR1.uplay_r1_loader.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
@ -286,14 +268,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R1 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\UplayR1Unlocker64.dll"; path = rootDirectory + @"\UplayR1Unlocker64.dll";
} }
"UplayR1.uplay_r1_loader64.dll".Write(path); "UplayR1.uplay_r1_loader64.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R1 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
UplayR1.CheckConfig(rootDirectory ?? directory, selection, installForm); UplayR1.CheckConfig(rootDirectory ?? directory, selection, installForm);
if (bit32) if (bit32)
@ -304,14 +284,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\UplayR2Unlocker32.dll"; path = rootDirectory + @"\UplayR2Unlocker32.dll";
} }
"UplayR2.upc_r2_loader.dll".Write(path); "UplayR2.upc_r2_loader.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
if (bit64) if (bit64)
{ {
@ -321,14 +299,12 @@ internal static class Koaloader
if (File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path); File.Delete(path);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R2 Unlocker from non-root directory: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
path = rootDirectory + @"\UplayR2Unlocker64.dll"; path = rootDirectory + @"\UplayR2Unlocker64.dll";
} }
"UplayR2.upc_r2_loader64.dll".Write(path); "UplayR2.upc_r2_loader64.dll".Write(path);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R2 Unlocker{(rootDirectory is not null && directory != rootDirectory ? " to root directory" : "")}: {Path.GetFileName(path)}", LogTextBox.Action, info: false);
} }
UplayR2.CheckConfig(rootDirectory ?? directory, selection, installForm); UplayR2.CheckConfig(rootDirectory ?? directory, selection, installForm);
} }

View file

@ -50,8 +50,7 @@ internal static class ScreamAPI
else if (File.Exists(config)) else if (File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -73,8 +72,7 @@ internal static class ScreamAPI
string id = pair.Key; string id = pair.Key;
(_, string name, _) = pair.Value; (_, string name, _) = pair.Value;
writer.WriteLine($" \"{id}\"{(pair.Equals(lastOverrideCatalogItem) ? "" : ",")}"); writer.WriteLine($" \"{id}\"{(pair.Equals(lastOverrideCatalogItem) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added override catalog item to ScreamAPI.json with id {id} ({name})", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added override catalog item to ScreamAPI.json with id {id} ({name})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -93,8 +91,7 @@ internal static class ScreamAPI
string id = pair.Key; string id = pair.Key;
(_, string name, _) = pair.Value; (_, string name, _) = pair.Value;
writer.WriteLine($" \"{id}\"{(pair.Equals(lastEntitlement) ? "" : ",")}"); writer.WriteLine($" \"{id}\"{(pair.Equals(lastEntitlement) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added entitlement to ScreamAPI.json with id {id} ({name})", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added entitlement to ScreamAPI.json with id {id} ({name})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ]"); writer.WriteLine(" ]");
} }
@ -112,30 +109,25 @@ internal static class ScreamAPI
if (File.Exists(api32)) if (File.Exists(api32))
{ {
File.Delete(api32); File.Delete(api32);
if (installForm is not null) installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32);
if (installForm is not null) installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored EOS: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
if (File.Exists(api64)) if (File.Exists(api64))
{ {
File.Delete(api64); File.Delete(api64);
if (installForm is not null) installForm?.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64);
if (installForm is not null) installForm?.UpdateUser($"Restored EOS: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored EOS: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
}); });
@ -145,26 +137,22 @@ internal static class ScreamAPI
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed EOS: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(api32); "ScreamAPI.EOSSDK-Win32-Shipping.dll".Write(api32);
if (installForm is not null) installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed EOS: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed EOS: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(api64); "ScreamAPI.EOSSDK-Win64-Shipping.dll".Write(api64);
if (installForm is not null) installForm?.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote ScreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -56,8 +56,7 @@ internal static class SmokeAPI
else if (File.Exists(config)) else if (File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -77,8 +76,7 @@ internal static class SmokeAPI
string dlcId = pair.Key; string dlcId = pair.Key;
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastOverrideDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastOverrideDlc) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added override DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added override DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -93,8 +91,7 @@ internal static class SmokeAPI
string dlcId = pair.Key; string dlcId = pair.Key;
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastInjectDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastInjectDlc) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added inject DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added inject DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -111,8 +108,7 @@ internal static class SmokeAPI
if (File.Exists(oldConfig)) if (File.Exists(oldConfig))
{ {
File.Delete(oldConfig); File.Delete(oldConfig);
if (installForm is not null) installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, info: false);
} }
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string cache); directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string cache);
if (File.Exists(api32_o)) if (File.Exists(api32_o))
@ -120,36 +116,30 @@ internal static class SmokeAPI
if (File.Exists(api32)) if (File.Exists(api32))
{ {
File.Delete(api32); File.Delete(api32);
if (installForm is not null) installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32);
if (installForm is not null) installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
if (File.Exists(api64)) if (File.Exists(api64))
{ {
File.Delete(api64); File.Delete(api64);
if (installForm is not null) installForm?.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64);
if (installForm is not null) installForm?.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(cache)) if (deleteConfig && File.Exists(cache))
{ {
File.Delete(cache); File.Delete(cache);
if (installForm is not null) installForm?.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", LogTextBox.Action, info: false);
} }
}); });
@ -159,33 +149,28 @@ internal static class SmokeAPI
if (File.Exists(oldConfig)) if (File.Exists(oldConfig))
{ {
File.Delete(oldConfig); File.Delete(oldConfig);
if (installForm is not null) installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", LogTextBox.Action, info: false);
} }
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out _); directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, 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);
if (installForm is not null) installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"SmokeAPI.steam_api.dll".Write(api32); "SmokeAPI.steam_api.dll".Write(api32);
if (installForm is not null) installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"SmokeAPI.steam_api64.dll".Write(api64); "SmokeAPI.steam_api64.dll".Write(api64);
if (installForm is not null) installForm?.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote SmokeAPI: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -44,8 +44,7 @@ internal static class UplayR1
else if (File.Exists(config)) else if (File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -64,8 +63,7 @@ internal static class UplayR1
string dlcId = pair.Key; string dlcId = pair.Key;
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added blacklist DLC to UplayR1Unlocker.jsonc with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added blacklist DLC to UplayR1Unlocker.jsonc with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -82,30 +80,25 @@ internal static class UplayR1
if (File.Exists(api32)) if (File.Exists(api32))
{ {
File.Delete(api32); File.Delete(api32);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api32); File.Move(api32_o, api32);
if (installForm is not null) installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
if (File.Exists(api64)) if (File.Exists(api64))
{ {
File.Delete(api64); File.Delete(api64);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api64); File.Move(api64_o, api64);
if (installForm is not null) installForm?.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored Uplay R1: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
}); });
@ -115,26 +108,22 @@ internal static class UplayR1
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"UplayR1.uplay_r1_loader.dll".Write(api32); "UplayR1.uplay_r1_loader.dll".Write(api32);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api32)}", LogTextBox.Action, info: false);
} }
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed Uplay R1: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"UplayR1.uplay_r1_loader64.dll".Write(api64); "UplayR1.uplay_r1_loader64.dll".Write(api64);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R1 Unlocker: {Path.GetFileName(api64)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);

View file

@ -46,8 +46,7 @@ internal static class UplayR2
else if (File.Exists(config)) else if (File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
} }
@ -68,8 +67,7 @@ internal static class UplayR2
string dlcId = pair.Key; string dlcId = pair.Key;
(_, string dlcName, _) = pair.Value; (_, string dlcName, _) = pair.Value;
writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}"); writer.WriteLine($" {dlcId}{(pair.Equals(lastBlacklistDlc) ? "" : ",")}");
if (installForm is not null) installForm?.UpdateUser($"Added blacklist DLC to UplayR2Unlocker.jsonc with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
installForm.UpdateUser($"Added blacklist DLC to UplayR2Unlocker.jsonc with appid {dlcId} ({dlcName})", LogTextBox.Action, info: false);
} }
writer.WriteLine(" ],"); writer.WriteLine(" ],");
} }
@ -87,12 +85,10 @@ internal static class UplayR2
if (File.Exists(api)) if (File.Exists(api))
{ {
File.Delete(api); File.Delete(api);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
File.Move(api32_o, api); File.Move(api32_o, api);
if (installForm is not null) installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
@ -100,18 +96,15 @@ internal static class UplayR2
if (File.Exists(api)) if (File.Exists(api))
{ {
File.Delete(api); File.Delete(api);
if (installForm is not null) installForm?.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
File.Move(api64_o, api); File.Move(api64_o, api);
if (installForm is not null) installForm?.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Restored Uplay R2: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
if (deleteConfig && File.Exists(config)) if (deleteConfig && File.Exists(config))
{ {
File.Delete(config); File.Delete(config);
if (installForm is not null) installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, info: false);
} }
}); });
@ -122,27 +115,23 @@ internal static class UplayR2
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api32_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api32_o)) if (File.Exists(api32_o))
{ {
"UplayR2.upc_r2_loader.dll".Write(api); "UplayR2.upc_r2_loader.dll".Write(api);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
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);
if (installForm is not null) installForm?.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Renamed Uplay R2: {Path.GetFileName(api)} -> {Path.GetFileName(api64_o)}", LogTextBox.Action, info: false);
} }
if (File.Exists(api64_o)) if (File.Exists(api64_o))
{ {
"UplayR2.upc_r2_loader64.dll".Write(api); "UplayR2.upc_r2_loader64.dll".Write(api);
if (installForm is not null) installForm?.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
installForm.UpdateUser($"Wrote Uplay R2 Unlocker: {Path.GetFileName(api)}", LogTextBox.Action, info: false);
} }
if (generateConfig) if (generateConfig)
CheckConfig(directory, selection, installForm); CheckConfig(directory, selection, installForm);