Added Leaderboard info map to AchievementManager
The leaderboard map created here contains information useful to displaying leaderboard stats in the Achievement dialog, including each leaderboard's name and description and a partial list of entries for display. The entire map is exposed to the UI in a single call for simplicity.
This commit is contained in:
parent
daf9ff012a
commit
61dded7043
|
@ -712,6 +712,12 @@ AchievementManager::GetAchievementProgress(AchievementId achievement_id, u32* va
|
||||||
return ResponseType::SUCCESS;
|
return ResponseType::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::unordered_map<AchievementId, AchievementManager::LeaderboardStatus>&
|
||||||
|
AchievementManager::GetLeaderboardsInfo() const
|
||||||
|
{
|
||||||
|
return m_leaderboard_map;
|
||||||
|
}
|
||||||
|
|
||||||
AchievementManager::RichPresence AchievementManager::GetRichPresence()
|
AchievementManager::RichPresence AchievementManager::GetRichPresence()
|
||||||
{
|
{
|
||||||
std::lock_guard lg{m_lock};
|
std::lock_guard lg{m_lock};
|
||||||
|
@ -732,6 +738,7 @@ void AchievementManager::CloseGame()
|
||||||
m_game_id = 0;
|
m_game_id = 0;
|
||||||
m_game_badge.name = "";
|
m_game_badge.name = "";
|
||||||
m_unlock_map.clear();
|
m_unlock_map.clear();
|
||||||
|
m_leaderboard_map.clear();
|
||||||
rc_api_destroy_fetch_game_data_response(&m_game_data);
|
rc_api_destroy_fetch_game_data_response(&m_game_data);
|
||||||
std::memset(&m_game_data, 0, sizeof(m_game_data));
|
std::memset(&m_game_data, 0, sizeof(m_game_data));
|
||||||
m_queue.Cancel();
|
m_queue.Cancel();
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
using AchievementId = u32;
|
using AchievementId = u32;
|
||||||
static constexpr size_t FORMAT_SIZE = 24;
|
static constexpr size_t FORMAT_SIZE = 24;
|
||||||
using FormattedValue = std::array<char, FORMAT_SIZE>;
|
using FormattedValue = std::array<char, FORMAT_SIZE>;
|
||||||
|
using LeaderboardRank = u32;
|
||||||
static constexpr size_t RP_SIZE = 256;
|
static constexpr size_t RP_SIZE = 256;
|
||||||
using RichPresence = std::array<char, RP_SIZE>;
|
using RichPresence = std::array<char, RP_SIZE>;
|
||||||
using Badge = std::vector<u8>;
|
using Badge = std::vector<u8>;
|
||||||
|
@ -83,6 +84,21 @@ public:
|
||||||
static constexpr std::string_view GOLD = "#FFD700";
|
static constexpr std::string_view GOLD = "#FFD700";
|
||||||
static constexpr std::string_view BLUE = "#0B71C1";
|
static constexpr std::string_view BLUE = "#0B71C1";
|
||||||
|
|
||||||
|
struct LeaderboardEntry
|
||||||
|
{
|
||||||
|
std::string username;
|
||||||
|
FormattedValue score;
|
||||||
|
LeaderboardRank rank;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LeaderboardStatus
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string description;
|
||||||
|
u32 player_index = 0;
|
||||||
|
std::unordered_map<u32, LeaderboardEntry> entries;
|
||||||
|
};
|
||||||
|
|
||||||
static AchievementManager* GetInstance();
|
static AchievementManager* GetInstance();
|
||||||
void Init();
|
void Init();
|
||||||
void SetUpdateCallback(UpdateCallback callback);
|
void SetUpdateCallback(UpdateCallback callback);
|
||||||
|
@ -113,6 +129,7 @@ public:
|
||||||
const UnlockStatus& GetUnlockStatus(AchievementId achievement_id) const;
|
const UnlockStatus& GetUnlockStatus(AchievementId achievement_id) const;
|
||||||
AchievementManager::ResponseType GetAchievementProgress(AchievementId achievement_id, u32* value,
|
AchievementManager::ResponseType GetAchievementProgress(AchievementId achievement_id, u32* value,
|
||||||
u32* target);
|
u32* target);
|
||||||
|
const std::unordered_map<AchievementId, LeaderboardStatus>& GetLeaderboardsInfo() const;
|
||||||
RichPresence GetRichPresence();
|
RichPresence GetRichPresence();
|
||||||
|
|
||||||
void CloseGame();
|
void CloseGame();
|
||||||
|
@ -165,6 +182,7 @@ private:
|
||||||
time_t m_last_ping_time = 0;
|
time_t m_last_ping_time = 0;
|
||||||
|
|
||||||
std::unordered_map<AchievementId, UnlockStatus> m_unlock_map;
|
std::unordered_map<AchievementId, UnlockStatus> m_unlock_map;
|
||||||
|
std::unordered_map<AchievementId, LeaderboardStatus> m_leaderboard_map;
|
||||||
|
|
||||||
Common::WorkQueueThread<std::function<void()>> m_queue;
|
Common::WorkQueueThread<std::function<void()>> m_queue;
|
||||||
Common::WorkQueueThread<std::function<void()>> m_image_queue;
|
Common::WorkQueueThread<std::function<void()>> m_image_queue;
|
||||||
|
|
Loading…
Reference in New Issue