From 5fbcb1f3a7b7f18a120db350f6b1fb3bd6cb305d Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sat, 7 Dec 2024 04:05:39 -0600 Subject: [PATCH] misc: chore: Cleanups & unused parameter removal --- .../Controller/JoyconConfigControllerStick.cs | 4 +- .../App/ApplicationLibrary.cs | 39 +++++++------------ .../Configuration/ConfigurationState.cs | 8 +--- .../Helper/DownloadableContentsHelper.cs | 2 +- .../Helper/TitleUpdatesHelper.cs | 2 +- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/Ryujinx.Common/Configuration/Hid/Controller/JoyconConfigControllerStick.cs b/src/Ryujinx.Common/Configuration/Hid/Controller/JoyconConfigControllerStick.cs index 608681551..076530744 100644 --- a/src/Ryujinx.Common/Configuration/Hid/Controller/JoyconConfigControllerStick.cs +++ b/src/Ryujinx.Common/Configuration/Hid/Controller/JoyconConfigControllerStick.cs @@ -1,6 +1,8 @@ namespace Ryujinx.Common.Configuration.Hid.Controller { - public class JoyconConfigControllerStick where TButton : unmanaged where TStick : unmanaged + public class JoyconConfigControllerStick + where TButton : unmanaged + where TStick : unmanaged { public TStick Joystick { get; set; } public bool InvertStickX { get; set; } diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 174db51ad..cc5a63ab8 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -1,5 +1,4 @@ using DynamicData; -using DynamicData.Kernel; using Gommon; using LibHac; using LibHac.Common; @@ -37,14 +36,13 @@ using System.Threading.Tasks; using ContentType = LibHac.Ncm.ContentType; using MissingKeyException = LibHac.Common.Keys.MissingKeyException; using Path = System.IO.Path; -using SpanHelpers = LibHac.Common.SpanHelpers; using TimeSpan = System.TimeSpan; namespace Ryujinx.UI.App.Common { public class ApplicationLibrary { - public static string DefaultLanPlayWebHost = "ryuldnweb.vudjun.com"; + public const string DefaultLanPlayWebHost = "ryuldnweb.vudjun.com"; public Language DesiredLanguage { get; set; } public event EventHandler ApplicationCountUpdated; public event EventHandler LdnGameDataReceived; @@ -191,12 +189,9 @@ namespace Ryujinx.UI.App.Common } } - if (isExeFs) - { - return GetApplicationFromExeFs(pfs, filePath); - } - - return null; + return isExeFs + ? GetApplicationFromExeFs(pfs, filePath) + : null; } /// The configured key set is missing a key. @@ -512,10 +507,6 @@ namespace Ryujinx.UI.App.Common case ".xci": case ".nsp": { - IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks - ? IntegrityCheckLevel.ErrorOnInvalid - : IntegrityCheckLevel.None; - using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(filePath, _virtualFileSystem); foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) @@ -604,7 +595,7 @@ namespace Ryujinx.UI.App.Common 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), + nacpFile.Get.Read(out _, 0, LibHac.Common.SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure(); var displayVersion = controlData.DisplayVersionString.ToString(); @@ -827,7 +818,7 @@ namespace Ryujinx.UI.App.Common { _downloadableContents.Edit(it => { - DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, application.IdBase, dlcs); + DownloadableContentsHelper.SaveDownloadableContentsJson(application.IdBase, dlcs); it.Remove(it.Items.Where(item => item.Dlc.TitleIdBase == application.IdBase)); it.AddOrUpdate(dlcs); @@ -839,7 +830,7 @@ namespace Ryujinx.UI.App.Common { _titleUpdates.Edit(it => { - TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, application.IdBase, updates); + TitleUpdatesHelper.SaveTitleUpdatesJson(application.IdBase, updates); it.Remove(it.Items.Where(item => item.TitleUpdate.TitleIdBase == application.IdBase)); it.AddOrUpdate(updates); @@ -1088,7 +1079,7 @@ namespace Ryujinx.UI.App.Common private bool AddAndAutoSelectUpdate(TitleUpdateModel update) { - var currentlySelected = TitleUpdates.Items.FirstOrOptional(it => + var currentlySelected = TitleUpdates.Items.FindFirst(it => it.TitleUpdate.TitleIdBase == update.TitleIdBase && it.IsSelected); var shouldSelect = !currentlySelected.HasValue || @@ -1464,7 +1455,7 @@ namespace Ryujinx.UI.App.Common if (addedNewDlc) { var gameDlcs = it.Items.Where(dlc => dlc.Dlc.TitleIdBase == application.IdBase).ToList(); - DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, application.IdBase, + DownloadableContentsHelper.SaveDownloadableContentsJson(application.IdBase, gameDlcs); } } @@ -1483,7 +1474,7 @@ namespace Ryujinx.UI.App.Common TitleUpdatesHelper.LoadTitleUpdatesJson(_virtualFileSystem, application.IdBase); it.AddOrUpdate(savedUpdates); - var selectedUpdate = savedUpdates.FirstOrOptional(update => update.IsSelected); + var selectedUpdate = savedUpdates.FindFirst(update => update.IsSelected); if (TryGetTitleUpdatesFromFile(application.Path, out var bundledUpdates)) { @@ -1498,9 +1489,9 @@ namespace Ryujinx.UI.App.Common if (!selectedUpdate.HasValue || selectedUpdate.Value.Item1.Version < update.Version) { shouldSelect = true; - if (selectedUpdate.HasValue) + if (selectedUpdate) _titleUpdates.AddOrUpdate((selectedUpdate.Value.Item1, false)); - selectedUpdate = DynamicData.Kernel.Optional<(TitleUpdateModel, bool IsSelected)>.Create((update, true)); + selectedUpdate = (update, true); } modifiedVersion = modifiedVersion || shouldSelect; @@ -1513,7 +1504,7 @@ namespace Ryujinx.UI.App.Common if (updatesChanged) { var gameUpdates = it.Items.Where(update => update.TitleUpdate.TitleIdBase == application.IdBase).ToList(); - TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, application.IdBase, gameUpdates); + TitleUpdatesHelper.SaveTitleUpdatesJson(application.IdBase, gameUpdates); } } }); @@ -1525,14 +1516,14 @@ namespace Ryujinx.UI.App.Common private void SaveDownloadableContentsForGame(ulong titleIdBase) { var dlcs = DownloadableContents.Items.Where(dlc => dlc.Dlc.TitleIdBase == titleIdBase).ToList(); - DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, titleIdBase, dlcs); + DownloadableContentsHelper.SaveDownloadableContentsJson(titleIdBase, dlcs); } // Save the _currently tracked_ update state for the game private void SaveTitleUpdatesForGame(ulong titleIdBase) { var updates = TitleUpdates.Items.Where(update => update.TitleUpdate.TitleIdBase == titleIdBase).ToList(); - TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, titleIdBase, updates); + TitleUpdatesHelper.SaveTitleUpdatesJson(titleIdBase, updates); } // ApplicationData isnt live-updating (e.g. when an update gets applied) and so this is meant to trigger a refresh diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index badb047df..04ddd442f 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -1,16 +1,12 @@ -using ARMeilleure; using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration.Hid; -using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.Common.Configuration.Multiplayer; -using Ryujinx.Common.Logging; using Ryujinx.Graphics.Vulkan; using Ryujinx.HLE; using Ryujinx.UI.Common.Configuration.System; using Ryujinx.UI.Common.Configuration.UI; using System; -using System.Collections.Generic; namespace Ryujinx.UI.Common.Configuration { @@ -21,10 +17,10 @@ namespace Ryujinx.UI.Common.Configuration if (Instance != null) { throw new InvalidOperationException("Configuration is already initialized"); - } + } Instance = new ConfigurationState(); - } + } public ConfigurationFileFormat ToFileFormat() { diff --git a/src/Ryujinx.UI.Common/Helper/DownloadableContentsHelper.cs b/src/Ryujinx.UI.Common/Helper/DownloadableContentsHelper.cs index 3695c5c5c..020529b55 100644 --- a/src/Ryujinx.UI.Common/Helper/DownloadableContentsHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/DownloadableContentsHelper.cs @@ -42,7 +42,7 @@ namespace Ryujinx.UI.Common.Helper } } - public static void SaveDownloadableContentsJson(VirtualFileSystem vfs, ulong applicationIdBase, List<(DownloadableContentModel, bool IsEnabled)> dlcs) + public static void SaveDownloadableContentsJson(ulong applicationIdBase, List<(DownloadableContentModel, bool IsEnabled)> dlcs) { DownloadableContentContainer container = default; List downloadableContentContainerList = new(); diff --git a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs index 18fbabd6d..c6bacfd91 100644 --- a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs @@ -49,7 +49,7 @@ namespace Ryujinx.UI.Common.Helper } } - public static void SaveTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase, List<(TitleUpdateModel, bool IsSelected)> updates) + public static void SaveTitleUpdatesJson(ulong applicationIdBase, List<(TitleUpdateModel, bool IsSelected)> updates) { var titleUpdateWindowData = new TitleUpdateMetadata {