From 3b5321fb0c8929c88f32312caad91771d6e8baaa Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 01:33:29 -0800 Subject: [PATCH 1/7] Menus/Match Race: replace encore toggle with button prompt, add Item Toggles shortcut --- src/k_menu.h | 1 + src/k_menudraw.c | 51 ++++++++++++++++-- src/menus/options-gameplay-item-toggles.c | 9 +++- src/menus/play-local-race-difficulty.c | 64 +++++++++++++++++++++-- 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index a83088868..1d4133419 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -250,6 +250,7 @@ typedef enum drace_mrkartspeed, drace_mrcpu, drace_mrracers, + drace_mritems, drace_encore, drace_boxend, drace_cupselect = drace_boxend, diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 5afa960a4..4128f3d48 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -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 = ¤tMenu->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; } } diff --git a/src/menus/options-gameplay-item-toggles.c b/src/menus/options-gameplay-item-toggles.c index 7598d5f00..2121492ec 100644 --- a/src/menus/options-gameplay-item-toggles.c +++ b/src/menus/options-gameplay-item-toggles.c @@ -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, }; diff --git a/src/menus/play-local-race-difficulty.c b/src/menus/play-local-race-difficulty.c index fbe305365..3908f9370 100644 --- a/src/menus/play-local-race-difficulty.c +++ b/src/menus/play-local-race-difficulty.c @@ -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 = ¤tMenu->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 From b7aa559449ec6cfeebe9e07067259aad10b390c9 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 01:57:57 -0800 Subject: [PATCH 2/7] Menus/Item Toggles: all off = thunderdome on --- src/menus/options-gameplay-item-toggles.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/menus/options-gameplay-item-toggles.c b/src/menus/options-gameplay-item-toggles.c index 2121492ec..8fb5d45fb 100644 --- a/src/menus/options-gameplay-item-toggles.c +++ b/src/menus/options-gameplay-item-toggles.c @@ -73,6 +73,22 @@ menu_t OPTIONS_GameplayItemsDef = { NULL, }; +static boolean M_AnyItemsEnabled(void) +{ + INT32 i; + for (i = 0; i < NUMKARTRESULTS-1; i++) + { + if (cv_items[i].value) + return true; + } + return false; +} + +static void M_ToggleThunderdome(void) +{ + CV_SetValue(&cv_thunderdome, !M_AnyItemsEnabled()); +} + void M_HandleItemToggles(INT32 choice) { const INT32 width = 8, height = 4; @@ -155,13 +171,13 @@ void M_HandleItemToggles(INT32 choice) else if (currentMenu->menuitems[itemOn].mvar1 == 0) { - INT32 v = cv_items[0].value; + INT32 v = !M_AnyItemsEnabled(); S_StartSound(NULL, sfx_s1b4); for (i = 0; i < NUMKARTRESULTS-1; i++) { - if (cv_items[i].value == v) - CV_AddValue(&cv_items[i], 1); + CV_SetValue(&cv_items[i], v); } + M_ToggleThunderdome(); } else { @@ -174,6 +190,7 @@ void M_HandleItemToggles(INT32 choice) S_StartSound(NULL, sfx_s1ba); } CV_AddValue(&cv_items[currentMenu->menuitems[itemOn].mvar1-1], 1); + M_ToggleThunderdome(); } } From 0c5858269f9fd07112269ac653b5c9062ff9e0bd Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 01:58:22 -0800 Subject: [PATCH 3/7] Menus/Match Race: show ring box for Item Toggles shortcut if thunderdome enabled --- src/k_menudraw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 4128f3d48..afb0e1f5b 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2643,7 +2643,9 @@ void M_DrawRaceDifficulty(void) INT32 cx = it->mvar1 + tx; INT32 cy = 79; - V_DrawMappedPatch(cx, cy, 0, W_CachePatchName(it->patch, PU_CACHE), + const char *pat = i == drace_mritems && cv_thunderdome.value ? "RBOXTOGG" : it->patch; + + V_DrawMappedPatch(cx, cy, 0, W_CachePatchName(pat, PU_CACHE), flicker ? R_GetTranslationColormap(TC_HITLAG, 0, GTC_MENUCACHE) : NULL); if (it->itemaction.cvar && !it->itemaction.cvar->value) From f1c2f3d309e540e68eab8f6d7179ba1e11411939 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 04:38:21 -0800 Subject: [PATCH 4/7] Menus/Item Toggles: shade disabled items instead of making them transparent --- src/k_menudraw.c | 66 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index afb0e1f5b..241b6f1c8 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5014,8 +5014,26 @@ void M_DrawVideoModes(void) // Gameplay Item Tggles: tic_t shitsfree = 0; +static void DrawMappedString(INT32 x, INT32 y, INT32 option, int font, const char *text, const UINT8 *colormap) +{ + V_DrawStringScaled( + x * FRACUNIT, + y * FRACUNIT, + FRACUNIT, + FRACUNIT, + FRACUNIT, + option, + colormap, + font, + text + ); +} + void M_DrawItemToggles(void) { + static UINT8 black[256]; + memset(black, 16, 256); + const INT32 edges = 8; const INT32 height = 4; const INT32 spacing = 35; @@ -5025,7 +5043,8 @@ void M_DrawItemToggles(void) INT32 x = currentMenu->x + menutransition.tics*64, y = currentMenu->y; INT32 onx = 0, ony = 0; consvar_t *cv; - INT32 i, translucent, drawnum; + INT32 i, drawnum; + patch_t *pat; M_DrawMenuTooltips(); M_DrawOptionsMovingButton(); @@ -5082,7 +5101,6 @@ void M_DrawItemToggles(void) } cv = &cv_items[currentMenu->menuitems[thisitem].mvar1-1]; - translucent = (cv->value ? 0 : V_TRANSLUCENT); drawnum = K_ItemResultToAmount(currentMenu->menuitems[thisitem].mvar1); @@ -5092,13 +5110,22 @@ void M_DrawItemToggles(void) V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBGD", PU_CACHE)); if (drawnum > 1) - { V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISMUL", PU_CACHE)); - V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].mvar1, true), PU_CACHE)); - V_DrawString(x+24, y+31, translucent, va("x%d", drawnum)); + + pat = W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].mvar1, true), PU_CACHE); + + V_DrawScaledPatch(x, y, 0, pat); + + if (!cv->value) + V_DrawMappedPatch(x, y, V_MODULATE, pat, black); + + if (drawnum > 1) + { + V_DrawString(x+24, y+31, 0, va("x%d", drawnum)); + + if (!cv->value) + DrawMappedString(x+24, y+31, V_MODULATE, HU_FONT, va("x%d", drawnum), black); } - else - V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].mvar1, true), PU_CACHE)); y += spacing; } @@ -5129,7 +5156,6 @@ void M_DrawItemToggles(void) else { cv = &cv_items[currentMenu->menuitems[itemOn].mvar1-1]; - translucent = (cv->value ? 0 : V_TRANSLUCENT); drawnum = K_ItemResultToAmount(currentMenu->menuitems[itemOn].mvar1); @@ -5139,14 +5165,26 @@ void M_DrawItemToggles(void) V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBGD", PU_CACHE)); if (drawnum > 1) - { V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITMUL", PU_CACHE)); - V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].mvar1, false), PU_CACHE)); - V_DrawScaledPatch(onx+27, ony+39, translucent, W_CachePatchName("K_ITX", PU_CACHE)); - V_DrawTimerString(onx+37, ony+34, translucent, va("%d", drawnum)); + + pat = W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].mvar1, false), PU_CACHE); + + V_DrawScaledPatch(onx-1, ony-2, 0, pat); + + if (!cv->value) + V_DrawMappedPatch(onx-1, ony-2, V_MODULATE, pat, black); + + if (drawnum > 1) + { + V_DrawScaledPatch(onx+27, ony+39, 0, W_CachePatchName("K_ITX", PU_CACHE)); + V_DrawTimerString(onx+37, ony+34, 0, va("%d", drawnum)); + + if (!cv->value) + { + V_DrawMappedPatch(onx+27, ony+39, V_MODULATE, W_CachePatchName("K_ITX", PU_CACHE), black); + DrawMappedString(onx+37, ony+34, V_MODULATE, TIMER_FONT, va("%d", drawnum), black); + } } - else - V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].mvar1, false), PU_CACHE)); } } } From 5e2948688673ef874ffd17649c73825dceaae0ef Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 04:39:08 -0800 Subject: [PATCH 5/7] Menus/Item Toggles: strike through disabled items --- src/k_menudraw.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 241b6f1c8..596f0812d 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5127,6 +5127,9 @@ void M_DrawItemToggles(void) DrawMappedString(x+24, y+31, V_MODULATE, HU_FONT, va("x%d", drawnum), black); } + if (!cv->value) + V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISSTRK", PU_CACHE)); + y += spacing; } @@ -5185,6 +5188,11 @@ void M_DrawItemToggles(void) DrawMappedString(onx+37, ony+34, V_MODULATE, TIMER_FONT, va("%d", drawnum), black); } } + + if (!cv->value) + { + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITSTRK", PU_CACHE)); + } } } } From ccbbc3cf1a08e2768dfda37b230c3647824a84d8 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 04:42:37 -0800 Subject: [PATCH 6/7] Menus/Item Toggles: interpolate with menu transition --- src/k_menudraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 596f0812d..f2cafd27b 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5040,7 +5040,7 @@ void M_DrawItemToggles(void) const INT32 column = itemOn/height; //const INT32 row = itemOn%height; INT32 leftdraw, rightdraw, totaldraw; - INT32 x = currentMenu->x + menutransition.tics*64, y = currentMenu->y; + INT32 x = currentMenu->x + M_EaseWithTransition(Easing_Linear, 5 * 64), y = currentMenu->y; INT32 onx = 0, ony = 0; consvar_t *cv; INT32 i, drawnum; From 188622ddd7157c3595e8da71320c0977f7374ca5 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 31 Dec 2023 04:47:08 -0800 Subject: [PATCH 7/7] Menus/Item Toggles: optimize patch caching --- src/k_menudraw.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index f2cafd27b..e68d15b58 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5066,6 +5066,11 @@ void M_DrawItemToggles(void) } } + patch_t *isbg = W_CachePatchName("K_ISBG", PU_CACHE); + patch_t *isbgd = W_CachePatchName("K_ISBGD", PU_CACHE); + patch_t *ismul = W_CachePatchName("K_ISMUL", PU_CACHE); + patch_t *isstrk = W_CachePatchName("K_ISSTRK", PU_CACHE); + for (i = leftdraw; i <= rightdraw; i++) { INT32 j; @@ -5087,7 +5092,7 @@ void M_DrawItemToggles(void) if (currentMenu->menuitems[thisitem].mvar1 == 0) { - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, isbg); V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISTOGL", PU_CACHE)); y += spacing; continue; @@ -5095,7 +5100,7 @@ void M_DrawItemToggles(void) if (currentMenu->menuitems[thisitem].mvar1 == 255) { - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBGD", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, isbgd); y += spacing; continue; } @@ -5104,13 +5109,10 @@ void M_DrawItemToggles(void) drawnum = K_ItemResultToAmount(currentMenu->menuitems[thisitem].mvar1); - if (cv->value) - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_CACHE)); - else - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBGD", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, cv->value ? isbg : isbgd); if (drawnum > 1) - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISMUL", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, ismul); pat = W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].mvar1, true), PU_CACHE); @@ -5128,7 +5130,7 @@ void M_DrawItemToggles(void) } if (!cv->value) - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISSTRK", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, isstrk); y += spacing; }