aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs')
-rw-r--r--src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs
index f2f56947..74b73751 100644
--- a/src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs
+++ b/src/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs
@@ -1,6 +1,6 @@
using Avalonia.Collections;
-using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Platform.Storage;
using Avalonia.Threading;
using DynamicData;
using LibHac.Common;
@@ -90,12 +90,19 @@ namespace Ryujinx.Ava.UI.ViewModels
get => string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowHeading], DownloadableContents.Count);
}
+ public IStorageProvider StorageProvider;
+
public DownloadableContentManagerViewModel(VirtualFileSystem virtualFileSystem, ulong titleId)
{
_virtualFileSystem = virtualFileSystem;
_titleId = titleId;
+ if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ {
+ StorageProvider = desktop.MainWindow.StorageProvider;
+ }
+
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId.ToString("x16"), "dlc.json");
try
@@ -195,29 +202,24 @@ namespace Ryujinx.Ava.UI.ViewModels
public async void Add()
{
- OpenFileDialog dialog = new()
+ var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
Title = LocaleManager.Instance[LocaleKeys.SelectDlcDialogTitle],
AllowMultiple = true,
- };
-
- dialog.Filters.Add(new FileDialogFilter
- {
- Name = "NSP",
- Extensions = { "nsp" },
- });
-
- if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
- {
- string[] files = await dialog.ShowAsync(desktop.MainWindow);
-
- if (files != null)
+ FileTypeFilter = new List<FilePickerFileType>
{
- foreach (string file in files)
+ new("NSP")
{
- await AddDownloadableContent(file);
+ Patterns = new[] { "*.nsp" },
+ AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
+ MimeTypes = new[] { "application/x-nx-nsp" }
}
}
+ });
+
+ foreach (var file in result)
+ {
+ await AddDownloadableContent(file.Path.LocalPath);
}
}