From 412381da4c87d5c070adafa09d4859d8d7564329 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 5 Feb 2022 14:40:05 +0100 Subject: [PATCH] Make credits font functions use the generalized functions. --- src/hu_stuff.c | 28 +++++++++---------- src/hu_stuff.h | 8 +----- src/v_video.c | 76 -------------------------------------------------- src/v_video.h | 6 ++-- 4 files changed, 17 insertions(+), 101 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 74bea7572..a949e17ed 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -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++) { diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 0e6710220..2d6fc633a 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -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]; diff --git a/src/v_video.c b/src/v_video.c index 5dec382c3..381e997f4 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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)<= CRED_FONTSIZE) - { - cx += (16*dupx)<width * dupx; - if ((cx>>FRACBITS) > scrwidth) - continue; - - V_DrawSciencePatch(cx, cy, option, cred_font[c], FRACUNIT); - cx += w<= 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 // diff --git a/src/v_video.h b/src/v_video.h index 71cfa4b1f..017524c92 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -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);