diff --git a/src/k_menu.h b/src/k_menu.h index ab3a26443..1505c8e96 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1259,7 +1259,15 @@ void M_DrawChallenges(void); void M_ChallengesTick(void); boolean M_ChallengesInputs(INT32 ch); +typedef enum +{ + statisticspage_basic = 0, + statisticspage_maps, + statisticspage_max +} statisticspage_t; + extern struct statisticsmenu_s { + statisticspage_t page; INT32 location; INT32 nummaps; INT32 numextramedals; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index ad92404a2..67e703dc9 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5997,15 +5997,57 @@ static void M_DrawMapMedals(INT32 mapnum, INT32 x, INT32 y) static void M_DrawStatsMaps(void) { - INT32 y = 80, i = -1; + INT32 y = 80, i; INT16 mnum; boolean dotopname = true, dobottomarrow = (statisticsmenu.location < statisticsmenu.maxscroll); INT32 location = statisticsmenu.location; + char beststr[256]; + + tic_t besttime = 0; + + INT32 mapsunfinished = 0; + + if (!statisticsmenu.maplist) + { + V_DrawCenteredThinString(BASEVIDWIDTH/2, 62, 0, "No maps!?"); + return; + } + + for (i = 0; i < nummapheaders; i++) + { + if (!mapheaderinfo[i] || (mapheaderinfo[i]->menuflags & (LF2_NOTIMEATTACK|LF2_HIDEINSTATS|LF2_HIDEINMENU))) + continue; + + if (mapheaderinfo[i]->records.time <= 0) + { + mapsunfinished++; + continue; + } + + besttime += mapheaderinfo[i]->records.time; + } + + V_DrawThinString(20, 60, 0, "Combined time records:"); + + sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); + V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 60, (mapsunfinished ? V_REDMAP : 0), beststr); + + if (mapsunfinished) + V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 70, V_REDMAP, va("(%d unfinished)", mapsunfinished)); + else + V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 70, 0, "(complete)"); + + V_DrawThinString(32, 70, 0, va("x %d/%d", M_CountMedals(false, false), M_CountMedals(true, false))); + V_DrawSmallMappedPatch(20, 70, 0, W_CachePatchName("GOTITA", PU_CACHE), + R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GOLD, GTC_MENUCACHE)); + if (location) V_DrawCharacter(10, y-(skullAnimCounter/5), '\x1A' | highlightflags, false); // up arrow + i = -1; + while ((mnum = statisticsmenu.maplist[++i]) != NEXTMAP_INVALID) { if (location) @@ -6136,12 +6178,8 @@ bottomarrow: void M_DrawStatistics(void) { char beststr[256]; - tic_t besttime = 0; - INT32 i; - INT32 mapsunfinished = 0; - { patch_t *bg = W_CachePatchName("M_XTRABG", PU_CACHE); V_DrawFixedPatch(0, 0, FRACUNIT, 0, bg, NULL); @@ -6213,43 +6251,17 @@ void M_DrawStatistics(void) V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 42, 0, beststr); - if (!statisticsmenu.maplist) + switch (statisticsmenu.page) { - V_DrawCenteredThinString(BASEVIDWIDTH/2, 62, 0, "No maps!?"); - return; - } - - besttime = 0; - - for (i = 0; i < nummapheaders; i++) - { - if (!mapheaderinfo[i] || (mapheaderinfo[i]->menuflags & (LF2_NOTIMEATTACK|LF2_HIDEINSTATS|LF2_HIDEINMENU))) - continue; - - if (mapheaderinfo[i]->records.time <= 0) + case statisticspage_maps: { - mapsunfinished++; - continue; + M_DrawStatsMaps(); + break; } - besttime += mapheaderinfo[i]->records.time; + default: + break; } - - V_DrawThinString(20, 60, 0, "Combined time records:"); - - sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); - V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 60, (mapsunfinished ? V_REDMAP : 0), beststr); - - if (mapsunfinished) - V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 70, V_REDMAP, va("(%d unfinished)", mapsunfinished)); - else - V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 70, 0, "(complete)"); - - V_DrawThinString(32, 70, 0, va("x %d/%d", M_CountMedals(false, false), M_CountMedals(true, false))); - V_DrawSmallMappedPatch(20, 70, 0, W_CachePatchName("GOTITA", PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GOLD, GTC_MENUCACHE)); - - M_DrawStatsMaps(); } #undef STATSSTEP diff --git a/src/menus/extras-statistics.c b/src/menus/extras-statistics.c index bc4843b27..787a633db 100644 --- a/src/menus/extras-statistics.c +++ b/src/menus/extras-statistics.c @@ -43,14 +43,12 @@ static boolean M_StatisticsAddMap(UINT16 map, cupheader_t *cup, boolean *headere return true; } -void M_Statistics(INT32 choice) +static void M_StatisticsMaps(void) { cupheader_t *cup; UINT16 i; boolean headerexists; - (void)choice; - statisticsmenu.maplist = Z_Malloc(sizeof(UINT16) * (nummapheaders+1 + numkartcupheaders), PU_STATIC, NULL); statisticsmenu.nummaps = 0; @@ -88,6 +86,46 @@ void M_Statistics(INT32 choice) { statisticsmenu.maxscroll = 0; } +} + +static void M_StatisticsPageInit(void) +{ + switch (statisticsmenu.page) + { + case statisticspage_maps: + { + M_StatisticsMaps(); + break; + } + + default: + break; + } +} + +static void M_StatisticsPageClear(void) +{ + switch (statisticsmenu.page) + { + case statisticspage_maps: + { + Z_Free(statisticsmenu.maplist); + statisticsmenu.maplist = NULL; + + break; + } + + default: + break; + } +} + +void M_Statistics(INT32 choice) +{ + (void)choice; + + statisticsmenu.page = statisticspage_basic; + M_StatisticsPageInit(); MISC_StatisticsDef.prevMenu = currentMenu; M_SetupNextMenu(&MISC_StatisticsDef, false); @@ -104,12 +142,36 @@ boolean M_StatisticsInputs(INT32 ch) M_GoBack(0); M_SetMenuDelay(pid); - Z_Free(statisticsmenu.maplist); - statisticsmenu.maplist = NULL; + M_StatisticsPageClear(); return true; } + if (menucmd[pid].dpad_lr != 0) + { + M_StatisticsPageClear(); + + statisticsmenu.page += + statisticspage_max + + ( + (menucmd[pid].dpad_lr > 0) + ? 1 + : -1 + ); + + statisticsmenu.page %= statisticspage_max; + + M_StatisticsPageInit(); + + S_StartSound(NULL, sfx_s3k5b); + M_SetMenuDelay(pid); + + return true; + } + + if (statisticsmenu.page != statisticspage_maps) + return true; // temporary + if (M_MenuExtraPressed(pid)) { if (statisticsmenu.location > 0)