forked from Mirror/Ryujinx
Discord Presence: Fix a crash when no valid program is loaded (#741)
* Discord Presence: Fix a crash when no valid program is loaded
This commit is contained in:
parent
a731ab3a2a
commit
16aa2cfd62
1 changed files with 22 additions and 4 deletions
|
@ -37,7 +37,7 @@ namespace Ryujinx
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
|
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
|
||||||
|
|
||||||
if (device.System.State.DiscordIntegrationEnabled == true)
|
if (device.System.State.DiscordIntegrationEnabled)
|
||||||
{
|
{
|
||||||
DiscordClient = new DiscordRpcClient("568815339807309834");
|
DiscordClient = new DiscordRpcClient("568815339807309834");
|
||||||
DiscordPresence = new RichPresence
|
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.");
|
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))
|
if (File.ReadAllLines(Path.Combine(ApplicationDirectory, "RPsupported.dat")).Contains(device.System.TitleID))
|
||||||
{
|
{
|
||||||
DiscordPresence.Assets.LargeImageKey = device.System.TitleID;
|
DiscordPresence.Assets.LargeImageKey = device.System.TitleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscordPresence.Details = $"Playing {device.System.TitleName}";
|
string state = device.System.TitleID;
|
||||||
DiscordPresence.State = device.System.TitleID.ToUpper();
|
|
||||||
|
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.LargeImageText = device.System.TitleName;
|
||||||
DiscordPresence.Assets.SmallImageKey = "ryujinx";
|
DiscordPresence.Assets.SmallImageKey = "ryujinx";
|
||||||
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
|
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
|
||||||
|
|
Loading…
Reference in a new issue