Compare commits
3 Commits
2d64cc4b62
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d88771d1b | ||
|
|
4e8157688e | ||
|
|
5085af0050 |
@@ -1,5 +1,6 @@
|
|||||||
using MsgPack;
|
using MsgPack;
|
||||||
using Ryujinx.Horizon.Common;
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.Prepo.Types;
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -8,7 +9,7 @@ namespace Ryujinx.Horizon
|
|||||||
{
|
{
|
||||||
public static class HorizonStatic
|
public static class HorizonStatic
|
||||||
{
|
{
|
||||||
internal static void HandlePlayReport(MessagePackObject report) =>
|
internal static void HandlePlayReport(PlayReport report) =>
|
||||||
new Thread(() => PlayReport?.Invoke(report))
|
new Thread(() => PlayReport?.Invoke(report))
|
||||||
{
|
{
|
||||||
Name = "HLE.PlayReportEvent",
|
Name = "HLE.PlayReportEvent",
|
||||||
@@ -16,7 +17,7 @@ namespace Ryujinx.Horizon
|
|||||||
Priority = ThreadPriority.AboveNormal
|
Priority = ThreadPriority.AboveNormal
|
||||||
}.Start();
|
}.Start();
|
||||||
|
|
||||||
public static event Action<MessagePackObject> PlayReport;
|
public static event Action<PlayReport> PlayReport;
|
||||||
|
|
||||||
[field: ThreadStatic]
|
[field: ThreadStatic]
|
||||||
public static HorizonOptions Options { get; private set; }
|
public static HorizonOptions Options { get; private set; }
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Gommon;
|
|
||||||
using MsgPack;
|
using MsgPack;
|
||||||
using MsgPack.Serialization;
|
using MsgPack.Serialization;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
@@ -12,19 +11,12 @@ using Ryujinx.Horizon.Sdk.Sf;
|
|||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
|
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
|
||||||
|
|
||||||
namespace Ryujinx.Horizon.Prepo.Ipc
|
namespace Ryujinx.Horizon.Prepo.Ipc
|
||||||
{
|
{
|
||||||
partial class PrepoService : IPrepoService
|
partial class PrepoService : IPrepoService
|
||||||
{
|
{
|
||||||
enum PlayReportKind
|
|
||||||
{
|
|
||||||
Normal,
|
|
||||||
System,
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly ArpApi _arp;
|
private readonly ArpApi _arp;
|
||||||
private readonly PrepoServicePermissionLevel _permissionLevel;
|
private readonly PrepoServicePermissionLevel _permissionLevel;
|
||||||
private ulong _systemSessionId;
|
private ulong _systemSessionId;
|
||||||
@@ -196,10 +188,17 @@ namespace Ryujinx.Horizon.Prepo.Ipc
|
|||||||
{
|
{
|
||||||
return PrepoResult.InvalidBufferSize;
|
return PrepoResult.InvalidBufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder = new();
|
StringBuilder builder = new();
|
||||||
MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(reportBuffer.ToArray());
|
MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(reportBuffer.ToArray());
|
||||||
|
|
||||||
|
PlayReport playReport = new()
|
||||||
|
{
|
||||||
|
Kind = playReportKind,
|
||||||
|
Room = gameRoom,
|
||||||
|
ReportData = deserializedReport
|
||||||
|
};
|
||||||
|
|
||||||
builder.AppendLine();
|
builder.AppendLine();
|
||||||
builder.AppendLine("PlayReport log:");
|
builder.AppendLine("PlayReport log:");
|
||||||
builder.AppendLine($" Kind: {playReportKind}");
|
builder.AppendLine($" Kind: {playReportKind}");
|
||||||
@@ -209,10 +208,12 @@ namespace Ryujinx.Horizon.Prepo.Ipc
|
|||||||
if (pid != 0)
|
if (pid != 0)
|
||||||
{
|
{
|
||||||
builder.AppendLine($" Pid: {pid}");
|
builder.AppendLine($" Pid: {pid}");
|
||||||
|
playReport.Pid = pid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.AppendLine($" ApplicationId: {applicationId}");
|
builder.AppendLine($" ApplicationId: {applicationId}");
|
||||||
|
playReport.AppId = applicationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result result = _arp.GetApplicationInstanceId(out ulong applicationInstanceId, pid);
|
Result result = _arp.GetApplicationInstanceId(out ulong applicationInstanceId, pid);
|
||||||
@@ -223,17 +224,20 @@ namespace Ryujinx.Horizon.Prepo.Ipc
|
|||||||
|
|
||||||
_arp.GetApplicationLaunchProperty(out ApplicationLaunchProperty applicationLaunchProperty, applicationInstanceId).AbortOnFailure();
|
_arp.GetApplicationLaunchProperty(out ApplicationLaunchProperty applicationLaunchProperty, applicationInstanceId).AbortOnFailure();
|
||||||
|
|
||||||
|
playReport.Version = applicationLaunchProperty.Version;
|
||||||
|
|
||||||
builder.AppendLine($" ApplicationVersion: {applicationLaunchProperty.Version}");
|
builder.AppendLine($" ApplicationVersion: {applicationLaunchProperty.Version}");
|
||||||
|
|
||||||
if (!userId.IsNull)
|
if (!userId.IsNull)
|
||||||
{
|
{
|
||||||
builder.AppendLine($" UserId: {userId}");
|
builder.AppendLine($" UserId: {userId}");
|
||||||
|
playReport.UserId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.AppendLine($" Room: {gameRoom}");
|
builder.AppendLine($" Room: {gameRoom}");
|
||||||
builder.AppendLine($" Report: {MessagePackObjectFormatter.Format(deserializedReport)}");
|
builder.AppendLine($" Report: {MessagePackObjectFormatter.Format(deserializedReport)}");
|
||||||
|
|
||||||
HorizonStatic.HandlePlayReport(deserializedReport);
|
HorizonStatic.HandlePlayReport(playReport);
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.ServicePrepo, builder.ToString());
|
Logger.Info?.Print(LogClass.ServicePrepo, builder.ToString());
|
||||||
|
|
||||||
|
|||||||
24
src/Ryujinx.Horizon/Prepo/Types/PlayReport.cs
Normal file
24
src/Ryujinx.Horizon/Prepo/Types/PlayReport.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using MsgPack;
|
||||||
|
using Ryujinx.Horizon.Sdk.Account;
|
||||||
|
using Ryujinx.Horizon.Sdk.Ncm;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.Prepo.Types
|
||||||
|
{
|
||||||
|
public struct PlayReport
|
||||||
|
{
|
||||||
|
public PlayReportKind Kind { get; init; }
|
||||||
|
public string Room { get; init; }
|
||||||
|
public MessagePackObject ReportData { get; init; }
|
||||||
|
|
||||||
|
public ApplicationId? AppId;
|
||||||
|
public ulong? Pid;
|
||||||
|
public uint Version;
|
||||||
|
public Uid? UserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PlayReportKind
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
System,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23696,6 +23696,56 @@
|
|||||||
"zh_CN": "选择一个要解压的 DLC",
|
"zh_CN": "选择一个要解压的 DLC",
|
||||||
"zh_TW": ""
|
"zh_TW": ""
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ID": "GameInfoRpcImage",
|
||||||
|
"Translations": {
|
||||||
|
"ar_SA": "",
|
||||||
|
"de_DE": "",
|
||||||
|
"el_GR": "",
|
||||||
|
"en_US": "Rich Presence Image",
|
||||||
|
"es_ES": "",
|
||||||
|
"fr_FR": "",
|
||||||
|
"he_IL": "",
|
||||||
|
"it_IT": "",
|
||||||
|
"ja_JP": "",
|
||||||
|
"ko_KR": "",
|
||||||
|
"no_NO": "",
|
||||||
|
"pl_PL": "",
|
||||||
|
"pt_BR": "",
|
||||||
|
"ru_RU": "",
|
||||||
|
"sv_SE": "",
|
||||||
|
"th_TH": "",
|
||||||
|
"tr_TR": "",
|
||||||
|
"uk_UA": "",
|
||||||
|
"zh_CN": "",
|
||||||
|
"zh_TW": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ID": "GameInfoRpcDynamic",
|
||||||
|
"Translations": {
|
||||||
|
"ar_SA": "",
|
||||||
|
"de_DE": "",
|
||||||
|
"el_GR": "",
|
||||||
|
"en_US": "Dynamic Rich Presence",
|
||||||
|
"es_ES": "",
|
||||||
|
"fr_FR": "",
|
||||||
|
"he_IL": "",
|
||||||
|
"it_IT": "",
|
||||||
|
"ja_JP": "",
|
||||||
|
"ko_KR": "",
|
||||||
|
"no_NO": "",
|
||||||
|
"pl_PL": "",
|
||||||
|
"pt_BR": "",
|
||||||
|
"ru_RU": "",
|
||||||
|
"sv_SE": "",
|
||||||
|
"th_TH": "",
|
||||||
|
"tr_TR": "",
|
||||||
|
"uk_UA": "",
|
||||||
|
"zh_CN": "",
|
||||||
|
"zh_TW": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@ using Ryujinx.Common.Logging;
|
|||||||
using Ryujinx.HLE;
|
using Ryujinx.HLE;
|
||||||
using Ryujinx.HLE.Loaders.Processes;
|
using Ryujinx.HLE.Loaders.Processes;
|
||||||
using Ryujinx.Horizon;
|
using Ryujinx.Horizon;
|
||||||
|
using Ryujinx.Horizon.Prepo.Types;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Ryujinx.Ava
|
namespace Ryujinx.Ava
|
||||||
@@ -37,6 +39,9 @@ namespace Ryujinx.Ava
|
|||||||
private static RichPresence _discordPresencePlaying;
|
private static RichPresence _discordPresencePlaying;
|
||||||
private static ApplicationMetadata _currentApp;
|
private static ApplicationMetadata _currentApp;
|
||||||
|
|
||||||
|
public static bool HasAssetImage(string titleId) => TitleIDs.DiscordGameAssetKeys.ContainsIgnoreCase(titleId);
|
||||||
|
public static bool HasAnalyzer(string titleId) => PlayReports.Analyzer.TitleIds.ContainsIgnoreCase(titleId);
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
_discordPresenceMain = new RichPresence
|
_discordPresenceMain = new RichPresence
|
||||||
@@ -120,7 +125,7 @@ namespace Ryujinx.Ava
|
|||||||
_currentApp = null;
|
_currentApp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandlePlayReport(MessagePackObject playReport)
|
private static void HandlePlayReport(PlayReport playReport)
|
||||||
{
|
{
|
||||||
if (_discordClient is null) return;
|
if (_discordClient is null) return;
|
||||||
if (!TitleIDs.CurrentApplication.Value.HasValue) return;
|
if (!TitleIDs.CurrentApplication.Value.HasValue) return;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
xmlns:ext="using:Ryujinx.Ava.Common.Markup"
|
xmlns:ext="using:Ryujinx.Ava.Common.Markup"
|
||||||
xmlns:viewModels="using:Ryujinx.Ava.UI.ViewModels"
|
xmlns:viewModels="using:Ryujinx.Ava.UI.ViewModels"
|
||||||
|
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.ApplicationDataView"
|
x:Class="Ryujinx.Ava.UI.Controls.ApplicationDataView"
|
||||||
@@ -85,6 +86,49 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Separator Margin="0, 10, 0, 10" Height="1" BorderBrush="Gray" Background="Gray" />
|
<Separator Margin="0, 10, 0, 10" Height="1" BorderBrush="Gray" Background="Gray" />
|
||||||
|
<StackPanel Orientation="Vertical" Spacing="5">
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
|
<ui:SymbolIcon Foreground="ForestGreen" Symbol="Checkmark" IsVisible="{Binding AppData.HasRichPresenceAsset}"/>
|
||||||
|
<TextBlock
|
||||||
|
Foreground="ForestGreen"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
IsVisible="{Binding AppData.HasRichPresenceAsset}"
|
||||||
|
Text="{ext:Locale GameInfoRpcImage}"
|
||||||
|
TextAlignment="Start"
|
||||||
|
TextWrapping="Wrap" >
|
||||||
|
</TextBlock>
|
||||||
|
<ui:SymbolIcon Foreground="Red" Symbol="Cancel" IsVisible="{Binding !AppData.HasRichPresenceAsset}"/>
|
||||||
|
<TextBlock
|
||||||
|
Foreground="Red"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
IsVisible="{Binding !AppData.HasRichPresenceAsset}"
|
||||||
|
Text="{ext:Locale GameInfoRpcImage}"
|
||||||
|
TextAlignment="Start"
|
||||||
|
TextWrapping="Wrap" >
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
|
<ui:SymbolIcon Foreground="ForestGreen" Symbol="Checkmark" IsVisible="{Binding AppData.HasDynamicRichPresenceSupport}"/>
|
||||||
|
<TextBlock
|
||||||
|
Foreground="ForestGreen"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
IsVisible="{Binding AppData.HasDynamicRichPresenceSupport}"
|
||||||
|
Text="{ext:Locale GameInfoRpcDynamic}"
|
||||||
|
TextAlignment="Start"
|
||||||
|
TextWrapping="Wrap" >
|
||||||
|
</TextBlock>
|
||||||
|
<ui:SymbolIcon Foreground="Red" Symbol="Cancel" IsVisible="{Binding !AppData.HasDynamicRichPresenceSupport}"/>
|
||||||
|
<TextBlock
|
||||||
|
Foreground="Red"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
IsVisible="{Binding !AppData.HasDynamicRichPresenceSupport}"
|
||||||
|
Text="{ext:Locale GameInfoRpcDynamic}"
|
||||||
|
TextAlignment="Start"
|
||||||
|
TextWrapping="Wrap" >
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<Separator Margin="0, 10, 0, 10" Height="1" BorderBrush="Gray" Background="Gray" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
IsVisible="{Binding AppData.HasLdnGames}"
|
IsVisible="{Binding AppData.HasLdnGames}"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
LocaleKeys.CompatibilityListNothing or
|
LocaleKeys.CompatibilityListNothing or
|
||||||
LocaleKeys.CompatibilityListBoots or
|
LocaleKeys.CompatibilityListBoots or
|
||||||
LocaleKeys.CompatibilityListMenus => Brushes.Red,
|
LocaleKeys.CompatibilityListMenus => Brushes.Red,
|
||||||
LocaleKeys.CompatibilityListIngame => Brushes.Yellow,
|
LocaleKeys.CompatibilityListIngame => Brushes.DarkOrange,
|
||||||
_ => Brushes.ForestGreen
|
_ => Brushes.ForestGreen
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,260 +0,0 @@
|
|||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels.Input;
|
|
||||||
using Ryujinx.Input;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Models.Input
|
|
||||||
{
|
|
||||||
public class StickVisualizer : BaseModel, IDisposable
|
|
||||||
{
|
|
||||||
public const int DrawStickPollRate = 50; // Milliseconds per poll.
|
|
||||||
public const int DrawStickCircumference = 5;
|
|
||||||
public const float DrawStickScaleFactor = DrawStickCanvasCenter;
|
|
||||||
public const int DrawStickCanvasSize = 100;
|
|
||||||
public const int DrawStickBorderSize = DrawStickCanvasSize + 5;
|
|
||||||
public const float DrawStickCanvasCenter = (DrawStickCanvasSize - DrawStickCircumference) / 2;
|
|
||||||
public const float MaxVectorLength = DrawStickCanvasSize / 2;
|
|
||||||
|
|
||||||
public CancellationTokenSource PollTokenSource;
|
|
||||||
public CancellationToken PollToken;
|
|
||||||
|
|
||||||
private static float _vectorLength;
|
|
||||||
private static float _vectorMultiplier;
|
|
||||||
|
|
||||||
private bool disposedValue;
|
|
||||||
|
|
||||||
private DeviceType _type;
|
|
||||||
public DeviceType Type
|
|
||||||
{
|
|
||||||
get => _type;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_type = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private GamepadInputConfig _gamepadConfig;
|
|
||||||
public GamepadInputConfig GamepadConfig
|
|
||||||
{
|
|
||||||
get => _gamepadConfig;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_gamepadConfig = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private KeyboardInputConfig _keyboardConfig;
|
|
||||||
public KeyboardInputConfig KeyboardConfig
|
|
||||||
{
|
|
||||||
get => _keyboardConfig;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_keyboardConfig = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private (float, float) _uiStickLeft;
|
|
||||||
public (float, float) UiStickLeft
|
|
||||||
{
|
|
||||||
get => (_uiStickLeft.Item1 * DrawStickScaleFactor, _uiStickLeft.Item2 * DrawStickScaleFactor);
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_uiStickLeft = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
OnPropertyChanged(nameof(UiStickRightX));
|
|
||||||
OnPropertyChanged(nameof(UiStickRightY));
|
|
||||||
OnPropertyChanged(nameof(UiDeadzoneRight));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private (float, float) _uiStickRight;
|
|
||||||
public (float, float) UiStickRight
|
|
||||||
{
|
|
||||||
get => (_uiStickRight.Item1 * DrawStickScaleFactor, _uiStickRight.Item2 * DrawStickScaleFactor);
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_uiStickRight = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
OnPropertyChanged(nameof(UiStickLeftX));
|
|
||||||
OnPropertyChanged(nameof(UiStickLeftY));
|
|
||||||
OnPropertyChanged(nameof(UiDeadzoneLeft));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float UiStickLeftX => ClampVector(UiStickLeft).Item1;
|
|
||||||
public float UiStickLeftY => ClampVector(UiStickLeft).Item2;
|
|
||||||
public float UiStickRightX => ClampVector(UiStickRight).Item1;
|
|
||||||
public float UiStickRightY => ClampVector(UiStickRight).Item2;
|
|
||||||
|
|
||||||
public int UiStickCircumference => DrawStickCircumference;
|
|
||||||
public int UiCanvasSize => DrawStickCanvasSize;
|
|
||||||
public int UiStickBorderSize => DrawStickBorderSize;
|
|
||||||
|
|
||||||
public float? UiDeadzoneLeft => _gamepadConfig?.DeadzoneLeft * DrawStickCanvasSize - DrawStickCircumference;
|
|
||||||
public float? UiDeadzoneRight => _gamepadConfig?.DeadzoneRight * DrawStickCanvasSize - DrawStickCircumference;
|
|
||||||
|
|
||||||
private InputViewModel Parent;
|
|
||||||
|
|
||||||
public StickVisualizer(InputViewModel parent)
|
|
||||||
{
|
|
||||||
Parent = parent;
|
|
||||||
|
|
||||||
PollTokenSource = new CancellationTokenSource();
|
|
||||||
PollToken = PollTokenSource.Token;
|
|
||||||
|
|
||||||
Task.Run(Initialize, PollToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateConfig(object config)
|
|
||||||
{
|
|
||||||
if (config is ControllerInputViewModel padConfig)
|
|
||||||
{
|
|
||||||
GamepadConfig = padConfig.Config;
|
|
||||||
Type = DeviceType.Controller;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (config is KeyboardInputViewModel keyConfig)
|
|
||||||
{
|
|
||||||
KeyboardConfig = keyConfig.Config;
|
|
||||||
Type = DeviceType.Keyboard;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type = DeviceType.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Initialize()
|
|
||||||
{
|
|
||||||
(float, float) leftBuffer;
|
|
||||||
(float, float) rightBuffer;
|
|
||||||
|
|
||||||
while (!PollToken.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
leftBuffer = (0f, 0f);
|
|
||||||
rightBuffer = (0f, 0f);
|
|
||||||
|
|
||||||
switch (Type)
|
|
||||||
{
|
|
||||||
case DeviceType.Keyboard:
|
|
||||||
IKeyboard keyboard = (IKeyboard)Parent.AvaloniaKeyboardDriver.GetGamepad("0");
|
|
||||||
|
|
||||||
if (keyboard != null)
|
|
||||||
{
|
|
||||||
KeyboardStateSnapshot snapshot = keyboard.GetKeyboardStateSnapshot();
|
|
||||||
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickRight))
|
|
||||||
{
|
|
||||||
leftBuffer.Item1 += 1;
|
|
||||||
}
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickLeft))
|
|
||||||
{
|
|
||||||
leftBuffer.Item1 -= 1;
|
|
||||||
}
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickUp))
|
|
||||||
{
|
|
||||||
leftBuffer.Item2 += 1;
|
|
||||||
}
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.LeftStickDown))
|
|
||||||
{
|
|
||||||
leftBuffer.Item2 -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickRight))
|
|
||||||
{
|
|
||||||
rightBuffer.Item1 += 1;
|
|
||||||
}
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickLeft))
|
|
||||||
{
|
|
||||||
rightBuffer.Item1 -= 1;
|
|
||||||
}
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickUp))
|
|
||||||
{
|
|
||||||
rightBuffer.Item2 += 1;
|
|
||||||
}
|
|
||||||
if (snapshot.IsPressed((Key)KeyboardConfig.RightStickDown))
|
|
||||||
{
|
|
||||||
rightBuffer.Item2 -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
UiStickLeft = leftBuffer;
|
|
||||||
UiStickRight = rightBuffer;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DeviceType.Controller:
|
|
||||||
IGamepad controller = Parent.SelectedGamepad;
|
|
||||||
|
|
||||||
if (controller != null)
|
|
||||||
{
|
|
||||||
leftBuffer = controller.GetStick((StickInputId)GamepadConfig.LeftJoystick);
|
|
||||||
rightBuffer = controller.GetStick((StickInputId)GamepadConfig.RightJoystick);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DeviceType.None:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentException($"Unable to poll device type \"{Type}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
UiStickLeft = leftBuffer;
|
|
||||||
UiStickRight = rightBuffer;
|
|
||||||
|
|
||||||
await Task.Delay(DrawStickPollRate, PollToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
PollTokenSource.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static (float, float) ClampVector((float, float) vect)
|
|
||||||
{
|
|
||||||
_vectorMultiplier = 1;
|
|
||||||
_vectorLength = MathF.Sqrt((vect.Item1 * vect.Item1) + (vect.Item2 * vect.Item2));
|
|
||||||
|
|
||||||
if (_vectorLength > MaxVectorLength)
|
|
||||||
{
|
|
||||||
_vectorMultiplier = MaxVectorLength / _vectorLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
vect.Item1 = vect.Item1 * _vectorMultiplier + DrawStickCanvasCenter;
|
|
||||||
vect.Item2 = vect.Item2 * _vectorMultiplier + DrawStickCanvasCenter;
|
|
||||||
|
|
||||||
return vect;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (!disposedValue)
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
PollTokenSource.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyboardConfig = null;
|
|
||||||
GamepadConfig = null;
|
|
||||||
Parent = null;
|
|
||||||
|
|
||||||
disposedValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(disposing: true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
using Avalonia.Svg.Skia;
|
using Avalonia.Svg.Skia;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using FluentAvalonia.UI.Controls;
|
|
||||||
using Ryujinx.Ava.Input;
|
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
|
||||||
using Ryujinx.Ava.UI.Models.Input;
|
using Ryujinx.Ava.UI.Models.Input;
|
||||||
using Ryujinx.Ava.UI.Views.Input;
|
using Ryujinx.Ava.UI.Views.Input;
|
||||||
using Ryujinx.Common.Utilities;
|
using Ryujinx.Common.Utilities;
|
||||||
@@ -14,30 +10,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
{
|
{
|
||||||
public partial class ControllerInputViewModel : BaseModel
|
public partial class ControllerInputViewModel : BaseModel
|
||||||
{
|
{
|
||||||
private GamepadInputConfig _config;
|
[ObservableProperty] private GamepadInputConfig _config;
|
||||||
public GamepadInputConfig Config
|
|
||||||
{
|
|
||||||
get => _config;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_config = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private StickVisualizer _visualizer;
|
|
||||||
public StickVisualizer Visualizer
|
|
||||||
{
|
|
||||||
get => _visualizer;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_visualizer = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _isLeft;
|
private bool _isLeft;
|
||||||
public bool IsLeft
|
public bool IsLeft
|
||||||
{
|
{
|
||||||
@@ -63,15 +37,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool HasSides => IsLeft ^ IsRight;
|
public bool HasSides => IsLeft ^ IsRight;
|
||||||
|
|
||||||
[ObservableProperty] private SvgImage _image;
|
[ObservableProperty] private SvgImage _image;
|
||||||
|
|
||||||
public InputViewModel ParentModel { get; }
|
public InputViewModel ParentModel { get; }
|
||||||
|
|
||||||
public ControllerInputViewModel(InputViewModel model, GamepadInputConfig config, StickVisualizer visualizer)
|
public ControllerInputViewModel(InputViewModel model, GamepadInputConfig config)
|
||||||
{
|
{
|
||||||
ParentModel = model;
|
ParentModel = model;
|
||||||
Visualizer = visualizer;
|
|
||||||
model.NotifyChangesEvent += OnParentModelChanged;
|
model.NotifyChangesEvent += OnParentModelChanged;
|
||||||
OnParentModelChanged();
|
OnParentModelChanged();
|
||||||
config.PropertyChanged += (_, args) =>
|
config.PropertyChanged += (_, args) =>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
private int _controller;
|
private int _controller;
|
||||||
private string _controllerImage;
|
private string _controllerImage;
|
||||||
private int _device;
|
private int _device;
|
||||||
private object _configViewModel;
|
[ObservableProperty] private object _configViewModel;
|
||||||
[ObservableProperty] private string _profileName;
|
[ObservableProperty] private string _profileName;
|
||||||
private bool _isLoaded;
|
private bool _isLoaded;
|
||||||
|
|
||||||
@@ -74,7 +74,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
OnPropertiesChanged(nameof(HasLed), nameof(CanClearLed));
|
OnPropertiesChanged(nameof(HasLed), nameof(CanClearLed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public StickVisualizer VisualStick { get; private set; }
|
|
||||||
|
|
||||||
public ObservableCollection<PlayerModel> PlayerIndexes { get; set; }
|
public ObservableCollection<PlayerModel> PlayerIndexes { get; set; }
|
||||||
public ObservableCollection<(DeviceType Type, string Id, string Name)> Devices { get; set; }
|
public ObservableCollection<(DeviceType Type, string Id, string Name)> Devices { get; set; }
|
||||||
@@ -95,19 +94,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
public bool IsModified { get; set; }
|
public bool IsModified { get; set; }
|
||||||
public event Action NotifyChangesEvent;
|
public event Action NotifyChangesEvent;
|
||||||
|
|
||||||
public object ConfigViewModel
|
|
||||||
{
|
|
||||||
get => _configViewModel;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_configViewModel = value;
|
|
||||||
|
|
||||||
VisualStick.UpdateConfig(value);
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerIndex PlayerIdChoose
|
public PlayerIndex PlayerIdChoose
|
||||||
{
|
{
|
||||||
get => _playerIdChoose;
|
get => _playerIdChoose;
|
||||||
@@ -283,7 +269,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
Devices = [];
|
Devices = [];
|
||||||
ProfilesList = [];
|
ProfilesList = [];
|
||||||
DeviceList = [];
|
DeviceList = [];
|
||||||
VisualStick = new StickVisualizer(this);
|
|
||||||
|
|
||||||
ControllerImage = ProControllerResource;
|
ControllerImage = ProControllerResource;
|
||||||
|
|
||||||
@@ -304,12 +289,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
|
|
||||||
if (Config is StandardKeyboardInputConfig keyboardInputConfig)
|
if (Config is StandardKeyboardInputConfig keyboardInputConfig)
|
||||||
{
|
{
|
||||||
ConfigViewModel = new KeyboardInputViewModel(this, new KeyboardInputConfig(keyboardInputConfig), VisualStick);
|
ConfigViewModel = new KeyboardInputViewModel(this, new KeyboardInputConfig(keyboardInputConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config is StandardControllerInputConfig controllerInputConfig)
|
if (Config is StandardControllerInputConfig controllerInputConfig)
|
||||||
{
|
{
|
||||||
ConfigViewModel = new ControllerInputViewModel(this, new GamepadInputConfig(controllerInputConfig), VisualStick);
|
ConfigViewModel = new ControllerInputViewModel(this, new GamepadInputConfig(controllerInputConfig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -908,8 +893,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
|
|
||||||
_mainWindow.ViewModel.AppHost?.NpadManager.UnblockInputUpdates();
|
_mainWindow.ViewModel.AppHost?.NpadManager.UnblockInputUpdates();
|
||||||
|
|
||||||
VisualStick.Dispose();
|
|
||||||
|
|
||||||
SelectedGamepad?.Dispose();
|
SelectedGamepad?.Dispose();
|
||||||
|
|
||||||
AvaloniaKeyboardDriver.Dispose();
|
AvaloniaKeyboardDriver.Dispose();
|
||||||
|
|||||||
@@ -6,29 +6,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
{
|
{
|
||||||
public partial class KeyboardInputViewModel : BaseModel
|
public partial class KeyboardInputViewModel : BaseModel
|
||||||
{
|
{
|
||||||
private KeyboardInputConfig _config;
|
[ObservableProperty] private KeyboardInputConfig _config;
|
||||||
public KeyboardInputConfig Config
|
|
||||||
{
|
|
||||||
get => _config;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_config = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private StickVisualizer _visualizer;
|
|
||||||
public StickVisualizer Visualizer
|
|
||||||
{
|
|
||||||
get => _visualizer;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_visualizer = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _isLeft;
|
private bool _isLeft;
|
||||||
public bool IsLeft
|
public bool IsLeft
|
||||||
@@ -60,10 +38,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||||||
|
|
||||||
public readonly InputViewModel ParentModel;
|
public readonly InputViewModel ParentModel;
|
||||||
|
|
||||||
public KeyboardInputViewModel(InputViewModel model, KeyboardInputConfig config, StickVisualizer visualizer)
|
public KeyboardInputViewModel(InputViewModel model, KeyboardInputConfig config)
|
||||||
{
|
{
|
||||||
ParentModel = model;
|
ParentModel = model;
|
||||||
Visualizer = visualizer;
|
|
||||||
model.NotifyChangesEvent += OnParentModelChanged;
|
model.NotifyChangesEvent += OnParentModelChanged;
|
||||||
OnParentModelChanged();
|
OnParentModelChanged();
|
||||||
Config = config;
|
Config = config;
|
||||||
|
|||||||
@@ -316,103 +316,17 @@
|
|||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch">
|
VerticalAlignment="Stretch">
|
||||||
<!-- Controller Picture -->
|
<!-- Controller Picture -->
|
||||||
|
<Image
|
||||||
|
Margin="0,10"
|
||||||
|
MaxHeight="300"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Source="{Binding Image}" />
|
||||||
<Border
|
<Border
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
CornerRadius="5"
|
CornerRadius="5"
|
||||||
Margin="0,10"
|
|
||||||
MinHeight="90">
|
MinHeight="90">
|
||||||
<StackPanel Orientation="Vertical">
|
|
||||||
<Image
|
|
||||||
Margin="5,10"
|
|
||||||
MaxHeight="300"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Source="{Binding Image}" />
|
|
||||||
<StackPanel
|
|
||||||
Margin="10"
|
|
||||||
Orientation="Horizontal"
|
|
||||||
Spacing="20"
|
|
||||||
HorizontalAlignment="Center">
|
|
||||||
<Border
|
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="5"
|
|
||||||
Height="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
Width="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
IsVisible="{Binding IsLeft}">
|
|
||||||
<Canvas
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}">
|
|
||||||
<Grid
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}">
|
|
||||||
<Ellipse
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Stroke="Black"
|
|
||||||
StrokeThickness="1"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}" />
|
|
||||||
<Ellipse
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Fill="Gray"
|
|
||||||
Opacity="100"
|
|
||||||
Height="{Binding Visualizer.UiDeadzoneLeft}"
|
|
||||||
Width="{Binding Visualizer.UiDeadzoneLeft}" />
|
|
||||||
</Grid>
|
|
||||||
<Ellipse
|
|
||||||
Fill="Red"
|
|
||||||
Width="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Height="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Canvas.Bottom="{Binding Visualizer.UiStickLeftY}"
|
|
||||||
Canvas.Left="{Binding Visualizer.UiStickLeftX}" />
|
|
||||||
</Canvas>
|
|
||||||
</Border>
|
|
||||||
<Border
|
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="5"
|
|
||||||
Height="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
Width="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
IsVisible="{Binding IsRight}">
|
|
||||||
<Canvas
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}">
|
|
||||||
<Grid
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}">
|
|
||||||
<Ellipse
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Stroke="Black"
|
|
||||||
StrokeThickness="1"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}" />
|
|
||||||
<Ellipse
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Fill="Gray"
|
|
||||||
Opacity="100"
|
|
||||||
Height="{Binding Visualizer.UiDeadzoneRight}"
|
|
||||||
Width="{Binding Visualizer.UiDeadzoneRight}" />
|
|
||||||
</Grid>
|
|
||||||
<Ellipse
|
|
||||||
Fill="Red"
|
|
||||||
Width="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Height="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Canvas.Bottom="{Binding Visualizer.UiStickRightY}"
|
|
||||||
Canvas.Left="{Binding Visualizer.UiStickRightX}" />
|
|
||||||
</Canvas>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
<Border
|
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="5">
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Margin="8"
|
Margin="8"
|
||||||
Orientation="Vertical">
|
Orientation="Vertical">
|
||||||
@@ -431,8 +345,8 @@
|
|||||||
Minimum="0"
|
Minimum="0"
|
||||||
Value="{Binding Config.TriggerThreshold, Mode=TwoWay}" />
|
Value="{Binding Config.TriggerThreshold, Mode=TwoWay}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Width="25"
|
Width="25"
|
||||||
Text="{Binding Config.TriggerThreshold, StringFormat=\{0:0.00\}}" />
|
Text="{Binding Config.TriggerThreshold, StringFormat=\{0:0.00\}}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
|
|||||||
@@ -309,79 +309,12 @@
|
|||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch">
|
VerticalAlignment="Stretch">
|
||||||
<!-- Controller Picture -->
|
<!-- Controller Picture -->
|
||||||
<Border
|
<Image
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="5"
|
|
||||||
Margin="0,10"
|
Margin="0,10"
|
||||||
MinHeight="90">
|
MaxHeight="300"
|
||||||
<StackPanel
|
HorizontalAlignment="Stretch"
|
||||||
Margin="10"
|
VerticalAlignment="Stretch"
|
||||||
Orientation="Horizontal"
|
Source="{Binding Image}" />
|
||||||
Spacing="20"
|
|
||||||
HorizontalAlignment="Center">
|
|
||||||
<Border
|
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="5"
|
|
||||||
Height="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
Width="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
IsVisible="{Binding IsLeft}">
|
|
||||||
<Canvas
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}">
|
|
||||||
<Grid
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}">
|
|
||||||
<Ellipse
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Stroke="Black"
|
|
||||||
StrokeThickness="1"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"/>
|
|
||||||
</Grid>
|
|
||||||
<Ellipse
|
|
||||||
Fill="Red"
|
|
||||||
Width="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Height="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Canvas.Bottom="{Binding Visualizer.UiStickLeftY}"
|
|
||||||
Canvas.Left="{Binding Visualizer.UiStickLeftX}" />
|
|
||||||
</Canvas>
|
|
||||||
</Border>
|
|
||||||
<Border
|
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="5"
|
|
||||||
Height="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
Width="{Binding Visualizer.UiStickBorderSize}"
|
|
||||||
IsVisible="{Binding IsRight}">
|
|
||||||
<Canvas
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}">
|
|
||||||
<Grid
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Background="{DynamicResource ThemeBackgroundColor}">
|
|
||||||
<Ellipse
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Stroke="Black"
|
|
||||||
StrokeThickness="1"
|
|
||||||
Width="{Binding Visualizer.UiCanvasSize}"
|
|
||||||
Height="{Binding Visualizer.UiCanvasSize}"/>
|
|
||||||
</Grid>
|
|
||||||
<Ellipse
|
|
||||||
Fill="Red"
|
|
||||||
Width="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Height="{Binding Visualizer.UiStickCircumference}"
|
|
||||||
Canvas.Bottom="{Binding Visualizer.UiStickRightY}"
|
|
||||||
Canvas.Left="{Binding Visualizer.UiStickRightX}" />
|
|
||||||
</Canvas>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
<Border
|
<Border
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
xmlns:helper="clr-namespace:Ryujinx.Common.Helper;assembly=Ryujinx.Common"
|
xmlns:helper="clr-namespace:Ryujinx.Common.Helper;assembly=Ryujinx.Common"
|
||||||
Width="1100"
|
Width="1100"
|
||||||
Height="850"
|
Height="768"
|
||||||
MinWidth="800"
|
MinWidth="800"
|
||||||
MinHeight="480"
|
MinHeight="480"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
public int GameCount { get; set; }
|
public int GameCount { get; set; }
|
||||||
|
|
||||||
public bool HasLdnGames => PlayerCount != 0 && GameCount != 0;
|
public bool HasLdnGames => PlayerCount != 0 && GameCount != 0;
|
||||||
|
|
||||||
|
public bool HasRichPresenceAsset => DiscordIntegrationModule.HasAssetImage(IdString);
|
||||||
|
public bool HasDynamicRichPresenceSupport => DiscordIntegrationModule.HasAnalyzer(IdString);
|
||||||
|
|
||||||
public TimeSpan TimePlayed { get; set; }
|
public TimeSpan TimePlayed { get; set; }
|
||||||
public DateTime? LastPlayed { get; set; }
|
public DateTime? LastPlayed { get; set; }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using MsgPack;
|
|||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@@ -15,6 +16,10 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
{
|
{
|
||||||
private readonly List<GameSpec> _specs = [];
|
private readonly List<GameSpec> _specs = [];
|
||||||
|
|
||||||
|
public string[] TitleIds => Specs.SelectMany(x => x.TitleIds).ToArray();
|
||||||
|
|
||||||
|
public IReadOnlyList<GameSpec> Specs => new ReadOnlyCollection<GameSpec>(_specs);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an analysis spec matching a specific game by title ID, with the provided spec configuration.
|
/// Add an analysis spec matching a specific game by title ID, with the provided spec configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -80,7 +85,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs the configured <see cref="GameSpec.FormatterSpec"/> for the specified game title ID.
|
/// Runs the configured <see cref="FormatterSpec"/> for the specified game title ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="runningGameId">The game currently running.</param>
|
/// <param name="runningGameId">The game currently running.</param>
|
||||||
/// <param name="appMeta">The Application metadata information, including localized game name and play time information.</param>
|
/// <param name="appMeta">The Application metadata information, including localized game name and play time information.</param>
|
||||||
@@ -89,10 +94,10 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public FormattedValue Format(
|
public FormattedValue Format(
|
||||||
string runningGameId,
|
string runningGameId,
|
||||||
ApplicationMetadata appMeta,
|
ApplicationMetadata appMeta,
|
||||||
MessagePackObject playReport
|
Horizon.Prepo.Types.PlayReport playReport
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!playReport.IsDictionary)
|
if (!playReport.ReportData.IsDictionary)
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|
||||||
if (!_specs.TryGetFirst(s => runningGameId.EqualsAnyIgnoreCase(s.TitleIds), out GameSpec spec))
|
if (!_specs.TryGetFirst(s => runningGameId.EqualsAnyIgnoreCase(s.TitleIds), out GameSpec spec))
|
||||||
@@ -100,10 +105,14 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
|
|
||||||
foreach (FormatterSpec formatSpec in spec.SimpleValueFormatters.OrderBy(x => x.Priority))
|
foreach (FormatterSpec formatSpec in spec.SimpleValueFormatters.OrderBy(x => x.Priority))
|
||||||
{
|
{
|
||||||
if (!playReport.AsDictionary().TryGetValue(formatSpec.ReportKey, out MessagePackObject valuePackObject))
|
if (!playReport.ReportData.AsDictionary().TryGetValue(formatSpec.ReportKey, out MessagePackObject valuePackObject))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return formatSpec.Formatter(new Value { Application = appMeta, PackedValue = valuePackObject });
|
return formatSpec.Formatter(new SingleValue(valuePackObject)
|
||||||
|
{
|
||||||
|
Application = appMeta,
|
||||||
|
PlayReport = playReport
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (MultiFormatterSpec formatSpec in spec.MultiValueFormatters.OrderBy(x => x.Priority))
|
foreach (MultiFormatterSpec formatSpec in spec.MultiValueFormatters.OrderBy(x => x.Priority))
|
||||||
@@ -111,7 +120,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
List<MessagePackObject> packedObjects = [];
|
List<MessagePackObject> packedObjects = [];
|
||||||
foreach (var reportKey in formatSpec.ReportKeys)
|
foreach (var reportKey in formatSpec.ReportKeys)
|
||||||
{
|
{
|
||||||
if (!playReport.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
packedObjects.Add(valuePackObject);
|
packedObjects.Add(valuePackObject);
|
||||||
@@ -120,23 +129,30 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
if (packedObjects.Count != formatSpec.ReportKeys.Length)
|
if (packedObjects.Count != formatSpec.ReportKeys.Length)
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|
||||||
return formatSpec.Formatter(packedObjects
|
return formatSpec.Formatter(new MultiValue(packedObjects)
|
||||||
.Select(packObject => new Value { Application = appMeta, PackedValue = packObject })
|
{
|
||||||
.ToArray());
|
Application = appMeta,
|
||||||
|
PlayReport = playReport
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SparseMultiFormatterSpec formatSpec in spec.SparseMultiValueFormatters.OrderBy(x => x.Priority))
|
foreach (SparseMultiFormatterSpec formatSpec in spec.SparseMultiValueFormatters.OrderBy(x => x.Priority))
|
||||||
{
|
{
|
||||||
Dictionary<string, Value> packedObjects = [];
|
Dictionary<string, MessagePackObject> packedObjects = [];
|
||||||
foreach (var reportKey in formatSpec.ReportKeys)
|
foreach (var reportKey in formatSpec.ReportKeys)
|
||||||
{
|
{
|
||||||
if (!playReport.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
packedObjects.Add(reportKey, new Value { Application = appMeta, PackedValue = valuePackObject });
|
packedObjects.Add(reportKey, valuePackObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatSpec.Formatter(packedObjects);
|
return formatSpec.Formatter(
|
||||||
|
new SparseMultiValue(packedObjects)
|
||||||
|
{
|
||||||
|
Application = appMeta,
|
||||||
|
PlayReport = playReport
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Utilities.PlayReport
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delegate type that powers single value formatters.<br/>
|
/// The delegate type that powers single value formatters.<br/>
|
||||||
@@ -12,7 +10,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <br/>
|
/// <br/>
|
||||||
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate FormattedValue ValueFormatter(Value value);
|
public delegate FormattedValue ValueFormatter(SingleValue value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delegate type that powers multiple value formatters.<br/>
|
/// The delegate type that powers multiple value formatters.<br/>
|
||||||
@@ -24,7 +22,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <br/>
|
/// <br/>
|
||||||
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate FormattedValue MultiValueFormatter(Value[] value);
|
public delegate FormattedValue MultiValueFormatter(MultiValue value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delegate type that powers multiple value formatters.
|
/// The delegate type that powers multiple value formatters.
|
||||||
@@ -38,5 +36,5 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <br/>
|
/// <br/>
|
||||||
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate FormattedValue SparseMultiValueFormatter(Dictionary<string, Value> values);
|
public delegate FormattedValue SparseMultiValueFormatter(SparseMultiValue value);
|
||||||
}
|
}
|
||||||
|
|||||||
87
src/Ryujinx/Utilities/PlayReport/MatchedValues.cs
Normal file
87
src/Ryujinx/Utilities/PlayReport/MatchedValues.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
using MsgPack;
|
||||||
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
|
{
|
||||||
|
public abstract class MatchedValue<T>
|
||||||
|
{
|
||||||
|
public MatchedValue(T matched)
|
||||||
|
{
|
||||||
|
Matched = matched;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The currently running application's <see cref="ApplicationMetadata"/>.
|
||||||
|
/// </summary>
|
||||||
|
public ApplicationMetadata Application { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The entire play report.
|
||||||
|
/// </summary>
|
||||||
|
public Horizon.Prepo.Types.PlayReport PlayReport { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The matched value from the Play Report.
|
||||||
|
/// </summary>
|
||||||
|
public T Matched { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The input data to a <see cref="ValueFormatter"/>,
|
||||||
|
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
||||||
|
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
||||||
|
/// </summary>
|
||||||
|
public class SingleValue : MatchedValue<Value>
|
||||||
|
{
|
||||||
|
public SingleValue(Value matched) : base(matched)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator SingleValue(MessagePackObject mpo) => new(mpo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The input data to a <see cref="MultiValueFormatter"/>,
|
||||||
|
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
||||||
|
/// and the matched <see cref="MessagePackObject"/>s from the Play Report.
|
||||||
|
/// </summary>
|
||||||
|
public class MultiValue : MatchedValue<Value[]>
|
||||||
|
{
|
||||||
|
public MultiValue(Value[] matched) : base(matched)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiValue(IEnumerable<MessagePackObject> matched) : base(Value.ConvertPackedObjects(matched))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MultiValue(List<MessagePackObject> matched)
|
||||||
|
=> new(matched.Select(x => new Value(x)).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The input data to a <see cref="SparseMultiValueFormatter"/>,
|
||||||
|
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
||||||
|
/// and the matched <see cref="MessagePackObject"/>s from the Play Report.
|
||||||
|
/// </summary>
|
||||||
|
public class SparseMultiValue : MatchedValue<Dictionary<string, Value>>
|
||||||
|
{
|
||||||
|
public SparseMultiValue(Dictionary<string, Value> matched) : base(matched)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public SparseMultiValue(Dictionary<string, MessagePackObject> matched) : base(Value.ConvertPackedObjectMap(matched))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator SparseMultiValue(Dictionary<string, MessagePackObject> matched)
|
||||||
|
=> new(matched
|
||||||
|
.ToDictionary(
|
||||||
|
x => x.Key,
|
||||||
|
x => new Value(x.Value)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,28 +39,28 @@
|
|||||||
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
||||||
);
|
);
|
||||||
|
|
||||||
private static FormattedValue BreathOfTheWild_MasterMode(Value value)
|
private static FormattedValue BreathOfTheWild_MasterMode(SingleValue value)
|
||||||
=> value.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
|
=> value.Matched.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
|
||||||
|
|
||||||
private static FormattedValue TearsOfTheKingdom_CurrentField(Value value) =>
|
private static FormattedValue TearsOfTheKingdom_CurrentField(SingleValue value) =>
|
||||||
value.DoubleValue switch
|
value.Matched.DoubleValue switch
|
||||||
{
|
{
|
||||||
> 800d => "Exploring the Sky Islands",
|
> 800d => "Exploring the Sky Islands",
|
||||||
< -201d => "Exploring the Depths",
|
< -201d => "Exploring the Depths",
|
||||||
_ => "Roaming Hyrule"
|
_ => "Roaming Hyrule"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static FormattedValue SuperMarioOdyssey_AssistMode(Value value)
|
private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
|
||||||
=> value.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
|
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
|
||||||
|
|
||||||
private static FormattedValue SuperMarioOdysseyChina_AssistMode(Value value)
|
private static FormattedValue SuperMarioOdysseyChina_AssistMode(SingleValue value)
|
||||||
=> value.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式";
|
=> value.Matched.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式";
|
||||||
|
|
||||||
private static FormattedValue SuperMario3DWorldOrBowsersFury(Value value)
|
private static FormattedValue SuperMario3DWorldOrBowsersFury(SingleValue value)
|
||||||
=> value.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
|
=> value.Matched.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
|
||||||
|
|
||||||
private static FormattedValue MarioKart8Deluxe_Mode(Value value)
|
private static FormattedValue MarioKart8Deluxe_Mode(SingleValue value)
|
||||||
=> value.StringValue switch
|
=> value.Matched.StringValue switch
|
||||||
{
|
{
|
||||||
// Single Player
|
// Single Player
|
||||||
"Single" => "Single Player",
|
"Single" => "Single Player",
|
||||||
@@ -87,11 +87,11 @@
|
|||||||
_ => FormattedValue.ForceReset
|
_ => FormattedValue.ForceReset
|
||||||
};
|
};
|
||||||
|
|
||||||
private static FormattedValue PokemonSVUnionCircle(Value value)
|
private static FormattedValue PokemonSVUnionCircle(SingleValue value)
|
||||||
=> value.BoxedValue is 0 ? "Playing Alone" : "Playing in a group";
|
=> value.Matched.BoxedValue is 0 ? "Playing Alone" : "Playing in a group";
|
||||||
|
|
||||||
private static FormattedValue PokemonSVArea(Value value)
|
private static FormattedValue PokemonSVArea(SingleValue value)
|
||||||
=> value.StringValue switch
|
=> value.Matched.StringValue switch
|
||||||
{
|
{
|
||||||
// Base Game Locations
|
// Base Game Locations
|
||||||
"a_w01" => "South Area One",
|
"a_w01" => "South Area One",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using MsgPack;
|
using MsgPack;
|
||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Utilities.PlayReport
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
{
|
{
|
||||||
@@ -9,12 +11,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
/// containing the currently running application's <see cref="ApplicationMetadata"/>,
|
||||||
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
/// and the matched <see cref="MessagePackObject"/> from the Play Report.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Value
|
public readonly struct Value
|
||||||
{
|
{
|
||||||
/// <summary>
|
public Value(MessagePackObject packedValue)
|
||||||
/// The currently running application's <see cref="ApplicationMetadata"/>.
|
{
|
||||||
/// </summary>
|
PackedValue = packedValue;
|
||||||
public ApplicationMetadata Application { get; init; }
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The matched value from the Play Report.
|
/// The matched value from the Play Report.
|
||||||
@@ -37,6 +39,17 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
: boxed.ToString();
|
: boxed.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static implicit operator Value(MessagePackObject matched) => new(matched);
|
||||||
|
|
||||||
|
public static Value[] ConvertPackedObjects(IEnumerable<MessagePackObject> packObjects)
|
||||||
|
=> packObjects.Select(packObject => new Value(packObject)).ToArray();
|
||||||
|
|
||||||
|
public static Dictionary<string, Value> ConvertPackedObjectMap(Dictionary<string, MessagePackObject> packObjects)
|
||||||
|
=> packObjects.ToDictionary(
|
||||||
|
x => x.Key,
|
||||||
|
x => new Value(x.Value)
|
||||||
|
);
|
||||||
|
|
||||||
#region AsX accessors
|
#region AsX accessors
|
||||||
|
|
||||||
public bool BooleanValue => PackedValue.AsBoolean();
|
public bool BooleanValue => PackedValue.AsBoolean();
|
||||||
|
|||||||
Reference in New Issue
Block a user