diff --git a/SPTInstaller/Assets/Styles.axaml b/SPTInstaller/Assets/Styles.axaml
index a20d4ad..97d4a66 100644
--- a/SPTInstaller/Assets/Styles.axaml
+++ b/SPTInstaller/Assets/Styles.axaml
@@ -9,6 +9,7 @@
+
@@ -267,4 +268,30 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SPTInstaller/Helpers/FileHelper.cs b/SPTInstaller/Helpers/FileHelper.cs
index da05f99..4b8f331 100644
--- a/SPTInstaller/Helpers/FileHelper.cs
+++ b/SPTInstaller/Helpers/FileHelper.cs
@@ -98,33 +98,29 @@ public static class FileHelper
{
Log.Debug($"Starting StreamAssemblyResourceOut, resourcename: {resourceName}, outputFilePath: {outputFilePath}");
var assembly = Assembly.GetExecutingAssembly();
- Log.Debug($"1");
FileInfo outputFile = new FileInfo(outputFilePath);
- Log.Debug($"2");
+
if (outputFile.Exists)
{
- Log.Debug($"3");
outputFile.Delete();
}
- Log.Debug($"4");
+
if (!outputFile.Directory.Exists)
{
- Log.Debug($"5");
Directory.CreateDirectory(outputFile.Directory.FullName);
}
- Log.Debug($"6");
+
var resName = assembly.GetManifestResourceNames().First(x => x.EndsWith(resourceName));
- Log.Debug($"7");
+
using (FileStream fs = File.Create(outputFilePath))
using (Stream s = assembly.GetManifestResourceStream(resName))
{
- Log.Debug($"8");
s.CopyTo(fs);
}
- Log.Debug($"9");
+
outputFile.Refresh();
- Log.Debug(outputFile.Exists.ToString());
+
return outputFile.Exists;
}
catch (Exception ex)
diff --git a/SPTInstaller/Resources/add_shortcuts.ps1 b/SPTInstaller/Resources/add_shortcuts.ps1
new file mode 100644
index 0000000..9ef3420
--- /dev/null
+++ b/SPTInstaller/Resources/add_shortcuts.ps1
@@ -0,0 +1,23 @@
+param (
+ [string]$installPath
+)
+
+$desktop = Join-Path $env:USERPROFILE "Desktop"
+
+$launcherExe = gci $installPath | where {$_.Name -like "*.Launcher.exe"} | select -ExpandProperty FullName
+$serverExe = gci $installPath | where {$_.Name -like "*.Server.exe"} | select -ExpandProperty FullName
+
+$launcherShortcut = Join-Path $desktop "SPT.Launcher.lnk"
+$serverShortcut = Join-Path $desktop "SPT.Server.lnk"
+
+$WshShell = New-Object -comObject WScript.Shell
+
+$launcher = $WshShell.CreateShortcut($launcherShortcut)
+$launcher.TargetPath = $launcherExe
+$launcher.WorkingDirectory = $installPath
+$launcher.Save()
+
+$server = $WshShell.CreateShortcut($serverShortcut)
+$server.TargetPath = $serverExe
+$server.WorkingDirectory = $installPath
+$server.Save()
\ No newline at end of file
diff --git a/SPTInstaller/Resources/update.ps1 b/SPTInstaller/Resources/update.ps1
index a93e30d..d68885e 100644
--- a/SPTInstaller/Resources/update.ps1
+++ b/SPTInstaller/Resources/update.ps1
@@ -43,7 +43,7 @@ while (-not $copied) {
}
Remove-Item $destination -ErrorAction SilentlyContinue
- Copy-Item $source $destination
+ Copy-Item $source $destination -ErrorAction SilentlyContinue
if (Test-Path $destination) {
$sLength = (Get-Item $source).Length
diff --git a/SPTInstaller/SPTInstaller.csproj b/SPTInstaller/SPTInstaller.csproj
index 36567aa..19519de 100644
--- a/SPTInstaller/SPTInstaller.csproj
+++ b/SPTInstaller/SPTInstaller.csproj
@@ -10,8 +10,8 @@
icon.ico
Assets\spt_installer.ico
Debug;Release;TEST
- 2.82
- 2.82
+ 2.83
+ 2.83
SPT
@@ -26,6 +26,8 @@
+
+
diff --git a/SPTInstaller/ViewModels/MessageViewModel.cs b/SPTInstaller/ViewModels/MessageViewModel.cs
index dfb686c..57bde1f 100644
--- a/SPTInstaller/ViewModels/MessageViewModel.cs
+++ b/SPTInstaller/ViewModels/MessageViewModel.cs
@@ -1,4 +1,5 @@
-using Avalonia;
+using System.Diagnostics;
+using Avalonia;
using ReactiveUI;
using Serilog;
using SPTInstaller.CustomControls;
@@ -9,6 +10,7 @@ using System.Windows.Input;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input;
using Avalonia.Platform.Storage;
+using SPTInstaller.Models;
namespace SPTInstaller.ViewModels;
@@ -38,6 +40,14 @@ public class MessageViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _showCloseButton, value);
}
+ private bool _showOptions;
+
+ public bool ShowOptions
+ {
+ get => _showOptions;
+ set => this.RaiseAndSetIfChanged(ref _showOptions, value);
+ }
+
private string _cacheInfoText;
public string CacheInfoText
@@ -54,6 +64,20 @@ public class MessageViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _clipCommandText, value);
}
+ private bool _addShortcuts;
+ public bool AddShortcuts
+ {
+ get => _addShortcuts;
+ set => this.RaiseAndSetIfChanged(ref _addShortcuts, value);
+ }
+
+ private bool _openInstallFolder = true;
+ public bool OpenInstallFolder
+ {
+ get => _openInstallFolder;
+ set => this.RaiseAndSetIfChanged(ref _openInstallFolder, value);
+ }
+
public ICommand CopyLogFileToClipboard => ReactiveCommand.CreateFromTask(async () =>
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
@@ -97,8 +121,7 @@ public class MessageViewModel : ViewModelBase
public ICommand CloseCommand { get; set; } = ReactiveCommand.Create(() =>
{
- if (Application.Current.ApplicationLifetime is
- Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
+ if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopApp)
{
desktopApp.MainWindow.Close();
}
@@ -110,6 +133,64 @@ public class MessageViewModel : ViewModelBase
Message = result.Message;
ClipCommandText = "Copy installer log to clipboard";
+ if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopApp)
+ {
+ var data = ServiceHelper.Get();
+
+ desktopApp.MainWindow.Closing += (_, _) =>
+ {
+ if (ShowOptions)
+ {
+ if (OpenInstallFolder)
+ {
+ Process.Start(new ProcessStartInfo()
+ {
+ FileName = "explorer.exe",
+ Arguments = data.TargetInstallPath
+ });
+ }
+
+ if (AddShortcuts)
+ {
+ var shortcuts = new FileInfo(Path.Join(DownloadCacheHelper.CachePath, "add_shortcuts.ps1"));
+
+ if (!FileHelper.StreamAssemblyResourceOut("add_shortcuts.ps1", shortcuts.FullName))
+ {
+ Log.Fatal("Failed to prepare shortcuts file");
+ return;
+ }
+
+ if (!File.Exists(shortcuts.FullName))
+ {
+ Log.Fatal("Shortcuts file not found");
+ return;
+ }
+
+ Log.Information("Running add shortcuts script ...");
+
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = "powershell.exe",
+ CreateNoWindow = true,
+ ArgumentList =
+ {
+ "-ExecutionPolicy", "Bypass", "-File", $"{shortcuts.FullName}", $"{data.TargetInstallPath}"
+ }
+ });
+ }
+ }
+
+ try
+ {
+ File.Copy(App.LogPath, Path.Join(data.TargetInstallPath, "spt-installer.log"), true);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to copy installer log to install path");
+ }
+ };
+ }
+
Task.Run(() =>
{
CacheInfoText = "Getting cache size ...";
@@ -122,6 +203,7 @@ public class MessageViewModel : ViewModelBase
if (result.Succeeded)
{
Log.Information(Message);
+ ShowOptions = true;
return;
}
diff --git a/SPTInstaller/Views/MessageView.axaml b/SPTInstaller/Views/MessageView.axaml
index 3ad9149..74c5bc3 100644
--- a/SPTInstaller/Views/MessageView.axaml
+++ b/SPTInstaller/Views/MessageView.axaml
@@ -15,7 +15,7 @@
-
-
+
+
+
+
-
+ InfoText="{Binding CacheInfoText}" State="{Binding CacheCheckState}"
+ />
+
+
\ No newline at end of file