Skip to content

Commit be81bf5

Browse files
committed
FSUI: Adjust sizes to match new font sizes
1 parent ea99636 commit be81bf5

File tree

6 files changed

+73
-57
lines changed

6 files changed

+73
-57
lines changed

pcsx2/Achievements.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,7 @@ void Achievements::DrawPauseMenuOverlays()
22542254
{
22552255
using ImGuiFullscreen::g_large_font;
22562256
using ImGuiFullscreen::g_medium_font;
2257+
using ImGuiFullscreen::GetLineHeight;
22572258
using ImGuiFullscreen::LayoutScale;
22582259

22592260
if (!HasActiveGame())
@@ -2269,14 +2270,14 @@ void Achievements::DrawPauseMenuOverlays()
22692270

22702271
const ImVec2 image_size(
22712272
LayoutScale(ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY));
2272-
const float start_y = LayoutScale(10.0f + 4.0f + 4.0f) + g_large_font.second + (g_medium_font.second * 2.0f);
2273+
const float start_y = LayoutScale(10.0f + 4.0f + 4.0f) + GetLineHeight(g_large_font) + (GetLineHeight(g_medium_font) * 2.0f);
22732274
const float margin = LayoutScale(10.0f);
22742275
const float spacing = LayoutScale(10.0f);
22752276
const float padding = LayoutScale(10.0f);
22762277

22772278
const float max_text_width = ImGuiFullscreen::LayoutScale(300.0f);
22782279
const float row_width = max_text_width + padding + padding + image_size.x + spacing;
2279-
const float title_height = padding + font.second + padding;
2280+
const float title_height = padding + GetLineHeight(font) + padding;
22802281

22812282
if (!s_active_challenge_indicators.empty())
22822283
{
@@ -2290,7 +2291,7 @@ void Achievements::DrawPauseMenuOverlays()
22902291
TRANSLATE("Achievements", "Active Challenge Achievements"));
22912292

22922293
const float y_advance = image_size.y + spacing;
2293-
const float acheivement_name_offset = (image_size.y - font.second) / 2.0f;
2294+
const float acheivement_name_offset = (image_size.y - GetLineHeight(font)) / 2.0f;
22942295
const float max_non_ellipised_text_width = max_text_width - LayoutScale(10.0f);
22952296
ImVec2 position(box_min.x + padding, box_min.y + title_height);
22962297

@@ -2350,6 +2351,7 @@ void Achievements::DrawAchievementsWindow()
23502351
{
23512352
using ImGuiFullscreen::g_large_font;
23522353
using ImGuiFullscreen::g_medium_font;
2354+
using ImGuiFullscreen::GetLineHeight;
23532355
using ImGuiFullscreen::LayoutScale;
23542356

23552357
if (!s_achievement_list)
@@ -2408,19 +2410,19 @@ void Achievements::DrawAchievementsWindow()
24082410
FullscreenUI::ReturnToPreviousWindow();
24092411
}
24102412

2411-
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + g_large_font.second));
2413+
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + GetLineHeight(g_large_font)));
24122414
text.assign(s_game_title);
24132415

24142416
if (s_hardcore_mode)
24152417
text.append(TRANSLATE_SV("Achievements", " (Hardcore Mode)"));
24162418

2417-
top += g_large_font.second + spacing;
2419+
top += GetLineHeight(g_large_font) + spacing;
24182420

24192421
ImGui::PushFont(g_large_font.first, g_large_font.second);
24202422
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), &title_bb);
24212423
ImGui::PopFont();
24222424

2423-
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font.second));
2425+
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + GetLineHeight(g_medium_font)));
24242426
if (s_game_summary.num_core_achievements > 0)
24252427
{
24262428
if (s_game_summary.num_unlocked_achievements == s_game_summary.num_core_achievements)
@@ -2440,7 +2442,7 @@ void Achievements::DrawAchievementsWindow()
24402442
text.assign(TRANSLATE_SV("Achievements", "This game has no achievements."));
24412443
}
24422444

2443-
top += g_medium_font.second + spacing;
2445+
top += GetLineHeight(g_medium_font) + spacing;
24442446

24452447
ImGui::PushFont(g_medium_font.first, g_medium_font.second);
24462448
ImGui::RenderTextClipped(
@@ -2541,6 +2543,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
25412543
{
25422544
using ImGuiFullscreen::g_large_font;
25432545
using ImGuiFullscreen::g_medium_font;
2546+
using ImGuiFullscreen::GetLineHeight;
25442547
using ImGuiFullscreen::LayoutScale;
25452548
using ImGuiFullscreen::LayoutUnscale;
25462549

@@ -2564,7 +2567,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
25642567
cheevo->description + summary_length));
25652568

25662569
// Messy, but need to undo LayoutScale in MenuButtonFrame()...
2567-
const float extra_summary_height = LayoutUnscale(std::max(summary_text_size.y - g_medium_font.second, 0.0f));
2570+
const float extra_summary_height = LayoutUnscale(std::max(summary_text_size.y - GetLineHeight(g_medium_font), 0.0f));
25682571

25692572
ImRect bb;
25702573
bool visible, hovered;
@@ -2602,7 +2605,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
26022605

26032606
SmallString text;
26042607

2605-
const float midpoint = bb.Min.y + g_large_font.second + spacing;
2608+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + spacing;
26062609
text.format((cheevo->points != 1) ? TRANSLATE_FS("Achievements", "{} points") : TRANSLATE_FS("Achievements", "{} point"), cheevo->points);
26072610

26082611
const ImVec2 points_size(g_medium_font.first->CalcTextSizeA(g_medium_font.second, FLT_MAX, 0.0f, text.c_str(), text.end_ptr()));
@@ -2635,7 +2638,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
26352638

26362639
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
26372640
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(points_start, midpoint));
2638-
const ImRect summary_bb(ImVec2(text_start_x, midpoint), ImVec2(points_start, midpoint + g_medium_font.second + extra_summary_height));
2641+
const ImRect summary_bb(ImVec2(text_start_x, midpoint), ImVec2(points_start, midpoint + GetLineHeight(g_medium_font) + extra_summary_height));
26392642
const ImRect points_bb(ImVec2(points_start, midpoint), bb.Max);
26402643
const ImRect lock_bb(
26412644
ImVec2(points_template_start + ((points_template_size.x - right_icon_size.x) * 0.5f), bb.Min.y), ImVec2(bb.Max.x, midpoint));
@@ -2664,7 +2667,7 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
26642667
ImDrawList* dl = ImGui::GetWindowDrawList();
26652668
const float progress_height = LayoutScale(progress_height_unscaled);
26662669
const float progress_spacing = LayoutScale(progress_spacing_unscaled);
2667-
const float top = midpoint + g_medium_font.second + progress_spacing;
2670+
const float top = midpoint + GetLineHeight(g_medium_font) + progress_spacing;
26682671
const ImRect progress_bb(ImVec2(text_start_x, top), ImVec2(bb.Max.x, top + progress_height));
26692672
const float fraction = cheevo->measured_percent * 0.01f;
26702673
dl->AddRectFilled(progress_bb.Min, progress_bb.Max, ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryDarkColor));
@@ -2710,6 +2713,7 @@ void Achievements::DrawLeaderboardsWindow()
27102713
{
27112714
using ImGuiFullscreen::g_large_font;
27122715
using ImGuiFullscreen::g_medium_font;
2716+
using ImGuiFullscreen::GetLineHeight;
27132717
using ImGuiFullscreen::LayoutScale;
27142718

27152719
static constexpr float alpha = 0.8f;
@@ -2809,21 +2813,21 @@ void Achievements::DrawLeaderboardsWindow()
28092813
}
28102814
}
28112815

2812-
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + g_large_font.second));
2816+
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + GetLineHeight(g_large_font)));
28132817
text.assign(Achievements::GetGameTitle());
28142818

2815-
top += g_large_font.second + spacing;
2819+
top += GetLineHeight(g_large_font) + spacing;
28162820

28172821
ImGui::PushFont(g_large_font.first, g_large_font.second);
28182822
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), &title_bb);
28192823
ImGui::PopFont();
28202824

28212825
if (is_leaderboard_open)
28222826
{
2823-
const ImRect subtitle_bb(ImVec2(left, top), ImVec2(right, top + g_large_font.second));
2827+
const ImRect subtitle_bb(ImVec2(left, top), ImVec2(right, top + GetLineHeight(g_large_font)));
28242828
text.assign(s_open_leaderboard->title);
28252829

2826-
top += g_large_font.second + spacing_small;
2830+
top += GetLineHeight(g_large_font) + spacing_small;
28272831

28282832
ImGui::PushFont(g_large_font.first, g_large_font.second);
28292833
ImGui::RenderTextClipped(
@@ -2840,17 +2844,17 @@ void Achievements::DrawLeaderboardsWindow()
28402844
text.format(TRANSLATE_FS("Achievements", "This game has {} leaderboards."), count);
28412845
}
28422846

2843-
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font.second));
2844-
top += g_medium_font.second + spacing_small;
2847+
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + GetLineHeight(g_medium_font)));
2848+
top += GetLineHeight(g_medium_font) + spacing_small;
28452849

28462850
ImGui::PushFont(g_medium_font.first, g_medium_font.second);
28472851
ImGui::RenderTextClipped(
28482852
summary_bb.Min, summary_bb.Max, text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
28492853

28502854
if (!is_leaderboard_open && !Achievements::IsHardcoreModeActive())
28512855
{
2852-
const ImRect hardcore_warning_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font.second));
2853-
top += g_medium_font.second + spacing_small;
2856+
const ImRect hardcore_warning_bb(ImVec2(left, top), ImVec2(right, top + GetLineHeight(g_medium_font)));
2857+
top += GetLineHeight(g_medium_font) + spacing_small;
28542858

28552859
ImGui::RenderTextClipped(hardcore_warning_bb.Min, hardcore_warning_bb.Max,
28562860
TRANSLATE("Achievements", "Submitting scores is disabled because hardcore mode is off. Leaderboards are read-only."),
@@ -2895,7 +2899,7 @@ void Achievements::DrawLeaderboardsWindow()
28952899
ImGuiFullscreen::MenuButtonFrame(
28962900
"legend", false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, &visible, &hovered, &bb.Min, &bb.Max, 0, alpha);
28972901

2898-
const float midpoint = bb.Min.y + g_large_font.second + LayoutScale(4.0f);
2902+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
28992903
const float icon_column_width = bb.Max.y - bb.Min.y;
29002904
float column_left = bb.Min.x + LayoutScale(15.0f) + padding;
29012905

@@ -2937,7 +2941,7 @@ void Achievements::DrawLeaderboardsWindow()
29372941

29382942
const float line_thickness = LayoutScale(1.0f);
29392943
const float line_padding = LayoutScale(5.0f);
2940-
const ImVec2 line_start(bb.Min.x, bb.Min.y + g_large_font.second + line_padding);
2944+
const ImVec2 line_start(bb.Min.x, bb.Min.y + GetLineHeight(g_large_font) + line_padding);
29412945
const ImVec2 line_end(bb.Max.x, line_start.y);
29422946
ImGui::GetWindowDrawList()->AddLine(line_start, line_end, ImGui::GetColorU32(ImGuiCol_TextDisabled), line_thickness);
29432947
}
@@ -3027,7 +3031,7 @@ void Achievements::DrawLeaderboardsWindow()
30273031
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, &visible, &hovered, &bb.Min, &bb.Max);
30283032
if (visible)
30293033
{
3030-
const float midpoint = bb.Min.y + g_large_font.second + LayoutScale(4.0f);
3034+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
30313035
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
30323036

30333037
ImGui::PushFont(g_large_font.first, g_large_font.second);
@@ -3071,6 +3075,7 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
30713075
float name_column_width, float time_column_width, float column_spacing)
30723076
{
30733077
using ImGuiFullscreen::g_large_font;
3078+
using ImGuiFullscreen::GetLineHeight;
30743079
using ImGuiFullscreen::LayoutScale;
30753080

30763081
static constexpr float alpha = 0.8f;
@@ -3082,7 +3087,7 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
30823087
if (!visible)
30833088
return;
30843089

3085-
const float midpoint = bb.Min.y + g_large_font.second + LayoutScale(4.0f);
3090+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
30863091
const float column_padding = LayoutScale(15.0f);
30873092
const float icon_column_width = bb.Max.y - bb.Min.y;
30883093
float column_left = bb.Min.x + column_padding;
@@ -3151,6 +3156,7 @@ void Achievements::DrawLeaderboardListEntry(const rc_client_leaderboard_t* lboar
31513156
{
31523157
using ImGuiFullscreen::g_large_font;
31533158
using ImGuiFullscreen::g_medium_font;
3159+
using ImGuiFullscreen::GetLineHeight;
31543160
using ImGuiFullscreen::LayoutScale;
31553161

31563162
static constexpr float alpha = 0.8f;
@@ -3172,7 +3178,7 @@ void Achievements::DrawLeaderboardListEntry(const rc_client_leaderboard_t* lboar
31723178
s_restore_leaderboard_focus = false;
31733179
}
31743180

3175-
const float midpoint = bb.Min.y + g_large_font.second + LayoutScale(4.0f);
3181+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
31763182
const float text_start_x = bb.Min.x + LayoutScale(15.0f);
31773183
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
31783184
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);

pcsx2/ImGui/FullscreenUI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ using ImGuiFullscreen::GetCachedSvgTexture;
154154
using ImGuiFullscreen::GetCachedSvgTextureAsync;
155155
using ImGuiFullscreen::GetCachedTexture;
156156
using ImGuiFullscreen::GetCachedTextureAsync;
157+
using ImGuiFullscreen::GetLineHeight;
157158
using ImGuiFullscreen::GetPlaceholderTexture;
158159
using ImGuiFullscreen::GetQueuedFocusResetType;
159160
using ImGuiFullscreen::HorizontalMenuItem;
@@ -2258,7 +2259,7 @@ void FullscreenUI::DrawInputBindingButton(
22582259
}
22592260
}
22602261

2261-
const float midpoint = bb.Min.y + g_large_font.second + LayoutScale(4.0f);
2262+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
22622263

22632264
if (oneline)
22642265
{
@@ -8012,7 +8013,7 @@ void FullscreenUI::DrawGameList(const ImVec2& heading_size)
80128013

80138014
DrawGameCover(entry, ImGui::GetWindowDrawList(), bb.Min, bb.Min + image_size);
80148015

8015-
const float midpoint = bb.Min.y + g_large_font.second + LayoutScale(4.0f);
8016+
const float midpoint = bb.Min.y + GetLineHeight(g_large_font) + LayoutScale(4.0f);
80168017
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
80178018
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
80188019
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);

pcsx2/ImGui/ImGuiFullscreen.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ bool ImGuiFullscreen::MenuButton(const char* title, const char* summary, bool en
14041404
if (!visible)
14051405
return false;
14061406

1407-
const float midpoint = bb.Min.y + font.second + LayoutScale(4.0f);
1407+
const float midpoint = bb.Min.y + GetLineHeight(font) + LayoutScale(4.0f);
14081408
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
14091409
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
14101410

@@ -1437,7 +1437,7 @@ bool ImGuiFullscreen::MenuButtonWithoutSummary(const char* title, bool enabled,
14371437
if (!visible)
14381438
return false;
14391439

1440-
const float midpoint = bb.Min.y + font.second + LayoutScale(4.0f);
1440+
const float midpoint = bb.Min.y + GetLineHeight(font) + LayoutScale(4.0f);
14411441
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
14421442
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
14431443

@@ -1467,7 +1467,7 @@ bool ImGuiFullscreen::MenuImageButton(const char* title, const char* summary, Im
14671467
ImGui::GetWindowDrawList()->AddImage(user_texture_id, bb.Min, bb.Min + image_size, uv0, uv1,
14681468
enabled ? IM_COL32(255, 255, 255, 255) : ImGui::GetColorU32(ImGuiCol_TextDisabled));
14691469

1470-
const float midpoint = bb.Min.y + title_font.second + LayoutScale(4.0f);
1470+
const float midpoint = bb.Min.y + GetLineHeight(title_font) + LayoutScale(4.0f);
14711471
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
14721472
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
14731473
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
@@ -1592,7 +1592,7 @@ bool ImGuiFullscreen::ToggleButton(
15921592
if (!visible)
15931593
return false;
15941594

1595-
const float midpoint = bb.Min.y + font.second + LayoutScale(4.0f);
1595+
const float midpoint = bb.Min.y + GetLineHeight(font) + LayoutScale(4.0f);
15961596
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
15971597
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
15981598

@@ -1663,7 +1663,7 @@ bool ImGuiFullscreen::ThreeWayToggleButton(
16631663
if (!visible)
16641664
return false;
16651665

1666-
const float midpoint = bb.Min.y + font.second + LayoutScale(4.0f);
1666+
const float midpoint = bb.Min.y + GetLineHeight(font) + LayoutScale(4.0f);
16671667
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
16681668
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
16691669

@@ -1742,7 +1742,7 @@ bool ImGuiFullscreen::MenuButtonWithValue(
17421742

17431743
const ImVec2 value_size(ImGui::CalcTextSize(value));
17441744

1745-
const float midpoint = bb.Min.y + font.second + LayoutScale(4.0f);
1745+
const float midpoint = bb.Min.y + GetLineHeight(font) + LayoutScale(4.0f);
17461746
const float text_end = bb.Max.x - value_size.x;
17471747
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
17481748
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));

pcsx2/ImGui/ImGuiFullscreen.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ namespace ImGuiFullscreen
2828

2929
static constexpr float LAYOUT_SCREEN_WIDTH = 1280.0f;
3030
static constexpr float LAYOUT_SCREEN_HEIGHT = 720.0f;
31-
static constexpr float LAYOUT_LARGE_FONT_SIZE = 26.0f;
32-
static constexpr float LAYOUT_MEDIUM_FONT_SIZE = 16.0f;
31+
static constexpr float LAYOUT_LARGE_FONT_SIZE = 22.0f;
32+
static constexpr float LAYOUT_MEDIUM_FONT_SIZE = 14.0f;
3333
static constexpr float LAYOUT_SMALL_FONT_SIZE = 10.0f;
3434
static constexpr float LAYOUT_MENU_BUTTON_HEIGHT = 50.0f;
3535
static constexpr float LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY = 26.0f;
@@ -71,6 +71,9 @@ namespace ImGuiFullscreen
7171
static __fi float LayoutScale(float v) { return ImCeil(g_layout_scale * v); }
7272
static __fi ImVec2 LayoutScale(const ImVec2& v) { return ImVec2(ImCeil(v.x * g_layout_scale), ImCeil(v.y * g_layout_scale)); }
7373
static __fi ImVec2 LayoutScale(float x, float y) { return ImVec2(ImCeil(x * g_layout_scale), ImCeil(y * g_layout_scale)); }
74+
/// Get the height of a line of text including the space to the next line.
75+
/// Matches the result returned by CalcTextSizeA for one line of text.
76+
static __fi float GetLineHeight(std::pair<ImFont*, float> font) { return ImCeil(font.second * font.first->LineHeight); }
7477

7578
static __fi float LayoutUnscale(float v) { return ImCeil(g_rcp_layout_scale * v); }
7679
static __fi ImVec2 LayoutUnscale(const ImVec2& v) { return ImVec2(ImCeil(v.x * g_rcp_layout_scale), ImCeil(v.y * g_rcp_layout_scale)); }

0 commit comments

Comments
 (0)