From cc4518f80addc183af44df064043cb71184a978c Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 12 Dec 2022 20:39:53 +0000 Subject: [PATCH] M_DrawChallengePreview Draws a preview of an unlock in the bottom left corner. - Currently only supports unlocked ones (needs a roughly character-sized question mark graphic created) - Currently only supports SECRET_SKIN and SECRET_FOLLOWER Also, makes the area available to M_BuildConditionSetString smaller to avoid crossing into that region --- src/k_menudraw.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++- src/m_cond.c | 4 +-- src/m_cond.h | 3 ++- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 92b242ab0..38e55886e 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4594,6 +4594,65 @@ drawborder: ); } +static void M_DrawChallengePreview(INT32 x, INT32 y) +{ + unlockable_t *ref = NULL; + UINT8 *colormap = NULL; + + if (challengesmenu.currentunlock >= MAXUNLOCKABLES) + { + return; + } + + // Okay, this is what we want to draw. + ref = &unlockables[challengesmenu.currentunlock]; + + if (!gamedata->unlocked[challengesmenu.currentunlock]) + { + // todo draw some sort of question mark? + return; + } + + switch (ref->type) + { + case SECRET_SKIN: + { + INT32 skin = M_UnlockableSkinNum(ref); + // Draw our character! + if (skin != -1) + { + colormap = R_GetTranslationColormap(skin, skins[skin].prefcolor, GTC_MENUCACHE); + M_DrawCharacterSprite(x, y, skin, false, false, 0, colormap); + } + break; + } + case SECRET_FOLLOWER: + { + INT32 skin = R_SkinAvailable(cv_skin[0].string); + INT32 fskin = M_UnlockableFollowerNum(ref); + + // Draw proximity reference for character + if (skin == -1) + skin = 0; + colormap = R_GetTranslationColormap(TC_BLINK, SKINCOLOR_BLACK, GTC_MENUCACHE); + M_DrawCharacterSprite(x, y, skin, false, false, 0, colormap); + + // Draw follower next to them + if (fskin != -1) + { + UINT16 col = K_GetEffectiveFollowerColor(followers[fskin].defaultcolor, cv_playercolor[0].value); + colormap = R_GetTranslationColormap(fskin, col, GTC_MENUCACHE); + M_DrawFollowerSprite(x - 16, y, fskin, false, 0, colormap, NULL); + } + break; + } + default: + { + break; + } + } +} + void M_DrawChallenges(void) { INT32 x = currentMenu->x, explodex, selectx; @@ -4723,6 +4782,13 @@ challengedesc: // Conditions for unlock if (challengesmenu.unlockcondition != NULL) { - V_DrawCenteredString(BASEVIDWIDTH/2, 120 + 40, V_ALLOWLOWERCASE, challengesmenu.unlockcondition); + V_DrawCenteredString(BASEVIDWIDTH/2, y + 40, V_ALLOWLOWERCASE, challengesmenu.unlockcondition); } + + // Derived from M_DrawCharSelectPreview + x = 40; + y = BASEVIDHEIGHT-16; + + // Unlock preview + M_DrawChallengePreview(x, y); } diff --git a/src/m_cond.c b/src/m_cond.c index 1735b01e6..7e8845815 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -772,8 +772,8 @@ char *M_BuildConditionSetString(UINT8 unlockid) else max += 8; - // Start trying to wrap if presumed length exceeds the screen width. - if (max >= BASEVIDWIDTH && start > 0) + // Start trying to wrap if presumed length exceeds the space we have on-screen. + if (max >= DESCRIPTIONWIDTH && start > 0) { message[start] = '\n'; max -= (start-strlines)*8; diff --git a/src/m_cond.h b/src/m_cond.h index bab7fc854..e3b1c568d 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -175,12 +175,13 @@ void M_NewGameDataStruct(void); // Challenges menu stuff void M_PopulateChallengeGrid(void); UINT8 *M_ChallengeGridExtraData(void); -char *M_BuildConditionSetString(UINT8 unlockid); #define CHE_NONE 0 #define CHE_HINT 1 #define CHE_CONNECTEDLEFT (1<<1) #define CHE_CONNECTEDUP (1<<2) #define CHE_DONTDRAW (CHE_CONNECTEDLEFT|CHE_CONNECTEDUP) +char *M_BuildConditionSetString(UINT8 unlockid); +#define DESCRIPTIONWIDTH 170 // Condition set setup void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1, INT16 x2);