mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-25 01:57:11 +02:00
UI: Simplify LDN data logic
This commit is contained in:
parent
c69881a0a2
commit
d3bc3a1081
5 changed files with 45 additions and 14 deletions
|
@ -9,6 +9,7 @@ using Avalonia.Threading;
|
|||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Gommon;
|
||||
using LibHac.Common;
|
||||
using LibHac.Ns;
|
||||
using Ryujinx.Ava.Common;
|
||||
|
@ -119,8 +120,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
public ApplicationData ListSelectedApplication;
|
||||
public ApplicationData GridSelectedApplication;
|
||||
|
||||
public IEnumerable<LdnGameData> LastLdnGameData;
|
||||
|
||||
// Key is Title ID
|
||||
public SafeDictionary<string, LdnGameDataArray> LdnData = [];
|
||||
|
||||
// The UI specifically uses a thicker bordered variant of the icon to avoid crunching out the border at lower resolutions.
|
||||
// For an example of this, download canary 1.2.95, then open the settings menu, and look at the icon in the top-left.
|
||||
|
|
|
@ -167,24 +167,28 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
var ldnGameDataArray = e.LdnData;
|
||||
ViewModel.LastLdnGameData = ldnGameDataArray;
|
||||
var ldnGameDataArray = e.LdnData.ToList();
|
||||
ViewModel.LdnData.Clear();
|
||||
foreach (var application in ViewModel.Applications)
|
||||
{
|
||||
ViewModel.LdnData[application.IdString] = new LdnGameDataArray(
|
||||
ldnGameDataArray,
|
||||
ref application.ControlHolder.Value
|
||||
);
|
||||
|
||||
UpdateApplicationWithLdnData(application);
|
||||
}
|
||||
|
||||
ViewModel.RefreshView();
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateApplicationWithLdnData(ApplicationData application)
|
||||
{
|
||||
if (application.ControlHolder.ByteSpan.Length > 0 && ViewModel.LastLdnGameData != null)
|
||||
if (application.HasControlHolder && ViewModel.LdnData.TryGetValue(application.IdString, out var ldnGameDatas))
|
||||
{
|
||||
IEnumerable<LdnGameData> ldnGameData = ViewModel.LastLdnGameData.Where(game => application.ControlHolder.Value.LocalCommunicationId.Items.Contains(Convert.ToUInt64(game.TitleId, 16)));
|
||||
|
||||
application.PlayerCount = ldnGameData.Sum(game => game.PlayerCount);
|
||||
application.GameCount = ldnGameData.Count();
|
||||
application.PlayerCount = ldnGameDatas.PlayerCount;
|
||||
application.GameCount = ldnGameDatas.GameCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue