2022-05-14 12:19:40 +01:00
|
|
|
|
using Microsoft.Win32;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace SPT_AKI_Installer.Aki.Helper
|
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public static class PreCheckHelper
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
|
|
|
|
private const string registryInstall = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
|
2022-05-30 13:04:54 +01:00
|
|
|
|
private static string OGGamePath;
|
|
|
|
|
public static string gameVersion;
|
2022-05-19 14:41:44 +01:00
|
|
|
|
private static string patchZip;
|
|
|
|
|
private static string akiZip;
|
2022-05-14 12:19:40 +01:00
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public static string DetectOriginalGamePath()
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
|
|
|
|
// We can't detect the installed path on non-Windows
|
|
|
|
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var uninstallStringValue = Registry.LocalMachine.OpenSubKey(registryInstall, false)
|
|
|
|
|
?.GetValue("UninstallString");
|
|
|
|
|
var info = (uninstallStringValue is string key) ? new FileInfo(key) : null;
|
2022-05-30 13:04:54 +01:00
|
|
|
|
OGGamePath = info?.DirectoryName;
|
|
|
|
|
|
|
|
|
|
return OGGamePath;
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public static void GameCheck(out string gamePath)
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
|
|
|
|
string Path = DetectOriginalGamePath();
|
|
|
|
|
|
|
|
|
|
if (Path == null)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("EFT IS NOT INSTALLED!");
|
|
|
|
|
LogHelper.Error("Press enter to close the app");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
gamePath = Path;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-30 13:04:54 +01:00
|
|
|
|
public static void DetectOriginalGameVersion(string gamePath)
|
|
|
|
|
{
|
|
|
|
|
gameVersion = FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public static void PatcherZipCheck(string gamePath, string targetPath, out string patcherZipPath)
|
|
|
|
|
{
|
|
|
|
|
// example patch name - Patcher.12.12.15.17861.to.12.12.15.17349.zip
|
|
|
|
|
patchZip = FileHelper.FindFile(targetPath, gameVersion, "Patcher");
|
2022-05-30 13:04:54 +01:00
|
|
|
|
if (patchZip == null)
|
|
|
|
|
{
|
2022-05-31 14:49:28 +01:00
|
|
|
|
patchZip = FileHelper.FindFile(targetPath, "PATCHERZIP");
|
2022-05-30 13:04:54 +01:00
|
|
|
|
}
|
2022-05-19 14:41:44 +01:00
|
|
|
|
patcherZipPath = patchZip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void AkiZipCheck(string targetPath, out string akiZipPath)
|
|
|
|
|
{
|
|
|
|
|
// example aki name - RELEASE-SPT-2.3.1-17349.zip
|
|
|
|
|
akiZip = FileHelper.FindFile(targetPath, "SPT", "RELEASE");
|
2022-05-30 13:04:54 +01:00
|
|
|
|
if (akiZip == null)
|
|
|
|
|
{
|
2022-05-31 14:49:28 +01:00
|
|
|
|
akiZip = FileHelper.FindFile(targetPath, "AKIZIP");
|
2022-05-30 13:04:54 +01:00
|
|
|
|
}
|
2022-05-19 14:41:44 +01:00
|
|
|
|
akiZipPath = akiZip;
|
|
|
|
|
}
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|