Menus/Match Race: replace encore toggle with button prompt, add Item Toggles shortcut

This commit is contained in:
James R 2023-12-31 01:33:29 -08:00
parent 03248d6bf8
commit 3b5321fb0c
4 changed files with 114 additions and 11 deletions

View file

@ -250,6 +250,7 @@ typedef enum
drace_mrkartspeed,
drace_mrcpu,
drace_mrracers,
drace_mritems,
drace_encore,
drace_boxend,
drace_cupselect = drace_boxend,

View file

@ -2545,7 +2545,7 @@ void M_DrawRaceDifficulty(void)
if (currentMenu->menuitems[i].status & IT_CVAR)
{
// implicitely we'll only take care of normal cvars
INT32 cx = 260 + tx;
INT32 cx = 190 + tx;
consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar;
if (i == itemOn)
@ -2553,7 +2553,7 @@ void M_DrawRaceDifficulty(void)
INT32 w = V_MenuStringWidth(cv->string, 0)/2;
M_DrawUnderline(140, 260 + w, y);
M_DrawUnderline(124, 190 + w, y);
V_DrawMenuString(cx - 10 - w - (skullAnimCounter/5), y, highlightflags, "\x1C"); // left arrow
V_DrawMenuString(cx + w + 2 + (skullAnimCounter/5), y, highlightflags, "\x1D"); // right arrow
@ -2562,14 +2562,14 @@ void M_DrawRaceDifficulty(void)
V_DrawCenteredMenuString(cx, y, f, cv->string);
}
V_DrawMenuString(140 + tx + (i == itemOn ? 1 : 0), y, f, currentMenu->menuitems[i].text);
V_DrawMenuString(124 + tx + (i == itemOn ? 1 : 0), y, f, currentMenu->menuitems[i].text);
if (i == itemOn)
{
M_DrawCursorHand(140 + tx, y);
M_DrawCursorHand(124 + tx, y);
}
y += 10;
y += 14;
break;
}
@ -2625,6 +2625,47 @@ void M_DrawRaceDifficulty(void)
x += GM_XOFFSET;
y += GM_YOFFSET;
if (i < drace_boxend)
{
y += 2; // extra spacing for Match Race options
}
break;
}
case IT_PATCH:
{
extern menu_anim_t g_drace_timer;
const menuitem_t *it = &currentMenu->menuitems[i];
boolean activated = g_drace_timer.dist == i;
boolean flicker = activated && (I_GetTime() - g_drace_timer.start) % 2 < 1;
INT32 cx = it->mvar1 + tx;
INT32 cy = 79;
V_DrawMappedPatch(cx, cy, 0, W_CachePatchName(it->patch, PU_CACHE),
flicker ? R_GetTranslationColormap(TC_HITLAG, 0, GTC_MENUCACHE) : NULL);
if (it->itemaction.cvar && !it->itemaction.cvar->value)
{
V_DrawMappedPatch(cx, cy, 0, W_CachePatchName("OFF_TOGG", PU_CACHE), NULL);
}
patch_t **bt = NULL;
switch (it->mvar2)
{
case MBT_Y:
bt = kp_button_y[1];
break;
case MBT_Z:
bt = kp_button_z[1];
break;
}
if (bt)
{
K_drawButton((cx + 24) * FRACUNIT, (cy + 22) * FRACUNIT, 0, bt, activated);
}
break;
}
}

View file

@ -48,6 +48,13 @@ menuitem_t OPTIONS_GameplayItems[] =
{IT_KEYHANDLER | IT_NOTHING, NULL, "Kitchen Sink", NULL, {.routine = M_HandleItemToggles}, KITEM_KITCHENSINK, 0}
};
static void init_routine(void)
{
// Since this menu can be accessed from different
// locations. (currentMenu has not changed yet.)
OPTIONS_GameplayItemsDef.prevMenu = currentMenu;
}
menu_t OPTIONS_GameplayItemsDef = {
sizeof (OPTIONS_GameplayItems) / sizeof (menuitem_t),
&OPTIONS_GameplayDef,
@ -61,7 +68,7 @@ menu_t OPTIONS_GameplayItemsDef = {
M_DrawItemToggles,
M_DrawOptionsCogs,
M_OptionsTick,
NULL,
init_routine,
NULL,
NULL,
};

View file

@ -1,6 +1,7 @@
/// \file menus/play-local-race-difficulty.c
/// \brief difficulty selection -- see drace_e
#include "../i_time.h"
#include "../k_menu.h"
#include "../m_cond.h" // Condition Sets
@ -20,8 +21,10 @@ menuitem_t PLAY_RaceDifficulty[] =
{IT_STRING2 | IT_CVAR, "Racers", "Sets the number of racers, including players and CPU.",
"MENUI005", {.cvar = &cv_maxplayers}, 0, 0},
{IT_STRING2 | IT_CVAR, "Encore", "Enable or disable Encore mode",
"MENUI005", {.cvar = &cv_dummygpencore}, 0, 0},
{IT_PATCH | IT_SPACE, NULL, NULL,
"ITEMTOGG", {NULL}, 222, MBT_Y},
{IT_PATCH | IT_SPACE, NULL, NULL,
"ENCRTOGG", {.cvar = &cv_dummygpencore}, 264, MBT_Z},
// For GP
{IT_STRING | IT_CALL, "Cup Select", "Go on and select a cup!", "MENUI004", {.routine = M_LevelSelectInit}, 2, GT_RACE},
@ -32,6 +35,54 @@ menuitem_t PLAY_RaceDifficulty[] =
{IT_STRING | IT_CALL, "Back", NULL, NULL, {.routine = M_GoBack}, 0, 0},
};
menu_anim_t g_drace_timer = {0, -1};
static void tick_routine(void)
{
if (g_drace_timer.dist == -1 || I_GetTime() - g_drace_timer.start < 4)
{
return;
}
switch (g_drace_timer.dist)
{
case drace_mritems:
M_SetupNextMenu(&OPTIONS_GameplayItemsDef, false);
break;
case drace_encore:
CV_AddValue(&cv_dummygpencore, 1);
break;
}
g_drace_timer.dist = -1;
}
static boolean input_routine(INT32 ch)
{
if (g_drace_timer.dist != -1)
{
return true;
}
UINT8 pid = 0;
(void)ch;
int i;
for (i = 0; i < currentMenu->numitems; ++i)
{
const menuitem_t *it = &currentMenu->menuitems[i];
if ((it->status & IT_DISPLAY) == IT_PATCH && M_MenuButtonPressed(pid, it->mvar2))
{
g_drace_timer.start = I_GetTime();
g_drace_timer.dist = i;
return true;
}
}
return false;
}
menu_t PLAY_RaceDifficultyDef = {
sizeof(PLAY_RaceDifficulty) / sizeof(menuitem_t),
&PLAY_RaceGamemodesDef,
@ -44,10 +95,10 @@ menu_t PLAY_RaceDifficultyDef = {
1, 5,
M_DrawRaceDifficulty,
NULL,
tick_routine,
NULL,
NULL,
NULL,
NULL
input_routine
};
void M_SetupDifficultyOptions(INT32 choice)
@ -56,6 +107,7 @@ void M_SetupDifficultyOptions(INT32 choice)
PLAY_RaceDifficulty[drace_mrkartspeed].status = IT_DISABLED;
PLAY_RaceDifficulty[drace_mrcpu].status = IT_DISABLED;
PLAY_RaceDifficulty[drace_mrracers].status = IT_DISABLED;
PLAY_RaceDifficulty[drace_mritems].status = IT_DISABLED;
PLAY_RaceDifficulty[drace_encore].status = IT_DISABLED;
PLAY_RaceDifficulty[drace_cupselect].status = IT_DISABLED;
PLAY_RaceDifficulty[drace_mapselect].status = IT_DISABLED;
@ -68,9 +120,11 @@ void M_SetupDifficultyOptions(INT32 choice)
PLAY_RaceDifficulty[drace_mapselect].status = IT_STRING|IT_CALL; // Level Select (Match Race)
PLAY_RaceDifficultyDef.lastOn = drace_mapselect; // Select map select by default.
PLAY_RaceDifficulty[drace_mritems].status = IT_PATCH|IT_SPACE; // Item Toggles
if (M_SecretUnlocked(SECRET_ENCORE, true))
{
PLAY_RaceDifficulty[drace_encore].status = IT_STRING2|IT_CVAR; // Encore on/off
PLAY_RaceDifficulty[drace_encore].status = IT_PATCH|IT_SPACE; // Encore on/off
}
}
else // GP