From 629c1662a48c2b72b84fd43d5bb64aa41e66a87c Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Tue, 22 Aug 2023 20:25:06 +0200 Subject: [PATCH] empty messages clear the whole widget --- src/hu_lib.c | 10 ++++++++++ src/hu_lib.h | 1 + src/hu_stuff.c | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/src/hu_lib.c b/src/hu_lib.c index 63a4474e..506d4f72 100644 --- a/src/hu_lib.c +++ b/src/hu_lib.c @@ -86,6 +86,16 @@ void HUlib_clear_cur_line (hu_multiline_t *const m) HUlib_clear_line(m->lines[m->curline]); } +void HUlib_clear_all_lines (hu_multiline_t *const m) +{ + int i; + + for (i = 0; i < m->numlines; i++) + { + HUlib_clear_line(m->lines[i]); + } +} + // [FG] add single char to line, increasing its length but not its width static boolean add_char_to_line(hu_line_t *const t, const char ch) diff --git a/src/hu_lib.h b/src/hu_lib.h index 20f5aac2..36e87e82 100644 --- a/src/hu_lib.h +++ b/src/hu_lib.h @@ -122,6 +122,7 @@ void HUlib_reset_align_offsets (void); void HUlib_clear_line (hu_line_t *const l); void HUlib_clear_cur_line (hu_multiline_t *const m); +void HUlib_clear_all_lines (hu_multiline_t *const m); void HUlib_add_string_to_cur_line (hu_multiline_t *const m, const char *s); void HUlib_add_strings_to_cur_line (hu_multiline_t *const m, const char *prefix, const char *s); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7fc983ba..9d967b00 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -580,6 +580,8 @@ void HU_Start(void) HUlib_init_multiline(&w_message, message_list ? hud_msg_lines : 1, &doom_font, colrngs[hudcolor_mesg], &message_on, NULL); + // [FG] clear messages + HUlib_clear_all_lines(&w_message); // create the secret message widget HUlib_init_multiline(&w_secret, 1, @@ -1532,6 +1534,10 @@ void HU_Ticker(void) //post the message to the message widget HUlib_add_string_to_cur_line(&w_message, plr->message); + // [FG] empty messages clear the whole widget + if (plr->message[0] == '\0') + HUlib_clear_all_lines(&w_message); + // clear the message to avoid posting multiple times plr->message = 0;