2022-05-19 14:41:44 +01:00
|
|
|
|
using Spectre.Console;
|
2022-05-14 02:58:38 +01:00
|
|
|
|
using SPT_AKI_Installer.Aki.Helper;
|
2022-05-19 14:41:44 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-14 02:58:38 +01:00
|
|
|
|
namespace SPT_AKI_Installer.Aki.Core
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
|
|
|
|
//TODO:
|
2022-05-14 02:58:38 +01:00
|
|
|
|
// locales, language selection
|
2022-05-19 14:41:44 +01:00
|
|
|
|
// make the installer download relevant version of patcher and aki based on game version if possible
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
|
|
|
|
public static class SPTinstaller
|
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
static void Main()
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-05-14 12:19:40 +01:00
|
|
|
|
string targetPath = Environment.CurrentDirectory;
|
2022-05-19 14:41:44 +01:00
|
|
|
|
#if DEBUG
|
2022-05-14 02:58:38 +01:00
|
|
|
|
targetPath = @"D:\install";
|
2022-05-19 14:41:44 +01:00
|
|
|
|
#endif
|
|
|
|
|
SpectreHelper.Figlet("SPT-AKI INSTALLER", Color.Yellow);
|
|
|
|
|
PreCheckHelper.GameCheck(out string originalGamePath);
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
if (originalGamePath == targetPath)
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
CloseApp("Installer is located in EFT's original directory! \n Please move the installer to a seperate folder as per the guide!");
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
|
|
|
|
var checkForExistingFiles = FileHelper.FindFile(targetPath, "EscapeFromTarkov.exe");
|
|
|
|
|
//Console.WriteLine(checkForExistingFiles ?? "null");
|
|
|
|
|
if (checkForExistingFiles != null)
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
CloseApp("Installer is located in a Folder that has existing Game Files \n Please make sure the installer is in a fresh folder as per the guide");
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
2022-05-19 14:41:44 +01:00
|
|
|
|
//Console.ReadKey();
|
|
|
|
|
|
|
|
|
|
PreCheckHelper.PatcherZipCheck(originalGamePath, targetPath, out string patcherZipPath);
|
|
|
|
|
PreCheckHelper.AkiZipCheck(targetPath, out string akiZipPath);
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
if (patcherZipPath == null && PreCheckHelper.PatcherNeededCheck())
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
CloseApp("Game Version needs to be patched to match Aki Version \n but Patcher is missing or the wrong version \n Press enter to close the app");
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
|
|
|
|
if (akiZipPath == null)
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
CloseApp("Aki's Zip could not be found \n Press enter to close the app");
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
if (PreCheckHelper.PatcherNeededCheck() && !PreCheckHelper.PatcherAkiCheck())
|
|
|
|
|
{
|
|
|
|
|
CloseApp("Patcher does not match downgraded version that Aki Requires \n Press enter to close the app");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogHelper.Info("Copying game files");
|
|
|
|
|
|
|
|
|
|
GameCopy(originalGamePath, targetPath);
|
|
|
|
|
if (PreCheckHelper.PatcherNeededCheck())
|
|
|
|
|
{
|
|
|
|
|
PatcherCopy(targetPath, patcherZipPath);
|
|
|
|
|
PatcherProcess(targetPath);
|
|
|
|
|
}
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
AkiInstall(targetPath, akiZipPath);
|
|
|
|
|
DeleteZip(patcherZipPath, akiZipPath);
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
static void GameCopy(string originalGamePath, string targetPath)
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
FileHelper.CopyDirectory(originalGamePath, targetPath, true);
|
|
|
|
|
LogHelper.Info("Game has been copied, Extracting patcher");
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
static void PatcherCopy(string targetPath, string patcherZipPath)
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
ZipHelper.Decompress(patcherZipPath, targetPath);
|
|
|
|
|
FileHelper.FindFolder(patcherZipPath, targetPath, out DirectoryInfo dir);
|
2022-05-14 02:58:38 +01:00
|
|
|
|
FileHelper.CopyDirectory(dir.FullName, targetPath, true);
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-05-13 22:41:15 +01:00
|
|
|
|
if (dir.Exists)
|
|
|
|
|
{
|
|
|
|
|
dir.Delete(true);
|
|
|
|
|
dir.Refresh();
|
|
|
|
|
if (dir.Exists)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("unable to delete patcher folder");
|
|
|
|
|
LogHelper.Error($"please delete folder called {dir.FullName}");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
static void PatcherProcess(string targetPath)
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
LogHelper.Info("patcher has been extracted, starting patcher");
|
2022-05-14 02:58:38 +01:00
|
|
|
|
ProcessHelper patcherProcess = new();
|
|
|
|
|
patcherProcess.StartProcess(Path.Join(targetPath + "/patcher.exe"), targetPath);
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
FileHelper.DeleteFiles(Path.Join(targetPath, "/patcher.exe"));
|
|
|
|
|
}
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
static void AkiInstall(string targetPath, string akiZipPath)
|
|
|
|
|
{
|
|
|
|
|
ZipHelper.Decompress(akiZipPath, targetPath);
|
|
|
|
|
LogHelper.Info("Aki has been extracted");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void DeleteZip(string patcherZipPath, string akiZipPath)
|
|
|
|
|
{
|
|
|
|
|
FileHelper.DeleteFiles(patcherZipPath, false);
|
|
|
|
|
FileHelper.DeleteFiles(akiZipPath, false);
|
|
|
|
|
|
|
|
|
|
LogHelper.User("Removed Zips, Press enter to close the installer, you can then delete the installer");
|
|
|
|
|
LogHelper.User("ENJOY SPT-AKI!");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void CloseApp(string text)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Warning(text);
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
Environment.Exit(0);
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|