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

This commit is contained in:
GoldenTails 2019-08-27 03:36:12 -05:00
parent b0e66874d3
commit 9f50b6ef73
3 changed files with 12 additions and 0 deletions

View file

@ -113,6 +113,7 @@ enum align {
align_center, align_center,
align_right, align_right,
align_fixed, align_fixed,
align_fixedcenter,
align_fixedright, align_fixedright,
align_small, align_small,
align_smallfixed, align_smallfixed,
@ -128,6 +129,7 @@ static const char *const align_opt[] = {
"center", "center",
"right", "right",
"fixed", "fixed",
"fixed-center",
"fixed-right", "fixed-right",
"small", "small",
"small-fixed", "small-fixed",
@ -739,6 +741,9 @@ static int libd_drawString(lua_State *L)
case align_fixed: case align_fixed:
V_DrawStringAtFixed(x, y, flags, str); V_DrawStringAtFixed(x, y, flags, str);
break; break;
case align_fixedcenter:
V_DrawCenteredStringAtFixed(x, y, flags, str);
break;
case align_fixedright: case align_fixedright:
V_DrawRightAlignedStringAtFixed(x, y, flags, str); V_DrawRightAlignedStringAtFixed(x, y, flags, str);
break; break;

View file

@ -2524,6 +2524,12 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
} }
} }
void V_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
x -= (V_StringWidth(string, option) / 2)<<FRACBITS;
V_DrawStringAtFixed(x, y, option, string);
}
void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{ {
x -= V_StringWidth(string, option)<<FRACBITS; x -= V_StringWidth(string, option)<<FRACBITS;

View file

@ -215,6 +215,7 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st
// draw a string using the hu_font at fixed_t coordinates // draw a string using the hu_font at fixed_t coordinates
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_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawRightAlignedStringAtFixed(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_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);