From c32082961aebfd1fe21787d6660ba2ad4c964822 Mon Sep 17 00:00:00 2001 From: Starlet Date: Fri, 13 Jul 2018 10:30:34 -0400 Subject: [PATCH] Make Discord RPC configurable --- Ryujinx/Config.cs | 4 +++ Ryujinx/Ryujinx.conf | 3 +++ Ryujinx/Ui/Program.cs | 60 ++++++++++++++++++++++++------------------- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index 940753ba53..17ac9052ec 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -19,6 +19,8 @@ namespace Ryujinx public static int GamePadIndex { get; private set; } public static float GamePadTriggerThreshold { get; private set; } + public static bool DiscordRPCEnable { get; private set; } + public static void Read(Logger Log) { string IniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -40,6 +42,8 @@ namespace Ryujinx GamePadDeadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"), CultureInfo.InvariantCulture); GamePadTriggerThreshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"), CultureInfo.InvariantCulture); + DiscordRPCEnable = Convert.ToBoolean(Parser.Value("DiscordRPC_Enable")); + string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); //When the classes are specified on the list, we only diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf index 59f7f859e7..b82527031a 100644 --- a/Ryujinx/Ryujinx.conf +++ b/Ryujinx/Ryujinx.conf @@ -31,6 +31,9 @@ GamePad_Trigger_Threshold = 0.5 #Whether or not to enable Controller support GamePad_Enable = true +#Whether or not to enable Discord Rich Presence (requires discord-rpc.dll 64-bit in same path as Ryujinx) +DiscordRPC_Enable = false + #https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs Controls_Left_JoyConKeyboard_Stick_Up = 105 Controls_Left_JoyConKeyboard_Stick_Down = 101 diff --git a/Ryujinx/Ui/Program.cs b/Ryujinx/Ui/Program.cs index dd5b53beff..9b8d2dfc07 100644 --- a/Ryujinx/Ui/Program.cs +++ b/Ryujinx/Ui/Program.cs @@ -19,14 +19,6 @@ namespace Ryujinx { Console.Title = "Ryujinx Console"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Handlers = new DiscordRpc.EventHandlers(); - Presence = new DiscordRpc.RichPresence(); - - DiscordRpc.Initialize("467315377412767744", ref Handlers, true, null); - } - IGalRenderer Renderer = new OGLRenderer(); IAalOutput AudioOut = new OpenALAudioOut(); @@ -35,6 +27,17 @@ namespace Ryujinx Config.Read(Ns.Log); + if (Config.DiscordRPCEnable) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Handlers = new DiscordRpc.EventHandlers(); + Presence = new DiscordRpc.RichPresence(); + + DiscordRpc.Initialize("467315377412767744", ref Handlers, true, null); + } + } + Ns.Log.Updated += ConsoleLog.PrintLog; if (args.Length == 1) @@ -61,30 +64,33 @@ namespace Ryujinx Ns.LoadCart(args[0]); } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (Config.DiscordRPCEnable) { - if (Ns.Os.SystemState.GetNpdmTitleName() != "Application") + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - Presence.details = $"{Ns.Os.SystemState.GetNpdmTitleName()} ({Ns.Os.SystemState.GetNpdmTitleId()})"; - } - else - { - Presence.details = Ns.Os.SystemState.GetNpdmTitleId(); - } + if (Ns.Os.SystemState.GetNpdmTitleName() != "Application") + { + Presence.details = $"{Ns.Os.SystemState.GetNpdmTitleName()} ({Ns.Os.SystemState.GetNpdmTitleId()})"; + } + else + { + Presence.details = Ns.Os.SystemState.GetNpdmTitleId(); + } - if (Ns.Os.SystemState.GetNpdmIs64Bit()) - { - Presence.state = "Playing a 64-bit game!"; - } - else - { - Presence.state = "Playing a 32-bit game!"; - } + if (Ns.Os.SystemState.GetNpdmIs64Bit()) + { + Presence.state = "Playing a 64-bit game!"; + } + else + { + Presence.state = "Playing a 32-bit game!"; + } - Presence.largeImageKey = "icon"; - Presence.largeImageText = "Ryujinx"; + Presence.largeImageKey = "icon"; + Presence.largeImageText = "Ryujinx"; - DiscordRpc.UpdatePresence(Presence); + DiscordRpc.UpdatePresence(Presence); + } } } else if (File.Exists(args[0]))