2022-05-14 12:19:40 +01:00
|
|
|
|
using System.Diagnostics;
|
2022-05-19 14:41:44 +01:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System;
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-14 02:58:38 +01:00
|
|
|
|
namespace SPT_AKI_Installer.Aki.Helper
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
|
|
|
|
public class ProcessHelper
|
|
|
|
|
{
|
|
|
|
|
private Process _process;
|
2022-05-19 14:41:44 +01:00
|
|
|
|
private string _exeDir;
|
|
|
|
|
private string _workingDir;
|
2022-06-06 15:55:46 +01:00
|
|
|
|
private string response;
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
|
|
|
|
public void StartProcess(string exeDir, string workingDir)
|
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
_exeDir = exeDir;
|
|
|
|
|
_workingDir = workingDir;
|
2022-05-13 22:41:15 +01:00
|
|
|
|
_process = new Process();
|
|
|
|
|
_process.StartInfo.FileName = exeDir;
|
|
|
|
|
_process.StartInfo.WorkingDirectory = workingDir;
|
2022-05-19 14:41:44 +01:00
|
|
|
|
_process.EnableRaisingEvents = true;
|
|
|
|
|
_process.StartInfo.Arguments = "autoclose";
|
2022-05-13 22:41:15 +01:00
|
|
|
|
_process.Start();
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
|
|
|
|
_process.WaitForExit();
|
|
|
|
|
ExitCodeCheck(_process.ExitCode);
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public void ExitCodeCheck(int exitCode)
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
/*
|
|
|
|
|
public enum PatcherExitCode
|
|
|
|
|
{
|
|
|
|
|
ProgramClosed = 0,
|
|
|
|
|
Success = 10,
|
|
|
|
|
EftExeNotFound = 11,
|
|
|
|
|
NoPatchFolder = 12,
|
|
|
|
|
MissingFile = 13,
|
|
|
|
|
MissingDir = 14
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
switch (exitCode)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
LogHelper.Warning("Patcher was closed before completing!");
|
2022-06-06 15:55:46 +01:00
|
|
|
|
LogHelper.Warning("If you need to start the patcher again, type retry");
|
|
|
|
|
LogHelper.Warning("If you want to close the installer, close the app.");
|
|
|
|
|
response = Console.ReadLine();
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-06-06 15:55:46 +01:00
|
|
|
|
while (!string.Equals(response, "retry", StringComparison.OrdinalIgnoreCase))
|
2022-05-19 14:41:44 +01:00
|
|
|
|
{
|
2022-06-06 15:55:46 +01:00
|
|
|
|
LogHelper.Warning("Answer needs to be retry");
|
|
|
|
|
LogHelper.Warning("Try Again..");
|
|
|
|
|
response = Console.ReadLine();
|
2022-05-19 14:41:44 +01:00
|
|
|
|
}
|
|
|
|
|
if (string.Equals(response, "retry", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
StartProcess(_exeDir, _workingDir);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 10:
|
2022-06-06 15:55:46 +01:00
|
|
|
|
LogHelper.Info("Patcher Finished Successfully, extracting Aki");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
|
LogHelper.Error("EscapeFromTarkov.exe is missing from the install Path");
|
|
|
|
|
LogHelper.Warning("Check your game files in their original location are complete!");
|
|
|
|
|
LogHelper.Warning("Closing the installer in 20 seconds");
|
|
|
|
|
Thread.Sleep(20000);
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
|
LogHelper.Error("Patchers Folder called 'Aki_Patches' missing");
|
|
|
|
|
LogHelper.Warning("Closing the installer in 20 seconds");
|
|
|
|
|
Thread.Sleep(20000);
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
|
LogHelper.Error("EFT files was missing a Vital file to continue");
|
|
|
|
|
LogHelper.Warning("please reinstall EFT through the BSG launcher");
|
|
|
|
|
LogHelper.Warning("Closing the installer in 20 seconds");
|
|
|
|
|
Thread.Sleep(20000);
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
|
LogHelper.Error("Patcher Reported Missing Folder");
|
|
|
|
|
// check with Waffle what this one is
|
|
|
|
|
LogHelper.Warning("Closing the installer in 20 seconds");
|
|
|
|
|
Thread.Sleep(20000);
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|