mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Make V_DrawSmallThinString() a less precise wrapper for V_DrawSmallThinStringAtFixed() to fix rounding errors.
This commit is contained in:
parent
5d1b1b7e2b
commit
0306d4580f
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
|
// Write a string using the tny_font, 0.5x scale
|
||||||
// NOTE: the text is centered for screens larger than the base width
|
// 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)
|
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;
|
x <<= FRACBITS;
|
||||||
const char *ch = string;
|
y <<= FRACBITS;
|
||||||
INT32 charflags = 0;
|
V_DrawSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draws a string at a fixed_t location.
|
// Draws a string at a fixed_t location.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue