Skip to content

Commit

Permalink
Fix overlapping dropshadows when using DBIGFONT in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Oct 27, 2024
1 parent abdf066 commit 8af07f4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/m_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
67 changes: 59 additions & 8 deletions src/v_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/v_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8af07f4

Please sign in to comment.