mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Create V_DrawSmallStringAtFixed() for new "small-fixed" option in v.drawString()
This commit is contained in:
parent
0da462836f
commit
8a44ca0a75
3 changed files with 97 additions and 0 deletions
|
|
@ -114,6 +114,7 @@ enum align {
|
||||||
align_right,
|
align_right,
|
||||||
align_fixed,
|
align_fixed,
|
||||||
align_small,
|
align_small,
|
||||||
|
align_smallfixed,
|
||||||
align_smallright,
|
align_smallright,
|
||||||
align_thin,
|
align_thin,
|
||||||
align_thinfixed,
|
align_thinfixed,
|
||||||
|
|
@ -125,6 +126,7 @@ static const char *const align_opt[] = {
|
||||||
"right",
|
"right",
|
||||||
"fixed",
|
"fixed",
|
||||||
"small",
|
"small",
|
||||||
|
"small-fixed",
|
||||||
"small-right",
|
"small-right",
|
||||||
"thin",
|
"thin",
|
||||||
"thin-fixed",
|
"thin-fixed",
|
||||||
|
|
@ -735,6 +737,9 @@ static int libd_drawString(lua_State *L)
|
||||||
case align_small:
|
case align_small:
|
||||||
V_DrawSmallString(x, y, flags, str);
|
V_DrawSmallString(x, y, flags, str);
|
||||||
break;
|
break;
|
||||||
|
case align_smallfixed:
|
||||||
|
V_DrawSmallStringAtFixed(x, y, flags, str);
|
||||||
|
break;
|
||||||
case align_smallright:
|
case align_smallright:
|
||||||
V_DrawRightAlignedSmallString(x, y, flags, str);
|
V_DrawRightAlignedSmallString(x, y, flags, str);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -2511,6 +2511,97 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draws a small string at a fixed_t location.
|
||||||
|
void V_DrawSmallStringAtFixed(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 = 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ignoring
|
||||||
|
continue;
|
||||||
|
if (*ch == '\n')
|
||||||
|
{
|
||||||
|
cx = x;
|
||||||
|
|
||||||
|
if (option & V_RETURN8)
|
||||||
|
cy += (4*dupy)<<FRACBITS;
|
||||||
|
else
|
||||||
|
cy += (6*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/4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
w = SHORT(hu_font[c]->width) * dupx / 2;
|
||||||
|
|
||||||
|
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/2);
|
||||||
|
|
||||||
|
cx += w<<FRACBITS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draws a thin string at a fixed_t location.
|
// Draws a thin string at a fixed_t location.
|
||||||
void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
|
void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string);
|
||||||
void V_DrawRightAlignedThinString(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);
|
void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
|
||||||
|
void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
|
||||||
void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
|
void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
|
||||||
|
|
||||||
// Draw tall nums, used for menu, HUD, intermission
|
// Draw tall nums, used for menu, HUD, intermission
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue