0
0
mirror of https://github.com/sp-tarkov/patcher.git synced 2025-02-13 01:50:47 -05:00

Merge pull request 'avalonia-port' (#3) from avalonia-port into main

Reviewed-on: waffle.lord/Patcher#3
This commit is contained in:
IsWaffle 2021-12-26 01:26:57 +00:00
commit 6ef883958d
75 changed files with 2929 additions and 933 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
/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

454
Patcher/PatchClient/.gitignore vendored Normal file
View File

@ -0,0 +1,454 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# Tye
.tye/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# JetBrains Rider
.idea/
*.sln.iml
##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

View File

@ -0,0 +1,28 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PatchClient"
x:Class="PatchClient.App">
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme Mode="Light"/>
</Application.Styles>
<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_Brush_Yellow" Color="{StaticResource AKI_Yellow}"/>
<SolidColorBrush x:Key="AKI_Brush_DarkGrayBlue" Color="{StaticResource AKI_DarkGrayBlue}"/>
</Application.Resources>
</Application>

View File

@ -0,0 +1,29 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using PatchClient.ViewModels;
using PatchClient.Views;
namespace PatchClient
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
}
}

View File

@ -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"-->

View File

@ -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
{
}
}

View File

@ -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)
)]

View File

@ -0,0 +1,71 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="using:PatchClient.CustomControls">
<Design.PreviewWith>
<Border Padding="20" Background="{StaticResource AKI_Background_Light}">
<!-- Add Controls for Previewer Here -->
<StackPanel Background="{StaticResource AKI_Background_Light}" Spacing="15" Margin="10">
<cc:TitleBar Title="Title Bar Text"/>
<Label Content="Normal label"/>
<Label Content="Yellow label" Classes="yellow"/>
<Label Content="Blue label" Classes="dark"/>
<ProgressBar Value="40"/>
<Separator Height="1"/>
<ProgressBar Value="60" Classes="done"/>
</StackPanel>
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style Selector="cc|TitleBar">
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
<Setter Property="XButtonForeground" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
</Style>
<Style Selector="Label">
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
</Style>
<Style Selector="Label.yellow">
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
</Style>
<Style Selector="Label.dark">
<Setter Property="Foreground" Value="DimGray"/>
</Style>
<Style Selector="ProgressBar">
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
</Style>
<Style Selector="ProgressBar.done">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="Transitions">
<Transitions>
<BrushTransition Property="Foreground" Duration="0:0:1"/>
</Transitions>
</Setter>
</Style>
<Style Selector="ProgressBar.done /template/ Border">
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="Width" Value="5"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Style.Animations>
<Animation Duration="0:0:0.2" FillMode="Forward">
<KeyFrame Cue="0%">
<Setter Property="Width" Value="200"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Width" Value="5"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<Style Selector="Separator">
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
</Style>
</Styles>

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -0,0 +1,45 @@
<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="PatchClient.CustomControls.TitleBar">
<Grid ColumnDefinitions="AUTO,*,AUTO">
<Rectangle Grid.ColumnSpan="3" IsHitTestVisible="False"
Fill="{Binding Background, RelativeSource={
RelativeSource AncestorType=UserControl}}"
/>
<Label Content="{Binding Title, RelativeSource={
RelativeSource AncestorType=UserControl}}"
IsHitTestVisible="False"
Foreground="{Binding Foreground, RelativeSource={
RelativeSource AncestorType=UserControl}}"
Background="Transparent"
VerticalContentAlignment="Center"
/>
<Button Content="&#xE106;" Grid.Column="2"
Foreground="{Binding XButtonForeground, RelativeSource={
RelativeSource AncestorType=UserControl}}"
Command="{Binding XButtonCommand, RelativeSource={
RelativeSource AncestorType=UserControl}}"
Background="Transparent"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
FontFamily="Segoe MDL2 Assets"
VerticalAlignment="Stretch"
CornerRadius="0"
Width="35"
>
<Button.Styles>
<Style Selector="Button:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="IndianRed"/>
</Style>
<Style Selector="Button:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="Crimson"/>
</Style>
</Button.Styles>
</Button>
</Grid>
</UserControl>

View File

@ -0,0 +1,67 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using System.Windows.Input;
namespace PatchClient.CustomControls
{
public partial class TitleBar : UserControl
{
public TitleBar()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public static readonly StyledProperty<string> TitleProperty =
AvaloniaProperty.Register<TitleBar, string>(nameof(Title));
public string Title
{
get => GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public static readonly StyledProperty<IBrush> XButtonForegroundProperty =
AvaloniaProperty.Register<TitleBar, IBrush>(nameof(XButtonForeground));
public IBrush XButtonForeground
{
get => GetValue(XButtonForegroundProperty);
set => SetValue(XButtonForegroundProperty, value);
}
public static new readonly StyledProperty<IBrush> ForegroundProperty =
AvaloniaProperty.Register<TitleBar, IBrush>(nameof(Foreground));
public new IBrush Foreground
{
get => GetValue(ForegroundProperty);
set => SetValue(ForegroundProperty, value);
}
public static new readonly StyledProperty<IBrush> BackgroundProperty =
AvaloniaProperty.Register<TitleBar, IBrush>(nameof(Background));
public new IBrush Background
{
get => GetValue(BackgroundProperty);
set => SetValue(BackgroundProperty, value);
}
//Close Button Command (X Button) Property
public static readonly StyledProperty<ICommand> XButtonCommandProperty =
AvaloniaProperty.Register<TitleBar, ICommand>(nameof(XButtonCommand));
public ICommand XButtonCommand
{
get => GetValue(XButtonCommandProperty);
set => SetValue(XButtonCommandProperty, value);
}
}
}

View File

@ -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;
});
}
}
}

View File

@ -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>

View File

@ -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();
}
}
}
}

View File

@ -0,0 +1,61 @@
using PatcherUtils;
using ReactiveUI;
using System;
namespace PatchClient.Models
{
public class LineItemProgress : ReactiveObject
{
private bool _Completed = false;
public bool Completed
{
get => _Completed;
set => this.RaiseAndSetIfChanged(ref _Completed, value);
}
public int Total { get; private set; } = 0;
private string _Info = "";
public string Info
{
get => _Info;
set => this.RaiseAndSetIfChanged(ref _Info, value);
}
private int _Progress;
public int Progress
{
get => _Progress;
set => this.RaiseAndSetIfChanged(ref _Progress, value);
}
private string _ProgressInfo = "";
public string ProgressInfo
{
get => _ProgressInfo;
set => this.RaiseAndSetIfChanged(ref _ProgressInfo, value);
}
public void UpdateProgress(int RemainingCount)
{
if (Completed) return;
int processed = Total - RemainingCount;
Progress = (int)Math.Floor((double)processed / Total * 100);
ProgressInfo = $"{processed} / {Total}";
if (Progress == 100) Completed = true;
}
public LineItemProgress(LineItem Item)
{
Info = Item.ItemText;
Total = Item.ItemValue;
Progress = (int)Math.Floor((double)Item.ItemValue / Total * 100);
}
}
}

View File

@ -0,0 +1,14 @@
using ReactiveUI;
namespace PatchClient.Models
{
public class ViewNavigator : ReactiveObject
{
private object _SelectedViewModel;
public object SelectedViewModel
{
get => _SelectedViewModel;
set => this.RaiseAndSetIfChanged(ref _SelectedViewModel, value);
}
}
}

View File

@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<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>
@ -18,4 +19,17 @@
<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>

View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;
namespace PatchClient
{
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
}
}

View File

@ -1,7 +1,8 @@
{
"profiles": {
"PatchClient": {
"commandName": "Project"
"commandName": "Project",
"hotReloadEnabled": false
}
}
}

View File

@ -0,0 +1,30 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using PatchClient.ViewModels;
using System;
namespace PatchClient
{
public class ViewLocator : IDataTemplate
{
public IControl Build(object data)
{
var name = data.GetType().FullName!.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
}
public bool Match(object data)
{
return data is ViewModelBase;
}
}
}

View File

@ -0,0 +1,27 @@
using Avalonia;
using PatchClient.Models;
using ReactiveUI;
using Splat;
using System.Windows.Input;
namespace PatchClient.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
public ICommand CloseCommand => ReactiveCommand.Create(() =>
{
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
{
desktopApp.MainWindow.Close();
}
});
public ViewNavigator navigator { get; set; } = new ViewNavigator();
public MainWindowViewModel()
{
navigator.SelectedViewModel = new PatcherViewModel();
Locator.CurrentMutable.RegisterConstant(navigator, typeof(ViewNavigator));
}
}
}

View File

@ -0,0 +1,19 @@
using ReactiveUI;
namespace PatchClient.ViewModels
{
public class MessageViewModel : ViewModelBase
{
private string _InfoText;
public string InfoText
{
get => _InfoText;
set => this.RaiseAndSetIfChanged(ref _InfoText, value);
}
public MessageViewModel(string Message)
{
InfoText = Message;
}
}
}

View File

@ -0,0 +1,92 @@
using Avalonia;
using PatchClient.Models;
using PatcherUtils;
using ReactiveUI;
using Splat;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
namespace PatchClient.ViewModels
{
public class PatcherViewModel : ViewModelBase
{
private bool initLineItemProgress = true;
public ObservableCollection<LineItemProgress> LineItems { get; set; } = new ObservableCollection<LineItemProgress>();
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);
}
private string _PatchMessage;
public string PatchMessage
{
get => _PatchMessage;
set => this.RaiseAndSetIfChanged(ref _PatchMessage, value);
}
private ViewNavigator navigator => Locator.Current.GetService<ViewNavigator>();
public PatcherViewModel()
{
RunPatcher();
}
private void RunPatcher()
{
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);
patcher.ProgressChanged += patcher_ProgressChanged;
string message = patcher.ApplyPatches();
navigator.SelectedViewModel = new MessageViewModel(message).WithDelay(400);
});
}
private void patcher_ProgressChanged(object Sender, int Progress, int Total, int Percent, string Message = "", params LineItem[] AdditionalLineItems)
{
foreach (LineItem item in AdditionalLineItems)
{
if (initLineItemProgress)
{
if (item.ItemValue <= 0) continue;
LineItems.Add(new LineItemProgress(item));
}
LineItems.FirstOrDefault(x => x.Info == item.ItemText).UpdateProgress(item.ItemValue);
}
initLineItemProgress = false;
PatchPercent = Percent;
if (!string.IsNullOrWhiteSpace(Message))
{
PatchMessage = Message;
}
ProgressMessage = $"Patching: {Progress} / {Total} - {Percent}%";
}
}
}

View File

@ -0,0 +1,22 @@
using PatchClient.Models;
using ReactiveUI;
namespace PatchClient.ViewModels
{
public class ViewModelBase : ReactiveObject
{
/// <summary>
/// Delay the return of the viewmodel
/// </summary>
/// <param name="Milliseconds">The amount of time in milliseconds to delay</param>
/// <returns>The viewmodel after the delay time</returns>
/// <remarks>Useful to delay the navigation to another view via the <see cref="ViewNavigator"/>. For instance, to allow an animation to complete.</remarks>
public ViewModelBase WithDelay(int Milliseconds)
{
System.Threading.Thread.Sleep(Milliseconds);
return this;
}
}
}

View File

@ -0,0 +1,37 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:PatchClient.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cc="using:PatchClient.CustomControls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchClient.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="Patch Client"
Height="240" Width="600"
WindowStartupLocation="CenterScreen"
ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaChromeHints="NoChrome"
ExtendClientAreaTitleBarHeightHint="-1"
Background="{StaticResource AKI_Background_Light}"
>
<Window.Styles>
<StyleInclude Source="/Assets/Styles.axaml"/>
</Window.Styles>
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<Grid RowDefinitions="AUTO,*">
<cc:TitleBar Title="Patch Client"
XButtonCommand="{Binding CloseCommand}"/>
<DockPanel LastChildFill="True" Grid.Row="1">
<ContentControl Content="{Binding navigator.SelectedViewModel}"/>
</DockPanel>
</Grid>
</Window>

View File

@ -0,0 +1,22 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace PatchClient.Views
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,20 @@
<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="PatchClient.Views.MessageView">
<UserControl.Styles>
<StyleInclude Source="/Assets/Styles.axaml"/>
</UserControl.Styles>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Label Content="You can close this window"
FontSize="12" FontWeight="SemiBold"/>
<Label Content="{Binding InfoText}"
Classes="yellow"
/>
</StackPanel>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace PatchClient.Views
{
public partial class MessageView : UserControl
{
public MessageView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,51 @@
<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"
xmlns:model="using:PatchClient.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchClient.Views.PatcherView">
<UserControl.Styles>
<StyleInclude Source="/Assets/Styles.axaml"/>
<Style Selector="Label">
<Setter Property="Margin" Value="0 0 0 5"/>
</Style>
</UserControl.Styles>
<Grid RowDefinitions="AUTO,AUTO,AUTO,AUTO,AUTO" Margin="10">
<!-- Current Patch Text -->
<Label Content="{Binding ProgressMessage}"/>
<Label Content="{Binding PatchMessage}" Grid.Row="1"
Classes="dark"/>
<ProgressBar Grid.Row="2" Value="{Binding PatchPercent}"/>
<Separator Grid.Row="3"
VerticalAlignment="Bottom"
Height="1"
Margin="0 20"/>
<!-- Line Item Info -->
<ItemsControl Items="{Binding LineItems}" Grid.Row="4">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type model:LineItemProgress}">
<Grid ColumnDefinitions="AUTO,3*,AUTO,*,AUTO">
<Label Content="{Binding Info}"
/>
<Label Content="{Binding ProgressInfo}" Grid.Column="2"
FontSize="12"/>
<ProgressBar Value="{Binding Progress}" Grid.Column="4"
Margin="0 0 0 4"
VerticalAlignment="Center"
Width="200" MaxWidth="200"
Classes.done="{Binding Completed}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace PatchClient.Views
{
public partial class PatcherView : UserControl
{
public PatcherView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

454
Patcher/PatchGenerator/.gitignore vendored Normal file
View File

@ -0,0 +1,454 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# Tye
.tye/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# JetBrains Rider
.idea/
*.sln.iml
##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

View File

@ -0,0 +1,29 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PatchGenerator"
x:Class="PatchGenerator.App"
>
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme Mode="Light"/>
</Application.Styles>
<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_Brush_Yellow" Color="{StaticResource AKI_Yellow}"/>
<SolidColorBrush x:Key="AKI_Brush_DarkGrayBlue" Color="{StaticResource AKI_DarkGrayBlue}"/>
</Application.Resources>
</Application>

View File

@ -0,0 +1,40 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using PatchGenerator.Models;
using PatchGenerator.ViewModels;
using PatchGenerator.Views;
namespace PatchGenerator
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.Startup += Desktop_Startup;
}
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)
};
}
}
}
}

View File

@ -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>

View File

@ -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();
}
}
}

View File

@ -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)
)]

View File

@ -0,0 +1,142 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="using:PatchGenerator.CustomControls">
<Design.PreviewWith>
<Border Padding="10" Background="{StaticResource AKI_Background_Light}">
<!-- Add Controls for Previewer Here -->
<StackPanel Background="{StaticResource AKI_Background_Light}" Spacing="15" Margin="10">
<cc:TitleBar Title="Title Bar Text"/>
<Label Content="Normal label"/>
<Label Content="Yellow label" Classes="yellow"/>
<Label Content="Blue label" Classes="dark"/>
<ProgressBar Value="40"/>
<Separator Height="1"/>
<ProgressBar Value="60" Classes="done"/>
<Button Content="Press Me :)" IsEnabled="True"/>
<CheckBox Content="Check .. Me Out! ba-dum-tss"/>
<TextBox Text="Some Text Here" />
</StackPanel>
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<!-- TitleBar Styles -->
<Style Selector="cc|TitleBar">
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
<Setter Property="XButtonForeground" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
</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">
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
</Style>
<Style Selector="Label.yellow">
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
</Style>
<Style Selector="Label.dark">
<Setter Property="Foreground" Value="DimGray"/>
</Style>
<!-- ProgressBar Styles -->
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml -->
<Style Selector="ProgressBar">
<Setter Property="Foreground" Value="{StaticResource AKI_Brush_Yellow}"/>
</Style>
<Style Selector="ProgressBar.done">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="Transitions">
<Transitions>
<BrushTransition Property="Foreground" Duration="0:0:1"/>
</Transitions>
</Setter>
</Style>
<Style Selector="ProgressBar.done /template/ Border">
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="Width" Value="5"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Style.Animations>
<Animation Duration="0:0:0.2" FillMode="Forward">
<KeyFrame Cue="0%">
<Setter Property="Width" Value="200"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Width" Value="5"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<!-- Seperator Styles -->
<!-- SourceRef: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Separator.xaml -->
<Style Selector="Separator">
<Setter Property="Background" Value="{StaticResource AKI_Background_Dark}"/>
</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>
<Style Selector="Button:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
</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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -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);
}
}
}

View File

@ -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>

View File

@ -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);
}
}
}

View File

@ -0,0 +1,45 @@
<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.TitleBar">
<Grid ColumnDefinitions="AUTO,*,AUTO">
<Rectangle Grid.ColumnSpan="3" IsHitTestVisible="False"
Fill="{Binding Background, RelativeSource={
RelativeSource AncestorType=UserControl}}"
/>
<Label Content="{Binding Title, RelativeSource={
RelativeSource AncestorType=UserControl}}"
IsHitTestVisible="False"
Foreground="{Binding Foreground, RelativeSource={
RelativeSource AncestorType=UserControl}}"
Background="Transparent"
VerticalContentAlignment="Center"
/>
<Button Content="&#xE106;" Grid.Column="2"
Foreground="{Binding XButtonForeground, RelativeSource={
RelativeSource AncestorType=UserControl}}"
Command="{Binding XButtonCommand, RelativeSource={
RelativeSource AncestorType=UserControl}}"
Background="Transparent"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
VerticalAlignment="Stretch"
FontFamily="Segoe MDL2 Assets"
CornerRadius="0"
Width="35"
>
<Button.Styles>
<Style Selector="Button:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="IndianRed"/>
</Style>
<Style Selector="Button:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="Crimson"/>
</Style>
</Button.Styles>
</Button>
</Grid>
</UserControl>

View File

@ -0,0 +1,67 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using System.Windows.Input;
namespace PatchGenerator.CustomControls
{
public partial class TitleBar : UserControl
{
public TitleBar()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public static readonly StyledProperty<string> TitleProperty =
AvaloniaProperty.Register<TitleBar, string>(nameof(Title));
public string Title
{
get => GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public static readonly StyledProperty<IBrush> XButtonForegroundProperty =
AvaloniaProperty.Register<TitleBar, IBrush>(nameof(XButtonForeground));
public IBrush XButtonForeground
{
get => GetValue(XButtonForegroundProperty);
set => SetValue(XButtonForegroundProperty, value);
}
public static new readonly StyledProperty<IBrush> ForegroundProperty =
AvaloniaProperty.Register<TitleBar, IBrush>(nameof(Foreground));
public new IBrush Foreground
{
get => GetValue(ForegroundProperty);
set => SetValue(ForegroundProperty, value);
}
public static new readonly StyledProperty<IBrush> BackgroundProperty =
AvaloniaProperty.Register<TitleBar, IBrush>(nameof(Background));
public new IBrush Background
{
get => GetValue(BackgroundProperty);
set => SetValue(BackgroundProperty, value);
}
//Close Button Command (X Button) Property
public static readonly StyledProperty<ICommand> XButtonCommandProperty =
AvaloniaProperty.Register<TitleBar, ICommand>(nameof(XButtonCommand));
public ICommand XButtonCommand
{
get => GetValue(XButtonCommandProperty);
set => SetValue(XButtonCommandProperty, value);
}
}
}

View File

@ -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;
});
}
}
}

View File

@ -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 }
};
}
}

View File

@ -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>

View File

@ -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;
}
}
}

View File

@ -1,22 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PatchGenerator
namespace PatchGenerator.Models
{
public class GenStartupArgs
{
public bool ReadyToRun => OutputFolderName != "" && CompareFolderPath != "" && TargetFolderPath != "";
public bool ReadyToRun => OutputFolderName != "" && SourceFolderPath != "" && TargetFolderPath != "";
public string OutputFolderName { get; private set; } = "";
public string CompareFolderPath { 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 CompareFolderPath, string TargetFolderPath, bool AutoZip)
protected GenStartupArgs(string OutputFolderName, string SourceFolderPath, string TargetFolderPath, bool AutoZip)
{
this.OutputFolderName = OutputFolderName;
this.CompareFolderPath = CompareFolderPath;
this.SourceFolderPath = SourceFolderPath;
this.TargetFolderPath = TargetFolderPath;
this.AutoZip = AutoZip;
}
@ -25,10 +19,10 @@ namespace PatchGenerator
{
if (Args == null || Args.Length == 0) return null;
string ofn = "";
string cfp = "";
string tfp = "";
bool az = true;
string outputFolderPath = "";
string sourceFolderPath = "";
string targetFolderPath = "";
bool autoZip = true;
foreach (string arg in Args)
{
@ -40,28 +34,28 @@ namespace PatchGenerator
{
case "OutputFolderName":
{
ofn = argSplit[1];
outputFolderPath = argSplit[1];
break;
}
case "CompareFolderPath":
case "SourceFolderPath":
{
cfp = argSplit[1];
sourceFolderPath = argSplit[1];
break;
}
case "TargetFolderPath":
{
tfp = argSplit[1];
targetFolderPath = argSplit[1];
break;
}
case "AutoZip":
{
az = bool.Parse(argSplit[1]);
autoZip = bool.Parse(argSplit[1]);
break;
}
}
}
return new GenStartupArgs(ofn, cfp, tfp, az);
return new GenStartupArgs(outputFolderPath, sourceFolderPath, targetFolderPath, autoZip);
}
}
}

View 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);
}
}
}

View 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"];
}
}
}
}

View File

@ -0,0 +1,14 @@
using ReactiveUI;
namespace PatchGenerator.Models
{
public class ViewNavigator : ReactiveObject
{
private object _SelectedViewModel;
public object SelectedViewModel
{
get => _SelectedViewModel;
set => this.RaiseAndSetIfChanged(ref _SelectedViewModel, value);
}
}
}

View File

@ -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>

View File

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<TargetFramework>net6.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@ -16,4 +16,21 @@
</Reference>
</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>

View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;
namespace PatchGenerator
{
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
}
}

View 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\\"
}
}
}

View File

@ -0,0 +1,30 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using PatchGenerator.ViewModels;
using System;
namespace PatchGenerator
{
public class ViewLocator : IDataTemplate
{
public IControl Build(object data)
{
var name = data.GetType().FullName!.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
}
public bool Match(object data)
{
return data is ViewModelBase;
}
}
}

View File

@ -0,0 +1,40 @@
using Avalonia;
using PatchGenerator.Models;
using ReactiveUI;
using Splat;
using System.Windows.Input;
namespace PatchGenerator.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
public ICommand CloseCommand => ReactiveCommand.Create(() =>
{
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
{
desktopApp.MainWindow.Close();
}
});
public ViewNavigator navigator { get; set; } = new ViewNavigator();
public MainWindowViewModel(GenStartupArgs genArgs = null)
{
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();
}
}
}

View File

@ -0,0 +1,23 @@
using PatchGenerator.Models;
using Splat;
namespace PatchGenerator.ViewModels
{
public class OptionsViewModel : ViewModelBase
{
public PatchGenInfo GenerationInfo { get; set; } = new PatchGenInfo();
private ViewNavigator navigator => Locator.Current.GetService<ViewNavigator>();
public OptionsViewModel()
{
GenerationInfo.SourceFolderPath = "Drop SOURCE folder here";
GenerationInfo.TargetFolderPath = "Drop TARGET folder here";
}
public void GeneratePatches()
{
navigator.SelectedViewModel = new PatchGenerationViewModel(GenerationInfo);
}
}
}

View File

@ -0,0 +1,132 @@
using Avalonia;
using Avalonia.Media;
using PatcherUtils;
using PatchGenerator.Helpers;
using PatchGenerator.Models;
using ReactiveUI;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace PatchGenerator.ViewModels
{
public class PatchGenerationViewModel : ViewModelBase
{
private bool _AutoScroll = true;
public bool AutoScroll
{
get => _AutoScroll;
set => this.RaiseAndSetIfChanged(ref _AutoScroll, value);
}
private string _ProgressMessage;
public string ProgressMessage
{
get => _ProgressMessage;
set => this.RaiseAndSetIfChanged(ref _ProgressMessage, value);
}
private int _PatchPercent;
public int PatchPercent
{
get => _PatchPercent;
set => this.RaiseAndSetIfChanged(ref _PatchPercent, value);
}
public ObservableCollection<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
//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 patchOutputFolder = Path.Join(generationInfo.PatchName.FromCwd(), LazyOperations.PatchFolder);
PatchHelper patcher = new PatchHelper(generationInfo.SourceFolderPath, generationInfo.TargetFolderPath, patchOutputFolder);
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();
File.Copy(LazyOperations.PatcherClientPath, $"{generationInfo.PatchName.FromCwd()}\\patcher.exe", true);
if (generationInfo.AutoZip)
{
LazyOperations.StartZipProcess(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.zip".FromCwd());
}
});
}
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));
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
});
}
}
}
}
}
}
}

View File

@ -0,0 +1,8 @@
using ReactiveUI;
namespace PatchGenerator.ViewModels
{
public class ViewModelBase : ReactiveObject
{
}
}

View File

@ -0,0 +1,37 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:PatchGenerator.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cc="using:PatchGenerator.CustomControls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchGenerator.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="PatchGenerator"
Height="400" Width="800"
WindowStartupLocation="CenterScreen"
ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaChromeHints="NoChrome"
ExtendClientAreaTitleBarHeightHint="-1"
Background="{StaticResource AKI_Background_Light}"
>
<Window.Styles>
<StyleInclude Source="/Assets/Styles.axaml"/>
</Window.Styles>
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<Grid RowDefinitions="AUTO,*">
<cc:TitleBar Title="Patch Generator"
XButtonCommand="{Binding CloseCommand}"/>
<DockPanel LastChildFill="True" Grid.Row="1">
<ContentControl Content="{Binding navigator.SelectedViewModel}"/>
</DockPanel>
</Grid>
</Window>

View File

@ -0,0 +1,22 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace PatchGenerator.Views
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,34 @@
<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"
xmlns:cc="using:PatchGenerator.CustomControls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchGenerator.Views.OptionsView">
<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>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace PatchGenerator.Views
{
public partial class OptionsView : UserControl
{
public OptionsView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,72 @@
<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"
xmlns:model="using:PatchGenerator.Models"
xmlns:cc="using:PatchGenerator.CustomControls"
xmlns:att="using:PatchGenerator.AttachedProperties"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PatchGenerator.Views.PatchGenerationView">
<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>

View File

@ -0,0 +1,32 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using PatchGenerator.AttachedProperties;
namespace PatchGenerator.Views
{
public partial class PatchGenerationView : UserControl
{
public PatchGenerationView()
{
InitializeComponent();
}
private void InitializeComponent()
{
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();
}
}
}
}
}

View File

@ -1,13 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31515.178
VisualStudioVersion = 16.0.31727.386
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
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
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,23 +15,23 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DDB70566-994E-4884-8555-C005B238039B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDB70566-994E-4884-8555-C005B238039B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDB70566-994E-4884-8555-C005B238039B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDB70566-994E-4884-8555-C005B238039B}.Release|Any CPU.Build.0 = Release|Any CPU
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9819B34-8111-4344-B2B3-3DE5D7A43A45}.Release|Any CPU.Build.0 = Release|Any CPU
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CA4D2BD-6596-41D1-8354-135868DF8DAB}.Release|Any CPU.Build.0 = Release|Any CPU
{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 = {A9AA1062-33C6-49F2-880C-067D44041C4A}
SolutionGuid = {07AD7FB8-3529-4A2A-BDD5-76F779273B9B}
EndGlobalSection
EndGlobal

View File

@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Reflection;

View File

@ -3,10 +3,9 @@
public class LineItem
{
public string ItemText;
public string ItemValue;
public bool HasValue => ItemValue != "";
public int ItemValue;
public LineItem(string ItemText, string ItemValue = "")
public LineItem(string ItemText, int ItemValue = 0)
{
this.ItemText = ItemText;
this.ItemValue = ItemValue;

View File

@ -1,10 +1,9 @@
using Aki.Common.Utils;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace PatcherUtils
{
@ -20,9 +19,14 @@ namespace PatcherUtils
private int deltaCount;
private int newCount;
private int delCount;
private int existCount;
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)
@ -32,6 +36,13 @@ namespace PatcherUtils
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;
@ -39,11 +50,42 @@ namespace PatcherUtils
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)
{
string decodedPath = SourceFilePath + ".decoded";
@ -58,11 +100,16 @@ namespace PatcherUtils
if (File.Exists(decodedPath))
{
File.Delete(SourceFilePath);
File.Move(decodedPath, SourceFilePath);
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);
@ -82,6 +129,11 @@ namespace PatcherUtils
.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);
@ -93,6 +145,11 @@ namespace PatcherUtils
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);
@ -104,6 +161,11 @@ namespace PatcherUtils
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
@ -118,14 +180,18 @@ namespace PatcherUtils
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"));
AdditionalInfo.Add(new LineItem("Delta Patch", 0));
AdditionalInfo.Add(new LineItem("New Patch", 0));
AdditionalInfo.Add(new LineItem("Del Patch", 0));
AdditionalInfo.Add(new LineItem("File Exists", 0));
filesProcessed = 0;
@ -144,23 +210,34 @@ namespace PatcherUtils
newCount++;
filesProcessed++;
RaiseProgressChanged(filesProcessed, fileCountTotal, targetFile.Name, AdditionalInfo.ToArray());
RaiseProgressChanged(filesProcessed, fileCountTotal, $"{targetFile.FullName.Replace(TargetFolder, "...")}.new", AdditionalInfo.ToArray());
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);
extension = ".delta";
deltaCount++;
}
else
{
existCount++;
}
SourceFiles.Remove(sourceFile);
deltaCount++;
filesProcessed++;
AdditionalInfo[0].ItemValue = deltaCount.ToString();
AdditionalInfo[1].ItemValue = newCount.ToString();
AdditionalInfo[0].ItemValue = deltaCount;
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.
@ -175,15 +252,19 @@ namespace PatcherUtils
delCount++;
AdditionalInfo[2].ItemValue = delCount.ToString();
AdditionalInfo[2].ItemValue = delCount;
filesProcessed++;
RaiseProgressChanged(filesProcessed, fileCountTotal, "", AdditionalInfo.ToArray());
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
@ -196,6 +277,9 @@ namespace PatcherUtils
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();
@ -207,9 +291,9 @@ namespace PatcherUtils
AdditionalInfo = new List<LineItem>()
{
new LineItem("Patches Remaining", deltaCount.ToString()),
new LineItem("New Files to Add", newCount.ToString()),
new LineItem("Files to Delete", delCount.ToString())
new LineItem("Patches Remaining", deltaCount),
new LineItem("New Files to Add", newCount),
new LineItem("Files to Delete", delCount)
};
filesProcessed = 0;
@ -238,10 +322,15 @@ namespace PatcherUtils
}
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);
File.Copy(deltaFile.FullName, destination, true);
newCount--;
@ -260,9 +349,9 @@ namespace PatcherUtils
}
}
AdditionalInfo[0].ItemValue = deltaCount.ToString();
AdditionalInfo[1].ItemValue = newCount.ToString();
AdditionalInfo[2].ItemValue = delCount.ToString();
AdditionalInfo[0].ItemValue = deltaCount;
AdditionalInfo[1].ItemValue = newCount;
AdditionalInfo[2].ItemValue = delCount;
++filesProcessed;
RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray());

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -2,3 +2,9 @@
Allows for generating and applying patches to software.
Currently used for downgrading EFT.
## Requirements
- .net 6
## Development Stuff
- VS 2022 w/ Avalonia VS Extension