M_CheckLevelEmblems: Support tagging ET_TIME emblems

An ET_TIME emblem with a nonzero tag is directly bound to a staff ghost's finish time. This will make late development medal implementation signifcantly easier.
This commit is contained in:
toaster 2023-02-04 22:17:47 +00:00
parent 2d54acae30
commit 42969d8d15
2 changed files with 29 additions and 6 deletions

View file

@ -1578,6 +1578,15 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
goto bademblem;
}
if (emblem->tag > 0)
{
if (emblem->tag > mapheaderinfo[emblemmap-1]->ghostCount
|| mapheaderinfo[emblemmap-1]->ghostBrief[emblem->tag-1] == NULL)
goto bademblem;
timetoreach = mapheaderinfo[emblemmap-1]->ghostBrief[emblem->tag-1]->time;
}
snprintf(targettext, 9, "%i'%02i\"%02i",
G_TicsToMinutes(timetoreach, false),
G_TicsToSeconds(timetoreach),
@ -1605,9 +1614,10 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
goto bademblem;
}
V_DrawRightAlignedString(workx, worky, splitflags|V_6WIDTHSPACE, targettext);
workx -= 67;
V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchName("NEEDIT", PU_CACHE));
workx -= V_ThinStringWidth(targettext, splitflags|V_6WIDTHSPACE);
V_DrawThinString(workx, worky, splitflags|V_6WIDTHSPACE, targettext);
workx -= 11;
V_DrawSmallScaledPatch(workx, worky, splitflags, W_CachePatchName("NEEDIT", PU_CACHE));
break;
@ -1619,8 +1629,8 @@ bademblem:
splitflags = (splitflags &~ V_HUDTRANSHALF)|V_HUDTRANS;
while (curemb--)
{
workx -= 12;
V_DrawSmallMappedPatch(workx + 4, worky, splitflags, emblempic[curemb], emblemcol[curemb]);
workx -= 11;
V_DrawSmallMappedPatch(workx, worky, splitflags, emblempic[curemb], emblemcol[curemb]);
}
}
}

View file

@ -949,6 +949,7 @@ UINT8 M_CheckLevelEmblems(void)
{
INT32 i;
INT32 valToReach;
INT16 tag;
INT16 levelnum;
UINT8 res;
UINT8 somethingUnlocked = 0;
@ -968,11 +969,23 @@ UINT8 M_CheckLevelEmblems(void)
levelnum = checkLevel;
valToReach = emblemlocations[i].var;
tag = emblemlocations[i].tag;
switch (emblemlocations[i].type)
{
case ET_TIME: // Requires time on map <= x
res = (G_GetBestTime(levelnum) <= (unsigned)valToReach);
if (tag > 0)
{
if (tag > mapheaderinfo[checkLevel]->ghostCount
|| mapheaderinfo[checkLevel]->ghostBrief[tag-1] == NULL)
continue;
res = (G_GetBestTime(levelnum) <= mapheaderinfo[checkLevel]->ghostBrief[tag-1]->time);
}
else
{
res = (G_GetBestTime(levelnum) <= (unsigned)valToReach);
}
break;
default: // unreachable but shuts the compiler up.
continue;