mirror of
https://github.com/sp-tarkov/patcher.git
synced 2025-02-13 01:50:47 -05:00
adding some command line args for automation
This commit is contained in:
parent
f4a1605ee4
commit
277a59cc7f
@ -2,7 +2,8 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:PatchGenerator"
|
xmlns:local="clr-namespace:PatchGenerator"
|
||||||
StartupUri="MainWindow.xaml">
|
StartupUri="MainWindow.xaml"
|
||||||
|
Startup="Application_Startup">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace PatchGenerator
|
namespace PatchGenerator
|
||||||
{
|
{
|
||||||
@ -13,5 +7,34 @@ namespace PatchGenerator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
private void Application_Startup(object sender, StartupEventArgs e)
|
||||||
|
{
|
||||||
|
GenStartupArgs startupArgs = null;
|
||||||
|
|
||||||
|
if (e.Args != null && e.Args.Length > 0)
|
||||||
|
{
|
||||||
|
if(e.Args[0].ToLower() == "help")
|
||||||
|
{
|
||||||
|
System.Text.StringBuilder sb = new System.Text.StringBuilder()
|
||||||
|
.AppendLine("Help - Shows this message box if in position 1")
|
||||||
|
.AppendLine("")
|
||||||
|
.AppendLine("Parameters below can be used like this: \"Name::Value\"")
|
||||||
|
.AppendLine("OutputFolderName - The output file for the patch")
|
||||||
|
.AppendLine("TargetFolderPath - The target folder path")
|
||||||
|
.AppendLine("CompareFolderPath - The compare folder path")
|
||||||
|
.AppendLine("AutoZip - Set if the output folder should be zipped up after patch generation. Defaults to true");
|
||||||
|
|
||||||
|
MessageBox.Show(sb.ToString(), "Parameter Help Info", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
|
||||||
|
Application.Current.Shutdown(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
startupArgs = GenStartupArgs.Parse(e.Args);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow mw = new MainWindow(startupArgs);
|
||||||
|
|
||||||
|
mw.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
67
Patcher/PatchGenerator/GenStartupArgs.cs
Normal file
67
Patcher/PatchGenerator/GenStartupArgs.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PatchGenerator
|
||||||
|
{
|
||||||
|
public class GenStartupArgs
|
||||||
|
{
|
||||||
|
public bool ReadyToRun => OutputFolderName != "" && CompareFolderPath != "" && TargetFolderPath != "";
|
||||||
|
public string OutputFolderName { get; private set; } = "";
|
||||||
|
public string CompareFolderPath { get; private set; } = "";
|
||||||
|
public string TargetFolderPath { get; private set; } = "";
|
||||||
|
public bool AutoZip { get; private set; } = true;
|
||||||
|
protected GenStartupArgs(string OutputFolderName, string CompareFolderPath, string TargetFolderPath, bool AutoZip)
|
||||||
|
{
|
||||||
|
this.OutputFolderName = OutputFolderName;
|
||||||
|
this.CompareFolderPath = CompareFolderPath;
|
||||||
|
this.TargetFolderPath = TargetFolderPath;
|
||||||
|
this.AutoZip = AutoZip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenStartupArgs Parse(string[] Args)
|
||||||
|
{
|
||||||
|
if (Args == null || Args.Length == 0) return null;
|
||||||
|
|
||||||
|
string ofn = "";
|
||||||
|
string cfp = "";
|
||||||
|
string tfp = "";
|
||||||
|
bool az = true;
|
||||||
|
|
||||||
|
foreach(string arg in Args)
|
||||||
|
{
|
||||||
|
if (arg.Split("::").Length != 2) return null;
|
||||||
|
|
||||||
|
var argSplit = arg.Split("::");
|
||||||
|
|
||||||
|
switch(argSplit[0])
|
||||||
|
{
|
||||||
|
case "OutputFolderName":
|
||||||
|
{
|
||||||
|
ofn = argSplit[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "CompareFolderPath":
|
||||||
|
{
|
||||||
|
cfp = argSplit[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TargetFolderPath":
|
||||||
|
{
|
||||||
|
tfp = argSplit[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "AutoZip":
|
||||||
|
{
|
||||||
|
az = bool.Parse(argSplit[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GenStartupArgs(ofn, cfp, tfp, az);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,35 @@ namespace PatchGenerator
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MainWindow(GenStartupArgs startupArgs = null)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
if (startupArgs == null) return;
|
||||||
|
|
||||||
|
FileNameBox.Text = startupArgs.OutputFolderName;
|
||||||
|
if (startupArgs.CompareFolderPath != "")
|
||||||
|
{
|
||||||
|
compareFolder = startupArgs.CompareFolderPath;
|
||||||
|
CompareLabel.Content = $"Compare Folder:\n{compareFolder}";
|
||||||
|
CompareLabel.BorderBrush = Brushes.DarkCyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startupArgs.TargetFolderPath != "")
|
||||||
|
{
|
||||||
|
targetFolder = startupArgs.TargetFolderPath;
|
||||||
|
TargetLabel.Content = $"Target Folder:\n{targetFolder}";
|
||||||
|
TargetLabel.BorderBrush = Brushes.DarkCyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoZip = startupArgs.AutoZip;
|
||||||
|
|
||||||
|
if (startupArgs.ReadyToRun)
|
||||||
|
{
|
||||||
|
GenButton_Click(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string GetStopWatchTime()
|
private string GetStopWatchTime()
|
||||||
{
|
{
|
||||||
return $"Hours: {stopwatch.Elapsed.Hours} - Mins: {stopwatch.Elapsed.Minutes} - Secs: {stopwatch.Elapsed.Seconds} - MilliSecs: {stopwatch.Elapsed.Milliseconds}";
|
return $"Hours: {stopwatch.Elapsed.Hours} - Mins: {stopwatch.Elapsed.Minutes} - Secs: {stopwatch.Elapsed.Seconds} - MilliSecs: {stopwatch.Elapsed.Milliseconds}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user