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 933088f3cb
commit a75bc92146
3 changed files with 12 additions and 0 deletions

View file

@ -117,6 +117,7 @@ enum align {
align_fixedright, align_fixedright,
align_small, align_small,
align_smallfixed, align_smallfixed,
align_smallfixedcenter,
align_smallfixedright, align_smallfixedright,
align_smallcenter, align_smallcenter,
align_smallright, align_smallright,
@ -137,6 +138,7 @@ static const char *const align_opt[] = {
"fixed-right", "fixed-right",
"small", "small",
"small-fixed", "small-fixed",
"small-fixed-center",
"small-fixed-right", "small-fixed-right",
"small-center", "small-center",
"small-right", "small-right",
@ -762,6 +764,9 @@ static int libd_drawString(lua_State *L)
case align_smallfixed: case align_smallfixed:
V_DrawSmallStringAtFixed(x, y, flags, str); V_DrawSmallStringAtFixed(x, y, flags, str);
break; break;
case align_smallfixedcenter:
V_DrawCenteredSmallStringAtFixed(x, y, flags, str);
break;
case align_smallfixedright: case align_smallfixedright:
V_DrawRightAlignedSmallStringAtFixed(x, y, flags, str); V_DrawRightAlignedSmallStringAtFixed(x, y, flags, str);
break; 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) void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{ {
x -= V_SmallStringWidth(string, option)<<FRACBITS; 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 // 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_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); 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 // draw a string using the tny_font at fixed_t coordinates