diff --git a/Patcher/PatchGenerator/Models/GenStartupArgs.cs b/Patcher/PatchGenerator/Models/GenStartupArgs.cs
index 4b80a84..9dd48d7 100644
--- a/Patcher/PatchGenerator/Models/GenStartupArgs.cs
+++ b/Patcher/PatchGenerator/Models/GenStartupArgs.cs
@@ -6,13 +6,15 @@
public string OutputFolderName { get; private set; } = "";
public string SourceFolderPath { get; private set; } = "";
public string TargetFolderPath { get; private set; } = "";
+ public bool AutoClose { get; private set; } = false;
public bool AutoZip { get; private set; } = true;
- protected GenStartupArgs(string OutputFolderName, string SourceFolderPath, string TargetFolderPath, bool AutoZip)
+ protected GenStartupArgs(string outputFolderName, string sourceFolderPath, string targetFolderPath, bool autoZip, bool autoClose)
{
- this.OutputFolderName = OutputFolderName;
- this.SourceFolderPath = SourceFolderPath;
- this.TargetFolderPath = TargetFolderPath;
- this.AutoZip = AutoZip;
+ OutputFolderName = outputFolderName;
+ SourceFolderPath = sourceFolderPath;
+ TargetFolderPath = targetFolderPath;
+ AutoZip = autoZip;
+ AutoClose = autoClose;
}
public static GenStartupArgs Parse(string[] Args)
@@ -23,6 +25,7 @@
string sourceFolderPath = "";
string targetFolderPath = "";
bool autoZip = true;
+ bool autoClose = false;
foreach (string arg in Args)
{
@@ -52,10 +55,15 @@
autoZip = bool.Parse(argSplit[1]);
break;
}
+ case "AutoClose":
+ {
+ autoClose = bool.Parse(argSplit[1]);
+ break;
+ }
}
}
- return new GenStartupArgs(outputFolderPath, sourceFolderPath, targetFolderPath, autoZip);
+ return new GenStartupArgs(outputFolderPath, sourceFolderPath, targetFolderPath, autoZip, autoClose);
}
}
}
diff --git a/Patcher/PatchGenerator/Models/PatchGenInfo.cs b/Patcher/PatchGenerator/Models/PatchGenInfo.cs
index 5716350..7d69924 100644
--- a/Patcher/PatchGenerator/Models/PatchGenInfo.cs
+++ b/Patcher/PatchGenerator/Models/PatchGenInfo.cs
@@ -62,5 +62,12 @@ namespace PatchGenerator.Models
get => _ReadyToRun;
set => this.RaiseAndSetIfChanged(ref _ReadyToRun, value);
}
+
+ private bool _AutoClose = false;
+ public bool AutoClose
+ {
+ get => _AutoClose;
+ set => this.RaiseAndSetIfChanged(ref _AutoClose, value);
+ }
}
}
diff --git a/Patcher/PatchGenerator/ViewModels/MainWindowViewModel.cs b/Patcher/PatchGenerator/ViewModels/MainWindowViewModel.cs
index 79298c5..3394088 100644
--- a/Patcher/PatchGenerator/ViewModels/MainWindowViewModel.cs
+++ b/Patcher/PatchGenerator/ViewModels/MainWindowViewModel.cs
@@ -32,6 +32,7 @@ namespace PatchGenerator.ViewModels
genInfo.SourceFolderPath = genArgs.SourceFolderPath;
genInfo.PatchName = genArgs.OutputFolderName;
genInfo.AutoZip = genArgs.AutoZip;
+ genInfo.AutoClose = genArgs.AutoClose;
Router.Navigate.Execute(new PatchGenerationViewModel(this, genInfo));
return;
diff --git a/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs b/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs
index 344d31f..d5d1c21 100644
--- a/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs
+++ b/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs
@@ -1,10 +1,12 @@
using Avalonia;
using Avalonia.Media;
using Avalonia.Threading;
+using PatchClient.Models;
using PatcherUtils;
using PatchGenerator.Helpers;
using PatchGenerator.Models;
using ReactiveUI;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
@@ -87,7 +89,12 @@ namespace PatchGenerator.ViewModels
patchGenStopwatch.Start();
- patcher.GeneratePatches();
+ var message = patcher.GeneratePatches();
+
+ if(message.ExitCode != PatcherExitCode.Success && generationInfo.AutoClose)
+ {
+ Environment.Exit((int)message.ExitCode);
+ }
patchGenStopwatch.Stop();
@@ -119,6 +126,11 @@ namespace PatchGenerator.ViewModels
PatchItemCollection.Add(new PatchItem("Done"));
}
+
+ if (generationInfo.AutoClose)
+ {
+ Environment.Exit((int)PatcherExitCode.Success);
+ }
});
}
diff --git a/Patcher/PatcherUtils/PatchHelper.cs b/Patcher/PatcherUtils/PatchHelper.cs
index 72f88a6..62c023e 100644
--- a/Patcher/PatcherUtils/PatchHelper.cs
+++ b/Patcher/PatcherUtils/PatchHelper.cs
@@ -168,7 +168,7 @@ namespace PatcherUtils
///
///
/// Patches are created in the delta folder specified during contruction
- public bool GeneratePatches()
+ public PatchMessage GeneratePatches()
{
//get all directory information needed
DirectoryInfo sourceDir = new DirectoryInfo(SourceFolder);
@@ -179,7 +179,7 @@ namespace PatcherUtils
if (!sourceDir.Exists || !targetDir.Exists || !deltaDir.Exists)
{
//One of the directories doesn't exist
- return false;
+ return new PatchMessage("Could not find a directory", PatcherExitCode.MissingDir);
}
LazyOperations.ExtractResourcesToTempDir();
@@ -244,7 +244,7 @@ namespace PatcherUtils
//Any remaining source files do not exist in the target folder and can be removed.
//reset progress info
- if (SourceFiles.Count == 0) return true;
+ if (SourceFiles.Count == 0) return new PatchMessage("Generation Done", PatcherExitCode.Success);
RaiseProgressChanged(0, SourceFiles.Count, "Processing .del files...");
filesProcessed = 0;
@@ -262,7 +262,7 @@ namespace PatcherUtils
RaiseProgressChanged(filesProcessed, fileCountTotal, $"{delFile.FullName.Replace(SourceFolder, "...")}.del", AdditionalInfo.ToArray());
}
- return true;
+ return new PatchMessage("Generation Done", PatcherExitCode.Success);
}
///