diff --git a/src/st_stuff.c b/src/st_stuff.c index f17b58fa62d0161d859c5371beb3d5c0a161c6da..9632ba31ef544b3336df5849a1d782b127f3cb46 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -480,7 +480,7 @@ static void ST_DrawNightsOverlayNum(fixed_t x /* right border */, fixed_t y, fix static void ST_drawDebugInfo(void) { INT32 height = 0, h = 8, w = 18, lowh; - void (*textfunc)(INT32, INT32, INT32, const char *); + fixed_t textscale = FRACUNIT/2; if (!(stplyr->mo && cv_debug)) return; @@ -489,12 +489,12 @@ static void ST_drawDebugInfo(void) if ((moviemode == MM_GIF && cv_gif_downscale.value) || vid.dupx == 1) { - textfunc = V_DrawRightAlignedString; + textscale = FRACUNIT; lowh = ((vid.height/vid.dupy) - 16); } else { - textfunc = V_DrawRightAlignedSmallString; + textscale = FRACUNIT/2; h /= 2; w /= 2; lowh = 0; @@ -505,10 +505,10 @@ static void ST_drawDebugInfo(void) V_DrawRightAlignedThinString(320, 8+lowh, VFLAGS|V_REDMAP, "SOME INFO NOT VISIBLE");\ return;\ }\ - textfunc(320, height, VFLAGS, str);\ + V_DrawRightAlignedFontString(320, height, 8, 12, VFLAGS, textscale, str, hu_font);\ height += h; -#define V_DrawDebugFlag(f, str) textfunc(width, height, VFLAGS|f, str);\ +#define V_DrawDebugFlag(f, str) V_DrawRightAlignedFontString(width, height, 8, 12, VFLAGS|f, textscale, str, hu_font);\ width -= w if (cv_debug & DBG_MEMORY) diff --git a/src/v_video.c b/src/v_video.c index 93d33d8d0c552ed9fc552cb0e91551567fd75a7b..b82d4c54b1b3898adfc38c4a855e95e1f4df1ade 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2141,8 +2141,8 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) return newstring; } -// Write a string using a supplied font and scale -// NOTE: the text is centered for screens larger than the base width +// Draw a string, using a supplied font and scale. +// NOTE: The text is centered for screens larger than the base width. void V_DrawFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font) { V_DrawFontStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, width, height, option, scale, string, font); @@ -2153,14 +2153,13 @@ void V_DrawCenteredFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 V_DrawCenteredFontStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, width, height, option, scale, string, font); } - void V_DrawRightAlignedFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font) { V_DrawRightAlignedFontStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, width, height, option, scale, string, font); } -// Write a string using a supplied font and scale at a fixed position -// NOTE: the text is centered for screens larger than the base width +// Write a string, using a supplied font and scale, at fixed_t coordinates. +// NOTE: The text is centered for screens larger than the base width. void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font) { fixed_t cx = x, cy = y; @@ -2271,138 +2270,6 @@ void V_DrawRightAlignedFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT3 V_DrawFontStringAtFixed(x, y, width, height, option, scale, string, font); } -// Write a string using the hu_font -// NOTE: the text is centered for screens larger than the base width -void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawFontString(x, y, 8, 12, option, FRACUNIT, string, hu_font); -} - -void V_DrawCenteredString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawCenteredFontString(x, y, 8, 12, option, FRACUNIT, string, hu_font); -} - -void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawRightAlignedFontString(x, y, 8, 12, option, FRACUNIT, string, hu_font); -} - -// Write a string using the hu_font, 0.5x scale -// NOTE: the text is centered for screens larger than the base width -void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawFontString(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); -} - -void V_DrawCenteredSmallString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawCenteredFontString(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); -} - -void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawRightAlignedFontString(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); -} - -// Write a string using the tny_font -// NOTE: the text is centered for screens larger than the base width -void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawFontString(x, y, 5, 12, option, FRACUNIT, string, tny_font); -} - -void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawCenteredFontString(x, y, 5, 12, option, FRACUNIT, string, tny_font); -} - -void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawRightAlignedFontString(x, y, 5, 12, option, FRACUNIT, string, tny_font); -} - -// Write a string using the tny_font, 0.5x scale -// NOTE: the text is centered for screens larger than the base width -void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawSmallThinStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, option, string); -} - -void V_DrawCenteredSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawCenteredSmallThinStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, option, string); -} - -void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - V_DrawRightAlignedSmallThinStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, option, string); -} - -// Draws a string at a fixed_t location. -void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawFontStringAtFixed(x, y, 8, 12, option, FRACUNIT, string, hu_font); -} - -void V_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawCenteredFontStringAtFixed(x, y, 8, 12, option, FRACUNIT, string, hu_font); -} - -void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawRightAlignedFontStringAtFixed(x, y, 8, 12, option, FRACUNIT, string, hu_font); -} - -// Draws a small string at a fixed_t location. -void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawFontStringAtFixed(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); -} - -void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawCenteredFontStringAtFixed(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); -} - -void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawRightAlignedFontStringAtFixed(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); -} - -// Draws a thin string at a fixed_t location. -void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawFontStringAtFixed(x, y, 5, 12, option, FRACUNIT, string, tny_font); -} - -void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawCenteredThinStringAtFixed(x, y, option, string); -} - -void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawRightAlignedThinStringAtFixed(x, y, option, string); -} - -// Draws a small string at a fixed_t location. -void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawFontStringAtFixed(x, y, 5, 12, option, FRACUNIT/2, string, tny_font); -} - -void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawCenteredFontStringAtFixed(x, y, 5, 12, option, FRACUNIT/2, string, tny_font); -} - -void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) -{ - V_DrawRightAlignedFontStringAtFixed(x, y, 5, 12, option, FRACUNIT/2, string, tny_font); -} - // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { @@ -2869,8 +2736,7 @@ INT16 V_LevelActNumWidth(UINT8 num) return result; } -// -// Find string width from supplied font characters +// Find string width from supplied font characters & character width. // INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t **font) { @@ -2909,31 +2775,6 @@ INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t * return w; } -// Find string width from hu_font chars -INT32 V_StringWidth(const char *string, INT32 option) -{ - return V_FontStringWidth(string, option, 8, hu_font); -} - -// Find string width from hu_font chars, 0.5x scale -INT32 V_SmallStringWidth(const char *string, INT32 option) -{ - return V_FontStringWidth(string, option, 8, hu_font)/2; -} - - -// Find string width from tny_font chars -INT32 V_ThinStringWidth(const char *string, INT32 option) -{ - return V_FontStringWidth(string, option, 5, tny_font); -} - -// Find string width from tny_font chars, 0.5x scale -INT32 V_SmallThinStringWidth(const char *string, INT32 option) -{ - return V_FontStringWidth(string, option, 5, tny_font)/2; -} - boolean *heatshifter = NULL; INT32 lastheight = 0; INT32 heatindex[2] = { 0, 0 }; diff --git a/src/v_video.h b/src/v_video.h index 3bcac674ad2b329f6cc430713385f7c3c52f7880..c94ec43dc1c760a7ac344d0b832b4e626b793b6a 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -17,6 +17,7 @@ #include "doomdef.h" #include "doomtype.h" #include "r_defs.h" +#include "hu_stuff.h" //font arrays // // VIDEO @@ -208,54 +209,49 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string); char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string); UINT8 *V_GetStringColormap(INT32 colorflags); -// draw a string using a supplied font and scale +// Draw a string, using a supplied font and scale. void V_DrawFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font); void V_DrawCenteredFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font); void V_DrawRightAlignedFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font); - +// Draw a string, using a supplied font and scale, at fixed_t coordinates. void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font); void V_DrawCenteredFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font); void V_DrawRightAlignedFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font); +// width = "average" character width (divided by 2 for space width), height = distance between two lines. TODO: incorporate these in the supplied font, somehow +// Defines for old string drawers. // draw a string using the hu_font -void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawCenteredString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string); - +#define V_DrawString(x,y,o,str) V_DrawFontString(x,y,8,12,o,FRACUNIT,str,hu_font) +#define V_DrawCenteredString(x,y,o,str) V_DrawCenteredFontString(x,y,8,12,o,FRACUNIT,str,hu_font) +#define V_DrawRightAlignedString(x,y,o,str) V_DrawRightAlignedFontString(x,y,8,12,o,FRACUNIT,str,hu_font) // draw a string using the hu_font, 0.5x scale -void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawCenteredSmallString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string); - -// draw a string using the tny_font -void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string); - +#define V_DrawSmallString(x,y,o,str) V_DrawFontString(x,y,8,12,o,FRACUNIT/2,str,hu_font) +#define V_DrawCenteredSmallString(x,y,o,str) V_DrawCenteredFontString(x,y,8,12,o,FRACUNIT/2,str,hu_font) +#define V_DrawRightAlignedSmallString(x,y,o,str) V_DrawRightAlignedFontString(x,y,8,12,o,FRACUNIT/2,str,hu_font) +// Write a string using the tny_font +#define V_DrawThinString(x,y,o,str) V_DrawFontString(x,y,5,12,o,FRACUNIT,str,tny_font) +#define V_DrawCenteredThinString(x,y,o,str) V_DrawCenteredFontString(x,y,5,12,o,FRACUNIT,str,tny_font) +#define V_DrawRightAlignedThinString(x,y,o,str) V_DrawRightAlignedFontString(x,y,5,12,o,FRACUNIT,str,tny_font) // draw a string using the tny_font, 0.5x scale -void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawCenteredSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); -void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); - +#define V_DrawSmallThinString(x,y,o,str) V_DrawFontString(x,y,5,12,o,FRACUNIT/2,str,tny_font) +#define V_DrawCenteredSmallThinString(x,y,o,str) V_DrawCenteredFontString(x,y,5,12,o,FRACUNIT/2,str,tny_font) +#define V_DrawRightAlignedSmallThinString(x,y,o,str) V_DrawRightAlignedFontString(x,y,5,12,o,FRACUNIT/2,str,tny_font) // draw a string using the hu_font at fixed_t coordinates -void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); - +#define V_DrawStringAtFixed(x,y,o,str) V_DrawFontStringAtFixed(x,y,8,12,o,FRACUNIT,str,hu_font) +#define V_DrawCenteredStringAtFixed(x,y,o,str) V_DrawCenteredFontStringAtFixed(x,y,8,12,o,FRACUNIT,str,hu_font) +#define V_DrawRightAlignedStringAtFixed(x,y,o,str) V_DrawRightAlignedFontStringAtFixed(x,y,8,12,o,FRACUNIT,str,hu_font) // draw a string using the hu_font at fixed_t coordinates, 0.5x scale -void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); - +#define V_DrawSmallStringAtFixed(x,y,o,str) V_DrawFontStringAtFixed(x,y,8,12,o,FRACUNIT/2,str,hu_font) +#define V_DrawCenteredSmallStringAtFixed(x,y,o,str) V_DrawCenteredFontStringAtFixed(x,y,8,12,o,FRACUNIT/2,str,hu_font) +#define V_DrawRightAlignedSmallStringAtFixed(x,y,o,str) V_DrawRightAlignedFontStringAtFixed(x,y,8,12,o,FRACUNIT/2,str,hu_font) // draw a string using the tny_font at fixed_t coordinates -void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *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); - +#define V_DrawThinStringAtFixed(x,y,o,str) V_DrawFontStringAtFixed(x,y,5,12,o,FRACUNIT,str,tny_font) +#define V_DrawCenteredThinStringAtFixed(x,y,o,str) V_DrawCenteredFontStringAtFixed(x,y,5,12,o,FRACUNIT,str,tny_font) +#define V_DrawRightAlignedThinStringAtFixed(x,y,o,str) V_DrawRightAlignedFontStringAtFixed(x,y,5,12,o,FRACUNIT,str,tny_font) // draw a string using the tny_font at fixed_t coordinates, 0.5x scale -void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); +#define V_DrawSmallThinStringAtFixed(x,y,o,str) V_DrawFontStringAtFixed(x,y,5,12,o,FRACUNIT/2,str,tny_font) +#define V_DrawCenteredSmallThinStringAtFixed(x,y,o,str) V_DrawCenteredFontStringAtFixed(x,y,5,12,o,FRACUNIT/2,str,tny_font) +#define V_DrawRightAlignedSmallThinStringAtFixed(x,y,o,str) V_DrawRightAlignedFontStringAtFixed(x,y,5,12,o,FRACUNIT/2,str,tny_font) // Draw tall nums, used for menu, HUD, intermission void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); @@ -277,14 +273,12 @@ INT32 V_NameTagWidth(const char *string); // Find string width from supplied font chars INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t **font); -// Find string width from hu_font chars -INT32 V_StringWidth(const char *string, INT32 option); -// Find string width from hu_font chars, 0.5x scale -INT32 V_SmallStringWidth(const char *string, INT32 option); -// Find string width from tny_font chars -INT32 V_ThinStringWidth(const char *string, INT32 option); -// Find string width from tny_font chars, 0.5x scale -INT32 V_SmallThinStringWidth(const char *string, INT32 option); + +// Defines for old string width functions. +#define V_StringWidth(str,o) V_FontStringWidth(str,o,8,hu_font) +#define V_SmallStringWidth(str,o) V_FontStringWidth(str,o,8,hu_font)/2 +#define V_ThinStringWidth(str,o) V_FontStringWidth(str,o,5,tny_font) +#define V_SmallThinStringWidth(str,o) V_FontStringWidth(str,o,5,tny_font)/2 void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param);