mirror of
https://github.com/sp-tarkov/patcher.git
synced 2025-02-13 00:50:46 -05:00
Merge pull request 'add patch client exit codes and startup arg to auto-close' (#6) from feature/client-startup-args into main
Reviewed-on: waffle.lord/Patcher#6
This commit is contained in:
commit
7e98381172
@ -17,9 +17,14 @@ namespace PatchClient
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
bool autoClose = false;
|
||||
|
||||
if(desktop.Args != null && desktop.Args[0].ToLower() == "autoclose")
|
||||
autoClose = true;
|
||||
|
||||
desktop.MainWindow = new MainWindow
|
||||
{
|
||||
DataContext = new MainWindowViewModel(),
|
||||
DataContext = new MainWindowViewModel(autoClose),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,11 @@ namespace PatchClient.ViewModels
|
||||
}
|
||||
});
|
||||
|
||||
public MainWindowViewModel()
|
||||
public MainWindowViewModel(bool autoClose)
|
||||
{
|
||||
this.WhenActivated((CompositeDisposable disposable) =>
|
||||
{
|
||||
Router.Navigate.Execute(new PatcherViewModel(this));
|
||||
Router.Navigate.Execute(new PatcherViewModel(this, autoClose));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ namespace PatchClient.ViewModels
|
||||
{
|
||||
public class PatcherViewModel : ViewModelBase
|
||||
{
|
||||
private bool initLineItemProgress = true;
|
||||
|
||||
private bool _initLineItemProgress = true;
|
||||
private bool _autoClose = false;
|
||||
public ObservableCollection<LineItemProgress> LineItems { get; set; } = new ObservableCollection<LineItemProgress>();
|
||||
|
||||
private string _ProgressMessage = "";
|
||||
@ -40,13 +40,21 @@ namespace PatchClient.ViewModels
|
||||
}
|
||||
|
||||
|
||||
public PatcherViewModel(IScreen Host) : base(Host)
|
||||
public PatcherViewModel(IScreen Host, bool autoClose) : base(Host)
|
||||
{
|
||||
_autoClose = autoClose;
|
||||
|
||||
this.WhenActivated((CompositeDisposable disposables) =>
|
||||
{
|
||||
//check if escapefromtarkov.exe is present
|
||||
if(!File.Exists(Path.Join(Directory.GetCurrentDirectory(), "escapefromtarkov.exe")))
|
||||
{
|
||||
if (_autoClose)
|
||||
{
|
||||
Environment.Exit((int)PatcherExitCode.EftExeNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
NavigateTo(new MessageViewModel(HostScreen, "EscapeFromTarkov.exe was not found. Please ensure you have copied the patcher to your SPT folder."));
|
||||
return;
|
||||
}
|
||||
@ -54,6 +62,12 @@ namespace PatchClient.ViewModels
|
||||
//check if patch folder is present
|
||||
if(!Directory.Exists(LazyOperations.PatchFolder))
|
||||
{
|
||||
if (_autoClose)
|
||||
{
|
||||
Environment.Exit((int)PatcherExitCode.NoPatchFolder);
|
||||
return;
|
||||
}
|
||||
|
||||
NavigateTo(new MessageViewModel(HostScreen, $"{LazyOperations.PatchFolder} folder is missing. Please copy it to\n'{Environment.CurrentDirectory}'\nand try patching again."));
|
||||
return;
|
||||
}
|
||||
@ -72,13 +86,18 @@ namespace PatchClient.ViewModels
|
||||
|
||||
patcher.ProgressChanged += patcher_ProgressChanged;
|
||||
|
||||
string message = patcher.ApplyPatches();
|
||||
var patchMessage = patcher.ApplyPatches();
|
||||
|
||||
LazyOperations.CleanupTempDir();
|
||||
|
||||
Directory.Delete(LazyOperations.PatchFolder, true);
|
||||
|
||||
await NavigateToWithDelay(new MessageViewModel(HostScreen, message), 400);
|
||||
if(_autoClose)
|
||||
{
|
||||
Environment.Exit((int)patchMessage.ExitCode);
|
||||
}
|
||||
|
||||
await NavigateToWithDelay(new MessageViewModel(HostScreen, patchMessage.Message), 400);
|
||||
});
|
||||
}
|
||||
|
||||
@ -89,7 +108,7 @@ namespace PatchClient.ViewModels
|
||||
foreach (LineItem item in AdditionalLineItems)
|
||||
{
|
||||
|
||||
if (initLineItemProgress)
|
||||
if (_initLineItemProgress)
|
||||
{
|
||||
LineItems.Add(new LineItemProgress(item));
|
||||
}
|
||||
@ -97,7 +116,7 @@ namespace PatchClient.ViewModels
|
||||
LineItems.FirstOrDefault(x => x.Info == item.ItemText).UpdateProgress(item.ItemValue);
|
||||
}
|
||||
|
||||
initLineItemProgress = false;
|
||||
_initLineItemProgress = false;
|
||||
|
||||
PatchPercent = Percent;
|
||||
|
||||
|
BIN
Patcher/PatchGenerator/Resources/PatchClient.exe
(Stored with Git LFS)
BIN
Patcher/PatchGenerator/Resources/PatchClient.exe
(Stored with Git LFS)
Binary file not shown.
16
Patcher/PatcherUtils/Model/PatchMessage.cs
Normal file
16
Patcher/PatcherUtils/Model/PatchMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using PatchClient.Models;
|
||||
|
||||
namespace PatcherUtils.Model
|
||||
{
|
||||
public class PatchMessage
|
||||
{
|
||||
public string Message { get; private set; }
|
||||
public PatcherExitCode ExitCode { get; private set; }
|
||||
|
||||
public PatchMessage(string message, PatcherExitCode exitCode)
|
||||
{
|
||||
Message = message;
|
||||
ExitCode = exitCode;
|
||||
}
|
||||
}
|
||||
}
|
11
Patcher/PatcherUtils/Model/PatcherExitCode.cs
Normal file
11
Patcher/PatcherUtils/Model/PatcherExitCode.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace PatchClient.Models
|
||||
{
|
||||
public enum PatcherExitCode
|
||||
{
|
||||
Success = 0,
|
||||
EftExeNotFound = 10,
|
||||
NoPatchFolder = 11,
|
||||
MissingFile = 12,
|
||||
MissingDir = 13
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using PatchClient.Models;
|
||||
using PatcherUtils.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@ -267,7 +269,7 @@ namespace PatcherUtils
|
||||
/// Apply a set of patches using the source and delta folders specified during construction.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ApplyPatches()
|
||||
public PatchMessage ApplyPatches()
|
||||
{
|
||||
//get needed directory information
|
||||
DirectoryInfo sourceDir = new DirectoryInfo(SourceFolder);
|
||||
@ -276,7 +278,7 @@ namespace PatcherUtils
|
||||
//check directories exist
|
||||
if (!sourceDir.Exists || !deltaDir.Exists)
|
||||
{
|
||||
return "One of the supplied directories doesn't exist";
|
||||
return new PatchMessage("One of the supplied directories doesn't exist", PatcherExitCode.MissingDir);
|
||||
}
|
||||
|
||||
LazyOperations.ExtractResourcesToTempDir();
|
||||
@ -312,7 +314,7 @@ namespace PatcherUtils
|
||||
|
||||
if (sourceFile == null)
|
||||
{
|
||||
return $"Failed to find matching source file for '{deltaFile.FullName}'";
|
||||
return new PatchMessage($"Failed to find matching source file for '{deltaFile.FullName}'", PatcherExitCode.MissingFile);
|
||||
}
|
||||
|
||||
ApplyDelta(sourceFile.FullName, deltaFile.FullName);
|
||||
@ -358,7 +360,7 @@ namespace PatcherUtils
|
||||
RaiseProgressChanged(filesProcessed, fileCountTotal, deltaFile.Name, AdditionalInfo.ToArray());
|
||||
}
|
||||
|
||||
return $"Patching Complete. You can delete the patcher.exe file.";
|
||||
return new PatchMessage($"Patching Complete. You can delete the patcher.exe file.", PatcherExitCode.Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user