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

This commit is contained in:
GoldenTails 2019-09-09 20:41:34 -05:00
parent 5f56d19a43
commit a216736ef4
3 changed files with 12 additions and 0 deletions

View file

@ -117,6 +117,7 @@ enum align {
align_fixedright,
align_small,
align_smallfixed,
align_smallfixedcenter,
align_smallfixedright,
align_smallcenter,
align_smallright,
@ -137,6 +138,7 @@ static const char *const align_opt[] = {
"fixed-right",
"small",
"small-fixed",
"small-fixed-center",
"small-fixed-right",
"small-center",
"small-right",
@ -762,6 +764,9 @@ static int libd_drawString(lua_State *L)
case align_smallfixed:
V_DrawSmallStringAtFixed(x, y, flags, str);
break;
case align_smallfixedcenter:
V_DrawCenteredSmallStringAtFixed(x, y, flags, str);
break;
case align_smallfixedright:
V_DrawRightAlignedSmallStringAtFixed(x, y, flags, str);
break;

View file

@ -2746,6 +2746,12 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st
}
}
void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
x -= (V_SmallStringWidth(string, option) / 2)<<FRACBITS;
V_DrawSmallStringAtFixed(x, y, option, string);
}
void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
x -= V_SmallStringWidth(string, option)<<FRACBITS;

View file

@ -223,6 +223,7 @@ void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const c
// draw a string using the hu_font at fixed_t coordinates, 0.5x scale
void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
// draw a string using the tny_font at fixed_t coordinates