mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 13:49:53 -06:00
Display active leaderboard data on screen
Up to four leaderboards are displayed in a window in the bottom right of the screen (vertically above challenge icons, if there are any). As per RetroAchievements standards, the markers only display the current leaderboard values with no further context necessary.
This commit is contained in:
@ -332,63 +332,70 @@ void OnScreenUI::DrawDebugText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
void OnScreenUI::DrawChallenges()
|
void OnScreenUI::DrawChallengesAndLeaderboards()
|
||||||
{
|
{
|
||||||
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
|
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
|
||||||
const auto& challenge_icons = AchievementManager::GetInstance().GetChallengeIcons();
|
const auto& challenge_icons = AchievementManager::GetInstance().GetChallengeIcons();
|
||||||
if (challenge_icons.empty())
|
const auto& leaderboard_progress = AchievementManager::GetInstance().GetActiveLeaderboards();
|
||||||
return;
|
float leaderboard_y = ImGui::GetIO().DisplaySize.y;
|
||||||
|
if (!challenge_icons.empty())
|
||||||
const std::string window_name = "Challenges";
|
|
||||||
|
|
||||||
u32 sum_of_icon_heights = 0;
|
|
||||||
u32 max_icon_width = 0;
|
|
||||||
for (const auto& [name, icon] : challenge_icons)
|
|
||||||
{
|
{
|
||||||
// These *should* all be the same square size but you never know.
|
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y), 0,
|
||||||
if (icon->width > max_icon_width)
|
ImVec2(1.0, 1.0));
|
||||||
max_icon_width = icon->width;
|
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f));
|
||||||
sum_of_icon_heights += icon->height;
|
if (ImGui::Begin("Challenges", nullptr,
|
||||||
}
|
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs |
|
||||||
ImGui::SetNextWindowPos(
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
|
||||||
ImVec2(ImGui::GetIO().DisplaySize.x - 20.f * m_backbuffer_scale - max_icon_width,
|
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |
|
||||||
ImGui::GetIO().DisplaySize.y - 20.f * m_backbuffer_scale - sum_of_icon_heights));
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing))
|
||||||
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f));
|
|
||||||
if (ImGui::Begin(window_name.c_str(), nullptr,
|
|
||||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs |
|
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
|
|
||||||
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())
|
for (const auto& [name, icon] : challenge_icons)
|
||||||
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->rgba_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);
|
if (m_challenge_texture_map.find(name) != m_challenge_texture_map.end())
|
||||||
continue;
|
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->rgba_data.data(),
|
||||||
|
sizeof(u32) * width * height);
|
||||||
}
|
}
|
||||||
if (texture)
|
for (auto& [name, texture] : m_challenge_texture_map)
|
||||||
{
|
{
|
||||||
ImGui::Image(texture.get(), ImVec2(static_cast<float>(icon_itr->second->width),
|
auto icon_itr = challenge_icons.find(name);
|
||||||
static_cast<float>(icon_itr->second->height)));
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
leaderboard_y -= ImGui::GetWindowHeight();
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::End();
|
if (!leaderboard_progress.empty())
|
||||||
|
{
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x, leaderboard_y), 0,
|
||||||
|
ImVec2(1.0, 1.0));
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f));
|
||||||
|
if (ImGui::Begin("Leaderboards", nullptr,
|
||||||
|
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs |
|
||||||
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
|
||||||
|
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |
|
||||||
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing))
|
||||||
|
{
|
||||||
|
for (const auto& value : leaderboard_progress)
|
||||||
|
ImGui::Text(value.data());
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
@ -400,7 +407,7 @@ void OnScreenUI::Finalize()
|
|||||||
DrawDebugText();
|
DrawDebugText();
|
||||||
OSD::DrawMessages();
|
OSD::DrawMessages();
|
||||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
DrawChallenges();
|
DrawChallengesAndLeaderboards();
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void DrawDebugText();
|
void DrawDebugText();
|
||||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
void DrawChallenges();
|
void DrawChallengesAndLeaderboards();
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
// ImGui resources.
|
// ImGui resources.
|
||||||
|
Reference in New Issue
Block a user