diff --git a/pcsx2/Achievements.cpp b/pcsx2/Achievements.cpp index 299542bdae9dc..71e73b45aa4f1 100644 --- a/pcsx2/Achievements.cpp +++ b/pcsx2/Achievements.cpp @@ -199,6 +199,7 @@ namespace Achievements static std::string s_game_hash; static std::string s_game_title; static std::string s_game_icon; + static std::string s_game_icon_url; static u32 s_game_crc; static rc_client_user_game_summary_t s_game_summary; static u32 s_game_id = 0; @@ -401,6 +402,10 @@ const std::string& Achievements::GetRichPresenceString() return s_rich_presence_string; } +const std::string& Achievements::GetGameIconURL() +{ + return s_game_icon_url; +} bool Achievements::Initialize() { @@ -945,6 +950,7 @@ void Achievements::ClientLoadGameCallback(int result, const char* error_message, s_has_leaderboards = has_leaderboards; s_has_rich_presence = rc_client_has_rich_presence(client); s_game_icon = {}; + s_game_icon_url = {}; // ensure fullscreen UI is ready for notifications MTGS::RunOnGSThread(&ImGuiManager::InitializeFullscreenUI); @@ -966,6 +972,16 @@ void Achievements::ClientLoadGameCallback(int result, const char* error_message, } } + char icon_url[64]; + if (int err = rc_client_game_get_image_url(info, icon_url, std::size(icon_url)); err == RC_OK) + { + s_game_icon_url = icon_url; + } + else + { + ReportRCError(err, "rc_client_game_get_image_url() failed: "); + } + UpdateGameSummary(); DisplayAchievementSummary(); @@ -990,6 +1006,7 @@ void Achievements::ClearGameInfo() s_game_id = 0; s_game_title = {}; s_game_icon = {}; + s_game_icon_url = {}; s_has_achievements = false; s_has_leaderboards = false; s_has_rich_presence = false; diff --git a/pcsx2/Achievements.h b/pcsx2/Achievements.h index 679d06e524beb..21dcc96a93d9d 100644 --- a/pcsx2/Achievements.h +++ b/pcsx2/Achievements.h @@ -108,6 +108,10 @@ namespace Achievements /// Should be called with the lock held. const std::string& GetRichPresenceString(); + /// Returns the current game icon url. + /// Should be called with the lock held. + const std::string& GetGameIconURL(); + /// Returns the RetroAchievements title for the current game. /// Should be called with the lock held. const std::string& GetGameTitle(); diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index 24ae9431b78fd..61996008427cc 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -3608,15 +3608,21 @@ void VMManager::UpdateDiscordPresence(bool update_session_time) // https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields DiscordRichPresence rp = {}; rp.largeImageKey = "4k-pcsx2"; - rp.largeImageText = "PCSX2 Emulator"; + rp.largeImageText = "PCSX2 PS2 Emulator"; rp.startTimestamp = s_discord_presence_time_epoch; rp.details = s_title.empty() ? TRANSLATE("VMManager","No Game Running") : s_title.c_str(); std::string state_string; + if (Achievements::HasRichPresence()) { + auto lock = Achievements::GetLock(); + state_string = StringUtil::Ellipsise(Achievements::GetRichPresenceString(), 128); rp.state = state_string.c_str(); + + rp.largeImageKey = Achievements::GetGameIconURL().c_str(); + rp.largeImageText = s_title.c_str(); } Discord_UpdatePresence(&rp);