Compare commits
5 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13d411e4de | ||
|
|
9f53b07491 | ||
|
|
cd8113dadf | ||
|
|
9089c4ffe5 | ||
|
|
fe9d8d05bd |
@@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
private static string GetDiskCachePath()
|
private static string GetDiskCachePath()
|
||||||
{
|
{
|
||||||
return GraphicsConfig.EnableShaderCache && GraphicsConfig.TitleId != null
|
return GraphicsConfig.EnableShaderCache && GraphicsConfig.TitleId != null
|
||||||
? Path.Combine(AppDataManager.GamesDirPath, GraphicsConfig.TitleId, "cache", "shader")
|
? Path.Combine(AppDataManager.GamesDirPath, GraphicsConfig.TitleId.ToLower(), "cache", "shader")
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Avalonia.Controls.Notifications;
|
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
using Gommon;
|
||||||
using LibHac;
|
using LibHac;
|
||||||
using LibHac.Account;
|
using LibHac.Account;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
@@ -15,6 +15,7 @@ using LibHac.Tools.FsSystem.NcaUtils;
|
|||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Controls;
|
using Ryujinx.Ava.UI.Controls;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
|
using Ryujinx.Ava.Utilities;
|
||||||
using Ryujinx.Ava.Utilities.Configuration;
|
using Ryujinx.Ava.Utilities.Configuration;
|
||||||
using Ryujinx.Common.Helper;
|
using Ryujinx.Common.Helper;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
@@ -418,35 +419,27 @@ namespace Ryujinx.Ava.Common
|
|||||||
|
|
||||||
public static async Task ExtractAoc(IStorageProvider storageProvider, string updateFilePath, string updateName)
|
public static async Task ExtractAoc(IStorageProvider storageProvider, string updateFilePath, string updateName)
|
||||||
{
|
{
|
||||||
var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
Optional<IStorageFolder> result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions
|
||||||
{
|
{
|
||||||
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle],
|
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle]
|
||||||
AllowMultiple = false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.Count == 0)
|
if (!result.HasValue) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtractAoc(result[0].Path.LocalPath, updateFilePath, updateName);
|
ExtractAoc(result.Value.Path.LocalPath, updateFilePath, updateName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
|
public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
|
||||||
{
|
{
|
||||||
var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
Optional<IStorageFolder> result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions
|
||||||
{
|
{
|
||||||
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle],
|
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle]
|
||||||
AllowMultiple = false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.Count == 0)
|
if (!result.HasValue) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtractSection(result[0].Path.LocalPath, ncaSectionType, titleFilePath, titleName, programIndex);
|
ExtractSection(result.Value.Path.LocalPath, ncaSectionType, titleFilePath, titleName, programIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (Result? result, bool canceled) CopyDirectory(FileSystemClient fs, string sourcePath, string destPath, CancellationToken token)
|
public static (Result? result, bool canceled) CopyDirectory(FileSystemClient fs, string sourcePath, string destPath, CancellationToken token)
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
{
|
{
|
||||||
if (sender is MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
|
if (sender is MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
|
||||||
{
|
{
|
||||||
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "shader");
|
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString.ToLower(), "cache", "shader");
|
||||||
|
|
||||||
if (!Directory.Exists(shaderCacheDir))
|
if (!Directory.Exists(shaderCacheDir))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1662,10 +1662,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public async Task OpenAmiiboWindow()
|
public async Task OpenAmiiboWindow()
|
||||||
{
|
{
|
||||||
if (!IsAmiiboRequested)
|
if (AppHost.Device.System.SearchingForAmiibo(out int deviceId) && IsGameRunning)
|
||||||
return;
|
|
||||||
|
|
||||||
if (AppHost.Device.System.SearchingForAmiibo(out int deviceId))
|
|
||||||
{
|
{
|
||||||
string titleId = AppHost.Device.Processes.ActiveApplication.ProgramIdText.ToUpper();
|
string titleId = AppHost.Device.Processes.ActiveApplication.ProgramIdText.ToUpper();
|
||||||
AmiiboWindow window = new(ShowAll, LastScannedAmiiboId, titleId);
|
AmiiboWindow window = new(ShowAll, LastScannedAmiiboId, titleId);
|
||||||
@@ -1683,10 +1680,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
public async Task OpenBinFile()
|
public async Task OpenBinFile()
|
||||||
{
|
{
|
||||||
if (!IsAmiiboRequested)
|
if (AppHost.Device.System.SearchingForAmiibo(out _) && IsGameRunning)
|
||||||
return;
|
|
||||||
|
|
||||||
if (AppHost.Device.System.SearchingForAmiibo(out int deviceId))
|
|
||||||
{
|
{
|
||||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,8 +114,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
MinWidth="90"
|
MinWidth="90"
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
ToolTip.Tip="{ext:Locale AddGameDirTooltip}"
|
ToolTip.Tip="{ext:Locale AddGameDirTooltip}">
|
||||||
Click="AddGameDirButton_OnClick">
|
|
||||||
<TextBlock HorizontalAlignment="Center"
|
<TextBlock HorizontalAlignment="Center"
|
||||||
Text="{ext:Locale SettingsTabGeneralAdd}" />
|
Text="{ext:Locale SettingsTabGeneralAdd}" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -168,8 +167,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
MinWidth="90"
|
MinWidth="90"
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
ToolTip.Tip="{ext:Locale AddAutoloadDirTooltip}"
|
ToolTip.Tip="{ext:Locale AddAutoloadDirTooltip}">
|
||||||
Click="AddAutoloadDirButton_OnClick">
|
|
||||||
<TextBlock HorizontalAlignment="Center"
|
<TextBlock HorizontalAlignment="Center"
|
||||||
Text="{ext:Locale SettingsTabGeneralAdd}" />
|
Text="{ext:Locale SettingsTabGeneralAdd}" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
|
using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.VisualTree;
|
using Avalonia.VisualTree;
|
||||||
|
using Gommon;
|
||||||
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using Ryujinx.Ava.Utilities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Settings
|
namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
@@ -18,31 +23,39 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ShowTitleBarBox.IsVisible = OperatingSystem.IsWindows();
|
ShowTitleBarBox.IsVisible = OperatingSystem.IsWindows();
|
||||||
|
AddGameDirButton.Command =
|
||||||
|
Commands.Create(() => AddDirButton(GameDirPathBox, ViewModel.GameDirectories, true));
|
||||||
|
AddAutoloadDirButton.Command =
|
||||||
|
Commands.Create(() => AddDirButton(AutoloadDirPathBox, ViewModel.AutoloadDirectories, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AddGameDirButton_OnClick(object sender, RoutedEventArgs e)
|
private async Task AddDirButton(TextBox addDirBox, AvaloniaList<string> directories, bool isGameList)
|
||||||
{
|
{
|
||||||
string path = GameDirPathBox.Text;
|
string path = addDirBox.Text;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !ViewModel.GameDirectories.Contains(path))
|
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !directories.Contains(path))
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Add(path);
|
directories.Add(path);
|
||||||
ViewModel.GameDirectoryChanged = true;
|
|
||||||
|
addDirBox.Clear();
|
||||||
|
|
||||||
|
if (isGameList)
|
||||||
|
ViewModel.GameDirectoryChanged = true;
|
||||||
|
else
|
||||||
|
ViewModel.AutoloadDirectoryChanged = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this.GetVisualRoot() is Window window)
|
Optional<IStorageFolder> folder = await RyujinxApp.MainWindow.ViewModel.StorageProvider.OpenSingleFolderPickerAsync();
|
||||||
{
|
|
||||||
var result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
|
||||||
{
|
|
||||||
AllowMultiple = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result.Count > 0)
|
if (folder.HasValue)
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Add(result[0].Path.LocalPath);
|
directories.Add(folder.Value.Path.LocalPath);
|
||||||
|
|
||||||
|
if (isGameList)
|
||||||
ViewModel.GameDirectoryChanged = true;
|
ViewModel.GameDirectoryChanged = true;
|
||||||
}
|
else
|
||||||
|
ViewModel.AutoloadDirectoryChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,33 +76,6 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AddAutoloadDirButton_OnClick(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
string path = AutoloadDirPathBox.Text;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !ViewModel.AutoloadDirectories.Contains(path))
|
|
||||||
{
|
|
||||||
ViewModel.AutoloadDirectories.Add(path);
|
|
||||||
ViewModel.AutoloadDirectoryChanged = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (this.GetVisualRoot() is Window window)
|
|
||||||
{
|
|
||||||
var result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
|
||||||
{
|
|
||||||
AllowMultiple = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result.Count > 0)
|
|
||||||
{
|
|
||||||
ViewModel.AutoloadDirectories.Add(result[0].Path.LocalPath);
|
|
||||||
ViewModel.AutoloadDirectoryChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemoveAutoloadDirButton_OnClick(object sender, RoutedEventArgs e)
|
private void RemoveAutoloadDirButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
int oldIndex = AutoloadDirsList.SelectedIndex;
|
int oldIndex = AutoloadDirsList.SelectedIndex;
|
||||||
|
|||||||
47
src/Ryujinx/Utilities/StorageProviderExtensions.cs
Normal file
47
src/Ryujinx/Utilities/StorageProviderExtensions.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
using Gommon;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities
|
||||||
|
{
|
||||||
|
public static class StorageProviderExtensions
|
||||||
|
{
|
||||||
|
public static async Task<Optional<IStorageFolder>> OpenSingleFolderPickerAsync(this IStorageProvider storageProvider, FolderPickerOpenOptions openOptions = null) =>
|
||||||
|
await storageProvider.OpenFolderPickerAsync(FixOpenOptions(openOptions, false))
|
||||||
|
.Then(folders => folders.FindFirst());
|
||||||
|
|
||||||
|
public static async Task<Optional<IStorageFile>> OpenSingleFilePickerAsync(this IStorageProvider storageProvider, FilePickerOpenOptions openOptions = null) =>
|
||||||
|
await storageProvider.OpenFilePickerAsync(FixOpenOptions(openOptions, false))
|
||||||
|
.Then(files => files.FindFirst());
|
||||||
|
|
||||||
|
public static async Task<Optional<IReadOnlyList<IStorageFolder>>> OpenMultiFolderPickerAsync(this IStorageProvider storageProvider, FolderPickerOpenOptions openOptions = null) =>
|
||||||
|
await storageProvider.OpenFolderPickerAsync(FixOpenOptions(openOptions, true))
|
||||||
|
.Then(folders => folders.Count > 0 ? Optional.Of(folders) : default);
|
||||||
|
|
||||||
|
public static async Task<Optional<IReadOnlyList<IStorageFile>>> OpenMultiFilePickerAsync(this IStorageProvider storageProvider, FilePickerOpenOptions openOptions = null) =>
|
||||||
|
await storageProvider.OpenFilePickerAsync(FixOpenOptions(openOptions, true))
|
||||||
|
.Then(files => files.Count > 0 ? Optional.Of(files) : default);
|
||||||
|
|
||||||
|
private static FilePickerOpenOptions FixOpenOptions(this FilePickerOpenOptions openOptions, bool allowMultiple)
|
||||||
|
{
|
||||||
|
if (openOptions is null)
|
||||||
|
return new FilePickerOpenOptions { AllowMultiple = allowMultiple };
|
||||||
|
|
||||||
|
openOptions.AllowMultiple = allowMultiple;
|
||||||
|
|
||||||
|
return openOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static FolderPickerOpenOptions FixOpenOptions(this FolderPickerOpenOptions openOptions, bool allowMultiple)
|
||||||
|
{
|
||||||
|
if (openOptions is null)
|
||||||
|
return new FolderPickerOpenOptions { AllowMultiple = allowMultiple };
|
||||||
|
|
||||||
|
openOptions.AllowMultiple = allowMultiple;
|
||||||
|
|
||||||
|
return openOptions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user