diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..93c4578
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
diff --git a/Patcher/PatcherUtils/PatchHelper.cs b/Patcher/PatcherUtils/PatchHelper.cs
index 29395de..2d34e18 100644
--- a/Patcher/PatcherUtils/PatchHelper.cs
+++ b/Patcher/PatcherUtils/PatchHelper.cs
@@ -58,8 +58,7 @@ namespace PatcherUtils
if(File.Exists(decodedPath))
{
- File.Delete(SourceFilePath);
- File.Move(decodedPath, SourceFilePath);
+ File.Move(decodedPath, SourceFilePath, true);
}
}
diff --git a/Patcher/_port/Patcher/PatchClient/PatchClient.csproj b/Patcher/_port/Patcher/PatchClient/PatchClient.csproj
index 183610d..55eb282 100644
--- a/Patcher/_port/Patcher/PatchClient/PatchClient.csproj
+++ b/Patcher/_port/Patcher/PatchClient/PatchClient.csproj
@@ -2,6 +2,7 @@
WinExe
net6.0
+ true
enable
diff --git a/Patcher/_port/Patcher/PatchClient/Program.cs b/Patcher/_port/Patcher/PatchClient/Program.cs
index 97aec7c..bc1e0c4 100644
--- a/Patcher/_port/Patcher/PatchClient/Program.cs
+++ b/Patcher/_port/Patcher/PatchClient/Program.cs
@@ -1,5 +1,4 @@
using Avalonia;
-using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;
using System;
diff --git a/Patcher/_port/Patcher/PatchClient/ViewModels/MainWindowViewModel.cs b/Patcher/_port/Patcher/PatchClient/ViewModels/MainWindowViewModel.cs
index 206c971..f56e6b7 100644
--- a/Patcher/_port/Patcher/PatchClient/ViewModels/MainWindowViewModel.cs
+++ b/Patcher/_port/Patcher/PatchClient/ViewModels/MainWindowViewModel.cs
@@ -10,7 +10,7 @@ namespace PatchClient.ViewModels
{
public ICommand CloseCommand => ReactiveCommand.Create(() =>
{
- if(Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
+ if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
{
desktopApp.MainWindow.Close();
}
diff --git a/Patcher/_port/Patcher/PatchClient/ViewModels/MessageViewModel.cs b/Patcher/_port/Patcher/PatchClient/ViewModels/MessageViewModel.cs
index 9819b19..4eecaf2 100644
--- a/Patcher/_port/Patcher/PatchClient/ViewModels/MessageViewModel.cs
+++ b/Patcher/_port/Patcher/PatchClient/ViewModels/MessageViewModel.cs
@@ -1,5 +1,4 @@
-using Avalonia;
-using ReactiveUI;
+using ReactiveUI;
namespace PatchClient.ViewModels
{
diff --git a/Patcher/_port/Patcher/PatchClient/ViewModels/PatcherViewModel.cs b/Patcher/_port/Patcher/PatchClient/ViewModels/PatcherViewModel.cs
index 8bc9b3c..ba3046b 100644
--- a/Patcher/_port/Patcher/PatchClient/ViewModels/PatcherViewModel.cs
+++ b/Patcher/_port/Patcher/PatchClient/ViewModels/PatcherViewModel.cs
@@ -1,12 +1,12 @@
using Avalonia;
using PatchClient.Models;
using PatcherUtils;
+using ReactiveUI;
using Splat;
using System;
-using ReactiveUI;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
-using System.Collections.ObjectModel;
namespace PatchClient.ViewModels
{
@@ -63,7 +63,7 @@ namespace PatchClient.ViewModels
foreach (LineItem item in AdditionalLineItems)
{
- if(initLineItemProgress)
+ if (initLineItemProgress)
{
if (item.ItemValue <= 0) continue;
diff --git a/Patcher/_port/Patcher/PatchClient/ViewModels/ViewModelBase.cs b/Patcher/_port/Patcher/PatchClient/ViewModels/ViewModelBase.cs
index 9e4534b..ae56d9e 100644
--- a/Patcher/_port/Patcher/PatchClient/ViewModels/ViewModelBase.cs
+++ b/Patcher/_port/Patcher/PatchClient/ViewModels/ViewModelBase.cs
@@ -1,9 +1,5 @@
-using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
using PatchClient.Models;
+using ReactiveUI;
namespace PatchClient.ViewModels
{
diff --git a/Patcher/_port/Patcher/PatchClient/Views/MessageView.axaml.cs b/Patcher/_port/Patcher/PatchClient/Views/MessageView.axaml.cs
index 1c00245..dab0189 100644
--- a/Patcher/_port/Patcher/PatchClient/Views/MessageView.axaml.cs
+++ b/Patcher/_port/Patcher/PatchClient/Views/MessageView.axaml.cs
@@ -1,4 +1,3 @@
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
diff --git a/Patcher/_port/Patcher/PatchClient/Views/PatcherView.axaml.cs b/Patcher/_port/Patcher/PatchClient/Views/PatcherView.axaml.cs
index 10c659a..d8ad362 100644
--- a/Patcher/_port/Patcher/PatchClient/Views/PatcherView.axaml.cs
+++ b/Patcher/_port/Patcher/PatchClient/Views/PatcherView.axaml.cs
@@ -1,4 +1,3 @@
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
diff --git a/Patcher/_port/Patcher/PatchGenerator/Assets/Styles.axaml b/Patcher/_port/Patcher/PatchGenerator/Assets/Styles.axaml
index 41b1c96..432b248 100644
--- a/Patcher/_port/Patcher/PatchGenerator/Assets/Styles.axaml
+++ b/Patcher/_port/Patcher/PatchGenerator/Assets/Styles.axaml
@@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="using:PatchGenerator.CustomControls">
-
+
@@ -12,18 +12,49 @@
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -36,6 +67,8 @@
+
+
@@ -65,7 +98,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Patcher/_port/Patcher/PatchGenerator/AttachedProperties/RandomBoolAttProp.cs b/Patcher/_port/Patcher/PatchGenerator/AttachedProperties/RandomBoolAttProp.cs
new file mode 100644
index 0000000..5b2eb0d
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/AttachedProperties/RandomBoolAttProp.cs
@@ -0,0 +1,24 @@
+using Avalonia;
+using Avalonia.Controls;
+
+namespace PatchGenerator.AttachedProperties
+{
+ ///
+ /// Just a random boolean value for you to attach and use to any control.
+ ///
+ public class RandomBoolAttProp : AvaloniaObject
+ {
+ public static readonly AttachedProperty RandomBoolProperty =
+ AvaloniaProperty.RegisterAttached("RandomBool");
+
+ public static bool GetRandomBool(Control control)
+ {
+ return control.GetValue(RandomBoolProperty);
+ }
+
+ public static void SetRandomBool(Control control, bool value)
+ {
+ control.SetValue(RandomBoolProperty, value);
+ }
+ }
+}
diff --git a/Patcher/_port/Patcher/PatchGenerator/CustomControls/FolderSelector.axaml b/Patcher/_port/Patcher/PatchGenerator/CustomControls/FolderSelector.axaml
new file mode 100644
index 0000000..5b5a529
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/CustomControls/FolderSelector.axaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Patcher/_port/Patcher/PatchGenerator/CustomControls/FolderSelector.axaml.cs b/Patcher/_port/Patcher/PatchGenerator/CustomControls/FolderSelector.axaml.cs
new file mode 100644
index 0000000..780cf97
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/CustomControls/FolderSelector.axaml.cs
@@ -0,0 +1,69 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Markup.Xaml;
+using System.IO;
+using System.Linq;
+
+namespace PatchGenerator.CustomControls
+{
+ public partial class FolderSelector : UserControl
+ {
+ public FolderSelector()
+ {
+ InitializeComponent();
+
+ AddHandler(DragDrop.DropEvent, Drop);
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ private void Drop(object sender, DragEventArgs e)
+ {
+ if (e.Data.Contains(DataFormats.FileNames))
+ {
+ string[] filePaths = e.Data.GetFileNames().ToArray();
+
+ if (filePaths.Length == 1)
+ {
+ DirectoryInfo folder = new DirectoryInfo(filePaths[0]);
+
+ if (folder.Exists)
+ {
+ FolderPath = filePaths[0];
+ FolderSelected = true;
+ return;
+ }
+
+ FolderPath = "Dropped object must be a folder";
+ FolderSelected = false;
+ return;
+ }
+
+ FolderPath = "Cannot drop multiple files";
+ FolderSelected = false;
+ }
+ }
+
+ private static readonly StyledProperty FolderSelectedProperty =
+ AvaloniaProperty.Register(nameof(FolderSelected));
+
+ private bool FolderSelected
+ {
+ get => GetValue(FolderSelectedProperty);
+ set => SetValue(FolderSelectedProperty, value);
+ }
+
+ public static readonly StyledProperty FolderPathProperty =
+ AvaloniaProperty.Register(nameof(FolderPath));
+
+ public string FolderPath
+ {
+ get => GetValue(FolderPathProperty);
+ set => SetValue(FolderPathProperty, value);
+ }
+ }
+}
diff --git a/Patcher/_port/Patcher/PatchGenerator/Helpers/PatchItemDefinitions.cs b/Patcher/_port/Patcher/PatchGenerator/Helpers/PatchItemDefinitions.cs
new file mode 100644
index 0000000..0c5e800
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/Helpers/PatchItemDefinitions.cs
@@ -0,0 +1,16 @@
+using Avalonia.Media;
+using System.Collections.Generic;
+
+namespace PatchGenerator.Helpers
+{
+ public static class PatchItemDefinitions
+ {
+ public static Dictionary Colors = new Dictionary()
+ {
+ {"delta", Brushes.MediumPurple },
+ {"new", Brushes.Green },
+ {"del", Brushes.IndianRed },
+ {"exists", Brushes.DimGray }
+ };
+ }
+}
diff --git a/Patcher/_port/Patcher/PatchGenerator/Models/GenStartupArgs.cs b/Patcher/_port/Patcher/PatchGenerator/Models/GenStartupArgs.cs
new file mode 100644
index 0000000..4b80a84
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/Models/GenStartupArgs.cs
@@ -0,0 +1,61 @@
+namespace PatchGenerator.Models
+{
+ public class GenStartupArgs
+ {
+ public bool ReadyToRun => OutputFolderName != "" && SourceFolderPath != "" && TargetFolderPath != "";
+ public string OutputFolderName { get; private set; } = "";
+ public string SourceFolderPath { get; private set; } = "";
+ public string TargetFolderPath { get; private set; } = "";
+ public bool AutoZip { get; private set; } = true;
+ protected GenStartupArgs(string OutputFolderName, string SourceFolderPath, string TargetFolderPath, bool AutoZip)
+ {
+ this.OutputFolderName = OutputFolderName;
+ this.SourceFolderPath = SourceFolderPath;
+ this.TargetFolderPath = TargetFolderPath;
+ this.AutoZip = AutoZip;
+ }
+
+ public static GenStartupArgs Parse(string[] Args)
+ {
+ if (Args == null || Args.Length == 0) return null;
+
+ string outputFolderPath = "";
+ string sourceFolderPath = "";
+ string targetFolderPath = "";
+ bool autoZip = true;
+
+ foreach (string arg in Args)
+ {
+ if (arg.Split("::").Length != 2) return null;
+
+ var argSplit = arg.Split("::");
+
+ switch (argSplit[0])
+ {
+ case "OutputFolderName":
+ {
+ outputFolderPath = argSplit[1];
+ break;
+ }
+ case "SourceFolderPath":
+ {
+ sourceFolderPath = argSplit[1];
+ break;
+ }
+ case "TargetFolderPath":
+ {
+ targetFolderPath = argSplit[1];
+ break;
+ }
+ case "AutoZip":
+ {
+ autoZip = bool.Parse(argSplit[1]);
+ break;
+ }
+ }
+ }
+
+ return new GenStartupArgs(outputFolderPath, sourceFolderPath, targetFolderPath, autoZip);
+ }
+ }
+}
diff --git a/Patcher/_port/Patcher/PatchGenerator/Models/PatchGenInfo.cs b/Patcher/_port/Patcher/PatchGenerator/Models/PatchGenInfo.cs
new file mode 100644
index 0000000..5716350
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/Models/PatchGenInfo.cs
@@ -0,0 +1,66 @@
+using ReactiveUI;
+using System.IO;
+
+namespace PatchGenerator.Models
+{
+ public class PatchGenInfo : ReactiveObject
+ {
+ private void UpdateReadyToRun()
+ {
+ if (Directory.Exists(SourceFolderPath) && Directory.Exists(TargetFolderPath) && PatchName != "")
+ {
+ ReadyToRun = true;
+ return;
+ }
+
+ ReadyToRun = false;
+ }
+
+ private string _PatchName = "";
+ public string PatchName
+ {
+ get => _PatchName;
+ set
+ {
+ this.RaiseAndSetIfChanged(ref _PatchName, value);
+ UpdateReadyToRun();
+ }
+ }
+
+ private string _SourceFolderPath = "";
+ public string SourceFolderPath
+ {
+ get => _SourceFolderPath;
+ set
+ {
+ this.RaiseAndSetIfChanged(ref _SourceFolderPath, value);
+ UpdateReadyToRun();
+ }
+ }
+
+ private string _TargetFolderPath = "";
+ public string TargetFolderPath
+ {
+ get => _TargetFolderPath;
+ set
+ {
+ this.RaiseAndSetIfChanged(ref _TargetFolderPath, value);
+ UpdateReadyToRun();
+ }
+ }
+
+ private bool _AutoZip = true;
+ public bool AutoZip
+ {
+ get => _AutoZip;
+ set => this.RaiseAndSetIfChanged(ref _AutoZip, value);
+ }
+
+ private bool _ReadyToRun = false;
+ public bool ReadyToRun
+ {
+ get => _ReadyToRun;
+ set => this.RaiseAndSetIfChanged(ref _ReadyToRun, value);
+ }
+ }
+}
diff --git a/Patcher/_port/Patcher/PatchGenerator/Models/PatchItem.cs b/Patcher/_port/Patcher/PatchGenerator/Models/PatchItem.cs
new file mode 100644
index 0000000..1355209
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/Models/PatchItem.cs
@@ -0,0 +1,40 @@
+using Avalonia.Media;
+using PatchGenerator.Helpers;
+using ReactiveUI;
+using System.Linq;
+
+namespace PatchGenerator.Models
+{
+ public class PatchItem : ReactiveObject
+ {
+ private string _Name = "";
+ public string Name
+ {
+ get => _Name;
+ set => this.RaiseAndSetIfChanged(ref _Name, value);
+ }
+
+ private IBrush _Color;
+ public IBrush Color
+ {
+ get => _Color;
+ set => this.RaiseAndSetIfChanged(ref _Color, value);
+ }
+
+ public PatchItem(string Name)
+ {
+ this.Name = Name.Replace(".new", "").Replace(".delta", "").Replace(".del", "");
+
+ IBrush color;
+
+ if (PatchItemDefinitions.Colors.TryGetValue(Name.Split('.').Last(), out color))
+ {
+ Color = color;
+ }
+ else
+ {
+ Color = PatchItemDefinitions.Colors["exists"];
+ }
+ }
+ }
+}
diff --git a/Patcher/_port/Patcher/PatchGenerator/PatchGenerator - Backup.csproj b/Patcher/_port/Patcher/PatchGenerator/PatchGenerator - Backup.csproj
new file mode 100644
index 0000000..140cb20
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/PatchGenerator - Backup.csproj
@@ -0,0 +1,43 @@
+
+
+ WinExe
+ net6.0
+ true
+ enable
+
+
+
+
+
+
+
+
+ References\Aki.Common.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %(Filename)
+
+
+
diff --git a/Patcher/_port/Patcher/PatchGenerator/PatchGenerator.csproj b/Patcher/_port/Patcher/PatchGenerator/PatchGenerator.csproj
index e35d971..a2d1623 100644
--- a/Patcher/_port/Patcher/PatchGenerator/PatchGenerator.csproj
+++ b/Patcher/_port/Patcher/PatchGenerator/PatchGenerator.csproj
@@ -2,6 +2,7 @@
WinExe
net6.0
+ true
enable
@@ -19,6 +20,15 @@
+
+
+
+
+
+
+
+
+
@@ -32,7 +42,4 @@
%(Filename)
-
-
-
diff --git a/Patcher/_port/Patcher/PatchGenerator/Program.cs b/Patcher/_port/Patcher/PatchGenerator/Program.cs
index eaffe80..dd81e50 100644
--- a/Patcher/_port/Patcher/PatchGenerator/Program.cs
+++ b/Patcher/_port/Patcher/PatchGenerator/Program.cs
@@ -1,5 +1,4 @@
using Avalonia;
-using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;
using System;
diff --git a/Patcher/_port/Patcher/PatchGenerator/Resources/7za.exe b/Patcher/_port/Patcher/PatchGenerator/Resources/7za.exe
new file mode 100644
index 0000000..2bdd57d
Binary files /dev/null and b/Patcher/_port/Patcher/PatchGenerator/Resources/7za.exe differ
diff --git a/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe b/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe
new file mode 100644
index 0000000..5f497b9
--- /dev/null
+++ b/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:36cd4919612d2b9099937d033fb69042d5fabcc78319aa654571561db09f72dd
+size 32562860
diff --git a/Patcher/_port/Patcher/PatchGenerator/Resources/xdelta3.exe b/Patcher/_port/Patcher/PatchGenerator/Resources/xdelta3.exe
new file mode 100644
index 0000000..1cce3c5
Binary files /dev/null and b/Patcher/_port/Patcher/PatchGenerator/Resources/xdelta3.exe differ
diff --git a/Patcher/_port/Patcher/PatchGenerator/ViewModels/OptionsViewModel.cs b/Patcher/_port/Patcher/PatchGenerator/ViewModels/OptionsViewModel.cs
index 7d11f9f..52ae787 100644
--- a/Patcher/_port/Patcher/PatchGenerator/ViewModels/OptionsViewModel.cs
+++ b/Patcher/_port/Patcher/PatchGenerator/ViewModels/OptionsViewModel.cs
@@ -1,12 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using PatchGenerator.Models;
+using Splat;
namespace PatchGenerator.ViewModels
{
public class OptionsViewModel : ViewModelBase
{
+ public PatchGenInfo GenerationInfo { get; set; } = new PatchGenInfo();
+
+ private ViewNavigator navigator => Locator.Current.GetService();
+
+ public OptionsViewModel(GenStartupArgs genArgs = null)
+ {
+ if (genArgs != null)
+ {
+ //TODO - parse/check startup args and start patching
+ return;
+ }
+
+ GenerationInfo.SourceFolderPath = "Drop SOURCE folder here";
+ GenerationInfo.TargetFolderPath = "Drop TARGET folder here";
+ }
+
+ public void GeneratePatches()
+ {
+ navigator.SelectedViewModel = new PatchGenerationViewModel(GenerationInfo);
+ }
}
}
diff --git a/Patcher/_port/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs b/Patcher/_port/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs
index 7747290..ca22acb 100644
--- a/Patcher/_port/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs
+++ b/Patcher/_port/Patcher/PatchGenerator/ViewModels/PatchGenerationViewModel.cs
@@ -1,6 +1,12 @@
-using System;
+using Avalonia.Media;
+using PatcherUtils;
+using PatchGenerator.Helpers;
+using PatchGenerator.Models;
+using ReactiveUI;
using System.Collections.Generic;
-using System.Linq;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
using System.Text;
using System.Threading.Tasks;
@@ -8,5 +14,92 @@ namespace PatchGenerator.ViewModels
{
public class PatchGenerationViewModel : ViewModelBase
{
+ private bool _AutoScroll = true;
+ public bool AutoScroll
+ {
+ get => _AutoScroll;
+ set => this.RaiseAndSetIfChanged(ref _AutoScroll, value);
+ }
+
+ private string _ProgressMessage;
+ public string ProgressMessage
+ {
+ get => _ProgressMessage;
+ set => this.RaiseAndSetIfChanged(ref _ProgressMessage, value);
+ }
+
+ private int _PatchPercent;
+ public int PatchPercent
+ {
+ get => _PatchPercent;
+ set => this.RaiseAndSetIfChanged(ref _PatchPercent, value);
+ }
+
+ public ObservableCollection PatchItemCollection { get; set; } = new ObservableCollection();
+ public ObservableCollection PatchItemLegendCollection { get; set; } = new ObservableCollection();
+
+ private Stopwatch patchGenStopwatch = new Stopwatch();
+
+ private readonly PatchGenInfo generationInfo;
+ public PatchGenerationViewModel(PatchGenInfo GenerationInfo)
+ {
+ generationInfo = GenerationInfo;
+
+ foreach (KeyValuePair pair in PatchItemDefinitions.Colors)
+ {
+ PatchItemLegendCollection.Add(new PatchItem("")
+ {
+ Name = pair.Key,
+ Color = pair.Value,
+ });
+ }
+
+ GeneratePatches();
+ }
+
+ public void GeneratePatches()
+ {
+ Task.Run(() =>
+ {
+ //Slight delay to avoid some weird race condition in avalonia core, seems to be a bug, but also maybe I'm just stupid, idk -waffle
+ System.Threading.Thread.Sleep(200);
+
+ string outputFolder = Path.Join(LazyOperations.PatchFolder, generationInfo.PatchName);
+
+ PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, outputFolder);
+
+ patcher.ProgressChanged += Patcher_ProgressChanged;
+
+ patchGenStopwatch.Start();
+
+ patcher.GeneratePatches();
+
+ patchGenStopwatch.Stop();
+
+ StringBuilder sb = new StringBuilder()
+ .Append("Patches Generated in ")
+ .Append($"{patchGenStopwatch.Elapsed.Hours} hr/s ")
+ .Append($"{patchGenStopwatch.Elapsed.Minutes} min/s ")
+ .Append($"{patchGenStopwatch.Elapsed.Seconds} sec/s");
+
+ ProgressMessage = sb.ToString();
+
+ //TODO - need to fix this. Wrong folder, and need to copy client to output
+ if (generationInfo.AutoZip)
+ {
+ LazyOperations.StartZipProcess(outputFolder, $"{outputFolder}.zip");
+ }
+ });
+ }
+
+ private void Patcher_ProgressChanged(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems)
+ {
+ ProgressMessage = $"{Progress}/{Total}";
+
+ PatchPercent = Percent;
+
+ PatchItemCollection.Add(new PatchItem(Message));
+ }
}
+
}
diff --git a/Patcher/_port/Patcher/PatchGenerator/ViewModels/ViewModelBase.cs b/Patcher/_port/Patcher/PatchGenerator/ViewModels/ViewModelBase.cs
index ad5d750..14a41bb 100644
--- a/Patcher/_port/Patcher/PatchGenerator/ViewModels/ViewModelBase.cs
+++ b/Patcher/_port/Patcher/PatchGenerator/ViewModels/ViewModelBase.cs
@@ -1,7 +1,4 @@
using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace PatchGenerator.ViewModels
{
diff --git a/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml b/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml
index de7c1ff..68aa4e3 100644
--- a/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml
+++ b/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml
@@ -2,9 +2,33 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:cc="using:PatchGenerator.CustomControls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchGenerator.Views.OptionsView">
-
+
+
+
+
+
+
+
+
+
diff --git a/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml.cs b/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml.cs
index 44033b0..484cfad 100644
--- a/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml.cs
+++ b/Patcher/_port/Patcher/PatchGenerator/Views/OptionsView.axaml.cs
@@ -1,4 +1,3 @@
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
diff --git a/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml b/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml
index 118acd2..fe5c2de 100644
--- a/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml
+++ b/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml
@@ -2,7 +2,71 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:model="using:PatchGenerator.Models"
+ xmlns:cc="using:PatchGenerator.CustomControls"
+ xmlns:att="using:PatchGenerator.AttachedProperties"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchGenerator.Views.PatchGenerationView">
- Welcome to Avalonia!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml.cs b/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml.cs
index 4822239..958aa2f 100644
--- a/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml.cs
+++ b/Patcher/_port/Patcher/PatchGenerator/Views/PatchGenerationView.axaml.cs
@@ -1,6 +1,6 @@
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
+using PatchGenerator.AttachedProperties;
namespace PatchGenerator.Views
{
@@ -15,5 +15,18 @@ namespace PatchGenerator.Views
{
AvaloniaXamlLoader.Load(this);
}
+
+ public void scrollChanged(object sender, ScrollChangedEventArgs e)
+ {
+ if (sender is ScrollViewer scrollViewer)
+ {
+ bool autoScroll = scrollViewer.GetValue(RandomBoolAttProp.RandomBoolProperty);
+
+ if (autoScroll)
+ {
+ scrollViewer.ScrollToEnd();
+ }
+ }
+ }
}
}
diff --git a/Patcher/_port/Patcher/PatcherUtils/LazyOperations.cs b/Patcher/_port/Patcher/PatcherUtils/LazyOperations.cs
index 06d4098..c4a69e8 100644
--- a/Patcher/_port/Patcher/PatcherUtils/LazyOperations.cs
+++ b/Patcher/_port/Patcher/PatcherUtils/LazyOperations.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Diagnostics;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
@@ -67,9 +66,9 @@ namespace PatcherUtils
///
public static void PrepTempDir()
{
- foreach(string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames())
+ foreach (string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames())
{
- switch(resource)
+ switch (resource)
{
case string a when a.EndsWith(SevenZExe):
{
@@ -108,7 +107,7 @@ namespace PatcherUtils
{
DirectoryInfo dir = new DirectoryInfo(TempDir);
- if(dir.Exists)
+ if (dir.Exists)
{
dir.Delete(true);
}
diff --git a/Patcher/_port/Patcher/PatcherUtils/PatchHelper.cs b/Patcher/_port/Patcher/PatcherUtils/PatchHelper.cs
index ac36a71..07f9852 100644
--- a/Patcher/_port/Patcher/PatcherUtils/PatchHelper.cs
+++ b/Patcher/_port/Patcher/PatcherUtils/PatchHelper.cs
@@ -97,10 +97,9 @@ namespace PatcherUtils
})
.WaitForExit();
- if(File.Exists(decodedPath))
+ if (File.Exists(decodedPath))
{
- File.Delete(SourceFilePath);
- File.Move(decodedPath, SourceFilePath);
+ File.Move(decodedPath, SourceFilePath, true);
}
}
@@ -116,7 +115,7 @@ namespace PatcherUtils
string deltaPath = GetDeltaPath(SourceFilePath, SourceFolder, "delta");
- Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name+".delta", ""));
+ Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name + ".delta", ""));
//TODO - don't hardcode FileName
@@ -140,7 +139,7 @@ namespace PatcherUtils
string deltaPath = GetDeltaPath(SourceFile, SourceFolder, "del");
- Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name+".del", ""));
+ Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name + ".del", ""));
File.Create(deltaPath);
}
@@ -156,7 +155,7 @@ namespace PatcherUtils
string deltaPath = GetDeltaPath(TargetFile, TargetFolder, "new");
- Directory.CreateDirectory(deltaPath.Replace(targetSourceInfo.Name+".new", ""));
+ Directory.CreateDirectory(deltaPath.Replace(targetSourceInfo.Name + ".new", ""));
targetSourceInfo.CopyTo(deltaPath, true);
}
@@ -180,6 +179,9 @@ namespace PatcherUtils
return false;
}
+ LazyOperations.CleanupTempDir();
+ LazyOperations.PrepTempDir();
+
List SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
fileCountTotal = SourceFiles.Count;
@@ -206,15 +208,18 @@ namespace PatcherUtils
newCount++;
filesProcessed++;
- RaiseProgressChanged(filesProcessed, fileCountTotal, targetFile.Name, AdditionalInfo.ToArray());
+ RaiseProgressChanged(filesProcessed, fileCountTotal, $"{targetFile.FullName.Replace(TargetFolder, "...")}.new", AdditionalInfo.ToArray());
continue;
}
+ string extension = "";
+
//if a matching source file was found, check the file hashes and get the delta.
- if(!CompareFileHashes(sourceFile.FullName, targetFile.FullName))
+ if (!CompareFileHashes(sourceFile.FullName, targetFile.FullName))
{
CreateDelta(sourceFile.FullName, targetFile.FullName);
+ extension = ".delta";
deltaCount++;
}
@@ -225,7 +230,7 @@ namespace PatcherUtils
AdditionalInfo[0].ItemValue = deltaCount;
AdditionalInfo[1].ItemValue = newCount;
- RaiseProgressChanged(filesProcessed, fileCountTotal, targetFile.Name, AdditionalInfo.ToArray());
+ RaiseProgressChanged(filesProcessed, fileCountTotal, $"{targetFile.FullName.Replace(TargetFolder, "...")}{extension}", AdditionalInfo.ToArray());
}
//Any remaining source files do not exist in the target folder and can be removed.
@@ -243,7 +248,7 @@ namespace PatcherUtils
AdditionalInfo[2].ItemValue = delCount;
filesProcessed++;
- RaiseProgressChanged(filesProcessed, fileCountTotal, "", AdditionalInfo.ToArray());
+ RaiseProgressChanged(filesProcessed, fileCountTotal, $"{delFile.FullName.Replace(SourceFolder, "...")}.del", AdditionalInfo.ToArray());
}
return true;
@@ -290,14 +295,14 @@ namespace PatcherUtils
foreach (FileInfo deltaFile in deltaDir.GetFiles("*", SearchOption.AllDirectories))
{
- switch(deltaFile.Extension)
+ switch (deltaFile.Extension)
{
case ".delta":
{
//apply delta
FileInfo sourceFile = SourceFiles.Find(f => f.FullName.Replace(sourceDir.FullName, "") == deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".delta", ""));
- if(sourceFile == null)
+ if (sourceFile == null)
{
return $"Failed to find matching source file for '{deltaFile.FullName}'";
}
@@ -310,7 +315,7 @@ namespace PatcherUtils
}
case ".new":
{
- if(newCount == 2 || newCount == 1 || newCount == 0)
+ if (newCount == 2 || newCount == 1 || newCount == 0)
{
}
@@ -318,7 +323,7 @@ namespace PatcherUtils
//copy new file
string destination = Path.Join(sourceDir.FullName, deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".new", ""));
- File.Copy(deltaFile.FullName, destination);
+ File.Copy(deltaFile.FullName, destination, true);
newCount--;