@@ -2940,6 +2940,8 @@ void Achievements::DrawAchievementsWindow()
29402940
29412941void Achievements::DrawAchievement (const rc_client_achievement_t * cheevo)
29422942{
2943+ using ImGuiFullscreen::DarkerColor;
2944+ using ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT ;
29432945 using ImGuiFullscreen::LayoutScale;
29442946 using ImGuiFullscreen::LayoutUnscale;
29452947 using ImGuiFullscreen::RenderShadowedTextClipped;
@@ -2948,17 +2950,19 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
29482950 static constexpr float alpha = 0 .8f ;
29492951 static constexpr float progress_height_unscaled = 20 .0f ;
29502952 static constexpr float progress_spacing_unscaled = 5 .0f ;
2953+ static constexpr float spacing_unscaled = 4 .0f ;
29512954
2952- const float spacing = ImGuiFullscreen::LayoutScale (4 .0f );
2953- const u32 text_color = ImGui::GetColorU32 (ImGuiCol_Text);
2955+ const float spacing = ImGuiFullscreen::LayoutScale (spacing_unscaled);
2956+ const u32 text_color = ImGui::GetColorU32 (UIStyle.SecondaryTextColor );
2957+ const u32 summary_color = ImGui::GetColorU32 (DarkerColor (UIStyle.SecondaryTextColor ));
2958+ const u32 rarity_color = ImGui::GetColorU32 (DarkerColor (DarkerColor (UIStyle.SecondaryTextColor )));
29542959
29552960 const bool is_unlocked = (cheevo->state == RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED );
29562961 const std::string_view measured_progress (cheevo->measured_progress );
29572962 const bool is_measured = !is_unlocked && !measured_progress.empty ();
2958- const float unlock_size = is_unlocked ? (spacing + ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE ) : 0 .0f ;
2959- const ImVec2 points_template_size (UIStyle.MediumFont ->CalcTextSizeA (UIStyle.MediumFont ->FontSize , FLT_MAX , 0 .0f ,
2960- TRANSLATE (" Achievements" , " XXX points" )));
2961-
2963+ const float unlock_rarity_height = spacing_unscaled + ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE ;
2964+ const ImVec2 points_template_size = UIStyle.MediumFont ->CalcTextSizeA (UIStyle.MediumFont ->FontSize , FLT_MAX , 0 .0f ,
2965+ TRANSLATE (" Achievements" , " XXX points" ));
29622966 const size_t summary_length = std::strlen (cheevo->description );
29632967 const float summary_wrap_width =
29642968 (ImGui::GetCurrentWindow ()->WorkRect .GetWidth () - (ImGui::GetStyle ().FramePadding .x * 2 .0f ) -
@@ -2968,15 +2972,15 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
29682972 cheevo->description + summary_length));
29692973
29702974 // Messy, but need to undo LayoutScale in MenuButtonFrame()...
2971- const float extra_summary_height = LayoutUnscale ( std::max (summary_text_size.y - UIStyle. MediumFont -> FontSize , 0 .0f ) );
2975+ const float extra_summary_height = std::max (LayoutUnscale ( summary_text_size.y ) - LAYOUT_MENU_BUTTON_HEIGHT , 0 .0f );
29722976
29732977 ImRect bb;
29742978 bool visible, hovered;
29752979 const bool clicked = ImGuiFullscreen::MenuButtonFrame (
29762980 TinyString::from_format (" chv_{}" , cheevo->id ), true ,
2977- !is_measured ? ImGuiFullscreen:: LAYOUT_MENU_BUTTON_HEIGHT + extra_summary_height + unlock_size :
2978- ImGuiFullscreen:: LAYOUT_MENU_BUTTON_HEIGHT + extra_summary_height + progress_height_unscaled +
2979- progress_spacing_unscaled,
2981+ !is_measured ? ( LAYOUT_MENU_BUTTON_HEIGHT + extra_summary_height + unlock_rarity_height) :
2982+ ( LAYOUT_MENU_BUTTON_HEIGHT + extra_summary_height + unlock_rarity_height + progress_height_unscaled +
2983+ progress_spacing_unscaled) ,
29802984 &visible, &hovered, &bb.Min , &bb.Max , 0 , alpha);
29812985 if (!visible)
29822986 return ;
@@ -3032,6 +3036,9 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
30323036 const float text_start_x = bb.Min .x + image_size.x + LayoutScale (15 .0f );
30333037 const ImRect title_bb (ImVec2 (text_start_x, bb.Min .y ), ImVec2 (points_start, midpoint));
30343038 const ImRect summary_bb (ImVec2 (text_start_x, midpoint), ImVec2 (points_start, midpoint + summary_text_size.y ));
3039+ const ImRect unlock_rarity_bb (summary_bb.Min .x , summary_bb.Max .y + spacing, summary_bb.Max .x ,
3040+ summary_bb.Max .y +
3041+ LayoutScale (spacing_unscaled + ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE ));
30353042 const ImRect points_bb (ImVec2 (points_start, midpoint), bb.Max );
30363043 const ImRect lock_bb (ImVec2 (points_template_start + ((points_template_size.x - right_icon_size.x ) * 0 .5f ), bb.Min .y ),
30373044 ImVec2 (bb.Max .x , midpoint));
@@ -3040,33 +3047,44 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
30403047 ImVec2 (0 .0f , 0 .0f ), 0 .0f , &title_bb);
30413048 RenderShadowedTextClipped (UIStyle.LargeFont , lock_bb.Min , lock_bb.Max , text_color, right_icon_text, nullptr ,
30423049 &right_icon_size, ImVec2 (0 .0f , 0 .0f ), 0 .0f , &lock_bb);
3050+ RenderShadowedTextClipped (UIStyle.MediumFont , points_bb.Min , points_bb.Max , summary_color, text.c_str (),
3051+ text.end_ptr (), &points_size, ImVec2 (0 .0f , 0 .0f ), 0 .0f , &points_bb);
30433052
30443053 if (cheevo->description && summary_length > 0 )
30453054 {
3046- RenderShadowedTextClipped (UIStyle.MediumFont , summary_bb.Min , summary_bb.Max , text_color , cheevo->description ,
3055+ RenderShadowedTextClipped (UIStyle.MediumFont , summary_bb.Min , summary_bb.Max , summary_color , cheevo->description ,
30473056 cheevo->description + summary_length, &summary_text_size, ImVec2 (0 .0f , 0 .0f ),
30483057 summary_wrap_width, &summary_bb);
30493058 }
3050- RenderShadowedTextClipped (UIStyle.MediumFont , points_bb.Min , points_bb.Max , text_color, text.c_str (), text.end_ptr (),
3051- &points_size, ImVec2 (0 .0f , 0 .0f ), 0 .0f , &points_bb);
3059+
3060+ // display hc if hc is active
3061+ const float rarity_to_display = IsHardcoreModeActive () ? cheevo->rarity_hardcore : cheevo->rarity ;
30523062
30533063 if (is_unlocked)
30543064 {
30553065 TinyString date;
30563066 FullscreenUI::TimeToPrintableString (&date, cheevo->unlock_time );
3057- text.format (TRANSLATE_FS (" Achievements" , " Unlocked: {}" ), date);
3067+ text.format (TRANSLATE_FS (" Achievements" , " Unlocked: {} | {:.1f}% of players have this achievement" ), date,
3068+ rarity_to_display);
30583069
3059- const ImRect unlock_bb (summary_bb.Min .x , summary_bb.Max .y + spacing, summary_bb.Max .x , bb.Max .y );
3060- RenderShadowedTextClipped (UIStyle.MediumFont , unlock_bb.Min , unlock_bb.Max , text_color, text.c_str (),
3061- text.end_ptr (), nullptr , ImVec2 (0 .0f , 0 .0f ), 0 .0f , &unlock_bb);
3070+ RenderShadowedTextClipped (UIStyle.MediumFont , unlock_rarity_bb.Min , unlock_rarity_bb.Max , rarity_color,
3071+ text.c_str (), text.end_ptr (), nullptr , ImVec2 (0 .0f , 0 .0f ), 0 .0f , &unlock_rarity_bb);
30623072 }
3063- else if (is_measured)
3073+ else
3074+ {
3075+ text.format (TRANSLATE_FS (" Achievements" , " {:.1f}% of players have this achievement" ), rarity_to_display);
3076+ RenderShadowedTextClipped (UIStyle.MediumFont , unlock_rarity_bb.Min , unlock_rarity_bb.Max , rarity_color,
3077+ text.c_str (), text.end_ptr (), nullptr , ImVec2 (0 .0f , 0 .0f ), 0 .0f , &unlock_rarity_bb);
3078+ }
3079+
3080+ if (!is_unlocked && is_measured)
30643081 {
30653082 ImDrawList* dl = ImGui::GetWindowDrawList ();
30663083 const float progress_height = LayoutScale (progress_height_unscaled);
30673084 const float progress_spacing = LayoutScale (progress_spacing_unscaled);
3068- const float top = midpoint + UIStyle.MediumFont ->FontSize + progress_spacing;
3069- const ImRect progress_bb (ImVec2 (text_start_x, top), ImVec2 (bb.Max .x , top + progress_height));
3085+ const ImRect progress_bb (summary_bb.Min .x , unlock_rarity_bb.Max .y + progress_spacing,
3086+ summary_bb.Max .x - progress_spacing,
3087+ unlock_rarity_bb.Max .y + progress_spacing + progress_height);
30703088 const float fraction = cheevo->measured_percent * 0 .01f ;
30713089 dl->AddRectFilled (progress_bb.Min , progress_bb.Max , ImGui::GetColorU32 (ImGuiFullscreen::UIStyle.PrimaryDarkColor ));
30723090 dl->AddRectFilled (progress_bb.Min , ImVec2 (progress_bb.Min .x + fraction * progress_bb.GetWidth (), progress_bb.Max .y ),
0 commit comments