Merge branch 'statistics-101percent' into 'master'

Statistics 101%

See merge request KartKrew/Kart!2231
This commit is contained in:
Oni 2024-04-05 02:27:48 +00:00
commit e19ed5bc29
6 changed files with 105 additions and 39 deletions

View file

@ -440,8 +440,14 @@ void G_UpdateTimeStickerMedals(UINT16 map, boolean showownrecord)
if (cv_dummyspbattack.value && !(emblem->flags & (ME_SPBATTACK|ME_ENCORE))) if (cv_dummyspbattack.value && !(emblem->flags & (ME_SPBATTACK|ME_ENCORE)))
return; return;
if (!gamedata->collected[(emblem-emblemlocations)] && gonnadrawtime) if (!gamedata->collected[(emblem-emblemlocations)])
break; {
if (gonnadrawtime)
break;
if (emblem->type == ET_TIME && emblem->tag == AUTOMEDAL_PLATINUM)
stickermedalinfo.platinumcount++;
}
// Simpler than having two checks // Simpler than having two checks
if (stickermedalinfo.visiblecount == MAXMEDALVISIBLECOUNT) if (stickermedalinfo.visiblecount == MAXMEDALVISIBLECOUNT)

View file

@ -213,6 +213,7 @@ void G_EndGame(void); // moved from y_inter.c/h and renamed
extern struct stickermedalinfo extern struct stickermedalinfo
{ {
UINT8 visiblecount; UINT8 visiblecount;
UINT8 platinumcount;
UINT8 jitter; UINT8 jitter;
boolean norecord; boolean norecord;
tic_t timetoreach; tic_t timetoreach;

View file

@ -1930,6 +1930,19 @@ tic_t K_TranslateTimer(tic_t drawtime, UINT8 mode, INT32 *return_jitter)
return drawtime; return drawtime;
} }
INT32 K_drawKartMicroTime(const char *todrawtext, INT32 workx, INT32 worky, INT32 splitflags)
{
using srb2::Draw;
Draw::TextElement text(todrawtext);
text.flags(splitflags);
text.font(Draw::Font::kZVote);
INT32 result = text.width();
Draw(workx - result, worky).text(text);
return result;
}
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode) void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode)
{ {
// TIME_X = BASEVIDWIDTH-124; // 196 // TIME_X = BASEVIDWIDTH-124; // 196
@ -2006,16 +2019,10 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, U
} }
} }
using srb2::Draw; workx -= K_drawKartMicroTime(stickermedalinfo.targettext, workx, worky, splitflags);
Draw::TextElement text(stickermedalinfo.targettext);
text.flags(splitflags);
text.font(Draw::Font::kZVote);
workx -= text.width();
Draw(workx, worky).text(text);
} }
workx -= (6 + (i*5)); workx -= (((1 + i - stickermedalinfo.platinumcount)*6) - 1);
if (!mode) if (!mode)
splitflags = (splitflags &~ V_HUDTRANSHALF)|V_HUDTRANS; splitflags = (splitflags &~ V_HUDTRANSHALF)|V_HUDTRANS;
@ -2029,16 +2036,21 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, U
static_cast<patch_t*>(W_CachePatchName(M_GetEmblemPatch(stickermedalinfo.emblems[i], false), PU_CACHE)), static_cast<patch_t*>(W_CachePatchName(M_GetEmblemPatch(stickermedalinfo.emblems[i], false), PU_CACHE)),
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(stickermedalinfo.emblems[i]), GTC_CACHE) R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(stickermedalinfo.emblems[i]), GTC_CACHE)
); );
workx += 6;
} }
else else if (
stickermedalinfo.emblems[i]->type != ET_TIME
|| stickermedalinfo.emblems[i]->tag != AUTOMEDAL_PLATINUM
)
{ {
V_DrawMappedPatch(workx, worky, splitflags, V_DrawMappedPatch(workx, worky, splitflags,
static_cast<patch_t*>(W_CachePatchName("NEEDIT", PU_CACHE)), static_cast<patch_t*>(W_CachePatchName("NEEDIT", PU_CACHE)),
NULL NULL
); );
}
workx += 6; workx += 6;
}
} }
} }

View file

@ -45,6 +45,7 @@ void K_drawKartFreePlay(void);
void K_drawKartPowerUps(void); void K_drawKartPowerUps(void);
void K_drawSpectatorHUD(boolean director); void K_drawSpectatorHUD(boolean director);
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode);
INT32 K_drawKartMicroTime(const char *todrawtext, INT32 workx, INT32 worky, INT32 splitflags);
void K_drawKart2PTimestamp(void); void K_drawKart2PTimestamp(void);
void K_drawKart4PTimestamp(void); void K_drawKart4PTimestamp(void);
void K_drawEmeraldWin(boolean overlay); void K_drawEmeraldWin(boolean overlay);

View file

@ -7952,24 +7952,32 @@ challengedesc:
#define STATSSTEP 10 #define STATSSTEP 10
static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y) static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y, boolean allowtime, boolean allowencore, boolean allowspb)
{ {
UINT8 lasttype = UINT8_MAX, curtype; UINT8 lasttype = UINT8_MAX, curtype;
// M_GetLevelEmblems is ONE-indexed, urgh // M_GetLevelEmblems is ONE-indexed, urgh
mapnum++; emblem_t *emblem = M_GetLevelEmblems(mapnum+1);
emblem_t *emblem = M_GetLevelEmblems(mapnum); const boolean hasmedals = (emblem != NULL);
boolean collected = false;
boolean hasmedals = (emblem != NULL);
while (emblem) while (emblem)
{ {
collected = gamedata->collected[emblem-emblemlocations];
switch (emblem->type) switch (emblem->type)
{ {
case ET_TIME: case ET_TIME:
{
if (!allowtime
|| (!collected && emblem->tag == AUTOMEDAL_PLATINUM))
{
emblem = M_GetLevelEmblems(-1);
continue;
}
curtype = 1; curtype = 1;
break; break;
}
case ET_GLOBAL: case ET_GLOBAL:
{ {
if (emblem->flags & GE_NOTMEDAL) if (emblem->flags & GE_NOTMEDAL)
@ -7982,8 +7990,8 @@ static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y)
} }
case ET_MAP: case ET_MAP:
{ {
if (((emblem->flags & ME_ENCORE) && !M_SecretUnlocked(SECRET_ENCORE, true)) if (((emblem->flags & ME_ENCORE) && !allowencore)
|| ((emblem->flags & ME_SPBATTACK) && !M_SecretUnlocked(SECRET_SPBATTACK, true))) || ((emblem->flags & ME_SPBATTACK) && !allowspb))
{ {
emblem = M_GetLevelEmblems(-1); emblem = M_GetLevelEmblems(-1);
continue; continue;
@ -7992,8 +8000,10 @@ static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y)
break; break;
} }
default: default:
{
curtype = 0; curtype = 0;
break; break;
}
} }
// Shift over if emblem is of a different discipline // Shift over if emblem is of a different discipline
@ -8001,7 +8011,7 @@ static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y)
x -= 4; x -= 4;
lasttype = curtype; lasttype = curtype;
if (gamedata->collected[emblem-emblemlocations]) if (collected)
V_DrawMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE), V_DrawMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE),
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE)); R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE));
else else
@ -8011,9 +8021,6 @@ static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y)
x -= 8; x -= 8;
} }
// Undo offset
mapnum--;
if (hasmedals) if (hasmedals)
x -= 4; x -= 4;
@ -8107,6 +8114,10 @@ static void M_DrawStatsMaps(void)
i = -1; i = -1;
const boolean allowencore = M_SecretUnlocked(SECRET_ENCORE, true);
const boolean allowspb = M_SecretUnlocked(SECRET_SPBATTACK, true);
boolean allowtime = false;
while ((mnum = statisticsmenu.maplist[++i]) != NEXTMAP_INVALID) while ((mnum = statisticsmenu.maplist[++i]) != NEXTMAP_INVALID)
{ {
if (location) if (location)
@ -8157,33 +8168,36 @@ static void M_DrawStatsMaps(void)
V_DrawFadeFill(24, y + 5, (BASEVIDWIDTH - 24) - 24, 3, 0, 31, 8 - (i & 1)*2); V_DrawFadeFill(24, y + 5, (BASEVIDWIDTH - 24) - 24, 3, 0, 31, 8 - (i & 1)*2);
if (!(mapheaderinfo[mnum]->menuflags & LF2_NOTIMEATTACK) allowtime = (
&& (
(timeattack[0] && (mapheaderinfo[mnum]->typeoflevel & TOL_RACE)) (timeattack[0] && (mapheaderinfo[mnum]->typeoflevel & TOL_RACE))
|| (timeattack[1] && (mapheaderinfo[mnum]->typeoflevel & TOL_BATTLE)) || (timeattack[1] && (mapheaderinfo[mnum]->typeoflevel & TOL_BATTLE))
|| (timeattack[2] && (mapheaderinfo[mnum]->typeoflevel & (TOL_SPECIAL|TOL_VERSUS))) || (timeattack[2] && (mapheaderinfo[mnum]->typeoflevel & (TOL_SPECIAL|TOL_VERSUS)))
) );
)
if (!(mapheaderinfo[mnum]->menuflags & LF2_NOTIMEATTACK) && allowtime)
{ {
besttime = mapheaderinfo[mnum]->records.timeattack.time; besttime = mapheaderinfo[mnum]->records.timeattack.time;
const char *todrawtext = "--'--\"--";
if (besttime) if (besttime)
{ {
V_DrawRightAlignedString((BASEVIDWIDTH-24), y+1, 0, todrawtext = va("%02d'%02d\"%02d",
va("%02d'%02d\"%02d", G_TicsToMinutes(besttime, true),
G_TicsToMinutes(besttime, true), G_TicsToSeconds(besttime),
G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)
G_TicsToCentiseconds(besttime)
)
); );
} }
else
{ K_drawKartMicroTime(
V_DrawRightAlignedString((BASEVIDWIDTH-24), y+1, V_GRAYMAP, "--'--\"--"); todrawtext,
} (BASEVIDWIDTH-24),
y,
(besttime ? 0 : V_TRANSLUCENT)
);
} }
M_DrawMapMedals(mnum, medalspos - 8, y); M_DrawMapMedals(mnum, medalspos - 8, y, allowtime, allowencore, allowspb);
if (mapheaderinfo[mnum]->menuttl[0]) if (mapheaderinfo[mnum]->menuttl[0])
{ {

View file

@ -3441,16 +3441,31 @@ INT32 M_CountMedals(boolean all, boolean extraonly)
{ {
for (i = 0; i < numemblems; ++i) for (i = 0; i < numemblems; ++i)
{ {
// Not init in SOC
if (emblemlocations[i].type == ET_NONE) if (emblemlocations[i].type == ET_NONE)
continue; continue;
// Not explicitly a medal
if ((emblemlocations[i].type == ET_GLOBAL) if ((emblemlocations[i].type == ET_GLOBAL)
&& (emblemlocations[i].flags & GE_NOTMEDAL)) && (emblemlocations[i].flags & GE_NOTMEDAL))
continue; continue;
// Not getting the counter, and not collected
if (!all && !gamedata->collected[i]) if (!all && !gamedata->collected[i])
continue; continue;
// Don't count Platinums in the overall count, so you can get 101% going for them
if (all
&& (emblemlocations[i].type == ET_TIME)
&& (emblemlocations[i].tag == AUTOMEDAL_PLATINUM))
continue;
// Relevant, add to da counter
found++; found++;
} }
} }
// Above but for extramedals
for (i = 0; i < MAXUNLOCKABLES; ++i) for (i = 0; i < MAXUNLOCKABLES; ++i)
{ {
if (unlockables[i].type != SECRET_EXTRAMEDAL) if (unlockables[i].type != SECRET_EXTRAMEDAL)
@ -3459,6 +3474,7 @@ INT32 M_CountMedals(boolean all, boolean extraonly)
continue; continue;
found++; found++;
} }
return found; return found;
} }
@ -3473,14 +3489,28 @@ boolean M_GotEnoughMedals(INT32 number)
INT32 i, gottenmedals = 0; INT32 i, gottenmedals = 0;
for (i = 0; i < numemblems; ++i) for (i = 0; i < numemblems; ++i)
{ {
// Not init in SOC
if (emblemlocations[i].type == ET_NONE) if (emblemlocations[i].type == ET_NONE)
continue; continue;
// Not explicitly a medal
if ((emblemlocations[i].type == ET_GLOBAL)
&& (emblemlocations[i].flags & GE_NOTMEDAL))
continue;
// Not collected
if (!gamedata->collected[i]) if (!gamedata->collected[i])
continue; continue;
// Add to counter. Hit our threshold?
if (++gottenmedals < number) if (++gottenmedals < number)
continue; continue;
// We did!
return true; return true;
} }
// Above but for extramedals
for (i = 0; i < MAXUNLOCKABLES; ++i) for (i = 0; i < MAXUNLOCKABLES; ++i)
{ {
if (unlockables[i].type != SECRET_EXTRAMEDAL) if (unlockables[i].type != SECRET_EXTRAMEDAL)
@ -3491,6 +3521,8 @@ boolean M_GotEnoughMedals(INT32 number)
continue; continue;
return true; return true;
} }
// Didn't hit our counter!
return false; return false;
} }