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

This commit is contained in:
GoldenTails 2019-09-07 17:55:33 -05:00
parent f1655d32f5
commit f7085fc171
3 changed files with 12 additions and 0 deletions

View file

@ -122,6 +122,7 @@ enum align {
align_smallthin, align_smallthin,
align_thin, align_thin,
align_thinfixed, align_thinfixed,
align_thinfixedcenter,
align_thinfixedright, align_thinfixedright,
align_thincenter, align_thincenter,
align_thinright align_thinright
@ -140,6 +141,7 @@ static const char *const align_opt[] = {
"small-thin", "small-thin",
"thin", "thin",
"thin-fixed", "thin-fixed",
"thin-fixed-center",
"thin-fixed-right", "thin-fixed-right",
"thin-center", "thin-center",
"thin-right", "thin-right",
@ -780,6 +782,9 @@ static int libd_drawString(lua_State *L)
case align_thinfixed: case align_thinfixed:
V_DrawThinStringAtFixed(x, y, flags, str); V_DrawThinStringAtFixed(x, y, flags, str);
break; break;
case align_thinfixedcenter:
V_DrawCenteredThinStringAtFixed(x, y, flags, str);
break;
case align_thinfixedright: case align_thinfixedright:
V_DrawRightAlignedThinStringAtFixed(x, y, flags, str); V_DrawRightAlignedThinStringAtFixed(x, y, flags, str);
break; break;

View file

@ -2848,6 +2848,12 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str
} }
} }
void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{
x -= (V_ThinStringWidth(string, option) / 2)<<FRACBITS;
V_DrawThinStringAtFixed(x, y, option, string);
}
void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
{ {
x -= V_ThinStringWidth(string, option)<<FRACBITS; x -= V_ThinStringWidth(string, option)<<FRACBITS;

View file

@ -225,6 +225,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st
// draw a string using the tny_font at fixed_t coordinates // draw a string using the tny_font at fixed_t coordinates
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);
void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);
// Draw tall nums, used for menu, HUD, intermission // Draw tall nums, used for menu, HUD, intermission