Merge branch 'purgeall' into 'master'

Main window: menu bar: add purge all caches button

See merge request [ryubing/ryujinx!179](https://git.ryujinx.app/ryubing/ryujinx/-/merge_requests/179)
merge-requests/179/merge
Xam 2025-10-26 21:07:50 +01:00
commit 1bfe5c6412
3 changed files with 142 additions and 3 deletions

View File

@ -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": {

View File

@ -53,12 +53,19 @@
</StackPanel>
<StackPanel
Margin="10,0,0,0"
Spacing="10"
HorizontalAlignment="Stretch"
Orientation="Vertical">
<CheckBox IsChecked="{Binding DebuggerSuspendOnStart}">
<TextBlock Text="{ext:Locale SettingsTabDebugSuspendOnStart}"
ToolTip.Tip="{ext:Locale SettingsTabDebugSuspendOnStartTooltip}" />
</CheckBox>
<Button
Click="PurgeAllSharedCaches_OnClick"
>
<TextBlock HorizontalAlignment="Center"
Text="{ext:Locale SettingsTabDebugPurgeAllCaches}" />
</Button>
</StackPanel>
</StackPanel>
</Border>

View File

@ -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]);
}
}
}
}