Merge pull request 'bug fixes, ui tweaks, additional logging' (#15) from waffle.lord/SPT-AKI-Installer:ui-tweaks into master
Reviewed-on: CWX/SPT-AKI-Installer#15
This commit is contained in:
commit
96bf6aaf63
@ -1,4 +1,5 @@
|
||||
using HttpClientProgress;
|
||||
using Serilog;
|
||||
using SPTInstaller.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -24,6 +25,7 @@ namespace SPTInstaller.Aki.Helper
|
||||
{
|
||||
if (expectedHash != null && FileHashHelper.CheckHash(cacheFile, expectedHash))
|
||||
{
|
||||
Log.Information($"Using cached file: {cacheFile.Name}");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
var originalGameDirInfo = new DirectoryInfo(_data.OriginalGamePath);
|
||||
var targetInstallDirInfo = new DirectoryInfo(_data.TargetInstallPath);
|
||||
|
||||
return FileHelper.CopyDirectoryWithProgress(originalGameDirInfo, targetInstallDirInfo, (message, progress) => { SetStatus($"Copying Client Files", message, progress, null, true); });
|
||||
return FileHelper.CopyDirectoryWithProgress(originalGameDirInfo, targetInstallDirInfo, (message, progress) => { SetStatus(null, message, progress, null, true); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
public override async Task<IResult> TaskOperation()
|
||||
{
|
||||
var progress = new Progress<double>((d) => { SetStatus("", "", (int)Math.Floor(d)); });
|
||||
var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); });
|
||||
|
||||
if (_data.PatchNeeded)
|
||||
{
|
||||
@ -101,7 +101,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
return buildResult;
|
||||
}
|
||||
|
||||
SetStatus("", "", 0);
|
||||
SetStatus(null, null, 0);
|
||||
|
||||
var patcherDownloadRresult = await DownloadPatcherFromMirrors(progress);
|
||||
|
||||
@ -111,7 +111,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
}
|
||||
}
|
||||
|
||||
SetStatus("Downloading SPT-AKI", "", 0);
|
||||
SetStatus("Downloading SPT-AKI", _data.AkiReleaseDownloadLink, 0);
|
||||
|
||||
_data.AkiZipInfo = await DownloadCacheHelper.GetOrDownloadFileAsync("sptaki.zip", _data.AkiReleaseDownloadLink, progress, _data.AkiReleaseHash);
|
||||
|
||||
|
@ -17,6 +17,8 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
public override async Task<IResult> TaskOperation()
|
||||
{
|
||||
SetStatus("Initializing", "");
|
||||
|
||||
_data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
|
||||
|
||||
if (_data.OriginalGamePath == null)
|
||||
@ -35,7 +37,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
if (_data.OriginalGamePath == null)
|
||||
{
|
||||
return Result.FromError("Unable to find EFT OG directory, please make sure EFT is installed. Please also run EFT once");
|
||||
return Result.FromError("Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once");
|
||||
}
|
||||
|
||||
if (_data.OriginalGamePath == _data.TargetInstallPath)
|
||||
@ -45,10 +47,9 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
if (File.Exists(Path.Join(_data.TargetInstallPath, "EscapeFromTarkov.exe")))
|
||||
{
|
||||
return Result.FromError("Installer is located in a Folder that has existing Game Files. Please make sure the installer is in a fresh folder as per the guide");
|
||||
return Result.FromError("Installer is located in a folder that has existing game files. Please make sure the installer is in a fresh folder as per the guide");
|
||||
}
|
||||
|
||||
|
||||
return Result.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
status += " - Patch Available";
|
||||
}
|
||||
|
||||
SetStatus("", status);
|
||||
SetStatus(null, status);
|
||||
|
||||
return Result.FromSuccess(status);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
var patcherEXE = new FileInfo(Path.Join(_data.TargetInstallPath, "patcher.exe"));
|
||||
|
||||
var progress = new Progress<double>((d) => { SetStatus("", "", (int)Math.Floor(d)); });
|
||||
var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); });
|
||||
|
||||
|
||||
if (_data.PatchNeeded)
|
||||
|
@ -91,15 +91,15 @@ namespace SPTInstaller.Models
|
||||
/// <summary>
|
||||
/// Update the status details of the task
|
||||
/// </summary>
|
||||
/// <param name="message">The main message to display. Not updated if empty</param>
|
||||
/// <param name="details">The details of the task. Not updated if empty</param>
|
||||
/// <param name="progress">Progress of the task. Not empty if null. Overrides progressStyle if a non-null value is supplied</param>
|
||||
/// <param name="message">The main message to display. Not updated if null</param>
|
||||
/// <param name="details">The details of the task. Not updated if null</param>
|
||||
/// <param name="progress">Progress of the task. Overrides progressStyle if a non-null value is supplied</param>
|
||||
/// <param name="progressStyle">The style of the progress bar</param>
|
||||
public void SetStatus(string message, string details, int? progress = null, ProgressStyle? progressStyle = null, bool noLog = false)
|
||||
public void SetStatus(string? message, string? details, int? progress = null, ProgressStyle? progressStyle = null, bool noLog = false)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(message) && message != StatusMessage)
|
||||
if(message != null && message != StatusMessage)
|
||||
{
|
||||
if (!noLog)
|
||||
if (!noLog && !string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
Log.Information($" <===> {message} <===>");
|
||||
}
|
||||
@ -107,9 +107,9 @@ namespace SPTInstaller.Models
|
||||
StatusMessage = message;
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(details) && details != StatusDetails)
|
||||
if(details != null && details != StatusDetails)
|
||||
{
|
||||
if (!noLog)
|
||||
if (!noLog && !string.IsNullOrWhiteSpace(details))
|
||||
{
|
||||
Log.Information(details);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace SPTInstaller.ViewModels
|
||||
{
|
||||
var result = await installer.RunTasks();
|
||||
|
||||
NavigateTo(new MessageViewModel(HostScreen, result.Message));
|
||||
NavigateTo(new MessageViewModel(HostScreen, result));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,20 @@
|
||||
using Avalonia;
|
||||
using ReactiveUI;
|
||||
using Serilog;
|
||||
using SPTInstaller.Interfaces;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace SPTInstaller.ViewModels
|
||||
{
|
||||
public class MessageViewModel : ViewModelBase
|
||||
{
|
||||
private bool _HasErrors;
|
||||
public bool HasErrors
|
||||
{
|
||||
get => _HasErrors;
|
||||
set => this.RaiseAndSetIfChanged(ref _HasErrors, value);
|
||||
}
|
||||
|
||||
private string _Message;
|
||||
public string Message
|
||||
{
|
||||
@ -22,10 +30,18 @@ namespace SPTInstaller.ViewModels
|
||||
}
|
||||
});
|
||||
|
||||
public MessageViewModel(IScreen Host, string message) : base(Host)
|
||||
public MessageViewModel(IScreen Host, IResult result) : base(Host)
|
||||
{
|
||||
Message = message;
|
||||
Log.Information(message);
|
||||
Message = result.Message;
|
||||
|
||||
if(result.Succeeded)
|
||||
{
|
||||
Log.Information(Message);
|
||||
return;
|
||||
}
|
||||
|
||||
HasErrors = true;
|
||||
Log.Error(Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace SPTInstaller.ViewModels
|
||||
|
||||
if(data == null || installer == null)
|
||||
{
|
||||
NavigateTo(new MessageViewModel(HostScreen, "Failed to get required service for prechecks"));
|
||||
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Failed to get required service for prechecks")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ namespace SPTInstaller.ViewModels
|
||||
if(!result.Succeeded)
|
||||
{
|
||||
//if a required precheck fails, abort to message view
|
||||
NavigateTo(new MessageViewModel(HostScreen ,result.Message));
|
||||
NavigateTo(new MessageViewModel(HostScreen ,result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3,24 +3,37 @@
|
||||
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="SPTInstaller.Views.MessageView">
|
||||
<Grid ColumnDefinitions="*,AUTO,*" RowDefinitions="*,AUTO,*">
|
||||
x:Class="SPTInstaller.Views.MessageView"
|
||||
>
|
||||
<UserControl.Styles>
|
||||
<Style Selector="Grid.error">
|
||||
<Setter Property="Background" Value="#330000"/>
|
||||
</Style>
|
||||
<Style Selector="Label.error">
|
||||
<Setter Property="Foreground" Value="Crimson"/>
|
||||
</Style>
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Spacing="20">
|
||||
</UserControl.Styles>
|
||||
|
||||
<Label Content="{Binding Message}" FontSize="18"
|
||||
HorizontalAlignment="Center"
|
||||
<Grid ColumnDefinitions="*,AUTO,*" RowDefinitions="*,AUTO,20,AUTO,*"
|
||||
Classes.error="{Binding HasErrors}">
|
||||
|
||||
<Label Grid.Column="1" Grid.Row="1"
|
||||
Classes.error="{Binding HasErrors}">
|
||||
<TextBlock Text="{Binding Message}" FontSize="18"
|
||||
TextWrapping="Wrap"
|
||||
MaxWidth="500"
|
||||
HorizontalAlignment="Center"
|
||||
/>
|
||||
</Label>
|
||||
|
||||
<Button Content="Close" Command="{Binding CloseCommand}"
|
||||
<Button Grid.Column="1" Grid.Row="3"
|
||||
Content="Close" Command="{Binding CloseCommand}"
|
||||
FontSize="15" FontWeight="SemiBold"
|
||||
Classes="yellow"
|
||||
Classes.yellow="{Binding !HasErrors}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||
Padding="20 10"
|
||||
/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
Loading…
x
Reference in New Issue
Block a user