diff --git a/Aki.Asset/icon.ico b/Aki.Asset/icon.ico
index 7fda173..50a2369 100644
Binary files a/Aki.Asset/icon.ico and b/Aki.Asset/icon.ico differ
diff --git a/Aki.Core/Program.cs b/Aki.Core/Program.cs
index 7ad6803..8316dfe 100644
--- a/Aki.Core/Program.cs
+++ b/Aki.Core/Program.cs
@@ -2,22 +2,32 @@
using System;
using System.Diagnostics;
using System.Threading;
-using Installer.Aki.Helper;
+using SPT_AKI_Installer.Aki.Helper;
+using Spectre.Console;
-namespace Installer.Aki.Core
+namespace SPT_AKI_Installer.Aki.Core
{
//TODO:
// delete patcher zip and aki zip
+ // progress for copyDirectory
+ // move Game/patcher/aki check methods out of core
+ // add figlet for SPT-AKI INSTALLER
+ // locales, language selection
public static class SPTinstaller
{
+ public static string targetPath = Environment.CurrentDirectory;
private static string patchRef;
private static string akiRef;
private static DirectoryInfo dir;
+ private static string gamePath;
static void Main(string[] args)
{
- string gamePath = GameHelper.DetectOriginalGamePath();
+#if DEBUG
+ targetPath = @"D:\install";
+#endif
+ GameCheck(out gamePath);
if (PatcherCheck(gamePath, out patchRef))
{
@@ -48,14 +58,16 @@ namespace Installer.Aki.Core
Console.ReadKey();
// copies and pastes EFT to AKI installer test folder
- FileHelper.CopyDirectory(gamePath, Environment.CurrentDirectory, true);
+#if !DEBUG
+ FileHelper.CopyDirectory(gamePath, targetPath, true);
LogHelper.User("GAME HAS BEEN COPIED, PRESS ENTER TO EXTRACT PATCHER!");
Console.ReadKey();
+#endif
// extracts patcher and moves out inner folders
- ZipHelper.Decompress(patchRef, Environment.CurrentDirectory);
+ ZipHelper.Decompress(patchRef, targetPath);
FileHelper.FindFolder(patchRef, out dir);
- FileHelper.CopyDirectory(dir.FullName, Environment.CurrentDirectory, true);
+ FileHelper.CopyDirectory(dir.FullName, targetPath, true);
if (dir.Exists)
{
dir.Delete(true);
@@ -68,9 +80,9 @@ namespace Installer.Aki.Core
}
// starts patcher and checks for user input to exit patcher and proceed
- LogHelper.User("PATCHER HAS BEEN EXTRACTED, STARTING PATCHER!");
- ProcessHelper patcherProcess = new ProcessHelper();
- patcherProcess.StartProcess(Path.Join(Environment.CurrentDirectory + "/patcher.exe"), Environment.CurrentDirectory);
+ LogHelper.Info("PATCHER HAS BEEN EXTRACTED, STARTING PATCHER!");
+ ProcessHelper patcherProcess = new();
+ patcherProcess.StartProcess(Path.Join(targetPath + "/patcher.exe"), targetPath);
LogHelper.User("PATCHER HAS BEEN STARTED, TYPE YES ONCE THE PATCHER IS COMPLETE!");
var complete = Console.ReadLine();
@@ -87,20 +99,44 @@ namespace Installer.Aki.Core
{
patcherProcess.EndProcess();
Thread.Sleep(1000);
- FileHelper.DeleteFile("file", Environment.CurrentDirectory + "/patcher.exe");
- ZipHelper.Decompress(akiRef, Environment.CurrentDirectory);
+ FileHelper.DeleteFile("file", targetPath + "/patcher.exe");
+ ZipHelper.Decompress(akiRef, targetPath);
LogHelper.Info("AKI HAS BEEN EXTRACTED, RUN THE SERVER AND WAIT TILL YOU SEE HAPPY SERVER THEN LAUNCHER AND ENJOY!");
LogHelper.User("PRESS ENTER TO CLOSE THE APP");
Console.ReadKey();
}
}
+ ///
+ /// checks the game is installed, out = game directory
+ ///
+ ///
+ private static void GameCheck(out string gamePath)
+ {
+ string Path = GameHelper.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;
+ }
+
+ ///
+ /// checks for patcher zip path, out = patcher path
+ ///
+ ///
+ ///
+ /// bool
private static bool PatcherCheck(string gamePath, out string patchRef)
{
FileVersionInfo version = FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe"));
string versionCheck = StringHelper.Splitter(version.ProductVersion, '-', '.', 2);
LogHelper.Info($"GAME VERSION IS: {version.ProductVersion}");
- string patcherRef = FileHelper.FindFile(Environment.CurrentDirectory, versionCheck);
+ string patcherRef = FileHelper.FindFile(targetPath, versionCheck);
if (patcherRef != null)
{
@@ -111,9 +147,14 @@ namespace Installer.Aki.Core
return false;
}
+ ///
+ /// checks for aki zip path, out = aki path
+ ///
+ ///
+ /// bool
private static bool AkiCheck(out string akiRef)
{
- string aki = FileHelper.FindFile(Environment.CurrentDirectory, "2.3.1");
+ string aki = FileHelper.FindFile(targetPath, "2.3.1");
if (aki != null)
{
diff --git a/Aki.Helper/FileHelper.cs b/Aki.Helper/FileHelper.cs
index 8f37818..3fc3c69 100644
--- a/Aki.Helper/FileHelper.cs
+++ b/Aki.Helper/FileHelper.cs
@@ -1,12 +1,13 @@
-using System;
+using SPT_AKI_Installer.Aki.Core;
+using System;
using System.IO;
-namespace Installer.Aki.Helper
+namespace SPT_AKI_Installer.Aki.Helper
{
public static class FileHelper
{
///
- /// CopyDirectory will use old path and copy to new path and
+ /// CopyDirectory will use old path and copy to new path and
/// asks if inner files/folders should be included
///
///
@@ -23,7 +24,6 @@ namespace Installer.Aki.Helper
foreach (FileInfo file in dir.GetFiles())
{
- Console.WriteLine(file.FullName);
string targetFilePath = Path.Combine(newDir, file.Name);
file.CopyTo(targetFilePath, true);
}
@@ -39,7 +39,7 @@ namespace Installer.Aki.Helper
}
///
- /// DeleteFiles will use a type to look for, the path
+ /// DeleteFiles will use a type to look for, the path
/// and if all inner files/folders should be included
///
///
@@ -88,7 +88,7 @@ namespace Installer.Aki.Helper
{
var patchInfo = new FileInfo(patchRef);
var patchName = patchInfo.Name.Replace(patchInfo.Extension, "");
- var path = new DirectoryInfo(Path.Join(Environment.CurrentDirectory, patchName));
+ var path = new DirectoryInfo(Path.Join(SPTinstaller.targetPath, patchName));
if (path.Exists)
{
dir = path;
diff --git a/Aki.Helper/GameHelper.cs b/Aki.Helper/GameHelper.cs
index 4cc3bc0..3577eaf 100644
--- a/Aki.Helper/GameHelper.cs
+++ b/Aki.Helper/GameHelper.cs
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
using System.IO;
-namespace Installer.Aki.Helper
+namespace SPT_AKI_Installer.Aki.Helper
{
public static class GameHelper
{
diff --git a/Aki.Helper/LogHelper.cs b/Aki.Helper/LogHelper.cs
index dd5d037..767731f 100644
--- a/Aki.Helper/LogHelper.cs
+++ b/Aki.Helper/LogHelper.cs
@@ -1,19 +1,22 @@
using System;
+using Spectre.Console;
-namespace Installer.Aki.Helper
+namespace SPT_AKI_Installer.Aki.Helper
{
public static class LogHelper
{
+ private static void Log(string tag, string message, string foreground, string background = "black")
+ {
+ AnsiConsole.MarkupLine($"[{foreground} on {background}][[{tag}]]: {message.EscapeMarkup()}[/]");
+ }
+
///
/// Outputs a string to console starting with [USER] with
/// a Green background and Black foreground
///
public static void User(string text)
{
- Console.BackgroundColor = ConsoleColor.Green;
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine($"[USER]: {text}");
- Console.ResetColor();
+ Log("USER", text, "green");
}
///
@@ -22,10 +25,7 @@ namespace Installer.Aki.Helper
///
public static void Warning(string text)
{
- Console.BackgroundColor = ConsoleColor.Yellow;
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine($"[WARNING]: {text}");
- Console.ResetColor();
+ Log("WARNING", text, "yellow");
}
///
@@ -34,10 +34,7 @@ namespace Installer.Aki.Helper
///
public static void Error(string text)
{
- Console.BackgroundColor = ConsoleColor.Red;
- Console.ForegroundColor = ConsoleColor.Black;
- Console.WriteLine($"[ERROR]: {text}");
- Console.ResetColor();
+ Log("ERROR", text, "red");
}
///
@@ -46,10 +43,7 @@ namespace Installer.Aki.Helper
///
public static void Info(string text)
{
- Console.BackgroundColor = ConsoleColor.DarkGray;
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine($"[INFO]: {text}");
- Console.ResetColor();
+ Log("INFO", text, "blue");
}
}
}
diff --git a/Aki.Helper/ProcessHelper.cs b/Aki.Helper/ProcessHelper.cs
index b3d7db1..c145ca0 100644
--- a/Aki.Helper/ProcessHelper.cs
+++ b/Aki.Helper/ProcessHelper.cs
@@ -6,7 +6,7 @@ using System.Threading;
using System.IO;
using System.Diagnostics;
-namespace Installer.Aki.Helper
+namespace SPT_AKI_Installer.Aki.Helper
{
public class ProcessHelper
{
diff --git a/Aki.Helper/StatusHelper.cs b/Aki.Helper/StatusHelper.cs
new file mode 100644
index 0000000..e93cdee
--- /dev/null
+++ b/Aki.Helper/StatusHelper.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SPT_AKI_Installer.Aki.Helper
+{
+ internal class StatusHelper
+{
+}
+}
diff --git a/Aki.Helper/StringHelper.cs b/Aki.Helper/StringHelper.cs
index 476d7f0..8447c8a 100644
--- a/Aki.Helper/StringHelper.cs
+++ b/Aki.Helper/StringHelper.cs
@@ -1,4 +1,4 @@
-namespace Installer.Aki.Helper
+namespace SPT_AKI_Installer.Aki.Helper
{
public static class StringHelper
{
diff --git a/Aki.Helper/ZipHelper.cs b/Aki.Helper/ZipHelper.cs
index f14c52c..d2183b4 100644
--- a/Aki.Helper/ZipHelper.cs
+++ b/Aki.Helper/ZipHelper.cs
@@ -1,33 +1,57 @@
-using SharpCompress.Common;
-using SharpCompress.Readers;
-using System;
-using System.IO;
+using SharpCompress.Archives;
+using SharpCompress.Archives.Zip;
+using SharpCompress.Common;
+using Spectre.Console;
+using System.Linq;
-namespace Installer.Aki.Helper
+namespace SPT_AKI_Installer.Aki.Helper
{
public static class ZipHelper
{
///
- /// will extract Zips in LZMA compression format, using Zips path
+ /// will extract Zips in LZMA compression format, using Zips path
/// to new path
///
- public static void Decompress(string zipPath, string extPath)
+ public static void Decompress(string ArchivePath, string OutputFolderPath)
{
- Stream stream = File.OpenRead(zipPath);
- var reader = ReaderFactory.Open(stream);
-
- while (reader.MoveToNextEntry())
+ AnsiConsole.Progress().Columns(
+ new PercentageColumn(),
+ new TaskDescriptionColumn(),
+ new ProgressBarColumn(),
+ new ElapsedTimeColumn()
+ ).Start((ProgressContext context) =>
{
- if (!reader.Entry.IsDirectory)
+ using var archive = ZipArchive.Open(ArchivePath);
+ var entries = archive.Entries.Where(entry => !entry.IsDirectory);
+ var task = context.AddTask("Extracting", true, entries.Count());
+
+ foreach (var entry in entries)
{
- Console.WriteLine(reader.Entry.Key);
- reader.WriteEntryToDirectory(extPath, new ExtractionOptions()
+ entry.WriteToDirectory($"{OutputFolderPath}", new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
+
+ task.Increment(1);
}
- }
+ });
+
+ //Stream stream = File.OpenRead(zipPath);
+ //var reader = ReaderFactory.Open(stream);
+
+ //while (reader.MoveToNextEntry())
+ //{
+ // if (!reader.Entry.IsDirectory)
+ // {
+ // Console.WriteLine(reader.Entry.Key);
+ // reader.WriteEntryToDirectory(extPath, new ExtractionOptions()
+ // {
+ // ExtractFullPath = true,
+ // Overwrite = true
+ // });
+ // }
+ //}
}
}
}
diff --git a/Properties/PublishProfiles/FolderProfile.pubxml b/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 0000000..388b15e
--- /dev/null
+++ b/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ Release
+ Any CPU
+ bin\Release\net6.0\publish\win-x64\
+ FileSystem
+ net6.0
+ win-x64
+ true
+ true
+ false
+ true
+
+
\ No newline at end of file
diff --git a/Properties/PublishProfiles/FolderProfile.pubxml.user b/Properties/PublishProfiles/FolderProfile.pubxml.user
new file mode 100644
index 0000000..7f2a7cd
--- /dev/null
+++ b/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -0,0 +1,9 @@
+
+
+
+
+ True|2022-05-14T00:56:09.8410037Z;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;
+
+
\ No newline at end of file
diff --git a/SPT-AKI Installer.csproj b/SPT-AKI Installer.csproj
deleted file mode 100644
index b4e56e0..0000000
--- a/SPT-AKI Installer.csproj
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- Exe
- net6.0
- true
- true
- true
- true
- Aki.Asset\icon.ico
- win-x64
- embedded
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SPT_AKI Installer.csproj b/SPT_AKI Installer.csproj
new file mode 100644
index 0000000..39bb286
--- /dev/null
+++ b/SPT_AKI Installer.csproj
@@ -0,0 +1,34 @@
+
+
+
+ Exe
+ net6.0
+ icon.ico
+ Aki.Asset\icon.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ \
+
+
+ True
+ \
+
+
+
+
diff --git a/SPT_AKI Installer.csproj.user b/SPT_AKI Installer.csproj.user
new file mode 100644
index 0000000..f965575
--- /dev/null
+++ b/SPT_AKI Installer.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ <_LastSelectedProfileId>C:\Users\craig\source\repos\CWXDEV\CWX-SPTinstaller\Properties\PublishProfiles\FolderProfile.pubxml
+
+
\ No newline at end of file
diff --git a/SPT-AKI Installer.sln b/SPT_AKI Installer.sln
similarity index 88%
rename from SPT-AKI Installer.sln
rename to SPT_AKI Installer.sln
index 577839a..1277b58 100644
--- a/SPT-AKI Installer.sln
+++ b/SPT_AKI Installer.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32407.343
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SPT-AKI Installer", "SPT-AKI Installer.csproj", "{7B07749A-3BE8-41B5-9B98-9F41C83FA15B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SPT_AKI Installer", "SPT_AKI Installer.csproj", "{7B07749A-3BE8-41B5-9B98-9F41C83FA15B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution