mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-15 10:36:58 +00:00
misc: Refactor Discord integration to listen on TitleIDs.CurrentApplication changes instead of waiting to be directly told when to change states.
This commit is contained in:
parent
1dd69912b1
commit
f463ea1c5d
6 changed files with 45 additions and 9 deletions
|
|
@ -2,6 +2,7 @@ using DiscordRPC;
|
|||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using Ryujinx.UI.App.Common;
|
||||
using Ryujinx.UI.Common.Configuration;
|
||||
|
|
@ -44,6 +45,16 @@ namespace Ryujinx.UI.Common
|
|||
};
|
||||
|
||||
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
|
||||
TitleIDs.CurrentApplicationChanged += titleId =>
|
||||
{
|
||||
if (titleId)
|
||||
SwitchToPlayingState(
|
||||
ApplicationLibrary.LoadAndSaveMetaData(titleId),
|
||||
Switch.Shared.Processes.ActiveApplication
|
||||
);
|
||||
else
|
||||
SwitchToMainState();
|
||||
};
|
||||
}
|
||||
|
||||
private static void Update(object sender, ReactiveEventArgs<bool> evnt)
|
||||
|
|
@ -69,7 +80,7 @@ namespace Ryujinx.UI.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes)
|
||||
private static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes)
|
||||
{
|
||||
_discordClient?.SetPresence(new RichPresence
|
||||
{
|
||||
|
|
@ -88,7 +99,7 @@ namespace Ryujinx.UI.Common
|
|||
});
|
||||
}
|
||||
|
||||
public static void SwitchToMainState() => _discordClient?.SetPresence(_discordPresenceMain);
|
||||
private static void SwitchToMainState() => _discordClient?.SetPresence(_discordPresenceMain);
|
||||
|
||||
private static string TruncateToByteLength(string input)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue