@@ -90,7 +90,7 @@ static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f;
90
90
static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3 .0f ;
91
91
92
92
static 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 ;
94
94
95
95
// Some API calls are really slow. Set a longer timeout.
96
96
static constexpr float SERVER_CALL_TIMEOUT = 60 .0f ;
@@ -1039,7 +1039,7 @@ void Achievements::UpdateGameSummary(bool update_progress_database, bool force_u
1039
1039
void Achievements::UpdateRecentUnlockAndAlmostThere ()
1040
1040
{
1041
1041
const auto lock = GetLock ();
1042
- if (!IsActive ())
1042
+ if (!HasActiveGame ())
1043
1043
return ;
1044
1044
1045
1045
s_state.most_recent_unlock = nullptr ;
@@ -2402,17 +2402,22 @@ static float IndicatorOpacity(float delta_time, T& i)
2402
2402
void Achievements::DrawGameOverlays ()
2403
2403
{
2404
2404
using ImGuiFullscreen::LayoutScale;
2405
+ using ImGuiFullscreen::ModAlpha;
2406
+ using ImGuiFullscreen::RenderShadowedTextClipped;
2405
2407
using ImGuiFullscreen::UIStyle;
2406
2408
2407
2409
if (!HasActiveGame () || !g_settings.achievements_overlays )
2408
2410
return ;
2409
2411
2410
2412
const auto lock = GetLock ();
2411
2413
2414
+ constexpr float overlay_opacity = 0 .8f ;
2415
+
2412
2416
const float margin =
2413
2417
std::max (ImCeil (ImGuiManager::GetScreenMargin () * ImGuiManager::GetGlobalScale ()), LayoutScale (10 .0f ));
2414
2418
const float spacing = LayoutScale (10 .0f );
2415
2419
const float padding = LayoutScale (10 .0f );
2420
+ const float rounding = LayoutScale (10 .0f );
2416
2421
const ImVec2 image_size =
2417
2422
LayoutScale (ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT);
2418
2423
const ImGuiIO& io = ImGui::GetIO ();
@@ -2428,13 +2433,12 @@ void Achievements::DrawGameOverlays()
2428
2433
{
2429
2434
AchievementChallengeIndicator& indicator = *it;
2430
2435
const float opacity = IndicatorOpacity (io.DeltaTime , indicator);
2431
- const u32 col = ImGui::GetColorU32 (ImVec4 (1 .0f , 1 .0f , 1 .0f , opacity));
2432
2436
2433
2437
GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync (indicator.badge_path );
2434
2438
if (badge)
2435
2439
{
2436
2440
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)) );
2438
2442
current_position.x -= x_advance;
2439
2443
}
2440
2444
@@ -2455,8 +2459,7 @@ void Achievements::DrawGameOverlays()
2455
2459
if (s_state.active_progress_indicator .has_value ())
2456
2460
{
2457
2461
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;
2460
2463
2461
2464
const char * text_start = s_state.active_progress_indicator ->achievement ->measured_progress ;
2462
2465
const char * text_end = text_start + std::strlen (text_start);
@@ -2466,23 +2469,23 @@ void Achievements::DrawGameOverlays()
2466
2469
const ImVec2 box_min = ImVec2 (position.x - image_size.x - text_size.x - spacing - padding * 2 .0f ,
2467
2470
position.y - image_size.y - padding * 2 .0f );
2468
2471
const ImVec2 box_max = position;
2469
- const float box_rounding = LayoutScale (1 .0f );
2470
2472
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);
2473
2474
2474
2475
GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync (indicator.badge_path );
2475
2476
if (badge)
2476
2477
{
2477
2478
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)));
2479
2481
}
2480
2482
2481
2483
const ImVec2 text_pos =
2482
2484
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);
2486
2489
2487
2490
if (!indicator.active && opacity <= 0 .01f )
2488
2491
{
@@ -2498,7 +2501,7 @@ void Achievements::DrawGameOverlays()
2498
2501
for (auto it = s_state.active_leaderboard_trackers .begin (); it != s_state.active_leaderboard_trackers .end ();)
2499
2502
{
2500
2503
LeaderboardTrackerIndicator& indicator = *it;
2501
- const float opacity = IndicatorOpacity (io.DeltaTime , indicator);
2504
+ const float opacity = IndicatorOpacity (io.DeltaTime , indicator) * overlay_opacity ;
2502
2505
2503
2506
TinyString width_string;
2504
2507
width_string.append (ICON_FA_STOPWATCH);
@@ -2507,25 +2510,22 @@ void Achievements::DrawGameOverlays()
2507
2510
const ImVec2 size = ImGuiFullscreen::UIStyle.MediumFont ->CalcTextSizeA (
2508
2511
ImGuiFullscreen::UIStyle.MediumFont ->FontSize , FLT_MAX, 0 .0f , width_string.c_str (), width_string.end_ptr ());
2509
2512
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);
2516
2516
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));
2518
2518
const ImVec2 text_size = ImGuiFullscreen::UIStyle.MediumFont ->CalcTextSizeA (
2519
2519
ImGuiFullscreen::UIStyle.MediumFont ->FontSize , FLT_MAX, 0 .0f , indicator.text .c_str (),
2520
2520
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 );
2525
2525
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 );
2529
2529
2530
2530
if (!indicator.active && opacity <= 0 .01f )
2531
2531
{
@@ -2537,7 +2537,7 @@ void Achievements::DrawGameOverlays()
2537
2537
++it;
2538
2538
}
2539
2539
2540
- position.x = box_min .x - padding;
2540
+ position.x = box. Min .x - padding;
2541
2541
}
2542
2542
2543
2543
// Uncomment if there are any other overlays above this one.
@@ -2577,16 +2577,11 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
2577
2577
2578
2578
ImDrawList* dl = ImGui::GetBackgroundDrawList ();
2579
2579
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) {
2582
2582
const ImVec2 description_size = UIStyle.MediumFont ->CalcTextSizeA (UIStyle.MediumFont ->FontSize , FLT_MAX,
2583
2583
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 ;
2590
2585
return std::max (text_height, badge_size);
2591
2586
};
2592
2587
@@ -2612,9 +2607,8 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
2612
2607
dl->AddRectFilled (box_min, box_max, box_background_color, box_rounding);
2613
2608
2614
2609
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) {
2618
2612
const ImVec2 image_max = ImVec2 (text_pos.x + badge_size, text_pos.y + badge_size);
2619
2613
ImVec2 badge_text_pos = ImVec2 (image_max.x + text_spacing + text_spacing, text_pos.y );
2620
2614
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)
2633
2627
nullptr , badge_text_width, &clip_rect);
2634
2628
badge_text_pos.y += description_size.y ;
2635
2629
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
-
2658
2630
text_pos.y = badge_text_pos.y ;
2659
2631
};
2660
2632
0 commit comments