0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 22:45:46 +00:00

UI: RPC: show game version when hovering large image asset.

This commit is contained in:
Evan Husted 2024-10-11 23:55:50 -05:00
parent 5b6e3521d8
commit 4d311dfc1a
2 changed files with 15 additions and 12 deletions

View file

@ -1,6 +1,8 @@
using DiscordRPC; using DiscordRPC;
using Humanizer; using Humanizer;
using LibHac.Bcat;
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.HLE.Loaders.Processes;
using Ryujinx.UI.App.Common; using Ryujinx.UI.App.Common;
using Ryujinx.UI.Common.Configuration; using Ryujinx.UI.Common.Configuration;
using System.Collections.Generic; using System.Collections.Generic;
@ -13,7 +15,7 @@ namespace Ryujinx.UI.Common
{ {
public static Timestamps StartedAt { get; set; } 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 string ApplicationId = "1293250299716173864";
private const int ApplicationByteLimit = 128; private const int ApplicationByteLimit = 128;
@ -29,7 +31,7 @@ namespace Ryujinx.UI.Common
Assets = new Assets Assets = new Assets
{ {
LargeImageKey = "ryujinx", LargeImageKey = "ryujinx",
LargeImageText = Description LargeImageText = TruncateToByteLength(_description)
}, },
Details = "Main Menu", Details = "Main Menu",
State = "Idling", 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 _discordClient?.SetPresence(new RichPresence
{ {
Assets = new Assets Assets = new Assets
{ {
LargeImageKey = _discordGameAssets.Contains(titleId.ToLower()) ? titleId : "game", LargeImageKey = _discordGameAssets.Contains(procRes.ProgramIdText.ToLower()) ? procRes.ProgramIdText : "game",
LargeImageText = TruncateToByteLength(appMeta.Title), LargeImageText = TruncateToByteLength($"{appMeta.Title} | {procRes.DisplayVersion}"),
SmallImageKey = "ryujinx", SmallImageKey = "ryujinx",
SmallImageText = Description SmallImageText = TruncateToByteLength(_description)
}, },
Details = TruncateToByteLength($"Playing {appMeta.Title}"), 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 Timestamps = Timestamps.Now
}); });
} }

View file

@ -785,12 +785,11 @@ namespace Ryujinx.Ava
return false; return false;
} }
ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata => ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText,
{ appMetadata => appMetadata.UpdatePreGame()
appMetadata.UpdatePreGame(); );
});
DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, appMeta); DiscordIntegrationModule.SwitchToPlayingState(appMeta, Device.Processes.ActiveApplication);
return true; return true;
} }