mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-10-19 07:34:45 +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.Common.Locale;
|
||||||
using Ryujinx.Ava.Systems.PlayReport;
|
using Ryujinx.Ava.Systems.PlayReport;
|
||||||
using Ryujinx.Ava.Utilities;
|
using Ryujinx.Ava.Utilities;
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.AppLibrary
|
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 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 =>
|
public string LocalizedStatusTooltip =>
|
||||||
Compatibility.Convert(x =>
|
Compatibility.Convert(x =>
|
||||||
#pragma warning disable CS8509 // It is exhaustive for all possible values this can contain.
|
#pragma warning disable CS8509 // It is exhaustive for all possible values this can contain.
|
||||||
|
@ -120,13 +120,13 @@
|
|||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
Header="{ext:Locale GameListContextMenuCacheManagementNukePptc}"
|
Header="{ext:Locale GameListContextMenuCacheManagementNukePptc}"
|
||||||
Icon="{ext:Icon fa-solid fa-trash-can}"
|
Icon="{ext:Icon fa-solid fa-trash-can}"
|
||||||
IsEnabled="{Binding HasPtcCacheFiles}" />
|
IsEnabled="{Binding SelectedApplication.HasPtcCacheFiles, FallbackValue=False}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Command="{Binding PurgeShaderCache}"
|
Command="{Binding PurgeShaderCache}"
|
||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
Header="{ext:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
Header="{ext:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
||||||
Icon="{ext:Icon fa-solid fa-trash-can}"
|
Icon="{ext:Icon fa-solid fa-trash-can}"
|
||||||
IsEnabled="{Binding HasShaderCacheFiles}" />
|
IsEnabled="{Binding SelectedApplication.HasShaderCacheFiles, FallbackValue=False}" />
|
||||||
<Separator/>
|
<Separator/>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Command="{Binding OpenPtcDirectory}"
|
Command="{Binding OpenPtcDirectory}"
|
||||||
|
@ -2121,8 +2121,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
});
|
});
|
||||||
|
|
||||||
public static AsyncRelayCommand<MainWindowViewModel> NukePtcCache { get; } =
|
public static AsyncRelayCommand<MainWindowViewModel> NukePtcCache { get; } =
|
||||||
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null &&
|
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication?.HasPtcCacheFiles ?? false,
|
||||||
vm.HasPtcCacheFiles(),
|
|
||||||
async viewModel =>
|
async viewModel =>
|
||||||
{
|
{
|
||||||
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
|
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; } =
|
public static AsyncRelayCommand<MainWindowViewModel> PurgeShaderCache { get; } =
|
||||||
Commands.CreateConditional<MainWindowViewModel>(
|
Commands.CreateConditional<MainWindowViewModel>(
|
||||||
vm => vm?.SelectedApplication != null && vm.HasShaderCacheFiles(),
|
vm => vm?.SelectedApplication?.HasShaderCacheFiles ?? false,
|
||||||
async viewModel =>
|
async viewModel =>
|
||||||
{
|
{
|
||||||
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
|
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; } =
|
public static RelayCommand<MainWindowViewModel> OpenPtcDirectory { get; } =
|
||||||
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null,
|
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null,
|
||||||
viewModel =>
|
viewModel =>
|
||||||
|
Loading…
Reference in New Issue
Block a user