|
|
@@ -16,6 +16,8 @@ using Ryujinx.Common.Logging;
|
|
|
using Ryujinx.HLE.FileSystem;
|
|
|
using Ryujinx.HLE.HOS;
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
|
|
+using Ryujinx.HLE.Loaders.Processes.Extensions;
|
|
|
+using Ryujinx.HLE.Utilities;
|
|
|
using Ryujinx.UI.App.Common;
|
|
|
using Ryujinx.UI.Common.Configuration;
|
|
|
using Ryujinx.UI.Common.Helper;
|
|
|
@@ -23,7 +25,6 @@ using Ryujinx.UI.Windows;
|
|
|
using System;
|
|
|
using System.Buffers;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.Globalization;
|
|
|
using System.IO;
|
|
|
using System.Reflection;
|
|
|
using System.Threading;
|
|
|
@@ -36,17 +37,13 @@ namespace Ryujinx.UI.Widgets
|
|
|
private readonly VirtualFileSystem _virtualFileSystem;
|
|
|
private readonly AccountManager _accountManager;
|
|
|
private readonly HorizonClient _horizonClient;
|
|
|
- private readonly BlitStruct<ApplicationControlProperty> _controlData;
|
|
|
|
|
|
- private readonly string _titleFilePath;
|
|
|
- private readonly string _titleName;
|
|
|
- private readonly string _titleIdText;
|
|
|
- private readonly ulong _titleId;
|
|
|
+ private readonly ApplicationData _applicationData;
|
|
|
|
|
|
private MessageDialog _dialog;
|
|
|
private bool _cancel;
|
|
|
|
|
|
- public GameTableContextMenu(MainWindow parent, VirtualFileSystem virtualFileSystem, AccountManager accountManager, HorizonClient horizonClient, string titleFilePath, string titleName, string titleId, BlitStruct<ApplicationControlProperty> controlData)
|
|
|
+ public GameTableContextMenu(MainWindow parent, VirtualFileSystem virtualFileSystem, AccountManager accountManager, HorizonClient horizonClient, ApplicationData applicationData)
|
|
|
{
|
|
|
_parent = parent;
|
|
|
|
|
|
@@ -55,23 +52,22 @@ namespace Ryujinx.UI.Widgets
|
|
|
_virtualFileSystem = virtualFileSystem;
|
|
|
_accountManager = accountManager;
|
|
|
_horizonClient = horizonClient;
|
|
|
- _titleFilePath = titleFilePath;
|
|
|
- _titleName = titleName;
|
|
|
- _titleIdText = titleId;
|
|
|
- _controlData = controlData;
|
|
|
+ _applicationData = applicationData;
|
|
|
|
|
|
- if (!ulong.TryParse(_titleIdText, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out _titleId))
|
|
|
+ if (!_applicationData.ControlHolder.ByteSpan.IsZeros())
|
|
|
{
|
|
|
- GtkDialog.CreateErrorDialog("The selected game did not have a valid Title Id");
|
|
|
-
|
|
|
- return;
|
|
|
+ _openSaveUserDirMenuItem.Sensitive = _applicationData.ControlHolder.Value.UserAccountSaveDataSize > 0;
|
|
|
+ _openSaveDeviceDirMenuItem.Sensitive = _applicationData.ControlHolder.Value.DeviceSaveDataSize > 0;
|
|
|
+ _openSaveBcatDirMenuItem.Sensitive = _applicationData.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _openSaveUserDirMenuItem.Sensitive = false;
|
|
|
+ _openSaveDeviceDirMenuItem.Sensitive = false;
|
|
|
+ _openSaveBcatDirMenuItem.Sensitive = false;
|
|
|
}
|
|
|
|
|
|
- _openSaveUserDirMenuItem.Sensitive = !Utilities.IsZeros(controlData.ByteSpan) && controlData.Value.UserAccountSaveDataSize > 0;
|
|
|
- _openSaveDeviceDirMenuItem.Sensitive = !Utilities.IsZeros(controlData.ByteSpan) && controlData.Value.DeviceSaveDataSize > 0;
|
|
|
- _openSaveBcatDirMenuItem.Sensitive = !Utilities.IsZeros(controlData.ByteSpan) && controlData.Value.BcatDeliveryCacheStorageSize > 0;
|
|
|
-
|
|
|
- string fileExt = System.IO.Path.GetExtension(_titleFilePath).ToLower();
|
|
|
+ string fileExt = System.IO.Path.GetExtension(_applicationData.Path).ToLower();
|
|
|
bool hasNca = fileExt == ".nca" || fileExt == ".nsp" || fileExt == ".pfs0" || fileExt == ".xci";
|
|
|
|
|
|
_extractRomFsMenuItem.Sensitive = hasNca;
|
|
|
@@ -137,7 +133,7 @@ namespace Ryujinx.UI.Widgets
|
|
|
|
|
|
private void OpenSaveDir(in SaveDataFilter saveDataFilter)
|
|
|
{
|
|
|
- if (!TryFindSaveData(_titleName, _titleId, _controlData, in saveDataFilter, out ulong saveDataId))
|
|
|
+ if (!TryFindSaveData(_applicationData.Name, _applicationData.Id, _applicationData.ControlHolder, in saveDataFilter, out ulong saveDataId))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
@@ -190,7 +186,7 @@ namespace Ryujinx.UI.Widgets
|
|
|
{
|
|
|
Title = "Ryujinx - NCA Section Extractor",
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Gtk3.UI.Common.Resources.Logo_Ryujinx.png"),
|
|
|
- SecondaryText = $"Extracting {ncaSectionType} section from {System.IO.Path.GetFileName(_titleFilePath)}...",
|
|
|
+ SecondaryText = $"Extracting {ncaSectionType} section from {System.IO.Path.GetFileName(_applicationData.Path)}...",
|
|
|
WindowPosition = WindowPosition.Center,
|
|
|
};
|
|
|
|
|
|
@@ -202,29 +198,16 @@ namespace Ryujinx.UI.Widgets
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- using FileStream file = new(_titleFilePath, FileMode.Open, FileAccess.Read);
|
|
|
+ using FileStream file = new(_applicationData.Path, FileMode.Open, FileAccess.Read);
|
|
|
|
|
|
Nca mainNca = null;
|
|
|
Nca patchNca = null;
|
|
|
|
|
|
- if ((System.IO.Path.GetExtension(_titleFilePath).ToLower() == ".nsp") ||
|
|
|
- (System.IO.Path.GetExtension(_titleFilePath).ToLower() == ".pfs0") ||
|
|
|
- (System.IO.Path.GetExtension(_titleFilePath).ToLower() == ".xci"))
|
|
|
+ if ((System.IO.Path.GetExtension(_applicationData.Path).ToLower() == ".nsp") ||
|
|
|
+ (System.IO.Path.GetExtension(_applicationData.Path).ToLower() == ".pfs0") ||
|
|
|
+ (System.IO.Path.GetExtension(_applicationData.Path).ToLower() == ".xci"))
|
|
|
{
|
|
|
- IFileSystem pfs;
|
|
|
-
|
|
|
- if (System.IO.Path.GetExtension(_titleFilePath) == ".xci")
|
|
|
- {
|
|
|
- Xci xci = new(_virtualFileSystem.KeySet, file.AsStorage());
|
|
|
-
|
|
|
- pfs = xci.OpenPartition(XciPartitionType.Secure);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var pfsTemp = new PartitionFileSystem();
|
|
|
- pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
|
|
|
- pfs = pfsTemp;
|
|
|
- }
|
|
|
+ IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(_applicationData.Path, _virtualFileSystem);
|
|
|
|
|
|
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
|
|
|
{
|
|
|
@@ -249,7 +232,7 @@ namespace Ryujinx.UI.Widgets
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (System.IO.Path.GetExtension(_titleFilePath).ToLower() == ".nca")
|
|
|
+ else if (System.IO.Path.GetExtension(_applicationData.Path).ToLower() == ".nca")
|
|
|
{
|
|
|
mainNca = new Nca(_virtualFileSystem.KeySet, file.AsStorage());
|
|
|
}
|
|
|
@@ -266,7 +249,11 @@ namespace Ryujinx.UI.Widgets
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- (Nca updatePatchNca, _) = ApplicationLibrary.GetGameUpdateData(_virtualFileSystem, mainNca.Header.TitleId.ToString("x16"), programIndex, out _);
|
|
|
+ IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
|
|
+ ? IntegrityCheckLevel.ErrorOnInvalid
|
|
|
+ : IntegrityCheckLevel.None;
|
|
|
+
|
|
|
+ (Nca updatePatchNca, _) = mainNca.GetUpdateData(_virtualFileSystem, checkLevel, programIndex, out _);
|
|
|
|
|
|
if (updatePatchNca != null)
|
|
|
{
|
|
|
@@ -460,44 +447,44 @@ namespace Ryujinx.UI.Widgets
|
|
|
private void OpenSaveUserDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
var userId = new LibHac.Fs.UserId((ulong)_accountManager.LastOpenedUser.UserId.High, (ulong)_accountManager.LastOpenedUser.UserId.Low);
|
|
|
- var saveDataFilter = SaveDataFilter.Make(_titleId, saveType: default, userId, saveDataId: default, index: default);
|
|
|
+ var saveDataFilter = SaveDataFilter.Make(_applicationData.Id, saveType: default, userId, saveDataId: default, index: default);
|
|
|
|
|
|
OpenSaveDir(in saveDataFilter);
|
|
|
}
|
|
|
|
|
|
private void OpenSaveDeviceDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- var saveDataFilter = SaveDataFilter.Make(_titleId, SaveDataType.Device, userId: default, saveDataId: default, index: default);
|
|
|
+ var saveDataFilter = SaveDataFilter.Make(_applicationData.Id, SaveDataType.Device, userId: default, saveDataId: default, index: default);
|
|
|
|
|
|
OpenSaveDir(in saveDataFilter);
|
|
|
}
|
|
|
|
|
|
private void OpenSaveBcatDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- var saveDataFilter = SaveDataFilter.Make(_titleId, SaveDataType.Bcat, userId: default, saveDataId: default, index: default);
|
|
|
+ var saveDataFilter = SaveDataFilter.Make(_applicationData.Id, SaveDataType.Bcat, userId: default, saveDataId: default, index: default);
|
|
|
|
|
|
OpenSaveDir(in saveDataFilter);
|
|
|
}
|
|
|
|
|
|
private void ManageTitleUpdates_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- new TitleUpdateWindow(_parent, _virtualFileSystem, _titleIdText, _titleName).Show();
|
|
|
+ new TitleUpdateWindow(_parent, _virtualFileSystem, _applicationData).Show();
|
|
|
}
|
|
|
|
|
|
private void ManageDlc_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- new DlcWindow(_virtualFileSystem, _titleIdText, _titleName).Show();
|
|
|
+ new DlcWindow(_virtualFileSystem, _applicationData.IdString, _applicationData).Show();
|
|
|
}
|
|
|
|
|
|
private void ManageCheats_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- new CheatWindow(_virtualFileSystem, _titleId, _titleName, _titleFilePath).Show();
|
|
|
+ new CheatWindow(_virtualFileSystem, _applicationData.Id, _applicationData.Name, _applicationData.Path).Show();
|
|
|
}
|
|
|
|
|
|
private void OpenTitleModDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
string modsBasePath = ModLoader.GetModsBasePath();
|
|
|
- string titleModsPath = ModLoader.GetApplicationDir(modsBasePath, _titleIdText);
|
|
|
+ string titleModsPath = ModLoader.GetApplicationDir(modsBasePath, _applicationData.IdString);
|
|
|
|
|
|
OpenHelper.OpenFolder(titleModsPath);
|
|
|
}
|
|
|
@@ -505,7 +492,7 @@ namespace Ryujinx.UI.Widgets
|
|
|
private void OpenTitleSdModDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
string sdModsBasePath = ModLoader.GetSdModsBasePath();
|
|
|
- string titleModsPath = ModLoader.GetApplicationDir(sdModsBasePath, _titleIdText);
|
|
|
+ string titleModsPath = ModLoader.GetApplicationDir(sdModsBasePath, _applicationData.IdString);
|
|
|
|
|
|
OpenHelper.OpenFolder(titleModsPath);
|
|
|
}
|
|
|
@@ -527,7 +514,7 @@ namespace Ryujinx.UI.Widgets
|
|
|
|
|
|
private void OpenPtcDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- string ptcDir = System.IO.Path.Combine(AppDataManager.GamesDirPath, _titleIdText, "cache", "cpu");
|
|
|
+ string ptcDir = System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationData.IdString, "cache", "cpu");
|
|
|
|
|
|
string mainPath = System.IO.Path.Combine(ptcDir, "0");
|
|
|
string backupPath = System.IO.Path.Combine(ptcDir, "1");
|
|
|
@@ -544,7 +531,7 @@ namespace Ryujinx.UI.Widgets
|
|
|
|
|
|
private void OpenShaderCacheDir_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- string shaderCacheDir = System.IO.Path.Combine(AppDataManager.GamesDirPath, _titleIdText, "cache", "shader");
|
|
|
+ string shaderCacheDir = System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationData.IdString, "cache", "shader");
|
|
|
|
|
|
if (!Directory.Exists(shaderCacheDir))
|
|
|
{
|
|
|
@@ -556,10 +543,10 @@ namespace Ryujinx.UI.Widgets
|
|
|
|
|
|
private void PurgePtcCache_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- DirectoryInfo mainDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, _titleIdText, "cache", "cpu", "0"));
|
|
|
- DirectoryInfo backupDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, _titleIdText, "cache", "cpu", "1"));
|
|
|
+ DirectoryInfo mainDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationData.IdString, "cache", "cpu", "0"));
|
|
|
+ DirectoryInfo backupDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationData.IdString, "cache", "cpu", "1"));
|
|
|
|
|
|
- MessageDialog warningDialog = GtkDialog.CreateConfirmationDialog("Warning", $"You are about to queue a PPTC rebuild on the next boot of:\n\n<b>{_titleName}</b>\n\nAre you sure you want to proceed?");
|
|
|
+ MessageDialog warningDialog = GtkDialog.CreateConfirmationDialog("Warning", $"You are about to queue a PPTC rebuild on the next boot of:\n\n<b>{_applicationData.Name}</b>\n\nAre you sure you want to proceed?");
|
|
|
|
|
|
List<FileInfo> cacheFiles = new();
|
|
|
|
|
|
@@ -593,9 +580,9 @@ namespace Ryujinx.UI.Widgets
|
|
|
|
|
|
private void PurgeShaderCache_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- DirectoryInfo shaderCacheDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, _titleIdText, "cache", "shader"));
|
|
|
+ DirectoryInfo shaderCacheDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationData.IdString, "cache", "shader"));
|
|
|
|
|
|
- using MessageDialog warningDialog = GtkDialog.CreateConfirmationDialog("Warning", $"You are about to delete the shader cache for :\n\n<b>{_titleName}</b>\n\nAre you sure you want to proceed?");
|
|
|
+ using MessageDialog warningDialog = GtkDialog.CreateConfirmationDialog("Warning", $"You are about to delete the shader cache for :\n\n<b>{_applicationData.Name}</b>\n\nAre you sure you want to proceed?");
|
|
|
|
|
|
List<DirectoryInfo> oldCacheDirectories = new();
|
|
|
List<FileInfo> newCacheFiles = new();
|
|
|
@@ -637,8 +624,11 @@ namespace Ryujinx.UI.Widgets
|
|
|
|
|
|
private void CreateShortcut_Clicked(object sender, EventArgs args)
|
|
|
{
|
|
|
- byte[] appIcon = new ApplicationLibrary(_virtualFileSystem).GetApplicationIcon(_titleFilePath, ConfigurationState.Instance.System.Language);
|
|
|
- ShortcutHelper.CreateAppShortcut(_titleFilePath, _titleName, _titleIdText, appIcon);
|
|
|
+ IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
|
|
+ ? IntegrityCheckLevel.ErrorOnInvalid
|
|
|
+ : IntegrityCheckLevel.None;
|
|
|
+ byte[] appIcon = new ApplicationLibrary(_virtualFileSystem, checkLevel).GetApplicationIcon(_applicationData.Path, ConfigurationState.Instance.System.Language, _applicationData.Id);
|
|
|
+ ShortcutHelper.CreateAppShortcut(_applicationData.Path, _applicationData.Name, _applicationData.IdString, appIcon);
|
|
|
}
|
|
|
}
|
|
|
}
|