v4.1.5.1
- Fixed some harmless installation/uninstallation inconsistencies - Fixed harmless Paradox Launcher repair inconsistencies - Improved exception handling output
This commit is contained in:
parent
43a1c8d248
commit
e4eca9fb0d
7 changed files with 64 additions and 70 deletions
|
@ -5,7 +5,7 @@
|
|||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<Version>4.1.5.0</Version>
|
||||
<Version>4.1.5.1</Version>
|
||||
<PackageIcon>Resources\ini.ico</PackageIcon>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
|
||||
|
|
|
@ -106,14 +106,10 @@ internal partial class InstallForm : CustomForm
|
|||
foreach (string directory in selection.DllDirectories)
|
||||
{
|
||||
if (Program.Canceled) throw new CustomMessageException("The operation was canceled.");
|
||||
if (selection.Platform is Platform.Steam or Platform.Paradox
|
||||
&& (selection.SelectedDlc.Any(d => d.Value.type is DlcType.Steam or DlcType.SteamHidden)
|
||||
|| selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.Steam or DlcType.SteamHidden))))
|
||||
if (selection.Platform is Platform.Steam or Platform.Paradox)
|
||||
{
|
||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out string cache);
|
||||
if (!uninstallProxy && (File.Exists(api32) || File.Exists(api64))
|
||||
|| uninstallProxy && (File.Exists(api32_o) || File.Exists(api64_o)
|
||||
|| !selection.Koaloader && (File.Exists(config) || File.Exists(cache))))
|
||||
if (uninstallProxy ? File.Exists(api32_o) || File.Exists(api64_o) || File.Exists(config) || File.Exists(cache) : File.Exists(api32) || File.Exists(api64))
|
||||
{
|
||||
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} SmokeAPI" +
|
||||
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
|
||||
|
@ -123,14 +119,10 @@ internal partial class InstallForm : CustomForm
|
|||
await SmokeAPI.Install(directory, selection, this);
|
||||
}
|
||||
}
|
||||
if (selection.Platform is Platform.Epic or Platform.Paradox
|
||||
&& (selection.SelectedDlc.Any(d => d.Value.type is DlcType.EpicCatalogItem or DlcType.EpicEntitlement)
|
||||
|| selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.EpicCatalogItem or DlcType.EpicEntitlement))))
|
||||
if (selection.Platform is Platform.Epic or Platform.Paradox)
|
||||
{
|
||||
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
|
||||
if (!uninstallProxy && (File.Exists(api32) || File.Exists(api64))
|
||||
|| uninstallProxy && (File.Exists(api32_o) || File.Exists(api64_o)
|
||||
|| !selection.Koaloader && File.Exists(config)))
|
||||
if (uninstallProxy ? File.Exists(api32_o) || File.Exists(api64_o) || File.Exists(config) : File.Exists(api32) || File.Exists(api64))
|
||||
{
|
||||
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} ScreamAPI" +
|
||||
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
|
||||
|
@ -143,9 +135,7 @@ internal partial class InstallForm : CustomForm
|
|||
if (selection.Platform is Platform.Ubisoft)
|
||||
{
|
||||
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, out string api64_o, out string config);
|
||||
if (!uninstallProxy && (File.Exists(api32) || File.Exists(api64))
|
||||
|| uninstallProxy && (File.Exists(api32_o) || File.Exists(api64_o)
|
||||
|| !selection.Koaloader && File.Exists(config)))
|
||||
if (uninstallProxy ? File.Exists(api32_o) || File.Exists(api64_o) || File.Exists(config) : File.Exists(api32) || File.Exists(api64))
|
||||
{
|
||||
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" +
|
||||
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
|
||||
|
@ -155,9 +145,7 @@ internal partial class InstallForm : CustomForm
|
|||
await UplayR1.Install(directory, selection, this);
|
||||
}
|
||||
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, out api64, out api64_o, out config);
|
||||
if (!uninstallProxy && (File.Exists(old_api32) || File.Exists(old_api64) || File.Exists(api32) || File.Exists(api64))
|
||||
|| uninstallProxy && (File.Exists(api32_o) || File.Exists(api64_o)
|
||||
|| !selection.Koaloader && File.Exists(config)))
|
||||
if (uninstallProxy ? File.Exists(api32_o) || File.Exists(api64_o) || File.Exists(config) : File.Exists(old_api32) || File.Exists(old_api64) || File.Exists(api32) || File.Exists(api64))
|
||||
{
|
||||
UpdateUser($"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" +
|
||||
$" {(uninstallProxy ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
|
||||
|
|
|
@ -750,7 +750,7 @@ internal partial class SelectForm : CustomForm
|
|||
{
|
||||
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))
|
||||
items.Add(new ContextMenuItem($"Open Epic Online Services Directory #{++epic}", "File Explorer",
|
||||
items.Add(new ContextMenuItem($"Open EOS Directory #{++epic}", "File Explorer",
|
||||
new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))));
|
||||
}
|
||||
if (selection.Platform is Platform.Ubisoft)
|
||||
|
|
|
@ -85,24 +85,29 @@ internal static class ParadoxLauncher
|
|||
if (!Program.IsProgramRunningDialog(form, selection))
|
||||
return form is InstallForm ? throw new CustomMessageException("Repair failed! The launcher is currently running!")
|
||||
: RepairResult.ProgramRunning;
|
||||
bool smokeConfig = false;
|
||||
bool smokeInstalled = false;
|
||||
byte[] steamOriginalSdk32 = null;
|
||||
byte[] steamOriginalSdk64 = null;
|
||||
bool screamConfig = false;
|
||||
bool screamInstalled = false;
|
||||
byte[] epicOriginalSdk32 = null;
|
||||
byte[] epicOriginalSdk64 = null;
|
||||
foreach (string directory in selection.DllDirectories)
|
||||
{
|
||||
directory.GetSmokeApiComponents(out string api32, out _, out string api64, out _, out string config, out _);
|
||||
smokeConfig = smokeConfig || File.Exists(config);
|
||||
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, out string config, out _);
|
||||
smokeInstalled = smokeInstalled
|
||||
|| File.Exists(api32_o) || File.Exists(api64_o) || File.Exists(config)
|
||||
|| File.Exists(api32) && api32.IsResourceFile(ResourceIdentifier.Steamworks32)
|
||||
|| File.Exists(api64) && api64.IsResourceFile(ResourceIdentifier.Steamworks64);
|
||||
await SmokeAPI.Uninstall(directory, deleteConfig: false);
|
||||
if (steamOriginalSdk32 is null && File.Exists(api32) && !api32.IsResourceFile(ResourceIdentifier.Steamworks32))
|
||||
steamOriginalSdk32 = File.ReadAllBytes(api32);
|
||||
if (steamOriginalSdk64 is null && File.Exists(api64) && !api64.IsResourceFile(ResourceIdentifier.Steamworks64))
|
||||
steamOriginalSdk64 = File.ReadAllBytes(api64);
|
||||
|
||||
directory.GetScreamApiComponents(out api32, out _, out api64, out _, out config);
|
||||
screamConfig = screamConfig || File.Exists(config);
|
||||
directory.GetScreamApiComponents(out api32, out api32_o, out api64, out api64_o, out config);
|
||||
screamInstalled = screamInstalled
|
||||
|| File.Exists(api32_o) || File.Exists(api64_o) || File.Exists(config)
|
||||
|| File.Exists(api32) && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)
|
||||
|| File.Exists(api64) && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64);
|
||||
await ScreamAPI.Uninstall(directory, deleteConfig: false);
|
||||
if (epicOriginalSdk32 is null && File.Exists(api32) && !api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
|
||||
epicOriginalSdk32 = File.ReadAllBytes(api32);
|
||||
|
@ -130,9 +135,8 @@ internal static class ParadoxLauncher
|
|||
installForm.UpdateUser("Corrected Steamworks: " + api64, LogTextBox.Action);
|
||||
neededRepair = true;
|
||||
}
|
||||
if (!selection.Koaloader && smokeConfig)
|
||||
if (smokeInstalled)
|
||||
await SmokeAPI.Install(directory, selection, generateConfig: false);
|
||||
|
||||
directory.GetScreamApiComponents(out api32, out _, out api64, out _, out _);
|
||||
if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
|
||||
{
|
||||
|
@ -148,7 +152,7 @@ internal static class ParadoxLauncher
|
|||
installForm.UpdateUser("Corrected Epic Online Services: " + api64, LogTextBox.Action);
|
||||
neededRepair = true;
|
||||
}
|
||||
if (!selection.Koaloader && screamConfig)
|
||||
if (screamInstalled)
|
||||
await ScreamAPI.Install(directory, selection, generateConfig: false);
|
||||
}
|
||||
if (neededRepair)
|
||||
|
|
|
@ -117,7 +117,7 @@ internal static class ScreamAPI
|
|||
}
|
||||
File.Move(api32_o, api32);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Restored Epic Online Services: {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))
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ internal static class ScreamAPI
|
|||
}
|
||||
File.Move(api64_o, api64);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Restored Epic Online Services: {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))
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ internal static class ScreamAPI
|
|||
{
|
||||
File.Move(api32, api32_o);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Renamed Epic Online Services: {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))
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ internal static class ScreamAPI
|
|||
{
|
||||
File.Move(api64, api64_o);
|
||||
if (installForm is not null)
|
||||
installForm.UpdateUser($"Renamed Epic Online Services: {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))
|
||||
{
|
||||
|
|
|
@ -107,6 +107,13 @@ internal static class SmokeAPI
|
|||
|
||||
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() =>
|
||||
{
|
||||
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
|
||||
if (File.Exists(oldConfig))
|
||||
{
|
||||
File.Delete(oldConfig);
|
||||
if (installForm is not null)
|
||||
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);
|
||||
if (File.Exists(api32_o))
|
||||
{
|
||||
|
|
|
@ -9,44 +9,39 @@ internal static class ExceptionHandler
|
|||
{
|
||||
internal static bool HandleException(this Exception e, Form form = null, string caption = null, string acceptButtonText = "Retry", string cancelButtonText = "Cancel")
|
||||
{
|
||||
caption ??= Program.Name + " encountered a fatal exception";
|
||||
while (e.InnerException is not null) // we usually don't need the outer exceptions
|
||||
e = e.InnerException;
|
||||
caption ??= Program.Name + " encountered an exception";
|
||||
StringBuilder output = new();
|
||||
string[] stackTrace = e.StackTrace?.Split('\n');
|
||||
if (stackTrace is not null && stackTrace.Length > 0)
|
||||
{
|
||||
_ = output.Append("STACK TRACE\n");
|
||||
for (int i = 0; i < Math.Min(stackTrace.Length, 3); i++)
|
||||
{
|
||||
string line = stackTrace[i];
|
||||
int atNum = line.IndexOf("at ");
|
||||
int inNum = line.IndexOf("in ");
|
||||
int ciNum = line.LastIndexOf(@"CreamInstaller\");
|
||||
int lineNum = line.LastIndexOf(":line ");
|
||||
if (line is not null && atNum != -1)
|
||||
_ = output.Append("\n " + (inNum != -1 ? line[atNum..(inNum - 1)] : line[atNum..])
|
||||
+ (inNum != -1 ? ("\n "
|
||||
+ (ciNum != -1 ? ("in "
|
||||
+ (lineNum != -1 ? line[ciNum..lineNum]
|
||||
+ "\n on " + line[(lineNum + 1)..]
|
||||
: line[ciNum..]))
|
||||
: line[inNum..]))
|
||||
: null));
|
||||
}
|
||||
}
|
||||
string[] messageLines = e.Message?.Split('\n');
|
||||
if (messageLines is not null && messageLines.Length > 0)
|
||||
int stackDepth = 0;
|
||||
while (e is not null)
|
||||
{
|
||||
if (stackDepth > 10)
|
||||
break;
|
||||
if (output.Length > 0)
|
||||
_ = output.Append("\n\n");
|
||||
_ = output.Append("MESSAGE\n");
|
||||
for (int i = 0; i < messageLines.Length; i++)
|
||||
string[] stackTrace = e.StackTrace?.Split('\n');
|
||||
if (stackTrace is not null && stackTrace.Length > 0)
|
||||
{
|
||||
string line = messageLines[i];
|
||||
if (line is not null)
|
||||
_ = output.Append("\n " + line);
|
||||
_ = output.Append(e.GetType() + (e.Message is not null ? (": " + e.Message) : ""));
|
||||
for (int i = 0; i < stackTrace.Length; i++)
|
||||
{
|
||||
string line = stackTrace[i];
|
||||
int atNum = line.IndexOf("at ");
|
||||
int inNum = line.IndexOf("in ");
|
||||
int ciNum = line.LastIndexOf(@"CreamInstaller\");
|
||||
int lineNum = line.LastIndexOf(":line ");
|
||||
if (line is not null && atNum != -1)
|
||||
_ = output.Append("\n " + (inNum != -1 ? line[atNum..(inNum - 1)] : line[atNum..])
|
||||
+ (inNum != -1 ? ("\n "
|
||||
+ (ciNum != -1 ? ("in "
|
||||
+ (lineNum != -1 ? line[ciNum..lineNum]
|
||||
+ "\n on " + line[(lineNum + 1)..]
|
||||
: line[ciNum..]))
|
||||
: line[inNum..]))
|
||||
: null));
|
||||
}
|
||||
}
|
||||
e = e.InnerException;
|
||||
stackDepth++;
|
||||
}
|
||||
using DialogForm dialogForm = new(form ?? Form.ActiveForm);
|
||||
return dialogForm.Show(SystemIcons.Error, output.ToString(), acceptButtonText, cancelButtonText, customFormText: caption) == DialogResult.OK;
|
||||
|
@ -54,7 +49,7 @@ internal static class ExceptionHandler
|
|||
|
||||
internal static void HandleFatalException(this Exception e)
|
||||
{
|
||||
bool? restart = e?.HandleException(acceptButtonText: "Restart");
|
||||
bool? restart = e?.HandleException(caption: Program.Name + " encountered a fatal exception", acceptButtonText: "Restart");
|
||||
if (restart.HasValue && restart.Value)
|
||||
Application.Restart();
|
||||
Application.Exit();
|
||||
|
@ -68,9 +63,9 @@ public class CustomMessageException : Exception
|
|||
|
||||
public override string ToString() => Message;
|
||||
|
||||
public CustomMessageException() => message = "CustomMessageException";
|
||||
public CustomMessageException() : base() => message = "CustomMessageException";
|
||||
|
||||
public CustomMessageException(string message) => this.message = message;
|
||||
public CustomMessageException(string message) : base(message) => this.message = message;
|
||||
|
||||
public CustomMessageException(string message, Exception _) => this.message = message;
|
||||
public CustomMessageException(string message, Exception e) : base(message, e) => this.message = message;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue