Minor touchups/cleanup

This commit is contained in:
SeventhSentinel 2019-01-04 16:47:03 -05:00
parent 5d51754936
commit 3e37d131ed
5 changed files with 39 additions and 29 deletions

View file

@ -294,7 +294,7 @@ void HU_LoadGraphics(void)
tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX); tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX);
tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX);
songcreditbg = W_CachePatchName("MUSCRED", PU_HUDGFX); songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX);
} }
// Initialise Heads up // Initialise Heads up
@ -2059,45 +2059,39 @@ static void HU_DrawDemoInfo(void)
// //
// Song credits // Song credits
// //
boolean songcreditinit = false;
static void HU_DrawSongCredits(void) static void HU_DrawSongCredits(void)
{ {
static UINT8 transparency = NUMTRANSMAPS; const char *str = va("\x1F"" %s", songCredits[cursongcredit.index].info);
static INT32 x = 0; INT32 len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE);
UINT16 len = V_ThinStringWidth(songCredits[cursongcredit.index].info, V_ALLOWLOWERCASE|V_6WIDTHSPACE); INT32 destx = (len+7);
INT32 y = (splitscreen ? (BASEVIDHEIGHT/2)-4 : 32);
INT32 bgt; INT32 bgt;
if (!songcreditinit)
{
memset(&cursongcredit,0,sizeof(struct cursongcredit));
songcreditinit = true;
return;
}
if (cursongcredit.anim) if (cursongcredit.anim)
{ {
if (transparency > 0) if (cursongcredit.trans > 0)
transparency--; cursongcredit.trans--;
if (x < (len+16)) if (cursongcredit.x < destx)
x += ((len+16) - x) / 2; cursongcredit.x += (destx - cursongcredit.x) / 2;
if (cursongcredit.x > destx)
cursongcredit.x = destx;
cursongcredit.anim--; cursongcredit.anim--;
} }
else else
{ {
if (transparency < NUMTRANSMAPS) if (cursongcredit.trans < NUMTRANSMAPS)
transparency++; cursongcredit.trans++;
if (x > 0) if (cursongcredit.x > 0)
x /= 2; cursongcredit.x /= 2;
if (cursongcredit.x < 0)
cursongcredit.x = 0;
} }
//V_DrawThinString(0, 0, 0, transparency); bgt = (NUMTRANSMAPS/2)+(cursongcredit.trans/2);
bgt = (NUMTRANSMAPS/2)+(transparency/2);
if (bgt < NUMTRANSMAPS) if (bgt < NUMTRANSMAPS)
V_DrawScaledPatch(x, 30, V_SNAPTOLEFT|(bgt<<V_ALPHASHIFT), songcreditbg); V_DrawScaledPatch(cursongcredit.x, y-2, V_SNAPTOLEFT|(bgt<<V_ALPHASHIFT), songcreditbg);
if (transparency < NUMTRANSMAPS) if (cursongcredit.trans < NUMTRANSMAPS)
V_DrawThinString(x-len-10, 32, V_SNAPTOLEFT|V_ALLOWLOWERCASE|V_6WIDTHSPACE|(transparency<<V_ALPHASHIFT), va("\x1F"" %s", songCredits[cursongcredit.index].info)); V_DrawRightAlignedThinString(cursongcredit.x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans<<V_ALPHASHIFT), str);
} }
// Heads up displays drawer, call each frame // Heads up displays drawer, call each frame

View file

@ -2304,6 +2304,10 @@ static void P_LevelInitStuff(void)
// earthquake camera // earthquake camera
memset(&quake,0,sizeof(struct quake)); memset(&quake,0,sizeof(struct quake));
// song credit init
memset(&cursongcredit,0,sizeof(struct cursongcredit));
cursongcredit.trans = NUMTRANSMAPS;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
#if 0 #if 0

View file

@ -1744,6 +1744,8 @@ void S_InitMusicCredit(void)
{ {
cursongcredit.index = i; cursongcredit.index = i;
cursongcredit.anim = 5*TICRATE; cursongcredit.anim = 5*TICRATE;
cursongcredit.x = 0;
cursongcredit.trans = NUMTRANSMAPS;
return; // Don't return when there's SOC support, to see if there's any "replacement" credits? return; // Don't return when there's SOC support, to see if there's any "replacement" credits?
} }
} }

View file

@ -133,6 +133,8 @@ extern struct cursongcredit
{ {
UINT16 index; UINT16 index;
UINT16 anim; UINT16 anim;
INT32 x;
UINT8 trans;
} cursongcredit; } cursongcredit;
typedef struct typedef struct

View file

@ -2266,6 +2266,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option)
{ {
INT32 c, w = 0; INT32 c, w = 0;
INT32 spacewidth = 2, charwidth = 0; INT32 spacewidth = 2, charwidth = 0;
boolean lowercase = (option & V_ALLOWLOWERCASE);
size_t i; size_t i;
switch (option & V_SPACINGMASK) switch (option & V_SPACINGMASK)
@ -2289,14 +2290,21 @@ INT32 V_ThinStringWidth(const char *string, INT32 option)
if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09
continue; continue;
c = toupper(c) - HU_FONTSTART; if (!lowercase || !tny_font[c-HU_FONTSTART])
c = toupper(c);
c -= HU_FONTSTART;
if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) if (c < 0 || c >= HU_FONTSIZE || !tny_font[c])
w += spacewidth; w += spacewidth;
else else
{
w += (charwidth ? charwidth w += (charwidth ? charwidth
: (option & V_6WIDTHSPACE ? max(1, SHORT(tny_font[c]->width)-1) : SHORT(tny_font[c]->width))); // Reuse this flag for the alternate bunched-up spacing : ((option & V_6WIDTHSPACE && i < strlen(string)-1) ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing
: SHORT(tny_font[c]->width)));
}
} }
return w; return w;
} }