diff --git a/src/d_main.c b/src/d_main.c index 0d5fdf59..ba884f7f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -317,6 +317,7 @@ void D_Display (void) if (borderdrawcount) { R_DrawViewBorder (); // erase old menu stuff + HU_Drawer (); borderdrawcount--; } } diff --git a/src/hu_lib.c b/src/hu_lib.c index d8eed132..078519ab 100644 --- a/src/hu_lib.c +++ b/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,13 +123,12 @@ 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 - del_char_from_line(l); - else - if (ch != KEY_ENTER) // phares - return false; // did not eat key - return true; // ate the key + else if (ch == KEY_BACKSPACE) // phares + del_char_from_line(l); + else if (ch != KEY_ENTER) // phares + return false; // did not eat key + + return true; // ate the key } boolean HUlib_add_key_to_cur_line(hu_multiline_t *const m, unsigned char ch) @@ -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 $ diff --git a/src/hu_lib.h b/src/hu_lib.h index 6cfb8a46..19dfb610 100644 --- a/src/hu_lib.h +++ b/src/hu_lib.h @@ -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 //---------------------------------------------------------------------------- diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 68353e3c..987e9179 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -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++; + } } // diff --git a/src/r_draw.c b/src/r_draw.c index 78b1818f..d5b7fee3 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -913,9 +913,12 @@ 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) { - V_CopyRect(x, y, background_buffer, w, h, x, y); + if (background_buffer == NULL) + return; + + V_CopyRect(x, y, background_buffer, w, h, x, y); } // @@ -928,23 +931,23 @@ static void R_VideoErase(int x, int y, int w, int h) // can scale to hires automatically in R_VideoErase(). // -void R_DrawViewBorder(void) +void R_DrawViewBorder(void) { - int side; + int side; - if (scaledviewwidth == video.unscaledw || background_buffer == NULL) - return; + if (scaledviewwidth == video.unscaledw || background_buffer == NULL) + return; - // copy top - R_VideoErase(0, 0, video.unscaledw, scaledviewy); + // copy top + R_VideoErase(0, 0, video.unscaledw, scaledviewy); - // copy sides - side = scaledviewx; - R_VideoErase(0, scaledviewy, side, scaledviewheight); - R_VideoErase(video.unscaledw - side, scaledviewy, side, scaledviewheight); + // copy sides + side = scaledviewx; + R_VideoErase(0, scaledviewy, side, scaledviewheight); + R_VideoErase(video.unscaledw - side, scaledviewy, side, scaledviewheight); - // copy bottom - R_VideoErase(0, scaledviewy + scaledviewheight, video.unscaledw, scaledviewy); + // copy bottom + R_VideoErase(0, scaledviewy + scaledviewheight, video.unscaledw, scaledviewy); } //---------------------------------------------------------------------------- diff --git a/src/r_draw.h b/src/r_draw.h index 217ec330..f8b2e1d7 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -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); diff --git a/src/r_main.c b/src/r_main.c index 3ca5a02e..2efd3f86 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -558,8 +558,6 @@ void R_ExecuteSetViewSize (void) } } - //HU_disable_all_widgets(); - // [crispy] forcefully initialize the status bar backing screen ST_refreshBackground(true);