From dc1871a74f2c4affc4727725015fc1758d1bbcd0 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 27 Aug 2019 03:25:28 -0500 Subject: [PATCH] Create V_DrawRightAlignedStringAtFixed() for new "fixed-right" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 12b894bf2..ed8e1b676 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -113,6 +113,7 @@ enum align { align_center, align_right, align_fixed, + align_fixedright, align_small, align_smallfixed, align_smallcenter, @@ -127,6 +128,7 @@ static const char *const align_opt[] = { "center", "right", "fixed", + "fixed-right", "small", "small-fixed", "small-center", @@ -737,6 +739,9 @@ static int libd_drawString(lua_State *L) case align_fixed: V_DrawStringAtFixed(x, y, flags, str); break; + case align_fixedright: + V_DrawRightAlignedStringAtFixed(x, y, flags, str); + break; // hu_font, 0.5x scale case align_small: V_DrawSmallString(x, y, flags, str); diff --git a/src/v_video.c b/src/v_video.c index 1e4217e4e..1b95d0145 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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)<