mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
optimise HUD widget erasing, avoid flicker when screen size is reduced (#1349)
This commit is contained in:
parent
e4464862c5
commit
b2c7b40641
@ -317,6 +317,7 @@ void D_Display (void)
|
||||
if (borderdrawcount)
|
||||
{
|
||||
R_DrawViewBorder (); // erase old menu stuff
|
||||
HU_Drawer ();
|
||||
borderdrawcount--;
|
||||
}
|
||||
}
|
||||
|
31
src/hu_lib.c
31
src/hu_lib.c
@ -22,6 +22,8 @@
|
||||
#include "m_swap.h"
|
||||
#include "hu_lib.h"
|
||||
#include "hu_stuff.h"
|
||||
#include "r_draw.h"
|
||||
#include "v_video.h"
|
||||
|
||||
// [FG] horizontal alignment
|
||||
|
||||
@ -121,12 +123,11 @@ boolean HUlib_add_key_to_line(hu_line_t *const l, unsigned char ch)
|
||||
{
|
||||
if (ch >= ' ' && ch <= '_')
|
||||
add_char_to_line(l, (char) ch);
|
||||
else
|
||||
if (ch == KEY_BACKSPACE) // phares
|
||||
else if (ch == KEY_BACKSPACE) // phares
|
||||
del_char_from_line(l);
|
||||
else
|
||||
if (ch != KEY_ENTER) // phares
|
||||
else if (ch != KEY_ENTER) // phares
|
||||
return false; // did not eat key
|
||||
|
||||
return true; // ate the key
|
||||
}
|
||||
|
||||
@ -503,6 +504,28 @@ void HUlib_init_multiline(hu_multiline_t *m,
|
||||
m->built = false;
|
||||
}
|
||||
|
||||
void HUlib_erase_widget (const hu_widget_t *const w)
|
||||
{
|
||||
const hu_multiline_t *const m = w->multiline;
|
||||
const hu_font_t *const f = *m->font;
|
||||
|
||||
const int height = m->numlines * f->line_height;
|
||||
const int y = vert_align_widget(w, m, f, w->h_align, w->v_align);
|
||||
|
||||
if (y < scaledviewy || y >= scaledviewy + scaledviewheight)
|
||||
{
|
||||
// erase entire line
|
||||
R_VideoErase(0, y, video.unscaledw, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// erase left border
|
||||
R_VideoErase(0, y, scaledviewx, height);
|
||||
// erase right border
|
||||
R_VideoErase(scaledviewx + scaledviewwidth, y, scaledviewx, height);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log: hu_lib.c,v $
|
||||
|
@ -137,6 +137,8 @@ void HUlib_init_multiline (hu_multiline_t *const m, int nl, hu_font_t **f, char
|
||||
boolean HUlib_add_key_to_line (hu_line_t *const l, unsigned char ch);
|
||||
boolean HUlib_add_key_to_cur_line (hu_multiline_t *const m, unsigned char ch);
|
||||
|
||||
void HUlib_erase_widget (const hu_widget_t *const w);
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "hu_stuff.h"
|
||||
#include "hu_obituary.h"
|
||||
#include "hu_lib.h"
|
||||
#include "r_state.h"
|
||||
#include "st_stuff.h" /* jff 2/16/98 need loc of status bar */
|
||||
#include "w_wad.h"
|
||||
#include "s_sound.h"
|
||||
@ -1423,15 +1424,6 @@ void HU_Drawer(void)
|
||||
|
||||
HUlib_reset_align_offsets();
|
||||
|
||||
// jff 4/24/98 Erase current lines before drawing current
|
||||
// needed when screen not fullsize
|
||||
// killough 11/98: only do it when not fullsize
|
||||
// moved here to properly update the w_sttime and w_monsec widgets
|
||||
if (scaledviewheight < 200)
|
||||
{
|
||||
HU_Erase();
|
||||
}
|
||||
|
||||
w = doom_widget;
|
||||
while (w->multiline)
|
||||
{
|
||||
@ -1482,9 +1474,32 @@ void WI_DrawTimeWidget(void)
|
||||
|
||||
void HU_Erase(void)
|
||||
{
|
||||
// [FG] TODO optimize!
|
||||
if (!automapactive && viewwindowx)
|
||||
R_DrawViewBorder();
|
||||
hu_widget_t *w;
|
||||
|
||||
if (automapactive || !scaledviewx)
|
||||
return;
|
||||
|
||||
HUlib_reset_align_offsets();
|
||||
|
||||
w = doom_widget;
|
||||
while (w->multiline)
|
||||
{
|
||||
if (*w->multiline->on)
|
||||
{
|
||||
HUlib_erase_widget(w);
|
||||
}
|
||||
w++;
|
||||
}
|
||||
|
||||
w = boom_widget;
|
||||
while (w->multiline)
|
||||
{
|
||||
if (w->multiline->built)
|
||||
{
|
||||
HUlib_erase_widget(w);
|
||||
}
|
||||
w++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -913,8 +913,11 @@ void R_FillBackScreen (void)
|
||||
// Copy a screen buffer.
|
||||
//
|
||||
|
||||
static void R_VideoErase(int x, int y, int w, int h)
|
||||
void R_VideoErase(int x, int y, int w, int h)
|
||||
{
|
||||
if (background_buffer == NULL)
|
||||
return;
|
||||
|
||||
V_CopyRect(x, y, background_buffer, w, h, x, y);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ void R_InitBuffer(void);
|
||||
void R_InitTranslationTables(void);
|
||||
|
||||
// Rendering function.
|
||||
void R_VideoErase(int x, int y, int w, int h);
|
||||
void R_FillBackScreen(void);
|
||||
void R_DrawBorder(int x, int y, int w, int h);
|
||||
|
||||
|
@ -558,8 +558,6 @@ void R_ExecuteSetViewSize (void)
|
||||
}
|
||||
}
|
||||
|
||||
//HU_disable_all_widgets();
|
||||
|
||||
// [crispy] forcefully initialize the status bar backing screen
|
||||
ST_refreshBackground(true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user