From 6fd0b1917582edd0c99f8b2cea63fb0a9e23d4d9 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Wed, 2 Aug 2023 00:45:09 +0200 Subject: [PATCH] Fix "+1 Rank!" possibly overlapping with time trial time in CJK font If this text on the time trial results screen would overlap with the time value, all rank labels will be displayed on the header line instead ("TIME TAKEN:" etc). This works because the overlap with the time most likely only happens with CJK fonts (where the time will be very wide because of the font size) while strings like "TIME TAKEN" take up very little space due to only needing 4 characters or so for the same information. --- desktop_version/src/Render.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b63312dc..dab519e1 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1356,12 +1356,21 @@ static void menurender(void) std::string tempstring = game.resulttimestring() + loc::gettext(" / ") + game.timetstring(game.timetrialresultpar) + loc::gettext(".99"); + uint32_t plus1_flags = PR_RIGHT | PR_CJK_LOW; + int plus1_offset = 0; + if (font::len(0, tempstring.c_str()) + font::len(0, loc::gettext("+1 Rank!")) > (292-49)) + { + // Time and "+1 Rank!" don't fit together, so put it next to titles instead + plus1_flags = PR_RIGHT | PR_CJK_HIGH; + plus1_offset = -10; + } + graphics.drawspritesetcol(22, 80-15, 50, 22); font::print(PR_CJK_HIGH, 49, 80-15, loc::gettext("TIME TAKEN:"), 255, 255, 255); font::print(PR_CJK_LOW, 49, 90-15, tempstring, tr, tg, tb); if (game.timetrialresulttime <= game.timetrialresultpar) { - font::print(PR_RIGHT | PR_CJK_LOW, 292, 90-15, loc::gettext("+1 Rank!"), 255, 255, 255); + font::print(plus1_flags, 292, 90-15+plus1_offset, loc::gettext("+1 Rank!"), 255, 255, 255); } tempstring = help.String(game.timetrialresultdeaths); @@ -1370,7 +1379,7 @@ static void menurender(void) font::print(PR_CJK_LOW, 49, 90+20, tempstring, tr, tg, tb); if (game.timetrialresultdeaths == 0) { - font::print(PR_RIGHT | PR_CJK_LOW, 292, 90+20, loc::gettext("+1 Rank!"), 255, 255, 255); + font::print(plus1_flags, 292, 90+20+plus1_offset, loc::gettext("+1 Rank!"), 255, 255, 255); } char buffer[SCREEN_WIDTH_CHARS + 1]; @@ -1385,7 +1394,7 @@ static void menurender(void) font::print(PR_CJK_LOW, 49, 90+55, buffer, tr, tg, tb); if (game.timetrialresulttrinkets >= game.timetrialresultshinytarget) { - font::print(PR_RIGHT | PR_CJK_LOW, 292, 90+55, loc::gettext("+1 Rank!"), 255, 255, 255); + font::print(plus1_flags, 292, 90+55+plus1_offset, loc::gettext("+1 Rank!"), 255, 255, 255); } const char* rank = "";