diff options
author | Ac_K <Acoustik666@gmail.com> | 2022-02-22 14:53:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 14:53:39 +0100 |
commit | ccf23fc6295dab55bf49823484b34eb1721f6a50 (patch) | |
tree | f7245b603e9b8d9081b744aaab78ead30bb7ad4d /Ryujinx/Ui/App/ApplicationLibrary.cs | |
parent | f1460d549441f10d63bde9d7d36282cc007b4c7e (diff) |
gui: Fixes the games icon when there is an update (#3148)1.1.49
* gui: Fixes the games icon when there is a game update
Currently we just load the version of the update, instead of the whole NACP file. This PR fixes that. A little cleanup is made into the code to avoid duplicate things.
(Closes #3039)
* Fix condition
Diffstat (limited to 'Ryujinx/Ui/App/ApplicationLibrary.cs')
-rw-r--r-- | Ryujinx/Ui/App/ApplicationLibrary.cs | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/Ryujinx/Ui/App/ApplicationLibrary.cs b/Ryujinx/Ui/App/ApplicationLibrary.cs index 6a0e81e9..519dd727 100644 --- a/Ryujinx/Ui/App/ApplicationLibrary.cs +++ b/Ryujinx/Ui/App/ApplicationLibrary.cs @@ -242,15 +242,18 @@ namespace Ryujinx.Ui.App } else { - // Store the ControlFS in variable called controlFs GetControlFsAndTitleId(pfs, out IFileSystem controlFs, out titleId); - ReadControlData(controlFs, controlHolder.ByteSpan); + // Check if there is an update available. + if (IsUpdateApplied(titleId, out IFileSystem updatedControlFs)) + { + // Replace the original ControlFs by the updated one. + controlFs = updatedControlFs; + } - // Get the title name, title ID, developer name and version number from the NACP - version = IsUpdateApplied(titleId, out string updateVersion) ? updateVersion : controlHolder.Value.DisplayVersion.ToString(); + ReadControlData(controlFs, controlHolder.ByteSpan); - GetNameIdDeveloper(ref controlHolder.Value, out titleName, out _, out developer); + GetGameInformation(ref controlHolder.Value, out titleName, out _, out developer, out version); // Read the icon from the ControlFS and store it as a byte array try @@ -351,10 +354,7 @@ namespace Ryujinx.Ui.App // Read the NACP data Read(assetOffset + (int)nacpOffset, (int)nacpSize).AsSpan().CopyTo(controlHolder.ByteSpan); - // Get the title name, title ID, developer name and version number from the NACP - version = controlHolder.Value.DisplayVersion.ToString(); - - GetNameIdDeveloper(ref controlHolder.Value, out titleName, out titleId, out developer); + GetGameInformation(ref controlHolder.Value, out titleName, out titleId, out developer, out version); } else { @@ -554,7 +554,7 @@ namespace Ryujinx.Ui.App return readableString; } - private void GetNameIdDeveloper(ref ApplicationControlProperty controlData, out string titleName, out string titleId, out string publisher) + private void GetGameInformation(ref ApplicationControlProperty controlData, out string titleName, out string titleId, out string publisher, out string version) { _ = Enum.TryParse(_desiredTitleLanguage.ToString(), out TitleLanguage desiredTitleLanguage); @@ -611,10 +611,14 @@ namespace Ryujinx.Ui.App { titleId = "0000000000000000"; } + + version = controlData.DisplayVersion.ToString(); } - private bool IsUpdateApplied(string titleId, out string version) + private bool IsUpdateApplied(string titleId, out IFileSystem updatedControlFs) { + updatedControlFs = null; + string updatePath = "(unknown)"; try @@ -623,14 +627,7 @@ namespace Ryujinx.Ui.App if (patchNca != null && controlNca != null) { - ApplicationControlProperty controlData = new ApplicationControlProperty(); - using var nacpFile = new UniqueRef<IFile>(); - - controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None).OpenFile(ref nacpFile.Ref(), "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure(); - - nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure(); - - version = controlData.DisplayVersion.ToString(); + updatedControlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None); return true; } @@ -645,8 +642,6 @@ namespace Ryujinx.Ui.App Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}. Errored File: {updatePath}"); } - version = ""; - return false; } } |