mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-01-23 13:35:04 +03:00
UI: Compat: Update owned game title IDs when ApplicationLibrary app count updates
This commit is contained in:
parent
e676fd8b17
commit
7fcd9b792e
@ -1,19 +1,18 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using ExCSS;
|
|
||||||
using Gommon;
|
using Gommon;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Utilities.Compat
|
namespace Ryujinx.Ava.Utilities.Compat
|
||||||
{
|
{
|
||||||
public partial class CompatibilityViewModel : ObservableObject
|
public class CompatibilityViewModel : BaseModel
|
||||||
{
|
{
|
||||||
[ObservableProperty] private bool _onlyShowOwnedGames = true;
|
private bool _onlyShowOwnedGames = true;
|
||||||
|
|
||||||
private IEnumerable<CompatibilityEntry> _currentEntries = CompatibilityCsv.Entries;
|
private IEnumerable<CompatibilityEntry> _currentEntries = CompatibilityCsv.Entries;
|
||||||
private readonly string[] _ownedGameTitleIds = [];
|
private string[] _ownedGameTitleIds = [];
|
||||||
private readonly ApplicationLibrary _appLibrary;
|
|
||||||
|
|
||||||
public IEnumerable<CompatibilityEntry> CurrentEntries => OnlyShowOwnedGames
|
public IEnumerable<CompatibilityEntry> CurrentEntries => OnlyShowOwnedGames
|
||||||
? _currentEntries.Where(x =>
|
? _currentEntries.Where(x =>
|
||||||
@ -24,14 +23,23 @@ namespace Ryujinx.Ava.Utilities.Compat
|
|||||||
|
|
||||||
public CompatibilityViewModel(ApplicationLibrary appLibrary)
|
public CompatibilityViewModel(ApplicationLibrary appLibrary)
|
||||||
{
|
{
|
||||||
_appLibrary = appLibrary;
|
appLibrary.ApplicationCountUpdated += (_, _)
|
||||||
_ownedGameTitleIds = appLibrary.Applications.Keys.Select(x => x.ToString("X16")).ToArray();
|
=> _ownedGameTitleIds = appLibrary.Applications.Keys.Select(x => x.ToString("X16")).ToArray();
|
||||||
|
|
||||||
PropertyChanged += (_, args) =>
|
_ownedGameTitleIds = appLibrary.Applications.Keys.Select(x => x.ToString("X16")).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnlyShowOwnedGames
|
||||||
|
{
|
||||||
|
get => _onlyShowOwnedGames;
|
||||||
|
set
|
||||||
{
|
{
|
||||||
if (args.PropertyName is nameof(OnlyShowOwnedGames))
|
OnPropertyChanging();
|
||||||
OnPropertyChanged(nameof(CurrentEntries));
|
OnPropertyChanging(nameof(CurrentEntries));
|
||||||
};
|
_onlyShowOwnedGames = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
OnPropertyChanged(nameof(CurrentEntries));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Search(string searchTerm)
|
public void Search(string searchTerm)
|
||||||
|
Loading…
Reference in New Issue
Block a user