Make credits font functions use the generalized functions.

This commit is contained in:
spherallic 2022-02-05 14:40:05 +01:00
parent b8cae8e735
commit 412381da4c
4 changed files with 17 additions and 101 deletions

View file

@ -62,13 +62,13 @@
//-------------------------------------------
fontdef_t hu_font;
fontdef_t tny_font;
fontdef_t cred_font;
patch_t *tallnum[10]; // 0-9
patch_t *nightsnum[10]; // 0-9
// Level title and credits fonts
// Level title fonts
patch_t *lt_font[LT_FONTSIZE];
patch_t *cred_font[CRED_FONTSIZE];
patch_t *ttlnum[10]; // act numbers (0-9)
// Name tag fonts
@ -204,6 +204,13 @@ void HU_LoadGraphics(void)
tny_font.chars[i] = NULL;
else
tny_font.chars[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
// cache the credits font for entire game execution (why not?)
sprintf(buffer, "CRFNT%.3d", j);
if (W_CheckNumForName(buffer) == LUMPERROR)
cred_font.chars[i] = NULL;
else
cred_font.chars[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
hu_font.kerning = 0;
@ -214,6 +221,10 @@ void HU_LoadGraphics(void)
tny_font.spacewidth = 2;
tny_font.linespacing = 12;
cred_font.kerning = 0;
cred_font.spacewidth = 16;
cred_font.linespacing = 16;
j = LT_FONTSTART;
for (i = 0; i < LT_FONTSIZE; i++)
{
@ -226,19 +237,6 @@ void HU_LoadGraphics(void)
lt_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// cache the credits font for entire game execution (why not?)
j = CRED_FONTSTART;
for (i = 0; i < CRED_FONTSIZE; i++)
{
sprintf(buffer, "CRFNT%.3d", j);
j++;
if (W_CheckNumForName(buffer) == LUMPERROR)
cred_font[i] = NULL;
else
cred_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
//cache numbers too!
for (i = 0; i < 10; i++)
{

View file

@ -23,7 +23,6 @@
//------------------------------------
#define HU_FONTSTART '\x16' // the first font character
#define HU_FONTEND '~'
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
// Level title font
@ -31,10 +30,6 @@
#define LT_FONTEND 'z' // the last font characters
#define LT_FONTSIZE (LT_FONTEND - LT_FONTSTART + 1)
#define CRED_FONTSTART '!' // the first font character
#define CRED_FONTEND 'Z' // the last font character
#define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1)
// Name tag font
// Used by base and outline font set
#define NT_FONTSTART '!' // the first font character
@ -54,7 +49,7 @@ typedef struct
UINT32 linespacing;
} fontdef_t;
extern fontdef_t hu_font, tny_font;
extern fontdef_t hu_font, tny_font, cred_font;
//------------------------------------
// sorted player lines
@ -91,7 +86,6 @@ extern boolean chat_on;
extern patch_t *tallnum[10];
extern patch_t *nightsnum[10];
extern patch_t *lt_font[LT_FONTSIZE];
extern patch_t *cred_font[CRED_FONTSIZE];
extern patch_t *ntb_font[NT_FONTSIZE];
extern patch_t *nto_font[NT_FONTSIZE];
extern patch_t *ttlnum[10];

View file

@ -2333,59 +2333,6 @@ void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, UINT8 num)
}
}
// Write a string using the credit font
// NOTE: the text is centered for screens larger than the base width
//
void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string)
{
INT32 w, c, dupx, dupy, scrwidth = BASEVIDWIDTH;
fixed_t cx = x, cy = y;
const char *ch = string;
// It's possible for string to be a null pointer
if (!string)
return;
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
dupx = dupy = 1;
if (option & V_NOSCALEPATCH)
scrwidth *= vid.dupx;
for (;;)
{
c = *ch++;
if (!c)
break;
if (c == '\n')
{
cx = x;
cy += (12*dupy)<<FRACBITS;
continue;
}
c = toupper(c) - CRED_FONTSTART;
if (c < 0 || c >= CRED_FONTSIZE)
{
cx += (16*dupx)<<FRACBITS;
continue;
}
w = cred_font[c]->width * dupx;
if ((cx>>FRACBITS) > scrwidth)
continue;
V_DrawSciencePatch(cx, cy, option, cred_font[c], FRACUNIT);
cx += w<<FRACBITS;
}
}
// Draw a string using the nt_font
// Note that the outline is a seperate font set
static void V_DrawNameTagLine(INT32 x, INT32 y, INT32 option, fixed_t scale, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string)
@ -2586,29 +2533,6 @@ INT32 V_NameTagWidth(const char *string)
return w;
}
// Find string width from cred_font chars
//
INT32 V_CreditStringWidth(const char *string)
{
INT32 c, w = 0;
size_t i;
// It's possible for string to be a null pointer
if (!string)
return 0;
for (i = 0; i < strlen(string); i++)
{
c = toupper(string[i]) - CRED_FONTSTART;
if (c < 0 || c >= CRED_FONTSIZE)
w += 16;
else
w += cred_font[c]->width;
}
return w;
}
// Write a string using the level title font
// NOTE: the text is centered for screens larger than the base width
//

View file

@ -252,6 +252,8 @@ void V_DrawRightAlignedFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fix
#define V_DrawSmallThinStringAtFixed(x,y,o,str) V_DrawFontStringAtFixed(x,y,o,FRACUNIT/2,FRACUNIT/2,str,tny_font)
#define V_DrawCenteredSmallThinStringAtFixed(x,y,o,str) V_DrawCenteredFontStringAtFixed(x,y,o,FRACUNIT/2,FRACUNIT/2,str,tny_font)
#define V_DrawRightAlignedSmallThinStringAtFixed(x,y,o,str) V_DrawRightAlignedFontStringAtFixed(x,y,o,FRACUNIT/2,FRACUNIT/2,str,tny_font)
// draw a string using the credit font
#define V_DrawCreditString(x,y,o,str) V_DrawFontStringAtFixed(x,y,o,FRACUNIT,FRACUNIT,str,cred_font)
// Draw tall nums, used for menu, HUD, intermission
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);
@ -263,9 +265,6 @@ INT32 V_LevelNameWidth(const char *string);
INT32 V_LevelNameHeight(const char *string);
INT16 V_LevelActNumWidth(UINT8 num); // act number width
void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
INT32 V_CreditStringWidth(const char *string);
// Draw a string using the nt_font
void V_DrawNameTag(INT32 x, INT32 y, INT32 option, fixed_t scale, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string);
INT32 V_CountNameTagLines(const char *string);
@ -279,6 +278,7 @@ INT32 V_FontStringWidth(const char *string, INT32 option, fontdef_t font);
#define V_SmallStringWidth(str,o) V_FontStringWidth(str,o,hu_font)/2
#define V_ThinStringWidth(str,o) V_FontStringWidth(str,o,tny_font)
#define V_SmallThinStringWidth(str,o) V_FontStringWidth(str,o,tny_font)/2
#define V_CreditStringWidth(str) V_FontStringWidth(str,0,cred_font)
void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param);