diff --git a/assets/locales.json b/assets/locales.json index be67c5122..20ecbf6a0 100644 --- a/assets/locales.json +++ b/assets/locales.json @@ -896,25 +896,25 @@ "ID": "MenuBarFileActionsInstallKeysFromFile", "Translations": { "ar_SA": "", - "de_DE": "Schlüssel (.KEYS oder .ZIP) installieren", + "de_DE": "Schlüssel (.KEYS) installieren", "el_GR": "", - "en_US": "Install Keys (.KEYS or .ZIP)", - "es_ES": "Instalar keys (.KEYS o .ZIP)", - "fr_FR": "Installer des Clés (.KEYS ou .ZIP)", + "en_US": "Install Keys (.KEYS)", + "es_ES": "Instalar keys (.KEYS)", + "fr_FR": "Installer des Clés (.KEYS)", "he_IL": "", - "it_IT": "Installa chiavi (.KEYS o .ZIP)", + "it_IT": "Installa chiavi (.KEYS)", "ja_JP": "", - "ko_KR": "키 설치 (.KEYS 또는 .ZIP)", - "no_NO": "Installer nøkler (.KEYS eller .ZIP)", + "ko_KR": "키 설치 (.KEYS)", + "no_NO": "Installer nøkler (.KEYS)", "pl_PL": "", - "pt_BR": "Instalar chaves (.KEYS ou .ZIP", - "ru_RU": "Установить ключи (.KEYS или .ZIP)", - "sv_SE": "Installera nycklar (.KEYS eller .ZIP)", - "th_TH": "ติดตั้งคีย์ (.KEYS หรือ .ZIP)", + "pt_BR": "Instalar chaves (.KEYS)", + "ru_RU": "Установить ключи (.KEYS)", + "sv_SE": "Installera nycklar (.KEYS)", + "th_TH": "ติดตั้งคีย์ (.KEYS)", "tr_TR": "", - "uk_UA": "Встановити ключі (.KEYS або .ZIP)", - "zh_CN": "安装密钥(.KEYS 或 .ZIP)", - "zh_TW": "安裝金鑰(.KEYS 或 .ZIP)" + "uk_UA": "Встановити ключі (.KEYS)", + "zh_CN": "安装密钥(.KEYS)", + "zh_TW": "安裝金鑰(.KEYS)" } }, { diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index 6ce19efee..9c6bfced6 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -501,53 +501,13 @@ namespace Ryujinx.HLE.FileSystem using FileStream file = File.OpenRead(keysSource); - switch (info.Extension) + if (info.Extension is ".keys") { - case ".zip": - using (ZipArchive archive = ZipFile.OpenRead(keysSource)) - { - InstallKeysFromZip(archive, installDirectory); - } - - break; - case ".keys": - VerifyKeysFile(keysSource); - File.Copy(keysSource, Path.Combine(installDirectory, info.Name), true); - break; - default: - throw new InvalidFirmwarePackageException("Input file is not a valid key package"); - } - } - - private static void InstallKeysFromZip(ZipArchive archive, string installDirectory) - { - string temporaryDirectory = Path.Combine(installDirectory, "temp"); - if (Directory.Exists(temporaryDirectory)) - { - Directory.Delete(temporaryDirectory, true); - } - - Directory.CreateDirectory(temporaryDirectory); - foreach (ZipArchiveEntry entry in archive.Entries) - { - if (Path.GetExtension(entry.FullName).Equals(".keys", StringComparison.OrdinalIgnoreCase)) - { - string extractDestination = Path.Combine(temporaryDirectory, entry.Name); - entry.ExtractToFile(extractDestination, overwrite: true); - try - { - VerifyKeysFile(extractDestination); - File.Move(extractDestination, Path.Combine(installDirectory, entry.Name), true); - } - catch (Exception) - { - Directory.Delete(temporaryDirectory, true); - throw; - } - } - } - - Directory.Delete(temporaryDirectory, true); + VerifyKeysFile(keysSource); + File.Copy(keysSource, Path.Combine(installDirectory, info.Name), true); + } + else + throw new InvalidFirmwarePackageException("Input file is not a valid key package"); } private void FinishInstallation(string temporaryDirectory, string registeredDirectory) diff --git a/src/Ryujinx/Systems/AppHost.cs b/src/Ryujinx/Systems/AppHost.cs index 29eb0a8ec..89f9412ba 100644 --- a/src/Ryujinx/Systems/AppHost.cs +++ b/src/Ryujinx/Systems/AppHost.cs @@ -1045,7 +1045,7 @@ namespace Ryujinx.Ava.Systems _viewModel.Window.TitleBar.ExtendsContentIntoTitleBar = true; } - if (_viewModel.WindowState is WindowState.FullScreen || _viewModel.StartGamesWithoutUI) + if (_viewModel.WindowState is WindowState.FullScreen || _viewModel.StartGamesWithoutUi) { _viewModel.ShowMenuAndStatusBar = false; } diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 9ffe48779..99b269ab1 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -562,7 +562,7 @@ namespace Ryujinx.Ava.UI.ViewModels } } - public bool StartGamesWithoutUI + public bool StartGamesWithoutUi { get => ConfigurationState.Instance.UI.StartNoUI; set @@ -974,9 +974,8 @@ namespace Ryujinx.Ava.UI.ViewModels string dialogTitle = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallTitle); string dialogMessage = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallMessage); - - bool alreadyKesyInstalled = ContentManager.AreKeysAlredyPresent(systemDirectory); - if (alreadyKesyInstalled) + + if (ContentManager.AreKeysAlredyPresent(systemDirectory)) { dialogMessage += LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallSubMessage); } @@ -994,7 +993,7 @@ namespace Ryujinx.Ava.UI.ViewModels if (result == UserResult.Yes) { - Logger.Info?.Print(LogClass.Application, $"Installing Keys"); + Logger.Info?.Print(LogClass.Application, $"Installing keys from {filename}"); Thread thread = new(() => { @@ -1206,15 +1205,14 @@ namespace Ryujinx.Ava.UI.ViewModels private async Task LoadContentFromFolder(LocaleKeys localeMessageAddedKey, LocaleKeys localeMessageRemovedKey, LoadContentFromFolderDelegate onDirsSelected, LocaleKeys dirSelectDialogTitle) { - IReadOnlyList result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions + Optional> result = await StorageProvider.OpenMultiFolderPickerAsync(new FolderPickerOpenOptions { - Title = LocaleManager.Instance[dirSelectDialogTitle], - AllowMultiple = true, + Title = LocaleManager.Instance[dirSelectDialogTitle] }); - if (result.Count > 0) + if (result.TryGet(out IReadOnlyList foldersToLoad)) { - List dirs = result.Select(it => it.Path.LocalPath).ToList(); + List dirs = foldersToLoad.Select(it => it.Path.LocalPath).ToList(); int numAdded = onDirsSelected(dirs, out int numRemoved); string msg = string.Join("\n", @@ -1270,51 +1268,26 @@ namespace Ryujinx.Ava.UI.ViewModels } } - public void TakeScreenshot() - { - AppHost.ScreenshotRequested = true; - } + public void TakeScreenshot() => AppHost.ScreenshotRequested = true; - public void HideUi() - { - ShowMenuAndStatusBar = false; - } + public void HideUi() => ShowMenuAndStatusBar = false; - public void ToggleStartGamesInFullscreen() - { - StartGamesInFullscreen = !StartGamesInFullscreen; - } + public void ToggleStartGamesInFullscreen() => StartGamesInFullscreen = !StartGamesInFullscreen; - public void ToggleStartGamesWithoutUI() - { - StartGamesWithoutUI = !StartGamesWithoutUI; - } + public void ToggleStartGamesWithoutUi() => StartGamesWithoutUi = !StartGamesWithoutUi; - public void ToggleShowConsole() - { - ShowConsole = !ShowConsole; - } + public void ToggleShowConsole() => ShowConsole = !ShowConsole; - public void SetListMode() - { - Glyph = Glyph.List; - } + public void SetListMode() => Glyph = Glyph.List; - public void SetGridMode() - { - Glyph = Glyph.Grid; - } + public void SetGridMode() => Glyph = Glyph.Grid; - public void SetAspectRatio(AspectRatio aspectRatio) - { - ConfigurationState.Instance.Graphics.AspectRatio.Value = aspectRatio; - } + public void SetAspectRatio(AspectRatio aspectRatio) => ConfigurationState.Instance.Graphics.AspectRatio.Value = aspectRatio; public async Task InstallFirmwareFromFile() { - IReadOnlyList result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { - AllowMultiple = false, FileTypeFilter = new List { new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes]) @@ -1338,69 +1311,50 @@ namespace Ryujinx.Ava.UI.ViewModels }, }); - if (result.Count > 0) + if (result.HasValue) { - await HandleFirmwareInstallation(result[0].Path.LocalPath); + await HandleFirmwareInstallation(result.Value.Path.LocalPath); } } public async Task InstallFirmwareFromFolder() { - IReadOnlyList result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions - { - AllowMultiple = false, - }); + Optional result = await StorageProvider.OpenSingleFolderPickerAsync(); - if (result.Count > 0) + if (result.HasValue) { - await HandleFirmwareInstallation(result[0].Path.LocalPath); + await HandleFirmwareInstallation(result.Value.Path.LocalPath); } } public async Task InstallKeysFromFile() { - IReadOnlyList result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { - AllowMultiple = false, FileTypeFilter = new List { - new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes]) - { - Patterns = ["*.keys", "*.zip"], - AppleUniformTypeIdentifiers = ["com.ryujinx.xci", "public.zip-archive"], - MimeTypes = ["application/keys", "application/zip"], - }, new("KEYS") { Patterns = ["*.keys"], AppleUniformTypeIdentifiers = ["com.ryujinx.xci"], MimeTypes = ["application/keys"], }, - new("ZIP") - { - Patterns = ["*.zip"], - AppleUniformTypeIdentifiers = ["public.zip-archive"], - MimeTypes = ["application/zip"], - }, }, }); - if (result.Count > 0) + if (result.HasValue) { - await HandleKeysInstallation(result[0].Path.LocalPath); + await HandleKeysInstallation(result.Value.Path.LocalPath); } } public async Task InstallKeysFromFolder() { - IReadOnlyList result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions - { - AllowMultiple = false, - }); + Optional result = await StorageProvider.OpenSingleFolderPickerAsync(); - if (result.Count > 0) + if (result.HasValue) { - await HandleKeysInstallation(result[0].Path.LocalPath); + await HandleKeysInstallation(result.Value.Path.LocalPath); } } @@ -1503,10 +1457,9 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task OpenFile() { - IReadOnlyList result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.LoadApplicationFromFileDialogTitle], - AllowMultiple = false, FileTypeFilter = new List { new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats]) @@ -1562,9 +1515,9 @@ namespace Ryujinx.Ava.UI.ViewModels }, }); - if (result.Count > 0) + if (result.HasValue) { - if (ApplicationLibrary.TryGetApplicationsFromFile(result[0].Path.LocalPath, + if (ApplicationLibrary.TryGetApplicationsFromFile(result.Value.Path.LocalPath, out List applications)) { await LoadApplication(applications[0]); @@ -1596,18 +1549,17 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task OpenFolder() { - IReadOnlyList result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions + Optional result = await StorageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions { - Title = LocaleManager.Instance[LocaleKeys.LoadUnpackedGameFromFolderDialogTitle], - AllowMultiple = false, + Title = LocaleManager.Instance[LocaleKeys.LoadUnpackedGameFromFolderDialogTitle] }); - if (result.Count > 0) + if (result.TryGet(out IStorageFolder value)) { ApplicationData applicationData = new() { - Name = Path.GetFileNameWithoutExtension(result[0].Path.LocalPath), - Path = result[0].Path.LocalPath, + Name = Path.GetFileNameWithoutExtension(value.Path.LocalPath), + Path = value.Path.LocalPath, }; await LoadApplication(applicationData); @@ -1812,10 +1764,9 @@ namespace Ryujinx.Ava.UI.ViewModels { if (AppHost.Device.System.SearchingForAmiibo(out _) && IsGameRunning) { - IReadOnlyList result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + Optional result = await StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.OpenFileDialogTitle], - AllowMultiple = false, FileTypeFilter = new List { new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats]) @@ -1824,9 +1775,10 @@ namespace Ryujinx.Ava.UI.ViewModels } } }); - if (result.Count > 0) + + if (result.HasValue) { - AppHost.Device.System.ScanAmiiboFromBin(result[0].Path.LocalPath); + AppHost.Device.System.ScanAmiiboFromBin(result.Value.Path.LocalPath); } } } diff --git a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml index ba3b94acf..9b5c85793 100755 --- a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml +++ b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml @@ -92,14 +92,14 @@