From 6ba8ae53f2a1f0929ab17929d10cb5a42f574b37 Mon Sep 17 00:00:00 2001 From: Judas Drekonym <77771385+ramdragons@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:06:40 -0600 Subject: [PATCH] Add TitleID sort method Adds an additional application list sorting method for the TitleID. A bit of a niche choice for sorting but I think the TID is a relevant enough piece of metadata that it should be there. (And I personally would be using it) - Using existing TitleId constant in ApplicationSort, implying this was meant to be in the sorting options at some point? - Reuses the "DlcManagerTableHeadingTitleIdLabel" locale for fulfilling the need already, might be better to make a unique one for this in the long run but this codebase is new to me so I wanted to make the changes as unobtrusive as possible - Using app.Id for the comparer seems to work fine, not sure if using something else like IdString would be better? --- src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs | 6 +++++- src/Ryujinx/UI/Views/Main/MainViewControls.axaml | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index efd96ad2e..c23f17690 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -1102,6 +1102,7 @@ namespace Ryujinx.Ava.UI.ViewModels ApplicationSort.FileSize => LocaleManager.Instance[LocaleKeys.GameListHeaderFileSize], ApplicationSort.Path => LocaleManager.Instance[LocaleKeys.GameListHeaderPath], ApplicationSort.Favorite => LocaleManager.Instance[LocaleKeys.CommonFavorite], + ApplicationSort.TitleId => LocaleManager.Instance[LocaleKeys.DlcManagerTableHeadingTitleIdLabel], _ => string.Empty, }; } @@ -1171,6 +1172,7 @@ namespace Ryujinx.Ava.UI.ViewModels public IHostUIHandler UiHandler { get; internal set; } public bool IsSortedByFavorite => SortMode == ApplicationSort.Favorite; public bool IsSortedByTitle => SortMode == ApplicationSort.Title; + public bool IsSortedByTitleId => SortMode == ApplicationSort.TitleId; public bool IsSortedByDeveloper => SortMode == ApplicationSort.Developer; public bool IsSortedByLastPlayed => SortMode == ApplicationSort.LastPlayed; public bool IsSortedByTimePlayed => SortMode == ApplicationSort.TotalTimePlayed; @@ -1204,7 +1206,9 @@ namespace Ryujinx.Ava.UI.ViewModels ApplicationSort.Path => IsAscending ? SortExpressionComparer.Ascending(app => app.Path) : SortExpressionComparer.Descending(app => app.Path), ApplicationSort.Favorite => IsAscending ? SortExpressionComparer.Ascending(app => new AppListFavoriteComparable(app)) - : SortExpressionComparer.Descending(app => new AppListFavoriteComparable(app)), + : SortExpressionComparer.Descending(app => new AppListFavoriteComparable(app)), + ApplicationSort.TitleId => IsAscending ? SortExpressionComparer.Ascending(app => app.Id) + : SortExpressionComparer.Descending(app => app.Id), _ => null, #pragma warning restore IDE0055 }; diff --git a/src/Ryujinx/UI/Views/Main/MainViewControls.axaml b/src/Ryujinx/UI/Views/Main/MainViewControls.axaml index bb820df44..3c3e2852b 100644 --- a/src/Ryujinx/UI/Views/Main/MainViewControls.axaml +++ b/src/Ryujinx/UI/Views/Main/MainViewControls.axaml @@ -105,6 +105,12 @@ GroupName="Sort" IsChecked="{Binding IsSortedByTitle, Mode=OneTime}" Tag="Title" /> +