diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index d14a43944..bf8fe017b 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -119,9 +119,25 @@ enum align { align_center, align_right, align_fixed, + align_fixedcenter, + align_fixedright, align_small, + align_smallfixed, + align_smallfixedcenter, + align_smallfixedright, + align_smallcenter, align_smallright, + align_smallthin, + align_smallthincenter, + align_smallthinright, + align_smallthinfixed, + align_smallthinfixedcenter, + align_smallthinfixedright, align_thin, + align_thinfixed, + align_thinfixedcenter, + align_thinfixedright, + align_thincenter, align_thinright }; static const char *const align_opt[] = { @@ -129,9 +145,25 @@ static const char *const align_opt[] = { "center", "right", "fixed", + "fixed-center", + "fixed-right", "small", + "small-fixed", + "small-fixed-center", + "small-fixed-right", + "small-center", "small-right", + "small-thin", + "small-thin-center", + "small-thin-right", + "small-thin-fixed", + "small-thin-fixed-center", + "small-thin-fixed-right", "thin", + "thin-fixed", + "thin-fixed-center", + "thin-fixed-right", + "thin-center", "thin-right", NULL}; @@ -775,20 +807,68 @@ static int libd_drawString(lua_State *L) case align_fixed: V_DrawStringAtFixed(x, y, flags, str); break; + case align_fixedcenter: + V_DrawCenteredStringAtFixed(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); break; + 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; + case align_smallcenter: + V_DrawCenteredSmallString(x, y, flags, str); + break; case align_smallright: V_DrawRightAlignedSmallString(x, y, flags, str); break; + case align_smallthin: + V_DrawSmallThinString(x, y, flags, str); + break; + case align_smallthincenter: + V_DrawCenteredSmallThinString(x, y, flags, str); + break; + case align_smallthinright: + V_DrawRightAlignedSmallThinString(x, y, flags, str); + break; + case align_smallthinfixed: + V_DrawSmallThinStringAtFixed(x, y, flags, str); + break; + case align_smallthinfixedcenter: + V_DrawCenteredSmallThinStringAtFixed(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); break; + case align_thincenter: + V_DrawCenteredThinString(x, y, flags, str); + break; case align_thinright: V_DrawRightAlignedThinString(x, y, flags, str); break; + case align_thinfixed: + V_DrawThinStringAtFixed(x, y, flags, str); + break; + case align_thinfixedcenter: + V_DrawCenteredThinStringAtFixed(x, y, flags, str); + break; + case align_thinfixedright: + V_DrawRightAlignedThinStringAtFixed(x, y, flags, str); + break; } return 0; } diff --git a/src/v_video.c b/src/v_video.c index 81625ff9e..a1e702f7e 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2299,6 +2299,13 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) } } +void V_DrawCenteredSmallString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x -= V_SmallStringWidth(string, option)/2; + V_DrawSmallString(x, y, option, string); +} + + void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string) { x -= V_SmallStringWidth(string, option); @@ -2404,12 +2411,44 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) } } +void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x -= V_ThinStringWidth(string, option)/2; + V_DrawThinString(x, y, option, string); +} + void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string) { x -= V_ThinStringWidth(string, option); V_DrawThinString(x, y, option, string); } +// +// Write a string using the tny_font, 0.5x scale +// NOTE: the text is centered for screens larger than the base width +// +// Literally a wrapper. ~Golden +void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x <<= FRACBITS; + y <<= FRACBITS; + V_DrawSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string); +} + +void V_DrawCenteredSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x <<= FRACBITS; + y <<= FRACBITS; + V_DrawCenteredSmallThinStringAtFixed((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) { @@ -2511,6 +2550,360 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) } } +void V_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= (V_StringWidth(string, option) / 2)<= 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<= 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<= HU_FONTSIZE || !tny_font[c]) + { + cx += FixedMul(spacewidth, dupx); + continue; + } + + if (charwidth) + { + w = FixedMul(charwidth, dupx); + center = w/2 - SHORT(tny_font[c]->width)*(dupx/4); + } + else + w = SHORT(tny_font[c]->width) * dupx / 2; + + if (cx > scrwidth) + break; + if (cx+left + w < 0) //left boundary check + { + cx += w; + continue; + } + + colormap = V_GetStringColormap(charflags); + + V_DrawFixedPatch(cx + center, cy, FRACUNIT/2, option, tny_font[c], colormap); + + cx += w; + } +} + +void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_SmallThinStringWidth(string, option)/4; + V_DrawSmallThinStringAtFixed(x, y, option, string); +} + +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) { @@ -3068,6 +3461,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)<