Added ActivateDeactivateRichPresence to AchievementManager

RetroAchievements Rich Presence is a script that is run periodically on a game's memory to provide a detailed text description of what the player is doing. Existing Discord presence on Dolphin would update a player's Discord status to say not just that they are using Dolphin but that they are playing, for example, Sonic Adventure 2 Battle; Rich Presence would detail that the player is in City Escape with 5 lives and 142 rings.

Activating this in the runtime simply entails loading that text script, as returned by the FetchGameData API call, into the runtime, here only determined by whether rich presence is enabled in the achievement settings. Deactivating this is done via the same rcheevos method by setting the rich presence to an empty string.
This commit is contained in:
LillyJadeKatrin 2023-04-13 23:35:49 -04:00
parent 64e3a64c87
commit 31c3288fd5
4 changed files with 17 additions and 0 deletions

View File

@ -142,6 +142,7 @@ void AchievementManager::LoadGameByFilenameAsync(const std::string& iso_path,
ActivateDeactivateAchievements();
}
ActivateDeactivateLeaderboards();
ActivateDeactivateRichPresence();
callback(fetch_game_data_response);
});
@ -191,6 +192,16 @@ void AchievementManager::ActivateDeactivateLeaderboards()
}
}
void AchievementManager::ActivateDeactivateRichPresence()
{
rc_runtime_activate_richpresence(
&m_runtime,
(m_is_game_loaded && Config::Get(Config::RA_RICH_PRESENCE_ENABLED)) ?
m_game_data.rich_presence_script :
"",
nullptr, 0);
}
void AchievementManager::CloseGame()
{
m_is_game_loaded = false;
@ -199,6 +210,7 @@ void AchievementManager::CloseGame()
m_unlock_map.clear();
ActivateDeactivateAchievements();
ActivateDeactivateLeaderboards();
ActivateDeactivateRichPresence();
}
void AchievementManager::Logout()

View File

@ -42,6 +42,8 @@ public:
void LoadUnlockData(const ResponseCallback& callback);
void ActivateDeactivateAchievements();
void ActivateDeactivateLeaderboards();
void ActivateDeactivateRichPresence();
void CloseGame();
void Logout();
void Shutdown();

View File

@ -17,6 +17,8 @@ const Info<bool> RA_ACHIEVEMENTS_ENABLED{
{System::Achievements, "Achievements", "AchievementsEnabled"}, false};
const Info<bool> RA_LEADERBOARDS_ENABLED{
{System::Achievements, "Achievements", "LeaderboardsEnabled"}, false};
const Info<bool> RA_RICH_PRESENCE_ENABLED{
{System::Achievements, "Achievements", "RichPresenceEnabled"}, false};
const Info<bool> RA_UNOFFICIAL_ENABLED{{System::Achievements, "Achievements", "UnofficialEnabled"},
false};
const Info<bool> RA_ENCORE_ENABLED{{System::Achievements, "Achievements", "EncoreEnabled"}, false};

View File

@ -13,6 +13,7 @@ extern const Info<std::string> RA_USERNAME;
extern const Info<std::string> RA_API_TOKEN;
extern const Info<bool> RA_ACHIEVEMENTS_ENABLED;
extern const Info<bool> RA_LEADERBOARDS_ENABLED;
extern const Info<bool> RA_RICH_PRESENCE_ENABLED;
extern const Info<bool> RA_UNOFFICIAL_ENABLED;
extern const Info<bool> RA_ENCORE_ENABLED;
} // namespace Config