@@ -90,7 +90,7 @@ static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f;
9090static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3 .0f ;
9191
9292static constexpr float INDICATOR_FADE_IN_TIME = 0 .1f ;
93- static constexpr float INDICATOR_FADE_OUT_TIME = 0 .5f ;
93+ static constexpr float INDICATOR_FADE_OUT_TIME = 0 .3f ;
9494
9595// Some API calls are really slow. Set a longer timeout.
9696static constexpr float SERVER_CALL_TIMEOUT = 60 .0f ;
@@ -1039,7 +1039,7 @@ void Achievements::UpdateGameSummary(bool update_progress_database, bool force_u
10391039void Achievements::UpdateRecentUnlockAndAlmostThere ()
10401040{
10411041 const auto lock = GetLock ();
1042- if (!IsActive ())
1042+ if (!HasActiveGame ())
10431043 return ;
10441044
10451045 s_state.most_recent_unlock = nullptr ;
@@ -2402,17 +2402,22 @@ static float IndicatorOpacity(float delta_time, T& i)
24022402void Achievements::DrawGameOverlays ()
24032403{
24042404 using ImGuiFullscreen::LayoutScale;
2405+ using ImGuiFullscreen::ModAlpha;
2406+ using ImGuiFullscreen::RenderShadowedTextClipped;
24052407 using ImGuiFullscreen::UIStyle;
24062408
24072409 if (!HasActiveGame () || !g_settings.achievements_overlays )
24082410 return ;
24092411
24102412 const auto lock = GetLock ();
24112413
2414+ constexpr float overlay_opacity = 0 .8f ;
2415+
24122416 const float margin =
24132417 std::max (ImCeil (ImGuiManager::GetScreenMargin () * ImGuiManager::GetGlobalScale ()), LayoutScale (10 .0f ));
24142418 const float spacing = LayoutScale (10 .0f );
24152419 const float padding = LayoutScale (10 .0f );
2420+ const float rounding = LayoutScale (10 .0f );
24162421 const ImVec2 image_size =
24172422 LayoutScale (ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT , ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT );
24182423 const ImGuiIO& io = ImGui::GetIO ();
@@ -2428,13 +2433,12 @@ void Achievements::DrawGameOverlays()
24282433 {
24292434 AchievementChallengeIndicator& indicator = *it;
24302435 const float opacity = IndicatorOpacity (io.DeltaTime , indicator);
2431- const u32 col = ImGui::GetColorU32 (ImVec4 (1 .0f , 1 .0f , 1 .0f , opacity));
24322436
24332437 GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync (indicator.badge_path );
24342438 if (badge)
24352439 {
24362440 dl->AddImage (badge, current_position, current_position + image_size, ImVec2 (0 .0f , 0 .0f ), ImVec2 (1 .0f , 1 .0f ),
2437- col );
2441+ ImGui::GetColorU32 ( ImVec4 ( 1 . 0f , 1 . 0f , 1 . 0f , opacity)) );
24382442 current_position.x -= x_advance;
24392443 }
24402444
@@ -2455,8 +2459,7 @@ void Achievements::DrawGameOverlays()
24552459 if (s_state.active_progress_indicator .has_value ())
24562460 {
24572461 AchievementProgressIndicator& indicator = s_state.active_progress_indicator .value ();
2458- const float opacity = IndicatorOpacity (io.DeltaTime , indicator);
2459- const u32 col = ImGui::GetColorU32 (ImVec4 (1 .0f , 1 .0f , 1 .0f , opacity));
2462+ const float opacity = IndicatorOpacity (io.DeltaTime , indicator) * overlay_opacity;
24602463
24612464 const char * text_start = s_state.active_progress_indicator ->achievement ->measured_progress ;
24622465 const char * text_end = text_start + std::strlen (text_start);
@@ -2466,23 +2469,23 @@ void Achievements::DrawGameOverlays()
24662469 const ImVec2 box_min = ImVec2 (position.x - image_size.x - text_size.x - spacing - padding * 2 .0f ,
24672470 position.y - image_size.y - padding * 2 .0f );
24682471 const ImVec2 box_max = position;
2469- const float box_rounding = LayoutScale (1 .0f );
24702472
2471- dl->AddRectFilled (box_min, box_max, ImGui::GetColorU32 (ImVec4 (0 .13f , 0 .13f , 0 .13f , opacity * 0 .5f )), box_rounding);
2472- dl->AddRect (box_min, box_max, ImGui::GetColorU32 (ImVec4 (0 .8f , 0 .8f , 0 .8f , opacity)), box_rounding);
2473+ dl->AddRectFilled (box_min, box_max, ImGui::GetColorU32 (ModAlpha (UIStyle.ToastBackgroundColor , opacity)), rounding);
24732474
24742475 GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync (indicator.badge_path );
24752476 if (badge)
24762477 {
24772478 const ImVec2 badge_pos = box_min + ImVec2 (padding, padding);
2478- dl->AddImage (badge, badge_pos, badge_pos + image_size, ImVec2 (0 .0f , 0 .0f ), ImVec2 (1 .0f , 1 .0f ), col);
2479+ dl->AddImage (badge, badge_pos, badge_pos + image_size, ImVec2 (0 .0f , 0 .0f ), ImVec2 (1 .0f , 1 .0f ),
2480+ ImGui::GetColorU32 (ImVec4 (1 .0f , 1 .0f , 1 .0f , opacity)));
24792481 }
24802482
24812483 const ImVec2 text_pos =
24822484 box_min + ImVec2 (padding + image_size.x + spacing, (box_max.y - box_min.y - text_size.y ) * 0 .5f );
2483- const ImVec4 text_clip_rect (text_pos.x , text_pos.y , box_max.x , box_max.y );
2484- dl->AddText (UIStyle.MediumFont , UIStyle.MediumFont ->FontSize , text_pos, col, text_start, text_end, 0 .0f ,
2485- &text_clip_rect);
2485+ const ImRect text_clip_rect (text_pos, box_max);
2486+ RenderShadowedTextClipped (dl, UIStyle.MediumFont , text_pos, box_max,
2487+ ImGui::GetColorU32 (ModAlpha (UIStyle.ToastTextColor , opacity)), text_start, text_end,
2488+ &text_size, ImVec2 (0 .0f , 0 .0f ), 0 .0f , &text_clip_rect);
24862489
24872490 if (!indicator.active && opacity <= 0 .01f )
24882491 {
@@ -2498,7 +2501,7 @@ void Achievements::DrawGameOverlays()
24982501 for (auto it = s_state.active_leaderboard_trackers .begin (); it != s_state.active_leaderboard_trackers .end ();)
24992502 {
25002503 LeaderboardTrackerIndicator& indicator = *it;
2501- const float opacity = IndicatorOpacity (io.DeltaTime , indicator);
2504+ const float opacity = IndicatorOpacity (io.DeltaTime , indicator) * overlay_opacity ;
25022505
25032506 TinyString width_string;
25042507 width_string.append (ICON_FA_STOPWATCH );
@@ -2507,25 +2510,22 @@ void Achievements::DrawGameOverlays()
25072510 const ImVec2 size = ImGuiFullscreen::UIStyle.MediumFont ->CalcTextSizeA (
25082511 ImGuiFullscreen::UIStyle.MediumFont ->FontSize , FLT_MAX , 0 .0f , width_string.c_str (), width_string.end_ptr ());
25092512
2510- const ImVec2 box_min = ImVec2 (position.x - size.x - padding * 2 .0f , position.y - size.y - padding * 2 .0f );
2511- const ImVec2 box_max = position;
2512- const float box_rounding = LayoutScale (1 .0f );
2513- dl->AddRectFilled (box_min, box_max, ImGui::GetColorU32 (ImVec4 (0 .13f , 0 .13f , 0 .13f , opacity * 0 .5f )),
2514- box_rounding);
2515- dl->AddRect (box_min, box_max, ImGui::GetColorU32 (ImVec4 (0 .8f , 0 .8f , 0 .8f , opacity)), box_rounding);
2513+ const ImRect box (ImVec2 (position.x - size.x - padding * 2 .0f , position.y - size.y - padding * 2 .0f ), position);
2514+ dl->AddRectFilled (box.Min , box.Max , ImGui::GetColorU32 (ModAlpha (UIStyle.ToastBackgroundColor , opacity)),
2515+ rounding);
25162516
2517- const u32 text_col = ImGui::GetColorU32 (ImVec4 ( 1 . 0f , 1 . 0f , 1 . 0f , opacity));
2517+ const u32 text_col = ImGui::GetColorU32 (ModAlpha (UIStyle. ToastTextColor , opacity));
25182518 const ImVec2 text_size = ImGuiFullscreen::UIStyle.MediumFont ->CalcTextSizeA (
25192519 ImGuiFullscreen::UIStyle.MediumFont ->FontSize , FLT_MAX , 0 .0f , indicator.text .c_str (),
25202520 indicator.text .c_str () + indicator.text .length ());
2521- const ImVec2 text_pos = ImVec2 (box_max. x - padding - text_size.x , box_min .y + padding);
2522- const ImVec4 text_clip_rect (box_min. x , box_min. y , box_max. x , box_max. y );
2523- dl-> AddText (UIStyle. MediumFont , UIStyle. MediumFont -> FontSize , text_pos, text_col, indicator.text .c_str (),
2524- indicator. text . c_str () + indicator. text . length (), 0 . 0f , &text_clip_rect );
2521+ const ImVec2 text_pos = ImVec2 (box. Max . x - padding - text_size.x , box. Min .y + padding);
2522+ RenderShadowedTextClipped (dl, UIStyle. MediumFont , text_pos, box. Max , text_col, indicator. text . c_str (),
2523+ indicator.text .c_str () + indicator. text . length (), &text_size, ImVec2 ( 0 . 0f , 0 . 0f ), 0 . 0f ,
2524+ &box );
25252525
2526- const ImVec2 icon_pos = ImVec2 (box_min. x + padding, box_min .y + padding);
2527- dl-> AddText (UIStyle. MediumFont , UIStyle.MediumFont -> FontSize , icon_pos, text_col, ICON_FA_STOPWATCH , nullptr ,
2528- 0 .0f , &text_clip_rect );
2526+ const ImVec2 icon_pos = ImVec2 (box. Min . x + padding, box. Min .y + padding);
2527+ RenderShadowedTextClipped (dl , UIStyle.MediumFont , icon_pos, box. Max , text_col, ICON_FA_STOPWATCH , nullptr ,
2528+ nullptr , ImVec2 ( 0 .0f , 0 . 0f ), 0 . 0f , &box );
25292529
25302530 if (!indicator.active && opacity <= 0 .01f )
25312531 {
@@ -2537,7 +2537,7 @@ void Achievements::DrawGameOverlays()
25372537 ++it;
25382538 }
25392539
2540- position.x = box_min .x - padding;
2540+ position.x = box. Min .x - padding;
25412541 }
25422542
25432543 // Uncomment if there are any other overlays above this one.
@@ -2577,16 +2577,11 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
25772577
25782578 ImDrawList* dl = ImGui::GetBackgroundDrawList ();
25792579
2580- const auto get_achievement_height = [&badge_size, &badge_text_width, &text_spacing, &progress_height](
2581- const rc_client_achievement_t * achievement, bool show_measured) {
2580+ const auto get_achievement_height = [&badge_size, &badge_text_width,
2581+ &text_spacing]( const rc_client_achievement_t * achievement, bool show_measured) {
25822582 const ImVec2 description_size = UIStyle.MediumFont ->CalcTextSizeA (UIStyle.MediumFont ->FontSize , FLT_MAX ,
25832583 badge_text_width, achievement->description );
2584- float text_height = UIStyle.MediumFont ->FontSize + text_spacing + description_size.y ;
2585- #if 0
2586- if (show_measured && achievement->measured_percent > 0.0f)
2587- text_height += text_spacing + progress_height;
2588- #endif
2589-
2584+ const float text_height = UIStyle.MediumFont ->FontSize + text_spacing + description_size.y ;
25902585 return std::max (text_height, badge_size);
25912586 };
25922587
@@ -2612,9 +2607,8 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
26122607 dl->AddRectFilled (box_min, box_max, box_background_color, box_rounding);
26132608
26142609 const auto draw_achievement_with_summary = [&box_max, &badge_text_width, &dl, &title_text_color, &text_color,
2615- &text_spacing, ¶graph_spacing, &text_pos, &progress_height,
2616- &badge_size](const rc_client_achievement_t * achievement,
2617- bool show_measured) {
2610+ &text_spacing, &text_pos, &badge_size](
2611+ const rc_client_achievement_t * achievement, bool show_measured) {
26182612 const ImVec2 image_max = ImVec2 (text_pos.x + badge_size, text_pos.y + badge_size);
26192613 ImVec2 badge_text_pos = ImVec2 (image_max.x + text_spacing + text_spacing, text_pos.y );
26202614 const ImVec4 clip_rect = ImVec4 (badge_text_pos.x , badge_text_pos.y , badge_text_pos.x + badge_text_width, box_max.y );
@@ -2633,28 +2627,6 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
26332627 nullptr , badge_text_width, &clip_rect);
26342628 badge_text_pos.y += description_size.y ;
26352629
2636- if (show_measured && achievement->measured_percent > 0 .0f )
2637- {
2638- #if 0
2639- // not a fan of the way this looks
2640- badge_text_pos.y += text_spacing;
2641-
2642- const float progress_fraction = static_cast<float>(achievement->measured_percent) / 100.0f;
2643- const ImRect progress_bb(badge_text_pos, badge_text_pos + ImVec2(badge_text_width, progress_height));
2644- const u32 progress_color = ImGui::GetColorU32(DarkerColor(UIStyle.SecondaryColor));
2645- dl->AddRectFilled(progress_bb.Min, progress_bb.Max, ImGui::GetColorU32(UIStyle.PrimaryDarkColor));
2646- dl->AddRectFilled(progress_bb.Min,
2647- ImVec2(progress_bb.Min.x + progress_fraction * progress_bb.GetWidth(), progress_bb.Max.y),
2648- progress_color);
2649- const ImVec2 text_size =
2650- UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, achievement->measured_progress);
2651- dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize,
2652- ImVec2(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
2653- progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f)),
2654- text_color, achievement->measured_progress);
2655- #endif
2656- }
2657-
26582630 text_pos.y = badge_text_pos.y ;
26592631 };
26602632
0 commit comments