From d34d0404f1a2acb6eb9087ea9328ec9a7b7e1250 Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:02:28 +0700 Subject: [PATCH] DiscordRPC: Add Rcheevos Icon Support (#3286) --- src/core/achievements.cpp | 5 +++++ src/core/achievements.h | 3 +++ src/core/system.cpp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index 5e31fa335..7836aa54f 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -523,6 +523,11 @@ const std::string& Achievements::GetGameIconPath() return s_game_icon; } +const std::string& Achievements::GetGameIconURL() +{ + return s_game_icon_url; +} + const std::string& Achievements::GetRichPresenceString() { return s_rich_presence_string; diff --git a/src/core/achievements.h b/src/core/achievements.h index c8bc63075..a572f5e60 100644 --- a/src/core/achievements.h +++ b/src/core/achievements.h @@ -115,6 +115,9 @@ bool HasRichPresence(); /// Should be called with the lock held. const std::string& GetRichPresenceString(); +/// Returns the URL for the current icon of the game +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/src/core/system.cpp b/src/core/system.cpp index 749b092e5..a5781dfda 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -5892,6 +5892,8 @@ void System::UpdateRichPresence(bool update_session_time) const auto lock = Achievements::GetLock(); state_string = StringUtil::Ellipsise(Achievements::GetRichPresenceString(), 128); rp.state = state_string.c_str(); + if (const std::string& icon_url = Achievements::GetGameIconURL(); !icon_url.empty()) + rp.largeImageKey = icon_url.c_str(); } dyn_libs::Discord_UpdatePresence(&rp);