| 3061 | } |
| 3062 | |
| 3063 | void Achievements::DrawLeaderboardsWindow() |
| 3064 | { |
| 3065 | using ImGuiFullscreen::g_large_font; |
| 3066 | using ImGuiFullscreen::g_medium_font; |
| 3067 | using ImGuiFullscreen::GetLineHeight; |
| 3068 | using ImGuiFullscreen::LayoutScale; |
| 3069 | |
| 3070 | static constexpr float alpha = 0.8f; |
| 3071 | static constexpr float heading_alpha = 0.95f; |
| 3072 | static constexpr float heading_height_unscaled = 110.0f; |
| 3073 | static constexpr float tab_height_unscaled = 50.0f; |
| 3074 | |
| 3075 | auto lock = Achievements::GetLock(); |
| 3076 | |
| 3077 | // ensure image downloads still happen while we're paused |
| 3078 | Achievements::IdleUpdate(); |
| 3079 | |
| 3080 | const bool is_leaderboard_open = (s_open_leaderboard != nullptr); |
| 3081 | bool close_leaderboard_on_exit = false; |
| 3082 | |
| 3083 | const bool has_multiple_subsets = (s_subset_list && std::count_if(s_subset_list->subsets, |
| 3084 | s_subset_list->subsets + s_subset_list->num_subsets, |
| 3085 | [](const rc_client_subset_t* subset) { return subset->num_leaderboards > 0; }) > 1); |
| 3086 | static bool sidebar_has_focus = false; |
| 3087 | static bool focus_sidebar = false; |
| 3088 | if (!has_multiple_subsets || is_leaderboard_open) |
| 3089 | sidebar_has_focus = false; |
| 3090 | |
| 3091 | ImRect bb; |
| 3092 | |
| 3093 | const ImVec4 background(0.13f, 0.13f, 0.13f, alpha); |
| 3094 | const ImVec4 heading_background(0.13f, 0.13f, 0.13f, heading_alpha); |
| 3095 | const ImVec2 display_size(ImGui::GetIO().DisplaySize); |
| 3096 | const float padding = LayoutScale(10.0f); |
| 3097 | const float spacing = LayoutScale(10.0f); |
| 3098 | const float spacing_small = spacing / 2.0f; |
| 3099 | float heading_height = LayoutScale(heading_height_unscaled); |
| 3100 | if (is_leaderboard_open) |
| 3101 | { |
| 3102 | // tabs |
| 3103 | heading_height += spacing_small + LayoutScale(tab_height_unscaled) + spacing; |
| 3104 | |
| 3105 | // Add space for a legend - spacing + 1 line of text + spacing + line |
| 3106 | heading_height += LayoutScale(ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) + spacing; |
| 3107 | } |
| 3108 | |
| 3109 | const float rank_column_width = std::max( |
| 3110 | g_large_font.first->CalcTextSizeA(g_large_font.second, std::numeric_limits<float>::max(), -1.0f, "99999").x, |
| 3111 | g_large_font.first |
| 3112 | ->CalcTextSizeA( |
| 3113 | g_large_font.second, std::numeric_limits<float>::max(), -1.0f, TRANSLATE("Achievements", "Rank")) |
| 3114 | .x); |
| 3115 | const float name_column_width = |
| 3116 | g_large_font.first->CalcTextSizeA(g_large_font.second, std::numeric_limits<float>::max(), -1.0f, "WWWWWWWWWWWWWWWWWWWWWW").x; |
| 3117 | const float time_column_width = |
| 3118 | g_large_font.first->CalcTextSizeA(g_large_font.second, std::numeric_limits<float>::max(), -1.0f, "WWWWWWWWWWW").x; |
| 3119 | const float column_spacing = spacing * 2.0f; |
| 3120 |
nothing calls this directly
no test coverage detected