From 4d311dfc1a57156e1a3ee83f944df78fa2265022 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Fri, 11 Oct 2024 23:55:50 -0500 Subject: [PATCH] UI: RPC: show game version when hovering large image asset. --- .../DiscordIntegrationModule.cs | 18 +++++++++++------- src/Ryujinx/AppHost.cs | 9 ++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs b/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs index 61ed82b75..33e8529eb 100644 --- a/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs +++ b/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs @@ -1,6 +1,8 @@ using DiscordRPC; using Humanizer; +using LibHac.Bcat; using Ryujinx.Common; +using Ryujinx.HLE.Loaders.Processes; using Ryujinx.UI.App.Common; using Ryujinx.UI.Common.Configuration; using System.Collections.Generic; @@ -13,7 +15,7 @@ namespace Ryujinx.UI.Common { public static Timestamps StartedAt { get; set; } - private const string Description = "A simple, experimental Nintendo Switch emulator."; + private static readonly string _description = $"{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo} {ReleaseInformation.Version}"; private const string ApplicationId = "1293250299716173864"; private const int ApplicationByteLimit = 128; @@ -29,7 +31,7 @@ namespace Ryujinx.UI.Common Assets = new Assets { LargeImageKey = "ryujinx", - LargeImageText = Description + LargeImageText = TruncateToByteLength(_description) }, Details = "Main Menu", State = "Idling", @@ -62,19 +64,21 @@ namespace Ryujinx.UI.Common } } - public static void SwitchToPlayingState(string titleId, ApplicationMetadata appMeta) + public static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes) { _discordClient?.SetPresence(new RichPresence { Assets = new Assets { - LargeImageKey = _discordGameAssets.Contains(titleId.ToLower()) ? titleId : "game", - LargeImageText = TruncateToByteLength(appMeta.Title), + LargeImageKey = _discordGameAssets.Contains(procRes.ProgramIdText.ToLower()) ? procRes.ProgramIdText : "game", + LargeImageText = TruncateToByteLength($"{appMeta.Title} | {procRes.DisplayVersion}"), SmallImageKey = "ryujinx", - SmallImageText = Description + SmallImageText = TruncateToByteLength(_description) }, Details = TruncateToByteLength($"Playing {appMeta.Title}"), - State = $"Total play time: {appMeta.TimePlayed.Humanize(2, false)}", + State = appMeta.LastPlayed.HasValue + ? $"Total play time: {appMeta.TimePlayed.Humanize(2, false)}" + : "Never played", Timestamps = Timestamps.Now }); } diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index ec566a388..a4301fdd3 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -785,12 +785,11 @@ namespace Ryujinx.Ava return false; } - ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata => - { - appMetadata.UpdatePreGame(); - }); + ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, + appMetadata => appMetadata.UpdatePreGame() + ); - DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, appMeta); + DiscordIntegrationModule.SwitchToPlayingState(appMeta, Device.Processes.ActiveApplication); return true; }