Create V_DrawCenteredThinString() for new "thin-center" option in v.drawString()

This commit is contained in:
GoldenTails 2019-08-27 03:05:03 -05:00
parent df15ad82d2
commit 426ccc9203
3 changed files with 12 additions and 0 deletions

View File

@ -119,6 +119,7 @@ enum align {
align_smallright,
align_thin,
align_thinfixed,
align_thincenter,
align_thinright
};
static const char *const align_opt[] = {
@ -132,6 +133,7 @@ static const char *const align_opt[] = {
"small-right",
"thin",
"thin-fixed",
"thin-center",
"thin-right",
NULL};
@ -752,6 +754,9 @@ static int libd_drawString(lua_State *L)
case align_thin:
V_DrawThinString(x, y, flags, str);
break;
case align_thincenter:
V_DrawCenteredThinString(x, y, flags, str);
break;
case align_thinright:
V_DrawRightAlignedThinString(x, y, flags, str);
break;

View File

@ -2411,6 +2411,12 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string)
}
}
void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string)
{
x -= V_ThinStringWidth(string, option)/2;
V_DrawThinString(x, y, option, string);
}
void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string)
{
x -= V_ThinStringWidth(string, option);

View File

@ -210,6 +210,7 @@ void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *s
// draw a string using the tny_font
void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *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);