From fcc5c8e0c4a3cd379cf42f56c293c99d1d9d2fd5 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 25 Dec 2021 04:57:35 -0500 Subject: [PATCH] Interpolate music credits --- src/hu_stuff.c | 173 +++++++++++++++++++++++++++++++++---------------- src/s_sound.c | 2 +- src/s_sound.h | 3 +- src/v_video.c | 12 ++++ src/v_video.h | 2 + 5 files changed, 134 insertions(+), 58 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7afc7d531..059bc00f8 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -56,6 +56,7 @@ #include "k_kart.h" #include "k_color.h" #include "k_hud.h" +#include "r_fps.h" // coords are scaled #define HU_INPUTX 0 @@ -165,6 +166,8 @@ static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; static INT32 cechoflags = 0; +static tic_t resynch_ticker = 0; + //====================================================================== // HEADS UP INIT //====================================================================== @@ -892,6 +895,64 @@ static inline boolean HU_keyInChatString(char *s, char ch) // // +static void HU_TickSongCredits(void) +{ + char *str; + INT32 len; + fixed_t destx; + + cursongcredit.old_x = cursongcredit.x; + + if (!cursongcredit.def) // No def + { + cursongcredit.x = cursongcredit.old_x = 0; + cursongcredit.anim = 0; + cursongcredit.trans = NUMTRANSMAPS; + return; + } + + str = va("\x1F"" %s", cursongcredit.def->source); + len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE); + destx = (len+7) * FRACUNIT; + + if (cursongcredit.anim > 0) + { + if (cursongcredit.trans > 0) + { + cursongcredit.trans--; + } + + if (cursongcredit.x < destx) + { + cursongcredit.x += (destx - cursongcredit.x) / 2; + } + + if (cursongcredit.x > destx) + { + cursongcredit.x = destx; + } + + cursongcredit.anim--; + } + else + { + if (cursongcredit.trans < NUMTRANSMAPS) + { + cursongcredit.trans++; + } + + if (cursongcredit.x > 0) + { + cursongcredit.x /= 2; + } + + if (cursongcredit.x < 0) + { + cursongcredit.x = 0; + } + } +} + void HU_Ticker(void) { if (dedicated) @@ -906,6 +967,49 @@ void HU_Ticker(void) hu_showscores = false; hu_keystrokes = false; + + if (chat_on) + { + // count down the scroll timer. + if (chat_scrolltime > 0) + chat_scrolltime--; + } + else + { + chat_scrolltime = 0; + } + + if (netgame) // would handle that in hu_drawminichat, but it's actually kinda awkward when you're typing a lot of messages. (only handle that in netgames duh) + { + size_t i = 0; + + // handle spam while we're at it: + for(; (i 0) + stop_spamming[i]--; + } + + // handle chat timers + for (i=0; (i 0) + chat_timers[i]--; + else + HU_removeChatText_Mini(); + } + } + + cechotimer--; + + if (gamestate != GS_LEVEL) + { + return; + } + + resynch_ticker++; + + HU_TickSongCredits(); } #ifndef NONET @@ -1887,8 +1991,6 @@ static void HU_DrawCEcho(void) echoptr = line; echoptr++; } - - --cechotimer; } // @@ -1938,42 +2040,28 @@ static void HU_DrawDemoInfo(void) void HU_DrawSongCredits(void) { char *str; - INT32 len, destx; - INT32 y = (r_splitscreen ? (BASEVIDHEIGHT/2)-4 : 32); + fixed_t x; + fixed_t y = (r_splitscreen ? (BASEVIDHEIGHT/2)-4 : 32) * FRACUNIT; 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); + bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans / 2); + x = R_InterpolateFixed(cursongcredit.old_x, cursongcredit.x); - if (cursongcredit.anim) - { - if (cursongcredit.trans > 0) - cursongcredit.trans--; - if (cursongcredit.x < destx) - cursongcredit.x += (destx - cursongcredit.x) / 2; - if (cursongcredit.x > destx) - cursongcredit.x = destx; - cursongcredit.anim--; - } - else - { - if (cursongcredit.trans < NUMTRANSMAPS) - cursongcredit.trans++; - if (cursongcredit.x > 0) - cursongcredit.x /= 2; - if (cursongcredit.x < 0) - cursongcredit.x = 0; - } - - bgt = (NUMTRANSMAPS/2)+(cursongcredit.trans/2); if (bgt < NUMTRANSMAPS) - V_DrawScaledPatch(cursongcredit.x, y-2, V_SNAPTOLEFT|(bgt< 0) - chat_scrolltime--; if (!OLDCHAT) HU_DrawChat(); else @@ -1999,31 +2084,9 @@ void HU_Drawer(void) else { typelines = 1; - chat_scrolltime = 0; if (!OLDCHAT && cv_consolechat.value < 2 && netgame) // Don't display minimized chat if you set the mode to Window (Hidden) HU_drawMiniChat(); // draw messages in a cool fashion. } - - if (netgame) // would handle that in hu_drawminichat, but it's actually kinda awkward when you're typing a lot of messages. (only handle that in netgames duh) - { - size_t i = 0; - - // handle spam while we're at it: - for(; (i 0) - stop_spamming[i]--; - } - - // handle chat timers - for (i=0; (i 0) - chat_timers[i]--; - else - HU_removeChatText_Mini(); - } - } #endif if (cechotimer) @@ -2062,12 +2125,10 @@ void HU_Drawer(void) // draw desynch text if (hu_redownloadinggamestate) { - static UINT32 resynch_ticker = 0; char resynch_text[14]; UINT32 i; // Animate the dots - resynch_ticker++; strcpy(resynch_text, "Resynching"); for (i = 0; i < (resynch_ticker / 16) % 4; i++) strcat(resynch_text, "."); diff --git a/src/s_sound.c b/src/s_sound.c index 7e44bb207..ac66a5777 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1580,7 +1580,7 @@ void S_ShowMusicCredit(void) { cursongcredit.def = def; cursongcredit.anim = 5*TICRATE; - cursongcredit.x = 0; + cursongcredit.x = cursongcredit.old_x =0; cursongcredit.trans = NUMTRANSMAPS; return; } diff --git a/src/s_sound.h b/src/s_sound.h index 816a90fb5..3e6decf74 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -179,8 +179,9 @@ extern struct cursongcredit { musicdef_t *def; UINT16 anim; - INT32 x; UINT8 trans; + fixed_t x; + fixed_t old_x; } cursongcredit; extern musicdef_t *musicdefstart; diff --git a/src/v_video.c b/src/v_video.c index 5bd7ba733..abaee0886 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2216,6 +2216,18 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st V_DrawThinString(x, y, option, string); } +void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= (V_ThinStringWidth(string, option) / 2) * FRACUNIT; + V_DrawThinStringAtFixed(x, y, option, string); +} + +void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_ThinStringWidth(string, option) * FRACUNIT; + V_DrawThinStringAtFixed(x, y, option, string); +} + // Draws a number using the PING font thingy. // TODO: Merge number drawing functions into one with "font name" selection. diff --git a/src/v_video.h b/src/v_video.h index da4506c9a..402f485a4 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -261,6 +261,8 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st #define V_DrawThinStringAtFixed( x,y,option,string ) \ V__DrawOneScaleString (x,y,FRACUNIT,option,TINY_FONT,string) +void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); +void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); // Draws a titlecard font string. // timer: when the letters start appearing (leave to 0 to disable)