Fix cup select & level select to both use the new input handling systems

This commit is contained in:
Sally Coolatta 2021-12-28 12:27:59 -05:00
parent 0179466107
commit a7022af93f

View file

@ -1163,17 +1163,11 @@ static void M_HandleMenuInput(void)
routine = currentMenu->menuitems[itemOn].itemaction; routine = currentMenu->menuitems[itemOn].itemaction;
// Handle menuitems which need a specific key handling // Handle menuitems which need a specific key handling
/*
// NOPE, we need a generic "typing" menu
// (sort of like the generic message menu)
// so that it can be gamepad friendly.
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
{ {
routine(-1); routine(-1);
return; return;
} }
*/
// TODO: Move this to message menu code // TODO: Move this to message menu code
if (currentMenu->menuitems[itemOn].status == IT_MSGHANDLER) if (currentMenu->menuitems[itemOn].status == IT_MSGHANDLER)
@ -2553,6 +2547,9 @@ void M_LevelSelectInit(INT32 choice)
void M_CupSelectHandler(INT32 choice) void M_CupSelectHandler(INT32 choice)
{ {
cupheader_t *newcup = kartcupheaders; cupheader_t *newcup = kartcupheaders;
const UINT8 pid = 0;
(void)choice;
while (newcup) while (newcup)
{ {
@ -2561,9 +2558,8 @@ void M_CupSelectHandler(INT32 choice)
newcup = newcup->next; newcup = newcup->next;
} }
switch (choice) if (menucmd[pid].dpad_lr > 0)
{ {
case KEY_RIGHTARROW:
cupgrid.x++; cupgrid.x++;
if (cupgrid.x >= CUPMENU_COLUMNS) if (cupgrid.x >= CUPMENU_COLUMNS)
{ {
@ -2573,8 +2569,10 @@ void M_CupSelectHandler(INT32 choice)
cupgrid.pageno = 0; cupgrid.pageno = 0;
} }
S_StartSound(NULL, sfx_s3k5b); S_StartSound(NULL, sfx_s3k5b);
break; M_SetMenuDelay(pid);
case KEY_LEFTARROW: }
else if (menucmd[pid].dpad_lr < 0)
{
cupgrid.x--; cupgrid.x--;
if (cupgrid.x < 0) if (cupgrid.x < 0)
{ {
@ -2584,24 +2582,34 @@ void M_CupSelectHandler(INT32 choice)
cupgrid.pageno = cupgrid.numpages-1; cupgrid.pageno = cupgrid.numpages-1;
} }
S_StartSound(NULL, sfx_s3k5b); S_StartSound(NULL, sfx_s3k5b);
break; M_SetMenuDelay(pid);
case KEY_UPARROW: }
if (menucmd[pid].dpad_ud > 0)
{
cupgrid.y++; cupgrid.y++;
if (cupgrid.y >= CUPMENU_ROWS) if (cupgrid.y >= CUPMENU_ROWS)
cupgrid.y = 0; cupgrid.y = 0;
S_StartSound(NULL, sfx_s3k5b); S_StartSound(NULL, sfx_s3k5b);
break; M_SetMenuDelay(pid);
case KEY_DOWNARROW: }
else if (menucmd[pid].dpad_ud < 0)
{
cupgrid.y--; cupgrid.y--;
if (cupgrid.y < 0) if (cupgrid.y < 0)
cupgrid.y = CUPMENU_ROWS-1; cupgrid.y = CUPMENU_ROWS-1;
S_StartSound(NULL, sfx_s3k5b); S_StartSound(NULL, sfx_s3k5b);
break; M_SetMenuDelay(pid);
case KEY_ENTER: }
if (M_MenuButtonPressed(pid, MBT_A) || M_MenuButtonPressed(pid, MBT_X) /*|| M_MenuButtonPressed(pid, MBT_START)*/)
{
M_SetMenuDelay(pid);
if ((!newcup) || (newcup && newcup->unlockrequired != -1 && !unlockables[newcup->unlockrequired].unlocked)) if ((!newcup) || (newcup && newcup->unlockrequired != -1 && !unlockables[newcup->unlockrequired].unlocked))
{ {
S_StartSound(NULL, sfx_s3kb2); S_StartSound(NULL, sfx_s3kb2);
break; return;
} }
if (cupgrid.grandprix == true) if (cupgrid.grandprix == true)
@ -2665,15 +2673,15 @@ void M_CupSelectHandler(INT32 choice)
M_SetupNextMenu(&PLAY_LevelSelectDef, false); M_SetupNextMenu(&PLAY_LevelSelectDef, false);
S_StartSound(NULL, sfx_s3k63); S_StartSound(NULL, sfx_s3k63);
} }
break; }
case KEY_ESCAPE: else if (M_MenuButtonPressed(pid, MBT_B) || M_MenuButtonPressed(pid, MBT_Y))
{
M_SetMenuDelay(pid);
if (currentMenu->prevMenu) if (currentMenu->prevMenu)
M_SetupNextMenu(currentMenu->prevMenu, false); M_SetupNextMenu(currentMenu->prevMenu, false);
else else
M_ClearMenus(true); M_ClearMenus(true);
break;
default:
break;
} }
} }
@ -2686,29 +2694,41 @@ void M_LevelSelectHandler(INT32 choice)
{ {
INT16 start = M_GetFirstLevelInList(levellist.newgametype); INT16 start = M_GetFirstLevelInList(levellist.newgametype);
INT16 maxlevels = M_CountLevelsToShowInList(levellist.newgametype); INT16 maxlevels = M_CountLevelsToShowInList(levellist.newgametype);
const UINT8 pid = 0;
(void)choice;
if (levellist.y != levellist.dest) if (levellist.y != levellist.dest)
return;
switch (choice)
{ {
case KEY_UPARROW: return;
levellist.cursor--; }
if (levellist.cursor < 0)
levellist.cursor = maxlevels-1; if (menucmd[pid].dpad_ud > 0)
S_StartSound(NULL, sfx_s3k5b); {
break;
case KEY_DOWNARROW:
levellist.cursor++; levellist.cursor++;
if (levellist.cursor >= maxlevels) if (levellist.cursor >= maxlevels)
levellist.cursor = 0; levellist.cursor = 0;
S_StartSound(NULL, sfx_s3k5b); S_StartSound(NULL, sfx_s3k5b);
break; M_SetMenuDelay(pid);
case KEY_ENTER: }
else if (menucmd[pid].dpad_ud < 0)
{
levellist.cursor--;
if (levellist.cursor < 0)
levellist.cursor = maxlevels-1;
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
}
M_LevelSelectScrollDest();
if (M_MenuButtonPressed(pid, MBT_A) || M_MenuButtonPressed(pid, MBT_X) /*|| M_MenuButtonPressed(pid, MBT_START)*/)
{ {
INT16 map = start; INT16 map = start;
INT16 add = levellist.cursor; INT16 add = levellist.cursor;
M_SetMenuDelay(pid);
while (add > 0) while (add > 0)
{ {
map++; map++;
@ -2723,7 +2743,10 @@ void M_LevelSelectHandler(INT32 choice)
} }
if (map >= NUMMAPS) if (map >= NUMMAPS)
break; {
// This shouldn't happen
return;
}
levellist.choosemap = map; levellist.choosemap = map;
@ -2792,18 +2815,15 @@ void M_LevelSelectHandler(INT32 choice)
M_ClearMenus(true); M_ClearMenus(true);
} }
} }
break; else if (M_MenuButtonPressed(pid, MBT_B) || M_MenuButtonPressed(pid, MBT_Y))
case KEY_ESCAPE: {
M_SetMenuDelay(pid);
if (currentMenu->prevMenu) if (currentMenu->prevMenu)
M_SetupNextMenu(currentMenu->prevMenu, false); M_SetupNextMenu(currentMenu->prevMenu, false);
else else
M_ClearMenus(true); M_ClearMenus(true);
break;
default:
break;
} }
M_LevelSelectScrollDest();
} }
void M_LevelSelectTick(void) void M_LevelSelectTick(void)
@ -2824,8 +2844,6 @@ void M_LevelSelectTick(void)
} }
} }
struct mpmenu_s mpmenu; struct mpmenu_s mpmenu;
// MULTIPLAYER OPTION SELECT // MULTIPLAYER OPTION SELECT