From 9f05c199c2030cfe7e8a2756d8247db217df4f53 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 16 Nov 2023 21:12:25 +0000 Subject: [PATCH] "Give up" pause menu option Shows up in GP for any eventmode Skips to the next stage in the queue --- src/k_menu.h | 3 ++ src/menus/transient/pause-game.c | 69 +++++++++++++++++++++++++++----- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 6343f2ceb..e4700187a 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -451,6 +451,8 @@ typedef enum #endif mpause_admin, mpause_callvote, + + mpause_giveup, mpause_restartmap, mpause_tryagain, @@ -1104,6 +1106,7 @@ extern consvar_t cv_dummyspectator; // 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_GiveUp(INT32 choice); // Give up (SP) 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_ConfirmSpectateChange(INT32 choice); // Splitscreen spectate/play menu func diff --git a/src/menus/transient/pause-game.c b/src/menus/transient/pause-game.c index 3f69e4655..b5677f5cf 100644 --- a/src/menus/transient/pause-game.c +++ b/src/menus/transient/pause-game.c @@ -40,6 +40,9 @@ menuitem_t PAUSE_Main[] = {IT_STRING | IT_ARROWS, "CALL VOTE", "M_ICOVOT", NULL, {.routine = M_HandlePauseMenuCallVote}, 0, 0}, + {IT_STRING | IT_CALL, "GIVE UP", "M_ICOGUP", + NULL, {.routine = M_GiveUp}, 0, 0}, + {IT_STRING | IT_CALL, "RESTART MAP", "M_ICORE", NULL, {.routine = M_RestartMap}, 0, 0}, @@ -130,6 +133,8 @@ void M_OpenPauseMenu(void) #ifdef HAVE_DISCORDRPC PAUSE_Main[mpause_discordrequests].status = IT_DISABLED; #endif + + PAUSE_Main[mpause_giveup].status = IT_DISABLED; PAUSE_Main[mpause_restartmap].status = IT_DISABLED; PAUSE_Main[mpause_tryagain].status = IT_DISABLED; @@ -172,19 +177,29 @@ void M_OpenPauseMenu(void) } else if (!netgame && !demo.playback) { - boolean retryallowed = (modeattacking != ATTACKING_NONE || gametype == GT_TUTORIAL); - if ( - retryallowed == false - && gamestate == GS_LEVEL - && G_GametypeUsesLives() - ) + boolean retryallowed = (modeattacking != ATTACKING_NONE); + boolean giveup = ( + grandprixinfo.gp == true + && grandprixinfo.eventmode != GPEVENT_NONE + && roundqueue.size != 0 + ); + { - for (i = 0; i <= splitscreen; i++) + if (gamestate == GS_LEVEL && !retryallowed) + { + if (gametype == GT_TUTORIAL) { - if (players[g_localplayers[i]].lives <= 1) - continue; retryallowed = true; - break; + } + else if (G_GametypeUsesLives()) + { + for (i = 0; i <= splitscreen; i++) + { + if (players[g_localplayers[i]].lives <= 1) + continue; + retryallowed = true; + break; + } } } @@ -192,6 +207,11 @@ void M_OpenPauseMenu(void) { PAUSE_Main[mpause_tryagain].status = IT_STRING | IT_CALL; } + + if (giveup) + { + PAUSE_Main[mpause_giveup].status = IT_STRING | IT_CALL; + } } if (netgame) // && (PAUSE_Main[mpause_admin].status == IT_DISABLED)) @@ -398,6 +418,35 @@ void M_TryAgain(INT32 choice) } } +static void M_GiveUpResponse(INT32 ch) +{ + if (ch != MA_YES) + return; + + if (exitcountdown != 1) + { + G_BeginLevelExit(); + exitcountdown = 1; + + if (server) + SendNetXCmd(XD_EXITLEVEL, NULL, 0); + } + + M_ClearMenus(false); +} + +void M_GiveUp(INT32 choice) +{ + (void)choice; + if (demo.playback) + return; + + if (!Playing()) + return; + + M_StartMessage("Give up", M_GetText("Are you sure you want to\ngive up on this challenge?\n"), &M_GiveUpResponse, MM_YESNO, NULL, NULL); +} + // Pause spectate / join functions void M_ConfirmSpectate(INT32 choice) {