2023-07-12 09:19:33 +02:00
|
|
|
|
using SPTInstaller.Interfaces;
|
2023-05-11 23:11:39 -04:00
|
|
|
|
using SPTInstaller.Models;
|
2022-07-09 00:33:55 -04:00
|
|
|
|
using System.Threading.Tasks;
|
2023-07-12 09:19:33 +02:00
|
|
|
|
using SPTInstaller.Helpers;
|
2022-07-09 00:33:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
namespace SPTInstaller.Installer_Tasks;
|
2022-07-09 00:33:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public class InitializationTask : InstallerTaskBase
|
|
|
|
|
{
|
|
|
|
|
private InternalData _data;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public InitializationTask(InternalData data) : base("Startup")
|
|
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public override async Task<IResult> TaskOperation()
|
|
|
|
|
{
|
2023-07-27 10:03:24 -04:00
|
|
|
|
SetStatus("Initializing", $"Installed EFT Game Path: {FileHelper.GetRedactedPath(_data.OriginalGamePath)}");
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
var result = PreCheckHelper.DetectOriginalGameVersion(_data.OriginalGamePath);
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
_data.OriginalGameVersion = result.Message;
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
SetStatus(null, $"Installed EFT Game Version: {_data.OriginalGameVersion}");
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
if (_data.OriginalGamePath == null)
|
|
|
|
|
{
|
2024-05-01 10:31:55 -04:00
|
|
|
|
return Result.FromError(
|
|
|
|
|
"Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once");
|
2023-07-12 09:19:33 +02:00
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
if (File.Exists(Path.Join(_data.TargetInstallPath, "EscapeFromTarkov.exe")))
|
|
|
|
|
{
|
2024-05-01 10:31:55 -04:00
|
|
|
|
return Result.FromError(
|
|
|
|
|
"Installer is located in a folder that has existing game files. Please make sure the installer is in an empty folder as per the guide");
|
2022-07-09 00:33:55 -04:00
|
|
|
|
}
|
2024-05-01 10:31:55 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
return Result.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
|
2022-07-09 00:33:55 -04:00
|
|
|
|
}
|
2023-07-12 09:19:33 +02:00
|
|
|
|
}
|