diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index f1a6d3a763..8397338b04 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -382,6 +382,25 @@ AchievementManager::ResponseType AchievementManager::AwardAchievement(Achievemen return r_type; } +AchievementManager::ResponseType AchievementManager::SubmitLeaderboard(AchievementId leaderboard_id, + int value) +{ + std::string username = Config::Get(Config::RA_USERNAME); + std::string api_token = Config::Get(Config::RA_API_TOKEN); + rc_api_submit_lboard_entry_request_t submit_request = {.username = username.c_str(), + .api_token = api_token.c_str(), + .leaderboard_id = leaderboard_id, + .score = value, + .game_hash = m_game_hash.data()}; + rc_api_submit_lboard_entry_response_t submit_response = {}; + ResponseType r_type = + Request( + submit_request, &submit_response, rc_api_init_submit_lboard_entry_request, + rc_api_process_submit_lboard_entry_response); + rc_api_destroy_submit_lboard_entry_response(&submit_response); + return r_type; +} + // 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 diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index 96e000344d..c68a141c63 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -64,6 +64,7 @@ private: void ActivateDeactivateAchievement(AchievementId id, bool enabled, bool unofficial, bool encore); ResponseType AwardAchievement(AchievementId achievement_id); + ResponseType SubmitLeaderboard(AchievementId leaderboard_id, int value); template ResponseType Request(RcRequest rc_request, RcResponse* rc_response, const std::function& init_request,