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
This commit is contained in:
toaster 2022-12-12 20:39:53 +00:00
parent cc9a65c8f8
commit cc4518f80a
3 changed files with 71 additions and 4 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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);