Added FetchGameData to AchievementManager

FetchGameData is the big one - this retrieves the logic for all the achievements, leaderboards, and rich presence, and all the relevant metadata for the game.
This commit is contained in:
LillyJadeKatrin 2023-04-05 20:19:58 -04:00
parent 7e8a770b30
commit bd75ce6e6d
2 changed files with 14 additions and 0 deletions

View File

@ -106,6 +106,17 @@ AchievementManager::ResponseType AchievementManager::StartRASession()
return r_type;
}
AchievementManager::ResponseType AchievementManager::FetchGameData()
{
std::string username = Config::Get(Config::RA_USERNAME);
std::string api_token = Config::Get(Config::RA_API_TOKEN);
rc_api_fetch_game_data_request_t fetch_data_request = {
.username = username.c_str(), .api_token = api_token.c_str(), .game_id = m_game_id};
return Request<rc_api_fetch_game_data_request_t, rc_api_fetch_game_data_response_t>(
fetch_data_request, &m_game_data, rc_api_init_fetch_game_data_request,
rc_api_process_fetch_game_data_response);
}
// Every RetroAchievements API call, with only a partial exception for fetch_image, follows
// the same design pattern (here, X is the name of the call):
// Create a specific rc_api_X_request_t struct and populate with the necessary values

View File

@ -44,6 +44,7 @@ private:
ResponseType VerifyCredentials(const std::string& password);
ResponseType ResolveHash(std::array<char, HASH_LENGTH> game_hash);
ResponseType StartRASession();
ResponseType FetchGameData();
template <typename RcRequest, typename RcResponse>
ResponseType Request(RcRequest rc_request, RcResponse* rc_response,
@ -57,6 +58,8 @@ private:
rc_api_fetch_game_data_response_t m_game_data{};
Common::WorkQueueThread<std::function<void()>> m_queue;
}; // class AchievementManager