From 42969d8d15a683053fc2b8090b0d6bf5900b257c Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 4 Feb 2023 22:17:47 +0000 Subject: [PATCH] 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. --- src/k_hud.c | 20 +++++++++++++++----- src/m_cond.c | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 0a1b262f4..86b9cc82a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -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]); } } } diff --git a/src/m_cond.c b/src/m_cond.c index b941ea65c..4f0a9126a 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -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;