diff --git a/src/k_menu.h b/src/k_menu.h index 4b10d0eac..29c0734ea 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -517,10 +517,11 @@ typedef enum } manswer_e; #define MAXMENUMESSAGE 256 +#define MENUMESSAGECLOSE 2 extern struct menumessage_s { boolean active; - boolean closing; + UINT8 closing; INT32 flags; // MM_ const char *header; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index b08e251b0..0b56ae847 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -606,15 +606,15 @@ static void M_DrawMenuTyping(void) // Draw the message popup submenu void M_DrawMenuMessage(void) { + if (!menumessage.active) + return; + INT32 x = (BASEVIDWIDTH - menumessage.x)/2; INT32 y = (BASEVIDHEIGHT - menumessage.y)/2 + floor(pow(2, (double)(9 - menumessage.fadetimer))); size_t i, start = 0; char string[MAXMENUMESSAGE]; const char *msg = menumessage.message; - if (!menumessage.active) - return; - V_DrawFadeScreen(31, menumessage.fadetimer); V_DrawFill(0, y, BASEVIDWIDTH, menumessage.y, 159); @@ -629,25 +629,64 @@ void M_DrawMenuMessage(void) INT32 workx = x + menumessage.x; INT32 worky = y + menumessage.y; + boolean push; + + if (menumessage.closing) + push = (menumessage.answer != MA_YES); + else + { + const UINT8 anim_duration = 16; + push = ((menumessage.timer % (anim_duration * 2)) < anim_duration); + } + workx -= V_ThinStringWidth(menumessage.defaultstr, V_6WIDTHSPACE|V_ALLOWLOWERCASE); - V_DrawThinString(workx, worky + 1, V_6WIDTHSPACE|V_ALLOWLOWERCASE, menumessage.defaultstr); + V_DrawThinString( + workx, worky + 1, + V_6WIDTHSPACE|V_ALLOWLOWERCASE + | ((push && (menumessage.closing & MENUMESSAGECLOSE)) ? highlightflags : 0), + menumessage.defaultstr + ); + + workx -= 2; workx -= SHORT(kp_button_x[1][0]->width); - K_drawButtonAnim(workx, worky, 0, kp_button_x[1], menumessage.timer); + K_drawButton( + workx * FRACUNIT, worky * FRACUNIT, + 0, kp_button_x[1], + push + ); workx -= SHORT(kp_button_b[1][0]->width); - K_drawButtonAnim(workx, worky, 0, kp_button_b[1], menumessage.timer); + K_drawButton( + workx * FRACUNIT, worky * FRACUNIT, + 0, kp_button_b[1], + push + ); if (menumessage.confirmstr) { workx -= 12; + if (menumessage.closing) + push = !push; + workx -= V_ThinStringWidth(menumessage.confirmstr, V_6WIDTHSPACE|V_ALLOWLOWERCASE); - V_DrawThinString(workx, worky + 1, V_6WIDTHSPACE|V_ALLOWLOWERCASE, menumessage.confirmstr); + V_DrawThinString( + workx, worky + 1, + V_6WIDTHSPACE|V_ALLOWLOWERCASE + | ((push && (menumessage.closing & MENUMESSAGECLOSE)) ? highlightflags : 0), + menumessage.confirmstr + ); + + workx -= 2; } workx -= SHORT(kp_button_a[1][0]->width); - K_drawButtonAnim(workx, worky, 0, kp_button_a[1], menumessage.timer); + K_drawButton( + workx * FRACUNIT, worky * FRACUNIT, + 0, kp_button_a[1], + push + ); } x -= 4; diff --git a/src/menus/transient/message-box.c b/src/menus/transient/message-box.c index bcb90293d..873d5838e 100644 --- a/src/menus/transient/message-box.c +++ b/src/menus/transient/message-box.c @@ -74,7 +74,7 @@ void M_StartMessage(const char *header, const char *string, void (*routine)(INT3 menumessage.answer = MA_NONE; menumessage.fadetimer = 1; menumessage.timer = 0; - menumessage.closing = false; + menumessage.closing = 0; menumessage.active = true; start = 0; @@ -141,9 +141,15 @@ void M_StopMessage(INT32 choice) const char pid = 0; - menumessage.closing = true; - menumessage.timer = 0; + // Set the answer. menumessage.answer = choice; + + // Intended length of time. + menumessage.closing = (TICRATE/2); + + // This weird operation is necessary so the text flash is consistently timed. + menumessage.closing |= ((2*MENUMESSAGECLOSE) - 1); + M_SetMenuDelay(pid); } @@ -151,18 +157,25 @@ boolean M_MenuMessageTick(void) { if (menumessage.closing) { - if (menumessage.fadetimer > 0) + if (menumessage.closing > MENUMESSAGECLOSE) { - menumessage.fadetimer--; + menumessage.closing--; } - - if (menumessage.fadetimer == 0) + else { - menumessage.active = false; - - if (menumessage.routine) + if (menumessage.fadetimer > 0) { - menumessage.routine(menumessage.answer); + menumessage.fadetimer--; + } + + if (menumessage.fadetimer == 0) + { + menumessage.active = false; + + if (menumessage.routine) + { + menumessage.routine(menumessage.answer); + } } }