diff --git a/project/SPT.Launcher/ViewModels/ProfileViewModel.cs b/project/SPT.Launcher/ViewModels/ProfileViewModel.cs index 59e8c4a..9151fed 100644 --- a/project/SPT.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/SPT.Launcher/ViewModels/ProfileViewModel.cs @@ -18,8 +18,6 @@ namespace SPT.Launcher.ViewModels [RequireLoggedIn] public class ProfileViewModel : ViewModelBase { - // public string CurrentUsername { get; set; } - private string _CurrentEdition; public string CurrentEdition { @@ -65,8 +63,6 @@ namespace SPT.Launcher.ViewModels _monitor = new ProcessMonitor("EscapeFromTarkov", 1000, aliveCallback: GameAliveCallBack, exitCallback: GameExitCallback); - // CurrentUsername = AccountManager.SelectedAccount.username; - CurrentEdition = AccountManager.SelectedAccount.edition; CurrentId = AccountManager.SelectedAccount.id; diff --git a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs index 6010d71..54d8902 100644 --- a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs +++ b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs @@ -11,7 +11,9 @@ using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading.Tasks; +using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.Notifications; +using Avalonia.Platform.Storage; namespace SPT.Launcher.ViewModels { @@ -148,18 +150,22 @@ namespace SPT.Launcher.ViewModels public async Task SelectGameFolderCommand() { - OpenFolderDialog dialog = new OpenFolderDialog(); - - dialog.Directory = Assembly.GetExecutingAssembly().Location; - - if (Application.Current?.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktop) + if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - string? result = await dialog.ShowAsync(desktop.MainWindow); - - if (result != null) + var startPath = await desktop.MainWindow.StorageProvider.TryGetFolderFromPathAsync(Assembly.GetExecutingAssembly().Location); + + var dir = await desktop.MainWindow.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions() { - LauncherSettingsProvider.Instance.GamePath = result; + Title = "Select your SPT folder", + SuggestedStartLocation = startPath + }); + + if (dir == null || dir.Count == 0) + { + return; } + + LauncherSettingsProvider.Instance.GamePath = dir[0].Path.LocalPath; } } } diff --git a/project/SPT.Launcher/Views/ProfileView.axaml b/project/SPT.Launcher/Views/ProfileView.axaml index 6dd8aa4..0a8dab6 100644 --- a/project/SPT.Launcher/Views/ProfileView.axaml +++ b/project/SPT.Launcher/Views/ProfileView.axaml @@ -13,7 +13,7 @@ ProfileInfo="{Binding ProfileInfo}" CurrentEdition="{Binding CurrentEdition}" CurrentId="{Binding CurrentId}" - WipeProfileOnStart="{Binding WipeProfileOnStart}" + WipeProfileOnStart="{Binding WipeProfileOnStart, Mode=TwoWay}" ProfileWipePending="{Binding ProfileWipePending}" CopyCommand="{Binding CopyCommand}" ChangeEditionCommand="{Binding ChangeEditionCommand}"