Create V_DrawCenteredSmallThinStringAtFixed() for new "small-thin-fixed-center" option in v.drawString()

Thankfully "center" is just "right" but with the X offset divided by 2.
This commit is contained in:
GoldenTails 2019-10-08 22:03:43 -05:00
parent 4cbcb68795
commit b2b4c4c79e
3 changed files with 13 additions and 1 deletions

View file

@ -123,6 +123,7 @@ enum align {
align_smallright,
align_smallthin,
align_smallthinfixed,
align_smallthinfixedcenter,
align_smallthinfixedright,
align_thin,
align_thinfixed,
@ -146,6 +147,7 @@ static const char *const align_opt[] = {
"small-right",
"small-thin",
"small-thin-fixed",
"small-thin-fixed-center",
"small-thin-fixed-right",
"thin",
"thin-fixed",
@ -786,6 +788,9 @@ static int libd_drawString(lua_State *L)
case align_smallthinfixed:
V_DrawSmallThinStringAtFixed(x, y, flags, str);
break;
case align_smallthinfixedcenter:
V_DrawCenteredSmallThinStringAtFixed(x, y, flags, str);
break;
case align_smallthinfixedright:
V_DrawRightAlignedSmallThinStringAtFixed(x, y, flags, str);
break;

View file

@ -2885,6 +2885,12 @@ void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char
}
}
void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
x -= V_SmallThinStringWidth(string, option)/4;
V_DrawSmallThinStringAtFixed(x, y, option, string);
}
void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
x -= V_SmallThinStringWidth(string, option)/2;

View file

@ -233,7 +233,8 @@ void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, con
// draw a string using the tny_font at fixed_t coordinates, 0.5x scale
void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
void V_DrawRightAlignedSmallThinStringAtFixed(INT32 x, INT32 y, INT32 option, const char *string);
void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
// Draw tall nums, used for menu, HUD, intermission
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);