diff --git a/assets/locales.json b/assets/locales.json index 9da7fe28c..2171d7ecb 100644 --- a/assets/locales.json +++ b/assets/locales.json @@ -295,7 +295,7 @@ { "ID": "MenuBarFileOpenFromFile", "Translations": { - "ar_SA": "_تحميل التطبيق...", + "ar_SA": "_تحميل التطبيق...", "de_DE": "_Anwendung laden...", "el_GR": "_Φόρτωση εφαρμογής...", "en_US": "_Load Application...", @@ -6465,7 +6465,6 @@ "uk_UA": "Я хочу скинути налаштування.", "zh_CN": "我要重置我的设置。", "zh_TW": "我想重設我的設定。" - } }, { @@ -13718,6 +13717,56 @@ "zh_TW": "警告" } }, + { + "ID": "DialogDeleteAllCaches", + "Translations": { + "ar_SA": "", + "de_DE": "", + "el_GR": "", + "en_US": "You are about to clear all caches for all games.\n\nAre you sure you want to proceed?", + "es_ES": "", + "fr_FR": "", + "he_IL": "", + "it_IT": "", + "ja_JP": "", + "ko_KR": "", + "no_NO": "", + "pl_PL": "", + "pt_BR": "", + "ru_RU": "", + "sv_SE": "", + "th_TH": "", + "tr_TR": "", + "uk_UA": "", + "zh_CN": "", + "zh_TW": "" + } + }, + { + "ID": "DialogDeleteAllCachesErrorMessage", + "Translations": { + "ar_SA": "", + "de_DE": "", + "el_GR": "", + "en_US": "Failed to purge some caches, check log file.", + "es_ES": "", + "fr_FR": "", + "he_IL": "", + "it_IT": "", + "ja_JP": "", + "ko_KR": "", + "no_NO": "", + "pl_PL": "", + "pt_BR": "", + "ru_RU": "", + "sv_SE": "", + "th_TH": "", + "tr_TR": "", + "uk_UA": "", + "zh_CN": "", + "zh_TW": "" + } + }, { "ID": "DialogPPTCDeletionMessage", "Translations": { @@ -24218,6 +24267,31 @@ "zh_TW": "在執行首項指令前暫停應用程式,以便從最早的點開始除錯。" } }, + { + "ID": "SettingsTabDebugPurgeAllCaches", + "Translations": { + "ar_SA": "", + "de_DE": "", + "el_GR": "", + "en_US": "Purge All Caches", + "es_ES": "", + "fr_FR": "", + "he_IL": "", + "it_IT": "", + "ja_JP": "", + "ko_KR": "", + "no_NO": "", + "pl_PL": "", + "pt_BR": "", + "ru_RU": "", + "sv_SE": "", + "th_TH": "", + "tr_TR": "", + "uk_UA": "", + "zh_CN": "", + "zh_TW": "" + } + }, { "ID": "LdnGameListOpen", "Translations": { diff --git a/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml b/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml index f491dda24..f1ff9c5ea 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml +++ b/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml @@ -53,12 +53,19 @@ + diff --git a/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml.cs index 14a65b8b2..d7924ab52 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml.cs +++ b/src/Ryujinx/UI/Views/Settings/SettingsDebugView.axaml.cs @@ -1,4 +1,11 @@ using Avalonia.Controls; +using Avalonia.Interactivity; +using Ryujinx.Ava.Common.Locale; +using Ryujinx.Ava.UI.Helpers; +using Ryujinx.Common.Configuration; +using Ryujinx.Common.Logging; +using System; +using System.IO; namespace Ryujinx.Ava.UI.Views.Settings { @@ -8,6 +15,57 @@ namespace Ryujinx.Ava.UI.Views.Settings { InitializeComponent(); } + + private async void PurgeAllSharedCaches_OnClick(object sender, RoutedEventArgs routedEventArgs) + { + var appList = RyujinxApp.MainWindow.ViewModel.Applications; + + if (appList.Count == 0) + { + return; + } + + UserResult result = await ContentDialogHelper.CreateConfirmationDialog( + LocaleManager.Instance[LocaleKeys.DialogWarning], + LocaleManager.Instance[LocaleKeys.DialogDeleteAllCaches], + LocaleManager.Instance[LocaleKeys.InputDialogYes], + LocaleManager.Instance[LocaleKeys.InputDialogNo], + LocaleManager.Instance[LocaleKeys.RyujinxConfirm]); + bool hasErrors = false; + + if (result != UserResult.Yes) + { + return; + } + + foreach (var application in appList) + { + DirectoryInfo cacheDir = new(Path.Combine(AppDataManager.GamesDirPath, application.IdString, "cache")); + + if (!cacheDir.Exists) + { + continue; + } + + foreach (var finfo in cacheDir.EnumerateDirectories()) + { + try + { + finfo.Delete(true); + + } + catch (Exception ex) + { + Logger.Error?.Print(LogClass.Application, $"Failed to purge shader cache for {application.Name}({application.IdString}): {ex}"); + hasErrors = true; + } + } + } + + if (hasErrors) + { + await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogDeleteAllCachesErrorMessage]); + } + } } } -