From 93b64a8d7d319bb3932739c36898a61ad2dfffbb Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 24 Aug 2019 09:27:37 -0500 Subject: [PATCH] Create V_DrawThinStringAtFixed() for new "thin-fixed" option in v.drawString() --- src/lua_hudlib.c | 5 +++ src/v_video.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 1 + 3 files changed, 97 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 235010f2a..0290eedeb 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -116,6 +116,7 @@ enum align { align_small, align_smallright, align_thin, + align_thinfixed, align_thinright }; static const char *const align_opt[] = { @@ -126,6 +127,7 @@ static const char *const align_opt[] = { "small", "small-right", "thin", + "thin-fixed", "thin-right", NULL}; @@ -743,6 +745,9 @@ static int libd_drawString(lua_State *L) case align_thinright: V_DrawRightAlignedThinString(x, y, flags, str); break; + case align_thinfixed: + V_DrawThinStringAtFixed(x, y, flags, str); + break; } return 0; } diff --git a/src/v_video.c b/src/v_video.c index 4785a1541..fa8d2cd37 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2511,6 +2511,97 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) } } +// Draws a thin string at a fixed_t location. +void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + fixed_t cx = x, cy = y; + INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0; + const char *ch = string; + INT32 spacewidth = 2, charwidth = 0; + + INT32 lowercase = (option & V_ALLOWLOWERCASE); + option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... + + if (option & V_NOSCALESTART) + { + dupx = vid.dupx; + dupy = vid.dupy; + scrwidth = vid.width; + } + else + { + dupx = dupy = 1; + scrwidth = vid.width/vid.dupx; + left = (scrwidth - BASEVIDWIDTH)/2; + scrwidth -= left; + } + + switch (option & V_SPACINGMASK) + { + case V_MONOSPACE: + spacewidth = 8; + /* FALLTHRU */ + case V_OLDSPACING: + charwidth = 8; + break; + case V_6WIDTHSPACE: + spacewidth = 6; + default: + break; + } + + for (;;ch++) + { + if (!*ch) + break; + if (*ch & 0x80) //color ignoring + continue; + if (*ch == '\n') + { + cx = x; + + if (option & V_RETURN8) + cy += (8*dupy)<= HU_FONTSIZE || !tny_font[c]) + { + cx += (spacewidth * dupx)<width)*(dupx/2); + } + else + w = SHORT(tny_font[c]->width) * dupx; + + if ((cx>>FRACBITS) > scrwidth) + break; + if ((cx>>FRACBITS)+left + w < 0) //left boundary check + { + cx += w<