Restart Map/Try Again pause menu entry

Closer to parity with pre-newmenus behaviour.
- Clinical term for server admins, colloquial for SP contexts (GP/modeattacking)
- Won't show up in GP if you're out of lives
- Also fixes lives going negative in K_PlayerLoseLife
This commit is contained in:
toaster 2022-11-17 16:45:07 +00:00
parent 0c8c3df6a3
commit 962393f7b9
5 changed files with 82 additions and 6 deletions

View file

@ -676,7 +676,7 @@ void K_PlayerLoseLife(player_t *player)
return; return;
} }
if (player->spectator || player->exiting || player->bot || (player->pflags & PF_LOSTLIFE)) if (player->spectator || player->exiting || player->bot || player->lives <= 0 || (player->pflags & PF_LOSTLIFE))
{ {
return; return;
} }

View file

@ -410,6 +410,8 @@ typedef enum
{ {
mpause_addons = 0, mpause_addons = 0,
mpause_switchmap, mpause_switchmap,
mpause_restartmap,
mpause_tryagain,
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
mpause_discordrequests, mpause_discordrequests,
#endif #endif
@ -978,6 +980,8 @@ extern consvar_t cv_dummymenuplayer;
extern consvar_t cv_dummyspectator; extern consvar_t cv_dummyspectator;
// Bunch of funny functions for the pause menu...~ // Bunch of funny functions for the pause menu...~
void M_RestartMap(INT32 choice); // Restart level (MP)
void M_TryAgain(INT32 choice); // Try again (SP)
void M_ConfirmSpectate(INT32 choice); // Spectate confirm when you're alone void M_ConfirmSpectate(INT32 choice); // Spectate confirm when you're alone
void M_ConfirmEnterGame(INT32 choice); // Enter game confirm when you're alone void M_ConfirmEnterGame(INT32 choice); // Enter game confirm when you're alone
void M_ConfirmSpectateChange(INT32 choice); // Splitscreen spectate/play menu func void M_ConfirmSpectateChange(INT32 choice); // Splitscreen spectate/play menu func

View file

@ -1594,6 +1594,12 @@ menuitem_t PAUSE_Main[] =
{IT_STRING | IT_SUBMENU, "CHANGE MAP", "M_ICOMAP", {IT_STRING | IT_SUBMENU, "CHANGE MAP", "M_ICOMAP",
NULL, {.submenu = &PAUSE_GamemodesDef}, 0, 0}, NULL, {.submenu = &PAUSE_GamemodesDef}, 0, 0},
{IT_STRING | IT_CALL, "RESTART MAP", "M_ICORE",
NULL, {.routine = M_RestartMap}, 0, 0},
{IT_STRING | IT_CALL, "TRY AGAIN", "M_ICORE",
NULL, {.routine = M_TryAgain}, 0, 0},
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
{IT_STRING | IT_CALL, "DISCORD REQUESTS", "M_ICODIS", {IT_STRING | IT_CALL, "DISCORD REQUESTS", "M_ICODIS",
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},

View file

@ -3659,19 +3659,29 @@ void M_DrawPause(void)
{ {
case IT_STRING: case IT_STRING:
{ {
char iconame[9]; // 8 chars + \0
patch_t *pp; patch_t *pp;
if (i == itemOn) if (i == itemOn)
{ {
strcpy(iconame, currentMenu->menuitems[i].tooltip); if (i == mpause_restartmap || i == mpause_tryagain)
iconame[7] = '2'; // Yes this is a stupid hack. Replace the last character with a 2 when we're selecting this graphic. {
pp = W_CachePatchName(
va("M_ICOR2%c", ('A'+(pausemenu.ticker & 1))),
PU_CACHE);
}
else
{
char iconame[9]; // 8 chars + \0
strcpy(iconame, currentMenu->menuitems[i].tooltip);
iconame[7] = '2'; // Yes this is a stupid hack. Replace the last character with a 2 when we're selecting this graphic.
pp = W_CachePatchName(iconame, PU_CACHE); pp = W_CachePatchName(iconame, PU_CACHE);
}
} }
else else
{
pp = W_CachePatchName(currentMenu->menuitems[i].tooltip, PU_CACHE); pp = W_CachePatchName(currentMenu->menuitems[i].tooltip, PU_CACHE);
}
// 294 - 261 = 33 // 294 - 261 = 33
// We need to move 33 px in 50 tics which means we move 33/50 = 0.66 px every tic = 2/3 of the offset. // We need to move 33 px in 50 tics which means we move 33/50 = 0.66 px every tic = 2/3 of the offset.

View file

@ -5870,6 +5870,8 @@ struct pausemenu_s pausemenu;
// Pause menu! // Pause menu!
void M_OpenPauseMenu(void) void M_OpenPauseMenu(void)
{ {
INT32 i = 0;
currentMenu = &PAUSE_MainDef; currentMenu = &PAUSE_MainDef;
// Ready the variables // Ready the variables
@ -5886,6 +5888,8 @@ void M_OpenPauseMenu(void)
PAUSE_Main[mpause_addons].status = IT_DISABLED; PAUSE_Main[mpause_addons].status = IT_DISABLED;
PAUSE_Main[mpause_switchmap].status = IT_DISABLED; PAUSE_Main[mpause_switchmap].status = IT_DISABLED;
PAUSE_Main[mpause_restartmap].status = IT_DISABLED;
PAUSE_Main[mpause_tryagain].status = IT_DISABLED;
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
PAUSE_Main[mpause_discordrequests].status = IT_DISABLED; PAUSE_Main[mpause_discordrequests].status = IT_DISABLED;
#endif #endif
@ -5905,9 +5909,29 @@ void M_OpenPauseMenu(void)
if (server || IsPlayerAdmin(consoleplayer)) if (server || IsPlayerAdmin(consoleplayer))
{ {
PAUSE_Main[mpause_switchmap].status = IT_STRING | IT_SUBMENU; PAUSE_Main[mpause_switchmap].status = IT_STRING | IT_SUBMENU;
PAUSE_Main[mpause_restartmap].status = IT_STRING | IT_CALL;
PAUSE_Main[mpause_addons].status = IT_STRING | IT_CALL; PAUSE_Main[mpause_addons].status = IT_STRING | IT_CALL;
} }
} }
else if (!netgame && !demo.playback)
{
boolean retryallowed = (modeattacking != ATTACKING_NONE);
if (G_GametypeUsesLives())
{
for (i = 0; i <= splitscreen; i++)
{
if (players[g_localplayers[i]].lives <= 1)
continue;
retryallowed = true;
break;
}
}
if (retryallowed)
{
PAUSE_Main[mpause_tryagain].status = IT_STRING | IT_CALL;
}
}
if (G_GametypeHasSpectators()) if (G_GametypeHasSpectators())
{ {
@ -5936,6 +5960,7 @@ void M_QuitPauseMenu(INT32 choice)
void M_PauseTick(void) void M_PauseTick(void)
{ {
pausemenu.offset /= 2; pausemenu.offset /= 2;
pausemenu.ticker++;
if (pausemenu.closing) if (pausemenu.closing)
{ {
@ -5984,6 +6009,37 @@ boolean M_PauseInputs(INT32 ch)
return false; return false;
} }
// Restart map
void M_RestartMap(INT32 choice)
{
(void)choice;
M_ClearMenus(false);
COM_ImmedExecute("restartlevel");
}
// Try again
void M_TryAgain(INT32 choice)
{
(void)choice;
if (demo.playback)
return;
if (netgame || !Playing()) // Should never happen!
return;
M_ClearMenus(false);
if (modeattacking != ATTACKING_NONE)
{
G_CheckDemoStatus(); // Cancel recording
M_StartTimeAttack(-1);
}
else
{
G_SetRetryFlag();
}
}
// Pause spectate / join functions // Pause spectate / join functions
void M_ConfirmSpectate(INT32 choice) void M_ConfirmSpectate(INT32 choice)
{ {