(re-)implement pages for the Statistics Menu

Was previously a feature of older versions of SRB2, but newer releases have had more compact statistics menus.
However, we now have wayyyyy more to track than SRB2 ever did, so this is now actually justified.

Currently there are only two pages, and the first page is empty. This will change shortly.
This commit is contained in:
toaster 2023-08-06 14:53:29 +01:00
parent 73a5500b0e
commit efe02794d4
3 changed files with 124 additions and 42 deletions

View file

@ -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;

View file

@ -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

View file

@ -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)