From b09045f6578d2fb749da2f3f20df41bb8cb3bc93 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 30 Dec 2022 23:58:22 +0000 Subject: [PATCH] Dehardcode menu gametype selection, part 3 Multiplayer map select now uses the value of `menugametype` accessible just above it on the menu, instead of having to select from a hardcoded set of options --- src/k_menu.h | 3 --- src/k_menudef.c | 18 ++---------------- src/k_menufunc.c | 9 ++++++++- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 6db215834..2ac8ecf35 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -436,9 +436,6 @@ typedef enum mpause_title, } mpause_e; -extern menuitem_t PAUSE_GamemodesMenu[]; -extern menu_t PAUSE_GamemodesDef; - extern menuitem_t PAUSE_PlaybackMenu[]; extern menu_t PAUSE_PlaybackMenuDef; diff --git a/src/k_menudef.c b/src/k_menudef.c index 74260d6e4..a4b8de7bd 100644 --- a/src/k_menudef.c +++ b/src/k_menudef.c @@ -1596,8 +1596,8 @@ menuitem_t PAUSE_Main[] = {IT_STRING | IT_KEYHANDLER, "GAMETYPE", "M_ICOGAM", NULL, {.routine = M_HandlePauseMenuGametype}, 0, 0}, - {IT_STRING | IT_SUBMENU, "CHANGE MAP", "M_ICOMAP", - NULL, {.submenu = &PAUSE_GamemodesDef}, 0, 0}, + {IT_STRING | IT_CALL, "CHANGE MAP", "M_ICOMAP", + NULL, {.routine = M_LevelSelectInit}, 0, -1}, {IT_STRING | IT_CALL, "RESTART MAP", "M_ICORE", NULL, {.routine = M_RestartMap}, 0, 0}, @@ -1650,20 +1650,6 @@ menu_t PAUSE_MainDef = { M_PauseInputs }; -// PAUSE : Map switching gametype selection (In case you want to pick from battle / race...) -menuitem_t PAUSE_GamemodesMenu[] = -{ - {IT_STRING | IT_CALL, "Race", "Select which gamemode to choose a new map from.", - NULL, {.routine = M_LevelSelectInit}, 0, GT_RACE}, - - {IT_STRING | IT_CALL, "Battle", "Select which gamemode to choose a new map from.", - NULL, {.routine = M_LevelSelectInit}, 0, GT_BATTLE}, - - {IT_STRING | IT_CALL, "Back", NULL, NULL, {.routine = M_GoBack}, 0, 0}, -}; - -menu_t PAUSE_GamemodesDef = KARTGAMEMODEMENU(PAUSE_GamemodesMenu, &PAUSE_MainDef); - // Replay popup menu menuitem_t PAUSE_PlaybackMenu[] = { diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 120d39f3c..a421ba8a5 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -3676,6 +3676,8 @@ static void M_LevelListFromGametype(INT16 gt) void M_LevelSelectInit(INT32 choice) { + INT32 gt = currentMenu->menuitems[itemOn].mvar2; + (void)choice; // Make sure this is reset as we'll only be using this function for offline games! @@ -3702,7 +3704,12 @@ void M_LevelSelectInit(INT32 choice) return; } - M_LevelListFromGametype(currentMenu->menuitems[itemOn].mvar2); + if (gt == -1) + { + gt = menugametype; + } + + M_LevelListFromGametype(gt); } static void M_LevelSelected(INT16 add)