mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2026-02-17 04:36:50 -05: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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user