From a216736ef4d61591d05b118cad33d0e7b0c32097 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 9 Sep 2019 20:41:34 -0500 Subject: [PATCH] Create V_DrawCenteredSmallStringAtFixed() for new "small-fixed-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 7a633f757..f890f62c0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -117,6 +117,7 @@ enum align { align_fixedright, align_small, align_smallfixed, + align_smallfixedcenter, align_smallfixedright, align_smallcenter, align_smallright, @@ -137,6 +138,7 @@ static const char *const align_opt[] = { "fixed-right", "small", "small-fixed", + "small-fixed-center", "small-fixed-right", "small-center", "small-right", @@ -762,6 +764,9 @@ static int libd_drawString(lua_State *L) case align_smallfixed: V_DrawSmallStringAtFixed(x, y, flags, str); break; + case align_smallfixedcenter: + V_DrawCenteredSmallStringAtFixed(x, y, flags, str); + break; case align_smallfixedright: V_DrawRightAlignedSmallStringAtFixed(x, y, flags, str); break; diff --git a/src/v_video.c b/src/v_video.c index dba9ed2dc..a4c1bf6ba 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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)<