Statistics respects cups now

- Adds headers to the list
- Adds indentation
- Doesn't show extra medals if there are none available
- Cleans up some of the undesired duplication in the drawer
This commit is contained in:
toaster 2023-03-14 20:27:58 +00:00
parent 4db0affd2b
commit 22e17fd881
3 changed files with 100 additions and 38 deletions

View file

@ -1196,6 +1196,7 @@ boolean M_ChallengesInputs(INT32 ch);
extern struct statisticsmenu_s { extern struct statisticsmenu_s {
INT32 location; INT32 location;
INT32 nummaps; INT32 nummaps;
INT32 numextramedals;
INT32 maxscroll; INT32 maxscroll;
UINT16 *maplist; UINT16 *maplist;
} statisticsmenu; } statisticsmenu;

View file

@ -5662,27 +5662,53 @@ static void M_DrawStatsMaps(void)
V_DrawCharacter(10, y-(skullAnimCounter/5), V_DrawCharacter(10, y-(skullAnimCounter/5),
'\x1A' | highlightflags, false); // up arrow '\x1A' | highlightflags, false); // up arrow
while (statisticsmenu.maplist[++i] != NEXTMAP_INVALID) while ((mnum = statisticsmenu.maplist[++i]) != NEXTMAP_INVALID)
{ {
if (location) if (location)
{ {
--location; --location;
continue; continue;
} }
else if (dotopname)
if (dotopname || mnum >= nummapheaders)
{ {
V_DrawThinString(20, y, V_6WIDTHSPACE|highlightflags, "LEVEL NAME"); if (mnum >= nummapheaders)
V_DrawRightAlignedThinString(BASEVIDWIDTH-20, y, V_6WIDTHSPACE|highlightflags, "MEDALS"); {
mnum = statisticsmenu.maplist[1+i];
if (mnum >= nummapheaders)
mnum = statisticsmenu.maplist[i-1];
}
if (mnum < nummapheaders)
{
const char *str;
if (mapheaderinfo[mnum]->cup)
str = va("%s CUP", mapheaderinfo[mnum]->cup->name);
else
str = "LOST AND FOUND";
V_DrawThinString(20, y, V_6WIDTHSPACE|highlightflags, str);
}
if (dotopname)
{
V_DrawRightAlignedThinString(BASEVIDWIDTH-20, y, V_6WIDTHSPACE|highlightflags, "MEDALS");
dotopname = false;
}
y += STATSSTEP; y += STATSSTEP;
dotopname = false; if (y >= BASEVIDHEIGHT-STATSSTEP)
goto bottomarrow;
continue;
} }
mnum = statisticsmenu.maplist[i]+1; M_DrawMapMedals(mnum+1, 291, y);
M_DrawMapMedals(mnum, 291, y);
{ {
char *title = G_BuildMapTitle(mnum); char *title = G_BuildMapTitle(mnum+1);
V_DrawThinString(20, y, V_6WIDTHSPACE, title); V_DrawThinString(24, y, V_6WIDTHSPACE, title);
Z_Free(title); Z_Free(title);
} }
@ -5691,15 +5717,12 @@ static void M_DrawStatsMaps(void)
if (y >= BASEVIDHEIGHT-STATSSTEP) if (y >= BASEVIDHEIGHT-STATSSTEP)
goto bottomarrow; goto bottomarrow;
} }
if (dotopname && !location) if (location)
{
V_DrawString(20, y, V_6WIDTHSPACE|highlightflags, "LEVEL NAME");
V_DrawString(256, y, V_6WIDTHSPACE|highlightflags, "MEDALS");
y += STATSSTEP;
}
else if (location)
--location; --location;
if (statisticsmenu.numextramedals == 0)
goto bottomarrow;
// Extra Emblem headers // Extra Emblem headers
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
{ {
@ -5738,7 +5761,6 @@ static void M_DrawStatsMaps(void)
continue; continue;
} }
if (i >= 0)
{ {
if (gamedata->unlocked[i]) if (gamedata->unlocked[i])
{ {
@ -5753,7 +5775,7 @@ static void M_DrawStatsMaps(void)
V_DrawSmallScaledPatch(291, y+1, V_6WIDTHSPACE, W_CachePatchName("NEEDIT", PU_CACHE)); V_DrawSmallScaledPatch(291, y+1, V_6WIDTHSPACE, W_CachePatchName("NEEDIT", PU_CACHE));
} }
V_DrawThinString(20, y, V_6WIDTHSPACE, va("%s", unlockables[i].name)); V_DrawThinString(24, y, V_6WIDTHSPACE, va("%s", unlockables[i].name));
} }
y += STATSSTEP; y += STATSSTEP;

View file

@ -8,37 +8,76 @@
struct statisticsmenu_s statisticsmenu; struct statisticsmenu_s statisticsmenu;
static boolean M_StatisticsAddMap(UINT16 map, cupheader_t *cup, boolean *headerexists)
{
if (!mapheaderinfo[map])
return false;
if (mapheaderinfo[map]->cup != cup)
return false;
// Check for no visibility
if (mapheaderinfo[map]->menuflags & (LF2_NOTIMEATTACK|LF2_HIDEINSTATS|LF2_HIDEINMENU))
return false;
// Check for completion
if ((mapheaderinfo[map]->menuflags & LF2_FINISHNEEDED)
&& !(mapheaderinfo[map]->mapvisited & MV_BEATEN))
return false;
// Check for unlock
if (M_MapLocked(map+1))
return false;
if (*headerexists == false)
{
statisticsmenu.maplist[statisticsmenu.nummaps++] = NEXTMAP_TITLE; // cheeky hack
*headerexists = true;
}
statisticsmenu.maplist[statisticsmenu.nummaps++] = map;
return true;
}
void M_Statistics(INT32 choice) void M_Statistics(INT32 choice)
{ {
UINT16 i = 0; cupheader_t *cup;
UINT16 i;
boolean headerexists;
(void)choice; (void)choice;
statisticsmenu.maplist = Z_Malloc(sizeof(UINT16) * nummapheaders, PU_STATIC, NULL); statisticsmenu.maplist = Z_Malloc(sizeof(UINT16) * (nummapheaders+1 + numkartcupheaders), PU_STATIC, NULL);
statisticsmenu.nummaps = 0; statisticsmenu.nummaps = 0;
for (cup = kartcupheaders; cup; cup = cup->next)
{
headerexists = false;
if (M_CupLocked(cup))
continue;
for (i = 0; i < CUPCACHE_MAX; i++)
{
if (cup->cachedlevels[i] >= nummapheaders)
continue;
M_StatisticsAddMap(cup->cachedlevels[i], cup, &headerexists);
}
}
headerexists = false;
for (i = 0; i < nummapheaders; i++) for (i = 0; i < nummapheaders; i++)
{ {
if (!mapheaderinfo[i]) M_StatisticsAddMap(i, NULL, &headerexists);
continue;
// Check for no visibility + legacy box
if (mapheaderinfo[i]->menuflags & (LF2_NOTIMEATTACK|LF2_HIDEINSTATS|LF2_HIDEINMENU))
continue;
// Check for completion
if ((mapheaderinfo[i]->menuflags & LF2_FINISHNEEDED)
&& !(mapheaderinfo[i]->mapvisited & MV_BEATEN))
continue;
// Check for unlock
if (M_MapLocked(i+1))
continue;
statisticsmenu.maplist[statisticsmenu.nummaps++] = i;
} }
if ((i = statisticsmenu.numextramedals = M_CountMedals(true, true)) != 0)
i += 2;
statisticsmenu.maplist[statisticsmenu.nummaps] = NEXTMAP_INVALID; statisticsmenu.maplist[statisticsmenu.nummaps] = NEXTMAP_INVALID;
statisticsmenu.maxscroll = (statisticsmenu.nummaps + M_CountMedals(true, true) + 2) - 10; statisticsmenu.maxscroll = (statisticsmenu.nummaps + i) - 11;
statisticsmenu.location = 0; statisticsmenu.location = 0;
if (statisticsmenu.maxscroll < 0) if (statisticsmenu.maxscroll < 0)