mirror of
https://github.com/sp-tarkov/patcher.git
synced 2025-02-12 22:50:46 -05:00
its 1am idk man, I did some things. Patch Generator WIP
This commit is contained in:
parent
f57abbb64a
commit
455125576a
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe filter=lfs diff=lfs merge=lfs -text
|
@ -58,8 +58,7 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
if(File.Exists(decodedPath))
|
if(File.Exists(decodedPath))
|
||||||
{
|
{
|
||||||
File.Delete(SourceFilePath);
|
File.Move(decodedPath, SourceFilePath, true);
|
||||||
File.Move(decodedPath, SourceFilePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ namespace PatchClient.ViewModels
|
|||||||
{
|
{
|
||||||
public ICommand CloseCommand => ReactiveCommand.Create(() =>
|
public ICommand CloseCommand => ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
if(Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
|
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
|
||||||
{
|
{
|
||||||
desktopApp.MainWindow.Close();
|
desktopApp.MainWindow.Close();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Avalonia;
|
using ReactiveUI;
|
||||||
using ReactiveUI;
|
|
||||||
|
|
||||||
namespace PatchClient.ViewModels
|
namespace PatchClient.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using PatchClient.Models;
|
using PatchClient.Models;
|
||||||
using PatcherUtils;
|
using PatcherUtils;
|
||||||
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
using System;
|
using System;
|
||||||
using ReactiveUI;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
|
|
||||||
namespace PatchClient.ViewModels
|
namespace PatchClient.ViewModels
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ namespace PatchClient.ViewModels
|
|||||||
foreach (LineItem item in AdditionalLineItems)
|
foreach (LineItem item in AdditionalLineItems)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(initLineItemProgress)
|
if (initLineItemProgress)
|
||||||
{
|
{
|
||||||
if (item.ItemValue <= 0) continue;
|
if (item.ItemValue <= 0) continue;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using ReactiveUI;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using PatchClient.Models;
|
using PatchClient.Models;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace PatchClient.ViewModels
|
namespace PatchClient.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:cc="using:PatchGenerator.CustomControls">
|
xmlns:cc="using:PatchGenerator.CustomControls">
|
||||||
<Design.PreviewWith>
|
<Design.PreviewWith>
|
||||||
<Border Padding="20" Background="{StaticResource AKI_Background_Light}">
|
<Border Padding="10" Background="{StaticResource AKI_Background_Light}">
|
||||||
<!-- Add Controls for Previewer Here -->
|
<!-- Add Controls for Previewer Here -->
|
||||||
<StackPanel Background="{StaticResource AKI_Background_Light}" Spacing="15" Margin="10">
|
<StackPanel Background="{StaticResource AKI_Background_Light}" Spacing="15" Margin="10">
|
||||||
<cc:TitleBar Title="Title Bar Text"/>
|
<cc:TitleBar Title="Title Bar Text"/>
|
||||||
@ -12,18 +12,49 @@
|
|||||||
<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 :)"/>
|
||||||
|
<CheckBox Content="Check .. Me Out! ba-dum-tss"/>
|
||||||
|
<TextBox Text="Some Text Here" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Design.PreviewWith>
|
</Design.PreviewWith>
|
||||||
|
|
||||||
<!-- Add Styles Here -->
|
<!-- Add Styles Here -->
|
||||||
|
|
||||||
|
<!-- TitleBar Styles -->
|
||||||
<Style Selector="cc|TitleBar">
|
<Style Selector="cc|TitleBar">
|
||||||
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
|
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
|
||||||
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
|
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
|
||||||
<Setter Property="XButtonForeground" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
|
<Setter Property="XButtonForeground" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- TextBox Styles -->
|
||||||
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml -->
|
||||||
|
<Style Selector="TextBox">
|
||||||
|
<Setter Property="Background" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBox:focus">
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBox:pointerover /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="BorderBrush" Value="DimGray"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBox:focus /template/ TextBlock#PART_Watermark, TextBox:focus /template/ TextBlock#PART_FloatingWatermark">
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBox:focus /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Label Styles -->
|
||||||
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Label.xaml -->
|
||||||
<Style Selector="Label">
|
<Style Selector="Label">
|
||||||
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
|
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
|
||||||
</Style>
|
</Style>
|
||||||
@ -36,6 +67,8 @@
|
|||||||
<Setter Property="Foreground" Value="DimGray"/>
|
<Setter Property="Foreground" Value="DimGray"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- ProgressBar Styles -->
|
||||||
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml -->
|
||||||
<Style Selector="ProgressBar">
|
<Style Selector="ProgressBar">
|
||||||
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
|
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
</Style>
|
</Style>
|
||||||
@ -65,7 +98,40 @@
|
|||||||
</Style.Animations>
|
</Style.Animations>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- Seperator Styles -->
|
||||||
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Separator.xaml -->
|
||||||
<Style Selector="Separator">
|
<Style Selector="Separator">
|
||||||
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
|
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- Button Styles -->
|
||||||
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Button.xaml -->
|
||||||
|
<Style Selector="Button">
|
||||||
|
<Setter Property="Background" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource AKI_Background_Dark}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Button:pointerover">
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Button:pressed /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Checkbox styles -->
|
||||||
|
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml -->
|
||||||
|
<Style Selector="CheckBox:checked">
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="CheckBox:checked /template/ Border#NormalRectangle">
|
||||||
|
<Setter Property="Background" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="CheckBox:checked /template/ Path#CheckGlyph">
|
||||||
|
<Setter Property="Fill" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
</Styles>
|
</Styles>
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace PatchGenerator.AttachedProperties
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Just a random boolean value for you to attach and use to any control.
|
||||||
|
/// </summary>
|
||||||
|
public class RandomBoolAttProp : AvaloniaObject
|
||||||
|
{
|
||||||
|
public static readonly AttachedProperty<bool> RandomBoolProperty =
|
||||||
|
AvaloniaProperty.RegisterAttached<RandomBoolAttProp, Control, bool>("RandomBool");
|
||||||
|
|
||||||
|
public static bool GetRandomBool(Control control)
|
||||||
|
{
|
||||||
|
return control.GetValue(RandomBoolProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetRandomBool(Control control, bool value)
|
||||||
|
{
|
||||||
|
control.SetValue(RandomBoolProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
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"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="PatchGenerator.CustomControls.FolderSelector"
|
||||||
|
DragDrop.AllowDrop="True"
|
||||||
|
Background="Transparent"
|
||||||
|
>
|
||||||
|
<UserControl.Styles>
|
||||||
|
<Style Selector="Border">
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AKI_Background_Dark}"/>
|
||||||
|
<Setter Property="BorderThickness" Value="2"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Border.folderSelected">
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBlock.folderSelected">
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
|
||||||
|
</Style>
|
||||||
|
</UserControl.Styles>
|
||||||
|
|
||||||
|
<Border Classes.folderSelected="{Binding FolderSelected, RelativeSource={
|
||||||
|
RelativeSource AncestorType=UserControl}}">
|
||||||
|
|
||||||
|
<TextBlock Text="{Binding FolderPath, RelativeSource={
|
||||||
|
RelativeSource AncestorType=UserControl}}"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Classes.folderSelected="{Binding FolderSelected, RelativeSource={
|
||||||
|
RelativeSource AncestorType=UserControl}}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
</UserControl>
|
@ -0,0 +1,69 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace PatchGenerator.CustomControls
|
||||||
|
{
|
||||||
|
public partial class FolderSelector : UserControl
|
||||||
|
{
|
||||||
|
public FolderSelector()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
AddHandler(DragDrop.DropEvent, Drop);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Drop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data.Contains(DataFormats.FileNames))
|
||||||
|
{
|
||||||
|
string[] filePaths = e.Data.GetFileNames().ToArray();
|
||||||
|
|
||||||
|
if (filePaths.Length == 1)
|
||||||
|
{
|
||||||
|
DirectoryInfo folder = new DirectoryInfo(filePaths[0]);
|
||||||
|
|
||||||
|
if (folder.Exists)
|
||||||
|
{
|
||||||
|
FolderPath = filePaths[0];
|
||||||
|
FolderSelected = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderPath = "Dropped object must be a folder";
|
||||||
|
FolderSelected = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderPath = "Cannot drop multiple files";
|
||||||
|
FolderSelected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly StyledProperty<bool> FolderSelectedProperty =
|
||||||
|
AvaloniaProperty.Register<FolderSelector, bool>(nameof(FolderSelected));
|
||||||
|
|
||||||
|
private bool FolderSelected
|
||||||
|
{
|
||||||
|
get => GetValue(FolderSelectedProperty);
|
||||||
|
set => SetValue(FolderSelectedProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<string> FolderPathProperty =
|
||||||
|
AvaloniaProperty.Register<FolderSelector, string>(nameof(FolderPath));
|
||||||
|
|
||||||
|
public string FolderPath
|
||||||
|
{
|
||||||
|
get => GetValue(FolderPathProperty);
|
||||||
|
set => SetValue(FolderPathProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using Avalonia.Media;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace PatchGenerator.Helpers
|
||||||
|
{
|
||||||
|
public static class PatchItemDefinitions
|
||||||
|
{
|
||||||
|
public static Dictionary<string, IBrush> Colors = new Dictionary<string, IBrush>()
|
||||||
|
{
|
||||||
|
{"delta", Brushes.MediumPurple },
|
||||||
|
{"new", Brushes.Green },
|
||||||
|
{"del", Brushes.IndianRed },
|
||||||
|
{"exists", Brushes.DimGray }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
namespace PatchGenerator.Models
|
||||||
|
{
|
||||||
|
public class GenStartupArgs
|
||||||
|
{
|
||||||
|
public bool ReadyToRun => OutputFolderName != "" && SourceFolderPath != "" && TargetFolderPath != "";
|
||||||
|
public string OutputFolderName { get; private set; } = "";
|
||||||
|
public string SourceFolderPath { get; private set; } = "";
|
||||||
|
public string TargetFolderPath { get; private set; } = "";
|
||||||
|
public bool AutoZip { get; private set; } = true;
|
||||||
|
protected GenStartupArgs(string OutputFolderName, string SourceFolderPath, string TargetFolderPath, bool AutoZip)
|
||||||
|
{
|
||||||
|
this.OutputFolderName = OutputFolderName;
|
||||||
|
this.SourceFolderPath = SourceFolderPath;
|
||||||
|
this.TargetFolderPath = TargetFolderPath;
|
||||||
|
this.AutoZip = AutoZip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenStartupArgs Parse(string[] Args)
|
||||||
|
{
|
||||||
|
if (Args == null || Args.Length == 0) return null;
|
||||||
|
|
||||||
|
string outputFolderPath = "";
|
||||||
|
string sourceFolderPath = "";
|
||||||
|
string targetFolderPath = "";
|
||||||
|
bool autoZip = true;
|
||||||
|
|
||||||
|
foreach (string arg in Args)
|
||||||
|
{
|
||||||
|
if (arg.Split("::").Length != 2) return null;
|
||||||
|
|
||||||
|
var argSplit = arg.Split("::");
|
||||||
|
|
||||||
|
switch (argSplit[0])
|
||||||
|
{
|
||||||
|
case "OutputFolderName":
|
||||||
|
{
|
||||||
|
outputFolderPath = argSplit[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "SourceFolderPath":
|
||||||
|
{
|
||||||
|
sourceFolderPath = argSplit[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "TargetFolderPath":
|
||||||
|
{
|
||||||
|
targetFolderPath = argSplit[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "AutoZip":
|
||||||
|
{
|
||||||
|
autoZip = bool.Parse(argSplit[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GenStartupArgs(outputFolderPath, sourceFolderPath, targetFolderPath, autoZip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
Patcher/_port/Patcher/PatchGenerator/Models/PatchGenInfo.cs
Normal file
66
Patcher/_port/Patcher/PatchGenerator/Models/PatchGenInfo.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using ReactiveUI;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace PatchGenerator.Models
|
||||||
|
{
|
||||||
|
public class PatchGenInfo : ReactiveObject
|
||||||
|
{
|
||||||
|
private void UpdateReadyToRun()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(SourceFolderPath) && Directory.Exists(TargetFolderPath) && PatchName != "")
|
||||||
|
{
|
||||||
|
ReadyToRun = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadyToRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _PatchName = "";
|
||||||
|
public string PatchName
|
||||||
|
{
|
||||||
|
get => _PatchName;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.RaiseAndSetIfChanged(ref _PatchName, value);
|
||||||
|
UpdateReadyToRun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _SourceFolderPath = "";
|
||||||
|
public string SourceFolderPath
|
||||||
|
{
|
||||||
|
get => _SourceFolderPath;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.RaiseAndSetIfChanged(ref _SourceFolderPath, value);
|
||||||
|
UpdateReadyToRun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _TargetFolderPath = "";
|
||||||
|
public string TargetFolderPath
|
||||||
|
{
|
||||||
|
get => _TargetFolderPath;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.RaiseAndSetIfChanged(ref _TargetFolderPath, value);
|
||||||
|
UpdateReadyToRun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _AutoZip = true;
|
||||||
|
public bool AutoZip
|
||||||
|
{
|
||||||
|
get => _AutoZip;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _AutoZip, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _ReadyToRun = false;
|
||||||
|
public bool ReadyToRun
|
||||||
|
{
|
||||||
|
get => _ReadyToRun;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _ReadyToRun, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
40
Patcher/_port/Patcher/PatchGenerator/Models/PatchItem.cs
Normal file
40
Patcher/_port/Patcher/PatchGenerator/Models/PatchItem.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using Avalonia.Media;
|
||||||
|
using PatchGenerator.Helpers;
|
||||||
|
using ReactiveUI;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace PatchGenerator.Models
|
||||||
|
{
|
||||||
|
public class PatchItem : ReactiveObject
|
||||||
|
{
|
||||||
|
private string _Name = "";
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => _Name;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _Name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IBrush _Color;
|
||||||
|
public IBrush Color
|
||||||
|
{
|
||||||
|
get => _Color;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _Color, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchItem(string Name)
|
||||||
|
{
|
||||||
|
this.Name = Name.Replace(".new", "").Replace(".delta", "").Replace(".del", "");
|
||||||
|
|
||||||
|
IBrush color;
|
||||||
|
|
||||||
|
if (PatchItemDefinitions.Colors.TryGetValue(Name.Split('.').Last(), out color))
|
||||||
|
{
|
||||||
|
Color = color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Color = PatchItemDefinitions.Colors["exists"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
<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\xdelta3.exe" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\7za.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>
|
@ -2,6 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@ -19,6 +20,15 @@
|
|||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**" />
|
||||||
<AvaloniaResource Remove="Assets\Styles.axaml" />
|
<AvaloniaResource Remove="Assets\Styles.axaml" />
|
||||||
<None Remove=".gitignore" />
|
<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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="0.10.11" />
|
<PackageReference Include="Avalonia" Version="0.10.11" />
|
||||||
@ -32,7 +42,4 @@
|
|||||||
<DependentUpon>%(Filename)</DependentUpon>
|
<DependentUpon>%(Filename)</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Models\" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/7za.exe
Normal file
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/7za.exe
Normal file
Binary file not shown.
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe
(Stored with Git LFS)
Normal file
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/PatchClient.exe
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/xdelta3.exe
Normal file
BIN
Patcher/_port/Patcher/PatchGenerator/Resources/xdelta3.exe
Normal file
Binary file not shown.
@ -1,12 +1,29 @@
|
|||||||
using System;
|
using PatchGenerator.Models;
|
||||||
using System.Collections.Generic;
|
using Splat;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PatchGenerator.ViewModels
|
namespace PatchGenerator.ViewModels
|
||||||
{
|
{
|
||||||
public class OptionsViewModel : ViewModelBase
|
public class OptionsViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
public PatchGenInfo GenerationInfo { get; set; } = new PatchGenInfo();
|
||||||
|
|
||||||
|
private ViewNavigator navigator => Locator.Current.GetService<ViewNavigator>();
|
||||||
|
|
||||||
|
public OptionsViewModel(GenStartupArgs genArgs = null)
|
||||||
|
{
|
||||||
|
if (genArgs != null)
|
||||||
|
{
|
||||||
|
//TODO - parse/check startup args and start patching
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GenerationInfo.SourceFolderPath = "Drop SOURCE folder here";
|
||||||
|
GenerationInfo.TargetFolderPath = "Drop TARGET folder here";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GeneratePatches()
|
||||||
|
{
|
||||||
|
navigator.SelectedViewModel = new PatchGenerationViewModel(GenerationInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
using System;
|
using Avalonia.Media;
|
||||||
|
using PatcherUtils;
|
||||||
|
using PatchGenerator.Helpers;
|
||||||
|
using PatchGenerator.Models;
|
||||||
|
using ReactiveUI;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -8,5 +14,92 @@ namespace PatchGenerator.ViewModels
|
|||||||
{
|
{
|
||||||
public class PatchGenerationViewModel : ViewModelBase
|
public class PatchGenerationViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private bool _AutoScroll = true;
|
||||||
|
public bool AutoScroll
|
||||||
|
{
|
||||||
|
get => _AutoScroll;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _AutoScroll, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _ProgressMessage;
|
||||||
|
public string ProgressMessage
|
||||||
|
{
|
||||||
|
get => _ProgressMessage;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _ProgressMessage, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _PatchPercent;
|
||||||
|
public int PatchPercent
|
||||||
|
{
|
||||||
|
get => _PatchPercent;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _PatchPercent, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<PatchItem> PatchItemCollection { get; set; } = new ObservableCollection<PatchItem>();
|
||||||
|
public ObservableCollection<PatchItem> PatchItemLegendCollection { get; set; } = new ObservableCollection<PatchItem>();
|
||||||
|
|
||||||
|
private Stopwatch patchGenStopwatch = new Stopwatch();
|
||||||
|
|
||||||
|
private readonly PatchGenInfo generationInfo;
|
||||||
|
public PatchGenerationViewModel(PatchGenInfo GenerationInfo)
|
||||||
|
{
|
||||||
|
generationInfo = GenerationInfo;
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, IBrush> pair in PatchItemDefinitions.Colors)
|
||||||
|
{
|
||||||
|
PatchItemLegendCollection.Add(new PatchItem("")
|
||||||
|
{
|
||||||
|
Name = pair.Key,
|
||||||
|
Color = pair.Value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneratePatches();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GeneratePatches()
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
//Slight delay to avoid some weird race condition in avalonia core, seems to be a bug, but also maybe I'm just stupid, idk -waffle
|
||||||
|
System.Threading.Thread.Sleep(200);
|
||||||
|
|
||||||
|
string outputFolder = Path.Join(LazyOperations.PatchFolder, generationInfo.PatchName);
|
||||||
|
|
||||||
|
PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, outputFolder);
|
||||||
|
|
||||||
|
patcher.ProgressChanged += Patcher_ProgressChanged;
|
||||||
|
|
||||||
|
patchGenStopwatch.Start();
|
||||||
|
|
||||||
|
patcher.GeneratePatches();
|
||||||
|
|
||||||
|
patchGenStopwatch.Stop();
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder()
|
||||||
|
.Append("Patches Generated in ")
|
||||||
|
.Append($"{patchGenStopwatch.Elapsed.Hours} hr/s ")
|
||||||
|
.Append($"{patchGenStopwatch.Elapsed.Minutes} min/s ")
|
||||||
|
.Append($"{patchGenStopwatch.Elapsed.Seconds} sec/s");
|
||||||
|
|
||||||
|
ProgressMessage = sb.ToString();
|
||||||
|
|
||||||
|
//TODO - need to fix this. Wrong folder, and need to copy client to output
|
||||||
|
if (generationInfo.AutoZip)
|
||||||
|
{
|
||||||
|
LazyOperations.StartZipProcess(outputFolder, $"{outputFolder}.zip");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Patcher_ProgressChanged(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems)
|
||||||
|
{
|
||||||
|
ProgressMessage = $"{Progress}/{Total}";
|
||||||
|
|
||||||
|
PatchPercent = Percent;
|
||||||
|
|
||||||
|
PatchItemCollection.Add(new PatchItem(Message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace PatchGenerator.ViewModels
|
namespace PatchGenerator.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,33 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:cc="using:PatchGenerator.CustomControls"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="PatchGenerator.Views.OptionsView">
|
x:Class="PatchGenerator.Views.OptionsView">
|
||||||
<Grid>
|
<Grid ColumnDefinitions="2*,10,2*" RowDefinitions="*,10, AUTO, 10, AUTO" Margin="10">
|
||||||
|
|
||||||
|
<cc:FolderSelector FolderPath="{Binding GenerationInfo.SourceFolderPath, Mode=TwoWay}"/>
|
||||||
|
<cc:FolderSelector Grid.Column="2"
|
||||||
|
FolderPath="{Binding GenerationInfo.TargetFolderPath, Mode=TwoWay}"/>
|
||||||
|
|
||||||
|
<TextBox Text="{Binding GenerationInfo.PatchName}"
|
||||||
|
Grid.Row="2" Grid.ColumnSpan="3"
|
||||||
|
Watermark="Output Folder Name"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CheckBox Content="Zip Generated Files" Grid.Row="4"
|
||||||
|
IsChecked="{Binding GenerationInfo.AutoZip}"/>
|
||||||
|
|
||||||
|
<Button Content="Generate Patches" Grid.ColumnSpan="3" Grid.Row="4"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
FontSize="15"
|
||||||
|
FontWeight="SemiBold"
|
||||||
|
Height="50"
|
||||||
|
Width="200"
|
||||||
|
Command="{Binding GeneratePatches}"
|
||||||
|
IsEnabled="{Binding GenerationInfo.ReadyToRun}"
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
@ -2,7 +2,71 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:model="using:PatchGenerator.Models"
|
||||||
|
xmlns:cc="using:PatchGenerator.CustomControls"
|
||||||
|
xmlns:att="using:PatchGenerator.AttachedProperties"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="PatchGenerator.Views.PatchGenerationView">
|
x:Class="PatchGenerator.Views.PatchGenerationView">
|
||||||
Welcome to Avalonia!
|
|
||||||
|
<UserControl.Styles>
|
||||||
|
<StyleInclude Source="/Assets/Styles.axaml"/>
|
||||||
|
</UserControl.Styles>
|
||||||
|
|
||||||
|
<Grid RowDefinitions="AUTO,*,AUTO,AUTO,AUTO">
|
||||||
|
|
||||||
|
<ItemsControl Items="{Binding PatchItemLegendCollection}">
|
||||||
|
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal" Grid.Column="1"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="10"
|
||||||
|
Spacing="30"
|
||||||
|
/>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type model:PatchItem}">
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
|
<Rectangle Fill="{Binding Color}" Height="10" Width="10"/>
|
||||||
|
<TextBlock Text="{Binding Name}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
|
||||||
|
</ItemsControl>
|
||||||
|
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1"
|
||||||
|
ScrollChanged="scrollChanged"
|
||||||
|
att:RandomBoolAttProp.RandomBool="{Binding AutoScroll}"
|
||||||
|
>
|
||||||
|
<ItemsControl Items="{Binding PatchItemCollection}"
|
||||||
|
Background="Transparent"
|
||||||
|
>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type model:PatchItem}">
|
||||||
|
<TextBlock Text="{Binding Name}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Foreground="{Binding Color}"
|
||||||
|
/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
|
||||||
|
</ItemsControl>
|
||||||
|
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<ProgressBar Grid.Row="2" Value="{Binding PatchPercent}" Margin="10"/>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="AUTO,*,AUTO" Grid.Row="3" Margin="10 0">
|
||||||
|
<Label Content="{Binding ProgressMessage}"/>
|
||||||
|
<Label Content="{Binding PatchPercent, StringFormat={}{0}%}" Grid.Column="2"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<CheckBox Content="AutoScroll" Grid.Row="4" HorizontalAlignment="Right" Margin="10"
|
||||||
|
IsChecked="{Binding AutoScroll}"/>
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using PatchGenerator.AttachedProperties;
|
||||||
|
|
||||||
namespace PatchGenerator.Views
|
namespace PatchGenerator.Views
|
||||||
{
|
{
|
||||||
@ -15,5 +15,18 @@ namespace PatchGenerator.Views
|
|||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void scrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is ScrollViewer scrollViewer)
|
||||||
|
{
|
||||||
|
bool autoScroll = scrollViewer.GetValue(RandomBoolAttProp.RandomBoolProperty);
|
||||||
|
|
||||||
|
if (autoScroll)
|
||||||
|
{
|
||||||
|
scrollViewer.ScrollToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
@ -67,9 +66,9 @@ namespace PatcherUtils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void PrepTempDir()
|
public static void PrepTempDir()
|
||||||
{
|
{
|
||||||
foreach(string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames())
|
foreach (string resource in Assembly.GetExecutingAssembly().GetManifestResourceNames())
|
||||||
{
|
{
|
||||||
switch(resource)
|
switch (resource)
|
||||||
{
|
{
|
||||||
case string a when a.EndsWith(SevenZExe):
|
case string a when a.EndsWith(SevenZExe):
|
||||||
{
|
{
|
||||||
@ -108,7 +107,7 @@ namespace PatcherUtils
|
|||||||
{
|
{
|
||||||
DirectoryInfo dir = new DirectoryInfo(TempDir);
|
DirectoryInfo dir = new DirectoryInfo(TempDir);
|
||||||
|
|
||||||
if(dir.Exists)
|
if (dir.Exists)
|
||||||
{
|
{
|
||||||
dir.Delete(true);
|
dir.Delete(true);
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,9 @@ namespace PatcherUtils
|
|||||||
})
|
})
|
||||||
.WaitForExit();
|
.WaitForExit();
|
||||||
|
|
||||||
if(File.Exists(decodedPath))
|
if (File.Exists(decodedPath))
|
||||||
{
|
{
|
||||||
File.Delete(SourceFilePath);
|
File.Move(decodedPath, SourceFilePath, true);
|
||||||
File.Move(decodedPath, SourceFilePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
string deltaPath = GetDeltaPath(SourceFilePath, SourceFolder, "delta");
|
string deltaPath = GetDeltaPath(SourceFilePath, SourceFolder, "delta");
|
||||||
|
|
||||||
Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name+".delta", ""));
|
Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name + ".delta", ""));
|
||||||
|
|
||||||
//TODO - don't hardcode FileName
|
//TODO - don't hardcode FileName
|
||||||
|
|
||||||
@ -140,7 +139,7 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
string deltaPath = GetDeltaPath(SourceFile, SourceFolder, "del");
|
string deltaPath = GetDeltaPath(SourceFile, SourceFolder, "del");
|
||||||
|
|
||||||
Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name+".del", ""));
|
Directory.CreateDirectory(deltaPath.Replace(sourceFileInfo.Name + ".del", ""));
|
||||||
|
|
||||||
File.Create(deltaPath);
|
File.Create(deltaPath);
|
||||||
}
|
}
|
||||||
@ -156,7 +155,7 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
string deltaPath = GetDeltaPath(TargetFile, TargetFolder, "new");
|
string deltaPath = GetDeltaPath(TargetFile, TargetFolder, "new");
|
||||||
|
|
||||||
Directory.CreateDirectory(deltaPath.Replace(targetSourceInfo.Name+".new", ""));
|
Directory.CreateDirectory(deltaPath.Replace(targetSourceInfo.Name + ".new", ""));
|
||||||
|
|
||||||
targetSourceInfo.CopyTo(deltaPath, true);
|
targetSourceInfo.CopyTo(deltaPath, true);
|
||||||
}
|
}
|
||||||
@ -180,6 +179,9 @@ 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;
|
||||||
@ -206,15 +208,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string extension = "";
|
||||||
|
|
||||||
//if a matching source file was found, check the file hashes and get the delta.
|
//if a matching source file was found, check the file hashes and get the delta.
|
||||||
if(!CompareFileHashes(sourceFile.FullName, targetFile.FullName))
|
if (!CompareFileHashes(sourceFile.FullName, targetFile.FullName))
|
||||||
{
|
{
|
||||||
CreateDelta(sourceFile.FullName, targetFile.FullName);
|
CreateDelta(sourceFile.FullName, targetFile.FullName);
|
||||||
|
extension = ".delta";
|
||||||
deltaCount++;
|
deltaCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +230,7 @@ namespace PatcherUtils
|
|||||||
AdditionalInfo[0].ItemValue = deltaCount;
|
AdditionalInfo[0].ItemValue = deltaCount;
|
||||||
AdditionalInfo[1].ItemValue = newCount;
|
AdditionalInfo[1].ItemValue = newCount;
|
||||||
|
|
||||||
RaiseProgressChanged(filesProcessed, fileCountTotal, targetFile.Name, AdditionalInfo.ToArray());
|
RaiseProgressChanged(filesProcessed, fileCountTotal, $"{targetFile.FullName.Replace(TargetFolder, "...")}{extension}", AdditionalInfo.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Any remaining source files do not exist in the target folder and can be removed.
|
//Any remaining source files do not exist in the target folder and can be removed.
|
||||||
@ -243,7 +248,7 @@ namespace PatcherUtils
|
|||||||
AdditionalInfo[2].ItemValue = delCount;
|
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;
|
||||||
@ -290,14 +295,14 @@ namespace PatcherUtils
|
|||||||
|
|
||||||
foreach (FileInfo deltaFile in deltaDir.GetFiles("*", SearchOption.AllDirectories))
|
foreach (FileInfo deltaFile in deltaDir.GetFiles("*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
switch(deltaFile.Extension)
|
switch (deltaFile.Extension)
|
||||||
{
|
{
|
||||||
case ".delta":
|
case ".delta":
|
||||||
{
|
{
|
||||||
//apply delta
|
//apply delta
|
||||||
FileInfo sourceFile = SourceFiles.Find(f => f.FullName.Replace(sourceDir.FullName, "") == deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".delta", ""));
|
FileInfo sourceFile = SourceFiles.Find(f => f.FullName.Replace(sourceDir.FullName, "") == deltaFile.FullName.Replace(deltaDir.FullName, "").Replace(".delta", ""));
|
||||||
|
|
||||||
if(sourceFile == null)
|
if (sourceFile == null)
|
||||||
{
|
{
|
||||||
return $"Failed to find matching source file for '{deltaFile.FullName}'";
|
return $"Failed to find matching source file for '{deltaFile.FullName}'";
|
||||||
}
|
}
|
||||||
@ -310,7 +315,7 @@ namespace PatcherUtils
|
|||||||
}
|
}
|
||||||
case ".new":
|
case ".new":
|
||||||
{
|
{
|
||||||
if(newCount == 2 || newCount == 1 || newCount == 0)
|
if (newCount == 2 || newCount == 1 || newCount == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -318,7 +323,7 @@ namespace PatcherUtils
|
|||||||
//copy new file
|
//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--;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user