mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-10-15 13:44:41 +00:00
chore: move HasPtcCacheFiles & HasShaderCacheFiles into ApplicationData, instead of having the weird static dependency helpers
This commit is contained in:
parent
47559cd311
commit
a62716002e
@ -11,11 +11,13 @@ using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Systems.PlayReport;
|
||||
using Ryujinx.Ava.Utilities;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Ryujinx.Ava.Systems.AppLibrary
|
||||
@ -84,6 +86,32 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
||||
|
||||
public LocaleKeys? PlayabilityStatus => Compatibility.Convert(x => x.Status).OrElse(null);
|
||||
|
||||
public bool HasPtcCacheFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
DirectoryInfo mainDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "cpu", "0"));
|
||||
DirectoryInfo backupDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, 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 bool HasShaderCacheFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
DirectoryInfo shaderCacheDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "shader"));
|
||||
|
||||
if (!shaderCacheDir.Exists) return false;
|
||||
|
||||
return shaderCacheDir.EnumerateDirectories("*").Any() ||
|
||||
shaderCacheDir.GetFiles("*.toc").Length != 0 ||
|
||||
shaderCacheDir.GetFiles("*.data").Length != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public string LocalizedStatusTooltip =>
|
||||
Compatibility.Convert(x =>
|
||||
#pragma warning disable CS8509 // It is exhaustive for all possible values this can contain.
|
||||
|
@ -120,13 +120,13 @@
|
||||
CommandParameter="{Binding}"
|
||||
Header="{ext:Locale GameListContextMenuCacheManagementNukePptc}"
|
||||
Icon="{ext:Icon fa-solid fa-trash-can}"
|
||||
IsEnabled="{Binding HasPtcCacheFiles}" />
|
||||
IsEnabled="{Binding SelectedApplication.HasPtcCacheFiles, FallbackValue=False}" />
|
||||
<MenuItem
|
||||
Command="{Binding PurgeShaderCache}"
|
||||
CommandParameter="{Binding}"
|
||||
Header="{ext:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
||||
Icon="{ext:Icon fa-solid fa-trash-can}"
|
||||
IsEnabled="{Binding HasShaderCacheFiles}" />
|
||||
IsEnabled="{Binding SelectedApplication.HasShaderCacheFiles, FallbackValue=False}" />
|
||||
<Separator/>
|
||||
<MenuItem
|
||||
Command="{Binding OpenPtcDirectory}"
|
||||
|
@ -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 =>
|
||||
|
Loading…
Reference in New Issue
Block a user