mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 02:42:20 +00:00
Make V_DrawSmallThinString() a less precise wrapper for V_DrawSmallThinStringAtFixed() to fix rounding errors.
This commit is contained in:
parent
75d94c6c1a
commit
c858d9fd4d
1 changed files with 4 additions and 100 deletions
104
src/v_video.c
104
src/v_video.c
|
@ -2427,108 +2427,12 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st
|
|||
// Write a string using the tny_font, 0.5x scale
|
||||
// NOTE: the text is centered for screens larger than the base width
|
||||
//
|
||||
// Literally a wrapper. ~Golden
|
||||
void V_DrawSmallThinString(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);
|
||||
|
||||
// Monospace only + spacing changes, otherwise the characters are squished together. ~Golden
|
||||
switch (option & V_SPACINGMASK)
|
||||
{
|
||||
case V_MONOSPACE:
|
||||
spacewidth = 3;
|
||||
/* FALLTHRU */
|
||||
case V_OLDSPACING:
|
||||
charwidth = 3;
|
||||
break;
|
||||
case V_6WIDTHSPACE:
|
||||
spacewidth = 2;
|
||||
charwidth = 3;
|
||||
break;
|
||||
default:
|
||||
spacewidth = 3;
|
||||
charwidth = 3;
|
||||
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;
|
||||
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;
|
||||
|
||||
// character does not exist or is a space
|
||||
if (c < 0 || c >= HU_FONTSIZE || !tny_font[c])
|
||||
{
|
||||
cx += spacewidth * dupx;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (charwidth)
|
||||
{
|
||||
w = charwidth * dupx;
|
||||
center = w/2 - SHORT(tny_font[c]->width)*dupx/4;
|
||||
}
|
||||
else
|
||||
w = SHORT(tny_font[c]->width) * dupx / 2;
|
||||
|
||||
if (cx > scrwidth)
|
||||
break;
|
||||
if (cx+left + w < 0) //left boundary check
|
||||
{
|
||||
cx += w;
|
||||
continue;
|
||||
}
|
||||
|
||||
colormap = V_GetStringColormap(charflags);
|
||||
V_DrawFixedPatch((cx + center)<<FRACBITS, cy<<FRACBITS, FRACUNIT/2, option, tny_font[c], colormap);
|
||||
|
||||
cx += w;
|
||||
}
|
||||
x <<= FRACBITS;
|
||||
y <<= FRACBITS;
|
||||
V_DrawSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string);
|
||||
}
|
||||
|
||||
// Draws a string at a fixed_t location.
|
||||
|
|
Loading…
Reference in a new issue