Compare commits
5 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566f3d079a | ||
|
|
d7707d4176 | ||
|
|
7a9b62884a | ||
|
|
de9faf183a | ||
|
|
0bf7c5dfa2 |
@@ -117,11 +117,6 @@ namespace Ryujinx.Ava
|
|||||||
_currentApp = appMeta;
|
_currentApp = appMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdatePlayingState()
|
|
||||||
{
|
|
||||||
_discordClient?.SetPresence(_discordPresencePlaying);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SwitchToMainState()
|
private static void SwitchToMainState()
|
||||||
{
|
{
|
||||||
_discordClient?.SetPresence(_discordPresenceMain);
|
_discordClient?.SetPresence(_discordPresenceMain);
|
||||||
@@ -135,21 +130,20 @@ namespace Ryujinx.Ava
|
|||||||
if (!TitleIDs.CurrentApplication.Value.HasValue) return;
|
if (!TitleIDs.CurrentApplication.Value.HasValue) return;
|
||||||
if (_discordPresencePlaying is null) return;
|
if (_discordPresencePlaying is null) return;
|
||||||
|
|
||||||
PlayReport.Analyzer.FormatPlayReportValue(TitleIDs.CurrentApplication.Value, _currentApp, playReport)
|
PlayReportAnalyzer.FormattedValue formattedValue =
|
||||||
.Match(out bool handled,
|
PlayReport.Analyzer.Format(TitleIDs.CurrentApplication.Value, _currentApp, playReport);
|
||||||
() =>
|
|
||||||
{
|
|
||||||
_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.");
|
|
||||||
});
|
|
||||||
|
|
||||||
if (handled)
|
if (!formattedValue.Handled) return;
|
||||||
UpdatePlayingState();
|
|
||||||
|
_discordPresencePlaying.Details = formattedValue.Reset
|
||||||
|
? $"Playing {_currentApp.Title}"
|
||||||
|
: formattedValue.FormattedString;
|
||||||
|
|
||||||
|
if (_discordClient.CurrentPresence.Details.Equals(_discordPresencePlaying.Details))
|
||||||
|
return; //don't trigger an update if the set presence Details are identical to current
|
||||||
|
|
||||||
|
_discordClient.SetPresence(_discordPresencePlaying);
|
||||||
|
Logger.Info?.Print(LogClass.UI, "Updated Discord RPC based on a supported play report.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string TruncateToByteLength(string input)
|
private static string TruncateToByteLength(string input)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
=> value.BoxedValue is 1 ? "Playing Master Mode" : PlayReportFormattedValue.ForceReset;
|
=> value.BoxedValue is 1 ? "Playing Master Mode" : PlayReportFormattedValue.ForceReset;
|
||||||
|
|
||||||
private static PlayReportFormattedValue TearsOfTheKingdom_CurrentField(PlayReportValue value) =>
|
private static PlayReportFormattedValue TearsOfTheKingdom_CurrentField(PlayReportValue value) =>
|
||||||
value.PackedValue.AsDouble() switch
|
value.DoubleValue switch
|
||||||
{
|
{
|
||||||
> 800d => "Exploring the Sky Islands",
|
> 800d => "Exploring the Sky Islands",
|
||||||
< -201d => "Exploring the Depths",
|
< -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";
|
=> value.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
|
||||||
|
|
||||||
private static PlayReportFormattedValue MarioKart8Deluxe_Mode(PlayReportValue value)
|
private static PlayReportFormattedValue MarioKart8Deluxe_Mode(PlayReportValue value)
|
||||||
=> value.BoxedValue switch
|
=> value.StringValue switch
|
||||||
{
|
{
|
||||||
// Single Player
|
// Single Player
|
||||||
"Single" => "Single Player",
|
"Single" => "Single Player",
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
/// <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>
|
||||||
/// <param name="playReport">The Play Report received from HLE.</param>
|
/// <param name="playReport">The Play Report received from HLE.</param>
|
||||||
/// <returns>A struct representing a possible formatted value.</returns>
|
/// <returns>A struct representing a possible formatted value.</returns>
|
||||||
public FormattedValue FormatPlayReportValue(
|
public FormattedValue Format(
|
||||||
string runningGameId,
|
string runningGameId,
|
||||||
ApplicationMetadata appMeta,
|
ApplicationMetadata appMeta,
|
||||||
MessagePackObject playReport
|
MessagePackObject playReport
|
||||||
@@ -132,23 +132,6 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string FormattedString { get; private init; }
|
public string FormattedString { get; private init; }
|
||||||
|
|
||||||
public void Match(out bool wasHandled, Action onReset, Action<string> onSuccess)
|
|
||||||
{
|
|
||||||
if (!Handled)
|
|
||||||
{
|
|
||||||
wasHandled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Reset)
|
|
||||||
onReset();
|
|
||||||
else
|
|
||||||
onSuccess(FormattedString);
|
|
||||||
|
|
||||||
wasHandled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The intended path of execution for having a string to return: simply return the string.
|
/// The intended path of execution for having a string to return: simply return the string.
|
||||||
/// This implicit conversion will make the struct for you.<br/><br/>
|
/// This implicit conversion will make the struct for you.<br/><br/>
|
||||||
@@ -176,6 +159,13 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="PlayReportValueFormatter"/>.
|
/// A delegate singleton you can use to always return <see cref="ForceReset"/> in a <see cref="PlayReportValueFormatter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly PlayReportValueFormatter AlwaysResets = _ => ForceReset;
|
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 +248,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.
|
/// so use <see cref="PackedValue"/> and the AsX (where X is a numerical type name i.e. Int32) methods for that.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object BoxedValue => PackedValue.ToObject();
|
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>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user