2024-05-01 10:31:55 -04:00

46 lines
1.5 KiB
C#

using SPTInstaller.Interfaces;
using SPTInstaller.Models;
using System.Threading.Tasks;
using SPTInstaller.Helpers;
namespace SPTInstaller.Installer_Tasks;
public class InitializationTask : InstallerTaskBase
{
private InternalData _data;
public InitializationTask(InternalData data) : base("Startup")
{
_data = data;
}
public override async Task<IResult> TaskOperation()
{
SetStatus("Initializing", $"Installed EFT Game Path: {FileHelper.GetRedactedPath(_data.OriginalGamePath)}");
var result = PreCheckHelper.DetectOriginalGameVersion(_data.OriginalGamePath);
if (!result.Succeeded)
{
return result;
}
_data.OriginalGameVersion = result.Message;
SetStatus(null, $"Installed EFT Game Version: {_data.OriginalGameVersion}");
if (_data.OriginalGamePath == null)
{
return Result.FromError(
"Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once");
}
if (File.Exists(Path.Join(_data.TargetInstallPath, "EscapeFromTarkov.exe")))
{
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");
}
return Result.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
}
}