| 3509 | } |
| 3510 | |
| 3511 | void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& entry, bool is_self, float rank_column_width, |
| 3512 | float name_column_width, float time_column_width, float column_spacing) |
| 3513 | { |
| 3514 | using ImGuiFullscreen::g_large_font; |
| 3515 | using ImGuiFullscreen::GetLineHeight; |
| 3516 | using ImGuiFullscreen::LayoutScale; |
| 3517 | |
| 3518 | static constexpr float alpha = 0.8f; |
| 3519 | |
| 3520 | ImRect bb; |
| 3521 | bool visible, hovered; |
| 3522 | bool pressed = ImGuiFullscreen::MenuButtonFrame( |
| 3523 | entry.user, true, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, &visible, &hovered, &bb.Min, &bb.Max, 0, alpha); |
| 3524 | if (!visible) |
| 3525 | return; |
| 3526 | |
| 3527 | const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f); |
| 3528 | const float column_padding = LayoutScale(15.0f); |
| 3529 | const float icon_column_width = bb.Max.y - bb.Min.y; |
| 3530 | float column_left = bb.Min.x + column_padding; |
| 3531 | SmallString text; |
| 3532 | |
| 3533 | text.format("{}", entry.rank); |
| 3534 | |
| 3535 | ImGui::PushFont(g_large_font.first, g_large_font.second); |
| 3536 | |
| 3537 | if (is_self) |
| 3538 | ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 242, 0, 255)); |
| 3539 | |
| 3540 | const ImRect rank_bb(ImVec2(column_left, bb.Min.y), ImVec2(column_left + rank_column_width, midpoint)); |
| 3541 | ImGuiFullscreen::RenderTextClippedWithShadow( |
| 3542 | rank_bb.Min, rank_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), &rank_bb); |
| 3543 | column_left += rank_column_width + column_spacing; |
| 3544 | |
| 3545 | const ImRect icon_bb(ImVec2(column_left, bb.Min.y), ImVec2(column_left + icon_column_width, bb.Min.y + icon_column_width)); |
| 3546 | GSTexture* icon_tex = nullptr; |
| 3547 | if (auto it = std::find_if(s_leaderboard_user_icon_paths.begin(), s_leaderboard_user_icon_paths.end(), |
| 3548 | [&entry](const auto& it) { return it.first == &entry; }); |
| 3549 | it != s_leaderboard_user_icon_paths.end()) |
| 3550 | { |
| 3551 | if (!it->second.empty()) |
| 3552 | icon_tex = ImGuiFullscreen::GetCachedTextureAsync(it->second.c_str()); |
| 3553 | } |
| 3554 | else |
| 3555 | { |
| 3556 | std::string path = Achievements::GetLeaderboardUserBadgePath(&entry); |
| 3557 | if (!path.empty()) |
| 3558 | { |
| 3559 | icon_tex = ImGuiFullscreen::GetCachedTextureAsync(path.c_str()); |
| 3560 | s_leaderboard_user_icon_paths.emplace_back(&entry, std::move(path)); |
| 3561 | } |
| 3562 | } |
| 3563 | if (icon_tex) |
| 3564 | { |
| 3565 | ImGui::GetWindowDrawList()->AddImage(reinterpret_cast<ImTextureID>(icon_tex->GetNativeHandle()), |
| 3566 | icon_bb.Min, icon_bb.Min + ImVec2(icon_column_width, icon_column_width)); |
| 3567 | } |
| 3568 |
nothing calls this directly
no test coverage detected