Refactored Achievement Badges into Texture Layers

Achievement badges/icons are refactored into the type CustomTextureData::ArraySlice::Level as that is the data type images loaded from the filesystem will be. This includes everything that uses the badges in the Qt UI and OnScreenDisplay, and similarly removes the OSD::Icon type because Level already contains that information.
This commit is contained in:
LillyJadeKatrin
2024-05-13 00:15:21 -04:00
parent 75465f00cc
commit dc8f3f6eae
9 changed files with 83 additions and 101 deletions

View File

@ -22,6 +22,7 @@
#include "Common/HttpRequest.h"
#include "Common/WorkQueueThread.h"
#include "DiscIO/Volume.h"
#include "VideoCommon/Assets/CustomTextureData.h"
namespace Core
{
@ -29,11 +30,6 @@ class CPUThreadGuard;
class System;
} // namespace Core
namespace OSD
{
struct Icon;
}
class AchievementManager
{
public:
@ -47,8 +43,8 @@ public:
using LeaderboardRank = u32;
static constexpr size_t RP_SIZE = 256;
using RichPresence = std::array<char, RP_SIZE>;
using Badge = std::vector<u8>;
using NamedIconMap = std::map<std::string, std::unique_ptr<OSD::Icon>, std::less<>>;
using Badge = VideoCommon::CustomTextureData::ArraySlice::Level;
using NamedBadgeMap = std::unordered_map<std::string, const Badge*>;
static constexpr size_t MAX_DISPLAYED_LBOARDS = 4;
struct BadgeStatus
@ -116,7 +112,7 @@ public:
const BadgeStatus& GetAchievementBadge(AchievementId id, bool locked) const;
const LeaderboardStatus* GetLeaderboardInfo(AchievementId leaderboard_id);
RichPresence GetRichPresence() const;
const NamedIconMap& GetChallengeIcons() const;
const NamedBadgeMap& GetChallengeIcons() const;
std::vector<std::string> GetActiveLeaderboards() const;
void DoState(PointerWrap& p);
@ -134,8 +130,6 @@ private:
std::unique_ptr<DiscIO::Volume> volume;
};
const BadgeStatus m_default_badge;
static void* FilereaderOpenByFilepath(const char* path_utf8);
static void* FilereaderOpenByVolume(const char* path_utf8);
static void FilereaderSeek(void* file_handle, int64_t offset, int origin);
@ -200,7 +194,7 @@ private:
std::chrono::steady_clock::time_point m_last_rp_time = std::chrono::steady_clock::now();
std::unordered_map<AchievementId, LeaderboardStatus> m_leaderboard_map;
NamedIconMap m_active_challenges;
NamedBadgeMap m_active_challenges;
std::vector<rc_client_leaderboard_tracker_t> m_active_leaderboards;
Common::WorkQueueThread<std::function<void()>> m_queue;