From a154b1a56537b7afa2199b9f07d4d038c26d79c9 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 9 Feb 2023 22:36:07 +0000 Subject: [PATCH] restoreMenu: Go to Difficulty select after Match Race, instead of the level selection menu - Splits M_SetupDifficultyOptions out of M_SetupDifficultySelect. - Permits Encore to be handled on Difficulty menu if unlocked after a Match Race. - Fixes an issue where the in-game Pause menu could be accessed in the menu - The prevMenu that was set was overriden with in-game Pause. - The assumption made - that the levelsearch/levellist struct would not be touched - is pretty transparently violated. - I made it go back to the Difficulty select instead of fixing the issue because: - Match Race is more dependent on the rules you configure for that particular round - This mode of play will be modified in future to not be literally offline MP with things like voting, but instead return to the menu - It was easier relative to the amount of work to properly restore (this is the biggest reason) --- src/k_menu.h | 1 + src/k_menufunc.c | 8 ++++++++ src/menus/play-local-race-difficulty.c | 18 +++++++++++------- src/menus/transient/level-select.c | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index b1b699fbc..ec6a96111 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -760,6 +760,7 @@ extern consvar_t cv_dummykartspeed; extern consvar_t cv_dummygpencore; extern consvar_t cv_dummymatchbots; +void M_SetupDifficultyOptions(INT32 choice); void M_SetupDifficultySelect(INT32 choice); void M_DifficultySelectInputs(INT32 choice); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index eb0add401..338dfb35f 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -384,6 +384,7 @@ menu_t *M_SpecificMenuRestore(menu_t *torestore) if (levellist.newgametype == GT_RACE) { M_SetupRaceMenu(-1); + M_SetupDifficultyOptions((cupgrid.grandprix == false)); } if (!M_LevelListFromGametype(-1)) @@ -409,6 +410,13 @@ menu_t *M_SpecificMenuRestore(menu_t *torestore) } } } + else if (torestore == &PLAY_RaceDifficultyDef) + { + // Handle a much smaller subset of unlock restrictions + M_SetupGametypeMenu(-1); + M_SetupRaceMenu(-1); + M_SetupDifficultyOptions((cupgrid.grandprix == false)); + } else if (torestore == &EXTRAS_ReplayHutDef) { // Handle modifications to the folder while playing diff --git a/src/menus/play-local-race-difficulty.c b/src/menus/play-local-race-difficulty.c index 3199f6910..8ff884eda 100644 --- a/src/menus/play-local-race-difficulty.c +++ b/src/menus/play-local-race-difficulty.c @@ -71,14 +71,8 @@ static CV_PossibleValue_t dummymatchbots_cons_t[] = { }; consvar_t cv_dummymatchbots = CVAR_INIT ("dummymatchbots", "Off", CV_HIDDEN, dummymatchbots_cons_t, NULL); -void M_SetupDifficultySelect(INT32 choice) +void M_SetupDifficultyOptions(INT32 choice) { - // check what we picked. - choice = currentMenu->menuitems[itemOn].mvar1; - - // setup the difficulty menu and then remove choices depending on choice - PLAY_RaceDifficultyDef.prevMenu = currentMenu; - PLAY_RaceDifficulty[drace_gpdifficulty].status = IT_DISABLED; PLAY_RaceDifficulty[drace_mrkartspeed].status = IT_DISABLED; PLAY_RaceDifficulty[drace_mrcpu].status = IT_DISABLED; @@ -106,6 +100,16 @@ void M_SetupDifficultySelect(INT32 choice) { PLAY_RaceDifficulty[drace_encore].status = IT_STRING2|IT_CVAR; // Encore on/off } +} + +void M_SetupDifficultySelect(INT32 choice) +{ + (void)choice; + + // setup the difficulty menu and then remove choices depending on choice + PLAY_RaceDifficultyDef.prevMenu = currentMenu; + + M_SetupDifficultyOptions(currentMenu->menuitems[itemOn].mvar1); M_SetupNextMenu(&PLAY_RaceDifficultyDef, false); } diff --git a/src/menus/transient/level-select.c b/src/menus/transient/level-select.c index b4cf228cf..55cfa3e80 100644 --- a/src/menus/transient/level-select.c +++ b/src/menus/transient/level-select.c @@ -500,7 +500,7 @@ void M_LevelSelected(INT16 add) } else { - restoreMenu = &PLAY_LevelSelectDef; + restoreMenu = &PLAY_RaceDifficultyDef; } } else