mirror of
https://github.com/sp-tarkov/patcher.git
synced 2025-02-13 09:52:45 -05:00
add patchclient, update other projects, blah
This commit is contained in:
parent
f44bb375c2
commit
308ea92267
9
Patcher/PatchClient/App.xaml
Normal file
9
Patcher/PatchClient/App.xaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="PatchClient.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:PatchClient"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
17
Patcher/PatchClient/App.xaml.cs
Normal file
17
Patcher/PatchClient/App.xaml.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace PatchClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
10
Patcher/PatchClient/AssemblyInfo.cs
Normal file
10
Patcher/PatchClient/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
48
Patcher/PatchClient/Extensions/ControlExtensions.cs
Normal file
48
Patcher/PatchClient/Extensions/ControlExtensions.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace PatchClient.Extensions
|
||||||
|
{
|
||||||
|
public static class ControlExtensions
|
||||||
|
{
|
||||||
|
public static void DispatcherSetValue(this ProgressBar pb, int Value)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
pb.Value = Value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispatcherSetIndetermination(this ProgressBar pb, bool Indeterminate)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
pb.IsIndeterminate = Indeterminate;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispaatcherSetContent(this ContentControl cc, object content)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
cc.Content = content;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispatcherSetText(this TextBlock tb, string Text)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
tb.Text = Text;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispatcherSetEnabled(this UIElement uie, bool Enabled)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
uie.IsEnabled = Enabled;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
Patcher/PatchClient/MainWindow.xaml
Normal file
36
Patcher/PatchClient/MainWindow.xaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<Window x:Class="PatchClient.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
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:local="clr-namespace:PatchClient"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Patching Client" Height="200" Width="600"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Loaded="Window_Loaded">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel VerticalAlignment="Center">
|
||||||
|
<Label x:Name="PatchMessageLabel"
|
||||||
|
Margin="10"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ContentControl Margin="10">
|
||||||
|
<Grid>
|
||||||
|
<ProgressBar x:Name="PatchProgressBar"
|
||||||
|
Height="20"
|
||||||
|
Foreground="MediumPurple"
|
||||||
|
/>
|
||||||
|
<Label x:Name="PatchProgressInfoLabel"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
FontSize="15" FontWeight="SemiBold"
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
</ContentControl>
|
||||||
|
|
||||||
|
<TextBlock x:Name="AdditionalInfoBlock"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="10"
|
||||||
|
/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
82
Patcher/PatchClient/MainWindow.xaml.cs
Normal file
82
Patcher/PatchClient/MainWindow.xaml.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using PatchClient.Extensions;
|
||||||
|
using PatcherUtils;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace PatchClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunPatcher()
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
FilePatcher bp = new FilePatcher()
|
||||||
|
{
|
||||||
|
TargetBase = Environment.CurrentDirectory,
|
||||||
|
PatchBase = LazyOperations.PatchFolder.FromCwd()
|
||||||
|
};
|
||||||
|
|
||||||
|
bp.ProgressChanged += Bp_ProgressChanged;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (bp.Run())
|
||||||
|
{
|
||||||
|
MessageBox.Show("Patch completed without issues", "Patching Successful");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Failed to patch client.", "Patching Failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
Application.Current.Shutdown(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Bp_ProgressChanged(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems)
|
||||||
|
{
|
||||||
|
string additionalInfo = "";
|
||||||
|
foreach (LineItem item in AdditionalLineItems)
|
||||||
|
{
|
||||||
|
additionalInfo += $"{item.ItemText}: {item.ItemValue}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PatchProgressBar.DispatcherSetValue(Percent);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(Message))
|
||||||
|
{
|
||||||
|
PatchMessageLabel.DispaatcherSetContent(Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
PatchProgressInfoLabel.DispaatcherSetContent($"[{Progress}/{Total}]");
|
||||||
|
|
||||||
|
AdditionalInfoBlock.DispatcherSetText(additionalInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
RunPatcher();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
Patcher/PatchClient/PatchClient.csproj
Normal file
13
Patcher/PatchClient/PatchClient.csproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
48
Patcher/PatchGenerator/Extensions/ControlExtensions.cs
Normal file
48
Patcher/PatchGenerator/Extensions/ControlExtensions.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace PatchGenerator.Extensions
|
||||||
|
{
|
||||||
|
public static class ControlExtensions
|
||||||
|
{
|
||||||
|
public static void DispatcherSetValue(this ProgressBar pb, int Value)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
pb.Value = Value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispatcherSetIndetermination(this ProgressBar pb, bool Indeterminate)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
pb.IsIndeterminate = Indeterminate;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispaatcherSetContent(this ContentControl cc, object content)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
cc.Content = content;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispatcherSetText(this TextBlock tb, string Text)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
tb.Text = Text;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DispatcherSetEnabled(this UIElement uie, bool Enabled)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
uie.IsEnabled = Enabled;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,8 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:PatchGenerator"
|
xmlns:local="clr-namespace:PatchGenerator"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="Patch Generator" Height="450" Width="800"
|
||||||
|
WindowStartupLocation="CenterScreen">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@ -14,30 +15,41 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="AUTO"/>
|
<RowDefinition Height="AUTO"/>
|
||||||
|
<RowDefinition Height="AUTO"/>
|
||||||
|
<RowDefinition Height="200"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="AUTO"/>
|
<RowDefinition Height="AUTO"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<DockPanel Grid.ColumnSpan="2" Margin="10 10 10 5"
|
||||||
|
LastChildFill="True">
|
||||||
|
<Label Content="Output Folder Name"
|
||||||
|
/>
|
||||||
|
<TextBox x:Name="FileNameBox"
|
||||||
|
TextChanged="FileNameBox_TextChanged"
|
||||||
|
/>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
<ProgressBar x:Name="GenProgressBar"
|
<ProgressBar x:Name="GenProgressBar"
|
||||||
Grid.ColumnSpan="2"
|
Grid.Row="1" Grid.ColumnSpan="2"
|
||||||
Height="20" Margin="10"
|
Height="20" Margin="10 5 10 10"
|
||||||
Foreground="MediumPurple"
|
Foreground="MediumPurple"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Label x:Name="GenProgressMessageLabel"
|
<Label x:Name="GenProgressMessageLabel"
|
||||||
FontSize="15" FontWeight="SemiBold"
|
FontSize="15" FontWeight="SemiBold"
|
||||||
Grid.ColumnSpan="2" Margin="0 0 10 0"
|
Grid.Row="1" Grid.ColumnSpan="2" Margin="0 0 10 5"
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Label x:Name="GenProgressInfoLabel"
|
<Label x:Name="GenProgressInfoLabel"
|
||||||
FontSize="15" FontWeight="SemiBold"
|
FontSize="15" FontWeight="SemiBold"
|
||||||
Grid.ColumnSpan="2" Margin="10 0 0 0"
|
Grid.Row="1" Grid.ColumnSpan="2" Margin="10 0 0 5"
|
||||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Label x:Name="CompareLabel"
|
<Label x:Name="CompareLabel"
|
||||||
Grid.Row="1" Margin="10 10 5 10"
|
Grid.Row="2" Margin="10 10 5 10"
|
||||||
Drop="CompareLabel_Drop"
|
Drop="CompareLabel_Drop"
|
||||||
AllowDrop="True"
|
AllowDrop="True"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
@ -47,7 +59,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Label x:Name="TargetLabel"
|
<Label x:Name="TargetLabel"
|
||||||
Grid.Column="1" Grid.Row="1" Margin="5 10 10 10"
|
Grid.Column="1" Grid.Row="2" Margin="5 10 10 10"
|
||||||
Drop="TargetLabel_Drop"
|
Drop="TargetLabel_Drop"
|
||||||
AllowDrop="True"
|
AllowDrop="True"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
@ -57,12 +69,13 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<TextBlock x:Name="AdditionalInfoBlock"
|
<TextBlock x:Name="AdditionalInfoBlock"
|
||||||
Grid.Row="2" Margin="10"
|
Grid.Row="3" Grid.RowSpan="2" Margin="10"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button x:Name="GenButton"
|
<Button x:Name="GenButton"
|
||||||
Grid.Column="1" Grid.Row="2"
|
Grid.Column="1" Grid.Row="4"
|
||||||
MinHeight="40" Margin="10"
|
MinHeight="40" Margin="10"
|
||||||
Content="Generate Patches"
|
Content="Generate Patches"
|
||||||
Click="GenButton_Click"
|
Click="GenButton_Click"
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
using System.Diagnostics;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using PatcherUtils;
|
using PatcherUtils;
|
||||||
|
using PatchGenerator.Extensions;
|
||||||
|
|
||||||
namespace PatchGenerator
|
namespace PatchGenerator
|
||||||
{
|
{
|
||||||
@ -14,7 +17,8 @@ namespace PatchGenerator
|
|||||||
{
|
{
|
||||||
private string compareFolder = "";
|
private string compareFolder = "";
|
||||||
private string targetFolder = "";
|
private string targetFolder = "";
|
||||||
private readonly string patchFolder = "Aki_Data/Patcher/".FromCwd();
|
private string outputFolderName = "";
|
||||||
|
|
||||||
private Stopwatch stopwatch = new Stopwatch();
|
private Stopwatch stopwatch = new Stopwatch();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
@ -74,26 +78,19 @@ namespace PatchGenerator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GeneratePatches()
|
private void GeneratePatches(string patchBase)
|
||||||
{
|
{
|
||||||
//create temp data
|
//create temp data
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
GenProgressBar.DispatcherSetIndetermination(true);
|
||||||
{
|
GenProgressMessageLabel.DispaatcherSetContent("Extracting temp data ...");
|
||||||
GenProgressBar.IsIndeterminate = true;
|
|
||||||
GenProgressMessageLabel.Content = "Extracting temp data ...";
|
|
||||||
});
|
|
||||||
|
|
||||||
|
LazyOperations.CleanupTempDir();
|
||||||
LazyOperations.PrepTempDir();
|
LazyOperations.PrepTempDir();
|
||||||
|
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
GenProgressBar.DispatcherSetIndetermination(false);
|
||||||
{
|
|
||||||
GenProgressBar.IsIndeterminate = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//generate patches
|
//generate patches
|
||||||
|
FileCompare bc = new FileCompare(targetFolder, compareFolder, patchBase);
|
||||||
FileCompare bc = new FileCompare(targetFolder, compareFolder, patchFolder);
|
|
||||||
|
|
||||||
bc.ProgressChanged += Bc_ProgressChanged;
|
bc.ProgressChanged += Bc_ProgressChanged;
|
||||||
|
|
||||||
@ -102,50 +99,89 @@ namespace PatchGenerator
|
|||||||
MessageBox.Show("Failed to generate diffs.", ":(", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show("Failed to generate diffs.", ":(", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - Build patcher
|
//Copy patch client to output folder
|
||||||
|
File.Copy(LazyOperations.PatcherClientPath, $"{outputFolderName}\\patcher.exe", true);
|
||||||
|
|
||||||
//TODO - compress to file (should add a name textbox or something)
|
//compress patch output folder to 7z file
|
||||||
|
LazyOperations.StartZipProcess(outputFolderName, $"{outputFolderName}.7z".FromCwd());
|
||||||
|
|
||||||
//Cleanup temp data
|
GenProgressBar.DispatcherSetValue(100);
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
GenProgressMessageLabel.DispaatcherSetContent("Done");
|
||||||
{
|
|
||||||
GenProgressBar.Value = 100;
|
|
||||||
GenProgressMessageLabel.Content = $"Done";
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!LazyOperations.CleanupTempDir())
|
|
||||||
{
|
|
||||||
MessageBox.Show($"Looks like some temp files could not be removed. You can safely delete this folder:\n\n{LazyOperations.TempDir}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Bc_ProgressChanged(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems)
|
private void Bc_ProgressChanged(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems)
|
||||||
{
|
{
|
||||||
|
|
||||||
string additionalInfo = "";
|
string additionalInfo = "";
|
||||||
foreach(LineItem item in AdditionalLineItems)
|
foreach (LineItem item in AdditionalLineItems)
|
||||||
{
|
{
|
||||||
additionalInfo += $"{item.ItemText}: {item.ItemValue}\n";
|
additionalInfo += $"{item.ItemText}: {item.ItemValue}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
|
||||||
|
GenProgressBar.DispatcherSetValue(Percent);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(Message))
|
||||||
{
|
{
|
||||||
GenProgressBar.Value = Percent;
|
GenProgressMessageLabel.DispaatcherSetContent(Message);
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(Message))
|
GenProgressInfoLabel.DispaatcherSetContent($"[{Progress}/{Total}]");
|
||||||
{
|
|
||||||
GenProgressMessageLabel.Content = Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
GenProgressInfoLabel.Content = $"[{Progress}/{Total}]";
|
AdditionalInfoBlock.DispatcherSetText(additionalInfo);
|
||||||
|
|
||||||
AdditionalInfoBlock.Text = additionalInfo;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenButton_Click(object sender, RoutedEventArgs e)
|
private void GenButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
GenButton.IsEnabled = false;
|
GenButton.IsEnabled = false;
|
||||||
|
CompareLabel.IsEnabled = false;
|
||||||
|
TargetLabel.IsEnabled = false;
|
||||||
|
FileNameBox.IsEnabled = false;
|
||||||
|
|
||||||
|
string InfoNeededMessage = "You must set the following: ";
|
||||||
|
bool infoNeeded = false;
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(FileNameBox.Text))
|
||||||
|
{
|
||||||
|
InfoNeededMessage += "\n[Output File Name]";
|
||||||
|
FileNameBox.BorderBrush = Brushes.Red;
|
||||||
|
infoNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(compareFolder))
|
||||||
|
{
|
||||||
|
InfoNeededMessage += "\n[COMPARE Folder]";
|
||||||
|
CompareLabel.BorderBrush = Brushes.Red;
|
||||||
|
infoNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(targetFolder))
|
||||||
|
{
|
||||||
|
InfoNeededMessage += "\n[TARGET Folder]";
|
||||||
|
TargetLabel.BorderBrush = Brushes.Red;
|
||||||
|
infoNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (infoNeeded)
|
||||||
|
{
|
||||||
|
MessageBox.Show(InfoNeededMessage, "Info Required", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
GenButton.IsEnabled = true;
|
||||||
|
CompareLabel.IsEnabled = true;
|
||||||
|
TargetLabel.IsEnabled = true;
|
||||||
|
FileNameBox.IsEnabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetEndingInfo(string info)
|
||||||
|
{
|
||||||
|
GenButton.DispatcherSetEnabled(true);
|
||||||
|
CompareLabel.DispatcherSetEnabled(true);
|
||||||
|
TargetLabel.DispatcherSetEnabled(true);
|
||||||
|
FileNameBox.DispatcherSetEnabled(true);
|
||||||
|
|
||||||
|
GenProgressMessageLabel.DispaatcherSetContent("");
|
||||||
|
GenProgressInfoLabel.DispaatcherSetContent(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
@ -154,20 +190,27 @@ namespace PatchGenerator
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GeneratePatches();
|
GeneratePatches(Path.Combine(outputFolderName.FromCwd(), LazyOperations.PatchFolder));
|
||||||
|
stopwatch.Stop();
|
||||||
|
SetEndingInfo($"Patches Generated in: {GetStopWatchTime()}");
|
||||||
}
|
}
|
||||||
finally
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
SetEndingInfo(ex.Message);
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
|
||||||
{
|
|
||||||
GenButton.IsEnabled = true;
|
|
||||||
GenProgressMessageLabel.Content = "";
|
|
||||||
GenProgressInfoLabel.Content = $"Patches Generated in: {GetStopWatchTime()}";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FileNameBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
FileNameBox.BorderBrush = Brushes.Gainsboro;
|
||||||
|
|
||||||
|
if (outputFolderName == FileNameBox.Text) return;
|
||||||
|
|
||||||
|
outputFolderName = Regex.Replace(FileNameBox.Text, "[^A-Za-z0-9.\\-_]", "");
|
||||||
|
|
||||||
|
FileNameBox.Text = outputFolderName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,6 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="Resources\7za.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Resources\7za.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatchGenerator", "PatchGene
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatcherUtils", "PatcherUtils\PatcherUtils.csproj", "{A9819B34-8111-4344-B2B3-3DE5D7A43A45}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatcherUtils", "PatcherUtils\PatcherUtils.csproj", "{A9819B34-8111-4344-B2B3-3DE5D7A43A45}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchClient", "PatchClient\PatchClient.csproj", "{9CA4D2BD-6596-41D1-8354-135868DF8DAB}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -21,6 +23,10 @@ Global
|
|||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -140,7 +140,7 @@ namespace PatcherUtils
|
|||||||
AdditionalInfo[3].ItemValue = matchCount.ToString();
|
AdditionalInfo[3].ItemValue = matchCount.ToString();
|
||||||
|
|
||||||
fileIt++;
|
fileIt++;
|
||||||
RaiseProgressChanged(fileIt, fileCount, "", AdditionalInfo.ToArray());
|
RaiseProgressChanged(fileIt, fileCount, file.Name, AdditionalInfo.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
foreach (FileInfo file in di.GetFiles())
|
foreach (FileInfo file in di.GetFiles())
|
||||||
{
|
{
|
||||||
FileInfo target;
|
FileInfo target = null;
|
||||||
|
|
||||||
switch (file.Extension)
|
switch (file.Extension)
|
||||||
{
|
{
|
||||||
@ -106,7 +106,7 @@ namespace PatcherUtils
|
|||||||
AdditionalInfo[2].ItemValue = delCount.ToString();
|
AdditionalInfo[2].ItemValue = delCount.ToString();
|
||||||
|
|
||||||
++fileIt;
|
++fileIt;
|
||||||
RaiseProgressChanged(fileIt, fileCount, "", AdditionalInfo.ToArray());
|
RaiseProgressChanged(fileIt, fileCount, target.Name, AdditionalInfo.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (DirectoryInfo directory in di.GetDirectories())
|
foreach (DirectoryInfo directory in di.GetDirectories())
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace PatcherUtils
|
namespace PatcherUtils
|
||||||
@ -11,12 +13,18 @@ namespace PatcherUtils
|
|||||||
public static string TempDir = "PATCHER_TEMP".FromCwd();
|
public static string TempDir = "PATCHER_TEMP".FromCwd();
|
||||||
|
|
||||||
private static string SevenZExe = "7za.exe";
|
private static string SevenZExe = "7za.exe";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The folder that the patches will be stored in
|
||||||
|
/// </summary>
|
||||||
|
public static string PatchFolder = "Aki_Data\\Patcher";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The path to the 7za.exe file in the <see cref="TempDir"/>
|
/// The path to the 7za.exe file in the <see cref="TempDir"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string SevenZExePath = $"{TempDir}\\{SevenZExe}";
|
public static string SevenZExePath = $"{TempDir}\\{SevenZExe}";
|
||||||
|
|
||||||
private static string PatcherClient = "patcher.exe";
|
private static string PatcherClient = "PatchClient.exe";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The path to the patcher.exe file in the <see cref="TempDir"/>
|
/// The path to the patcher.exe file in the <see cref="TempDir"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,11 +77,22 @@ namespace PatcherUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void StartZipProcess(string SourcePath, string DestinationPath)
|
||||||
|
{
|
||||||
|
ProcessStartInfo procInfo = new ProcessStartInfo()
|
||||||
|
{
|
||||||
|
FileName = SevenZExePath,
|
||||||
|
Arguments = $"a {DestinationPath} {SourcePath}"
|
||||||
|
};
|
||||||
|
|
||||||
|
Process.Start(procInfo);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the <see cref="TempDir"/> recursively
|
/// Deletes the <see cref="TempDir"/> recursively
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <Returns>Returns true if the temp directory was deleted.</Returns>
|
/// <Returns>Returns true if the temp directory was deleted.</Returns>
|
||||||
public static bool CleanupTempDir()
|
public static void CleanupTempDir()
|
||||||
{
|
{
|
||||||
DirectoryInfo dir = new DirectoryInfo(TempDir);
|
DirectoryInfo dir = new DirectoryInfo(TempDir);
|
||||||
|
|
||||||
@ -81,15 +100,6 @@ namespace PatcherUtils
|
|||||||
{
|
{
|
||||||
dir.Delete(true);
|
dir.Delete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
dir.Refresh();
|
|
||||||
|
|
||||||
if(dir.Exists)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,16 @@
|
|||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Resources\7za.exe" />
|
||||||
|
<None Remove="Resources\PatchClient.exe" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\7za.exe" />
|
||||||
|
<EmbeddedResource Include="Resources\PatchClient.exe" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Aki.ByteBanger">
|
<Reference Include="Aki.ByteBanger">
|
||||||
<HintPath>..\PatchGenerator\References\Aki.ByteBanger.dll</HintPath>
|
<HintPath>..\PatchGenerator\References\Aki.ByteBanger.dll</HintPath>
|
||||||
|
BIN
Patcher/PatcherUtils/Resources/PatchClient.exe
Normal file
BIN
Patcher/PatcherUtils/Resources/PatchClient.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user