diff --git a/src/BfmeFoundationProject_AllInOneLauncher/Elements/Native/FolderPicker.cs b/src/BfmeFoundationProject_AllInOneLauncher/Elements/Native/FolderPicker.cs new file mode 100644 index 0000000..adfce4f --- /dev/null +++ b/src/BfmeFoundationProject_AllInOneLauncher/Elements/Native/FolderPicker.cs @@ -0,0 +1,33 @@ +using System; +using System.IO; +using System.Windows; +using Microsoft.Win32; + +namespace BfmeFoundationProject.AllInOneLauncher.Elements.Native; + +internal static class FolderPicker +{ + public static string? ShowDialog(Window owner, string title = "", string? initialPath = null) + { + var dlg = new OpenFolderDialog + { + Title = title, + ValidateNames = true, + }; + + if (Directory.Exists(initialPath)) + { + dlg.InitialDirectory = initialPath; + } + + bool? result = dlg.ShowDialog(owner); + if (result == true) + { + var selected = dlg.FolderName; + if (Directory.Exists(selected)) + return selected; + } + + return null; + } +} diff --git a/src/BfmeFoundationProject_AllInOneLauncher/Pages/Primary/Offline.xaml.cs b/src/BfmeFoundationProject_AllInOneLauncher/Pages/Primary/Offline.xaml.cs index e16a98e..5bad012 100644 --- a/src/BfmeFoundationProject_AllInOneLauncher/Pages/Primary/Offline.xaml.cs +++ b/src/BfmeFoundationProject_AllInOneLauncher/Pages/Primary/Offline.xaml.cs @@ -113,8 +113,15 @@ private void OnLaunchGameClicked(object sender, EventArgs e) private void OnInstallGameClicked(object sender, EventArgs e) { - PopupVisualizer.ShowPopup(new InstallGamePopup(), - OnPopupSubmited: async (submittedData) => await BfmeSyncManager.InstallGame((BfmeGame)gameTabs.SelectedIndex, submittedData[0], submittedData[1])); + try + { + PopupVisualizer.ShowPopup(new InstallGamePopup(), + OnPopupSubmited: async (submittedData) => await BfmeSyncManager.InstallGame((BfmeGame)gameTabs.SelectedIndex, submittedData[0], submittedData[1])); + } + catch (Exception ex) + { + PopupVisualizer.ShowPopup(new ErrorPopup(ex)); + } } private async void TabChanged(object sender, EventArgs e) diff --git a/src/BfmeFoundationProject_AllInOneLauncher/Popups/InstallGamePopup.xaml b/src/BfmeFoundationProject_AllInOneLauncher/Popups/InstallGamePopup.xaml index 31ce196..634332c 100644 --- a/src/BfmeFoundationProject_AllInOneLauncher/Popups/InstallGamePopup.xaml +++ b/src/BfmeFoundationProject_AllInOneLauncher/Popups/InstallGamePopup.xaml @@ -9,6 +9,7 @@ xmlns:generic="clr-namespace:BfmeFoundationProject.AllInOneLauncher.Elements.Generic" mc:Ignorable="d" Width="700" HorizontalAlignment="Center" VerticalAlignment="Center"> + @@ -17,7 +18,7 @@ - + @@ -48,7 +49,7 @@ - + English French @@ -62,14 +63,42 @@ - - - + + + + + + + + + + + + + + + + + + -