Merge pull request 'master' (#16) from CWX/SPT-AKI-Installer:master into master

Reviewed-on: waffle.lord/SPT-AKI-Installer#16
This commit is contained in:
IsWaffle 2023-10-19 00:55:14 +00:00
commit 74d48b90b1
11 changed files with 118 additions and 14 deletions

13
.idea/.idea.SPTInstaller/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/.idea.SPTInstaller.iml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

1
.idea/.idea.SPTInstaller/.idea/.name generated Normal file
View File

@ -0,0 +1 @@
SPTInstaller

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AvaloniaProject">
<option name="projectPerEditor">
<map>
<entry key="SPTInstaller/CustomControls/DetailedPreCheckItem.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/CustomControls/PreCheckItem.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/CustomControls/SPTInstallButton.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/Views/DetailedPreChecksView.axaml" value="SPTInstaller/SPTInstaller.csproj" />
<entry key="SPTInstaller/Views/PreChecksView.axaml" value="SPTInstaller/SPTInstaller.csproj" />
</map>
</option>
</component>
</project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

6
.idea/.idea.SPTInstaller/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -22,7 +22,7 @@
<Label Grid.Column="1"
Content="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}}"
Classes.bold="{Binding State, RelativeSource={RelativeSource AncestorType=UserControl}
Classes.bold="{Binding State, RelativeSource={RelativeSource AncestorType=UserControl},
Converter={StaticResource ResourceKey=IsStateConverter},
ConverterParameter=Running}"
/>

View File

@ -9,8 +9,9 @@
<PackageIcon>icon.ico</PackageIcon>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<Configurations>Debug;Release;TEST</Configurations>
<AssemblyVersion>2.16</AssemblyVersion>
<FileVersion>2.16</FileVersion>
<AssemblyVersion>2.17</AssemblyVersion>
<FileVersion>2.17</FileVersion>
<Company>SPT-AKI</Company>
</PropertyGroup>
<ItemGroup>

View File

@ -5,6 +5,8 @@ using System.Windows.Input;
using Avalonia.Controls;
using Avalonia.Threading;
using DialogHostAvalonia;
using Gitea.Api;
using Gitea.Client;
using ReactiveUI;
using Serilog;
using SPTInstaller.Controllers;
@ -25,7 +27,7 @@ public class PreChecksViewModel : ViewModelBase
public ICommand DismissUpdateCommand { get; set; }
public InstallerUpdateInfo UpdateInfo { get; set; } = new InstallerUpdateInfo();
public InstallerUpdateInfo UpdateInfo { get; set; } = new();
private string _installPath;
public string InstallPath
@ -34,6 +36,14 @@ public class PreChecksViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _installPath, value);
}
private string _installButtonText;
public string InstallButtonText
{
get => _installButtonText;
set => this.RaiseAndSetIfChanged(ref _installButtonText, value);
}
private bool _allowInstall;
public bool AllowInstall
{
@ -62,11 +72,21 @@ public class PreChecksViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _cacheCheckState, value);
}
private StatusSpinner.SpinnerState _installButtonCheckState;
public StatusSpinner.SpinnerState InstallButtonCheckState
{
get => _installButtonCheckState;
set => this.RaiseAndSetIfChanged(ref _installButtonCheckState, value);
}
public PreChecksViewModel(IScreen host) : base(host)
{
var data = ServiceHelper.Get<InternalData?>();
var installer = ServiceHelper.Get<InstallController?>();
InstallButtonText = "Please wait ...";
InstallButtonCheckState = StatusSpinner.SpinnerState.Pending;
if (data == null || installer == null)
{
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Failed to get required service for prechecks")));
@ -75,6 +95,11 @@ public class PreChecksViewModel : ViewModelBase
data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
data.TargetInstallPath = Environment.CurrentDirectory;
InstallPath = data.TargetInstallPath;
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
#if !TEST
if (data.OriginalGamePath == null)
{
@ -83,11 +108,6 @@ public class PreChecksViewModel : ViewModelBase
}
#endif
data.TargetInstallPath = Environment.CurrentDirectory;
InstallPath = data.TargetInstallPath;
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
if (data.OriginalGamePath == data.TargetInstallPath)
{
Log.CloseAndFlush();
@ -156,10 +176,38 @@ public class PreChecksViewModel : ViewModelBase
Task.Run(async () =>
{
// run prechecks
var result = await installer.RunPreChecks();
// check for updates
await UpdateInfo.CheckForUpdates(Assembly.GetExecutingAssembly().GetName()?.Version);
// get latest spt version
InstallButtonText = "Getting latest release ...";
InstallButtonCheckState = StatusSpinner.SpinnerState.Running;
var repo = new RepositoryApi(Configuration.Default);
var akiRepoReleases = await repo.RepoListReleasesAsync("SPT-AKI", "Stable-releases");
if (akiRepoReleases == null || akiRepoReleases.Count == 0)
{
InstallButtonText = "Could not get SPT releases from repo";
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
return;
}
var latestAkiRelease = akiRepoReleases.FindAll(x => !x.Prerelease)[0];
if (latestAkiRelease == null)
{
InstallButtonText = "Could not find the latest SPT release";
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
return;
}
InstallButtonText = $"Start Install: SPT v{latestAkiRelease.TagName}";
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
AllowDetailsButton = true;
AllowInstall = result.Succeeded;
});

View File

@ -24,14 +24,18 @@
Margin="5"
/>
<Button Grid.Row="1" Grid.RowSpan="3" Grid.Column="3"
Content="Start Install" Padding="20 10"
<Button Grid.Row="1" Grid.RowSpan="3" Grid.Column="3" Padding="20 10"
VerticalAlignment="Top"
FontSize="15" FontWeight="SemiBold"
Classes="yellow"
IsEnabled="{Binding AllowInstall}"
Command="{Binding StartInstallCommand}"
/>
>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding InstallButtonText}" VerticalAlignment="Center" Foreground="Black"/>
<cc:StatusSpinner State="{Binding InstallButtonCheckState}" Margin="2" IsVisible="{Binding !AllowInstall}"/>
</StackPanel>
</Button>
<ScrollViewer Grid.Row="4" Grid.ColumnSpan="5">
<ItemsControl ItemsSource="{Binding PreChecks}">

View File

@ -19,13 +19,18 @@
HorizontalAlignment="Center"
/>
</StackPanel>
<Button Grid.Column="2" Grid.Row="3" Content="Start Install" Padding="20 10"
<Button Grid.Column="2" Grid.Row="3" Padding="20 10"
Margin="10"
FontSize="15" FontWeight="SemiBold"
Classes="yellow"
IsEnabled="{Binding AllowInstall}"
Command="{Binding StartInstallCommand}"
/>
>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding InstallButtonText}" VerticalAlignment="Center" Foreground="Black"/>
<cc:StatusSpinner State="{Binding InstallButtonCheckState}" Margin="2" IsVisible="{Binding !AllowInstall}"/>
</StackPanel>
</Button>
<ItemsControl ItemsSource="{Binding PreChecks}" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="4" HorizontalAlignment="Center">
<ItemsControl.ItemsPanel>