Remove old string drawing functions

This commit is contained in:
James R 2019-06-26 17:09:13 -07:00
parent 295631b953
commit d8a2d6c7e2
2 changed files with 20 additions and 622 deletions

View file

@ -1791,217 +1791,6 @@ void V_DrawStringScaled(
}
}
}
//
// 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)
{
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0;
const char *ch = string;
INT32 charflags = 0;
const UINT8 *colormap = NULL;
INT32 spacewidth = 4, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
{
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
if (!(option & V_SNAPTOLEFT))
{
left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left;
}
}
charflags = (option & V_CHARCOLORMASK);
colormap = V_GetStringColormap(charflags);
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
spacewidth = 8;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = 8;
break;
case V_6WIDTHSPACE:
spacewidth = 6;
default:
break;
}
for (;;ch++)
{
if (!*ch)
break;
if (*ch & 0x80) //color parsing -x 2.16.09
{
// manually set flags override color codes
if (!(option & V_CHARCOLORMASK))
{
charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK;
colormap = V_GetStringColormap(charflags);
}
continue;
}
if (*ch == '\n')
{
cx = x;
if (option & V_RETURN8)
cy += 8*dupy;
else
cy += 12*dupy;
continue;
}
c = *ch;
if (!lowercase)
c = toupper(c);
c -= HU_FONTSTART;
// character does not exist or is a space
if (c < 0 || c >= HU_FONTSIZE || !hu_font[c])
{
cx += spacewidth * dupx;
continue;
}
if (charwidth)
{
w = charwidth * dupx;
center = w/2 - SHORT(hu_font[c]->width)*dupx/2;
}
else
w = SHORT(hu_font[c]->width) * dupx;
if (cx > scrwidth)
break;
if (cx+left + w < 0) //left boundary check
{
cx += w;
continue;
}
V_DrawFixedPatch((cx + center)<<FRACBITS, cy<<FRACBITS, FRACUNIT, option, hu_font[c], colormap);
cx += w;
}
}
// SRB2kart
void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string)
{
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0;
const char *ch = string;
INT32 charflags = 0;
const UINT8 *colormap = NULL;
INT32 spacewidth = 12, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
{
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2;
}
charflags = (option & V_CHARCOLORMASK);
colormap = V_GetStringColormap(charflags);
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
spacewidth = 12;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = 12;
break;
case V_6WIDTHSPACE:
spacewidth = 6;
default:
break;
}
for (;;ch++)
{
if (!*ch)
break;
if (*ch & 0x80) //color parsing -x 2.16.09
{
// manually set flags override color codes
if (!(option & V_CHARCOLORMASK))
{
charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK;
colormap = V_GetStringColormap(charflags);
}
continue;
}
if (*ch == '\n')
{
cx = x;
if (option & V_RETURN8)
cy += 8*dupy;
else
cy += 12*dupy;
continue;
}
c = *ch;
if (!lowercase)
c = toupper(c);
c -= KART_FONTSTART;
// character does not exist or is a space
if (c < 0 || c >= KART_FONTSIZE || !kart_font[c])
{
cx += spacewidth * dupx;
continue;
}
if (charwidth)
{
w = charwidth * dupx;
center = w/2 - SHORT(kart_font[c]->width)*dupx/2;
}
else
w = SHORT(kart_font[c]->width) * dupx;
if (cx > scrwidth)
break;
if (cx+left + w < 0) //left boundary check
{
cx += w;
continue;
}
V_DrawFixedPatch((cx + center)<<FRACBITS, cy<<FRACBITS, FRACUNIT, option, kart_font[c], colormap);
cx += w;
}
}
//
void V_DrawCenteredString(INT32 x, INT32 y, INT32 option, const char *string)
@ -2016,220 +1805,12 @@ void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string
V_DrawString(x, y, option, string);
}
//
// 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)
{
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0;
const char *ch = string;
INT32 charflags = 0;
const UINT8 *colormap = NULL;
INT32 spacewidth = 2, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
{
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left;
}
charflags = (option & V_CHARCOLORMASK);
colormap = V_GetStringColormap(charflags);
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
spacewidth = 4;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = 4;
break;
case V_6WIDTHSPACE:
spacewidth = 3;
default:
break;
}
for (;;ch++)
{
if (!*ch)
break;
if (*ch & 0x80) //color parsing -x 2.16.09
{
// manually set flags override color codes
if (!(option & V_CHARCOLORMASK))
{
charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK;
colormap = V_GetStringColormap(charflags);
}
continue;
}
if (*ch == '\n')
{
cx = x;
if (option & V_RETURN8)
cy += 4*dupy;
else
cy += 6*dupy;
continue;
}
c = *ch;
if (!lowercase)
c = toupper(c);
c -= HU_FONTSTART;
if (c < 0 || c >= HU_FONTSIZE || !hu_font[c])
{
cx += spacewidth * dupx;
continue;
}
if (charwidth)
{
w = charwidth * dupx;
center = w/2 - SHORT(hu_font[c]->width)*dupx/4;
}
else
w = SHORT(hu_font[c]->width) * dupx / 2;
if (cx > scrwidth)
break;
if (cx+left + w < 0) //left boundary check
{
cx += w;
continue;
}
V_DrawFixedPatch((cx + center)<<FRACBITS, cy<<FRACBITS, FRACUNIT/2, option, hu_font[c], colormap);
cx += w;
}
}
void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string)
{
x -= V_SmallStringWidth(string, option);
V_DrawSmallString(x, y, option, string);
}
//
// 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)
{
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, left = 0;
const char *ch = string;
INT32 charflags = 0;
const UINT8 *colormap = NULL;
INT32 spacewidth = 2, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
{
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left;
}
charflags = (option & V_CHARCOLORMASK);
colormap = V_GetStringColormap(charflags);
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
spacewidth = 5;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = 5;
break;
// Out of video flags, so we're reusing this for alternate charwidth instead
/*case V_6WIDTHSPACE:
spacewidth = 3;*/
default:
break;
}
for (;;ch++)
{
if (!*ch)
break;
if (*ch & 0x80) //color parsing -x 2.16.09
{
// manually set flags override color codes
if (!(option & V_CHARCOLORMASK))
{
charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK;
colormap = V_GetStringColormap(charflags);
}
continue;
}
if (*ch == '\n')
{
cx = x;
if (option & V_RETURN8)
cy += 8*dupy;
else
cy += 12*dupy;
continue;
}
c = *ch;
if (!lowercase || !tny_font[c-HU_FONTSTART])
c = toupper(c);
c -= HU_FONTSTART;
if (c < 0 || c >= HU_FONTSIZE || !tny_font[c])
{
cx += spacewidth * dupx;
continue;
}
if (charwidth)
w = charwidth * dupx;
else
w = ((option & V_6WIDTHSPACE ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing
: SHORT(tny_font[c]->width)) * dupx);
if (cx > scrwidth)
break;
if (cx+left + w < 0) //left boundary check
{
cx += w;
continue;
}
V_DrawFixedPatch(cx<<FRACBITS, cy<<FRACBITS, FRACUNIT, option, tny_font[c], colormap);
cx += w;
}
}
void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string)
{
x -= V_ThinStringWidth(string, option)/2;
@ -2242,97 +1823,6 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st
V_DrawThinString(x, y, option, string);
}
// Draws a string at a fixed_t location.
void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
fixed_t cx = x, cy = y;
INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0;
const char *ch = string;
INT32 spacewidth = 4, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
{
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left;
}
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
spacewidth = 8;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = 8;
break;
case V_6WIDTHSPACE:
spacewidth = 6;
default:
break;
}
for (;;ch++)
{
if (!*ch)
break;
if (*ch & 0x80) //color ignoring
continue;
if (*ch == '\n')
{
cx = x;
if (option & V_RETURN8)
cy += (8*dupy)<<FRACBITS;
else
cy += (12*dupy)<<FRACBITS;
continue;
}
c = *ch;
if (!lowercase)
c = toupper(c);
c -= HU_FONTSTART;
// character does not exist or is a space
if (c < 0 || c >= HU_FONTSIZE || !hu_font[c])
{
cx += (spacewidth * dupx)<<FRACBITS;
continue;
}
if (charwidth)
{
w = charwidth * dupx;
center = w/2 - SHORT(hu_font[c]->width)*(dupx/2);
}
else
w = SHORT(hu_font[c]->width) * dupx;
if ((cx>>FRACBITS) > scrwidth)
break;
if ((cx>>FRACBITS)+left + w < 0) //left boundary check
{
cx += w<<FRACBITS;
continue;
}
V_DrawSciencePatch(cx + (center<<FRACBITS), cy, option, hu_font[c], FRACUNIT);
cx += w<<FRACBITS;
}
}
// Draws a tallnum. Replaces two functions in y_inter and st_stuff
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num)
{
@ -2401,56 +1891,6 @@ void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colorm
} while (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;
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 = SHORT(cred_font[c]->width) * dupx;
if ((cx>>FRACBITS) > scrwidth)
break;
V_DrawSciencePatch(cx, cy, option, cred_font[c], FRACUNIT);
cx += w<<FRACBITS;
}
}
// Find string width from cred_font chars
//
INT32 V_CreditStringWidth(const char *string)
@ -2474,61 +1914,6 @@ INT32 V_CreditStringWidth(const char *string)
return w;
}
// Write a string using the level title font
// NOTE: the text is centered for screens larger than the base width
//
void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string)
{
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, left = 0;
const char *ch = string;
if (option & V_NOSCALESTART)
{
dupx = vid.dupx;
dupy = vid.dupy;
scrwidth = vid.width;
}
else
{
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left;
}
for (;;)
{
c = *ch++;
if (!c)
break;
if (c == '\n')
{
cx = x;
cy += 12*dupy;
continue;
}
c = toupper(c) - LT_FONTSTART;
if (c < 0 || c >= LT_FONTSIZE || !lt_font[c])
{
cx += 12*dupx;
continue;
}
w = SHORT(lt_font[c]->width) * dupx;
if (cx > scrwidth)
break;
if (cx+left + w < 0) //left boundary check
{
cx += w;
continue;
}
V_DrawScaledPatch(cx, cy, option, lt_font[c]);
cx += w;
}
}
// Find string width from lt_font chars
//
INT32 V_LevelNameWidth(const char *string)

View file

@ -161,6 +161,12 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength);
void V_DrawFadeConsBack(INT32 plines);
/* Convenience macros for leagacy string function macros. */
#define V__DrawOneScaleString( x,y,scale,option,font,string ) \
V_DrawStringScaled(x,y,scale,FRACUNIT,FRACUNIT,option,font,string)
#define V__DrawDupxString( x,y,scale,option,font,string )\
V__DrawOneScaleString ((x)<<FRACBITS,(y)<<FRACBITS,scale,option,font,string)
// draw a single character
void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);
// draw a single character, but for the chat
@ -168,7 +174,8 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UI
UINT8 *V_GetStringColormap(INT32 colorflags);
void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string);
#define V_DrawLevelTitle( x,y,option,string ) \
V__DrawDupxString (x,y,FRACUNIT,option,LT_FONT,string)
// wordwrap a string using the hu_font
char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string);
@ -185,21 +192,26 @@ void V_DrawStringScaled(
const char *text);
// draw a string using the hu_font
void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string);
void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string); // SRB2kart
#define V_DrawString( x,y,option,string ) \
V__DrawDupxString (x,y,FRACUNIT,option,HU_FONT,string)
#define V_DrawKartString( x,y,option,string ) \
V__DrawDupxString (x,y,FRACUNIT,option,KART_FONT,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);
// draw a string using the hu_font, 0.5x scale
void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string);
#define V_DrawSmallString( x,y,option,string ) \
V__DrawDupxString (x,y,FRACUNIT>>1,option,HU_FONT,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);
#define V_DrawThinString( x,y,option,string ) \
V__DrawDupxString (x,y,FRACUNIT,option,TINY_FONT,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);
void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
#define V_DrawStringAtFixed( x,y,option,string ) \
V__DrawOneScaleString (x,y,FRACUNIT,option,HU_FONT,string)
// Draw tall nums, used for menu, HUD, intermission
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);
@ -213,7 +225,8 @@ void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colorm
INT32 V_LevelNameWidth(const char *string);
INT32 V_LevelNameHeight(const char *string);
void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
#define V_DrawCreditString( x,y,option,string ) \
V__DrawOneScaleString (x,y,FRACUNIT,option,CRED_FONT,string)
INT32 V_CreditStringWidth(const char *string);
// Find string width from hu_font chars