From 22e17fd881eddaaffc62bd342f4ab0ad16d8548c Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 14 Mar 2023 20:27:58 +0000 Subject: [PATCH] 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 --- src/k_menu.h | 1 + src/k_menudraw.c | 58 +++++++++++++++++-------- src/menus/extras-statistics.c | 79 ++++++++++++++++++++++++++--------- 3 files changed, 100 insertions(+), 38 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 6ee320f92..52a60ac42 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1196,6 +1196,7 @@ boolean M_ChallengesInputs(INT32 ch); extern struct statisticsmenu_s { INT32 location; INT32 nummaps; + INT32 numextramedals; INT32 maxscroll; UINT16 *maplist; } statisticsmenu; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e8ade83a9..92acf9805 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5662,27 +5662,53 @@ static void M_DrawStatsMaps(void) V_DrawCharacter(10, y-(skullAnimCounter/5), '\x1A' | highlightflags, false); // up arrow - while (statisticsmenu.maplist[++i] != NEXTMAP_INVALID) + while ((mnum = statisticsmenu.maplist[++i]) != NEXTMAP_INVALID) { if (location) { --location; continue; } - else if (dotopname) + + if (dotopname || mnum >= nummapheaders) { - V_DrawThinString(20, y, V_6WIDTHSPACE|highlightflags, "LEVEL NAME"); - V_DrawRightAlignedThinString(BASEVIDWIDTH-20, y, V_6WIDTHSPACE|highlightflags, "MEDALS"); + if (mnum >= nummapheaders) + { + 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; - dotopname = false; + if (y >= BASEVIDHEIGHT-STATSSTEP) + goto bottomarrow; + + continue; } - mnum = statisticsmenu.maplist[i]+1; - M_DrawMapMedals(mnum, 291, y); + M_DrawMapMedals(mnum+1, 291, y); { - char *title = G_BuildMapTitle(mnum); - V_DrawThinString(20, y, V_6WIDTHSPACE, title); + char *title = G_BuildMapTitle(mnum+1); + V_DrawThinString(24, y, V_6WIDTHSPACE, title); Z_Free(title); } @@ -5691,15 +5717,12 @@ static void M_DrawStatsMaps(void) if (y >= BASEVIDHEIGHT-STATSSTEP) goto bottomarrow; } - if (dotopname && !location) - { - V_DrawString(20, y, V_6WIDTHSPACE|highlightflags, "LEVEL NAME"); - V_DrawString(256, y, V_6WIDTHSPACE|highlightflags, "MEDALS"); - y += STATSSTEP; - } - else if (location) + if (location) --location; + if (statisticsmenu.numextramedals == 0) + goto bottomarrow; + // Extra Emblem headers for (i = 0; i < 2; ++i) { @@ -5738,7 +5761,6 @@ static void M_DrawStatsMaps(void) continue; } - if (i >= 0) { 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_DrawThinString(20, y, V_6WIDTHSPACE, va("%s", unlockables[i].name)); + V_DrawThinString(24, y, V_6WIDTHSPACE, va("%s", unlockables[i].name)); } y += STATSSTEP; diff --git a/src/menus/extras-statistics.c b/src/menus/extras-statistics.c index 97f4b3192..d34a5d9f4 100644 --- a/src/menus/extras-statistics.c +++ b/src/menus/extras-statistics.c @@ -8,37 +8,76 @@ 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) { - UINT16 i = 0; + cupheader_t *cup; + UINT16 i; + boolean headerexists; (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; + 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++) { - if (!mapheaderinfo[i]) - 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; + M_StatisticsAddMap(i, NULL, &headerexists); } + + if ((i = statisticsmenu.numextramedals = M_CountMedals(true, true)) != 0) + i += 2; + 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; if (statisticsmenu.maxscroll < 0)