chore: move HasPtcCacheFiles & HasShaderCacheFiles into ApplicationData, instead of having the weird static dependency helpers

This commit is contained in:
GreemDev 2025-10-14 16:09:51 -05:00
parent 47559cd311
commit a62716002e
3 changed files with 32 additions and 32 deletions

View file

@ -2121,8 +2121,7 @@ namespace Ryujinx.Ava.UI.ViewModels
});
public static AsyncRelayCommand<MainWindowViewModel> NukePtcCache { get; } =
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null &&
vm.HasPtcCacheFiles(),
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication?.HasPtcCacheFiles ?? false,
async viewModel =>
{
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
@ -2171,22 +2170,9 @@ namespace Ryujinx.Ava.UI.ViewModels
}
});
private bool HasPtcCacheFiles()
{
if (this.SelectedApplication == null) return false;
DirectoryInfo mainDir = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath,
this.SelectedApplication.IdString, "cache", "cpu", "0"));
DirectoryInfo backupDir = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath,
this.SelectedApplication.IdString, "cache", "cpu", "1"));
return (mainDir.Exists && (mainDir.EnumerateFiles("*.cache").Any() || mainDir.EnumerateFiles("*.info").Any())) ||
(backupDir.Exists && (backupDir.EnumerateFiles("*.cache").Any() || backupDir.EnumerateFiles("*.info").Any()));
}
public static AsyncRelayCommand<MainWindowViewModel> PurgeShaderCache { get; } =
Commands.CreateConditional<MainWindowViewModel>(
vm => vm?.SelectedApplication != null && vm.HasShaderCacheFiles(),
vm => vm?.SelectedApplication?.HasShaderCacheFiles ?? false,
async viewModel =>
{
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
@ -2243,20 +2229,6 @@ namespace Ryujinx.Ava.UI.ViewModels
}
});
private bool HasShaderCacheFiles()
{
if (this.SelectedApplication == null) return false;
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath,
this.SelectedApplication.IdString, "cache", "shader"));
if (!shaderCacheDir.Exists) return false;
return shaderCacheDir.EnumerateDirectories("*").Any() ||
shaderCacheDir.GetFiles("*.toc").Any() ||
shaderCacheDir.GetFiles("*.data").Any();
}
public static RelayCommand<MainWindowViewModel> OpenPtcDirectory { get; } =
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null,
viewModel =>