diff --git a/Patcher/.idea/.idea.Patcher/.idea/avalonia.xml b/Patcher/.idea/.idea.Patcher/.idea/avalonia.xml index 49f50b2..084bf92 100644 --- a/Patcher/.idea/.idea.Patcher/.idea/avalonia.xml +++ b/Patcher/.idea/.idea.Patcher/.idea/avalonia.xml @@ -5,6 +5,7 @@ + diff --git a/Patcher/PatchClient/PatchClient.csproj b/Patcher/PatchClient/PatchClient.csproj index 90d23d4..ed2bdbf 100644 --- a/Patcher/PatchClient/PatchClient.csproj +++ b/Patcher/PatchClient/PatchClient.csproj @@ -1,11 +1,11 @@  WinExe - net6.0 + net8.0 true enable - 2.10.2 - 2.10.2 + 2.12.0 + 2.12.0 diff --git a/Patcher/PatchClient/Views/MainWindow.axaml.cs b/Patcher/PatchClient/Views/MainWindow.axaml.cs index 1f88916..1dddb35 100644 --- a/Patcher/PatchClient/Views/MainWindow.axaml.cs +++ b/Patcher/PatchClient/Views/MainWindow.axaml.cs @@ -11,9 +11,6 @@ namespace PatchClient.Views public MainWindow() { InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif } private void InitializeComponent() diff --git a/Patcher/PatchGenerator/PatchGenerator.csproj b/Patcher/PatchGenerator/PatchGenerator.csproj index ac6becd..f70c910 100644 --- a/Patcher/PatchGenerator/PatchGenerator.csproj +++ b/Patcher/PatchGenerator/PatchGenerator.csproj @@ -1,11 +1,11 @@  WinExe - net6.0 + net8.0 true enable - 2.10.2 - 2.10.2 + 2.12.0 + 2.12.0 @@ -27,8 +27,7 @@ - - + @@ -42,4 +41,7 @@ %(Filename) + + + diff --git a/Patcher/PatchGenerator/Resources/7za.exe b/Patcher/PatchGenerator/Resources/7za.exe deleted file mode 100644 index 2bdd57d..0000000 Binary files a/Patcher/PatchGenerator/Resources/7za.exe and /dev/null differ diff --git a/Patcher/PatchGenerator/Resources/PatchClient.exe b/Patcher/PatchGenerator/Resources/PatchClient.exe index aa98b0f..2407816 100644 --- a/Patcher/PatchGenerator/Resources/PatchClient.exe +++ b/Patcher/PatchGenerator/Resources/PatchClient.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:232ada1ba713252985713bc85f12c721f9497ec367524f07c33a4ebf4d0281a4 -size 102628809 +oid sha256:5f6df2d05c2ec1d33446146dd61eebc2c238411c04e02fae71fa1f13d2926b4f +size 96953730 diff --git a/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs b/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs index be5ce67..1d83b55 100644 --- a/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs +++ b/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs @@ -16,6 +16,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Timers; +using PatcherUtils.Model; namespace PatchGenerator.ViewModels { @@ -140,12 +141,19 @@ namespace PatchGenerator.ViewModels System.Threading.Thread.Sleep(2000); - PatchItemCollection.Add(new PatchItem("Kicking off 7zip ...")); - - LazyOperations.StartZipProcess(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.zip".FromCwd()); + PatchItemCollection.Add(new PatchItem("Zipping patcher ...")); + ProgressMessage = "Zipping patcher"; + IndeterminateProgress = false; + var progress = new Progress(p => + { + PatchPercent = p; + }); + + LazyOperations.CompressDirectory(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.7z".FromCwd(), progress); + PatchItemCollection.Add(new PatchItem("Done")); } diff --git a/Patcher/PatchGenerator/Views/MainWindow.axaml.cs b/Patcher/PatchGenerator/Views/MainWindow.axaml.cs index 2af0cec..09b5b8c 100644 --- a/Patcher/PatchGenerator/Views/MainWindow.axaml.cs +++ b/Patcher/PatchGenerator/Views/MainWindow.axaml.cs @@ -11,9 +11,6 @@ namespace PatchGenerator.Views public MainWindow() { InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif } private void InitializeComponent() diff --git a/Patcher/PatcherUtils/LazyOperations.cs b/Patcher/PatcherUtils/LazyOperations.cs index 1ff02d6..8c059bf 100644 --- a/Patcher/PatcherUtils/LazyOperations.cs +++ b/Patcher/PatcherUtils/LazyOperations.cs @@ -1,7 +1,9 @@ -using PatcherUtils.Model; -using System.Diagnostics; +using System; +using PatcherUtils.Model; using System.IO; using System.Reflection; +using Aki.Common.Utils; +using SevenZip; namespace PatcherUtils { @@ -18,12 +20,12 @@ namespace PatcherUtils /// public static string PatchFolder = "Aki_Patches"; - private static string SevenZExe = "7za.exe"; + private static string SevenZDll = "7z.dll"; /// /// The path to the 7za.exe file in the /// - public static string SevenZExePath = $"{TempDir}\\{SevenZExe}"; + public static string SevenZDllPath = $"{TempDir}\\{SevenZDll}"; private static string PatcherClient = "PatchClient.exe"; /// @@ -79,9 +81,9 @@ namespace PatcherUtils { switch (resource) { - case string a when a.EndsWith(SevenZExe): + case string a when a.EndsWith(SevenZDll): { - StreamResourceOut(assembly, resource, SevenZExePath); + StreamResourceOut(assembly, resource, SevenZDllPath); break; } case string a when a.EndsWith(PatcherClient): @@ -98,17 +100,34 @@ namespace PatcherUtils } } - public static void StartZipProcess(string SourcePath, string DestinationPath) + public static void CompressDirectory(string SourceDirectoryPath, string DestinationFilePath, IProgress progress) { - ProcessStartInfo procInfo = new ProcessStartInfo() + var outputFile = new FileInfo(DestinationFilePath); + + SevenZipBase.SetLibraryPath(SevenZDllPath); + var compressor = new SevenZipCompressor() { - FileName = SevenZExePath, - Arguments = $"a -mm=LZMA {DestinationPath} {SourcePath}" + ArchiveFormat = OutArchiveFormat.SevenZip, + CompressionMethod = CompressionMethod.Lzma2, + CompressionLevel = CompressionLevel.Normal }; - Process.Start(procInfo); + compressor.Compressing += (_, args) => + { + progress.Report(args.PercentDone); + }; - PatchLogger.LogInfo($"Zip process started"); + using var outputStream = outputFile.OpenWrite(); + + compressor.CompressDirectory(SourceDirectoryPath, outputStream); + + outputFile.Refresh(); + + // failed to compress data + if (!outputFile.Exists || outputFile.Length == 0) + { + Logger.LogError("Failed to compress patcher"); + } } /// diff --git a/Patcher/PatcherUtils/PatcherUtils.csproj b/Patcher/PatcherUtils/PatcherUtils.csproj index 08c5334..55ccfb0 100644 --- a/Patcher/PatcherUtils/PatcherUtils.csproj +++ b/Patcher/PatcherUtils/PatcherUtils.csproj @@ -1,7 +1,9 @@ - net6.0 + net8.0 + 2.11.0 + 2.11.0 @@ -9,6 +11,7 @@ + @@ -18,4 +21,8 @@ + + + + diff --git a/Patcher/PatcherUtils/Resources/7z.dll b/Patcher/PatcherUtils/Resources/7z.dll new file mode 100644 index 0000000..2ba9f27 Binary files /dev/null and b/Patcher/PatcherUtils/Resources/7z.dll differ