summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/OnScreenUI.cpp
diff options
context:
space:
mode:
authorLillyJadeKatrin <lilly.kitty.1988@gmail.com>2024-06-13 00:03:46 -0400
committerLillyJadeKatrin <lilly.kitty.1988@gmail.com>2024-06-15 07:36:49 -0400
commit3d5a1f7d335105862a9d86d12806bebdb33db12e (patch)
tree42682a0568ade409ae199af754e1019c00a9e6b3 /Source/Core/VideoCommon/OnScreenUI.cpp
parent6c5ceaa06d26eae901a6baff0efa869cb75415aa (diff)
Refactored Challenge Icons to handle icon updates
If an icon is displayed on screen before it downloads, it was displaying a default icon but it would fail to load the actual icon even after it was downloaded. This fixes that.
Diffstat (limited to 'Source/Core/VideoCommon/OnScreenUI.cpp')
-rw-r--r--Source/Core/VideoCommon/OnScreenUI.cpp51
1 files changed, 24 insertions, 27 deletions
diff --git a/Source/Core/VideoCommon/OnScreenUI.cpp b/Source/Core/VideoCommon/OnScreenUI.cpp
index 1d5a432d8a..d3a3c7397d 100644
--- a/Source/Core/VideoCommon/OnScreenUI.cpp
+++ b/Source/Core/VideoCommon/OnScreenUI.cpp
@@ -334,11 +334,28 @@ void OnScreenUI::DrawDebugText()
void OnScreenUI::DrawChallengesAndLeaderboards()
{
#ifdef USE_RETRO_ACHIEVEMENTS
- std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
- const auto& challenge_icons = AchievementManager::GetInstance().GetChallengeIcons();
- const auto& leaderboard_progress = AchievementManager::GetInstance().GetActiveLeaderboards();
+ auto& instance = AchievementManager::GetInstance();
+ std::lock_guard lg{instance.GetLock()};
+ if (instance.AreChallengesUpdated())
+ {
+ instance.ResetChallengesUpdated();
+ const auto& challenges = instance.GetActiveChallenges();
+ m_challenge_texture_map.clear();
+ for (const auto& name : challenges)
+ {
+ const auto& icon = instance.GetAchievementBadge(name, false);
+ const u32 width = icon.width;
+ const u32 height = icon.height;
+ TextureConfig tex_config(width, height, 1, 1, 1, AbstractTextureFormat::RGBA8, 0,
+ AbstractTextureType::Texture_2DArray);
+ auto res = m_challenge_texture_map.insert_or_assign(name, g_gfx->CreateTexture(tex_config));
+ res.first->second->Load(0, width, height, width, icon.data.data(),
+ sizeof(u32) * width * height);
+ }
+ }
+
float leaderboard_y = ImGui::GetIO().DisplaySize.y;
- if (!challenge_icons.empty())
+ if (!m_challenge_texture_map.empty())
{
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y), 0,
ImVec2(1.0, 1.0));
@@ -349,37 +366,17 @@ void OnScreenUI::DrawChallengesAndLeaderboards()
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing))
{
- for (const auto& [name, icon] : challenge_icons)
- {
- if (m_challenge_texture_map.find(name) != m_challenge_texture_map.end())
- continue;
- const u32 width = icon->width;
- const u32 height = icon->height;
- TextureConfig tex_config(width, height, 1, 1, 1, AbstractTextureFormat::RGBA8, 0,
- AbstractTextureType::Texture_2DArray);
- auto res = m_challenge_texture_map.insert_or_assign(name, g_gfx->CreateTexture(tex_config));
- res.first->second->Load(0, width, height, width, icon->data.data(),
- sizeof(u32) * width * height);
- }
for (auto& [name, texture] : m_challenge_texture_map)
{
- auto icon_itr = challenge_icons.find(name);
- if (icon_itr == challenge_icons.end())
- {
- m_challenge_texture_map.erase(name);
- continue;
- }
- if (texture)
- {
- ImGui::Image(texture.get(), ImVec2(static_cast<float>(icon_itr->second->width),
- static_cast<float>(icon_itr->second->height)));
- }
+ ImGui::Image(texture.get(), ImVec2(static_cast<float>(texture->GetWidth()),
+ static_cast<float>(texture->GetHeight())));
}
leaderboard_y -= ImGui::GetWindowHeight();
}
ImGui::End();
}
+ const auto& leaderboard_progress = instance.GetActiveLeaderboards();
if (!leaderboard_progress.empty())
{
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x, leaderboard_y), 0,