mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-14 19:36:59 +00:00
misc: chore: Play Report analyzer code simplification
This commit is contained in:
parent
d7707d4176
commit
566f3d079a
2 changed files with 14 additions and 36 deletions
|
|
@ -117,17 +117,6 @@ namespace Ryujinx.Ava
|
|||
_currentApp = appMeta;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
_discordClient?.SetPresence(_discordPresenceMain);
|
||||
|
|
@ -141,14 +130,20 @@ namespace Ryujinx.Ava
|
|||
if (!TitleIDs.CurrentApplication.Value.HasValue) return;
|
||||
if (_discordPresencePlaying is null) return;
|
||||
|
||||
PlayReport.Analyzer.FormatPlayReportValue(TitleIDs.CurrentApplication.Value, _currentApp, playReport)
|
||||
.Match(out bool handled,
|
||||
() => _discordPresencePlaying.Details = $"Playing {_currentApp.Title}",
|
||||
formattedString => _discordPresencePlaying.Details = formattedString
|
||||
);
|
||||
PlayReportAnalyzer.FormattedValue formattedValue =
|
||||
PlayReport.Analyzer.Format(TitleIDs.CurrentApplication.Value, _currentApp, playReport);
|
||||
|
||||
if (handled && UpdatePlayingState())
|
||||
Logger.Info?.Print(LogClass.UI, "Updated Discord RPC based on a supported play report.");
|
||||
if (!formattedValue.Handled) return;
|
||||
|
||||
_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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue