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_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
extern consvar_t cv_dummygpdifficulty;
@ -897,7 +898,7 @@ void M_PleaseWait(void);
void M_PopupMasterServerRules(void);
// Time Attack
void M_PrepareTimeAttack(INT32 choice);
void M_PrepareTimeAttack(boolean menuupdate);
void M_StartTimeAttack(INT32 choice);
void M_ReplayTimeAttack(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)
{
M_PrepareTimeAttack(0);
M_PrepareTimeAttack(true);
}
}
}

View file

@ -52,6 +52,42 @@ boolean M_TimeAttackInputs(INT32 ch)
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;
}
@ -215,11 +251,12 @@ menu_t PLAY_TAGhostsDef = {
};
// time attack stuff...
void M_PrepareTimeAttack(INT32 choice)
void M_PrepareTimeAttack(boolean menuupdate)
{
if (menuupdate)
{
(void) choice;
timeattackmenu.ticker = 0;
}
// Gametype guess
if (levellist.guessgt != MAXGAMETYPES)
@ -426,7 +463,7 @@ static void M_WriteGuestReplay(INT32 ch)
Z_Free(rguest);
Z_Free(gpath);
M_PrepareTimeAttack(0);
M_PrepareTimeAttack(false);
M_SetupNextMenu(&PLAY_TimeAttackDef, false);
// 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)
{
currentMenu->transitionID = PLAY_TimeAttackDef.transitionID+1;
M_LevelSelected(0);
M_LevelSelected(0, true);
}
else
{

View file

@ -608,7 +608,7 @@ boolean M_LevelListFromGametype(INT16 gt)
{
if (levellist.levelsearch.tutorial && levellist.mapcount == 1)
{
M_LevelSelected(0); // Skip the list!
M_LevelSelected(0, true); // Skip the list!
}
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;
INT16 map = M_GetFirstLevelInList(&i, &levellist.levelsearch);
@ -691,16 +691,19 @@ void M_LevelSelected(INT16 add)
if (levellist.levelsearch.timeattack)
{
S_StartSound(NULL, sfx_s3k63);
restorelevellist = levellist;
M_PrepareTimeAttack(0);
M_PrepareTimeAttack(menuupdate);
if (menuupdate)
{
S_StartSound(NULL, sfx_s3k63);
PLAY_TimeAttackDef.lastOn = ta_start;
PLAY_TimeAttackDef.prevMenu = currentMenu;
M_SetupNextMenu(&PLAY_TimeAttackDef, false);
}
}
else
{
if (gamestate == GS_MENU)
@ -774,42 +777,13 @@ void M_LevelSelected(INT16 add)
}
}
void M_LevelSelectHandler(INT32 choice)
{
const UINT8 pid = 0;
(void)choice;
if (I_GetTime() - levellist.slide.start < M_LEVELLIST_SLIDETIME)
{
return;
}
if (menucmd[pid].dpad_ud > 0)
{
levellist.cursor++;
if (levellist.cursor >= levellist.mapcount)
levellist.cursor = 0;
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
}
else if (menucmd[pid].dpad_ud < 0)
{
levellist.cursor--;
if (levellist.cursor < 0)
levellist.cursor = levellist.mapcount-1;
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
}
else if (levellist.levelsearch.cup == NULL)
; // Mode with no cup? No left/right input for you!
else if (menucmd[pid].dpad_lr != 0)
boolean M_LevelSelectCupSwitch(boolean next, boolean skipones)
{
levelsearch_t templevelsearch = levellist.levelsearch;
while (1)
{
if (menucmd[pid].dpad_lr > 0)
if (next)
{
// Next
if (++cupgrid.x >= CUPMENU_COLUMNS)
@ -849,7 +823,7 @@ void M_LevelSelectHandler(INT32 choice)
if (templevelsearch.cup == levellist.levelsearch.cup)
{
break;
return false;
}
if (!templevelsearch.cup)
@ -866,7 +840,7 @@ void M_LevelSelectHandler(INT32 choice)
// 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))
|| (skipones && count == 1))
{
continue;
}
@ -879,10 +853,48 @@ void M_LevelSelectHandler(INT32 choice)
M_LevelSelectScrollDest();
levellist.slide.start = 0;
return true;
}
}
void M_LevelSelectHandler(INT32 choice)
{
const UINT8 pid = 0;
(void)choice;
if (I_GetTime() - levellist.slide.start < M_LEVELLIST_SLIDETIME)
{
return;
}
if (menucmd[pid].dpad_ud > 0)
{
levellist.cursor++;
if (levellist.cursor >= levellist.mapcount)
levellist.cursor = 0;
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
}
else if (menucmd[pid].dpad_ud < 0)
{
levellist.cursor--;
if (levellist.cursor < 0)
levellist.cursor = levellist.mapcount-1;
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
}
else if (levellist.levelsearch.cup == NULL)
; // Mode with no cup? No left/right input for you!
else if (menucmd[pid].dpad_lr != 0)
{
if (M_LevelSelectCupSwitch(
(menucmd[pid].dpad_lr > 0),
levellist.levelsearch.timeattack)
)
{
S_StartSound(NULL, sfx_s3k5b);
M_SetMenuDelay(pid);
break;
}
}
@ -891,7 +903,7 @@ void M_LevelSelectHandler(INT32 choice)
if (M_MenuConfirmPressed(pid) /*|| M_MenuButtonPressed(pid, MBT_START)*/)
{
M_SetMenuDelay(pid);
M_LevelSelected(levellist.cursor);
M_LevelSelected(levellist.cursor, true);
}
else if (M_MenuBackPressed(pid))
{