mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Create V_DrawThinStringAtFixed() for new "thin-fixed" option in v.drawString()
This commit is contained in:
parent
b836b911a7
commit
0da462836f
3 changed files with 97 additions and 0 deletions
|
|
@ -116,6 +116,7 @@ enum align {
|
||||||
align_small,
|
align_small,
|
||||||
align_smallright,
|
align_smallright,
|
||||||
align_thin,
|
align_thin,
|
||||||
|
align_thinfixed,
|
||||||
align_thinright
|
align_thinright
|
||||||
};
|
};
|
||||||
static const char *const align_opt[] = {
|
static const char *const align_opt[] = {
|
||||||
|
|
@ -126,6 +127,7 @@ static const char *const align_opt[] = {
|
||||||
"small",
|
"small",
|
||||||
"small-right",
|
"small-right",
|
||||||
"thin",
|
"thin",
|
||||||
|
"thin-fixed",
|
||||||
"thin-right",
|
"thin-right",
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
|
|
@ -743,6 +745,9 @@ static int libd_drawString(lua_State *L)
|
||||||
case align_thinright:
|
case align_thinright:
|
||||||
V_DrawRightAlignedThinString(x, y, flags, str);
|
V_DrawRightAlignedThinString(x, y, flags, str);
|
||||||
break;
|
break;
|
||||||
|
case align_thinfixed:
|
||||||
|
V_DrawThinStringAtFixed(x, y, flags, str);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2511,6 +2511,97 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draws a thin string at a fixed_t location.
|
||||||
|
void V_DrawThinStringAtFixed(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 = 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 || !tny_font[c-HU_FONTSTART])
|
||||||
|
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)<<FRACBITS;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (charwidth)
|
||||||
|
{
|
||||||
|
w = charwidth * dupx;
|
||||||
|
center = w/2 - SHORT(tny_font[c]->width)*(dupx/2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
w = SHORT(tny_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, tny_font[c], FRACUNIT);
|
||||||
|
|
||||||
|
cx += w<<FRACBITS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draws a tallnum. Replaces two functions in y_inter and st_stuff
|
// Draws a tallnum. Replaces two functions in y_inter and st_stuff
|
||||||
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num)
|
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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_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
|
||||||
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);
|
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue