QOL: Also support left/right inputs switching the Course from the top-level Time Attack view directly

- Abstracts out M_LevelSelectCupSwitch
- Pre-emptively supports cvars/arrow options on that menu
This commit is contained in:
toaster 2024-01-25 04:37:34 +00:00
parent 954d728da0
commit 5e85de05ec
5 changed files with 143 additions and 93 deletions

View file

@ -854,7 +854,8 @@ void M_CupSelectTick(void);
void M_LevelSelectHandler(INT32 choice); void M_LevelSelectHandler(INT32 choice);
void M_LevelSelectTick(void); void M_LevelSelectTick(void);
void M_LevelSelected(INT16 add); void M_LevelSelected(INT16 add, boolean menuupdate);
boolean M_LevelSelectCupSwitch(boolean next, boolean skipones);
// dummy consvars for GP & match race setup // dummy consvars for GP & match race setup
extern consvar_t cv_dummygpdifficulty; extern consvar_t cv_dummygpdifficulty;
@ -897,7 +898,7 @@ void M_PleaseWait(void);
void M_PopupMasterServerRules(void); void M_PopupMasterServerRules(void);
// Time Attack // Time Attack
void M_PrepareTimeAttack(INT32 choice); void M_PrepareTimeAttack(boolean menuupdate);
void M_StartTimeAttack(INT32 choice); void M_StartTimeAttack(INT32 choice);
void M_ReplayTimeAttack(INT32 choice); void M_ReplayTimeAttack(INT32 choice);
void M_HandleStaffReplay(INT32 choice); void M_HandleStaffReplay(INT32 choice);

View file

@ -565,7 +565,7 @@ menu_t *M_SpecificMenuRestore(menu_t *torestore)
} }
else if (levellist.levelsearch.timeattack) else if (levellist.levelsearch.timeattack)
{ {
M_PrepareTimeAttack(0); M_PrepareTimeAttack(true);
} }
} }
} }

View file

@ -52,6 +52,42 @@ boolean M_TimeAttackInputs(INT32 ch)
return true; return true;
} }
if (menucmd[pid].dpad_lr != 0
&& !((currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_ARROWS
|| (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_CVAR)
)
{
if (menucmd[pid].dpad_lr > 0)
{
levellist.cursor++;
if (levellist.cursor >= levellist.mapcount)
{
M_LevelSelectCupSwitch(true, false);
levellist.cursor = 0;
}
}
else
{
levellist.cursor--;
if (levellist.cursor < 0)
{
M_LevelSelectCupSwitch(false, false);
levellist.cursor = levellist.mapcount-1;
}
}
M_LevelSelectScrollDest();
levellist.slide.start = 0;
M_LevelSelected(levellist.cursor, false);
itemOn = ta_start;
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
return true;
}
return false; return false;
} }
@ -215,11 +251,12 @@ menu_t PLAY_TAGhostsDef = {
}; };
// time attack stuff... // time attack stuff...
void M_PrepareTimeAttack(INT32 choice) void M_PrepareTimeAttack(boolean menuupdate)
{ {
(void) choice; if (menuupdate)
{
timeattackmenu.ticker = 0; timeattackmenu.ticker = 0;
}
// Gametype guess // Gametype guess
if (levellist.guessgt != MAXGAMETYPES) if (levellist.guessgt != MAXGAMETYPES)
@ -426,7 +463,7 @@ static void M_WriteGuestReplay(INT32 ch)
Z_Free(rguest); Z_Free(rguest);
Z_Free(gpath); Z_Free(gpath);
M_PrepareTimeAttack(0); M_PrepareTimeAttack(false);
M_SetupNextMenu(&PLAY_TimeAttackDef, false); M_SetupNextMenu(&PLAY_TimeAttackDef, false);
// TODO the following isn't showing up and I'm not sure why // TODO the following isn't showing up and I'm not sure why

View file

@ -309,7 +309,7 @@ void M_CupSelectHandler(INT32 choice)
else if (count == 1 && levellist.levelsearch.timeattack == true) else if (count == 1 && levellist.levelsearch.timeattack == true)
{ {
currentMenu->transitionID = PLAY_TimeAttackDef.transitionID+1; currentMenu->transitionID = PLAY_TimeAttackDef.transitionID+1;
M_LevelSelected(0); M_LevelSelected(0, true);
} }
else else
{ {

View file

@ -608,7 +608,7 @@ boolean M_LevelListFromGametype(INT16 gt)
{ {
if (levellist.levelsearch.tutorial && levellist.mapcount == 1) if (levellist.levelsearch.tutorial && levellist.mapcount == 1)
{ {
M_LevelSelected(0); // Skip the list! M_LevelSelected(0, true); // Skip the list!
} }
else else
{ {
@ -664,7 +664,7 @@ void M_LevelSelectInit(INT32 choice)
} }
} }
void M_LevelSelected(INT16 add) void M_LevelSelected(INT16 add, boolean menuupdate)
{ {
UINT8 i = 0; UINT8 i = 0;
INT16 map = M_GetFirstLevelInList(&i, &levellist.levelsearch); INT16 map = M_GetFirstLevelInList(&i, &levellist.levelsearch);
@ -691,15 +691,18 @@ void M_LevelSelected(INT16 add)
if (levellist.levelsearch.timeattack) if (levellist.levelsearch.timeattack)
{ {
S_StartSound(NULL, sfx_s3k63);
restorelevellist = levellist; restorelevellist = levellist;
M_PrepareTimeAttack(0); M_PrepareTimeAttack(menuupdate);
PLAY_TimeAttackDef.lastOn = ta_start; if (menuupdate)
PLAY_TimeAttackDef.prevMenu = currentMenu; {
M_SetupNextMenu(&PLAY_TimeAttackDef, false); S_StartSound(NULL, sfx_s3k63);
PLAY_TimeAttackDef.lastOn = ta_start;
PLAY_TimeAttackDef.prevMenu = currentMenu;
M_SetupNextMenu(&PLAY_TimeAttackDef, false);
}
} }
else else
{ {
@ -774,6 +777,86 @@ void M_LevelSelected(INT16 add)
} }
} }
boolean M_LevelSelectCupSwitch(boolean next, boolean skipones)
{
levelsearch_t templevelsearch = levellist.levelsearch;
while (1)
{
if (next)
{
// Next
if (++cupgrid.x >= CUPMENU_COLUMNS)
{
cupgrid.x = 0;
if (++cupgrid.y >= CUPMENU_ROWS)
{
cupgrid.y = 0;
if (++cupgrid.pageno >= cupgrid.numpages)
{
cupgrid.pageno = 0;
}
}
}
}
else
{
// Prev
if (cupgrid.x == 0)
{
cupgrid.x = CUPMENU_COLUMNS;
if (cupgrid.y == 0)
{
cupgrid.y = CUPMENU_ROWS;
if (cupgrid.pageno == 0)
{
cupgrid.pageno = cupgrid.numpages;
}
cupgrid.pageno--;
}
cupgrid.y--;
}
cupgrid.x--;
}
templevelsearch.cup = cupgrid.builtgrid[CUPMENU_CURSORID];
if (templevelsearch.cup == levellist.levelsearch.cup)
{
return false;
}
if (!templevelsearch.cup)
{
continue;
}
UINT16 count = M_CountLevelsToShowInList(&templevelsearch);
if (count == 0
// The following isn't ideal, but in addition to the
// necessary programming work being extremely annoying,
// I also just think being forced to switch between
// Time Attack single-course views and multi-course
// selections would just plain kind of look bad.
// ~toast 250124 (ON A PLANE BACK FROM MAGFEST WOOOOOOOO)
|| (skipones && count == 1))
{
continue;
}
levellist.levelsearch = templevelsearch;
levellist.cursor = 0;
levellist.mapcount = count;
M_LevelSelectScrollDest();
levellist.slide.start = 0;
return true;
}
}
void M_LevelSelectHandler(INT32 choice) void M_LevelSelectHandler(INT32 choice)
{ {
const UINT8 pid = 0; const UINT8 pid = 0;
@ -805,84 +888,13 @@ void M_LevelSelectHandler(INT32 choice)
; // Mode with no cup? No left/right input for you! ; // Mode with no cup? No left/right input for you!
else if (menucmd[pid].dpad_lr != 0) else if (menucmd[pid].dpad_lr != 0)
{ {
levelsearch_t templevelsearch = levellist.levelsearch; if (M_LevelSelectCupSwitch(
(menucmd[pid].dpad_lr > 0),
while (1) levellist.levelsearch.timeattack)
)
{ {
if (menucmd[pid].dpad_lr > 0)
{
// Next
if (++cupgrid.x >= CUPMENU_COLUMNS)
{
cupgrid.x = 0;
if (++cupgrid.y >= CUPMENU_ROWS)
{
cupgrid.y = 0;
if (++cupgrid.pageno >= cupgrid.numpages)
{
cupgrid.pageno = 0;
}
}
}
}
else
{
// Prev
if (cupgrid.x == 0)
{
cupgrid.x = CUPMENU_COLUMNS;
if (cupgrid.y == 0)
{
cupgrid.y = CUPMENU_ROWS;
if (cupgrid.pageno == 0)
{
cupgrid.pageno = cupgrid.numpages;
}
cupgrid.pageno--;
}
cupgrid.y--;
}
cupgrid.x--;
}
templevelsearch.cup = cupgrid.builtgrid[CUPMENU_CURSORID];
if (templevelsearch.cup == levellist.levelsearch.cup)
{
break;
}
if (!templevelsearch.cup)
{
continue;
}
UINT16 count = M_CountLevelsToShowInList(&templevelsearch);
if (count == 0
// The following isn't ideal, but in addition to the
// necessary programming work being extremely annoying,
// I also just think being forced to switch between
// Time Attack single-course views and multi-course
// selections would just plain kind of look bad.
// ~toast 250124 (ON A PLANE BACK FROM MAGFEST WOOOOOOOO)
|| (count == 1 && templevelsearch.timeattack == true))
{
continue;
}
levellist.levelsearch = templevelsearch;
levellist.cursor = 0;
levellist.mapcount = count;
M_LevelSelectScrollDest();
levellist.slide.start = 0;
S_StartSound(NULL, sfx_s3k5b); S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid); M_SetMenuDelay(pid);
break;
} }
} }
@ -891,7 +903,7 @@ void M_LevelSelectHandler(INT32 choice)
if (M_MenuConfirmPressed(pid) /*|| M_MenuButtonPressed(pid, MBT_START)*/) if (M_MenuConfirmPressed(pid) /*|| M_MenuButtonPressed(pid, MBT_START)*/)
{ {
M_SetMenuDelay(pid); M_SetMenuDelay(pid);
M_LevelSelected(levellist.cursor); M_LevelSelected(levellist.cursor, true);
} }
else if (M_MenuBackPressed(pid)) else if (M_MenuBackPressed(pid))
{ {