Compare commits

..

No commits in common. "944e34fa6b361a55f66fbf6b12ef2cfe0b09530c" and "b2b64dcae065464b63e46626b88f8d88d494110a" have entirely different histories.

9 changed files with 28 additions and 37 deletions

View File

@ -9,16 +9,13 @@ using SPTInstaller.ViewModels;
using SPTInstaller.Views;
using System.Reactive;
using System.Text;
using SPTInstaller.Helpers;
using SPTInstaller.Models;
using DynamicData;
namespace SPTInstaller;
public partial class App : Application
{
public static string LogPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "spt-installer", "spt-installer.log");
public static string LogDebugPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"spt-installer", "spt-isntaller-debug.log");
public static void ReLaunch(bool debug, string installPath = "")
{
@ -59,38 +56,34 @@ public partial class App : Application
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
var data = ServiceHelper.Get<InternalData>() ?? throw new Exception("failed to get internal data");
data.DebugMode = false;
var debug = false;
var providedPath = "";
if (desktop.Args != null)
{
data.DebugMode = desktop.Args.Any(x => x.ToLower() == "debug");
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 (data.DebugMode)
if (debug)
{
Log.CloseAndFlush();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo
.File(path: LogDebugPath,
.File(path: LogPath,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug)
.CreateLogger();
Trace.Listeners.Add(new SerilogTraceListener.SerilogTraceListener());
System.Diagnostics.Trace.Listeners.Add(new SerilogTraceListener.SerilogTraceListener());
Log.Debug("TraceListener is registered");
}
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(providedPath),
DataContext = new MainWindowViewModel(providedPath, debug),
};
}

View File

@ -5,7 +5,6 @@ namespace SPTInstaller.Models;
public class InternalData
{
public bool DebugMode { get; set; } = false;
/// <summary>
/// The folder to install SPT into
/// </summary>

View File

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

View File

@ -13,6 +13,7 @@ namespace SPTInstaller.ViewModels;
public class InstallPathSelectionViewModel : ViewModelBase
{
private bool _debugging = false;
private InternalData _data;
private string _selectedPath;
@ -38,8 +39,9 @@ public class InstallPathSelectionViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
}
public InstallPathSelectionViewModel(IScreen host, string installPath) : base(host)
public InstallPathSelectionViewModel(IScreen host, string installPath, bool debugging) : base(host)
{
_debugging = debugging;
_data = ServiceHelper.Get<InternalData?>() ?? throw new Exception("Failed to get internal data");
SelectedPath = Environment.CurrentDirectory;
ValidPath = false;
@ -152,6 +154,6 @@ public class InstallPathSelectionViewModel : ViewModelBase
_data.TargetInstallPath = SelectedPath;
NavigateTo(new PreChecksViewModel(HostScreen));
NavigateTo(new PreChecksViewModel(HostScreen, _debugging));
}
}

View File

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

View File

@ -3,8 +3,6 @@ using ReactiveUI;
using Serilog;
using System.Globalization;
using System.Reflection;
using SPTInstaller.Helpers;
using SPTInstaller.Models;
namespace SPTInstaller.ViewModels;
@ -21,12 +19,10 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
set => this.RaiseAndSetIfChanged(ref _title, value);
}
public MainWindowViewModel(string installPath)
public MainWindowViewModel(string installPath, bool debugging)
{
var data = ServiceHelper.Get<InternalData>() ?? throw new Exception("failed to get interanl data");
Title =
$"{(data.DebugMode ? "-debug-" : "")} SPT Installer {"v" + Assembly.GetExecutingAssembly().GetName()?.Version?.ToString() ?? "--unknown version--"}";
$"{(debugging ? "-debug-" : "")} SPT Installer {"v" + Assembly.GetExecutingAssembly().GetName()?.Version?.ToString() ?? "--unknown version--"}";
Log.Information($"========= {Title} Started =========");
Log.Information(Environment.OSVersion.VersionString);
@ -35,7 +31,7 @@ public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScree
Log.Information("System Language: {iso} - {name}", uiCulture.TwoLetterISOLanguageName, uiCulture.DisplayName);
Router.Navigate.Execute(new InstallerUpdateViewModel(this, installPath));
Router.Navigate.Execute(new InstallerUpdateViewModel(this, installPath, debugging));
}
public void CloseCommand()

View File

@ -80,8 +80,6 @@ public class MessageViewModel : ViewModelBase
public ICommand CopyLogFileToClipboard => ReactiveCommand.CreateFromTask(async () =>
{
var data = ServiceHelper.Get<InternalData>();
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
try
@ -93,7 +91,7 @@ public class MessageViewModel : ViewModelBase
}
var dataObject = new DataObject();
var logFile = await desktop.MainWindow.StorageProvider.TryGetFileFromPathAsync(data.DebugMode ? App.LogDebugPath : App.LogPath);
var logFile = await desktop.MainWindow.StorageProvider.TryGetFileFromPathAsync(App.LogPath);
if (logFile == null)
{

View File

@ -6,9 +6,11 @@ namespace SPTInstaller.ViewModels;
public class OverviewViewModel : ViewModelBase
{
private string _providedPath;
public OverviewViewModel(IScreen Host, string providedPath) : base(Host)
private bool _debugging;
public OverviewViewModel(IScreen Host, string providedPath, bool debugging) : base(Host)
{
_providedPath = providedPath;
_debugging = debugging;
if (!string.IsNullOrEmpty(_providedPath))
{
@ -18,6 +20,6 @@ public class OverviewViewModel : ViewModelBase
public void NextCommand()
{
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _providedPath));
NavigateTo(new InstallPathSelectionViewModel(HostScreen, _providedPath, _debugging));
}
}

View File

@ -109,13 +109,12 @@ public class PreChecksViewModel : ViewModelBase
});
}
public PreChecksViewModel(IScreen host) : base(host)
public PreChecksViewModel(IScreen host, bool debugging) : base(host)
{
Debugging = debugging;
var data = ServiceHelper.Get<InternalData?>();
var installer = ServiceHelper.Get<InstallController?>();
Debugging = data.DebugMode;
installer.RecheckRequested += ReCheckRequested;
InstallButtonText = "Please wait ...";