diff --git a/SPTInstaller/CustomControls/UpdateInfoCard.axaml b/SPTInstaller/CustomControls/UpdateInfoCard.axaml
index 5c7f528..d9f0772 100644
--- a/SPTInstaller/CustomControls/UpdateInfoCard.axaml
+++ b/SPTInstaller/CustomControls/UpdateInfoCard.axaml
@@ -20,6 +20,17 @@
+
+
+
diff --git a/SPTInstaller/CustomControls/UpdateInfoCard.axaml.cs b/SPTInstaller/CustomControls/UpdateInfoCard.axaml.cs
index a6c004f..95e79f6 100644
--- a/SPTInstaller/CustomControls/UpdateInfoCard.axaml.cs
+++ b/SPTInstaller/CustomControls/UpdateInfoCard.axaml.cs
@@ -26,6 +26,22 @@ public partial class UpdateInfoCard : UserControl
public static readonly StyledProperty UpdatingProperty =
AvaloniaProperty.Register(nameof(Updating));
+ public bool UpdateAvailable
+ {
+ get => GetValue(UpdateAvailableProperty);
+ set => SetValue(UpdateAvailableProperty, value);
+ }
+ public static readonly StyledProperty UpdateAvailableProperty =
+ AvaloniaProperty.Register(nameof(UpdateAvailable));
+
+ public bool IndeterminateProgress
+ {
+ get => GetValue(IndeterminateProgressProperty);
+ set => SetValue(IndeterminateProgressProperty, value);
+ }
+ public static readonly StyledProperty IndeterminateProgressProperty =
+ AvaloniaProperty.Register(nameof(IndeterminateProgress));
+
public string InfoText
{
get => GetValue(InfoTextProperty);
diff --git a/SPTInstaller/Models/InstallerUpdateInfo.cs b/SPTInstaller/Models/InstallerUpdateInfo.cs
index c798f97..2b6e956 100644
--- a/SPTInstaller/Models/InstallerUpdateInfo.cs
+++ b/SPTInstaller/Models/InstallerUpdateInfo.cs
@@ -20,18 +20,32 @@ public class InstallerUpdateInfo : ReactiveObject
set => this.RaiseAndSetIfChanged(ref _updateInfoText, value);
}
- private bool _updateAvailable;
+ private bool _showCard = false;
+ public bool ShowCard
+ {
+ get => _showCard;
+ set => this.RaiseAndSetIfChanged(ref _showCard, value);
+ }
+
+ private bool _updating = false;
+ public bool Updating
+ {
+ get => _updating;
+ set => this.RaiseAndSetIfChanged(ref _updating, value);
+ }
+
+ private bool _updateAvailable = false;
public bool UpdateAvailable
{
get => _updateAvailable;
set => this.RaiseAndSetIfChanged(ref _updateAvailable, value);
}
- private bool _updating;
- public bool Updating
+ private bool _checkingForUpdates = false;
+ public bool CheckingForUpdates
{
- get => _updating;
- set => this.RaiseAndSetIfChanged(ref _updating, value);
+ get => _checkingForUpdates;
+ set => this.RaiseAndSetIfChanged(ref _checkingForUpdates, value);
}
private int _downloadProgress;
@@ -44,6 +58,7 @@ public class InstallerUpdateInfo : ReactiveObject
public async Task UpdateInstaller()
{
Updating = true;
+ UpdateAvailable = false;
var updater = new FileInfo(Path.Join(DownloadCacheHelper.CachePath, "update.ps1"));
FileHelper.StreamAssemblyResourceOut("update.ps1", updater.FullName);
@@ -84,11 +99,37 @@ public class InstallerUpdateInfo : ReactiveObject
return file.FullName;
}
+ private void EndCheck(string infoText, bool updateAvailable)
+ {
+ UpdateInfoText = infoText;
+
+ if (!updateAvailable)
+ {
+ Task.Run(async () =>
+ {
+ // delay card dismiss
+ await Task.Delay(TimeSpan.FromSeconds(2));
+ ShowCard = updateAvailable;
+ });
+ }
+ else
+ {
+ ShowCard = updateAvailable;
+ }
+
+ CheckingForUpdates = false;
+ UpdateAvailable = updateAvailable;
+ }
+
public async Task CheckForUpdates(Version? currentVersion)
{
if (currentVersion == null)
return;
+ UpdateInfoText = "Checking for installer updates";
+ ShowCard = true;
+ CheckingForUpdates = true;
+
try
{
var repo = new RepositoryApi(Configuration.Default);
@@ -96,31 +137,39 @@ public class InstallerUpdateInfo : ReactiveObject
var releases = await repo.RepoListReleasesAsync("CWX", "SPT-AKI-Installer");
if (releases == null || releases.Count == 0)
+ {
+ EndCheck("No updates available", false);
return;
+ }
var latest = releases.FindAll(x => !x.Prerelease)[0];
if (latest == null)
+ {
+ EndCheck("No updates available", false);
return;
+ }
var latestVersion = new Version(latest.TagName);
if (latestVersion == null || latestVersion <= currentVersion)
+ {
+ EndCheck("No updates available", false);
return;
-
- UpdateAvailable = true;
+ }
_newVersion = latestVersion;
- UpdateInfoText = $"A newer installer is available, version {latestVersion}";
-
NewInstallerUrl = latest.Assets[0].BrowserDownloadUrl;
+ EndCheck($"Update available, version {latestVersion}", true);
+
return;
}
catch (Exception ex)
{
- Log.Logger.Error(ex, "Failed to check for updates");
+ EndCheck(ex.Message, false);
+ Log.Error(ex, "Failed to check for updates");
}
return;
diff --git a/SPTInstaller/SPTInstaller.csproj b/SPTInstaller/SPTInstaller.csproj
index 32b3b7b..eb0fe88 100644
--- a/SPTInstaller/SPTInstaller.csproj
+++ b/SPTInstaller/SPTInstaller.csproj
@@ -9,8 +9,8 @@
icon.ico
Assets\icon.ico
Debug;Release;TEST
- 2.7
- 2.7
+ 2.8
+ 2.8
diff --git a/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs b/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs
index eece790..83c5618 100644
--- a/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs
+++ b/SPTInstaller/ViewModels/DetailedPreChecksViewModel.cs
@@ -3,7 +3,7 @@
namespace SPTInstaller.ViewModels;
public class DetailedPreChecksViewModel : PreChecksViewModel
{
- public DetailedPreChecksViewModel(IScreen host) : base(host, null)
+ public DetailedPreChecksViewModel(IScreen host) : base(host)
{
}
}
diff --git a/SPTInstaller/ViewModels/MainWindowViewModel.cs b/SPTInstaller/ViewModels/MainWindowViewModel.cs
index 4aa3aa6..6d767d0 100644
--- a/SPTInstaller/ViewModels/MainWindowViewModel.cs
+++ b/SPTInstaller/ViewModels/MainWindowViewModel.cs
@@ -2,10 +2,8 @@
using Gitea.Client;
using ReactiveUI;
using Serilog;
-using SPTInstaller.Models;
using System.Globalization;
using System.Reflection;
-using System.Threading.Tasks;
namespace SPTInstaller.ViewModels;
@@ -13,7 +11,6 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
{
public RoutingState Router { get; } = new();
public ViewModelActivator Activator { get; } = new();
- public InstallerUpdateInfo UpdateInfo { get; } = new();
private string _title;
public string Title
@@ -26,9 +23,7 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
{
Configuration.Default.BasePath = "https://dev.sp-tarkov.com/api/v1";
- Version? version = Assembly.GetExecutingAssembly().GetName()?.Version;
-
- Title = $"SPT Installer {"v" + version?.ToString() ?? "--unknown version--"}";
+ Title = $"SPT Installer {"v" + Assembly.GetExecutingAssembly().GetName()?.Version?.ToString() ?? "--unknown version--"}";
Log.Information($"========= {Title} Started =========");
Log.Information(Environment.OSVersion.VersionString);
@@ -37,12 +32,7 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
Log.Information("System Language: {iso} - {name}", uiCulture.TwoLetterISOLanguageName, uiCulture.DisplayName);
- Task.Run(async () =>
- {
- await UpdateInfo.CheckForUpdates(version);
- });
-
- Router.Navigate.Execute(new PreChecksViewModel(this, DismissUpdateCommand));
+ Router.Navigate.Execute(new PreChecksViewModel(this));
}
public void CloseCommand()
@@ -60,15 +50,4 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
desktopApp.MainWindow.WindowState = Avalonia.Controls.WindowState.Minimized;
}
}
-
- public void DismissUpdateCommand()
- {
- UpdateInfo.UpdateAvailable = false;
- }
-
- public async Task UpdateInstallerCommand()
- {
- Router.Navigate.Execute(new MessageViewModel(this, Result.FromSuccess("Please wait while the update is installed"), false));
- await UpdateInfo.UpdateInstaller();
- }
}
\ No newline at end of file
diff --git a/SPTInstaller/ViewModels/PreChecksViewModel.cs b/SPTInstaller/ViewModels/PreChecksViewModel.cs
index e307045..a4a25b9 100644
--- a/SPTInstaller/ViewModels/PreChecksViewModel.cs
+++ b/SPTInstaller/ViewModels/PreChecksViewModel.cs
@@ -1,4 +1,6 @@
using System.Collections.ObjectModel;
+using System.Diagnostics.Metrics;
+using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Input;
using ReactiveUI;
@@ -11,26 +13,39 @@ namespace SPTInstaller.ViewModels;
public class PreChecksViewModel : ViewModelBase
{
- private string _installPath;
- private bool _allowInstall;
public ObservableCollection PreChecks { get; set; } = new(ServiceHelper.GetAll());
public ICommand StartInstallCommand { get; set; }
public ICommand ShowDetailedViewCommand { get; set; }
+ public ICommand UpdateInstallerCommand { get; set; }
+
+ public ICommand DismissUpdateCommand { get; set; }
+
+ public InstallerUpdateInfo UpdateInfo { get; set; } = new InstallerUpdateInfo();
+
+ private string _installPath;
public string InstallPath
{
get => _installPath;
set => this.RaiseAndSetIfChanged(ref _installPath, value);
}
+ private bool _allowInstall;
public bool AllowInstall
{
get => _allowInstall;
set => this.RaiseAndSetIfChanged(ref _allowInstall, value);
}
- public PreChecksViewModel(IScreen host, Action? dismissUpdateCard) : base(host)
+ private bool _allowDetailsButton = false;
+ public bool AllowDetailsButton
+ {
+ get => _allowDetailsButton;
+ set => this.RaiseAndSetIfChanged(ref _allowDetailsButton, value);
+ }
+
+ public PreChecksViewModel(IScreen host) : base(host)
{
var data = ServiceHelper.Get();
var installer = ServiceHelper.Get();
@@ -55,20 +70,37 @@ public class PreChecksViewModel : ViewModelBase
StartInstallCommand = ReactiveCommand.Create(() =>
{
- dismissUpdateCard?.Invoke();
+ UpdateInfo.ShowCard = false;
NavigateTo(new InstallViewModel(HostScreen));
});
ShowDetailedViewCommand = ReactiveCommand.Create(() =>
{
- dismissUpdateCard?.Invoke();
+ UpdateInfo.ShowCard = false;
Log.Logger.Information("Opening Detailed PreCheck View");
NavigateTo(new DetailedPreChecksViewModel(HostScreen));
});
+ UpdateInstallerCommand = ReactiveCommand.Create(async () =>
+ {
+ AllowDetailsButton = false;
+ AllowInstall = false;
+ await UpdateInfo.UpdateInstaller();
+ });
+
+ DismissUpdateCommand = ReactiveCommand.Create(() =>
+ {
+ UpdateInfo.ShowCard = false;
+ });
+
+
Task.Run(async () =>
{
var result = await installer.RunPreChecks();
+
+ await UpdateInfo.CheckForUpdates(Assembly.GetExecutingAssembly().GetName()?.Version);
+
+ AllowDetailsButton = true;
AllowInstall = result.Succeeded;
});
}
diff --git a/SPTInstaller/Views/MainWindow.axaml b/SPTInstaller/Views/MainWindow.axaml
index 4894196..9c3d2ec 100644
--- a/SPTInstaller/Views/MainWindow.axaml
+++ b/SPTInstaller/Views/MainWindow.axaml
@@ -33,15 +33,5 @@
/>
-
-
diff --git a/SPTInstaller/Views/PreChecksView.axaml b/SPTInstaller/Views/PreChecksView.axaml
index 51d1241..54fccc8 100644
--- a/SPTInstaller/Views/PreChecksView.axaml
+++ b/SPTInstaller/Views/PreChecksView.axaml
@@ -46,7 +46,20 @@
+
+