Merge pull request 'master' (#8) from CWX/SPT-AKI-Installer:master into master
Reviewed-on: waffle.lord/SPT-AKI-Installer#8
This commit is contained in:
commit
ea771037af
@ -2,6 +2,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:SPTInstaller"
|
||||
x:Class="SPTInstaller.App"
|
||||
xmlns:dialogHostAvalonia="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||
RequestedThemeVariant="Light">
|
||||
<Application.DataTemplates>
|
||||
<local:ViewLocator/>
|
||||
@ -9,6 +10,7 @@
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
<dialogHostAvalonia:DialogHostStyles />
|
||||
</Application.Styles>
|
||||
|
||||
<Application.Resources>
|
||||
|
28
SPTInstaller/CustomControls/Dialogs/ConfirmationDialog.axaml
Normal file
28
SPTInstaller/CustomControls/Dialogs/ConfirmationDialog.axaml
Normal file
@ -0,0 +1,28 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="300"
|
||||
x:Class="SPTInstaller.CustomControls.Dialogs.ConfirmationDialog"
|
||||
MinWidth="300" MinHeight="100"
|
||||
MaxWidth="600" MaxHeight="300">
|
||||
<Grid RowDefinitions="10,AUTO,*,AUTO,10" ColumnDefinitions="10,*,AUTO,10,AUTO,10"
|
||||
Background="{StaticResource AKI_Background_Light}">
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4"
|
||||
Text="{Binding Message, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
TextWrapping="Wrap"
|
||||
/>
|
||||
<Button Content="No" Grid.Row="3" Grid.Column="2"
|
||||
Width="50" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}"
|
||||
CommandParameter="False"
|
||||
Classes="yellow"
|
||||
/>
|
||||
<Button Content="Yes" Grid.Row="3" Grid.Column="4"
|
||||
Width="50" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}"
|
||||
CommandParameter="True"
|
||||
/>
|
||||
</Grid>
|
||||
</UserControl>
|
@ -0,0 +1,22 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace SPTInstaller.CustomControls.Dialogs;
|
||||
public partial class ConfirmationDialog : UserControl
|
||||
{
|
||||
public ConfirmationDialog(string message)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => GetValue(MessageProperty);
|
||||
set => SetValue(MessageProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<string> MessageProperty =
|
||||
AvaloniaProperty.Register<ConfirmationDialog, string>(nameof(Message));
|
||||
}
|
@ -111,4 +111,13 @@ public static class FileHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckPathForProblemLocations(string path)
|
||||
{
|
||||
if (path.ToLower().EndsWith("desktop")) return true;
|
||||
|
||||
var problemNames = new string[] {"onedrive", "nextcloud", "dropbox", "google" };
|
||||
|
||||
return problemNames.Where(x => path.ToLower().Contains(x)).Count() > 0;
|
||||
}
|
||||
|
||||
}
|
@ -33,8 +33,9 @@ internal class Program
|
||||
ServiceHelper.Register<InternalData>();
|
||||
ServiceHelper.Register<PreCheckBase, NetFramework472PreCheck>();
|
||||
ServiceHelper.Register<PreCheckBase, NetCore6PreCheck>();
|
||||
ServiceHelper.Register<PreCheckBase, FreeSpacePreCheck>();
|
||||
|
||||
#if !TEST
|
||||
ServiceHelper.Register<PreCheckBase, FreeSpacePreCheck>();
|
||||
var logPath = Path.Join(Environment.CurrentDirectory, "spt-aki-installer_.log");
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
|
@ -35,6 +35,7 @@
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.4" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.4" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.4" />
|
||||
<PackageReference Include="DialogHost.Avalonia" Version="0.7.6" />
|
||||
<PackageReference Include="FubarCoder.RestSharp.Portable.HttpClient" Version="4.0.8" />
|
||||
<PackageReference Include="MegaApiClient" Version="1.10.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
@ -1,11 +1,13 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Threading;
|
||||
using DialogHostAvalonia;
|
||||
using ReactiveUI;
|
||||
using Serilog;
|
||||
using SPTInstaller.Controllers;
|
||||
using SPTInstaller.CustomControls.Dialogs;
|
||||
using SPTInstaller.Helpers;
|
||||
using SPTInstaller.Models;
|
||||
|
||||
@ -58,17 +60,39 @@ public class PreChecksViewModel : ViewModelBase
|
||||
|
||||
data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
|
||||
|
||||
#if !TEST
|
||||
if (data.OriginalGamePath == null)
|
||||
{
|
||||
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Could not find EFT install.\n\nDo you own and have the game installed?")));
|
||||
}
|
||||
#endif
|
||||
|
||||
data.TargetInstallPath = Environment.CurrentDirectory;
|
||||
InstallPath = data.TargetInstallPath;
|
||||
|
||||
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
|
||||
|
||||
StartInstallCommand = ReactiveCommand.Create(() =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (FileHelper.CheckPathForProblemLocations(InstallPath))
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
Log.Warning("Problem folder detected, confirming install path ...");
|
||||
var confirmation = await DialogHost.Show(new ConfirmationDialog($"We suspect you may be installing to your desktop or a cloud synced folder.\nYou might want to consider installing somewhere else to avoid issues.\n\nAre you sure you want to install to this path?\n{InstallPath}"));
|
||||
|
||||
if (confirmation == null || !bool.TryParse(confirmation.ToString(), out var confirm) || !confirm)
|
||||
{
|
||||
Log.Information("User declined install path, exiting");
|
||||
Environment.Exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
Log.Information("User accepted install path");
|
||||
}
|
||||
});
|
||||
|
||||
StartInstallCommand = ReactiveCommand.Create(async () =>
|
||||
{
|
||||
UpdateInfo.ShowCard = false;
|
||||
NavigateTo(new InstallViewModel(HostScreen));
|
||||
|
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:cc="using:SPTInstaller.CustomControls"
|
||||
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SPTInstaller.Views.MainWindow"
|
||||
Icon="/Assets/icon.ico"
|
||||
@ -33,6 +34,8 @@
|
||||
MinButtonCommand="{Binding MinimizeCommand}"
|
||||
/>
|
||||
|
||||
<rxui:RoutedViewHost Router="{Binding Router}" Grid.Row="1"/>
|
||||
<dialogHost:DialogHost Grid.Row="1" Background="Transparent">
|
||||
<rxui:RoutedViewHost Router="{Binding Router}"/>
|
||||
</dialogHost:DialogHost>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
Loading…
x
Reference in New Issue
Block a user