Global System and System.IO usages have been replaced with global usings in GlobalUsings.cs for improved code readability. Alongside, a FreeSpacePreCheck has been added in FreeSpacePreCheck.cs to ensure enough drive space is available before installation. This check was initially taking place in InitializationTask.cs which has been removed for better separation of concerns. The PreCheckViewModel visibility is now dependent on the success status of PreChecks, enhancing user experience.
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
using ReactiveUI;
|
|
using SPTInstaller.Aki.Helper;
|
|
using SPTInstaller.Controllers;
|
|
using SPTInstaller.Helpers;
|
|
using SPTInstaller.Models;
|
|
|
|
namespace SPTInstaller.ViewModels;
|
|
|
|
public class PreChecksViewModel : ViewModelBase
|
|
{
|
|
private string _installPath;
|
|
|
|
public ObservableCollection<PreCheckBase> PreChecks { get; set; } = new(ServiceHelper.GetAll<PreCheckBase>());
|
|
public ICommand StartInstallCommand { get; set; }
|
|
public bool PreCheckSucceeded { get; set; }
|
|
public string InstallPath
|
|
{
|
|
get => _installPath;
|
|
set => this.RaiseAndSetIfChanged(ref _installPath, value);
|
|
}
|
|
|
|
public PreChecksViewModel(IScreen host) : base(host)
|
|
{
|
|
var data = ServiceHelper.Get<InternalData?>();
|
|
var installer = ServiceHelper.Get<InstallController?>();
|
|
|
|
if (data == null || installer == null)
|
|
{
|
|
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Failed to get required service for prechecks")));
|
|
return;
|
|
}
|
|
|
|
data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
|
|
data.TargetInstallPath = Environment.CurrentDirectory;
|
|
InstallPath = data.TargetInstallPath;
|
|
|
|
StartInstallCommand = ReactiveCommand.Create(() => NavigateTo(new InstallViewModel(HostScreen)));
|
|
|
|
Task.Run(async () =>
|
|
{
|
|
var result = await installer.RunPreChecks();
|
|
PreCheckSucceeded = result.Succeeded;
|
|
});
|
|
}
|
|
} |