diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index 91f5162acb..6979cee414 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -231,8 +231,7 @@ namespace Ryujinx.HLE.HOS } } - CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); - TitleID = metaData.Aci0.TitleId.ToString("x16"); + TitleID = CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); LoadNso("rtld"); LoadNso("main"); @@ -430,8 +429,7 @@ namespace Ryujinx.HLE.HOS } } - CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); - TitleID = metaData.Aci0.TitleId.ToString("x16"); + TitleID = CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); LoadNso("rtld"); LoadNso("main"); @@ -522,14 +520,12 @@ namespace Ryujinx.HLE.HOS Nacp controlData = new Nacp(controlFile.AsStream()); - CurrentTitle = controlData.Descriptions[(int)State.DesiredTitleLanguage].Title; - TitleName = controlData.Descriptions[(int)State.DesiredTitleLanguage].Title; - TitleID = metaData.Aci0.TitleId.ToString("x16"); + TitleName = CurrentTitle = controlData.Descriptions[(int)State.DesiredTitleLanguage].Title; + TitleID = metaData.Aci0.TitleId.ToString("x16"); if (string.IsNullOrWhiteSpace(CurrentTitle)) { - CurrentTitle = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title; - TitleName = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title; + TitleName = CurrentTitle = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title; } return controlData; @@ -541,8 +537,7 @@ namespace Ryujinx.HLE.HOS } else { - CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); - TitleID = metaData.Aci0.TitleId.ToString("x16"); + TitleID = CurrentTitle = metaData.Aci0.TitleId.ToString("x16"); } LoadNso("rtld"); diff --git a/Ryujinx/DiscordRpc.cs b/Ryujinx/DiscordRpc.cs index a0aa9a84a8..9be4f80ecd 100644 --- a/Ryujinx/DiscordRpc.cs +++ b/Ryujinx/DiscordRpc.cs @@ -1,4 +1,25 @@ -using System; +/* +Copyright 2017 Discord, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index fb71ff5e36..cfa2511faa 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -21,6 +21,19 @@ namespace Ryujinx { Console.Title = "Ryujinx Console"; + if (File.Exists("./discord-rpc.dll") || File.Exists("./discord-rpc.so")) + { + Handlers = new DiscordRpc.EventHandlers(); + Presence = new DiscordRpc.RichPresence(); + DiscordRpc.Initialize("568815339807309834", ref Handlers, true, null); + Presence.details = "Ryujinx Console"; + Presence.state = "Reading the console logs..."; + Presence.startTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); + Presence.largeImageKey = "ryujinx"; + Presence.largeImageText = "Ryujinx"; + DiscordRpc.UpdatePresence(Presence); + } + IGalRenderer renderer = new OglRenderer(); IAalOutput audioOut = InitializeAudioEngine(); @@ -33,36 +46,6 @@ namespace Ryujinx AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; - void SetPresence(string FileType) - { - if (File.Exists("./discord-rpc.dll")||File.Exists("./discord-rpc.so")) - { - string[] RPsupported = File.ReadAllLines("./RPsupported"); - if (RPsupported.Contains(device.System.TitleID)) - { - Presence.largeImageKey = device.System.TitleID; - } - else - { - Presence.largeImageKey = "ryujinx"; - } - Presence.details = $"Playing {device.System.TitleName}"; - Presence.state = device.System.TitleID.ToUpper(); - Presence.largeImageText = device.System.TitleName; - Presence.startTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); - Presence.smallImageKey = FileType; - Presence.smallImageText = FileType.ToUpper().Replace("-", " "); - DiscordRpc.UpdatePresence(Presence); - } - } - - if (File.Exists("./discord-rpc.dll") || File.Exists("./discord-rpc.so")) - { - Handlers = new DiscordRpc.EventHandlers(); - Presence = new DiscordRpc.RichPresence(); - DiscordRpc.Initialize("568815339807309834", ref Handlers, true, null); - } - if (args.Length == 1) { if (Directory.Exists(args[0])) @@ -78,13 +61,13 @@ namespace Ryujinx { Logger.PrintInfo(LogClass.Application, "Loading as cart with RomFS."); device.LoadCart(args[0], romFsFiles[0]); - SetPresence("cart-with-romfs"); + SetGamePresence(device); } else { Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS."); device.LoadCart(args[0]); - SetPresence("cart-without-romfs"); + SetGamePresence(device); } } else if (File.Exists(args[0])) @@ -94,23 +77,23 @@ namespace Ryujinx case ".xci": Logger.PrintInfo(LogClass.Application, "Loading as XCI."); device.LoadXci(args[0]); - SetPresence("xci"); + SetGamePresence(device); break; case ".nca": Logger.PrintInfo(LogClass.Application, "Loading as NCA."); device.LoadNca(args[0]); - SetPresence("nca"); + SetGamePresence(device); break; case ".nsp": case ".pfs0": Logger.PrintInfo(LogClass.Application, "Loading as NSP."); device.LoadNsp(args[0]); - SetPresence("nsp"); + SetGamePresence(device); break; default: Logger.PrintInfo(LogClass.Application, "Loading as homebrew."); device.LoadProgram(args[0]); - SetPresence("nro-nso"); + SetGamePresence(device); break; } } @@ -153,6 +136,25 @@ namespace Ryujinx } } + private static void SetGamePresence(Switch device) + { + if (File.Exists("./discord-rpc.dll") || File.Exists("./discord-rpc.so")) + { + string[] RPsupported = File.ReadAllLines("./RPsupported"); + if (RPsupported.Contains(device.System.TitleID)) + { + Presence.largeImageKey = device.System.TitleID; + Presence.largeImageText = device.System.TitleName; + } + Presence.details = $"Playing {device.System.TitleName}"; + Presence.state = device.System.TitleID.ToUpper(); + Presence.smallImageKey = "ryujinx"; + Presence.smallImageText = "Ryujinx"; + Presence.startTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); + DiscordRpc.UpdatePresence(Presence); + } + } + /// /// Picks an audio output renderer supported on this machine /// diff --git a/Ryujinx/RPsupported b/Ryujinx/RPsupported index ca2aa84546..ad2d715df0 100644 --- a/Ryujinx/RPsupported +++ b/Ryujinx/RPsupported @@ -1,3 +1,38 @@ +01000d200ac0c000 +01000d700be88000 +01000dc007e90000 +01000e2003fa0000 +01002fc00c6d0000 +0100225000fee000 +010028d0045ce000 +01002b30028f6000 +010034e005c9c000 +01004f8006a78000 +010051f00ac5e000 +0100574009f9e000 +0100628004bce000 +0100633007d48000 +010065500b218000 +010068f00aa78000 01006a800016e000 +01007330027ee000 +0100749009844000 +01007a4008486000 +010080b00ad66000 +010094e00b52e000 01009aa000faa000 -0100a5c00d162000 \ No newline at end of file +0100a4200a284000 +0100a5c00d162000 +0100ae000aebc000 +0100b3f000be2000 +0100bc2004ff4000 +0100cf3007578000 +0100d5d00c6be000 +0100d6b00cd88000 +0100d870045b6000 +0100e0c00adac000 +0100e7200b272000 +0100e9f00b882000 +0100eab00605c000 +0100efd00a4fa000 +0100f6a00a684000 \ No newline at end of file