From 426ccc9203cb61b6d16e84e457256a5f8ff0a9b4 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 27 Aug 2019 03:05:03 -0500 Subject: [PATCH] Create V_DrawCenteredThinString() for new "thin-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e0d3c52fa..12b894bf2 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -119,6 +119,7 @@ enum align { align_smallright, align_thin, align_thinfixed, + align_thincenter, align_thinright }; static const char *const align_opt[] = { @@ -132,6 +133,7 @@ static const char *const align_opt[] = { "small-right", "thin", "thin-fixed", + "thin-center", "thin-right", NULL}; @@ -752,6 +754,9 @@ static int libd_drawString(lua_State *L) case align_thin: V_DrawThinString(x, y, flags, str); break; + case align_thincenter: + V_DrawCenteredThinString(x, y, flags, str); + break; case align_thinright: V_DrawRightAlignedThinString(x, y, flags, str); break; diff --git a/src/v_video.c b/src/v_video.c index 973cbc0c4..1e4217e4e 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2411,6 +2411,12 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) } } +void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x -= V_ThinStringWidth(string, option)/2; + V_DrawThinString(x, y, option, string); +} + void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string) { x -= V_ThinStringWidth(string, option); diff --git a/src/v_video.h b/src/v_video.h index 6f03c4d8f..9a0fe51d4 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -210,6 +210,7 @@ void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *s // draw a string using the tny_font 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_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string);