From 2e687b4033ae913155ea31d28304b95e4bedb91e Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 3 Apr 2023 21:10:09 +0100 Subject: [PATCH] Sound credits no longer go off the screen Uses V_ThinStringWidth to check whether it'd exceed BASEVIDWIDTH. Does not apply to the main song title - if that exceeds the width of the screen, just visibly fail. --- src/s_sound.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 4825d63e6..789a1b83b 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -34,6 +34,7 @@ #include "k_menu.h" // M_PlayMenuJam #include "m_random.h" // P_RandomKey #include "i_time.h" +#include "v_video.h" // V_ThinStringWidth #ifdef HW3SOUND // 3D Sound Interface @@ -2079,6 +2080,7 @@ void S_ShowMusicCredit(void) char credittext[128] = ""; char *work = NULL; size_t len = 128, worklen; + INT32 widthused = BASEVIDWIDTH, workwidth; if (!cv_songcredits.value || S_PlaysimMusicDisabled()) return; @@ -2109,6 +2111,8 @@ void S_ShowMusicCredit(void) } } + widthused -= V_ThinStringWidth(credittext, V_ALLOWLOWERCASE|V_6WIDTHSPACE); + #define MUSICCREDITAPPEND(field)\ if (field)\ {\ @@ -2116,8 +2120,13 @@ void S_ShowMusicCredit(void) worklen = strlen(work);\ if (worklen <= len)\ {\ - strncat(credittext, work, len);\ - len -= worklen;\ + workwidth = V_ThinStringWidth(work, V_ALLOWLOWERCASE|V_6WIDTHSPACE);\ + if (widthused >= workwidth)\ + {\ + strncat(credittext, work, len);\ + len -= worklen;\ + widthused -= workwidth;\ + }\ }\ }