From 8af07f46175d4abe4fe115466dd2c3db91110a61 Mon Sep 17 00:00:00 2001 From: Brad Harding Date: Sun, 27 Oct 2024 14:29:36 +1100 Subject: [PATCH] Fix overlapping dropshadows when using DBIGFONT in menu --- src/m_font.c | 2 +- src/m_menu.c | 9 +++++++ src/v_video.c | 67 +++++++++++++++++++++++++++++++++++++++++++++------ src/v_video.h | 1 + 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/src/m_font.c b/src/m_font.c index 7505ac65a..c1e2a35f5 100644 --- a/src/m_font.c +++ b/src/m_font.c @@ -199,7 +199,7 @@ bool M_DrawFON2String(int x, int y, const char *str, bool highlight) cx += FON2_SPACE; else { - V_DrawMenuPatch(cx, y, chars[c].patch, highlight, SCREENWIDTH); + V_DrawBigFontPatch(cx, y, chars[c].patch, highlight, SCREENWIDTH); cx += chars[c].width + kerning; } } diff --git a/src/m_menu.c b/src/m_menu.c index 3a686b94c..f6055e37e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4363,6 +4363,9 @@ void M_Drawer(void) M_DrawPatchWithShadow(x - 26, yy, skullpatch, true); } + for (int i = 0; i < MAXSCREENAREA; i++) + tempscreen[i] = PINK; + for (int i = 0; i < max; i++) { bool highlight; @@ -4581,6 +4584,12 @@ void M_Drawer(void) y += LINEHEIGHT - 1; } + for (int i = 0; i < MAXSCREENAREA; i++) + if (tempscreen[i] == nearestblack) + screens[0][i] = black45[screens[0][i]]; + else if (tempscreen[i] != PINK) + screens[0][i] = tempscreen[i]; + for (int i = 0; i < max; i++) currentmenu->menuitems[i].width = widest; } diff --git a/src/v_video.c b/src/v_video.c index 41992d51e..bc4b16e0c 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -877,7 +877,6 @@ void V_DrawTranslucentAltHUDText(int x, int y, byte *screen, patch_t *patch, void V_DrawMenuPatch(int x, int y, patch_t *patch, bool highlight, int shadowwidth) { byte *desttop; - const byte *black = (highlight || !menuhighlight ? black40 : black45); const int width = SHORT(patch->width) << FRACBITS; y -= SHORT(patch->topoffset); @@ -917,7 +916,60 @@ void V_DrawMenuPatch(int x, int y, patch_t *patch, bool highlight, int shadowwid byte *dot = dest + SCREENWIDTH + 2; if (i <= shadowwidth && *dot != 47 && *dot != 191) - *dot = black[*dot]; + *dot = black40[*dot]; + } + + srccol += DYI; + } + + column = (column_t *)((byte *)column + length + 4); + } + } +} + +void V_DrawBigFontPatch(int x, int y, patch_t *patch, bool highlight, int shadowwidth) +{ + byte *desttop; + const int width = SHORT(patch->width) << FRACBITS; + + y -= SHORT(patch->topoffset); + x -= SHORT(patch->leftoffset); + x += WIDESCREENDELTA; + + desttop = &tempscreen[((y * DY) >> FRACBITS) * SCREENWIDTH + ((x * DX) >> FRACBITS)]; + + for (int col = 0, i = 0; col < width; col += DXI, i++, desttop++) + { + column_t *column = (column_t *)((byte *)patch + LONG(patch->columnoffset[col >> FRACBITS])); + + // step through the posts in a column + while (column->topdelta != 0xFF) + { + const byte *source = (byte *)column + 3; + byte *dest = &desttop[((column->topdelta * DY) >> FRACBITS) * SCREENWIDTH]; + const byte length = column->length; + int count = (length * DY) >> FRACBITS; + int srccol = 0; + + while (count-- > 0) + { + const int height = (((y + column->topdelta + length) * DY) >> FRACBITS) - count; + + if (height > 0) + { + const byte dot = source[srccol >> FRACBITS]; + + *dest = (menuhighlight ? (highlight ? gold4[dot] : colormaps[0][6 * 256 + dot]) : dot); + } + + dest += SCREENWIDTH; + + if (height + 2 > 0 && menushadow) + { + byte *dot = dest + SCREENWIDTH + 2; + + if (i <= shadowwidth && *dot != 47 && *dot != 191) + *dot = nearestblack; } srccol += DYI; @@ -1692,16 +1744,15 @@ void V_DrawPixel(int x, int y, byte color, bool highlight, bool shadow) { if (shadow && menushadow) { - byte *dot = *screens + (y * SCREENWIDTH + x + WIDESCREENDELTA) * 2; - const byte *black = (highlight || !menuhighlight ? black40 : black45); + byte *dot = *screens + (y * SCREENWIDTH + x + WIDESCREENDELTA) * 2; - *dot = black[*dot]; + *dot = black40[*dot]; dot++; - *dot = black[*dot]; + *dot = black40[*dot]; dot += SCREENWIDTH; - *dot = black[*dot]; + *dot = black40[*dot]; dot--; - *dot = black[*dot]; + *dot = black40[*dot]; } } else if (color && color != 32) diff --git a/src/v_video.h b/src/v_video.h index d135b8562..ae8930e28 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -91,6 +91,7 @@ void V_DrawSolidShadowPatch(int x, int y, patch_t *patch); void V_DrawSpectreShadowPatch(int x, int y, patch_t *patch); bool V_IsEmptyPatch(patch_t *patch); void V_DrawMenuPatch(int x, int y, patch_t *patch, bool highlight, int shadowwidth); +void V_DrawBigFontPatch(int x, int y, patch_t *patch, bool highlight, int shadowwidth); void V_DrawHelpPatch(patch_t *patch); void V_DrawFlippedPatch(int x, int y, patch_t *patch); void V_DrawFlippedShadowPatch(int x, int y, patch_t *patch);