mirror of
https://github.com/sp-tarkov/patcher.git
synced 2025-02-13 02:10:47 -05:00
finished port, replace old project files
This commit is contained in:
parent
455125576a
commit
b936b09026
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1 +1,2 @@
|
|||||||
/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
|
/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
|
||||||
|
/Patcher/PatcherUtils/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
|
||||||
|
@ -1,156 +0,0 @@
|
|||||||
<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>
|
|
||||||
<!-- Colors -->
|
|
||||||
<Color x:Key="AKI_DarkGray">#121212</Color>
|
|
||||||
<Color x:Key="AKI_Yellow">#FFC107</Color>
|
|
||||||
<Color x:Key="AKI_White">#FFFFFF</Color>
|
|
||||||
<Color x:Key="AKI_Gray">#282828</Color>
|
|
||||||
<Color x:Key="AKI_DarkGrayBlue">#323947</Color>
|
|
||||||
|
|
||||||
<!-- Brushes -->
|
|
||||||
<SolidColorBrush x:Key="AKI_Foreground_Light" Color="{StaticResource AKI_White}"/>
|
|
||||||
<SolidColorBrush x:Key="AKI_Background_Light" Color="{StaticResource AKI_Gray}"/>
|
|
||||||
<SolidColorBrush x:Key="AKI_Background_Dark" Color="{StaticResource AKI_DarkGray}"/>
|
|
||||||
<SolidColorBrush x:Key="AKI_Background_Yellow" Color="{StaticResource AKI_Yellow}"/>
|
|
||||||
<SolidColorBrush x:Key="AKI_Background_DarkGrayBlue" Color="{StaticResource AKI_DarkGrayBlue}"/>
|
|
||||||
|
|
||||||
<!-- Remove Hightlight effect from buttons -->
|
|
||||||
<Style x:Key="NoChromeButton" TargetType="{x:Type Button}">
|
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
|
||||||
<Setter Property="BorderThickness" Value="1"/>
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
|
||||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
|
||||||
<Setter Property="Padding" Value="1"/>
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="{x:Type Button}">
|
|
||||||
<Grid x:Name="NoChromeGrid" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
|
|
||||||
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
|
||||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
<ControlTemplate.Triggers>
|
|
||||||
<Trigger Property="IsEnabled" Value="false">
|
|
||||||
<Trigger.EnterActions>
|
|
||||||
<BeginStoryboard x:Name="disable_enter">
|
|
||||||
<Storyboard>
|
|
||||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.100" BeginTime="0:0:0.100"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</Trigger.EnterActions>
|
|
||||||
<Trigger.ExitActions>
|
|
||||||
<RemoveStoryboard BeginStoryboardName="disable_enter"/>
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.100"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</Trigger.ExitActions>
|
|
||||||
</Trigger>
|
|
||||||
</ControlTemplate.Triggers>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- App Button Base Style -->
|
|
||||||
<Style x:Key="AppButtonStyleBase" TargetType="{x:Type Button}" BasedOn="{StaticResource NoChromeButton}">
|
|
||||||
<Setter Property="Foreground" Value="Gray"/>
|
|
||||||
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
|
||||||
<Setter Property="BorderThickness" Value="0"/>
|
|
||||||
<Setter Property="MinWidth" Value="40"/>
|
|
||||||
<Setter Property="MinHeight" Value="25"/>
|
|
||||||
<Setter Property="FontSize" Value="12"/>
|
|
||||||
<Setter Property="FontWeight" Value="Bold"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Close App Button Style -->
|
|
||||||
<Style x:Key="AppCloseButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource AppButtonStyleBase}">
|
|
||||||
<Style.Triggers>
|
|
||||||
<EventTrigger RoutedEvent="PreviewMouseDown">
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)" To="{StaticResource AKI_DarkGrayBlue}" Duration="0:0:0.200"/>
|
|
||||||
<ColorAnimation Storyboard.TargetProperty="(Button.Foreground).(SolidColorBrush.Color)" To="White" Duration="0:0:0.200"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</EventTrigger>
|
|
||||||
<EventTrigger RoutedEvent="MouseEnter">
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)" To="IndianRed" Duration="0:0:0.200"/>
|
|
||||||
<ColorAnimation Storyboard.TargetProperty="(Button.Foreground).(SolidColorBrush.Color)" To="White" Duration="0:0:0.200"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</EventTrigger>
|
|
||||||
<EventTrigger RoutedEvent="MouseLeave">
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)" To="{StaticResource AKI_DarkGray}" Duration="0:0:0.200"/>
|
|
||||||
<ColorAnimation Storyboard.TargetProperty="(Button.Foreground).(SolidColorBrush.Color)" To="Gray" Duration="0:0:0.200"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</EventTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- TextBlock Style -->
|
|
||||||
<Style TargetType="{x:Type TextBlock}">
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
|
|
||||||
<Setter Property="Opacity" Value="0"/>
|
|
||||||
<Style.Triggers>
|
|
||||||
<EventTrigger RoutedEvent="Loaded">
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.250" BeginTime="0:0:0.150"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</EventTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Label Style-->
|
|
||||||
<Style TargetType="{x:Type Label}">
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
|
|
||||||
<Setter Property="Opacity" Value="0"/>
|
|
||||||
<Style.Triggers>
|
|
||||||
<EventTrigger RoutedEvent="Loaded">
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.250" BeginTime="0:0:0.150"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</EventTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Progressbar Style -->
|
|
||||||
<Style TargetType="{x:Type ProgressBar}">
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource AKI_Background_Yellow}"/>
|
|
||||||
<Setter Property="Background" Value="{StaticResource AKI_Background_DarkGrayBlue}"/>
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource AKI_Background_DarkGrayBlue}"/>
|
|
||||||
<Setter Property="BorderThickness" Value="0"/>
|
|
||||||
<Setter Property="Opacity" Value="0"/>
|
|
||||||
<Style.Triggers>
|
|
||||||
<EventTrigger RoutedEvent="Loaded">
|
|
||||||
<BeginStoryboard>
|
|
||||||
<Storyboard>
|
|
||||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.250" BeginTime="0:0:0.150"/>
|
|
||||||
</Storyboard>
|
|
||||||
</BeginStoryboard>
|
|
||||||
</EventTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
</Application.Resources>
|
|
||||||
</Application>
|
|
||||||
|
|
||||||
<!--Foreground="{StaticResource AKI_Background_Yellow}"
|
|
||||||
Background="{StaticResource AKI_Background_DarkGrayBlue}"
|
|
||||||
BorderBrush="{StaticResource AKI_Background_DarkGrayBlue}"
|
|
||||||
BorderThickness="0"-->
|
|
@ -1,17 +0,0 @@
|
|||||||
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
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
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)
|
|
||||||
)]
|
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -18,7 +18,7 @@
|
|||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
/>
|
/>
|
||||||
<Button Content="X" Grid.Column="2"
|
<Button Content="" Grid.Column="2"
|
||||||
Foreground="{Binding XButtonForeground, RelativeSource={
|
Foreground="{Binding XButtonForeground, RelativeSource={
|
||||||
RelativeSource AncestorType=UserControl}}"
|
RelativeSource AncestorType=UserControl}}"
|
||||||
Command="{Binding XButtonCommand, RelativeSource={
|
Command="{Binding XButtonCommand, RelativeSource={
|
||||||
@ -26,6 +26,7 @@
|
|||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
|
FontFamily="Segoe MDL2 Assets"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
CornerRadius="0"
|
CornerRadius="0"
|
||||||
Width="35"
|
Width="35"
|
@ -1,49 +0,0 @@
|
|||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Shell;
|
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<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"
|
|
||||||
Background="{StaticResource AKI_Background_Light}"
|
|
||||||
Loaded="Window_Loaded"
|
|
||||||
WindowStyle="SingleBorderWindow">
|
|
||||||
<WindowChrome.WindowChrome>
|
|
||||||
<WindowChrome CaptionHeight="0" CornerRadius="0" GlassFrameThickness="0 0 0 5" UseAeroCaptionButtons="False"
|
|
||||||
ResizeBorderThickness="5"
|
|
||||||
/>
|
|
||||||
</WindowChrome.WindowChrome>
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="AUTO"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="AUTO"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Label Content="Patching Client"
|
|
||||||
FontSize="15" Background="{StaticResource AKI_Background_Dark}"
|
|
||||||
MouseDown="label_topbar_MouseDown"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button x:Name="Close_Button" Grid.Column="1" Content="X" HorizontalAlignment="Right" VerticalAlignment="Stretch"
|
|
||||||
Style="{StaticResource AppCloseButtonStyle}"
|
|
||||||
Click="Close_Button_Click"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<StackPanel Grid.ColumnSpan="2" Grid.Row="1">
|
|
||||||
<Label x:Name="PatchMessageLabel"
|
|
||||||
Margin="10"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ContentControl Margin="10 0 10 10">
|
|
||||||
<Grid>
|
|
||||||
<ProgressBar x:Name="PatchProgressBar"
|
|
||||||
Height="20"
|
|
||||||
/>
|
|
||||||
<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>
|
|
@ -1,90 +0,0 @@
|
|||||||
using PatchClient.Extensions;
|
|
||||||
using PatcherUtils;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace PatchClient
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for MainWindow.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class MainWindow : Window
|
|
||||||
{
|
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RunPatcher()
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
PatchHelper patcher = new PatchHelper(Environment.CurrentDirectory, null, LazyOperations.PatchFolder.FromCwd());
|
|
||||||
|
|
||||||
patcher.ProgressChanged += patcher_ProgressChanged;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LazyOperations.CleanupTempDir();
|
|
||||||
LazyOperations.PrepTempDir();
|
|
||||||
|
|
||||||
string message = patcher.ApplyPatches();
|
|
||||||
|
|
||||||
MessageBox.Show(message, "Patcher");
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
|
||||||
{
|
|
||||||
Application.Current.Shutdown(0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void patcher_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();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Close_Button_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Application.Current.Shutdown(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void label_topbar_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.ChangedButton == MouseButton.Left)
|
|
||||||
{
|
|
||||||
this.DragMove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<UseWPF>true</UseWPF>
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<AvaloniaResource Include="Assets\**" />
|
||||||
|
<AvaloniaResource Remove="Assets\Styles.axaml" />
|
||||||
|
<None Remove=".gitignore" />
|
||||||
<None Remove="Resources\xdelta3.exe" />
|
<None Remove="Resources\xdelta3.exe" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\xdelta3.exe" />
|
<EmbeddedResource Include="Resources\xdelta3.exe" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -18,4 +19,17 @@
|
|||||||
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="0.10.11" />
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="0.10.11" />
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.11" />
|
||||||
|
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AvaloniaXaml Update="Assets\Styles.axaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</AvaloniaXaml>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"PatchClient": {
|
"PatchClient": {
|
||||||
"commandName": "Project"
|
"commandName": "Project",
|
||||||
|
"hotReloadEnabled": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,6 +48,10 @@ namespace PatchClient.ViewModels
|
|||||||
{
|
{
|
||||||
Task.Run(() =>
|
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
|
||||||
|
//Error without delay: An item with the same key has already been added. Key: [1, Avalonia.Controls.Generators.ItemContainerInfo]
|
||||||
|
System.Threading.Thread.Sleep(1000);
|
||||||
|
|
||||||
PatchHelper patcher = new PatchHelper(Environment.CurrentDirectory, null, LazyOperations.PatchFolder);
|
PatchHelper patcher = new PatchHelper(Environment.CurrentDirectory, null, LazyOperations.PatchFolder);
|
||||||
|
|
||||||
patcher.ProgressChanged += patcher_ProgressChanged;
|
patcher.ProgressChanged += patcher_ProgressChanged;
|
@ -1,7 +1,8 @@
|
|||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="using:PatchGenerator"
|
xmlns:local="using:PatchGenerator"
|
||||||
x:Class="PatchGenerator.App">
|
x:Class="PatchGenerator.App"
|
||||||
|
>
|
||||||
<Application.DataTemplates>
|
<Application.DataTemplates>
|
||||||
<local:ViewLocator/>
|
<local:ViewLocator/>
|
||||||
</Application.DataTemplates>
|
</Application.DataTemplates>
|
@ -1,6 +1,7 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using PatchGenerator.Models;
|
||||||
using PatchGenerator.ViewModels;
|
using PatchGenerator.ViewModels;
|
||||||
using PatchGenerator.Views;
|
using PatchGenerator.Views;
|
||||||
|
|
||||||
@ -17,13 +18,23 @@ namespace PatchGenerator
|
|||||||
{
|
{
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow = new MainWindow
|
desktop.Startup += Desktop_Startup;
|
||||||
{
|
|
||||||
DataContext = new MainWindowViewModel(),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Desktop_Startup(object? sender, ControlledApplicationLifetimeStartupEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
GenStartupArgs genArgs = GenStartupArgs.Parse(e.Args);
|
||||||
|
|
||||||
|
desktop.MainWindow = new MainWindow
|
||||||
|
{
|
||||||
|
DataContext = new MainWindowViewModel(genArgs)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +0,0 @@
|
|||||||
<Application x:Class="PatchGenerator.App"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:local="clr-namespace:PatchGenerator"
|
|
||||||
StartupUri="MainWindow.xaml"
|
|
||||||
Startup="Application_Startup">
|
|
||||||
<Application.Resources>
|
|
||||||
|
|
||||||
</Application.Resources>
|
|
||||||
</Application>
|
|
@ -1,40 +0,0 @@
|
|||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace PatchGenerator
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for App.xaml
|
|
||||||
/// </summary>
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
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)
|
|
||||||
)]
|
|
@ -12,7 +12,7 @@
|
|||||||
<ProgressBar Value="40"/>
|
<ProgressBar Value="40"/>
|
||||||
<Separator Height="1"/>
|
<Separator Height="1"/>
|
||||||
<ProgressBar Value="60" Classes="done"/>
|
<ProgressBar Value="60" Classes="done"/>
|
||||||
<Button Content="Press Me :)"/>
|
<Button Content="Press Me :)" IsEnabled="True"/>
|
||||||
<CheckBox Content="Check .. Me Out! ba-dum-tss"/>
|
<CheckBox Content="Check .. Me Out! ba-dum-tss"/>
|
||||||
<TextBox Text="Some Text Here" />
|
<TextBox Text="Some Text Here" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@ -119,6 +119,11 @@
|
|||||||
<Setter Property="Background" Value="{StaticResource AKI_Brush_Yellow}"/>
|
<Setter Property="Background" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Button:disabled /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
<!-- Checkbox styles -->
|
<!-- Checkbox styles -->
|
||||||
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml -->
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml -->
|
||||||
<Style Selector="CheckBox:checked">
|
<Style Selector="CheckBox:checked">
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -18,7 +18,7 @@
|
|||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
/>
|
/>
|
||||||
<Button Content="X" Grid.Column="2"
|
<Button Content="" Grid.Column="2"
|
||||||
Foreground="{Binding XButtonForeground, RelativeSource={
|
Foreground="{Binding XButtonForeground, RelativeSource={
|
||||||
RelativeSource AncestorType=UserControl}}"
|
RelativeSource AncestorType=UserControl}}"
|
||||||
Command="{Binding XButtonCommand, RelativeSource={
|
Command="{Binding XButtonCommand, RelativeSource={
|
||||||
@ -27,6 +27,7 @@
|
|||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
FontFamily="Segoe MDL2 Assets"
|
||||||
CornerRadius="0"
|
CornerRadius="0"
|
||||||
Width="35"
|
Width="35"
|
||||||
>
|
>
|
@ -1,48 +0,0 @@
|
|||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
<Window x:Class="PatchGenerator.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:PatchGenerator"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Title="Patch Generator" Height="450" Width="800"
|
|
||||||
WindowStartupLocation="CenterScreen">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="AUTO"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="AUTO"/>
|
|
||||||
<RowDefinition Height="AUTO"/>
|
|
||||||
<RowDefinition Height="200"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="AUTO"/>
|
|
||||||
</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"
|
|
||||||
Grid.Row="1" Grid.ColumnSpan="2"
|
|
||||||
Height="20" Margin="10 5 10 10"
|
|
||||||
Foreground="MediumPurple"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Label x:Name="GenProgressMessageLabel"
|
|
||||||
FontSize="15" FontWeight="SemiBold"
|
|
||||||
Grid.Row="1" Grid.ColumnSpan="2" Margin="0 0 10 5"
|
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Label x:Name="GenProgressInfoLabel"
|
|
||||||
FontSize="15" FontWeight="SemiBold"
|
|
||||||
Grid.Row="1" Grid.ColumnSpan="2" Margin="10 0 0 5"
|
|
||||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Label x:Name="CompareLabel"
|
|
||||||
Grid.Row="2" Margin="10 10 5 10"
|
|
||||||
Drop="CompareLabel_Drop"
|
|
||||||
AllowDrop="True"
|
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
|
|
||||||
Content="Drag and drop COMPARE folder here"
|
|
||||||
BorderBrush="Gainsboro" BorderThickness="2"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Label x:Name="TargetLabel"
|
|
||||||
Grid.Column="1" Grid.Row="2" Margin="5 10 10 10"
|
|
||||||
Drop="TargetLabel_Drop"
|
|
||||||
AllowDrop="True"
|
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
|
|
||||||
Content="Drag and drop TARGET folder here"
|
|
||||||
BorderBrush="Gainsboro" BorderThickness="2"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextBlock x:Name="AdditionalInfoBlock"
|
|
||||||
Grid.Row="3" Grid.RowSpan="2" Margin="10"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
TextWrapping="Wrap"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button x:Name="GenButton"
|
|
||||||
Grid.Column="1" Grid.Row="4"
|
|
||||||
MinHeight="40" Margin="10"
|
|
||||||
Content="Generate Patches"
|
|
||||||
Click="GenButton_Click"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CheckBox x:Name="AutoZip_checkBox" Grid.Row="3" Grid.Column="1" VerticalAlignment="Bottom"
|
|
||||||
Margin="10"
|
|
||||||
ToolTip="This will compress the patch files after they are generated using 7z format."
|
|
||||||
Content="Auto Zip After Patches are Generated"
|
|
||||||
IsChecked="{Binding Path=AutoZip,
|
|
||||||
RelativeSource={
|
|
||||||
RelativeSource AncestorType=Window,
|
|
||||||
Mode=FindAncestor}}"
|
|
||||||
/>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
@ -1,253 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using PatcherUtils;
|
|
||||||
using PatchGenerator.Extensions;
|
|
||||||
|
|
||||||
namespace PatchGenerator
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for MainWindow.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class MainWindow : Window
|
|
||||||
{
|
|
||||||
private string compareFolder = "";
|
|
||||||
private string targetFolder = "";
|
|
||||||
private string outputFolderName = "";
|
|
||||||
public bool AutoZip { get; set; } = true;
|
|
||||||
|
|
||||||
private Stopwatch stopwatch = new Stopwatch();
|
|
||||||
|
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
return $"Hours: {stopwatch.Elapsed.Hours} - Mins: {stopwatch.Elapsed.Minutes} - Secs: {stopwatch.Elapsed.Seconds} - MilliSecs: {stopwatch.Elapsed.Milliseconds}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool FileDropCheck(DragEventArgs args, ref string str)
|
|
||||||
{
|
|
||||||
if (!args.Data.GetDataPresent(DataFormats.FileDrop))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] paths = (string[])args.Data.GetData(DataFormats.FileDrop);
|
|
||||||
|
|
||||||
if (paths.Length != 1) return false;
|
|
||||||
|
|
||||||
if (!Directory.Exists(paths[0]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
str = paths[0];
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CompareLabel_Drop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (FileDropCheck(e, ref compareFolder))
|
|
||||||
{
|
|
||||||
CompareLabel.Content = $"Compare Folder:\n{compareFolder}";
|
|
||||||
CompareLabel.BorderBrush = Brushes.DarkCyan;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Dropped File/s could not be used. Make sure you only drop one folder.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TargetLabel_Drop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if(FileDropCheck(e, ref targetFolder))
|
|
||||||
{
|
|
||||||
TargetLabel.Content = $"Target Folder:\n{targetFolder}";
|
|
||||||
TargetLabel.BorderBrush = Brushes.DarkCyan;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Dropped File/s could not be used. Make sure you only drop one folder.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GeneratePatches(string patchBase)
|
|
||||||
{
|
|
||||||
//create temp data
|
|
||||||
GenProgressBar.DispatcherSetIndetermination(true);
|
|
||||||
GenProgressMessageLabel.DispaatcherSetContent("Extracting temp data ...");
|
|
||||||
|
|
||||||
LazyOperations.CleanupTempDir();
|
|
||||||
LazyOperations.PrepTempDir();
|
|
||||||
|
|
||||||
GenProgressBar.DispatcherSetIndetermination(false);
|
|
||||||
|
|
||||||
//generate patches
|
|
||||||
//TODO - fix these weird variable names (why did I do this?)
|
|
||||||
PatchHelper patcher = new PatchHelper(compareFolder, targetFolder, patchBase);
|
|
||||||
|
|
||||||
patcher.ProgressChanged += patcher_ProgressChanged;
|
|
||||||
|
|
||||||
if (!patcher.GeneratePatches())
|
|
||||||
{
|
|
||||||
MessageBox.Show("One of the provided folder paths doesn't exist.", "Oops :(", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Copy patch client to output folder
|
|
||||||
File.Copy(LazyOperations.PatcherClientPath, $"{outputFolderName}\\patcher.exe", true);
|
|
||||||
|
|
||||||
//compress patch output folder to 7z file
|
|
||||||
if (AutoZip)
|
|
||||||
{
|
|
||||||
LazyOperations.StartZipProcess(outputFolderName, $"{outputFolderName}.7z".FromCwd());
|
|
||||||
}
|
|
||||||
|
|
||||||
GenProgressBar.DispatcherSetValue(100);
|
|
||||||
GenProgressMessageLabel.DispaatcherSetContent("Done");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void patcher_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";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GenProgressBar.DispatcherSetValue(Percent);
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(Message))
|
|
||||||
{
|
|
||||||
GenProgressMessageLabel.DispaatcherSetContent(Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
GenProgressInfoLabel.DispaatcherSetContent($"[{Progress}/{Total}]");
|
|
||||||
|
|
||||||
AdditionalInfoBlock.DispatcherSetText(additionalInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GenButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
GenButton.IsEnabled = false;
|
|
||||||
CompareLabel.IsEnabled = false;
|
|
||||||
TargetLabel.IsEnabled = false;
|
|
||||||
FileNameBox.IsEnabled = false;
|
|
||||||
AutoZip_checkBox.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;
|
|
||||||
AutoZip_checkBox.IsEnabled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetEndingInfo(string info)
|
|
||||||
{
|
|
||||||
GenButton.DispatcherSetEnabled(true);
|
|
||||||
CompareLabel.DispatcherSetEnabled(true);
|
|
||||||
TargetLabel.DispatcherSetEnabled(true);
|
|
||||||
FileNameBox.DispatcherSetEnabled(true);
|
|
||||||
AutoZip_checkBox.DispatcherSetEnabled(true);
|
|
||||||
|
|
||||||
GenProgressMessageLabel.DispaatcherSetContent("");
|
|
||||||
GenProgressInfoLabel.DispaatcherSetContent(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
stopwatch.Reset();
|
|
||||||
stopwatch.Start();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GeneratePatches(Path.Combine(outputFolderName.FromCwd(), LazyOperations.PatchFolder));
|
|
||||||
stopwatch.Stop();
|
|
||||||
SetEndingInfo($"Patches Generated in: {GetStopWatchTime()}");
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
stopwatch.Stop();
|
|
||||||
SetEndingInfo(ex.Message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,9 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<UseWPF>true</UseWPF>
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -16,4 +16,21 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AvaloniaResource Include="Assets\**" />
|
||||||
|
<AvaloniaResource Remove="Assets\Styles.axaml" />
|
||||||
|
<None Remove=".gitignore" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="0.10.11" />
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="0.10.11" />
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.11" />
|
||||||
|
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="CustomControls\TitleBar.axaml.cs">
|
||||||
|
<DependentUpon>%(Filename)</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
9
Patcher/PatchGenerator/Properties/launchSettings.json
Normal file
9
Patcher/PatchGenerator/Properties/launchSettings.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"PatchGenerator": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "\"OutputFolderName::Patcher_12.3.4.5_to_6.7.8.9\" \"SourceFolderPath::C:\\Users\\JohnO\\Desktop\\12.12.10.16338\" \"TargetFolderPath::C:\\Users\\JohnO\\Desktop\\12.11.7.15680\" \"AutoZip::True\"",
|
||||||
|
"workingDirectory": "C:\\Users\\JohnO\\Desktop\\Patcher\\"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
@ -17,11 +17,24 @@ namespace PatchGenerator.ViewModels
|
|||||||
});
|
});
|
||||||
|
|
||||||
public ViewNavigator navigator { get; set; } = new ViewNavigator();
|
public ViewNavigator navigator { get; set; } = new ViewNavigator();
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel(GenStartupArgs genArgs = null)
|
||||||
{
|
{
|
||||||
navigator.SelectedViewModel = new OptionsViewModel();
|
|
||||||
|
|
||||||
Locator.CurrentMutable.RegisterConstant(navigator, typeof(ViewNavigator));
|
Locator.CurrentMutable.RegisterConstant(navigator, typeof(ViewNavigator));
|
||||||
|
|
||||||
|
if (genArgs != null && genArgs.ReadyToRun)
|
||||||
|
{
|
||||||
|
PatchGenInfo genInfo = new PatchGenInfo();
|
||||||
|
|
||||||
|
genInfo.TargetFolderPath = genArgs.TargetFolderPath;
|
||||||
|
genInfo.SourceFolderPath = genArgs.SourceFolderPath;
|
||||||
|
genInfo.PatchName = genArgs.OutputFolderName;
|
||||||
|
genInfo.AutoZip = genArgs.AutoZip;
|
||||||
|
|
||||||
|
navigator.SelectedViewModel = new PatchGenerationViewModel(genInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
navigator.SelectedViewModel = new OptionsViewModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,14 +9,8 @@ namespace PatchGenerator.ViewModels
|
|||||||
|
|
||||||
private ViewNavigator navigator => Locator.Current.GetService<ViewNavigator>();
|
private ViewNavigator navigator => Locator.Current.GetService<ViewNavigator>();
|
||||||
|
|
||||||
public OptionsViewModel(GenStartupArgs genArgs = null)
|
public OptionsViewModel()
|
||||||
{
|
{
|
||||||
if (genArgs != null)
|
|
||||||
{
|
|
||||||
//TODO - parse/check startup args and start patching
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerationInfo.SourceFolderPath = "Drop SOURCE folder here";
|
GenerationInfo.SourceFolderPath = "Drop SOURCE folder here";
|
||||||
GenerationInfo.TargetFolderPath = "Drop TARGET folder here";
|
GenerationInfo.TargetFolderPath = "Drop TARGET folder here";
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using Avalonia.Media;
|
using Avalonia;
|
||||||
|
using Avalonia.Media;
|
||||||
using PatcherUtils;
|
using PatcherUtils;
|
||||||
using PatchGenerator.Helpers;
|
using PatchGenerator.Helpers;
|
||||||
using PatchGenerator.Models;
|
using PatchGenerator.Models;
|
||||||
@ -62,11 +63,12 @@ namespace PatchGenerator.ViewModels
|
|||||||
Task.Run(() =>
|
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
|
//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);
|
//Error without delay: An item with the same key has already been added. Key: [1, Avalonia.Controls.Generators.ItemContainerInfo]
|
||||||
|
System.Threading.Thread.Sleep(1000);
|
||||||
|
|
||||||
string outputFolder = Path.Join(LazyOperations.PatchFolder, generationInfo.PatchName);
|
string patchOutputFolder = Path.Join(generationInfo.PatchName.FromCwd(), LazyOperations.PatchFolder);
|
||||||
|
|
||||||
PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, outputFolder);
|
PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, patchOutputFolder);
|
||||||
|
|
||||||
patcher.ProgressChanged += Patcher_ProgressChanged;
|
patcher.ProgressChanged += Patcher_ProgressChanged;
|
||||||
|
|
||||||
@ -84,10 +86,11 @@ namespace PatchGenerator.ViewModels
|
|||||||
|
|
||||||
ProgressMessage = sb.ToString();
|
ProgressMessage = sb.ToString();
|
||||||
|
|
||||||
//TODO - need to fix this. Wrong folder, and need to copy client to output
|
File.Copy(LazyOperations.PatcherClientPath, $"{generationInfo.PatchName.FromCwd()}\\patcher.exe", true);
|
||||||
|
|
||||||
if (generationInfo.AutoZip)
|
if (generationInfo.AutoZip)
|
||||||
{
|
{
|
||||||
LazyOperations.StartZipProcess(outputFolder, $"{outputFolder}.zip");
|
LazyOperations.StartZipProcess(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.zip".FromCwd());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,6 +102,30 @@ namespace PatchGenerator.ViewModels
|
|||||||
PatchPercent = Percent;
|
PatchPercent = Percent;
|
||||||
|
|
||||||
PatchItemCollection.Add(new PatchItem(Message));
|
PatchItemCollection.Add(new PatchItem(Message));
|
||||||
|
|
||||||
|
if(Percent == 100)
|
||||||
|
{
|
||||||
|
if (Application.Current.Resources.TryGetResource("AKI_Brush_Yellow", out var color))
|
||||||
|
{
|
||||||
|
if (color is IBrush brush)
|
||||||
|
{
|
||||||
|
PatchItemCollection.Add(new PatchItem("")
|
||||||
|
{
|
||||||
|
Name = new StringBuilder().AppendLine("Summary").AppendLine("----------").ToString(),
|
||||||
|
Color = brush
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (LineItem item in AdditionalLineItems)
|
||||||
|
{
|
||||||
|
PatchItemCollection.Add(new PatchItem("")
|
||||||
|
{
|
||||||
|
Name = $"{item.ItemText}: {item.ItemValue}",
|
||||||
|
Color = brush
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.31515.178
|
VisualStudioVersion = 16.0.31727.386
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatchGenerator", "PatchGenerator\PatchGenerator.csproj", "{DDB70566-994E-4884-8555-C005B238039B}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchClient", "PatchClient\PatchClient.csproj", "{1C297369-03CA-4CA8-A651-22568A1CA310}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PatcherUtils", "PatcherUtils\PatcherUtils.csproj", "{A9819B34-8111-4344-B2B3-3DE5D7A43A45}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchGenerator", "PatchGenerator\PatchGenerator.csproj", "{0E0664C4-E698-41E4-919F-892D627739EA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchClient", "PatchClient\PatchClient.csproj", "{9CA4D2BD-6596-41D1-8354-135868DF8DAB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatcherUtils", "PatcherUtils\PatcherUtils.csproj", "{C84233F8-6630-4322-9FB6-0A957F39CDA7}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -15,23 +15,23 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{DDB70566-994E-4884-8555-C005B238039B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{1C297369-03CA-4CA8-A651-22568A1CA310}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{DDB70566-994E-4884-8555-C005B238039B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1C297369-03CA-4CA8-A651-22568A1CA310}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DDB70566-994E-4884-8555-C005B238039B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1C297369-03CA-4CA8-A651-22568A1CA310}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DDB70566-994E-4884-8555-C005B238039B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1C297369-03CA-4CA8-A651-22568A1CA310}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0E0664C4-E698-41E4-919F-892D627739EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0E0664C4-E698-41E4-919F-892D627739EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0E0664C4-E698-41E4-919F-892D627739EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0E0664C4-E698-41E4-919F-892D627739EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {A9AA1062-33C6-49F2-880C-067D44041C4A}
|
SolutionGuid = {07AD7FB8-3529-4A2A-BDD5-76F779273B9B}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
public class LineItem
|
public class LineItem
|
||||||
{
|
{
|
||||||
public string ItemText;
|
public string ItemText;
|
||||||
public string ItemValue;
|
public int ItemValue;
|
||||||
public bool HasValue => ItemValue != "";
|
|
||||||
|
|
||||||
public LineItem(string ItemText, string ItemValue = "")
|
public LineItem(string ItemText, int ItemValue = 0)
|
||||||
{
|
{
|
||||||
this.ItemText = ItemText;
|
this.ItemText = ItemText;
|
||||||
this.ItemValue = ItemValue;
|
this.ItemValue = ItemValue;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
using Aki.Common.Utils;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace PatcherUtils
|
namespace PatcherUtils
|
||||||
{
|
{
|
||||||
@ -20,9 +19,14 @@ namespace PatcherUtils
|
|||||||
private int deltaCount;
|
private int deltaCount;
|
||||||
private int newCount;
|
private int newCount;
|
||||||
private int delCount;
|
private int delCount;
|
||||||
|
private int existCount;
|
||||||
|
|
||||||
private List<LineItem> AdditionalInfo = new List<LineItem>();
|
private List<LineItem> AdditionalInfo = new List<LineItem>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reports patch creation or application progress
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Includes an array of <see cref="LineItem"/> with details for each type of patch</remarks>
|
||||||
public event ProgressChangedHandler ProgressChanged;
|
public event ProgressChangedHandler ProgressChanged;
|
||||||
|
|
||||||
protected virtual void RaiseProgressChanged(int progress, int total, string Message = "", params LineItem[] AdditionalLineItems)
|
protected virtual void RaiseProgressChanged(int progress, int total, string Message = "", params LineItem[] AdditionalLineItems)
|
||||||
@ -32,6 +36,13 @@ namespace PatcherUtils
|
|||||||
ProgressChanged?.Invoke(this, progress, total, percent, Message, AdditionalLineItems);
|
ProgressChanged?.Invoke(this, progress, total, percent, Message, AdditionalLineItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A helper class to create and apply patches to folders
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SourceFolder">The directory that will have patches applied to it.</param>
|
||||||
|
/// <param name="TargetFolder">The directory to compare against during patch creation.</param>
|
||||||
|
/// <param name="DeltaFolder">The directory where the patches are/will be located.</param>
|
||||||
|
/// <remarks><paramref name="TargetFolder"/> can be null if you only plan to apply patches.</remarks>
|
||||||
public PatchHelper(string SourceFolder, string TargetFolder, string DeltaFolder)
|
public PatchHelper(string SourceFolder, string TargetFolder, string DeltaFolder)
|
||||||
{
|
{
|
||||||
this.SourceFolder = SourceFolder;
|
this.SourceFolder = SourceFolder;
|
||||||
@ -39,11 +50,42 @@ namespace PatcherUtils
|
|||||||
this.DeltaFolder = DeltaFolder;
|
this.DeltaFolder = DeltaFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetDeltaPath(string sourceFile, string sourceFolder, string extension)
|
/// <summary>
|
||||||
|
/// Get the delta folder file path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SourceFilePath"></param>
|
||||||
|
/// <param name="SourceFolderPath"></param>
|
||||||
|
/// <param name="FileExtension">The extension to append to the file</param>
|
||||||
|
/// <returns>A file path inside the delta folder</returns>
|
||||||
|
private string GetDeltaPath(string SourceFilePath, string SourceFolderPath, string FileExtension)
|
||||||
{
|
{
|
||||||
return Path.Join(DeltaFolder, $"{sourceFile.Replace(sourceFolder, "")}.{extension}");
|
return Path.Join(DeltaFolder, $"{SourceFilePath.Replace(SourceFolderPath, "")}.{FileExtension}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if two files have the same MD5 hash
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SourceFilePath"></param>
|
||||||
|
/// <param name="TargetFilePath"></param>
|
||||||
|
/// <returns>True if the hashes match</returns>
|
||||||
|
private bool CompareFileHashes(string SourceFilePath, string TargetFilePath)
|
||||||
|
{
|
||||||
|
using (MD5 md5Service = MD5.Create())
|
||||||
|
using (var sourceStream = File.OpenRead(SourceFilePath))
|
||||||
|
using (var targetStream = File.OpenRead(TargetFilePath))
|
||||||
|
{
|
||||||
|
byte[] sourceHash = md5Service.ComputeHash(sourceStream);
|
||||||
|
byte[] targetHash = md5Service.ComputeHash(targetStream);
|
||||||
|
|
||||||
|
return Enumerable.SequenceEqual(sourceHash, targetHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply a delta to a file using xdelta
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SourceFilePath"></param>
|
||||||
|
/// <param name="DeltaFilePath"></param>
|
||||||
private void ApplyDelta(string SourceFilePath, string DeltaFilePath)
|
private void ApplyDelta(string SourceFilePath, string DeltaFilePath)
|
||||||
{
|
{
|
||||||
string decodedPath = SourceFilePath + ".decoded";
|
string decodedPath = SourceFilePath + ".decoded";
|
||||||
@ -62,6 +104,12 @@ namespace PatcherUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a .delta file using xdelta
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SourceFilePath"></param>
|
||||||
|
/// <param name="TargetFilePath"></param>
|
||||||
|
/// <remarks>Used to patch an existing file with xdelta</remarks>
|
||||||
private void CreateDelta(string SourceFilePath, string TargetFilePath)
|
private void CreateDelta(string SourceFilePath, string TargetFilePath)
|
||||||
{
|
{
|
||||||
FileInfo sourceFileInfo = new FileInfo(SourceFilePath);
|
FileInfo sourceFileInfo = new FileInfo(SourceFilePath);
|
||||||
@ -81,6 +129,11 @@ namespace PatcherUtils
|
|||||||
.WaitForExit();
|
.WaitForExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a .del file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SourceFile"></param>
|
||||||
|
/// <remarks>Used to mark a file for deletion</remarks>
|
||||||
private void CreateDelFile(string SourceFile)
|
private void CreateDelFile(string SourceFile)
|
||||||
{
|
{
|
||||||
FileInfo sourceFileInfo = new FileInfo(SourceFile);
|
FileInfo sourceFileInfo = new FileInfo(SourceFile);
|
||||||
@ -92,6 +145,11 @@ namespace PatcherUtils
|
|||||||
File.Create(deltaPath);
|
File.Create(deltaPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a .new file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="TargetFile"></param>
|
||||||
|
/// <remarks>Used to mark a file that needs to be added</remarks>
|
||||||
private void CreateNewFile(string TargetFile)
|
private void CreateNewFile(string TargetFile)
|
||||||
{
|
{
|
||||||
FileInfo targetSourceInfo = new FileInfo(TargetFile);
|
FileInfo targetSourceInfo = new FileInfo(TargetFile);
|
||||||
@ -103,6 +161,11 @@ namespace PatcherUtils
|
|||||||
targetSourceInfo.CopyTo(deltaPath, true);
|
targetSourceInfo.CopyTo(deltaPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate a full set of patches using the source and target folders specified during contruction./>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks>Patches are created in the delta folder specified during contruction</remarks>
|
||||||
public bool GeneratePatches()
|
public bool GeneratePatches()
|
||||||
{
|
{
|
||||||
//get all directory information needed
|
//get all directory information needed
|
||||||
@ -117,14 +180,18 @@ namespace PatcherUtils
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LazyOperations.CleanupTempDir();
|
||||||
|
LazyOperations.PrepTempDir();
|
||||||
|
|
||||||
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
||||||
|
|
||||||
fileCountTotal = SourceFiles.Count;
|
fileCountTotal = SourceFiles.Count;
|
||||||
|
|
||||||
AdditionalInfo.Clear();
|
AdditionalInfo.Clear();
|
||||||
AdditionalInfo.Add(new LineItem("Delta Patch", "0"));
|
AdditionalInfo.Add(new LineItem("Delta Patch", 0));
|
||||||
AdditionalInfo.Add(new LineItem("New Patch", "0"));
|
AdditionalInfo.Add(new LineItem("New Patch", 0));
|
||||||
AdditionalInfo.Add(new LineItem("Del Patch", "0"));
|
AdditionalInfo.Add(new LineItem("Del Patch", 0));
|
||||||
|
AdditionalInfo.Add(new LineItem("File Exists", 0));
|
||||||
|
|
||||||
filesProcessed = 0;
|
filesProcessed = 0;
|
||||||
|
|
||||||
@ -143,23 +210,34 @@ namespace PatcherUtils
|
|||||||
newCount++;
|
newCount++;
|
||||||
filesProcessed++;
|
filesProcessed++;
|
||||||
|
|
||||||
RaiseProgressChanged(filesProcessed, fileCountTotal, targetFile.Name, AdditionalInfo.ToArray());
|
RaiseProgressChanged(filesProcessed, fileCountTotal, $"{targetFile.FullName.Replace(TargetFolder, "...")}.new", AdditionalInfo.ToArray());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if a matching source file was found, get the delta for it.
|
string extension = "";
|
||||||
|
|
||||||
|
//if a matching source file was found, check the file hashes and get the delta.
|
||||||
|
if (!CompareFileHashes(sourceFile.FullName, targetFile.FullName))
|
||||||
|
{
|
||||||
CreateDelta(sourceFile.FullName, targetFile.FullName);
|
CreateDelta(sourceFile.FullName, targetFile.FullName);
|
||||||
|
extension = ".delta";
|
||||||
|
deltaCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
existCount++;
|
||||||
|
}
|
||||||
|
|
||||||
SourceFiles.Remove(sourceFile);
|
SourceFiles.Remove(sourceFile);
|
||||||
|
|
||||||
deltaCount++;
|
|
||||||
filesProcessed++;
|
filesProcessed++;
|
||||||
|
|
||||||
AdditionalInfo[0].ItemValue = deltaCount.ToString();
|
AdditionalInfo[0].ItemValue = deltaCount;
|
||||||
AdditionalInfo[1].ItemValue = newCount.ToString();
|
AdditionalInfo[1].ItemValue = newCount;
|
||||||
|
AdditionalInfo[3].ItemValue = existCount;
|
||||||
|
|
||||||
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.
|
//Any remaining source files do not exist in the target folder and can be removed.
|
||||||
@ -174,15 +252,19 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
delCount++;
|
delCount++;
|
||||||
|
|
||||||
AdditionalInfo[2].ItemValue = delCount.ToString();
|
AdditionalInfo[2].ItemValue = delCount;
|
||||||
|
|
||||||
filesProcessed++;
|
filesProcessed++;
|
||||||
RaiseProgressChanged(filesProcessed, fileCountTotal, "", AdditionalInfo.ToArray());
|
RaiseProgressChanged(filesProcessed, fileCountTotal, $"{delFile.FullName.Replace(SourceFolder, "...")}.del", AdditionalInfo.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply a set of patches using the source and delta folders specified during construction.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public string ApplyPatches()
|
public string ApplyPatches()
|
||||||
{
|
{
|
||||||
//get needed directory information
|
//get needed directory information
|
||||||
@ -195,6 +277,9 @@ namespace PatcherUtils
|
|||||||
return "One of the supplied directories doesn't exist";
|
return "One of the supplied directories doesn't exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LazyOperations.CleanupTempDir();
|
||||||
|
LazyOperations.PrepTempDir();
|
||||||
|
|
||||||
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
||||||
|
|
||||||
List<FileInfo> deltaFiles = deltaDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
List<FileInfo> deltaFiles = deltaDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
||||||
@ -206,9 +291,9 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
AdditionalInfo = new List<LineItem>()
|
AdditionalInfo = new List<LineItem>()
|
||||||
{
|
{
|
||||||
new LineItem("Patches Remaining", deltaCount.ToString()),
|
new LineItem("Patches Remaining", deltaCount),
|
||||||
new LineItem("New Files to Add", newCount.ToString()),
|
new LineItem("New Files to Add", newCount),
|
||||||
new LineItem("Files to Delete", delCount.ToString())
|
new LineItem("Files to Delete", delCount)
|
||||||
};
|
};
|
||||||
|
|
||||||
filesProcessed = 0;
|
filesProcessed = 0;
|
||||||
@ -237,10 +322,15 @@ namespace PatcherUtils
|
|||||||
}
|
}
|
||||||
case ".new":
|
case ".new":
|
||||||
{
|
{
|
||||||
|
if (newCount == 2 || newCount == 1 || newCount == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//copy new file
|
//copy new file
|
||||||
string destination = Path.Join(sourceDir.FullName, deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".new", ""));
|
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--;
|
newCount--;
|
||||||
|
|
||||||
@ -259,9 +349,9 @@ namespace PatcherUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdditionalInfo[0].ItemValue = deltaCount.ToString();
|
AdditionalInfo[0].ItemValue = deltaCount;
|
||||||
AdditionalInfo[1].ItemValue = newCount.ToString();
|
AdditionalInfo[1].ItemValue = newCount;
|
||||||
AdditionalInfo[2].ItemValue = delCount.ToString();
|
AdditionalInfo[2].ItemValue = delCount;
|
||||||
|
|
||||||
++filesProcessed;
|
++filesProcessed;
|
||||||
RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray());
|
RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Binary file not shown.
@ -1,35 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<AvaloniaResource Include="Assets\**" />
|
|
||||||
<AvaloniaResource Remove="Assets\Styles.axaml" />
|
|
||||||
<None Remove=".gitignore" />
|
|
||||||
<None Remove="Resources\xdelta3.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Resources\xdelta3.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Avalonia" Version="0.10.11" />
|
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.11" />
|
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.11" />
|
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.11" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<AvaloniaXaml Update="Assets\Styles.axaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</AvaloniaXaml>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"profiles": {
|
|
||||||
"PatchClient": {
|
|
||||||
"commandName": "Project"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
@ -1,45 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PatcherUtils\PatcherUtils.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Aki.Common">
|
|
||||||
<HintPath>References\Aki.Common.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<AvaloniaResource Include="Assets\**" />
|
|
||||||
<AvaloniaResource Remove="Assets\Styles.axaml" />
|
|
||||||
<None Remove=".gitignore" />
|
|
||||||
<None Remove="Resources\7za.exe" />
|
|
||||||
<None Remove="Resources\PatchClient.exe" />
|
|
||||||
<None Remove="Resources\xdelta3.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Resources\7za.exe" />
|
|
||||||
<EmbeddedResource Include="Resources\PatchClient.exe" />
|
|
||||||
<EmbeddedResource Include="Resources\xdelta3.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Avalonia" Version="0.10.11" />
|
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.11" />
|
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.11" />
|
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.11" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="CustomControls\TitleBar.axaml.cs">
|
|
||||||
<DependentUpon>%(Filename)</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
Binary file not shown.
Binary file not shown.
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe
(Stored with Git LFS)
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 16
|
|
||||||
VisualStudioVersion = 16.0.31727.386
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchClient", "PatchClient\PatchClient.csproj", "{1C297369-03CA-4CA8-A651-22568A1CA310}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchGenerator", "PatchGenerator\PatchGenerator.csproj", "{0E0664C4-E698-41E4-919F-892D627739EA}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatcherUtils", "PatcherUtils\PatcherUtils.csproj", "{C84233F8-6630-4322-9FB6-0A957F39CDA7}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{1C297369-03CA-4CA8-A651-22568A1CA310}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1C297369-03CA-4CA8-A651-22568A1CA310}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1C297369-03CA-4CA8-A651-22568A1CA310}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1C297369-03CA-4CA8-A651-22568A1CA310}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{0E0664C4-E698-41E4-919F-892D627739EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0E0664C4-E698-41E4-919F-892D627739EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0E0664C4-E698-41E4-919F-892D627739EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0E0664C4-E698-41E4-919F-892D627739EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C84233F8-6630-4322-9FB6-0A957F39CDA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {07AD7FB8-3529-4A2A-BDD5-76F779273B9B}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,116 +0,0 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace PatcherUtils
|
|
||||||
{
|
|
||||||
public class LazyOperations
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A directory to store temporary data.
|
|
||||||
/// </summary>
|
|
||||||
public static string TempDir = "PATCHER_TEMP".FromCwd();
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The folder that the patches will be stored in
|
|
||||||
/// </summary>
|
|
||||||
public static string PatchFolder = "Aki_Patches";
|
|
||||||
|
|
||||||
private static string SevenZExe = "7za.exe";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The path to the 7za.exe file in the <see cref="TempDir"/>
|
|
||||||
/// </summary>
|
|
||||||
public static string SevenZExePath = $"{TempDir}\\{SevenZExe}";
|
|
||||||
|
|
||||||
private static string PatcherClient = "PatchClient.exe";
|
|
||||||
/// <summary>
|
|
||||||
/// The path to the patcher.exe file in the <see cref="TempDir"/>
|
|
||||||
/// </summary>
|
|
||||||
public static string PatcherClientPath = $"{TempDir}\\{PatcherClient}";
|
|
||||||
|
|
||||||
private static string XDelta3EXE = "xdelta3.exe";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The path to the xdelta3.exe flie in the <see cref="TempDir"/>
|
|
||||||
/// </summary>
|
|
||||||
public static string XDelta3Path = $"{TempDir}\\{XDelta3EXE}";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Streams embedded resources out of the assembly
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ResourceName"></param>
|
|
||||||
/// <param name="OutputFilePath"></param>
|
|
||||||
/// <remarks>The resource will not be streamed out if the <paramref name="OutputFilePath"/> already exists</remarks>
|
|
||||||
private static void StreamResourceOut(string ResourceName, string OutputFilePath)
|
|
||||||
{
|
|
||||||
FileInfo outputFile = new FileInfo(OutputFilePath);
|
|
||||||
|
|
||||||
if (outputFile.Exists) return;
|
|
||||||
|
|
||||||
if (!outputFile.Directory.Exists)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(outputFile.Directory.FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (FileStream fs = File.Create(OutputFilePath))
|
|
||||||
using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName))
|
|
||||||
{
|
|
||||||
s.CopyTo(fs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks the resources in the assembly and streams them to the temp directory for later use.
|
|
||||||
/// </summary>
|
|
||||||
public static void PrepTempDir()
|
|
||||||
{
|
|
||||||
foreach (string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames())
|
|
||||||
{
|
|
||||||
switch (resource)
|
|
||||||
{
|
|
||||||
case string a when a.EndsWith(SevenZExe):
|
|
||||||
{
|
|
||||||
StreamResourceOut(resource, SevenZExePath);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case string a when a.EndsWith(PatcherClient):
|
|
||||||
{
|
|
||||||
StreamResourceOut(resource, PatcherClientPath);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case string a when a.EndsWith(XDelta3EXE):
|
|
||||||
{
|
|
||||||
StreamResourceOut(resource, XDelta3Path);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void StartZipProcess(string SourcePath, string DestinationPath)
|
|
||||||
{
|
|
||||||
ProcessStartInfo procInfo = new ProcessStartInfo()
|
|
||||||
{
|
|
||||||
FileName = SevenZExePath,
|
|
||||||
Arguments = $"a {DestinationPath} {SourcePath}"
|
|
||||||
};
|
|
||||||
|
|
||||||
Process.Start(procInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deletes the <see cref="TempDir"/> recursively
|
|
||||||
/// </summary>
|
|
||||||
public static void CleanupTempDir()
|
|
||||||
{
|
|
||||||
DirectoryInfo dir = new DirectoryInfo(TempDir);
|
|
||||||
|
|
||||||
if (dir.Exists)
|
|
||||||
{
|
|
||||||
dir.Delete(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
namespace PatcherUtils
|
|
||||||
{
|
|
||||||
public class LineItem
|
|
||||||
{
|
|
||||||
public string ItemText;
|
|
||||||
public int ItemValue;
|
|
||||||
|
|
||||||
public LineItem(string ItemText, int ItemValue = 0)
|
|
||||||
{
|
|
||||||
this.ItemText = ItemText;
|
|
||||||
this.ItemValue = ItemValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,360 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
|
|
||||||
namespace PatcherUtils
|
|
||||||
{
|
|
||||||
public class PatchHelper
|
|
||||||
{
|
|
||||||
private string SourceFolder = "";
|
|
||||||
private string TargetFolder = "";
|
|
||||||
private string DeltaFolder = "";
|
|
||||||
|
|
||||||
private int fileCountTotal;
|
|
||||||
private int filesProcessed;
|
|
||||||
|
|
||||||
private int deltaCount;
|
|
||||||
private int newCount;
|
|
||||||
private int delCount;
|
|
||||||
|
|
||||||
private List<LineItem> AdditionalInfo = new List<LineItem>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reports patch creation or application progress
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Includes an array of <see cref="LineItem"/> with details for each type of patch</remarks>
|
|
||||||
public event ProgressChangedHandler ProgressChanged;
|
|
||||||
|
|
||||||
protected virtual void RaiseProgressChanged(int progress, int total, string Message = "", params LineItem[] AdditionalLineItems)
|
|
||||||
{
|
|
||||||
int percent = (int)Math.Floor((double)progress / total * 100);
|
|
||||||
|
|
||||||
ProgressChanged?.Invoke(this, progress, total, percent, Message, AdditionalLineItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A helper class to create and apply patches to folders
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="SourceFolder">The directory that will have patches applied to it.</param>
|
|
||||||
/// <param name="TargetFolder">The directory to compare against during patch creation.</param>
|
|
||||||
/// <param name="DeltaFolder">The directory where the patches are/will be located.</param>
|
|
||||||
/// <remarks><paramref name="TargetFolder"/> can be null if you only plan to apply patches.</remarks>
|
|
||||||
public PatchHelper(string SourceFolder, string TargetFolder, string DeltaFolder)
|
|
||||||
{
|
|
||||||
this.SourceFolder = SourceFolder;
|
|
||||||
this.TargetFolder = TargetFolder;
|
|
||||||
this.DeltaFolder = DeltaFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the delta folder file path.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="SourceFilePath"></param>
|
|
||||||
/// <param name="SourceFolderPath"></param>
|
|
||||||
/// <param name="FileExtension">The extension to append to the file</param>
|
|
||||||
/// <returns>A file path inside the delta folder</returns>
|
|
||||||
private string GetDeltaPath(string SourceFilePath, string SourceFolderPath, string FileExtension)
|
|
||||||
{
|
|
||||||
return Path.Join(DeltaFolder, $"{SourceFilePath.Replace(SourceFolderPath, "")}.{FileExtension}");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if two files have the same MD5 hash
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="SourceFilePath"></param>
|
|
||||||
/// <param name="TargetFilePath"></param>
|
|
||||||
/// <returns>True if the hashes match</returns>
|
|
||||||
private bool CompareFileHashes(string SourceFilePath, string TargetFilePath)
|
|
||||||
{
|
|
||||||
using (MD5 md5Service = MD5.Create())
|
|
||||||
using (var sourceStream = File.OpenRead(SourceFilePath))
|
|
||||||
using (var targetStream = File.OpenRead(TargetFilePath))
|
|
||||||
{
|
|
||||||
byte[] sourceHash = md5Service.ComputeHash(sourceStream);
|
|
||||||
byte[] targetHash = md5Service.ComputeHash(targetStream);
|
|
||||||
|
|
||||||
return Enumerable.SequenceEqual(sourceHash, targetHash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Apply a delta to a file using xdelta
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="SourceFilePath"></param>
|
|
||||||
/// <param name="DeltaFilePath"></param>
|
|
||||||
private void ApplyDelta(string SourceFilePath, string DeltaFilePath)
|
|
||||||
{
|
|
||||||
string decodedPath = SourceFilePath + ".decoded";
|
|
||||||
|
|
||||||
Process.Start(new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = LazyOperations.XDelta3Path,
|
|
||||||
Arguments = $"-d -f -s \"{SourceFilePath}\" \"{DeltaFilePath}\" \"{decodedPath}\"",
|
|
||||||
CreateNoWindow = true
|
|
||||||
})
|
|
||||||
.WaitForExit();
|
|
||||||
|
|
||||||
if (File.Exists(decodedPath))
|
|
||||||
{
|
|
||||||
File.Move(decodedPath, SourceFilePath, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a .delta file using xdelta
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="SourceFilePath"></param>
|
|
||||||
/// <param name="TargetFilePath"></param>
|
|
||||||
/// <remarks>Used to patch an existing file with xdelta</remarks>
|
|
||||||
private void CreateDelta(string SourceFilePath, string TargetFilePath)
|
|
||||||
{
|
|
||||||
FileInfo sourceFileInfo = new FileInfo(SourceFilePath);
|
|
||||||
|
|
||||||
string deltaPath = GetDeltaPath(SourceFilePath, SourceFolder, "delta");
|
|
||||||
|
|
||||||
Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name + ".delta", ""));
|
|
||||||
|
|
||||||
//TODO - don't hardcode FileName
|
|
||||||
|
|
||||||
Process.Start(new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = LazyOperations.XDelta3Path,
|
|
||||||
Arguments = $"-0 -e -f -s \"{SourceFilePath}\" \"{TargetFilePath}\" \"{deltaPath}\"",
|
|
||||||
CreateNoWindow = true
|
|
||||||
})
|
|
||||||
.WaitForExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a .del file
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="SourceFile"></param>
|
|
||||||
/// <remarks>Used to mark a file for deletion</remarks>
|
|
||||||
private void CreateDelFile(string SourceFile)
|
|
||||||
{
|
|
||||||
FileInfo sourceFileInfo = new FileInfo(SourceFile);
|
|
||||||
|
|
||||||
string deltaPath = GetDeltaPath(SourceFile, SourceFolder, "del");
|
|
||||||
|
|
||||||
Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name + ".del", ""));
|
|
||||||
|
|
||||||
File.Create(deltaPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a .new file
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="TargetFile"></param>
|
|
||||||
/// <remarks>Used to mark a file that needs to be added</remarks>
|
|
||||||
private void CreateNewFile(string TargetFile)
|
|
||||||
{
|
|
||||||
FileInfo targetSourceInfo = new FileInfo(TargetFile);
|
|
||||||
|
|
||||||
string deltaPath = GetDeltaPath(TargetFile, TargetFolder, "new");
|
|
||||||
|
|
||||||
Directory.CreateDirectory(deltaPath.Replace(targetSourceInfo.Name + ".new", ""));
|
|
||||||
|
|
||||||
targetSourceInfo.CopyTo(deltaPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generate a full set of patches using the source and target folders specified during contruction./>
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// <remarks>Patches are created in the delta folder specified during contruction</remarks>
|
|
||||||
public bool GeneratePatches()
|
|
||||||
{
|
|
||||||
//get all directory information needed
|
|
||||||
DirectoryInfo sourceDir = new DirectoryInfo(SourceFolder);
|
|
||||||
DirectoryInfo targetDir = new DirectoryInfo(TargetFolder);
|
|
||||||
DirectoryInfo deltaDir = Directory.CreateDirectory(DeltaFolder);
|
|
||||||
|
|
||||||
//make sure all directories exist
|
|
||||||
if (!sourceDir.Exists || !targetDir.Exists || !deltaDir.Exists)
|
|
||||||
{
|
|
||||||
//One of the directories doesn't exist
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyOperations.CleanupTempDir();
|
|
||||||
LazyOperations.PrepTempDir();
|
|
||||||
|
|
||||||
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
|
||||||
|
|
||||||
fileCountTotal = SourceFiles.Count;
|
|
||||||
|
|
||||||
AdditionalInfo.Clear();
|
|
||||||
AdditionalInfo.Add(new LineItem("Delta Patch", 0));
|
|
||||||
AdditionalInfo.Add(new LineItem("New Patch", 0));
|
|
||||||
AdditionalInfo.Add(new LineItem("Del Patch", 0));
|
|
||||||
|
|
||||||
filesProcessed = 0;
|
|
||||||
|
|
||||||
RaiseProgressChanged(0, fileCountTotal, "Generating deltas...");
|
|
||||||
|
|
||||||
foreach (FileInfo targetFile in targetDir.GetFiles("*", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
//find a matching source file based on the relative path of the file
|
|
||||||
FileInfo sourceFile = SourceFiles.Find(f => f.FullName.Replace(sourceDir.FullName, "") == targetFile.FullName.Replace(targetDir.FullName, ""));
|
|
||||||
|
|
||||||
//if the target file doesn't exist in the source files, the target file needs to be added.
|
|
||||||
if (sourceFile == null)
|
|
||||||
{
|
|
||||||
CreateNewFile(targetFile.FullName);
|
|
||||||
|
|
||||||
newCount++;
|
|
||||||
filesProcessed++;
|
|
||||||
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
CreateDelta(sourceFile.FullName, targetFile.FullName);
|
|
||||||
extension = ".delta";
|
|
||||||
deltaCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceFiles.Remove(sourceFile);
|
|
||||||
|
|
||||||
filesProcessed++;
|
|
||||||
|
|
||||||
AdditionalInfo[0].ItemValue = deltaCount;
|
|
||||||
AdditionalInfo[1].ItemValue = newCount;
|
|
||||||
|
|
||||||
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.
|
|
||||||
//reset progress info
|
|
||||||
RaiseProgressChanged(0, SourceFiles.Count, "Processing .del files...");
|
|
||||||
filesProcessed = 0;
|
|
||||||
fileCountTotal = SourceFiles.Count;
|
|
||||||
|
|
||||||
foreach (FileInfo delFile in SourceFiles)
|
|
||||||
{
|
|
||||||
CreateDelFile(delFile.FullName);
|
|
||||||
|
|
||||||
delCount++;
|
|
||||||
|
|
||||||
AdditionalInfo[2].ItemValue = delCount;
|
|
||||||
|
|
||||||
filesProcessed++;
|
|
||||||
RaiseProgressChanged(filesProcessed, fileCountTotal, $"{delFile.FullName.Replace(SourceFolder, "...")}.del", AdditionalInfo.ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Apply a set of patches using the source and delta folders specified during construction.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string ApplyPatches()
|
|
||||||
{
|
|
||||||
//get needed directory information
|
|
||||||
DirectoryInfo sourceDir = new DirectoryInfo(SourceFolder);
|
|
||||||
DirectoryInfo deltaDir = new DirectoryInfo(DeltaFolder);
|
|
||||||
|
|
||||||
//check directories exist
|
|
||||||
if (!sourceDir.Exists || !deltaDir.Exists)
|
|
||||||
{
|
|
||||||
return "One of the supplied directories doesn't exist";
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyOperations.CleanupTempDir();
|
|
||||||
LazyOperations.PrepTempDir();
|
|
||||||
|
|
||||||
List<FileInfo> SourceFiles = sourceDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
|
||||||
|
|
||||||
List<FileInfo> deltaFiles = deltaDir.GetFiles("*", SearchOption.AllDirectories).ToList();
|
|
||||||
|
|
||||||
deltaCount = deltaFiles.Where(x => x.Extension == ".delta").Count();
|
|
||||||
newCount = deltaFiles.Where(x => x.Extension == ".new").Count();
|
|
||||||
delCount = deltaFiles.Where(x => x.Extension == ".del").Count();
|
|
||||||
|
|
||||||
|
|
||||||
AdditionalInfo = new List<LineItem>()
|
|
||||||
{
|
|
||||||
new LineItem("Patches Remaining", deltaCount),
|
|
||||||
new LineItem("New Files to Add", newCount),
|
|
||||||
new LineItem("Files to Delete", delCount)
|
|
||||||
};
|
|
||||||
|
|
||||||
filesProcessed = 0;
|
|
||||||
|
|
||||||
fileCountTotal = deltaFiles.Count;
|
|
||||||
|
|
||||||
foreach (FileInfo deltaFile in deltaDir.GetFiles("*", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
return $"Failed to find matching source file for '{deltaFile.FullName}'";
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyDelta(sourceFile.FullName, deltaFile.FullName);
|
|
||||||
|
|
||||||
deltaCount--;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ".new":
|
|
||||||
{
|
|
||||||
if (newCount == 2 || newCount == 1 || newCount == 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//copy new file
|
|
||||||
string destination = Path.Join(sourceDir.FullName, deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".new", ""));
|
|
||||||
|
|
||||||
File.Copy(deltaFile.FullName, destination, true);
|
|
||||||
|
|
||||||
newCount--;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ".del":
|
|
||||||
{
|
|
||||||
//remove unneeded file
|
|
||||||
string delFilePath = Path.Join(sourceDir.FullName, deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".del", ""));
|
|
||||||
|
|
||||||
File.Delete(delFilePath);
|
|
||||||
|
|
||||||
delCount--;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AdditionalInfo[0].ItemValue = deltaCount;
|
|
||||||
AdditionalInfo[1].ItemValue = newCount;
|
|
||||||
AdditionalInfo[2].ItemValue = delCount;
|
|
||||||
|
|
||||||
++filesProcessed;
|
|
||||||
RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyOperations.CleanupTempDir();
|
|
||||||
|
|
||||||
Directory.Delete(LazyOperations.PatchFolder, true);
|
|
||||||
|
|
||||||
return $"Patching Complete. You can delete the patcher.exe file.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="Resources\7za.exe" />
|
|
||||||
<None Remove="Resources\PatchClient.exe" />
|
|
||||||
<None Remove="Resources\xdelta3.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Resources\7za.exe" />
|
|
||||||
<EmbeddedResource Include="Resources\PatchClient.exe" />
|
|
||||||
<EmbeddedResource Include="Resources\xdelta3.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Aki.Common">
|
|
||||||
<HintPath>..\PatchGenerator\References\Aki.Common.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||||||
namespace PatcherUtils
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// <see cref="WriteProgressHandler(object, int, int, int, string, string[])"/> delegate
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Sender">The object calling the handler</param>
|
|
||||||
/// <param name="Progress">The current number of items processed</param>
|
|
||||||
/// <param name="Total">The total number of items</param>
|
|
||||||
/// <param name="Percent">The percentage of items processed</param>
|
|
||||||
/// <param name="Message">An optional message to display above the progress bar</param>
|
|
||||||
/// <param name="AdditionalLineItems">Additional information to display below the progress bar.</param>
|
|
||||||
public delegate void ProgressChangedHandler(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems);
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace PatcherUtils
|
|
||||||
{
|
|
||||||
public static class RandomExtensions
|
|
||||||
{
|
|
||||||
public static string FromCwd(this string s)
|
|
||||||
{
|
|
||||||
return Path.Combine(Environment.CurrentDirectory, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,3 +2,9 @@
|
|||||||
|
|
||||||
Allows for generating and applying patches to software.
|
Allows for generating and applying patches to software.
|
||||||
Currently used for downgrading EFT.
|
Currently used for downgrading EFT.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
- .net 6
|
||||||
|
|
||||||
|
## Development Stuff
|
||||||
|
- VS 2022 w/ Avalonia VS Extension
|
Loading…
x
Reference in New Issue
Block a user