aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Guillemard <me@thog.eu>2019-08-19 22:28:01 +0200
committerGitHub <noreply@github.com>2019-08-19 22:28:01 +0200
commit16aa2cfd621d6b9a6e4fcdc9323afc18891ea7d5 (patch)
tree4b453157bc91b90cc4a38181cfff83791be91dd4
parenta731ab3a2aad56e6ceb8b4e2444a61353246295c (diff)
Discord Presence: Fix a crash when no valid program is loaded (#741)
* Discord Presence: Fix a crash when no valid program is loaded
-rw-r--r--Ryujinx/Program.cs26
1 files changed, 22 insertions, 4 deletions
diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs
index ac668290..d0518441 100644
--- a/Ryujinx/Program.cs
+++ b/Ryujinx/Program.cs
@@ -37,7 +37,7 @@ namespace Ryujinx
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
- if (device.System.State.DiscordIntegrationEnabled == true)
+ if (device.System.State.DiscordIntegrationEnabled)
{
DiscordClient = new DiscordRpcClient("568815339807309834");
DiscordPresence = new RichPresence
@@ -108,15 +108,33 @@ namespace Ryujinx
Logger.PrintWarning(LogClass.Application, "Please specify the folder with the NSOs/IStorage or a NSO/NRO.");
}
- if (device.System.State.DiscordIntegrationEnabled == true)
+ if (device.System.State.DiscordIntegrationEnabled)
{
if (File.ReadAllLines(Path.Combine(ApplicationDirectory, "RPsupported.dat")).Contains(device.System.TitleID))
{
DiscordPresence.Assets.LargeImageKey = device.System.TitleID;
}
- DiscordPresence.Details = $"Playing {device.System.TitleName}";
- DiscordPresence.State = device.System.TitleID.ToUpper();
+ string state = device.System.TitleID;
+
+ if (state == null)
+ {
+ state = "Ryujinx";
+ }
+ else
+ {
+ state = state.ToUpper();
+ }
+
+ string details = "Idling";
+
+ if (device.System.TitleName != null)
+ {
+ details = $"Playing {device.System.TitleName}";
+ }
+
+ DiscordPresence.Details = details;
+ DiscordPresence.State = state;
DiscordPresence.Assets.LargeImageText = device.System.TitleName;
DiscordPresence.Assets.SmallImageKey = "ryujinx";
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";