From 4cbcb68795498a8254d3ded0f378cda156ea3c83 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 8 Oct 2019 21:54:18 -0500 Subject: [PATCH] Create V_DrawRightAlignedSmallThinStringAtFixed() for new "small-thin-fixed-right" option in v.drawString() You guys have no idea how long this took to code. --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 22 ++++++++++++++++++++++ src/v_video.h | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 935a41b43..e5c384949 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -123,6 +123,7 @@ enum align { align_smallright, align_smallthin, align_smallthinfixed, + align_smallthinfixedright, align_thin, align_thinfixed, align_thinfixedcenter, @@ -145,6 +146,7 @@ static const char *const align_opt[] = { "small-right", "small-thin", "small-thin-fixed", + "small-thin-fixed-right", "thin", "thin-fixed", "thin-fixed-center", @@ -784,6 +786,9 @@ static int libd_drawString(lua_State *L) case align_smallthinfixed: V_DrawSmallThinStringAtFixed(x, y, flags, str); break; + case align_smallthinfixedright: + V_DrawRightAlignedSmallThinStringAtFixed(x, y, flags, str); + break; // tny_font case align_thin: V_DrawThinString(x, y, flags, str); diff --git a/src/v_video.c b/src/v_video.c index 2333631fb..a90735927 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2435,6 +2435,13 @@ void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) V_DrawSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string); } +/*void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x <<= FRACBITS; + y <<= FRACBITS; + V_DrawRightAlignedSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string); +}*/ + // Draws a string at a fixed_t location. void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) { @@ -2878,6 +2885,12 @@ void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char } } +void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_SmallThinStringWidth(string, option)/2; + V_DrawSmallThinStringAtFixed(x, y, option, string); +} + // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { @@ -3435,6 +3448,15 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) return w; } +// +// Find string width from tny_font chars, 0.5x scale +// +INT32 V_SmallThinStringWidth(const char *string, INT32 option) +{ + INT32 w = V_ThinStringWidth(string, option)<