Compare commits
3 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11bc32d98e | ||
|
|
063430ea16 | ||
|
|
65f08caaa3 |
@@ -135,21 +135,21 @@ namespace Ryujinx.Ava
|
||||
if (!TitleIDs.CurrentApplication.Value.HasValue) return;
|
||||
if (_discordPresencePlaying is null) return;
|
||||
|
||||
PlayReportAnalyzer.FormattedValue value = PlayReport.Analyzer.FormatPlayReportValue(TitleIDs.CurrentApplication.Value, _currentApp, playReport);
|
||||
|
||||
if (!value.Handled) return;
|
||||
|
||||
if (value.Reset)
|
||||
{
|
||||
_discordPresencePlaying.Details = $"Playing {_currentApp.Title}";
|
||||
Logger.Info?.Print(LogClass.UI, "Reset Discord RPC based on a supported play report value formatter.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_discordPresencePlaying.Details = value.FormattedString;
|
||||
Logger.Info?.Print(LogClass.UI, "Updated Discord RPC based on a supported play report.");
|
||||
}
|
||||
UpdatePlayingState();
|
||||
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.");
|
||||
});
|
||||
|
||||
if (handled)
|
||||
UpdatePlayingState();
|
||||
}
|
||||
|
||||
private static string TruncateToByteLength(string input)
|
||||
|
||||
@@ -7,7 +7,10 @@ namespace Ryujinx.Ava.Utilities
|
||||
public static PlayReportAnalyzer Analyzer { get; } = new PlayReportAnalyzer()
|
||||
.AddSpec(
|
||||
"01007ef00011e000",
|
||||
spec => spec.AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode)
|
||||
spec => spec
|
||||
.AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode)
|
||||
// reset to normal status when switching between normal & master mode in title screen
|
||||
.AddValueFormatter("AoCVer", PlayReportFormattedValue.AlwaysResets)
|
||||
)
|
||||
.AddSpec(
|
||||
"0100f2c0115b6000",
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Ryujinx.Ava.Utilities
|
||||
/// <summary>
|
||||
/// A potential formatted value returned by a <see cref="PlayReportValueFormatter"/>.
|
||||
/// </summary>
|
||||
public struct FormattedValue
|
||||
public readonly struct FormattedValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Was any handler able to match anything in the Play Report?
|
||||
@@ -132,6 +132,23 @@ namespace Ryujinx.Ava.Utilities
|
||||
/// </summary>
|
||||
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>
|
||||
/// 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/>
|
||||
|
||||
Reference in New Issue
Block a user