From a7ca3c176879d9326a725a0a12173958969ed633 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 14 Mar 2024 06:18:25 -0700 Subject: [PATCH] HUD: switch viewpoint text to thin font if it becomes too wide - 200 px limit in Race (GTR_CIRCUIT) - 100 px limit in Battle (GTR_BUMPERS) --- src/st_stuff.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 335359ef7..a1ea8e790 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1286,6 +1286,24 @@ static void ST_overlayDrawer(void) INT32 y = (BASEVIDHEIGHT / (r_splitscreen + 1)) - 34; INT32 width = 50; + const char *text = player_names[stplyr-players]; + int font = KART_FONT; + fixed_t textwidth = V_StringScaledWidth(FRACUNIT, FRACUNIT, FRACUNIT, flags, font, text); + fixed_t threshold = textwidth; + + // k_drawKartHUD + if (gametyperules & GTR_CIRCUIT) + threshold = 200*FRACUNIT; + else if (gametyperules & GTR_BUMPERS) + threshold = 100*FRACUNIT; + + if (LUA_HudEnabled(hud_gametypeinfo) && textwidth > threshold) + { + y += 5; + font = TINY_FONT; + textwidth = V_StringScaledWidth(FRACUNIT, FRACUNIT, FRACUNIT, flags, font, text); + } + if (r_splitscreen) { flags = (flags & ~V_ALPHAMASK) | V_HUDTRANSHALF; @@ -1297,10 +1315,8 @@ static void ST_overlayDrawer(void) V_DrawCenteredThinString(x, y, flags | V_ORANGEMAP, "Watching"); } - const char *text = player_names[stplyr-players]; - fixed_t textwidth = V_StringScaledWidth(FRACUNIT, FRACUNIT, FRACUNIT, flags, KART_FONT, text); V_DrawStringScaled(x*FRACUNIT - textwidth/2, (y+10)*FRACUNIT, - FRACUNIT, FRACUNIT, FRACUNIT, flags, NULL, KART_FONT, text); + FRACUNIT, FRACUNIT, FRACUNIT, flags, NULL, font, text); } else {