2023-05-11 23:11:39 -04:00
using SPTInstaller.Aki.Helper ;
using SPTInstaller.Interfaces ;
using SPTInstaller.Models ;
2022-07-09 00:33:55 -04:00
using System.Threading.Tasks ;
2023-05-11 23:11:39 -04:00
namespace SPTInstaller.Installer_Tasks
2022-07-09 00:33:55 -04:00
{
2023-05-11 23:11:39 -04:00
public class InitializationTask : InstallerTaskBase
2022-07-09 00:33:55 -04:00
{
private InternalData _data ;
public InitializationTask ( InternalData data ) : base ( "Startup" )
{
_data = data ;
}
2023-05-11 23:11:39 -04:00
public override async Task < IResult > TaskOperation ( )
2022-07-09 00:33:55 -04:00
{
2023-05-22 15:09:00 -04:00
SetStatus ( "Initializing" , $"Target Install Path: {FileHelper.GetRedactedPath(_data.TargetInstallPath)}" ) ;
2023-05-18 20:04:00 -04:00
2022-07-09 00:33:55 -04:00
_data . OriginalGamePath = PreCheckHelper . DetectOriginalGamePath ( ) ;
if ( _data . OriginalGamePath = = null )
{
2023-05-11 23:11:39 -04:00
return Result . FromError ( "EFT IS NOT INSTALLED!" ) ;
2022-07-09 00:33:55 -04:00
}
2023-05-22 15:09:00 -04:00
SetStatus ( null , $"Installed EFT Game Path: {FileHelper.GetRedactedPath(_data.OriginalGamePath)}" ) ;
2022-07-25 22:31:30 +01:00
var result = PreCheckHelper . DetectOriginalGameVersion ( _data . OriginalGamePath ) ;
if ( ! result . Succeeded )
{
return result ;
}
_data . OriginalGameVersion = result . Message ;
2022-07-09 00:33:55 -04:00
2023-05-22 15:09:00 -04:00
SetStatus ( null , $"Installed EFT Game Version: {_data.OriginalGameVersion}" ) ;
2022-07-09 00:33:55 -04:00
if ( _data . OriginalGamePath = = null )
{
2023-05-18 20:04:00 -04:00
return Result . FromError ( "Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once" ) ;
2022-07-09 00:33:55 -04:00
}
if ( _data . OriginalGamePath = = _data . TargetInstallPath )
{
2023-05-11 23:11:39 -04:00
return Result . FromError ( "Installer is located in EFT's original directory. Please move the installer to a seperate folder as per the guide" ) ;
2022-07-09 00:33:55 -04:00
}
if ( File . Exists ( Path . Join ( _data . TargetInstallPath , "EscapeFromTarkov.exe" ) ) )
{
2023-05-18 20:04:00 -04:00
return Result . FromError ( "Installer is located in a folder that has existing game files. Please make sure the installer is in a fresh folder as per the guide" ) ;
2022-07-09 00:33:55 -04:00
}
2023-05-11 23:11:39 -04:00
return Result . FromSuccess ( $"Current Game Version: {_data.OriginalGameVersion}" ) ;
2022-07-09 00:33:55 -04:00
}
}
}