Make name tag font(s) into fontdefs, and some more general cleanup.

This commit is contained in:
spherallic 2022-02-14 21:35:11 +01:00
parent be729c334f
commit a6153b62f2
4 changed files with 47 additions and 59 deletions

View file

@ -1718,7 +1718,7 @@ static void CON_DrawHudlines(void)
;//charwidth = 4 * con_scalefactor;
else
{
//charwidth = (hu_font['A'-HU_FONTSTART]->width) * con_scalefactor;
//charwidth = (hu_font.chars['A'-HU_FONTSTART]->width) * con_scalefactor;
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true);
}
}

View file

@ -58,21 +58,22 @@
#define HU_CSAY 2 // Server CECHOes to everyone.
//-------------------------------------------
// heads up font
// Fonts & stuff
//-------------------------------------------
// Font definitions
fontdef_t hu_font;
fontdef_t tny_font;
fontdef_t cred_font;
fontdef_t lt_font;
fontdef_t ntb_font;
fontdef_t nto_font;
// Numbers
patch_t *tallnum[10]; // 0-9
patch_t *nightsnum[10]; // 0-9
patch_t *ttlnum[10]; // act numbers (0-9)
// Name tag fonts
patch_t *ntb_font[NT_FONTSIZE];
patch_t *nto_font[NT_FONTSIZE];
patch_t *tallminus;
patch_t *tallinfin;
static player_t *plr;
boolean chat_on; // entering a chat message?
@ -87,8 +88,6 @@ patch_t *bflagico;
patch_t *rmatcico;
patch_t *bmatcico;
patch_t *tagico;
patch_t *tallminus;
patch_t *tallinfin;
//-------------------------------------------
// coop hud
@ -217,6 +216,20 @@ void HU_LoadGraphics(void)
lt_font.chars[i] = NULL;
else
lt_font.chars[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
// name tag font base
sprintf(buffer, "NTFNT%.3d", j);
if (W_CheckNumForName(buffer) == LUMPERROR)
ntb_font.chars[i] = NULL;
else
ntb_font.chars[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
// name tag font outline
sprintf(buffer, "NTFNO%.3d", j);
if (W_CheckNumForName(buffer) == LUMPERROR)
nto_font.chars[i] = NULL;
else
nto_font.chars[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
hu_font.kerning = 0;
@ -235,6 +248,10 @@ void HU_LoadGraphics(void)
lt_font.spacewidth = 16;
lt_font.linespacing = 20;
ntb_font.kerning = nto_font.kerning = 0;
ntb_font.spacewidth = nto_font.spacewidth = 4;
ntb_font.linespacing = nto_font.linespacing = 21;
//cache numbers too!
for (i = 0; i < 10; i++)
{
@ -242,36 +259,14 @@ void HU_LoadGraphics(void)
tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
sprintf(buffer, "NGTNUM%d", i);
nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX);
sprintf(buffer, "TTL%.2d", i);
ttlnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// minus for negative tallnums
tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX);
tallinfin = (patch_t *)W_CachePatchName("STTINFIN", PU_HUDGFX);
// cache act numbers for level titles
for (i = 0; i < 10; i++)
{
sprintf(buffer, "TTL%.2d", i);
ttlnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// cache the base name tag font & outline for entire game execution
j = NT_FONTSTART;
for (i = 0; i < NT_FONTSIZE; i++, j++)
{
sprintf(buffer, "NTFNT%.3d", j);
if (W_CheckNumForName(buffer) == LUMPERROR)
ntb_font[i] = NULL;
else
ntb_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
sprintf(buffer, "NTFNO%.3d", j);
if (W_CheckNumForName(buffer) == LUMPERROR)
nto_font[i] = NULL;
else
nto_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// cache the crosshairs, don't bother to know which one is being used,
// just cache all 3, they're so small anyway.
for (i = 0; i < HU_CROSSHAIRS; i++)
@ -1148,7 +1143,7 @@ boolean HU_Responder(event_t *ev)
else
c_input++;
}
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font[c-HU_FONTSTART])
else if ((c >= HU_FONTSTART && c <= HU_FONTEND && hu_font.chars[c-HU_FONTSTART])
|| c == ' ') // Allow spaces, of course
{
if (CHAT_MUTE || strlen(w_chat) >= HU_MAXMSGLEN)

View file

@ -19,18 +19,12 @@
#include "r_defs.h"
//------------------------------------
// heads up font
// Fonts & stuff
//------------------------------------
#define HU_FONTSTART '\x16' // the first font character
#define HU_FONTEND '~'
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
// Name tag font
// Used by base and outline font set
#define NT_FONTSTART '!' // the first font character
#define NT_FONTEND 'Z' // the last font character
#define NT_FONTSIZE (NT_FONTEND - NT_FONTSTART + 1)
#define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init();
extern char *shiftxform; // english translation shift table
@ -45,6 +39,12 @@ typedef struct
} fontdef_t;
extern fontdef_t hu_font, tny_font, cred_font, lt_font;
extern fontdef_t ntb_font, nto_font;
extern patch_t *tallnum[10];
extern patch_t *nightsnum[10];
extern patch_t *ttlnum[10];
extern patch_t *tallminus;
extern patch_t *tallinfin;
//------------------------------------
// sorted player lines
@ -78,19 +78,12 @@ void HU_AddChatText(const char *text, boolean playsound);
// set true when entering a chat message
extern boolean chat_on;
extern patch_t *tallnum[10];
extern patch_t *nightsnum[10];
extern patch_t *ntb_font[NT_FONTSIZE];
extern patch_t *nto_font[NT_FONTSIZE];
extern patch_t *ttlnum[10];
extern patch_t *emeraldpics[3][8];
extern patch_t *rflagico;
extern patch_t *bflagico;
extern patch_t *rmatcico;
extern patch_t *bmatcico;
extern patch_t *tagico;
extern patch_t *tallminus;
extern patch_t *tallinfin;
extern patch_t *tokenicon;
// set true whenever the tab rankings are being shown for any reason

View file

@ -2387,21 +2387,21 @@ static void V_DrawNameTagLine(INT32 x, INT32 y, INT32 option, fixed_t scale, UIN
if (*ch == '\n')
{
cx = x<<FRACBITS;
cy += FixedMul((21*dupy)*FRACUNIT, scale);
cy += FixedMul((ntb_font.linespacing*dupy)*FRACUNIT, scale);
continue;
}
c = toupper(*ch);
c -= NT_FONTSTART;
c -= HU_FONTSTART;
// character does not exist or is a space
if (c < 0 || c >= NT_FONTSIZE || !ntb_font[c] || !nto_font[c])
if (c < 0 || c >= HU_FONTSIZE || !ntb_font.chars[c] || !nto_font.chars[c])
{
cx += FixedMul((4 * dupx)*FRACUNIT, scale);
cx += FixedMul((ntb_font.spacewidth * dupx)*FRACUNIT, scale);
continue;
}
w = FixedMul(((ntb_font[c]->width)+2 * dupx) * FRACUNIT, scale);
w = FixedMul(((ntb_font.chars[c]->width)+2 * dupx) * FRACUNIT, scale);
if (FixedInt(cx) > scrwidth)
continue;
@ -2411,8 +2411,8 @@ static void V_DrawNameTagLine(INT32 x, INT32 y, INT32 option, fixed_t scale, UIN
continue;
}
V_DrawFixedPatch(cx, cy, scale, option, nto_font[c], outlinecolormap);
V_DrawFixedPatch(cx, cy, scale, option, ntb_font[c], basecolormap);
V_DrawFixedPatch(cx, cy, scale, option, nto_font.chars[c], outlinecolormap);
V_DrawFixedPatch(cx, cy, scale, option, ntb_font.chars[c], basecolormap);
cx += w;
}
@ -2538,11 +2538,11 @@ INT32 V_NameTagWidth(const char *string)
for (i = 0; i < strlen(string); i++)
{
c = toupper(string[i]) - NT_FONTSTART;
if (c < 0 || c >= NT_FONTSIZE || !ntb_font[c] || !nto_font[c])
w += 4;
c = toupper(string[i]) - HU_FONTSTART;
if (c < 0 || c >= HU_FONTSIZE || !ntb_font.chars[c] || !nto_font.chars[c])
w += ntb_font.spacewidth;
else
w += (ntb_font[c]->width)+2;
w += (ntb_font.chars[c]->width)+2;
}
return w;