Compare commits

..

1 Commits

Author SHA1 Message Date
Frog Business e7ca6e8d76 Merge 6d78e71fc7 into 744d813b87 2025-02-15 01:53:36 -06:00
4 changed files with 74 additions and 116 deletions
-1
View File
@@ -56,7 +56,6 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update; ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
TitleIDs.CurrentApplication.Event += (_, e) => Use(e.NewValue); TitleIDs.CurrentApplication.Event += (_, e) => Use(e.NewValue);
HorizonStatic.PlayReport += HandlePlayReport; HorizonStatic.PlayReport += HandlePlayReport;
PlayReports.Initialize();
} }
private static void Update(object sender, ReactiveEventArgs<bool> evnt) private static void Update(object sender, ReactiveEventArgs<bool> evnt)
+13 -36
View File
@@ -1,6 +1,5 @@
using Gommon; using Gommon;
using Ryujinx.Ava.Utilities.AppLibrary; using Ryujinx.Ava.Utilities.AppLibrary;
using Ryujinx.Common.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -28,12 +27,10 @@ namespace Ryujinx.Ava.Utilities.PlayReport
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns> /// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
public Analyzer AddSpec(string titleId, Func<GameSpec, GameSpec> transform) public Analyzer AddSpec(string titleId, Func<GameSpec, GameSpec> transform)
{ {
if (ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _)) Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
return AddSpec(transform(GameSpec.Create(titleId))); $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
Logger.Notice.PrintMsg(LogClass.Application, return AddSpec(transform(GameSpec.Create(titleId)));
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{titleId}'");
return this;
} }
/// <summary> /// <summary>
@@ -44,12 +41,10 @@ namespace Ryujinx.Ava.Utilities.PlayReport
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns> /// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
public Analyzer AddSpec(string titleId, Action<GameSpec> transform) public Analyzer AddSpec(string titleId, Action<GameSpec> transform)
{ {
if (ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _)) Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
return AddSpec(GameSpec.Create(titleId).Apply(transform)); $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
Logger.Notice.PrintMsg(LogClass.Application, return AddSpec(GameSpec.Create(titleId).Apply(transform));
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{titleId}'");
return this;
} }
/// <summary> /// <summary>
@@ -62,19 +57,10 @@ namespace Ryujinx.Ava.Utilities.PlayReport
Func<GameSpec, GameSpec> transform) Func<GameSpec, GameSpec> transform)
{ {
string[] tids = titleIds.ToArray(); string[] tids = titleIds.ToArray();
if (tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _) && !string.IsNullOrEmpty(x))) Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
return AddSpec(transform(GameSpec.Create(tids))); $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
Logger.Notice.PrintMsg(LogClass.Application, return AddSpec(transform(GameSpec.Create(tids)));
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{
tids.FormatCollection(
x => x,
separator: ", ",
prefix: "[",
suffix: "]"
)
}'");
return this;
} }
/// <summary> /// <summary>
@@ -86,21 +72,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
public Analyzer AddSpec(IEnumerable<string> titleIds, Action<GameSpec> transform) public Analyzer AddSpec(IEnumerable<string> titleIds, Action<GameSpec> transform)
{ {
string[] tids = titleIds.ToArray(); string[] tids = titleIds.ToArray();
if (tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _) && !string.IsNullOrEmpty(x))) Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
return AddSpec(GameSpec.Create(tids).Apply(transform)); $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
Logger.Notice.PrintMsg(LogClass.Application, return AddSpec(GameSpec.Create(tids).Apply(transform));
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{
tids.FormatCollection(
x => x,
separator: ", ",
prefix: "[",
suffix: "]"
)
}'");
return this;
} }
/// <summary> /// <summary>
/// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec. /// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec.
/// </summary> /// </summary>
@@ -1,5 +1,4 @@
using Gommon; using Gommon;
using Humanizer;
using System; using System;
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Collections.Generic; using System.Collections.Generic;
@@ -19,9 +18,6 @@ namespace Ryujinx.Ava.Utilities.PlayReport
< -201d => "Exploring the Depths", < -201d => "Exploring the Depths",
_ => "Roaming Hyrule" _ => "Roaming Hyrule"
}; };
private static FormattedValue SkywardSwordHD_Rupees(SingleValue value)
=> "rupee".ToQuantity(value.Matched.IntValue);
private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value) private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode"; => value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
+61 -75
View File
@@ -1,81 +1,67 @@
using System; namespace Ryujinx.Ava.Utilities.PlayReport
namespace Ryujinx.Ava.Utilities.PlayReport
{ {
public static partial class PlayReports public static partial class PlayReports
{ {
public static void Initialize() public static Analyzer Analyzer { get; } = new Analyzer()
{ .AddSpec(
// init lazy value "01007ef00011e000",
_ = Analyzer; spec => spec
} .AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode)
// reset to normal status when switching between normal & master mode in title screen
public static Analyzer Analyzer => _analyzerLazy.Value; .AddValueFormatter("AoCVer", FormattedValue.SingleAlwaysResets)
)
private static readonly Lazy<Analyzer> _analyzerLazy = new(() => .AddSpec(
new Analyzer() "0100f2c0115b6000",
.AddSpec( spec => spec
"01007ef00011e000", .AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField))
spec => spec .AddSpec(
.AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode) "0100000000010000",
// reset to normal status when switching between normal & master mode in title screen spec =>
.AddValueFormatter("AoCVer", FormattedValue.SingleAlwaysResets) spec.AddValueFormatter("is_kids_mode", SuperMarioOdyssey_AssistMode)
) )
.AddSpec( .AddSpec(
"0100f2c0115b6000", "010075000ecbe000",
spec => spec spec =>
.AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField)) spec.AddValueFormatter("is_kids_mode", SuperMarioOdysseyChina_AssistMode)
.AddSpec( )
"0100000000010000", .AddSpec(
spec => "010028600ebda000",
spec.AddValueFormatter("is_kids_mode", SuperMarioOdyssey_AssistMode) spec => spec.AddValueFormatter("mode", SuperMario3DWorldOrBowsersFury)
) )
.AddSpec( .AddSpec( // Global & China IDs
"010075000ecbe000", ["0100152000022000", "010075100e8ec000"],
spec => spec => spec.AddValueFormatter("To", MarioKart8Deluxe_Mode)
spec.AddValueFormatter("is_kids_mode", SuperMarioOdysseyChina_AssistMode) )
) .AddSpec(
.AddSpec( ["0100a3d008c5c000", "01008f6008c5e000"],
"010028600ebda000", spec => spec
spec => spec.AddValueFormatter("mode", SuperMario3DWorldOrBowsersFury) .AddValueFormatter("area_no", PokemonSVArea)
) .AddValueFormatter("team_circle", PokemonSVUnionCircle)
.AddSpec( // Global & China IDs )
["0100152000022000", "010075100e8ec000"], .AddSpec(
spec => spec.AddValueFormatter("To", MarioKart8Deluxe_Mode) "01006a800016e000",
) spec => spec
.AddSpec( .AddSparseMultiValueFormatter(
["0100a3d008c5c000", "01008f6008c5e000"], [
spec => spec // Metadata to figure out what PlayReport we have.
.AddValueFormatter("area_no", PokemonSVArea) "match_mode", "match_submode", "anniversary", "fighter", "reason", "challenge_count",
.AddValueFormatter("team_circle", PokemonSVUnionCircle) "adv_slot",
) // List of Fighters
.AddSpec( "player_1_fighter", "player_2_fighter", "player_3_fighter", "player_4_fighter",
"01006a800016e000", "player_5_fighter", "player_6_fighter", "player_7_fighter", "player_8_fighter",
spec => spec // List of rankings/placements
.AddSparseMultiValueFormatter( "player_1_rank", "player_2_rank", "player_3_rank", "player_4_rank", "player_5_rank",
[ "player_6_rank", "player_7_rank", "player_8_rank"
// Metadata to figure out what PlayReport we have. ],
"match_mode", "match_submode", "anniversary", "fighter", "reason", "challenge_count", SuperSmashBrosUltimate_Mode
"adv_slot", )
// List of Fighters )
"player_1_fighter", "player_2_fighter", "player_3_fighter", "player_4_fighter", .AddSpec(
"player_5_fighter", "player_6_fighter", "player_7_fighter", "player_8_fighter", [
// List of rankings/placements "0100c9a00ece6000", "01008d300c50c000", "0100d870045b6000",
"player_1_rank", "player_2_rank", "player_3_rank", "player_4_rank", "player_5_rank", "010012f017576000", "0100c62011050000", "0100b3c014bda000"],
"player_6_rank", "player_7_rank", "player_8_rank" spec => spec.AddValueFormatter("launch_title_id", NsoEmulator_LaunchedGame)
], );
SuperSmashBrosUltimate_Mode
)
)
.AddSpec(
[
"0100c9a00ece6000", "01008d300c50c000", "0100d870045b6000",
"010012f017576000", "0100c62011050000", "0100b3c014bda000"
],
spec => spec.AddValueFormatter("launch_title_id", NsoEmulator_LaunchedGame)
)
.AddSpec("01002da013484000", spec => spec.AddValueFormatter("rupees", SkywardSwordHD_Rupees))
);
private static string Playing(string game) => $"Playing {game}"; private static string Playing(string game) => $"Playing {game}";
} }