mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-03-11 20:45:32 +00:00
Cleanup & successful deletion feedback
This commit is contained in:
parent
aef114c309
commit
71ad102f73
4 changed files with 118 additions and 68 deletions
|
|
@ -24292,6 +24292,56 @@
|
|||
"zh_TW": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "SettingsTabDebugPurgeAllCachesSuccessTitle",
|
||||
"Translations": {
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "All Shader & CPU caches deleted",
|
||||
"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": "SettingsTabDebugPurgeAllCachesSuccessText",
|
||||
"Translations": {
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "Destroyed the caches of {0} applications.",
|
||||
"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": {
|
||||
|
|
@ -24918,4 +24968,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@ using Avalonia.Media.Imaging;
|
|||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using DynamicData.Binding;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Audio.Backends.OpenAL;
|
||||
using Ryujinx.Audio.Backends.SDL3;
|
||||
using Ryujinx.Audio.Backends.SoundIo;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Systems.AppLibrary;
|
||||
using Ryujinx.Ava.Systems.Configuration;
|
||||
using Ryujinx.Ava.Systems.Configuration.System;
|
||||
using Ryujinx.Ava.Systems.Configuration.UI;
|
||||
|
|
@ -19,6 +21,7 @@ using Ryujinx.Common.Configuration;
|
|||
using Ryujinx.Common.Configuration.Multiplayer;
|
||||
using Ryujinx.Common.GraphicsDriver;
|
||||
using Ryujinx.Common.Helper;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Ryujinx.HLE;
|
||||
|
|
@ -912,7 +915,13 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
CloseWindow?.Invoke();
|
||||
}
|
||||
|
||||
[ObservableProperty] private bool _wantsToReset;
|
||||
public void CancelButton()
|
||||
{
|
||||
RevertIfNotSaved();
|
||||
CloseWindow?.Invoke();
|
||||
}
|
||||
|
||||
[ObservableProperty] public partial bool WantsToReset { get; set; }
|
||||
|
||||
public AsyncRelayCommand ResetButton => Commands.Create(async () =>
|
||||
{
|
||||
|
|
@ -932,10 +941,62 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
"Configuration Reset");
|
||||
});
|
||||
|
||||
public void CancelButton()
|
||||
public AsyncRelayCommand PurgeAllCaches => Commands.Create(async () =>
|
||||
{
|
||||
RevertIfNotSaved();
|
||||
CloseWindow?.Invoke();
|
||||
}
|
||||
ObservableCollectionExtended<ApplicationData> 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 (ApplicationData application in appList)
|
||||
{
|
||||
DirectoryInfo cacheDir = new(Path.Combine(AppDataManager.GamesDirPath, application.IdString, "cache"));
|
||||
|
||||
if (!cacheDir.Exists)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo dInfo in cacheDir.EnumerateDirectories())
|
||||
{
|
||||
try
|
||||
{
|
||||
dInfo.Delete(recursive: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.Application, $"Failed to purge shader cache for {application.Name} ({application.IdString}): {ex}");
|
||||
hasErrors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasErrors)
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogDeleteAllCachesErrorMessage]);
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationHelper.ShowSuccess(
|
||||
title: LocaleManager.Instance[LocaleKeys.SettingsTabDebugPurgeAllCachesSuccessTitle],
|
||||
text: LocaleManager.GetFormatted(LocaleKeys.SettingsTabDebugPurgeAllCachesSuccessText, appList.Count));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,7 @@
|
|||
<TextBlock Text="{ext:Locale SettingsTabDebugSuspendOnStart}"
|
||||
ToolTip.Tip="{ext:Locale SettingsTabDebugSuspendOnStartTooltip}" />
|
||||
</CheckBox>
|
||||
<Button
|
||||
Click="PurgeAllSharedCaches_OnClick"
|
||||
>
|
||||
<Button Command="{Binding PurgeAllCaches}">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
Text="{ext:Locale SettingsTabDebugPurgeAllCaches}" />
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,4 @@
|
|||
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
|
||||
{
|
||||
|
|
@ -15,57 +8,5 @@ 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue