mirror of https://github.com/PCSX2/pcsx2.git
FullscreenUI: Properly account for multiline Rich Presence in Title Info
This commit is contained in:
parent
62c0148472
commit
9a932e7dd5
|
@ -4574,10 +4574,8 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type)
|
|||
|
||||
// title info
|
||||
{
|
||||
const bool has_rich_presence = Achievements::IsActive() && !Achievements::GetRichPresenceString().empty();
|
||||
|
||||
const float image_width = has_rich_presence ? 60.0f : 50.0f;
|
||||
const float image_height = has_rich_presence ? 90.0f : 75.0f;
|
||||
const float image_width = 60.0f;
|
||||
const float image_height = 90.0f;
|
||||
const std::string_view path_string(Path::GetFileName(s_current_disc_path));
|
||||
const ImVec2 title_size(
|
||||
g_large_font->CalcTextSizeA(g_large_font->FontSize, std::numeric_limits<float>::max(), -1.0f, s_current_game_title.c_str()));
|
||||
|
@ -4596,6 +4594,29 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type)
|
|||
(path_string.empty() ? title_pos.y : path_pos.y) + g_medium_font->FontSize + LayoutScale(4.0f));
|
||||
|
||||
float rp_height = 0.0f;
|
||||
{
|
||||
const auto lock = Achievements::GetLock();
|
||||
const std::string& rp = Achievements::IsActive() ? Achievements::GetRichPresenceString() : std::string();
|
||||
|
||||
if (!rp.empty())
|
||||
{
|
||||
const float wrap_width = LayoutScale(350.0f);
|
||||
const ImVec2 rp_size = g_medium_font->CalcTextSizeA(
|
||||
g_medium_font->FontSize, std::numeric_limits<float>::max(), wrap_width, rp.data(), rp.data() + rp.length());
|
||||
|
||||
// Add a small extra gap if any Rich Presence is displayed
|
||||
rp_height = rp_size.y - g_medium_font->FontSize + 2.0f;
|
||||
|
||||
const ImVec2 rp_pos(display_size.x - LayoutScale(20.0f + 50.0f + 20.0f) - rp_size.x,
|
||||
subtitle_pos.y + g_medium_font->FontSize + LayoutScale(4.0f) - rp_height);
|
||||
|
||||
title_pos.y -= rp_height;
|
||||
path_pos.y -= rp_height;
|
||||
subtitle_pos.y -= rp_height;
|
||||
|
||||
DrawShadowedText(dl, g_medium_font, rp_pos, text_color, rp.data(), rp.data() + rp.length(), wrap_width);
|
||||
}
|
||||
}
|
||||
|
||||
DrawShadowedText(dl, g_large_font, title_pos, text_color, s_current_game_title.c_str());
|
||||
if (!path_string.empty())
|
||||
|
@ -4604,35 +4625,11 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type)
|
|||
}
|
||||
DrawShadowedText(dl, g_medium_font, subtitle_pos, text_color, s_current_game_subtitle.c_str());
|
||||
|
||||
if (has_rich_presence)
|
||||
{
|
||||
const auto lock = Achievements::GetLock();
|
||||
const std::string& rp = Achievements::GetRichPresenceString();
|
||||
if (!rp.empty())
|
||||
{
|
||||
const float wrap_width = LayoutScale(350.0f);
|
||||
const ImVec2 rp_size = g_medium_font->CalcTextSizeA(
|
||||
g_medium_font->FontSize, std::numeric_limits<float>::max(), wrap_width, rp.data(), rp.data() + rp.size());
|
||||
|
||||
// we make the image one line higher, so we only need to compensate when it's multiline RP
|
||||
rp_height = rp_size.y - g_medium_font->FontSize;
|
||||
|
||||
const ImVec2 rp_pos(display_size.x - LayoutScale(20.0f + 50.0f + 20.0f) - rp_size.x - rp_height,
|
||||
subtitle_pos.y + g_medium_font->FontSize + LayoutScale(4.0f));
|
||||
|
||||
title_pos.y -= rp_height;
|
||||
path_pos.y -= rp_height;
|
||||
subtitle_pos.y -= rp_height;
|
||||
|
||||
DrawShadowedText(dl, g_medium_font, rp_pos, text_color, rp.data(), rp.data() + rp.size(), wrap_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GSTexture* const cover = GetCoverForCurrentGame();
|
||||
const ImVec2 image_min(
|
||||
display_size.x - LayoutScale(10.0f + image_width) - rp_height, display_size.y - LayoutScale(10.0f + image_height) - rp_height);
|
||||
const ImVec2 image_max(image_min.x + LayoutScale(image_width) + rp_height, image_min.y + LayoutScale(image_height) + rp_height);
|
||||
display_size.x - LayoutScale(10.0f + image_width), display_size.y - LayoutScale(10.0f + image_height) - rp_height);
|
||||
const ImVec2 image_max(image_min.x + LayoutScale(image_width), image_min.y + LayoutScale(image_height) + rp_height);
|
||||
const ImRect image_rect(CenterImage(
|
||||
ImRect(image_min, image_max), ImVec2(static_cast<float>(cover->GetWidth()), static_cast<float>(cover->GetHeight()))));
|
||||
dl->AddImage(cover->GetNativeHandle(), image_rect.Min, image_rect.Max);
|
||||
|
|
Loading…
Reference in New Issue