From 6d4b55a2d506bbfe8bd3c5f7cfa59b52cff07611 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 10 Dec 2022 21:06:24 +0000 Subject: [PATCH] Add a x/X counter to the unlocks menu, like KAR and Smash --- src/k_menu.h | 8 ++++++++ src/k_menudraw.c | 39 ++++++++++++++++++++++++++------------- src/k_menufunc.c | 42 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 73 insertions(+), 16 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index d6c6534dd..1701b3911 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1088,6 +1088,12 @@ void M_DrawAddons(void); #define RIGHTUNLOCKSCROLL 3 #define LEFTUNLOCKSCROLL (RIGHTUNLOCKSCROLL-1) +#define CC_TOTAL 0 +#define CC_UNLOCKED 1 +#define CC_TALLY 2 +#define CC_ANIM 3 +#define CC_MAX 4 + // Keep track of some pause menu data for visual goodness. extern struct challengesmenu_s { @@ -1105,6 +1111,8 @@ extern struct challengesmenu_s { boolean pending; boolean requestnew; + UINT8 unlockcount[CC_MAX]; + UINT8 fade; } challengesmenu; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index a3b27c54f..bc5db7449 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4684,24 +4684,37 @@ void M_DrawChallenges(void) M_DrawCharSelectExplosions(false, explodex, currentMenu->y); challengedesc: - y = 120; - V_DrawScaledPatch(0, y, 0, W_CachePatchName("MENUHINT", PU_CACHE)); - if (challengesmenu.currentunlock < MAXUNLOCKABLES) + // Tally { - str = unlockables[challengesmenu.currentunlock].name; - if (!gamedata->unlocked[challengesmenu.currentunlock]) + str = va("%d/%d", + challengesmenu.unlockcount[CC_UNLOCKED] + challengesmenu.unlockcount[CC_TALLY], + challengesmenu.unlockcount[CC_TOTAL] + ); + V_DrawRightAlignedKartString(BASEVIDWIDTH-7, 9-challengesmenu.unlockcount[CC_ANIM], 0, str); + } + + // Name bar + { + y = 120; + V_DrawScaledPatch(0, y, 0, W_CachePatchName("MENUHINT", PU_CACHE)); + + if (challengesmenu.currentunlock < MAXUNLOCKABLES) { - str = "???"; //M_CreateSecretMenuOption(str); + str = unlockables[challengesmenu.currentunlock].name; + if (!gamedata->unlocked[challengesmenu.currentunlock]) + { + str = "???"; //M_CreateSecretMenuOption(str); + } + } + else + { + str = "---"; } - } - else - { - str = "---"; - } - offset = V_LSTitleLowStringWidth(str, 0) / 2; - V_DrawLSTitleLowString(BASEVIDWIDTH/2 - offset, y+6, 0, str); + offset = V_LSTitleLowStringWidth(str, 0) / 2; + V_DrawLSTitleLowString(BASEVIDWIDTH/2 - offset, y+6, 0, str); + } if (!challengesmenu.fade) V_DrawThinString(20, 120 + 60, V_ALLOWLOWERCASE, "Press (B)"); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 3319e32b8..6b28385dc 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -6848,6 +6848,8 @@ struct challengesmenu_s challengesmenu; menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu) { + UINT8 i; + M_UpdateUnlockablesAndExtraEmblems(false); if ((challengesmenu.pending = challengesmenu.requestnew = (M_GetNextAchievedUnlock() < MAXUNLOCKABLES))) @@ -6864,6 +6866,24 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu) if (gamedata->challengegrid) challengesmenu.extradata = M_ChallengeGridExtraData(); + memset(&challengesmenu.unlockcount, 0, sizeof(challengesmenu.unlockcount)); + for (i = 0; i < MAXUNLOCKABLES; i++) + { + if (!unlockables[i].conditionset) + { + continue; + } + + challengesmenu.unlockcount[CC_TOTAL]++; + + if (!gamedata->unlocked[i]) + { + continue; + } + + challengesmenu.unlockcount[CC_UNLOCKED]++; + } + return &MISC_ChallengesDef; } @@ -7035,6 +7055,8 @@ void M_ChallengesTick(void) if (setup_explosions[i].tics > 0) setup_explosions[i].tics--; } + if (challengesmenu.unlockcount[CC_ANIM] > 0) + challengesmenu.unlockcount[CC_ANIM]--; if (challengesmenu.pending) { @@ -7075,6 +7097,8 @@ void M_ChallengesTick(void) { // Unlock animation... also tied directly to the actual unlock! gamedata->unlocked[challengesmenu.currentunlock] = true; + challengesmenu.unlockcount[CC_TALLY]++; + challengesmenu.unlockcount[CC_ANIM]++; Z_Free(challengesmenu.extradata); if ((challengesmenu.extradata = M_ChallengeGridExtraData())) @@ -7127,10 +7151,22 @@ void M_ChallengesTick(void) } } } - else if (challengesmenu.fade > 0) + else { - // Fade decrease. - challengesmenu.fade--; + + // Tick down the tally. (currently not visible) + /*if ((challengesmenu.ticker & 1) + && challengesmenu.unlockcount[CC_TALLY] > 0) + { + challengesmenu.unlockcount[CC_TALLY]--; + challengesmenu.unlockcount[CC_UNLOCKED]++; + }*/ + + if (challengesmenu.fade > 0) + { + // Fade decrease. + challengesmenu.fade--; + } } }