From 0da462836fe33f67e7968d76bd26ece1924ad899 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 24 Aug 2019 09:27:37 -0500 Subject: [PATCH 01/21] 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< Date: Sat, 24 Aug 2019 11:45:32 -0500 Subject: [PATCH 02/21] Create V_DrawSmallStringAtFixed() for new "small-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 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< Date: Tue, 27 Aug 2019 02:27:25 -0500 Subject: [PATCH 03/21] Add V_COLORMAP support for small-fixed and thin-fixed text. --- src/v_video.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 98a87fd6f..aaa796e8b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2517,6 +2517,8 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st fixed_t cx = x, cy = y; INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0; const char *ch = string; + INT32 charflags = 0; + const UINT8 *colormap = NULL; INT32 spacewidth = 2, charwidth = 0; INT32 lowercase = (option & V_ALLOWLOWERCASE); @@ -2536,6 +2538,8 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st scrwidth -= left; } + charflags = (option & V_CHARCOLORMASK); + switch (option & V_SPACINGMASK) { case V_MONOSPACE: @@ -2554,8 +2558,13 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st { if (!*ch) break; - if (*ch & 0x80) //color ignoring + if (*ch & 0x80) //color parsing -x 2.16.09 + { + // manually set flags override color codes + if (!(option & V_CHARCOLORMASK)) + charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; continue; + } if (*ch == '\n') { cx = x; @@ -2596,7 +2605,9 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st continue; } - V_DrawSciencePatch(cx + (center< Date: Tue, 27 Aug 2019 02:57:19 -0500 Subject: [PATCH 04/21] Create V_DrawCenteredSmallString() for new "small-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 7 +++++++ src/v_video.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 914b2fecf..e0d3c52fa 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -115,6 +115,7 @@ enum align { align_fixed, align_small, align_smallfixed, + align_smallcenter, align_smallright, align_thin, align_thinfixed, @@ -127,6 +128,7 @@ static const char *const align_opt[] = { "fixed", "small", "small-fixed", + "small-center", "small-right", "thin", "thin-fixed", @@ -740,6 +742,9 @@ static int libd_drawString(lua_State *L) case align_smallfixed: V_DrawSmallStringAtFixed(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; diff --git a/src/v_video.c b/src/v_video.c index aaa796e8b..973cbc0c4 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); diff --git a/src/v_video.h b/src/v_video.h index 06397d409..6f03c4d8f 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -205,6 +205,7 @@ void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string // draw a string using the hu_font, 0.5x scale void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawCenteredSmallString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string); // draw a string using the tny_font From 7ef82c6f086004deddb624c271f9ea8eedd26bb8 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 27 Aug 2019 03:05:03 -0500 Subject: [PATCH 05/21] Create V_DrawCenteredThinString() for new "thin-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e0d3c52fa..12b894bf2 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -119,6 +119,7 @@ enum align { align_smallright, align_thin, align_thinfixed, + align_thincenter, align_thinright }; static const char *const align_opt[] = { @@ -132,6 +133,7 @@ static const char *const align_opt[] = { "small-right", "thin", "thin-fixed", + "thin-center", "thin-right", NULL}; @@ -752,6 +754,9 @@ static int libd_drawString(lua_State *L) 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; diff --git a/src/v_video.c b/src/v_video.c index 973cbc0c4..1e4217e4e 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2411,6 +2411,12 @@ 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); diff --git a/src/v_video.h b/src/v_video.h index 6f03c4d8f..9a0fe51d4 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -210,6 +210,7 @@ void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *s // draw a string using the tny_font void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); From 3c00c22a1dac99f9f073a7b1b2154c4f6e73ca45 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 27 Aug 2019 03:25:28 -0500 Subject: [PATCH 06/21] 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)< Date: Tue, 27 Aug 2019 03:28:45 -0500 Subject: [PATCH 07/21] Fixed v_video.h declaration for V_DrawRightAlignedStringAtFixed() --- src/v_video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.h b/src/v_video.h index cf096ae4b..0c8477adc 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -215,7 +215,7 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st // draw a string using the hu_font at fixed_t coordinates void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawRightAlignedStringAtFixed(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); From 3d2934350d4f3001c6e1498d37a9a6be1059aa2c Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 27 Aug 2019 03:36:12 -0500 Subject: [PATCH 08/21] Create V_DrawCenteredStringAtFixed() for new "fixed-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index ed8e1b676..906afede8 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -113,6 +113,7 @@ enum align { align_center, align_right, align_fixed, + align_fixedcenter, align_fixedright, align_small, align_smallfixed, @@ -128,6 +129,7 @@ static const char *const align_opt[] = { "center", "right", "fixed", + "fixed-center", "fixed-right", "small", "small-fixed", @@ -739,6 +741,9 @@ 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; diff --git a/src/v_video.c b/src/v_video.c index 1b95d0145..d4aad6a64 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_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= (V_StringWidth(string, option) / 2)< Date: Tue, 27 Aug 2019 22:44:19 -0500 Subject: [PATCH 09/21] Create V_DrawSmallThinString() for new "small-thin" option in v.drawString() Note this has some major limitations to prevent squished text. It defaults to using V_MONOSPACE|V_OLDSPACING and you cannot change the size of characters. V_6WIDTHSPACE seems to act exactly the same as V_OLDSPACING too. --- src/lua_hudlib.c | 5 ++ src/v_video.c | 205 +++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 3 + 3 files changed, 213 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 906afede8..c10bc2efd 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -119,6 +119,7 @@ enum align { align_smallfixed, align_smallcenter, align_smallright, + align_smallthin, align_thin, align_thinfixed, align_thincenter, @@ -135,6 +136,7 @@ static const char *const align_opt[] = { "small-fixed", "small-center", "small-right", + "small-thin", "thin", "thin-fixed", "thin-center", @@ -760,6 +762,9 @@ static int libd_drawString(lua_State *L) case align_smallright: V_DrawRightAlignedSmallString(x, y, flags, str); break; + case align_smallthin: + V_DrawSmallThinString(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 d4aad6a64..7a51c9088 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2423,6 +2423,211 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st 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 +// +/* +void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0; + const char *ch = string; + INT32 charflags = 0; + const UINT8 *colormap = NULL; + 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)/4; + scrwidth -= left; + } + + charflags = (option & V_CHARCOLORMASK); + + switch (option & V_SPACINGMASK) + { + case V_MONOSPACE: + spacewidth = 3; + // FALLTHRU + case V_OLDSPACING: + charwidth = 3; + break; + case V_6WIDTHSPACE: + spacewidth = 2; + default: + break; + } + + for (;;ch++) + { + if (!*ch) + break; + if (*ch & 0x80) //color parsing -x 2.16.09 + { + // manually set flags override color codes + if (!(option & V_CHARCOLORMASK)) + charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + continue; + } + if (*ch == '\n') + { + cx = x; + + if (option & V_RETURN8) + cy += 4*dupy; + else + cy += 6*dupy; + + continue; + } + + c = *ch; + if (!lowercase || !tny_font[c-HU_FONTSTART]) + c = toupper(c); + c -= HU_FONTSTART; + + if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) + { + cx += spacewidth * dupx; + continue; + } + + if (charwidth) + { + w = 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)<= HU_FONTSIZE || !tny_font[c]) + { + cx += spacewidth * dupx; + continue; + } + + if (charwidth) + { + w = 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)< Date: Tue, 27 Aug 2019 22:48:16 -0500 Subject: [PATCH 10/21] remove large commented broken version of V_DrawSmallThinString() lol --- src/v_video.c | 97 --------------------------------------------------- 1 file changed, 97 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 7a51c9088..33608de44 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2427,103 +2427,6 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st // Write a string using the tny_font, 0.5x scale // NOTE: the text is centered for screens larger than the base width // -/* -void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) -{ - INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0; - const char *ch = string; - INT32 charflags = 0; - const UINT8 *colormap = NULL; - 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)/4; - scrwidth -= left; - } - - charflags = (option & V_CHARCOLORMASK); - - switch (option & V_SPACINGMASK) - { - case V_MONOSPACE: - spacewidth = 3; - // FALLTHRU - case V_OLDSPACING: - charwidth = 3; - break; - case V_6WIDTHSPACE: - spacewidth = 2; - default: - break; - } - - for (;;ch++) - { - if (!*ch) - break; - if (*ch & 0x80) //color parsing -x 2.16.09 - { - // manually set flags override color codes - if (!(option & V_CHARCOLORMASK)) - charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; - continue; - } - if (*ch == '\n') - { - cx = x; - - if (option & V_RETURN8) - cy += 4*dupy; - else - cy += 6*dupy; - - continue; - } - - c = *ch; - if (!lowercase || !tny_font[c-HU_FONTSTART]) - c = toupper(c); - c -= HU_FONTSTART; - - if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) - { - cx += spacewidth * dupx; - continue; - } - - if (charwidth) - { - w = 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)< Date: Sat, 7 Sep 2019 17:37:21 -0500 Subject: [PATCH 11/21] Create V_DrawRightAlignedThinStringAtFixed() for new "thin-fixed-right" option in v.drawString() These function names are starting to become rediculous... --- 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 c10bc2efd..61c1ea141 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -122,6 +122,7 @@ enum align { align_smallthin, align_thin, align_thinfixed, + align_thinfixedright, align_thincenter, align_thinright }; @@ -139,6 +140,7 @@ static const char *const align_opt[] = { "small-thin", "thin", "thin-fixed", + "thin-fixed-right", "thin-center", "thin-right", NULL}; @@ -778,6 +780,9 @@ static int libd_drawString(lua_State *L) case align_thinfixed: V_DrawThinStringAtFixed(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 33608de44..c59bebf34 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2848,6 +2848,12 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str } } +void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_ThinStringWidth(string, option)< Date: Sat, 7 Sep 2019 17:41:03 -0500 Subject: [PATCH 12/21] Fixed V_DrawRightAlignedThinStringAtFixed declaration to use fixed_t for positioning. --- src/v_video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.h b/src/v_video.h index fcf71e9d1..311ec8310 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -225,7 +225,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st // draw a string using the tny_font at fixed_t coordinates void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawRightAlignedThinStringAtFixed(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); // Draw tall nums, used for menu, HUD, intermission void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); From ce744a5ebe0f5eaa71f7a1ef80f362f4b8549630 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 7 Sep 2019 17:55:33 -0500 Subject: [PATCH 13/21] Create V_DrawCenteredThinStringAtFixed() for new "thin-fixed-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 61c1ea141..bf03b351b 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -122,6 +122,7 @@ enum align { align_smallthin, align_thin, align_thinfixed, + align_thinfixedcenter, align_thinfixedright, align_thincenter, align_thinright @@ -140,6 +141,7 @@ static const char *const align_opt[] = { "small-thin", "thin", "thin-fixed", + "thin-fixed-center", "thin-fixed-right", "thin-center", "thin-right", @@ -780,6 +782,9 @@ static int libd_drawString(lua_State *L) 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; diff --git a/src/v_video.c b/src/v_video.c index c59bebf34..d80b507bc 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2848,6 +2848,12 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str } } +void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= (V_ThinStringWidth(string, option) / 2)< Date: Mon, 9 Sep 2019 19:49:04 -0500 Subject: [PATCH 14/21] Create V_DrawRightAlignedSmallStringAtFixed() for new "small-fixed-right" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index bf03b351b..7a633f757 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -117,6 +117,7 @@ enum align { align_fixedright, align_small, align_smallfixed, + align_smallfixedright, align_smallcenter, align_smallright, align_smallthin, @@ -136,6 +137,7 @@ static const char *const align_opt[] = { "fixed-right", "small", "small-fixed", + "small-fixed-right", "small-center", "small-right", "small-thin", @@ -760,6 +762,9 @@ static int libd_drawString(lua_State *L) case align_smallfixed: V_DrawSmallStringAtFixed(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; diff --git a/src/v_video.c b/src/v_video.c index d80b507bc..dba9ed2dc 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2746,6 +2746,12 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st } } +void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_SmallStringWidth(string, option)< Date: Mon, 9 Sep 2019 20:41:34 -0500 Subject: [PATCH 15/21] Create V_DrawCenteredSmallStringAtFixed() for new "small-fixed-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 7a633f757..f890f62c0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -117,6 +117,7 @@ enum align { align_fixedright, align_small, align_smallfixed, + align_smallfixedcenter, align_smallfixedright, align_smallcenter, align_smallright, @@ -137,6 +138,7 @@ static const char *const align_opt[] = { "fixed-right", "small", "small-fixed", + "small-fixed-center", "small-fixed-right", "small-center", "small-right", @@ -762,6 +764,9 @@ static int libd_drawString(lua_State *L) 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; diff --git a/src/v_video.c b/src/v_video.c index dba9ed2dc..a4c1bf6ba 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2746,6 +2746,12 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st } } +void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= (V_SmallStringWidth(string, option) / 2)< Date: Mon, 9 Sep 2019 21:25:52 -0500 Subject: [PATCH 16/21] Create V_DrawSmallThinStringAtFixed() for new "small-thin-fixed" option in v.drawString() I removed the limitation present in "small-thin" by converting all relevant variables to fixed_t's and using FixedMul() and FixedDiv() when necessary. Who'da thunk it would actually work? --- src/lua_hudlib.c | 5 +++ src/v_video.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 2 + 3 files changed, 109 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f890f62c0..935a41b43 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -122,6 +122,7 @@ enum align { align_smallcenter, align_smallright, align_smallthin, + align_smallthinfixed, align_thin, align_thinfixed, align_thinfixedcenter, @@ -143,6 +144,7 @@ static const char *const align_opt[] = { "small-center", "small-right", "small-thin", + "small-thin-fixed", "thin", "thin-fixed", "thin-fixed-center", @@ -779,6 +781,9 @@ static int libd_drawString(lua_State *L) case align_smallthin: V_DrawSmallThinString(x, y, flags, str); break; + case align_smallthinfixed: + V_DrawSmallThinStringAtFixed(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 a4c1bf6ba..3e64c7748 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2872,6 +2872,108 @@ void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, con V_DrawThinStringAtFixed(x, y, option, string); } +// Draws a small string at a fixed_t location. +void V_DrawSmallThinStringAtFixed(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 charflags = 0; + const UINT8 *colormap = NULL; + INT32 spacewidth = 2<= 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; + } +} + // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { diff --git a/src/v_video.h b/src/v_video.h index 33328de8c..f1e33e154 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -231,6 +231,8 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); +void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); + // Draw tall nums, used for menu, HUD, intermission void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits); From 0306d4580f001c635e347002a4cfacf5cb9cdd8c Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 28 Sep 2019 13:01:58 -0500 Subject: [PATCH 17/21] Make V_DrawSmallThinString() a less precise wrapper for V_DrawSmallThinStringAtFixed() to fix rounding errors. --- src/v_video.c | 104 ++------------------------------------------------ 1 file changed, 4 insertions(+), 100 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 3e64c7748..2333631fb 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2427,108 +2427,12 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st // 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) { - INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0; - const char *ch = string; - INT32 charflags = 0; - const UINT8 *colormap = NULL; - 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; - } - - charflags = (option & V_CHARCOLORMASK); - - // Monospace only + spacing changes, otherwise the characters are squished together. ~Golden - switch (option & V_SPACINGMASK) - { - case V_MONOSPACE: - spacewidth = 3; - /* FALLTHRU */ - case V_OLDSPACING: - charwidth = 3; - break; - case V_6WIDTHSPACE: - spacewidth = 2; - charwidth = 3; - break; - default: - spacewidth = 3; - charwidth = 3; - break; - } - - for (;;ch++) - { - if (!*ch) - break; - if (*ch & 0x80) //color parsing -x 2.16.09 - { - // manually set flags override color codes - if (!(option & V_CHARCOLORMASK)) - charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; - continue; - } - if (*ch == '\n') - { - cx = x; - - if (option & V_RETURN8) - cy += 4*dupy; - else - cy += 6*dupy; - - continue; - } - - c = *ch; - if (!lowercase) - c = toupper(c); - c -= HU_FONTSTART; - - // character does not exist or is a space - if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) - { - cx += spacewidth * dupx; - continue; - } - - if (charwidth) - { - w = 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)< Date: Tue, 8 Oct 2019 21:54:18 -0500 Subject: [PATCH 18/21] 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)< Date: Tue, 8 Oct 2019 22:03:43 -0500 Subject: [PATCH 19/21] Create V_DrawCenteredSmallThinStringAtFixed() for new "small-thin-fixed-center" option in v.drawString() Thankfully "center" is just "right" but with the X offset divided by 2. --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 6 ++++++ src/v_video.h | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e5c384949..60d4d1c21 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -123,6 +123,7 @@ enum align { align_smallright, align_smallthin, align_smallthinfixed, + align_smallthinfixedcenter, align_smallthinfixedright, align_thin, align_thinfixed, @@ -146,6 +147,7 @@ static const char *const align_opt[] = { "small-right", "small-thin", "small-thin-fixed", + "small-thin-fixed-center", "small-thin-fixed-right", "thin", "thin-fixed", @@ -786,6 +788,9 @@ static int libd_drawString(lua_State *L) 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; diff --git a/src/v_video.c b/src/v_video.c index a90735927..cdacd8127 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2885,6 +2885,12 @@ void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char } } +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; diff --git a/src/v_video.h b/src/v_video.h index 5b038419f..9c7d67b11 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -233,7 +233,8 @@ void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, con // draw a string using the tny_font at fixed_t coordinates, 0.5x scale void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); -void V_DrawRightAlignedSmallThinStringAtFixed(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); +void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); // Draw tall nums, used for menu, HUD, intermission void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); From 7a00a08a52163ed01b4b6f5c0b82b97cda35558d Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 8 Oct 2019 22:11:40 -0500 Subject: [PATCH 20/21] Make V_DrawRightAlignedSmallThinString() a less precise wrapper for V_DrawRightAlignedSmallThinStringAtFixed() for new "small-thin-right" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 4 ++-- src/v_video.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 60d4d1c21..5c2cd6e32 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -122,6 +122,7 @@ enum align { align_smallcenter, align_smallright, align_smallthin, + align_smallthinright, align_smallthinfixed, align_smallthinfixedcenter, align_smallthinfixedright, @@ -146,6 +147,7 @@ static const char *const align_opt[] = { "small-center", "small-right", "small-thin", + "small-thin-right", "small-thin-fixed", "small-thin-fixed-center", "small-thin-fixed-right", @@ -785,6 +787,9 @@ static int libd_drawString(lua_State *L) case align_smallthin: V_DrawSmallThinString(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; diff --git a/src/v_video.c b/src/v_video.c index cdacd8127..e7cf845d8 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2435,12 +2435,12 @@ 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) +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) diff --git a/src/v_video.h b/src/v_video.h index 9c7d67b11..169687183 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -215,6 +215,7 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st // draw a string using the tny_font, 0.5x scale void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); // draw a string using the hu_font at fixed_t coordinates void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); From c25e4bb1d83dc43528547ef5b7c7084093363dda Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 8 Oct 2019 22:16:50 -0500 Subject: [PATCH 21/21] Make V_DrawCenteredSmallThinString() a less precise wrapper for V_DrawCenteredSmallThinStringAtFixed() for new "small-thin-center" option in v.drawString() --- src/lua_hudlib.c | 5 +++++ src/v_video.c | 7 +++++++ src/v_video.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 5c2cd6e32..d15fe2cea 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -122,6 +122,7 @@ enum align { align_smallcenter, align_smallright, align_smallthin, + align_smallthincenter, align_smallthinright, align_smallthinfixed, align_smallthinfixedcenter, @@ -147,6 +148,7 @@ static const char *const align_opt[] = { "small-center", "small-right", "small-thin", + "small-thin-center", "small-thin-right", "small-thin-fixed", "small-thin-fixed-center", @@ -787,6 +789,9 @@ static int libd_drawString(lua_State *L) 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; diff --git a/src/v_video.c b/src/v_video.c index e7cf845d8..8a4a3a030 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_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; diff --git a/src/v_video.h b/src/v_video.h index 169687183..1e7af29d2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -215,6 +215,7 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st // draw a string using the tny_font, 0.5x scale void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); +void V_DrawCenteredSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); // draw a string using the hu_font at fixed_t coordinates