Added GenerateRichPresence to AchievementManager

GenerateRichPresence calls rc_runtime_get_richpresence in rhceevos on the achievement runtime to get the current Rich Presence string, a description of the player's current in-game state based on its memory as fed into a custom-developed script downloaded via FetchGameData. This gets passed into PingRichPresence, but is separated into its own method so it can be used elsewhere locally.
This commit is contained in:
LillyJadeKatrin 2023-04-15 12:02:28 -04:00
parent 1b880564cb
commit 22ee729055
2 changed files with 15 additions and 0 deletions

View File

@ -409,6 +409,20 @@ void AchievementManager::ActivateDeactivateAchievement(AchievementId id, bool en
rc_runtime_deactivate_achievement(&m_runtime, id);
}
RichPresence AchievementManager::GenerateRichPresence()
{
RichPresence rp_buffer;
Core::RunAsCPUThread([&] {
rc_runtime_get_richpresence(
&m_runtime, rp_buffer.data(), RP_SIZE,
[](unsigned address, unsigned num_bytes, void* ud) {
return static_cast<AchievementManager*>(ud)->MemoryPeeker(address, num_bytes, ud);
},
this, nullptr);
});
return rp_buffer;
}
AchievementManager::ResponseType AchievementManager::AwardAchievement(AchievementId achievement_id)
{
std::string username = Config::Get(Config::RA_USERNAME);

View File

@ -72,6 +72,7 @@ private:
ResponseType FetchUnlockData(bool hardcore);
void ActivateDeactivateAchievement(AchievementId id, bool enabled, bool unofficial, bool encore);
RichPresence GenerateRichPresence();
ResponseType AwardAchievement(AchievementId achievement_id);
ResponseType SubmitLeaderboard(AchievementId leaderboard_id, int value);