fix background erase for carousel and and various widgets (#2047)

* call ST_Drawer only once
This commit is contained in:
Roman Fomin 2024-11-25 14:57:48 +07:00 committed by GitHub
parent b85fde8e7c
commit 7ab1fa9995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 58 additions and 27 deletions

View File

@ -317,18 +317,12 @@ void D_Display (void)
switch (gamestate) // do buffered drawing switch (gamestate) // do buffered drawing
{ {
case GS_LEVEL: case GS_LEVEL:
if (!gametic) if (automapactive && !automapoverlay && gametic)
break;
if (automapactive)
{
if (!automapoverlay)
{ {
// [FG] update automap while playing // [FG] update automap while playing
R_RenderPlayerView(&players[displayplayer]); R_RenderPlayerView(&players[displayplayer]);
AM_Drawer(); AM_Drawer();
} }
ST_Drawer();
}
break; break;
case GS_INTERMISSION: case GS_INTERMISSION:
WI_Drawer(); WI_Drawer();
@ -345,10 +339,7 @@ void D_Display (void)
// draw the view directly // draw the view directly
if (gamestate == GS_LEVEL && automap_off && gametic) if (gamestate == GS_LEVEL && automap_off && gametic)
{ R_RenderPlayerView(&players[displayplayer]);
R_RenderPlayerView(&players[displayplayer]);
ST_Drawer();
}
// clean up border stuff // clean up border stuff
if (gamestate != oldgamestate && gamestate != GS_LEVEL) if (gamestate != oldgamestate && gamestate != GS_LEVEL)
@ -369,7 +360,6 @@ void D_Display (void)
if (borderdrawcount) if (borderdrawcount)
{ {
R_DrawViewBorder(); // erase old menu stuff R_DrawViewBorder(); // erase old menu stuff
ST_Drawer();
borderdrawcount--; borderdrawcount--;
} }
} }
@ -381,12 +371,13 @@ void D_Display (void)
if (gamestate == GS_LEVEL && automapactive && automapoverlay) if (gamestate == GS_LEVEL && automapactive && automapoverlay)
{ {
AM_Drawer(); AM_Drawer();
ST_Drawer();
// [crispy] force redraw of border // [crispy] force redraw of border
viewactivestate = false; viewactivestate = false;
} }
if (gamestate == GS_LEVEL && gametic)
ST_Drawer();
// draw pause pic // draw pause pic
if (paused) if (paused)
{ {

View File

@ -22,6 +22,7 @@
#include "m_array.h" #include "m_array.h"
#include "m_misc.h" #include "m_misc.h"
#include "r_defs.h" #include "r_defs.h"
#include "r_draw.h"
#include "st_sbardef.h" #include "st_sbardef.h"
#include "v_fmt.h" #include "v_fmt.h"
#include "v_video.h" #include "v_video.h"
@ -201,6 +202,22 @@ static int CalcOffset(void)
return 0; return 0;
} }
void ST_EraseCarousel(int y)
{
static boolean erase;
if (duration > 0)
{
R_VideoErase(0, y - 16, video.unscaledw, 32);
erase = true;
}
else if (erase)
{
R_VideoErase(0, y - 16, video.unscaledw, 32);
erase = false;
}
}
void ST_DrawCarousel(int x, int y, sbarelem_t *elem) void ST_DrawCarousel(int x, int y, sbarelem_t *elem)
{ {
if (duration == 0) if (duration == 0)

View File

@ -21,6 +21,8 @@ void ST_ResetCarousel(void);
void ST_UpdateCarousel(struct player_s *player); void ST_UpdateCarousel(struct player_s *player);
void ST_EraseCarousel(int y);
void ST_DrawCarousel(int x, int y, struct sbarelem_s *elem); void ST_DrawCarousel(int x, int y, struct sbarelem_s *elem);
#endif #endif

View File

@ -196,6 +196,8 @@ typedef struct sbe_widget_s
hudfont_t *font; hudfont_t *font;
widgetline_t *lines; widgetline_t *lines;
int height;
// message // message
int duration; int duration;
} sbe_widget_t; } sbe_widget_t;

View File

@ -1552,6 +1552,19 @@ static void DrawStatusBar(void)
DrawCenteredMessage(); DrawCenteredMessage();
} }
static void EraseBackground(int y, int height)
{
if (y > scaledviewy && y < scaledviewy + scaledviewheight - height)
{
R_VideoErase(0, y, scaledviewx, height);
R_VideoErase(scaledviewx + scaledviewwidth, y, scaledviewx, height);
}
else
{
R_VideoErase(0, y, video.unscaledw, height);
}
}
static void EraseElem(int x, int y, sbarelem_t *elem, player_t *player) static void EraseElem(int x, int y, sbarelem_t *elem, player_t *player)
{ {
if (!CheckConditions(elem->conditions, player)) if (!CheckConditions(elem->conditions, player))
@ -1578,16 +1591,21 @@ static void EraseElem(int x, int y, sbarelem_t *elem, player_t *player)
height += font->maxheight; height += font->maxheight;
} }
if (y > scaledviewy && y < scaledviewy + scaledviewheight - height) if (height > 0)
{ {
R_VideoErase(0, y, scaledviewx, height); EraseBackground(y, height);
R_VideoErase(scaledviewx + scaledviewwidth, y, scaledviewx, height); widget->height = height;
} }
else else if (widget->height)
{ {
R_VideoErase(0, y, video.unscaledw, height); EraseBackground(y, widget->height);
widget->height = 0;
} }
} }
else if (elem->type == sbe_carousel)
{
ST_EraseCarousel(y);
}
sbarelem_t *child; sbarelem_t *child;
array_foreach(child, elem->children) array_foreach(child, elem->children)
@ -1598,7 +1616,7 @@ static void EraseElem(int x, int y, sbarelem_t *elem, player_t *player)
void ST_Erase(void) void ST_Erase(void)
{ {
if (!sbardef) if (!sbardef || screenblocks >= 10)
{ {
return; return;
} }

View File

@ -89,9 +89,10 @@ static boolean message_review;
static void UpdateMessage(sbe_widget_t *widget, player_t *player) static void UpdateMessage(sbe_widget_t *widget, player_t *player)
{ {
ST_ClearLines(widget);
if (!player->message) if (!player->message)
{ {
ST_ClearLines(widget);
return; return;
} }
@ -129,12 +130,11 @@ static void UpdateMessage(sbe_widget_t *widget, player_t *player)
if (duration_left == 0) if (duration_left == 0)
{ {
ST_ClearLines(widget);
overwrite = true; overwrite = true;
} }
else else
{ {
SetLine(widget, string); ST_AddLine(widget, string);
--duration_left; --duration_left;
} }
} }
@ -464,6 +464,8 @@ boolean ST_MessagesResponder(event_t *ev)
static void UpdateChat(sbe_widget_t *widget) static void UpdateChat(sbe_widget_t *widget)
{ {
ST_ClearLines(widget);
static char string[HU_MAXLINELENGTH + 1]; static char string[HU_MAXLINELENGTH + 1];
string[0] = '\0'; string[0] = '\0';
@ -476,9 +478,8 @@ static void UpdateChat(sbe_widget_t *widget)
{ {
M_StringConcat(string, "_", sizeof(string)); M_StringConcat(string, "_", sizeof(string));
} }
ST_AddLine(widget, string);
} }
SetLine(widget, string);
} }
static boolean IsVanillaMap(int e, int m) static boolean IsVanillaMap(int e, int m)
@ -909,7 +910,7 @@ static void UpdateSpeed(sbe_widget_t *widget, player_t *player)
{ {
if (speedometer <= 0) if (speedometer <= 0)
{ {
SetLine(widget, ""); ST_ClearLines(widget);
return; return;
} }
@ -927,7 +928,7 @@ static void UpdateSpeed(sbe_widget_t *widget, player_t *player)
static char string[60]; static char string[60];
M_snprintf(string, sizeof(string), GRAY_S "%.*f " GREEN_S "%s", M_snprintf(string, sizeof(string), GRAY_S "%.*f " GREEN_S "%s",
type && speed ? 1 : 0, speed, units[type]); type && speed ? 1 : 0, speed, units[type]);
SetLine(widget, string); ST_AddLine(widget, string);
} }
static void UpdateCmd(sbe_widget_t *widget) static void UpdateCmd(sbe_widget_t *widget)