diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 0290eedeb..914b2fecf 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -114,6 +114,7 @@ enum align { align_right, align_fixed, align_small, + align_smallfixed, align_smallright, align_thin, align_thinfixed, @@ -125,6 +126,7 @@ static const char *const align_opt[] = { "right", "fixed", "small", + "small-fixed", "small-right", "thin", "thin-fixed", @@ -735,6 +737,9 @@ static int libd_drawString(lua_State *L) case align_small: V_DrawSmallString(x, y, flags, str); break; + case align_smallfixed: + V_DrawSmallStringAtFixed(x, y, flags, str); + break; case align_smallright: V_DrawRightAlignedSmallString(x, y, flags, str); break; diff --git a/src/v_video.c b/src/v_video.c index fa8d2cd37..98a87fd6f 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 small string at a fixed_t location. +void V_DrawSmallStringAtFixed(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 = 4; + /* FALLTHRU */ + case V_OLDSPACING: + charwidth = 4; + break; + case V_6WIDTHSPACE: + spacewidth = 3; + default: + break; + } + + for (;;ch++) + { + if (!*ch) + break; + if (*ch & 0x80) //color ignoring + continue; + if (*ch == '\n') + { + cx = x; + + if (option & V_RETURN8) + cy += (4*dupy)<= HU_FONTSIZE || !hu_font[c]) + { + cx += (spacewidth * dupx)<width)*(dupx/4); + } + else + w = SHORT(hu_font[c]->width) * dupx / 2; + + if ((cx>>FRACBITS) > scrwidth) + break; + if ((cx>>FRACBITS)+left + w < 0) //left boundary check + { + cx += w<