Merge pull request 'add installpath param' (#99) from waffle.lord/Installer:impl/install-path-param into master
Reviewed-on: SPT/Installer#99
This commit is contained in:
commit
45e988f7f8
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
@ -7,6 +8,8 @@ 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;
|
||||||
|
|
||||||
@ -14,6 +17,24 @@ 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);
|
||||||
@ -35,7 +56,19 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
var debug = desktop.Args != null && desktop.Args.Any(x => x.ToLower() == "debug");
|
var debug = false;
|
||||||
|
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()
|
||||||
@ -52,7 +85,7 @@ public partial class App : Application
|
|||||||
|
|
||||||
desktop.MainWindow = new MainWindow
|
desktop.MainWindow = new MainWindow
|
||||||
{
|
{
|
||||||
DataContext = new MainWindowViewModel(debug),
|
DataContext = new MainWindowViewModel(providedPath, debug),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,10 @@ 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()
|
||||||
|
@ -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.85</AssemblyVersion>
|
<AssemblyVersion>2.86</AssemblyVersion>
|
||||||
<FileVersion>2.85</FileVersion>
|
<FileVersion>2.86</FileVersion>
|
||||||
<Company>SPT</Company>
|
<Company>SPT</Company>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ 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;
|
||||||
|
|
||||||
@ -38,13 +39,26 @@ public class InstallPathSelectionViewModel : ViewModelBase
|
|||||||
set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
|
set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstallPathSelectionViewModel(IScreen host, bool debugging) : base(host)
|
public InstallPathSelectionViewModel(IScreen host, string installPath, 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +145,7 @@ public class InstallPathSelectionViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task NextCommand()
|
public void NextCommand()
|
||||||
{
|
{
|
||||||
if (FileHelper.CheckPathForProblemLocations(SelectedPath, out var failedCheck) && failedCheck.CheckAction == PathCheckAction.Deny)
|
if (FileHelper.CheckPathForProblemLocations(SelectedPath, out var failedCheck) && failedCheck.CheckAction == PathCheckAction.Deny)
|
||||||
{
|
{
|
||||||
|
@ -13,9 +13,12 @@ public class InstallerUpdateViewModel : ViewModelBase
|
|||||||
private InternalData _data;
|
private InternalData _data;
|
||||||
|
|
||||||
private bool _debugging;
|
private bool _debugging;
|
||||||
public InstallerUpdateViewModel(IScreen Host, bool debugging) : base(Host)
|
private string _installPath;
|
||||||
|
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 () =>
|
||||||
@ -24,14 +27,14 @@ public class InstallerUpdateViewModel : ViewModelBase
|
|||||||
|
|
||||||
if (!UpdateInfo.UpdateAvailable)
|
if (!UpdateInfo.UpdateAvailable)
|
||||||
{
|
{
|
||||||
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
|
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _installPath, _debugging));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotNowCommand()
|
public void NotNowCommand()
|
||||||
{
|
{
|
||||||
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _debugging));
|
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _installPath, _debugging));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateInstallCommand()
|
public async Task UpdateInstallCommand()
|
||||||
|
@ -19,7 +19,7 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
|
|||||||
set => this.RaiseAndSetIfChanged(ref _title, value);
|
set => this.RaiseAndSetIfChanged(ref _title, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindowViewModel(bool debugging)
|
public MainWindowViewModel(string installPath, 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, debugging));
|
Router.Navigate.Execute(new InstallerUpdateViewModel(this, installPath, debugging));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseCommand()
|
public void CloseCommand()
|
||||||
|
@ -214,15 +214,7 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var installerPath = Path.Join(Environment.CurrentDirectory, "SPTInstaller.exe");
|
App.ReLaunch(true, InstallPath);
|
||||||
|
|
||||||
Process.Start(new ProcessStartInfo()
|
|
||||||
{
|
|
||||||
FileName = installerPath,
|
|
||||||
Arguments = "debug"
|
|
||||||
});
|
|
||||||
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user