diff --git a/SPTInstaller/CustomControls/Dialogs/ChangeLogDialog.axaml b/SPTInstaller/CustomControls/Dialogs/ChangeLogDialog.axaml
deleted file mode 100644
index 99cbbbd..0000000
--- a/SPTInstaller/CustomControls/Dialogs/ChangeLogDialog.axaml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/SPTInstaller/CustomControls/Dialogs/ChangeLogDialog.axaml.cs b/SPTInstaller/CustomControls/Dialogs/ChangeLogDialog.axaml.cs
deleted file mode 100644
index b3552ed..0000000
--- a/SPTInstaller/CustomControls/Dialogs/ChangeLogDialog.axaml.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using Tmds.DBus.Protocol;
-
-namespace SPTInstaller.CustomControls.Dialogs;
-
-public partial class ChangeLogDialog : UserControl
-{
- public string Message { get; set; }
- public string Version { get; set; }
- public ChangeLogDialog(string newVersion, string message)
- {
- InitializeComponent();
- Message = message;
- Version = newVersion;
- }
-
- // public static readonly StyledProperty MessageProperty =
- // AvaloniaProperty.Register("Message");
- //
- // public string Message
- // {
- // get => GetValue(MessageProperty);
- // set => SetValue(MessageProperty, value);
- // }
-}
\ No newline at end of file
diff --git a/SPTInstaller/CustomControls/UpdateButton.axaml b/SPTInstaller/CustomControls/UpdateButton.axaml
index 6c63fe7..d5134e6 100644
--- a/SPTInstaller/CustomControls/UpdateButton.axaml
+++ b/SPTInstaller/CustomControls/UpdateButton.axaml
@@ -26,8 +26,6 @@
-
diff --git a/SPTInstaller/CustomControls/UpdateButton.axaml.cs b/SPTInstaller/CustomControls/UpdateButton.axaml.cs
index 155311d..4ea2783 100644
--- a/SPTInstaller/CustomControls/UpdateButton.axaml.cs
+++ b/SPTInstaller/CustomControls/UpdateButton.axaml.cs
@@ -50,15 +50,6 @@ public partial class UpdateButton : UserControl
set => SetValue(UpdateCommandProperty, value);
}
- public static readonly StyledProperty WhatsNewCommandProperty =
- AvaloniaProperty.Register("WhatsNewCommand");
-
- public ICommand WhatsNewCommand
- {
- get => GetValue(WhatsNewCommandProperty);
- set => SetValue(WhatsNewCommandProperty, value);
- }
-
public static readonly StyledProperty UpdatingProperty = AvaloniaProperty.Register(
"Updating");
diff --git a/SPTInstaller/Helpers/FileHelper.cs b/SPTInstaller/Helpers/FileHelper.cs
index 786dae3..da05f99 100644
--- a/SPTInstaller/Helpers/FileHelper.cs
+++ b/SPTInstaller/Helpers/FileHelper.cs
@@ -142,6 +142,8 @@ public static class FileHelper
/// Returns true if the path is bad, otherwise false
public static bool CheckPathForProblemLocations(string path, out PathCheck failedCheck)
{
+ path = Path.TrimEndingDirectorySeparator(path);
+
failedCheck = new();
var problemPaths = new List()
diff --git a/SPTInstaller/Models/InstallerUpdateInfo.cs b/SPTInstaller/Models/InstallerUpdateInfo.cs
index cd58bc8..813f7e7 100644
--- a/SPTInstaller/Models/InstallerUpdateInfo.cs
+++ b/SPTInstaller/Models/InstallerUpdateInfo.cs
@@ -11,7 +11,7 @@ public class InstallerUpdateInfo : ReactiveObject
{
public Version? NewVersion { get; private set; }
- public string ChangeLog = "";
+ public string ChangeLog { get; private set; }= "";
private string _updateInfoText = "";
@@ -21,14 +21,6 @@ public class InstallerUpdateInfo : ReactiveObject
set => this.RaiseAndSetIfChanged(ref _updateInfoText, value);
}
- private bool _show = false;
-
- public bool Show
- {
- get => _show;
- set => this.RaiseAndSetIfChanged(ref _show, value);
- }
-
private bool _updating = false;
public bool Updating
@@ -123,7 +115,6 @@ public class InstallerUpdateInfo : ReactiveObject
}
UpdateInfoText = infoText;
- Show = updateAvailable;
CheckingForUpdates = false;
UpdateAvailable = updateAvailable;
}
@@ -134,7 +125,6 @@ public class InstallerUpdateInfo : ReactiveObject
return;
UpdateInfoText = "Checking for installer updates";
- Show = true;
CheckingForUpdates = true;
try
diff --git a/SPTInstaller/SPTInstaller.csproj b/SPTInstaller/SPTInstaller.csproj
index 960f8e6..ba8701d 100644
--- a/SPTInstaller/SPTInstaller.csproj
+++ b/SPTInstaller/SPTInstaller.csproj
@@ -10,8 +10,8 @@
icon.ico
Assets\spt_installer.ico
Debug;Release;TEST
- 2.71
- 2.71
+ 2.80
+ 2.80
SPT
diff --git a/SPTInstaller/ViewModels/InstallPathSelectionViewModel.cs b/SPTInstaller/ViewModels/InstallPathSelectionViewModel.cs
index 23c93c2..b2c9547 100644
--- a/SPTInstaller/ViewModels/InstallPathSelectionViewModel.cs
+++ b/SPTInstaller/ViewModels/InstallPathSelectionViewModel.cs
@@ -1,4 +1,5 @@
using System.Linq;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
@@ -81,11 +82,19 @@ public class InstallPathSelectionViewModel : ViewModelBase
return;
}
+ var match = Regex.Match(SelectedPath[2..], @"[\/:*?""<>|]");
+ if (match.Success)
+ {
+ ErrorMessage = "Path cannot contain these characters: / : * ? \" < > |";
+ ValidPath = false;
+ return;
+ }
+
if (FileHelper.CheckPathForProblemLocations(SelectedPath, out var failedCheck))
{
if (failedCheck.CheckType == PathCheckType.EndsWith)
{
- ErrorMessage = "This folder can be install in, but only in a subdirectory";
+ ErrorMessage = $"You can install in {failedCheck.Target}, but only in a subdirectory. Example: ..\\{failedCheck.Target}\\SPT";
ValidPath = false;
return;
}
@@ -124,7 +133,7 @@ public class InstallPathSelectionViewModel : ViewModelBase
public async Task NextCommand()
{
- if (FileHelper.CheckPathForProblemLocations(SelectedPath, out _))
+ if (FileHelper.CheckPathForProblemLocations(SelectedPath, out var failedCheck) && failedCheck.CheckAction == PathCheckAction.Deny)
{
return;
}
diff --git a/SPTInstaller/ViewModels/InstallerUpdateViewModel.cs b/SPTInstaller/ViewModels/InstallerUpdateViewModel.cs
index ff53ff2..24fd3ee 100644
--- a/SPTInstaller/ViewModels/InstallerUpdateViewModel.cs
+++ b/SPTInstaller/ViewModels/InstallerUpdateViewModel.cs
@@ -1,12 +1,40 @@
-using ReactiveUI;
+using System.Reflection;
+using System.Threading.Tasks;
+using ReactiveUI;
+using SPTInstaller.Helpers;
+using SPTInstaller.Models;
namespace SPTInstaller.ViewModels;
public class InstallerUpdateViewModel : ViewModelBase
{
+
+ public InstallerUpdateInfo UpdateInfo { get; set; } = new();
+ private InternalData _data;
+
private bool _debugging;
public InstallerUpdateViewModel(IScreen Host, bool debugging) : base(Host)
{
_debugging = debugging;
+ _data = ServiceHelper.Get() ?? throw new Exception("Failed to get internal data");
+
+ Task.Run(async () =>
+ {
+ await UpdateInfo.CheckForUpdates(Assembly.GetExecutingAssembly().GetName().Version);
+ if (!UpdateInfo.UpdateAvailable)
+ {
+ NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
+ }
+ });
+ }
+
+ public void NotNowCommand()
+ {
+ NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
+ }
+
+ public async Task UpdateInstallCommand()
+ {
+ await UpdateInfo.UpdateInstaller();
}
}
\ No newline at end of file
diff --git a/SPTInstaller/ViewModels/PreChecksViewModel.cs b/SPTInstaller/ViewModels/PreChecksViewModel.cs
index 089dd3b..e535e15 100644
--- a/SPTInstaller/ViewModels/PreChecksViewModel.cs
+++ b/SPTInstaller/ViewModels/PreChecksViewModel.cs
@@ -1,6 +1,5 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Threading;
@@ -32,16 +31,8 @@ public class PreChecksViewModel : ViewModelBase
public ICommand SelectPreCheckCommand { get; set; }
public ICommand StartInstallCommand { get; set; }
- public ICommand UpdateInstallerCommand { get; set; }
-
- public ICommand DismissUpdateCommand { get; set; }
-
- public ICommand WhatsNewCommand { get; set; }
-
public ICommand LaunchWithDebug { get; set; }
- public InstallerUpdateInfo UpdateInfo { get; set; } = new();
-
private bool _debugging;
public bool Debugging
@@ -195,8 +186,8 @@ public class PreChecksViewModel : ViewModelBase
if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) ||
!confirm)
{
- Log.Information("User declined install path, exiting");
- Environment.Exit(0);
+ Log.Information("User declined install path");
+ NavigateBack();
}
});
@@ -258,31 +249,14 @@ public class PreChecksViewModel : ViewModelBase
StartInstallCommand = ReactiveCommand.Create(async () =>
{
- UpdateInfo.Show = false;
NavigateTo(new InstallViewModel(HostScreen));
});
- UpdateInstallerCommand = ReactiveCommand.Create(async () =>
- {
- AllowDetailsButton = false;
- AllowInstall = false;
- await UpdateInfo.UpdateInstaller();
- });
-
- DismissUpdateCommand = ReactiveCommand.Create(() => { UpdateInfo.Show = false; });
-
- WhatsNewCommand =
- ReactiveCommand.Create(async () => await DialogHost.Show(new ChangeLogDialog(UpdateInfo.NewVersion.ToString(), UpdateInfo.ChangeLog)));
-
-
Task.Run(async () =>
{
// run prechecks
var result = await installer.RunPreChecks();
- // check for updates
- await UpdateInfo.CheckForUpdates(Assembly.GetExecutingAssembly().GetName()?.Version);
-
// get latest spt version
InstallButtonText = "Getting latest release ...";
InstallButtonCheckState = StatusSpinner.SpinnerState.Running;
diff --git a/SPTInstaller/ViewModels/ViewModelBase.cs b/SPTInstaller/ViewModels/ViewModelBase.cs
index e8873c9..f417e86 100644
--- a/SPTInstaller/ViewModels/ViewModelBase.cs
+++ b/SPTInstaller/ViewModels/ViewModelBase.cs
@@ -48,6 +48,11 @@ public class ViewModelBase : ReactiveObject, IActivatableViewModel, IRoutableVie
Dispatcher.UIThread.InvokeAsync(() => { HostScreen.Router.Navigate.Execute(ViewModel); });
}
+ public void NavigateBack()
+ {
+ Dispatcher.UIThread.InvokeAsync(() => { HostScreen.Router.NavigateBack.Execute(); });
+ }
+
public ViewModelBase(IScreen Host)
{
HostScreen = Host;
diff --git a/SPTInstaller/Views/InstallPathSelectionView.axaml b/SPTInstaller/Views/InstallPathSelectionView.axaml
index bc46f44..ea4a7c8 100644
--- a/SPTInstaller/Views/InstallPathSelectionView.axaml
+++ b/SPTInstaller/Views/InstallPathSelectionView.axaml
@@ -27,6 +27,7 @@
-
-
-
\ No newline at end of file