General Menu Message input cleanup

- M_StopMessage is now in charge of setting the answer to a given prompt.
- Menu Messages can now be dismissed on the title screen, instead of carried into the top-level menu transition.
This commit is contained in:
toaster 2023-06-18 14:01:58 +01:00
parent 17f23e8974
commit d450faeaaf
4 changed files with 34 additions and 15 deletions

View file

@ -1676,6 +1676,8 @@ static boolean M_ConfirmConnect(void)
if (G_PlayerInputDown(0, gc_b, 1) || G_PlayerInputDown(0, gc_x, 1) || G_GetDeviceGameKeyDownArray(0)[KEY_ESCAPE]) if (G_PlayerInputDown(0, gc_b, 1) || G_PlayerInputDown(0, gc_x, 1) || G_GetDeviceGameKeyDownArray(0)[KEY_ESCAPE])
{ {
cl_requestmode = CL_ABORTED; cl_requestmode = CL_ABORTED;
M_StopMessage(MA_NO);
return true; return true;
} }
@ -1704,6 +1706,7 @@ static boolean M_ConfirmConnect(void)
else else
cl_requestmode = CL_LOADFILES; cl_requestmode = CL_LOADFILES;
M_StopMessage(MA_YES);
return true; return true;
} }
@ -2174,7 +2177,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
I_lock_mutex(&k_menu_mutex); I_lock_mutex(&k_menu_mutex);
#endif #endif
if (M_MenuMessageTick() && M_ConfirmConnect()) if (M_MenuMessageTick() && M_ConfirmConnect())
M_StopMessage(0); ;
else if (menumessage.active == false) else if (menumessage.active == false)
cl_mode = cl_requestmode; cl_mode = cl_requestmode;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS

View file

@ -2131,8 +2131,10 @@ void F_TitleScreenTicker(boolean run)
// Now start the music // Now start the music
S_ChangeMusicInternal("_title", looptitle); S_ChangeMusicInternal("_title", looptitle);
} }
else if (menumessage.fadetimer < 9) else if (menumessage.active)
menumessage.fadetimer++; {
M_MenuMessageTick();
}
finalecount++; finalecount++;
} }

View file

@ -539,6 +539,21 @@ void M_StartControlPanel(void)
// (We can change this timer later when extra animation is added.) // (We can change this timer later when extra animation is added.)
if (finalecount < 1) if (finalecount < 1)
return; return;
if (menumessage.active)
{
if (!menumessage.closing && menumessage.fadetimer == 9)
{
// The following doesn't work with MM_YESNO.
// However, because there's no guarantee a profile
// is selected or controls set up to our liking,
// we can't call M_HandleMenuMessage.
M_StopMessage(MA_NONE);
}
return;
}
} }
menuactive = true; menuactive = true;
@ -549,8 +564,6 @@ void M_StartControlPanel(void)
} }
else if (!Playing()) else if (!Playing())
{ {
M_StopMessage(0); // Doesn't work with MM_YESNO or MM_EVENTHANDLER... but good enough to get the game as it is currently functional again
if (gamestate != GS_MENU) if (gamestate != GS_MENU)
{ {
G_SetGamestate(GS_MENU); G_SetGamestate(GS_MENU);

View file

@ -136,11 +136,14 @@ void M_StartMessage(const char *header, const char *string, void (*routine)(INT3
void M_StopMessage(INT32 choice) void M_StopMessage(INT32 choice)
{ {
if (!menumessage.active || menumessage.closing)
return;
const char pid = 0; const char pid = 0;
(void) choice;
menumessage.closing = true; menumessage.closing = true;
menumessage.timer = 0; menumessage.timer = 0;
menumessage.answer = choice;
M_SetMenuDelay(pid); M_SetMenuDelay(pid);
} }
@ -192,20 +195,18 @@ void M_HandleMenuMessage(void)
case MM_YESNO: case MM_YESNO:
{ {
if (btok) if (btok)
menumessage.answer = MA_YES; M_StopMessage(MA_YES);
else if (btnok) else if (btnok)
menumessage.answer = MA_NO; M_StopMessage(MA_NO);
break; break;
} }
default: default:
break; {
} if (btok || btnok)
M_StopMessage(MA_NONE);
// if we detect any keypress, don't forget to set the menu delay regardless. break;
if (btok || btnok) }
{
M_StopMessage(0);
M_SetMenuDelay(pid);
} }
} }