Create V_DrawRightAlignedStringAtFixed() for new "fixed-right" option in v.drawString()

This commit is contained in:
GoldenTails 2019-08-27 03:25:28 -05:00
parent 7ef82c6f08
commit 3c00c22a1d
3 changed files with 14 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_fixedright,
align_small, align_small,
align_smallfixed, align_smallfixed,
align_smallcenter, align_smallcenter,
@ -127,6 +128,7 @@ static const char *const align_opt[] = {
"center", "center",
"right", "right",
"fixed", "fixed",
"fixed-right",
"small", "small",
"small-fixed", "small-fixed",
"small-center", "small-center",
@ -737,6 +739,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_fixedright:
V_DrawRightAlignedStringAtFixed(x, y, flags, str);
break;
// hu_font, 0.5x scale // hu_font, 0.5x scale
case align_small: case align_small:
V_DrawSmallString(x, y, flags, str); V_DrawSmallString(x, y, flags, str);

View file

@ -2524,6 +2524,12 @@ void V_DrawStringAtFixed(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;
V_DrawStringAtFixed(x, y, option, string);
}
// Draws a small string at a fixed_t location. // Draws a small string at a fixed_t location.
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)
{ {

View file

@ -213,7 +213,10 @@ 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_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string);
void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string);
// 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_DrawRightAlignedStringAtFixed(INT32 x, INT32 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);
void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);