all the things
This commit is contained in:
parent
0fc99bf5cd
commit
b999f3cb4c
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace SPT_AKI_Installer.Aki.Core
|
namespace SPT_AKI_Installer.Aki.Core
|
||||||
{
|
{
|
||||||
@ -19,6 +20,15 @@ namespace SPT_AKI_Installer.Aki.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string OriginalGameVersion { get; set; }
|
public string OriginalGameVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patcher zip file info
|
||||||
|
/// </summary>
|
||||||
|
public FileInfo PatcherZipInfo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SPT-AKI zip file info
|
||||||
|
/// </summary>
|
||||||
|
public FileInfo AkiZipInfo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The release download link for SPT-AKI
|
/// The release download link for SPT-AKI
|
||||||
|
@ -29,7 +29,8 @@ namespace SPT_AKI_Installer.Aki.Core.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int RowIndex { get; set; }
|
public int RowIndex { get; set; }
|
||||||
|
|
||||||
private bool _continueRendering = false;
|
private bool _continueRenderingProgress = false;
|
||||||
|
private bool _continueRenderingIndeterminateProgress = false;
|
||||||
|
|
||||||
private int _indeterminateState = 0;
|
private int _indeterminateState = 0;
|
||||||
|
|
||||||
@ -66,14 +67,19 @@ namespace SPT_AKI_Installer.Aki.Core.Model
|
|||||||
/// <remarks>this doesn't need to be called if you set isIndeterminate in the constructor. You need to set IsIndeterminate to false to stop this background task</remarks>
|
/// <remarks>this doesn't need to be called if you set isIndeterminate in the constructor. You need to set IsIndeterminate to false to stop this background task</remarks>
|
||||||
public void StartDrawingIndeterminateProgress()
|
public void StartDrawingIndeterminateProgress()
|
||||||
{
|
{
|
||||||
_continueRendering = true;
|
_continueRenderingProgress = false;
|
||||||
new Task(new Action(() => { RenderIndeterminateProgress(ref _continueRendering); })).Start();
|
_continueRenderingIndeterminateProgress = true;
|
||||||
|
|
||||||
|
new Task(new Action(() => { RenderIndeterminateProgress(ref _continueRenderingIndeterminateProgress); })).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartDrawingProgress()
|
public void StartDrawingProgress()
|
||||||
{
|
{
|
||||||
_continueRendering = true;
|
Progress = 0;
|
||||||
new Task(new Action(() => { RenderProgress(ref _continueRendering); })).Start();
|
_continueRenderingIndeterminateProgress = false;
|
||||||
|
_continueRenderingProgress = true;
|
||||||
|
|
||||||
|
new Task(new Action(() => { RenderProgress(ref _continueRenderingProgress); })).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReRenderEntry(string message)
|
private void ReRenderEntry(string message)
|
||||||
@ -134,7 +140,8 @@ namespace SPT_AKI_Installer.Aki.Core.Model
|
|||||||
|
|
||||||
if (stopRendering)
|
if (stopRendering)
|
||||||
{
|
{
|
||||||
_continueRendering = false;
|
_continueRenderingProgress = false;
|
||||||
|
_continueRenderingIndeterminateProgress = false;
|
||||||
ReRenderEntry(message);
|
ReRenderEntry(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,42 +30,6 @@ namespace SPT_AKI_Installer.Aki.Core
|
|||||||
.RunTasksAsync(taskList)
|
.RunTasksAsync(taskList)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
// GameCopy(originalGamePath, targetPath);
|
|
||||||
|
|
||||||
// if (DownloadHelper.patchNeedCheck)
|
|
||||||
// {
|
|
||||||
// PatcherCopy(targetPath, patcherZipPath);
|
|
||||||
// PatcherProcess(targetPath);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// AkiInstall(targetPath, akiZipPath);
|
|
||||||
// DeleteZip(patcherZipPath, akiZipPath);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void GameCopy(string originalGamePath, string targetPath)
|
|
||||||
// {
|
|
||||||
// LogHelper.Info("Copying game files");
|
|
||||||
// FileHelper.CopyDirectory(originalGamePath, targetPath, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void PatcherCopy(string targetPath, string patcherZipPath)
|
|
||||||
// {
|
|
||||||
// LogHelper.Info("Extracting patcher");
|
|
||||||
// ZipHelper.ZipDecompress(patcherZipPath, targetPath);
|
|
||||||
// FileHelper.FindFolder(patcherZipPath, targetPath, out DirectoryInfo dir);
|
|
||||||
// FileHelper.CopyDirectory(dir.FullName, targetPath, true);
|
|
||||||
|
|
||||||
// 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}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPTinstaller(
|
public SPTinstaller(
|
||||||
@ -91,6 +55,7 @@ namespace SPT_AKI_Installer.Aki.Core
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
await LiveTableTaskRunner.RunAsync(tasks);
|
await LiveTableTaskRunner.RunAsync(tasks);
|
||||||
|
CloseApp("SPT is Ready to play");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IHost ConfigureHost()
|
private static IHost ConfigureHost()
|
||||||
@ -102,37 +67,12 @@ namespace SPT_AKI_Installer.Aki.Core
|
|||||||
services.AddTransient<LiveTableTask, ReleaseCheckTask>();
|
services.AddTransient<LiveTableTask, ReleaseCheckTask>();
|
||||||
services.AddTransient<LiveTableTask, DownloadTask>();
|
services.AddTransient<LiveTableTask, DownloadTask>();
|
||||||
services.AddTransient<LiveTableTask, CopyClientTask>();
|
services.AddTransient<LiveTableTask, CopyClientTask>();
|
||||||
|
services.AddTransient<LiveTableTask, SetupClientTask>();
|
||||||
services.AddTransient<SPTinstaller>();
|
services.AddTransient<SPTinstaller>();
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void PatcherProcess(string targetPath)
|
|
||||||
//{
|
|
||||||
// LogHelper.Info("Starting patcher");
|
|
||||||
// ProcessHelper patcherProcess = new();
|
|
||||||
// patcherProcess.StartProcess(Path.Join(targetPath + "/patcher.exe"), targetPath);
|
|
||||||
|
|
||||||
// FileHelper.DeleteFiles(Path.Join(targetPath, "/patcher.exe"));
|
|
||||||
//}
|
|
||||||
|
|
||||||
//static void AkiInstall(string targetPath, string akiZipPath)
|
|
||||||
//{
|
|
||||||
// ZipHelper.ZipDecompress(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)
|
static void CloseApp(string text)
|
||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine($"[yellow]{text.EscapeMarkup()}[/]");
|
AnsiConsole.MarkupLine($"[yellow]{text.EscapeMarkup()}[/]");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SPT_AKI_Installer.Aki.Core.Model;
|
using SPT_AKI_Installer.Aki.Core.Model;
|
||||||
|
using SPT_AKI_Installer.Aki.Helper;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -18,30 +19,12 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
{
|
{
|
||||||
SetStatus("Copying", false);
|
SetStatus("Copying", false);
|
||||||
|
|
||||||
try
|
var originalGameDirInfo = new DirectoryInfo(_data.OriginalGamePath);
|
||||||
{
|
var targetInstallDirInfo = new DirectoryInfo(_data.TargetInstallPath);
|
||||||
int totalFiles = Directory.GetFiles(_data.OriginalGamePath, "*.*", SearchOption.AllDirectories).Length;
|
|
||||||
int processedFiles = 0;
|
|
||||||
|
|
||||||
foreach (string dirPath in Directory.GetDirectories(_data.OriginalGamePath, "*", SearchOption.AllDirectories))
|
var progress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
{
|
|
||||||
Directory.CreateDirectory(dirPath.Replace(_data.OriginalGamePath, _data.TargetInstallPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string newPath in Directory.GetFiles(_data.OriginalGamePath, "*.*", SearchOption.AllDirectories))
|
return FileHelper.CopyDirectoryWithProgress(originalGameDirInfo, targetInstallDirInfo, progress);
|
||||||
{
|
|
||||||
File.Copy(newPath, newPath.Replace(_data.OriginalGamePath, _data.TargetInstallPath), true);
|
|
||||||
processedFiles++;
|
|
||||||
|
|
||||||
Progress = (int)Math.Floor(((double)processedFiles / totalFiles) * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GenericResult.FromSuccess();
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
return GenericResult.FromError(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
{
|
{
|
||||||
var mirrorListInfo = new FileInfo(Path.Join(_data.TargetInstallPath, "mirrors.json"));
|
var mirrorListInfo = new FileInfo(Path.Join(_data.TargetInstallPath, "mirrors.json"));
|
||||||
|
|
||||||
SetStatus("Downloading mirror list", false);
|
SetStatus("Downloading Mirror List", false);
|
||||||
|
|
||||||
var progress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
var progress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
|
|
||||||
@ -45,11 +45,11 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
return GenericResult.FromError("Failed to deserialize mirrors list");
|
return GenericResult.FromError("Failed to deserialize mirrors list");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<GenericResult> DownloadPatcherFromMirrors(FileInfo patcherZip, IProgress<double> progress)
|
private async Task<GenericResult> DownloadPatcherFromMirrors(IProgress<double> progress)
|
||||||
{
|
{
|
||||||
foreach (string mirror in _data.PatcherReleaseMirrors)
|
foreach (string mirror in _data.PatcherReleaseMirrors)
|
||||||
{
|
{
|
||||||
SetStatus($"Download Patcher: {mirror}", false);
|
SetStatus($"Downloading Patcher: {mirror}", false);
|
||||||
|
|
||||||
// mega is a little weird since they use encryption, but thankfully there is a great library for their api :)
|
// mega is a little weird since they use encryption, but thankfully there is a great library for their api :)
|
||||||
if (mirror.StartsWith("https://mega"))
|
if (mirror.StartsWith("https://mega"))
|
||||||
@ -63,7 +63,7 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var megaDownloadStream = await megaClient.DownloadAsync(new Uri(mirror), progress);
|
using var megaDownloadStream = await megaClient.DownloadAsync(new Uri(mirror), progress);
|
||||||
using var patcherFileStream = patcherZip.Open(FileMode.Create);
|
using var patcherFileStream = _data.PatcherZipInfo.Open(FileMode.Create);
|
||||||
{
|
{
|
||||||
await megaDownloadStream.CopyToAsync(patcherFileStream);
|
await megaDownloadStream.CopyToAsync(patcherFileStream);
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await DownloadHelper.DownloadFile(patcherZip, mirror, progress);
|
var result = await DownloadHelper.DownloadFile(_data.PatcherZipInfo, mirror, progress);
|
||||||
|
|
||||||
if(result.Succeeded)
|
if(result.Succeeded)
|
||||||
{
|
{
|
||||||
@ -90,12 +90,12 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
|
|
||||||
public override async Task<GenericResult> RunAsync()
|
public override async Task<GenericResult> RunAsync()
|
||||||
{
|
{
|
||||||
var patcherZipInfo = new FileInfo(Path.Join(_data.TargetInstallPath, "patcher.zip"));
|
_data.PatcherZipInfo = new FileInfo(Path.Join(_data.TargetInstallPath, "patcher.zip"));
|
||||||
var akiZipInfo = new FileInfo(Path.Join(_data.TargetInstallPath, "sptaki.zip"));
|
_data.AkiZipInfo= new FileInfo(Path.Join(_data.TargetInstallPath, "sptaki.zip"));
|
||||||
|
|
||||||
if (_data.PatchNeeded)
|
if (_data.PatchNeeded)
|
||||||
{
|
{
|
||||||
if (patcherZipInfo.Exists) patcherZipInfo.Delete();
|
if (_data.PatcherZipInfo.Exists) _data.PatcherZipInfo.Delete();
|
||||||
|
|
||||||
var buildResult = await BuildMirrorList();
|
var buildResult = await BuildMirrorList();
|
||||||
|
|
||||||
@ -104,12 +104,10 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatus("Downloading Patcher", false);
|
|
||||||
|
|
||||||
Progress = 0;
|
Progress = 0;
|
||||||
|
|
||||||
var progress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
var progress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
var patcherDownloadRresult = await DownloadPatcherFromMirrors(patcherZipInfo, progress);
|
var patcherDownloadRresult = await DownloadPatcherFromMirrors(progress);
|
||||||
|
|
||||||
if (!patcherDownloadRresult.Succeeded)
|
if (!patcherDownloadRresult.Succeeded)
|
||||||
{
|
{
|
||||||
@ -117,7 +115,7 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (akiZipInfo.Exists) akiZipInfo.Delete();
|
if (_data.AkiZipInfo.Exists) _data.AkiZipInfo.Delete();
|
||||||
|
|
||||||
SetStatus("Downloading SPT-AKI", false);
|
SetStatus("Downloading SPT-AKI", false);
|
||||||
|
|
||||||
@ -125,7 +123,7 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
|
|
||||||
var akiProgress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
var akiProgress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
|
|
||||||
var releaseDownloadResult = await DownloadHelper.DownloadFile(akiZipInfo, _data.AkiReleaseDownloadLink, akiProgress);
|
var releaseDownloadResult = await DownloadHelper.DownloadFile(_data.AkiZipInfo, _data.AkiReleaseDownloadLink, akiProgress);
|
||||||
|
|
||||||
if (!releaseDownloadResult.Succeeded)
|
if (!releaseDownloadResult.Succeeded)
|
||||||
{
|
{
|
||||||
|
@ -28,17 +28,17 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
|
|
||||||
if (_data.OriginalGamePath == null)
|
if (_data.OriginalGamePath == null)
|
||||||
{
|
{
|
||||||
GenericResult.FromError("Unable to find EFT OG directory \n please make sure EFT is installed \n please also run EFT once");
|
return GenericResult.FromError("Unable to find EFT OG directory, please make sure EFT is installed. Please also run EFT once");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data.OriginalGamePath == _data.TargetInstallPath)
|
if (_data.OriginalGamePath == _data.TargetInstallPath)
|
||||||
{
|
{
|
||||||
GenericResult.FromError("Installer is located in EFT's original directory \n Please move the installer to a seperate folder as per the guide");
|
return GenericResult.FromError("Installer is located in EFT's original directory. Please move the installer to a seperate folder as per the guide");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(Path.Join(_data.TargetInstallPath, "EscapeFromTarkov.exe")))
|
if (File.Exists(Path.Join(_data.TargetInstallPath, "EscapeFromTarkov.exe")))
|
||||||
{
|
{
|
||||||
GenericResult.FromError("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");
|
return GenericResult.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
return GenericResult.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
|
return GenericResult.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using SPT_AKI_Installer.Aki.Core.Model;
|
using SPT_AKI_Installer.Aki.Core.Model;
|
||||||
|
using SPT_AKI_Installer.Aki.Helper;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SPT_AKI_Installer.Aki.Core.Tasks
|
namespace SPT_AKI_Installer.Aki.Core.Tasks
|
||||||
@ -18,12 +18,71 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
|
|||||||
|
|
||||||
public override async Task<GenericResult> RunAsync()
|
public override async Task<GenericResult> RunAsync()
|
||||||
{
|
{
|
||||||
/* TODO:
|
// extract patcher files
|
||||||
* patch if needed
|
SetStatus("Extrating Patcher", false);
|
||||||
* extract release
|
|
||||||
*/
|
|
||||||
|
|
||||||
throw new NotImplementedException();
|
var extractPatcherProgress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
|
|
||||||
|
var patcherOutputDir = new DirectoryInfo(Path.Join(_data.TargetInstallPath, "patcher"));
|
||||||
|
|
||||||
|
var extractPatcherResult = ZipHelper.Decompress(_data.PatcherZipInfo, patcherOutputDir, extractPatcherProgress);
|
||||||
|
|
||||||
|
if(!extractPatcherResult.Succeeded)
|
||||||
|
{
|
||||||
|
return extractPatcherResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy patcher files to install directory
|
||||||
|
SetStatus("Copying Patcher", false);
|
||||||
|
|
||||||
|
var patcherDirInfo = patcherOutputDir.GetDirectories("Patcher*", SearchOption.TopDirectoryOnly).First();
|
||||||
|
var targetInstallDirInfo = new DirectoryInfo(_data.TargetInstallPath);
|
||||||
|
|
||||||
|
var copyPatcherProgress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
|
|
||||||
|
var copyPatcherResult = FileHelper.CopyDirectoryWithProgress(patcherDirInfo, targetInstallDirInfo, copyPatcherProgress);
|
||||||
|
|
||||||
|
if(!copyPatcherResult.Succeeded)
|
||||||
|
{
|
||||||
|
return copyPatcherResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// run patcher
|
||||||
|
SetStatus("Running Patcher");
|
||||||
|
StartDrawingIndeterminateProgress();
|
||||||
|
|
||||||
|
var patcherEXE = new FileInfo(Path.Join(_data.TargetInstallPath, "patcher.exe"));
|
||||||
|
|
||||||
|
var patchingResult = ProcessHelper.PatchClientFiles(patcherEXE, targetInstallDirInfo);
|
||||||
|
|
||||||
|
if(!patchingResult.Succeeded)
|
||||||
|
{
|
||||||
|
return patchingResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract release files
|
||||||
|
SetStatus("Extracting Release");
|
||||||
|
StartDrawingProgress();
|
||||||
|
|
||||||
|
var extractReleaseProgress = new Progress<double>((d) => { Progress = (int)Math.Floor(d); });
|
||||||
|
|
||||||
|
var extractReleaseResult = ZipHelper.Decompress(_data.AkiZipInfo, targetInstallDirInfo, extractReleaseProgress);
|
||||||
|
|
||||||
|
if(!extractReleaseResult.Succeeded)
|
||||||
|
{
|
||||||
|
return extractPatcherResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup temp files
|
||||||
|
SetStatus("Cleanup");
|
||||||
|
StartDrawingIndeterminateProgress();
|
||||||
|
|
||||||
|
patcherOutputDir.Delete(true);
|
||||||
|
_data.PatcherZipInfo.Delete();
|
||||||
|
_data.AkiZipInfo.Delete();
|
||||||
|
patcherEXE.Delete();
|
||||||
|
|
||||||
|
return GenericResult.FromSuccess("SPT is Setup. Happy Playing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,38 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
|
using SPT_AKI_Installer.Aki.Core.Model;
|
||||||
|
|
||||||
namespace SPT_AKI_Installer.Aki.Helper
|
namespace SPT_AKI_Installer.Aki.Helper
|
||||||
{
|
{
|
||||||
public static class FileHelper
|
public static class FileHelper
|
||||||
{
|
{
|
||||||
public static void CopyDirectory(string oldDir, string newDir, bool overwrite)
|
public static GenericResult CopyDirectoryWithProgress(DirectoryInfo sourceDir, DirectoryInfo targetDir, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
int totalFiles = Directory.GetFiles(oldDir, "*.*", SearchOption.AllDirectories).Length;
|
try
|
||||||
|
{
|
||||||
|
int totalFiles = sourceDir.GetFiles("*.*", SearchOption.AllDirectories).Length;
|
||||||
|
int processedFiles = 0;
|
||||||
|
|
||||||
AnsiConsole.Progress().Columns(
|
foreach (var dir in sourceDir.GetDirectories("*", SearchOption.AllDirectories))
|
||||||
new PercentageColumn(),
|
|
||||||
new TaskDescriptionColumn(),
|
|
||||||
new ProgressBarColumn(),
|
|
||||||
new ElapsedTimeColumn(),
|
|
||||||
new SpinnerColumn()
|
|
||||||
).Start((ProgressContext context) =>
|
|
||||||
{
|
{
|
||||||
var task = context.AddTask("Copying Files", true, totalFiles);
|
Directory.CreateDirectory(dir.FullName.Replace(sourceDir.FullName, targetDir.FullName));
|
||||||
|
|
||||||
foreach (string dirPath in Directory.GetDirectories(oldDir, "*", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(dirPath.Replace(oldDir, newDir));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string newPath in Directory.GetFiles(oldDir, "*.*", SearchOption.AllDirectories))
|
foreach (var file in sourceDir.GetFiles("*.*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
File.Copy(newPath, newPath.Replace(oldDir, newDir), overwrite);
|
File.Copy(file.FullName, file.FullName.Replace(sourceDir.FullName, targetDir.FullName), true);
|
||||||
task.Increment(1);
|
processedFiles++;
|
||||||
|
|
||||||
|
progress.Report((int)Math.Floor(((double)processedFiles / totalFiles) * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
return GenericResult.FromSuccess();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
return GenericResult.FromError(ex.Message);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeleteFiles(string filePath, bool allFolders = false)
|
public static void DeleteFiles(string filePath, bool allFolders = false)
|
||||||
|
@ -27,29 +27,29 @@ namespace SPT_AKI_Installer.Aki.Helper
|
|||||||
return FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
|
return FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetPatcherZipPath(string gameVersion, string targetPath)
|
//public static string GetPatcherZipPath(string gameVersion, string targetPath)
|
||||||
{
|
//{
|
||||||
// example patch name - Patcher.12.12.15.17861.to.12.12.15.17349.zip
|
// // example patch name - Patcher.12.12.15.17861.to.12.12.15.17349.zip
|
||||||
var patchZip = FileHelper.FindFile(targetPath, gameVersion, "Patcher");
|
// var patchZip = FileHelper.FindFile(targetPath, gameVersion, "Patcher");
|
||||||
if (patchZip == null)
|
// if (patchZip == null)
|
||||||
{
|
// {
|
||||||
patchZip = FileHelper.FindFile(targetPath, "PATCHERZIP");
|
// patchZip = FileHelper.FindFile(targetPath, "PATCHERZIP");
|
||||||
}
|
// }
|
||||||
|
|
||||||
return patchZip;
|
// return patchZip;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static string GetAkiZipPath(string targetPath)
|
//public static string GetAkiZipPath(string targetPath)
|
||||||
{
|
//{
|
||||||
// example aki name - RELEASE-SPT-2.3.1-17349.zip
|
// // example aki name - RELEASE-SPT-2.3.1-17349.zip
|
||||||
var akiZip = FileHelper.FindFile(targetPath, "SPT", "RELEASE");
|
// var akiZip = FileHelper.FindFile(targetPath, "SPT", "RELEASE");
|
||||||
|
|
||||||
if (akiZip == null)
|
// if (akiZip == null)
|
||||||
{
|
// {
|
||||||
akiZip = FileHelper.FindFile(targetPath, "AKIZIP");
|
// akiZip = FileHelper.FindFile(targetPath, "AKIZIP");
|
||||||
}
|
// }
|
||||||
|
|
||||||
return akiZip;
|
// return akiZip;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using SPT_AKI_Installer.Aki.Core.Model;
|
using SPT_AKI_Installer.Aki.Core.Model;
|
||||||
|
|
||||||
namespace SPT_AKI_Installer.Aki.Helper
|
namespace SPT_AKI_Installer.Aki.Helper
|
||||||
@ -14,13 +15,18 @@ namespace SPT_AKI_Installer.Aki.Helper
|
|||||||
PatchFailed = 15
|
PatchFailed = 15
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProcessHelper
|
public static class ProcessHelper
|
||||||
{
|
{
|
||||||
public GenericResult PatchClientFiles(string exeDir, string workingDir)
|
public static GenericResult PatchClientFiles(FileInfo executable, DirectoryInfo workingDir)
|
||||||
{
|
{
|
||||||
|
if(!executable.Exists || !workingDir.Exists)
|
||||||
|
{
|
||||||
|
return GenericResult.FromError($"Could not find executable ({executable.Name}) or working directory ({workingDir.Name})");
|
||||||
|
}
|
||||||
|
|
||||||
var process = new Process();
|
var process = new Process();
|
||||||
process.StartInfo.FileName = exeDir;
|
process.StartInfo.FileName = executable.FullName;
|
||||||
process.StartInfo.WorkingDirectory = workingDir;
|
process.StartInfo.WorkingDirectory = workingDir.FullName;
|
||||||
process.EnableRaisingEvents = true;
|
process.EnableRaisingEvents = true;
|
||||||
process.StartInfo.Arguments = "autoclose";
|
process.StartInfo.Arguments = "autoclose";
|
||||||
process.Start();
|
process.Start();
|
||||||
|
@ -1,38 +1,56 @@
|
|||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
using SharpCompress.Common;
|
using SharpCompress.Common;
|
||||||
using Spectre.Console;
|
using SPT_AKI_Installer.Aki.Core.Model;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace SPT_AKI_Installer.Aki.Helper
|
namespace SPT_AKI_Installer.Aki.Helper
|
||||||
{
|
{
|
||||||
public static class ZipHelper
|
public static class ZipHelper
|
||||||
{
|
{
|
||||||
public static void ZipDecompress(string ArchivePath, string OutputFolderPath)
|
public static GenericResult Decompress(FileInfo ArchivePath, DirectoryInfo OutputFolderPath, IProgress<double> progress = null)
|
||||||
{
|
{
|
||||||
AnsiConsole.Progress().Columns(
|
try
|
||||||
new PercentageColumn(),
|
|
||||||
new TaskDescriptionColumn(),
|
|
||||||
new ProgressBarColumn(),
|
|
||||||
new ElapsedTimeColumn(),
|
|
||||||
new SpinnerColumn()
|
|
||||||
).Start((ProgressContext context) =>
|
|
||||||
{
|
{
|
||||||
using var archive = ZipArchive.Open(ArchivePath);
|
OutputFolderPath.Refresh();
|
||||||
var entries = archive.Entries.Where(entry => !entry.IsDirectory);
|
|
||||||
var task = context.AddTask("Extracting Files", true, entries.Count());
|
|
||||||
|
|
||||||
foreach (var entry in entries)
|
if (!OutputFolderPath.Exists) OutputFolderPath.Create();
|
||||||
|
|
||||||
|
using var archive = ZipArchive.Open(ArchivePath);
|
||||||
|
var totalEntries = archive.Entries.Where(entry => !entry.IsDirectory);
|
||||||
|
int processedEntries = 0;
|
||||||
|
|
||||||
|
foreach (var entry in totalEntries)
|
||||||
{
|
{
|
||||||
entry.WriteToDirectory($"{OutputFolderPath}", new ExtractionOptions()
|
entry.WriteToDirectory(OutputFolderPath.FullName, new ExtractionOptions()
|
||||||
{
|
{
|
||||||
ExtractFullPath = true,
|
ExtractFullPath = true,
|
||||||
Overwrite = true
|
Overwrite = true
|
||||||
});
|
});
|
||||||
|
|
||||||
task.Increment(1);
|
processedEntries++;
|
||||||
|
|
||||||
|
if (progress != null)
|
||||||
|
{
|
||||||
|
progress.Report(Math.Floor(((double)processedEntries / totalEntries.Count()) * 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputFolderPath.Refresh();
|
||||||
|
|
||||||
|
if(!OutputFolderPath.Exists)
|
||||||
|
{
|
||||||
|
return GenericResult.FromError($"Failed to extract files: {ArchivePath.Name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return GenericResult.FromSuccess();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
return GenericResult.FromError(ex.Message);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<History>True|2022-06-21T18:47:38.7532473Z;True|2022-06-08T18:26:47.7977621+01:00;True|2022-06-06T15:07:18.8067168+01:00;True|2022-06-05T22:55:20.5192697+01:00;True|2022-05-30T13:11:30.6942032+01:00;True|2022-05-30T13:08:08.4269393+01:00;True|2022-05-17T01:06:33.6758525+01:00;True|2022-05-14T01:56:09.8410037+01:00;True|2022-05-14T00:54:24.0683990+01:00;True|2022-05-14T00:53:04.7105427+01:00;True|2022-05-14T00:51:00.6280767+01:00;True|2022-05-14T00:49:19.4630888+01:00;True|2022-05-14T00:47:59.2166156+01:00;</History>
|
<History>True|2022-07-09T17:06:26.5751622Z;True|2022-07-09T12:56:17.1018408-04:00;True|2022-07-09T12:38:17.0878078-04:00;True|2022-07-09T12:18:23.6469737-04:00;True|2022-06-21T14:47:38.7532473-04:00;True|2022-06-08T13:26:47.7977621-04:00;True|2022-06-06T10:07:18.8067168-04:00;True|2022-06-05T17:55:20.5192697-04:00;True|2022-05-30T08:11:30.6942032-04:00;True|2022-05-30T08:08:08.4269393-04:00;True|2022-05-16T20:06:33.6758525-04:00;True|2022-05-13T20:56:09.8410037-04:00;True|2022-05-13T19:54:24.0683990-04:00;True|2022-05-13T19:53:04.7105427-04:00;True|2022-05-13T19:51:00.6280767-04:00;True|2022-05-13T19:49:19.4630888-04:00;True|2022-05-13T19:47:59.2166156-04:00;</History>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_LastSelectedProfileId>C:\Users\craig\source\repos\CWXDEV\CWX-SPTinstaller\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
<_LastSelectedProfileId>Z:\dev_stuff\SPT-AKI-Installer\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user