Compare commits

...

4 Commits

3 changed files with 40 additions and 16 deletions

View File

@@ -117,9 +117,15 @@ namespace Ryujinx.Ava
_currentApp = appMeta;
}
private static void UpdatePlayingState()
private static bool UpdatePlayingState()
{
if (_discordClient is null) return false;
if (_discordClient.CurrentPresence.Details.Equals(_discordPresencePlaying.Details))
return false;
_discordClient?.SetPresence(_discordPresencePlaying);
return true;
}
private static void SwitchToMainState()
@@ -137,19 +143,12 @@ namespace Ryujinx.Ava
PlayReport.Analyzer.FormatPlayReportValue(TitleIDs.CurrentApplication.Value, _currentApp, playReport)
.Match(out bool handled,
() =>
{
_discordPresencePlaying.Details = $"Playing {_currentApp.Title}";
Logger.Info?.Print(LogClass.UI, "Reset Discord RPC based on a supported play report value formatter.");
},
formattedString =>
{
_discordPresencePlaying.Details = formattedString;
Logger.Info?.Print(LogClass.UI, "Updated Discord RPC based on a supported play report.");
});
() => _discordPresencePlaying.Details = $"Playing {_currentApp.Title}",
formattedString => _discordPresencePlaying.Details = formattedString
);
if (handled)
UpdatePlayingState();
if (handled && UpdatePlayingState())
Logger.Info?.Print(LogClass.UI, "Updated Discord RPC based on a supported play report.");
}
private static string TruncateToByteLength(string input)

View File

@@ -38,7 +38,7 @@ namespace Ryujinx.Ava.Utilities
=> 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",
@@ -55,7 +55,7 @@ namespace Ryujinx.Ava.Utilities
=> 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",

View File

@@ -176,6 +176,13 @@ namespace Ryujinx.Ava.Utilities
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="PlayReportValueFormatter"/>.
/// </summary>
public static readonly PlayReportValueFormatter AlwaysResets = _ => ForceReset;
/// <summary>
/// A delegate factory you can use to always return the specified
/// <paramref name="formattedValue"/> in a <see cref="PlayReportValueFormatter"/>.
/// </summary>
/// <param name="formattedValue">The string to always return for this delegate instance.</param>
public static PlayReportValueFormatter AlwaysReturns(string formattedValue) => _ => formattedValue;
}
}
@@ -258,6 +265,24 @@ namespace Ryujinx.Ava.Utilities
/// 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>