Skip to content

Commit

Permalink
misc: chore: type-specific value accessors on PlayReportValue
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Feb 4, 2025
1 parent de9faf1 commit 7a9b628
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Ryujinx/Utilities/PlayReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static PlayReportFormattedValue BreathOfTheWild_MasterMode(PlayReportVal
=> value.BoxedValue is 1 ? "Playing Master Mode" : PlayReportFormattedValue.ForceReset;

private static PlayReportFormattedValue TearsOfTheKingdom_CurrentField(PlayReportValue value) =>
value.PackedValue.AsDouble() switch
value.DoubleValue switch
{
> 800d => "Exploring the Sky Islands",
< -201d => "Exploring the Depths",
Expand All @@ -55,7 +55,7 @@ private static PlayReportFormattedValue SuperMario3DWorldOrBowsersFury(PlayRepor
=> value.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";

private static PlayReportFormattedValue MarioKart8Deluxe_Mode(PlayReportValue value)
=> value.BoxedValue switch
=> value.StringValue switch
{
// Single Player
"Single" => "Single Player",
Expand Down
18 changes: 18 additions & 0 deletions src/Ryujinx/Utilities/PlayReportAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,24 @@ public class PlayReportValue
/// so use <see cref="PackedValue"/> and the AsX (where X is a numerical type name i.e. Int32) methods for that.
/// </summary>
public object BoxedValue => PackedValue.ToObject();

#region AsX accessors

public bool BooleanValue => PackedValue.AsBoolean();
public byte ByteValye => PackedValue.AsByte();
public sbyte SByteValye => PackedValue.AsSByte();
public short ShortValye => PackedValue.AsInt16();
public ushort UShortValye => PackedValue.AsUInt16();
public int IntValye => PackedValue.AsInt32();
public uint UIntValye => PackedValue.AsUInt32();
public long LongValye => PackedValue.AsInt64();
public ulong ULongValye => PackedValue.AsUInt64();
public float FloatValue => PackedValue.AsSingle();
public double DoubleValue => PackedValue.AsDouble();
public string StringValue => PackedValue.AsString();
public Span<byte> BinaryValue => PackedValue.AsBinary();

#endregion
}

/// <summary>
Expand Down

0 comments on commit 7a9b628

Please sign in to comment.