Compare commits

..

No commits in common. "45e988f7f8deabbe07b3934aab498ddf8ce0e0d8" and "498eeaa0efc6e0a22f93a823f4b8e51f29709593" have entirely different histories.

7 changed files with 21 additions and 67 deletions

View File

@ -1,5 +1,4 @@
using System.Diagnostics; using System.Linq;
using System.Linq;
using Avalonia; using Avalonia;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
@ -8,8 +7,6 @@ using Serilog;
using SPTInstaller.ViewModels; using SPTInstaller.ViewModels;
using SPTInstaller.Views; using SPTInstaller.Views;
using System.Reactive; using System.Reactive;
using System.Text;
using DynamicData;
namespace SPTInstaller; namespace SPTInstaller;
@ -17,24 +14,6 @@ public partial class App : Application
{ {
public static string LogPath = Path.Join(Environment.CurrentDirectory, "spt-installer.log"); public static string LogPath = Path.Join(Environment.CurrentDirectory, "spt-installer.log");
public static void ReLaunch(bool debug, string installPath = "")
{
var installerPath = Path.Join(Environment.CurrentDirectory, "SPTInstaller.exe");
var args = new StringBuilder()
.Append(debug ? "debug " : "")
.Append(!string.IsNullOrEmpty(installPath) ? $"installPath=\"{installPath}\"" : "")
.ToString();
Process.Start(new ProcessStartInfo()
{
FileName = installerPath,
Arguments = args
});
Environment.Exit(0);
}
public override void Initialize() public override void Initialize()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
@ -56,19 +35,7 @@ public partial class App : Application
{ {
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{ {
var debug = false; var debug = desktop.Args != null && desktop.Args.Any(x => x.ToLower() == "debug");
var providedPath = "";
if (desktop.Args != null)
{
debug = desktop.Args.Any(x => x.ToLower() == "debug");
var installPath = desktop.Args.FirstOrDefault(x => x.StartsWith("installPath=", StringComparison.CurrentCultureIgnoreCase));
providedPath = installPath != null && installPath.Contains('=') ? installPath?.Split('=')[1] ?? "" : "";
}
if (debug) if (debug)
{ {
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
@ -85,7 +52,7 @@ public partial class App : Application
desktop.MainWindow = new MainWindow desktop.MainWindow = new MainWindow
{ {
DataContext = new MainWindowViewModel(providedPath, debug), DataContext = new MainWindowViewModel(debug),
}; };
} }

View File

@ -95,10 +95,6 @@ public partial class WhyCacheThoughDialog : UserControl
AdditionalInfo = message; AdditionalInfo = message;
AdditionalInfoColor = allDeleted ? "green" : "red"; AdditionalInfoColor = allDeleted ? "green" : "red";
Log.Information(message); Log.Information(message);
var data = ServiceHelper.Get<InternalData>();
App.ReLaunch(false, data.TargetInstallPath!);
} }
public void MoveDownloadsPatcherToCache() public void MoveDownloadsPatcherToCache()

View File

@ -10,8 +10,8 @@
<PackageIcon>icon.ico</PackageIcon> <PackageIcon>icon.ico</PackageIcon>
<ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon> <ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon>
<Configurations>Debug;Release;TEST</Configurations> <Configurations>Debug;Release;TEST</Configurations>
<AssemblyVersion>2.86</AssemblyVersion> <AssemblyVersion>2.85</AssemblyVersion>
<FileVersion>2.86</FileVersion> <FileVersion>2.85</FileVersion>
<Company>SPT</Company> <Company>SPT</Company>
</PropertyGroup> </PropertyGroup>

View File

@ -5,7 +5,6 @@ using Avalonia;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using ReactiveUI; using ReactiveUI;
using Serilog;
using SPTInstaller.Helpers; using SPTInstaller.Helpers;
using SPTInstaller.Models; using SPTInstaller.Models;
@ -39,26 +38,13 @@ public class InstallPathSelectionViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _errorMessage, value); set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
} }
public InstallPathSelectionViewModel(IScreen host, string installPath, bool debugging) : base(host) public InstallPathSelectionViewModel(IScreen host, bool debugging) : base(host)
{ {
_debugging = debugging; _debugging = debugging;
_data = ServiceHelper.Get<InternalData?>() ?? throw new Exception("Failed to get internal data"); _data = ServiceHelper.Get<InternalData?>() ?? throw new Exception("Failed to get internal data");
SelectedPath = Environment.CurrentDirectory; SelectedPath = Environment.CurrentDirectory;
ValidPath = false; ValidPath = false;
if (!string.IsNullOrEmpty(installPath))
{
SelectedPath = installPath;
ValidatePath();
if (ValidPath)
{
Log.Information("Install Path was provided by parameter and seems valid");
Task.Run(NextCommand);
return;
}
}
AdjustInstallPath(); AdjustInstallPath();
} }
@ -145,7 +131,7 @@ public class InstallPathSelectionViewModel : ViewModelBase
} }
} }
public void NextCommand() public async Task NextCommand()
{ {
if (FileHelper.CheckPathForProblemLocations(SelectedPath, out var failedCheck) && failedCheck.CheckAction == PathCheckAction.Deny) if (FileHelper.CheckPathForProblemLocations(SelectedPath, out var failedCheck) && failedCheck.CheckAction == PathCheckAction.Deny)
{ {

View File

@ -13,12 +13,9 @@ public class InstallerUpdateViewModel : ViewModelBase
private InternalData _data; private InternalData _data;
private bool _debugging; private bool _debugging;
private string _installPath; public InstallerUpdateViewModel(IScreen Host, bool debugging) : base(Host)
public InstallerUpdateViewModel(IScreen Host, string installPath, bool debugging) : base(Host)
{ {
_debugging = debugging; _debugging = debugging;
_installPath = installPath;
_data = ServiceHelper.Get<InternalData>() ?? throw new Exception("Failed to get internal data"); _data = ServiceHelper.Get<InternalData>() ?? throw new Exception("Failed to get internal data");
Task.Run(async () => Task.Run(async () =>
@ -27,14 +24,14 @@ public class InstallerUpdateViewModel : ViewModelBase
if (!UpdateInfo.UpdateAvailable) if (!UpdateInfo.UpdateAvailable)
{ {
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _installPath, _debugging)); NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
} }
}); });
} }
public void NotNowCommand() public void NotNowCommand()
{ {
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _installPath, _debugging)); NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
} }
public async Task UpdateInstallCommand() public async Task UpdateInstallCommand()

View File

@ -19,7 +19,7 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
set => this.RaiseAndSetIfChanged(ref _title, value); set => this.RaiseAndSetIfChanged(ref _title, value);
} }
public MainWindowViewModel(string installPath, bool debugging) public MainWindowViewModel(bool debugging)
{ {
Title = Title =
$"{(debugging ? "-debug-" : "")} SPT Installer {"v" + Assembly.GetExecutingAssembly().GetName()?.Version?.ToString() ?? "--unknown version--"}"; $"{(debugging ? "-debug-" : "")} SPT Installer {"v" + Assembly.GetExecutingAssembly().GetName()?.Version?.ToString() ?? "--unknown version--"}";
@ -31,7 +31,7 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
Log.Information("System Language: {iso} - {name}", uiCulture.TwoLetterISOLanguageName, uiCulture.DisplayName); Log.Information("System Language: {iso} - {name}", uiCulture.TwoLetterISOLanguageName, uiCulture.DisplayName);
Router.Navigate.Execute(new InstallerUpdateViewModel(this, installPath, debugging)); Router.Navigate.Execute(new InstallerUpdateViewModel(this, debugging));
} }
public void CloseCommand() public void CloseCommand()

View File

@ -214,7 +214,15 @@ public class PreChecksViewModel : ViewModelBase
{ {
try try
{ {
App.ReLaunch(true, InstallPath); var installerPath = Path.Join(Environment.CurrentDirectory, "SPTInstaller.exe");
Process.Start(new ProcessStartInfo()
{
FileName = installerPath,
Arguments = "debug"
});
Environment.Exit(0);
} }
catch (Exception ex) catch (Exception ex)
{ {