@@ -101,6 +101,7 @@ using ImGuiFullscreen::BeginMenuButtons;
101
101
using ImGuiFullscreen::BeginNavBar;
102
102
using ImGuiFullscreen::CancelPendingMenuClose;
103
103
using ImGuiFullscreen::CenterImage;
104
+ using ImGuiFullscreen::DarkerColor;
104
105
using ImGuiFullscreen::DefaultActiveButton;
105
106
using ImGuiFullscreen::DrawShadowedText;
106
107
using ImGuiFullscreen::EndFixedPopupModal;
@@ -6399,106 +6400,95 @@ void FullscreenUI::DrawPatchesOrCheatsSettingsPage(bool cheats)
6399
6400
6400
6401
void FullscreenUI::DrawPauseMenu ()
6401
6402
{
6403
+ static constexpr float top_bar_height = 90 .0f ;
6404
+ static constexpr float top_bar_padding = 10 .0f ;
6405
+
6402
6406
SmallString buffer;
6403
6407
6404
6408
ImDrawList* dl = ImGui::GetBackgroundDrawList ();
6405
6409
const ImVec2 display_size (ImGui::GetIO ().DisplaySize );
6406
- const ImU32 text_color = ImGui::GetColorU32 (UIStyle.BackgroundTextColor ) | IM_COL32_A_MASK;
6407
- dl->AddRectFilled (ImVec2 (0 .0f , 0 .0f ), display_size - LayoutScale (0 .0f , LAYOUT_FOOTER_HEIGHT),
6408
- (ImGui::GetColorU32 (UIStyle.BackgroundColor ) & ~IM_COL32_A_MASK) | (200 << IM_COL32_A_SHIFT));
6410
+ const ImU32 title_text_color = ImGui::GetColorU32 (UIStyle.BackgroundTextColor );
6411
+ const ImU32 text_color = ImGui::GetColorU32 (DarkerColor (UIStyle.BackgroundTextColor ));
6409
6412
6410
- // title info
6413
+ // top bar
6414
+ const float scaled_top_bar_height = LayoutScale (top_bar_height);
6411
6415
{
6416
+ const float scaled_text_spacing = LayoutScale (4 .0f );
6417
+ const float scaled_top_bar_padding = LayoutScale (top_bar_padding);
6418
+ dl->AddRectFilled (ImVec2 (0 .0f , 0 .0f ), ImVec2 (display_size.x , scaled_top_bar_height),
6419
+ ImGui::GetColorU32 (ModAlpha (UIStyle.BackgroundColor , 0 .95f )), 0 .0f );
6420
+
6421
+ GPUTexture* const cover = GetCoverForCurrentGame ();
6422
+ const float image_padding = LayoutScale (5 .0f ); // compensate for font baseline
6423
+ const float image_size = scaled_top_bar_height - scaled_top_bar_padding - scaled_top_bar_padding - image_padding;
6424
+ const ImRect image_rect (
6425
+ CenterImage (ImRect (scaled_top_bar_padding + image_padding, scaled_top_bar_padding + image_padding,
6426
+ scaled_top_bar_padding + image_size, scaled_top_bar_padding + image_size),
6427
+ ImVec2 (static_cast <float >(cover->GetWidth ()), static_cast <float >(cover->GetHeight ()))));
6428
+ dl->AddImage (cover, image_rect.Min , image_rect.Max );
6429
+
6412
6430
if (!s_state.current_game_serial .empty ())
6413
6431
buffer.format (" {} - {}" , s_state.current_game_serial , Path::GetFileName (s_state.current_game_path ));
6414
6432
else
6415
6433
buffer.assign (Path::GetFileName (s_state.current_game_path ));
6416
6434
6417
- const float image_width = 60 .0f ;
6418
- const float image_height = 60 .0f ;
6419
-
6420
- const ImVec2 title_size (UIStyle.LargeFont ->CalcTextSizeA (
6421
- UIStyle.LargeFont ->FontSize , std::numeric_limits<float >::max (), -1 .0f , s_state.current_game_title .c_str (),
6422
- s_state.current_game_title .c_str () + s_state.current_game_title .size ()));
6423
- const ImVec2 subtitle_size (UIStyle.MediumFont ->CalcTextSizeA (
6424
- UIStyle.MediumFont ->FontSize , std::numeric_limits<float >::max (), -1 .0f , buffer.c_str (), buffer.end_ptr ()));
6425
-
6426
- ImVec2 title_pos (display_size.x - LayoutScale (10 .0f + image_width + 20 .0f ) - title_size.x ,
6427
- display_size.y - LayoutScale (LAYOUT_FOOTER_HEIGHT) - LayoutScale (10 .0f + image_height));
6428
- ImVec2 subtitle_pos (display_size.x - LayoutScale (10 .0f + image_width + 20 .0f ) - subtitle_size.x ,
6429
- title_pos.y + UIStyle.LargeFont ->FontSize + LayoutScale (4 .0f ));
6435
+ ImVec2 text_pos = ImVec2 (scaled_top_bar_padding + image_size + scaled_top_bar_padding, scaled_top_bar_padding);
6436
+ DrawShadowedText (dl, UIStyle.LargeFont , text_pos, title_text_color, s_state.current_game_title .c_str (),
6437
+ s_state.current_game_title .c_str () + s_state.current_game_title .size ());
6438
+ text_pos.y += UIStyle.LargeFont ->FontSize + scaled_text_spacing;
6430
6439
6431
- float rp_height = 0 . 0f ;
6440
+ if ( Achievements::IsActive ())
6432
6441
{
6433
6442
const auto lock = Achievements::GetLock ();
6434
- const std::string& rp = Achievements::IsActive () ? Achievements::GetRichPresenceString () : std::string ();
6435
-
6436
- if (!rp.empty ())
6443
+ if (const std::string& rp = Achievements::GetRichPresenceString (); !rp.empty ())
6437
6444
{
6438
- const float wrap_width = LayoutScale (350 .0f );
6439
- const ImVec2 rp_size =
6440
- UIStyle.MediumFont ->CalcTextSizeA (UIStyle.MediumFont ->FontSize , std::numeric_limits<float >::max (), wrap_width,
6441
- rp.data (), rp.data () + rp.length ());
6442
-
6443
- // Add a small extra gap if any Rich Presence is displayed
6444
- rp_height = rp_size.y - UIStyle.MediumFont ->FontSize + LayoutScale (2 .0f );
6445
-
6446
- const ImVec2 rp_pos (display_size.x - LayoutScale (20 .0f + 50 .0f + 20 .0f ) - rp_size.x ,
6447
- subtitle_pos.y + UIStyle.MediumFont ->FontSize + LayoutScale (4 .0f ) - rp_height);
6448
-
6449
- title_pos.y -= rp_height;
6450
- subtitle_pos.y -= rp_height;
6451
-
6452
- DrawShadowedText (dl, UIStyle.MediumFont , rp_pos, text_color, rp.data (), rp.data () + rp.length (), wrap_width);
6445
+ DrawShadowedText (dl, UIStyle.MediumFont , text_pos, title_text_color, rp.data (), rp.data () + rp.length ());
6446
+ text_pos.y += UIStyle.MediumFont ->FontSize + scaled_text_spacing;
6453
6447
}
6454
6448
}
6455
6449
6456
- DrawShadowedText (dl, UIStyle.LargeFont , title_pos, text_color, s_state.current_game_title .c_str (),
6457
- s_state.current_game_title .c_str () + s_state.current_game_title .size ());
6458
- DrawShadowedText (dl, UIStyle.MediumFont , subtitle_pos, text_color, buffer.c_str (), buffer.end_ptr ());
6450
+ DrawShadowedText (dl, UIStyle.MediumFont , text_pos, text_color, buffer.c_str (), buffer.end_ptr ());
6459
6451
6460
- GPUTexture* const cover = GetCoverForCurrentGame ();
6461
- const ImVec2 image_min (display_size.x - LayoutScale (10 .0f + image_width),
6462
- display_size.y - LayoutScale (LAYOUT_FOOTER_HEIGHT) - LayoutScale (10 .0f + image_height) -
6463
- rp_height);
6464
- const ImVec2 image_max (image_min.x + LayoutScale (image_width), image_min.y + LayoutScale (image_height) + rp_height);
6465
- const ImRect image_rect (CenterImage (ImRect (image_min, image_max), ImVec2 (static_cast <float >(cover->GetWidth ()),
6466
- static_cast <float >(cover->GetHeight ()))));
6467
- dl->AddImage (cover, image_rect.Min , image_rect.Max );
6468
- }
6469
-
6470
- // current time / play time
6471
- {
6452
+ // current time / play time
6472
6453
buffer.format (" {:%X}" , fmt::localtime (std::time (nullptr )));
6473
6454
6474
- const ImVec2 time_size (UIStyle.LargeFont ->CalcTextSizeA (
6475
- UIStyle.LargeFont ->FontSize , std::numeric_limits<float >::max (), -1 .0f , buffer.c_str (), buffer.end_ptr ()));
6476
- const ImVec2 time_pos (display_size.x - LayoutScale (10 .0f ) - time_size.x , LayoutScale (10 .0f ));
6477
- DrawShadowedText (dl, UIStyle.LargeFont , time_pos, text_color, buffer.c_str (), buffer.end_ptr ());
6455
+ ImVec2 text_size = UIStyle.LargeFont ->CalcTextSizeA (UIStyle.LargeFont ->FontSize , std::numeric_limits<float >::max (),
6456
+ -1 .0f , buffer.c_str (), buffer.end_ptr ());
6457
+ text_pos = ImVec2 (display_size.x - scaled_top_bar_padding - text_size.x , scaled_top_bar_padding);
6458
+ DrawShadowedText (dl, UIStyle.LargeFont , text_pos, title_text_color, buffer.c_str (), buffer.end_ptr ());
6459
+ text_pos.y += UIStyle.LargeFont ->FontSize + scaled_text_spacing;
6478
6460
6479
6461
if (!s_state.current_game_serial .empty ())
6480
6462
{
6481
6463
const std::time_t cached_played_time = GameList::GetCachedPlayedTimeForSerial (s_state.current_game_serial );
6482
6464
const std::time_t session_time = static_cast <std::time_t >(System::GetSessionPlayedTime ());
6483
6465
6484
6466
buffer.format (FSUI_FSTR (" Session: {}" ), GameList::FormatTimespan (session_time, true ));
6485
- const ImVec2 session_size (UIStyle.MediumFont ->CalcTextSizeA (
6467
+ text_size = ImVec2 (UIStyle.MediumFont ->CalcTextSizeA (
6486
6468
UIStyle.MediumFont ->FontSize , std::numeric_limits<float >::max (), -1 .0f , buffer.c_str (), buffer.end_ptr ()));
6487
- const ImVec2 session_pos ( display_size.x - LayoutScale ( 10 . 0f ) - session_size. x ,
6488
- time_pos. y + UIStyle. LargeFont -> FontSize + LayoutScale ( 4 . 0f ));
6489
- DrawShadowedText (dl, UIStyle.MediumFont , session_pos, text_color, buffer. c_str (), buffer. end_ptr ()) ;
6469
+ text_pos. x = display_size.x - scaled_top_bar_padding - text_size. x ;
6470
+ DrawShadowedText (dl, UIStyle. MediumFont , text_pos, text_color, buffer. c_str (), buffer. end_ptr ( ));
6471
+ text_pos. y += UIStyle.MediumFont -> FontSize + scaled_text_spacing ;
6490
6472
6491
6473
buffer.format (FSUI_FSTR (" All Time: {}" ), GameList::FormatTimespan (cached_played_time + session_time, true ));
6492
- const ImVec2 total_size (UIStyle.MediumFont ->CalcTextSizeA (
6474
+ text_size = ImVec2 (UIStyle.MediumFont ->CalcTextSizeA (
6493
6475
UIStyle.MediumFont ->FontSize , std::numeric_limits<float >::max (), -1 .0f , buffer.c_str (), buffer.end_ptr ()));
6494
- const ImVec2 total_pos ( display_size.x - LayoutScale ( 10 . 0f ) - total_size. x ,
6495
- session_pos. y + UIStyle.MediumFont -> FontSize + LayoutScale ( 4 . 0f ));
6496
- DrawShadowedText (dl, UIStyle.MediumFont , total_pos, text_color, buffer. c_str (), buffer. end_ptr ()) ;
6476
+ text_pos. x = display_size.x - scaled_top_bar_padding - text_size. x ;
6477
+ DrawShadowedText (dl, UIStyle.MediumFont , text_pos, text_color, buffer. c_str (), buffer. end_ptr ( ));
6478
+ text_pos. y += UIStyle.MediumFont -> FontSize + scaled_text_spacing ;
6497
6479
}
6498
6480
}
6499
6481
6500
- const ImVec2 window_size (LayoutScale (500 .0f , LAYOUT_SCREEN_HEIGHT));
6501
- const ImVec2 window_pos (0 .0f , display_size.y - LayoutScale (LAYOUT_FOOTER_HEIGHT) - window_size.y );
6482
+ const ImVec2 window_size (LayoutScale (500 .0f ),
6483
+ display_size.y - scaled_top_bar_height - LayoutScale (LAYOUT_FOOTER_HEIGHT));
6484
+ const ImVec2 window_pos (0 .0f , scaled_top_bar_height);
6485
+
6486
+ // background
6487
+ dl->AddRectFilled (ImVec2 (0 .0f , scaled_top_bar_height),
6488
+ ImVec2 (display_size.x , display_size.x - scaled_top_bar_height - LayoutScale (LAYOUT_FOOTER_HEIGHT)),
6489
+ ImGui::GetColorU32 (ModAlpha (UIStyle.BackgroundColor , 0 .85f )));
6490
+
6491
+ Achievements::DrawPauseMenuOverlays ();
6502
6492
6503
6493
if (BeginFullscreenWindow (window_pos, window_size, " pause_menu" , ImVec4 (0 .0f , 0 .0f , 0 .0f , 0 .0f ), 0 .0f ,
6504
6494
ImVec2 (10 .0f , 10 .0f ), ImGuiWindowFlags_NoBackground))
0 commit comments