From 00d55ba05846f52dc6d7e4724e377ae6ed548137 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 31 May 2025 22:27:05 +0300 Subject: [PATCH] Add new music credit draw style, 'songcredits Box' --- src/g_game.c | 3 ++- src/hu_stuff.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 8eb394756..e046a4f6e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -385,7 +385,8 @@ consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, N consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // Display song credits -consvar_t cv_songcredits = {"songcredits", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t songcredits_cons_t[] = {{0, "Off"}, {1, "Default"}, {2, "Box"}, {0, NULL}}; +consvar_t cv_songcredits = {"songcredits", "Default", CV_SAVE, songcredits_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // Show "FREE PLAY" when you're alone. :( consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index b7d0c10d9..f8f0524b2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2131,7 +2131,7 @@ void HU_TickSongCredits(void) } } -void HU_DrawSongCredits(void) +static void HU_DrawSongCreditsVanilla(void) { char *str; INT32 len; @@ -2139,9 +2139,6 @@ void HU_DrawSongCredits(void) INT32 y = (splitscreen ? (BASEVIDHEIGHT/2)-4 : 32); INT32 bgt; - if (!cursongcredit.def) // No def - return; - str = va("\x1F"" %s", cursongcredit.def->source); len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE); destx = (len + 7) * FRACUNIT; @@ -2171,6 +2168,70 @@ void HU_DrawSongCredits(void) V_DrawRightAlignedThinString(cursongcredit.x / FRACUNIT, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans<source; + INT32 strwidth = V_SmallStringWidth(str, V_ALLOWLOWERCASE) + 4; + + // dup dup dup dup + INT32 dup = min(vid.dupx, vid.dupy); + + // Center it + INT32 x = (BASEVIDWIDTH/2 - strwidth/2)*dup + ((vid.width - (BASEVIDWIDTH * vid.dupx)) / 2); + INT32 y = 0; + + INT32 flags = V_SNAPTOTOP|V_NOSCALESTART; + INT32 t = cursongcredit.anim; + INT32 bgt; + + fixed_t interpoffset = FixedMul(BOXCREDITHEIGHT*dup*FRACUNIT/(TICRATE/2), R_GetHudUncap()); + + if (t > BOXCREDITSLIDEIN) + { + // Sliding in + t = TICRATE/2 - (t - BOXCREDITSLIDEIN); + y = -BOXCREDITHEIGHT*dup + (FixedMul(BOXCREDITHEIGHT*FRACUNIT, FixedDiv(t*FRACUNIT, TICRATE*FRACUNIT/2))*dup + interpoffset)/FRACUNIT; + } + else if (t < TICRATE/2) + { + // Sliding out + y = -BOXCREDITHEIGHT*dup + (FixedMul(BOXCREDITHEIGHT*FRACUNIT, FixedDiv(t*FRACUNIT, TICRATE*FRACUNIT/2))*dup - interpoffset)/FRACUNIT; + } + + bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans/2); + + if (bgt < NUMTRANSMAPS) + { + V_DrawFill(x, y, strwidth*dup, BOXCREDITHEIGHT*dup, 28|flags|(bgt<