Compare commits

..

4 Commits

Author SHA1 Message Date
Willians
12feefe8a7 Merge 05c7839b2d into 4e8157688e 2025-02-08 02:37:53 +00:00
Willians
05c7839b2d Update locales.json 2025-02-07 23:37:50 -03:00
Willians
bbd099b129 Update locales.json 2025-02-06 23:49:47 -03:00
Willians
54bdfc71a9 Update Brazilian Translation 2025-02-06 23:21:46 -03:00
10 changed files with 207 additions and 346 deletions

View File

@@ -1,6 +1,5 @@
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;
@@ -9,7 +8,7 @@ namespace Ryujinx.Horizon
{ {
public static class HorizonStatic public static class HorizonStatic
{ {
internal static void HandlePlayReport(PlayReport report) => internal static void HandlePlayReport(MessagePackObject report) =>
new Thread(() => PlayReport?.Invoke(report)) new Thread(() => PlayReport?.Invoke(report))
{ {
Name = "HLE.PlayReportEvent", Name = "HLE.PlayReportEvent",
@@ -17,7 +16,7 @@ namespace Ryujinx.Horizon
Priority = ThreadPriority.AboveNormal Priority = ThreadPriority.AboveNormal
}.Start(); }.Start();
public static event Action<PlayReport> PlayReport; public static event Action<MessagePackObject> PlayReport;
[field: ThreadStatic] [field: ThreadStatic]
public static HorizonOptions Options { get; private set; } public static HorizonOptions Options { get; private set; }

View File

@@ -1,3 +1,4 @@
using Gommon;
using MsgPack; using MsgPack;
using MsgPack.Serialization; using MsgPack.Serialization;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
@@ -11,12 +12,19 @@ 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;
@@ -192,13 +200,6 @@ namespace Ryujinx.Horizon.Prepo.Ipc
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}");
@@ -208,12 +209,10 @@ 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);
@@ -224,20 +223,17 @@ 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(playReport); HorizonStatic.HandlePlayReport(deserializedReport);
Logger.Info?.Print(LogClass.ServicePrepo, builder.ToString()); Logger.Info?.Print(LogClass.ServicePrepo, builder.ToString());

View File

@@ -1,24 +0,0 @@
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,
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,6 @@ 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.Linq;
using System.Text; using System.Text;
@@ -125,7 +124,7 @@ namespace Ryujinx.Ava
_currentApp = null; _currentApp = null;
} }
private static void HandlePlayReport(PlayReport playReport) private static void HandlePlayReport(MessagePackObject playReport)
{ {
if (_discordClient is null) return; if (_discordClient is null) return;
if (!TitleIDs.CurrentApplication.Value.HasValue) return; if (!TitleIDs.CurrentApplication.Value.HasValue) return;

View File

@@ -85,7 +85,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
/// <summary> /// <summary>
/// Runs the configured <see cref="FormatterSpec"/> for the specified game title ID. /// Runs the configured <see cref="GameSpec.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>
@@ -94,10 +94,10 @@ namespace Ryujinx.Ava.Utilities.PlayReport
public FormattedValue Format( public FormattedValue Format(
string runningGameId, string runningGameId,
ApplicationMetadata appMeta, ApplicationMetadata appMeta,
Horizon.Prepo.Types.PlayReport playReport MessagePackObject playReport
) )
{ {
if (!playReport.ReportData.IsDictionary) if (!playReport.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))
@@ -105,14 +105,10 @@ 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.ReportData.AsDictionary().TryGetValue(formatSpec.ReportKey, out MessagePackObject valuePackObject)) if (!playReport.AsDictionary().TryGetValue(formatSpec.ReportKey, out MessagePackObject valuePackObject))
continue; continue;
return formatSpec.Formatter(new SingleValue(valuePackObject) return formatSpec.Formatter(new Value { Application = appMeta, PackedValue = 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))
@@ -120,7 +116,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.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject)) if (!playReport.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
continue; continue;
packedObjects.Add(valuePackObject); packedObjects.Add(valuePackObject);
@@ -129,30 +125,23 @@ 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(new MultiValue(packedObjects) return formatSpec.Formatter(packedObjects
{ .Select(packObject => new Value { Application = appMeta, PackedValue = packObject })
Application = appMeta, .ToArray());
PlayReport = playReport
});
} }
foreach (SparseMultiFormatterSpec formatSpec in spec.SparseMultiValueFormatters.OrderBy(x => x.Priority)) foreach (SparseMultiFormatterSpec formatSpec in spec.SparseMultiValueFormatters.OrderBy(x => x.Priority))
{ {
Dictionary<string, MessagePackObject> packedObjects = []; Dictionary<string, Value> packedObjects = [];
foreach (var reportKey in formatSpec.ReportKeys) foreach (var reportKey in formatSpec.ReportKeys)
{ {
if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject)) if (!playReport.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
continue; continue;
packedObjects.Add(reportKey, valuePackObject); packedObjects.Add(reportKey, new Value { Application = appMeta, PackedValue = valuePackObject });
} }
return formatSpec.Formatter( return formatSpec.Formatter(packedObjects);
new SparseMultiValue(packedObjects)
{
Application = appMeta,
PlayReport = playReport
});
} }
return FormattedValue.Unhandled; return FormattedValue.Unhandled;

View File

@@ -1,4 +1,6 @@
namespace Ryujinx.Ava.Utilities.PlayReport using System.Collections.Generic;
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/>
@@ -10,7 +12,7 @@
/// <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(SingleValue value); public delegate FormattedValue ValueFormatter(Value value);
/// <summary> /// <summary>
/// The delegate type that powers multiple value formatters.<br/> /// The delegate type that powers multiple value formatters.<br/>
@@ -22,7 +24,7 @@
/// <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(MultiValue value); public delegate FormattedValue MultiValueFormatter(Value[] value);
/// <summary> /// <summary>
/// The delegate type that powers multiple value formatters. /// The delegate type that powers multiple value formatters.
@@ -36,5 +38,5 @@
/// <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(SparseMultiValue value); public delegate FormattedValue SparseMultiValueFormatter(Dictionary<string, Value> values);
} }

View File

@@ -1,87 +0,0 @@
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)
)
);
}
}

View File

@@ -39,28 +39,28 @@
.AddValueFormatter("team_circle", PokemonSVUnionCircle) .AddValueFormatter("team_circle", PokemonSVUnionCircle)
); );
private static FormattedValue BreathOfTheWild_MasterMode(SingleValue value) private static FormattedValue BreathOfTheWild_MasterMode(Value value)
=> value.Matched.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset; => value.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
private static FormattedValue TearsOfTheKingdom_CurrentField(SingleValue value) => private static FormattedValue TearsOfTheKingdom_CurrentField(Value value) =>
value.Matched.DoubleValue switch value.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(SingleValue value) private static FormattedValue SuperMarioOdyssey_AssistMode(Value value)
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode"; => value.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
private static FormattedValue SuperMarioOdysseyChina_AssistMode(SingleValue value) private static FormattedValue SuperMarioOdysseyChina_AssistMode(Value value)
=> value.Matched.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式"; => value.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式";
private static FormattedValue SuperMario3DWorldOrBowsersFury(SingleValue value) private static FormattedValue SuperMario3DWorldOrBowsersFury(Value value)
=> value.Matched.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury"; => value.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
private static FormattedValue MarioKart8Deluxe_Mode(SingleValue value) private static FormattedValue MarioKart8Deluxe_Mode(Value value)
=> value.Matched.StringValue switch => value.StringValue switch
{ {
// Single Player // Single Player
"Single" => "Single Player", "Single" => "Single Player",
@@ -87,11 +87,11 @@
_ => FormattedValue.ForceReset _ => FormattedValue.ForceReset
}; };
private static FormattedValue PokemonSVUnionCircle(SingleValue value) private static FormattedValue PokemonSVUnionCircle(Value value)
=> value.Matched.BoxedValue is 0 ? "Playing Alone" : "Playing in a group"; => value.BoxedValue is 0 ? "Playing Alone" : "Playing in a group";
private static FormattedValue PokemonSVArea(SingleValue value) private static FormattedValue PokemonSVArea(Value value)
=> value.Matched.StringValue switch => value.StringValue switch
{ {
// Base Game Locations // Base Game Locations
"a_w01" => "South Area One", "a_w01" => "South Area One",

View File

@@ -1,8 +1,6 @@
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
{ {
@@ -11,12 +9,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 readonly struct Value public class Value
{ {
public Value(MessagePackObject packedValue) /// <summary>
{ /// The currently running application's <see cref="ApplicationMetadata"/>.
PackedValue = packedValue; /// </summary>
} public ApplicationMetadata Application { get; init; }
/// <summary> /// <summary>
/// The matched value from the Play Report. /// The matched value from the Play Report.
@@ -39,17 +37,6 @@ 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();