From 1f6038be659ee861ed1d52dc684e0ab85fc50f63 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 6 Apr 2024 22:19:51 +0100 Subject: [PATCH] Add "Time Tracked" page to Statistics Ugly but releasable --- src/k_menu.h | 1 + src/k_menudraw.c | 122 ++++++++++++++++++++++++++++------ src/menus/extras-statistics.c | 3 + 3 files changed, 106 insertions(+), 20 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 47a92f58b..d4e214878 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1434,6 +1434,7 @@ typedef enum statisticspage_chars = 0, statisticspage_gp, statisticspage_maps, + statisticspage_time, statisticspage_max } statisticspage_t; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index be7d460f0..68c532f60 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -8474,10 +8474,103 @@ bottomarrow: #undef STATSSTEP +static void M_GetStatsTime(char *beststr, UINT32 totaltime) +{ + beststr[0] = 0; + + boolean showallsubsequent = false; + + UINT32 besttime = G_TicsToHours(totaltime); + if (besttime) + { + showallsubsequent = true; + if (besttime >= 24) + { + strcat(beststr, va("%u day%s, ", besttime/24, (besttime < 48 ? "" : "s"))); + besttime %= 24; + } + + strcat(beststr, va("%u hour%s, ", besttime, (besttime == 1 ? "" : "s"))); + } + besttime = G_TicsToMinutes(totaltime, false); + if (besttime || showallsubsequent) + { + showallsubsequent = true; + strcat(beststr, va("%u minute%s, ", besttime, (besttime == 1 ? "" : "s"))); + } + besttime = G_TicsToSeconds(totaltime); + strcat(beststr, va("%i second%s", besttime, (besttime == 1 ? "" : "s"))); +} + +static void M_DrawStatsTimeTracked(void) +{ + INT32 y = 70; + char beststr[256]; + + #define DISPLAYAMODE(str, besttime) \ + { \ + V_DrawThinString(24, y, 0, str); \ + M_GetStatsTime(beststr, besttime); \ + V_DrawRightAlignedThinString(BASEVIDWIDTH-24, y, 0, beststr); \ + y += 10; \ + } + + DISPLAYAMODE("Race Mode", gamedata->modeplaytime[GDGT_RACE]); + + if (gamedata->roundsplayed[GDGT_PRISONS]) + { + DISPLAYAMODE("Prison Break", gamedata->modeplaytime[GDGT_PRISONS]); + } + + DISPLAYAMODE("Battle Mode", gamedata->modeplaytime[GDGT_BATTLE]); + + if (gamedata->roundsplayed[GDGT_SPECIAL]) + { + DISPLAYAMODE("Special Mode", gamedata->modeplaytime[GDGT_SPECIAL]); + } + + if (gamedata->roundsplayed[GDGT_CUSTOM]) + { + DISPLAYAMODE("All Custom Modes", gamedata->modeplaytime[GDGT_CUSTOM]); + } + + if (M_SecretUnlocked(SECRET_ONLINE, true)) + { + y += 2; + + DISPLAYAMODE("Playing Online", gamedata->totalnetgametime); + } + + if (M_SecretUnlocked(SECRET_TIMEATTACK, true) + || M_SecretUnlocked(SECRET_PRISONBREAK, true) + || M_SecretUnlocked(SECRET_SPECIALATTACK, true)) + { + y += 2; + + DISPLAYAMODE("Time Attack Modes", gamedata->timeattackingtotaltime); + + if (M_SecretUnlocked(SECRET_SPBATTACK, true)) + { + DISPLAYAMODE(" (SPB Attack)", gamedata->spbattackingtotaltime); + } + } + + if (gamedata->totaltumbletime) + { + y += 2; + + DISPLAYAMODE("Tumbling through the air", gamedata->totaltumbletime); + } + + y += 2; + + DISPLAYAMODE("On Menus", gamedata->totalmenutime); + DISPLAYAMODE(" (staring at this screen)", gamedata->totaltimestaringatstatistics); +} + void M_DrawStatistics(void) { char beststr[256]; - tic_t besttime = 0; { const char *pagename = NULL; @@ -8487,7 +8580,6 @@ void M_DrawStatistics(void) switch (statisticsmenu.page) { - case statisticspage_gp: { pagename = gamedata->everseenspecial @@ -8511,6 +8603,13 @@ void M_DrawStatistics(void) break; } + case statisticspage_time: + { + pagename = "TIME TRACKED"; + M_DrawStatsTimeTracked(); + break; + } + default: break; } @@ -8528,26 +8627,9 @@ void M_DrawStatistics(void) 0, "\x1D"); // right arrow } - beststr[0] = 0; V_DrawThinString(20, 30, highlightflags, "Total Play Time:"); - besttime = G_TicsToHours(gamedata->totalplaytime); - if (besttime) - { - if (besttime >= 24) - { - strcat(beststr, va("%u day%s, ", besttime/24, (besttime < 48 ? "" : "s"))); - besttime %= 24; - } - strcat(beststr, va("%u hour%s, ", besttime, (besttime == 1 ? "" : "s"))); - } - besttime = G_TicsToMinutes(gamedata->totalplaytime, false); - if (besttime) - { - strcat(beststr, va("%u minute%s, ", besttime, (besttime == 1 ? "" : "s"))); - } - besttime = G_TicsToSeconds(gamedata->totalplaytime); - strcat(beststr, va("%i second%s", besttime, (besttime == 1 ? "" : "s"))); + M_GetStatsTime(beststr, gamedata->totalplaytime); V_DrawRightAlignedThinString(BASEVIDWIDTH-20, 30, 0, beststr); beststr[0] = 0; diff --git a/src/menus/extras-statistics.c b/src/menus/extras-statistics.c index 005c6e43f..23df0ff26 100644 --- a/src/menus/extras-statistics.c +++ b/src/menus/extras-statistics.c @@ -255,7 +255,10 @@ static void M_StatisticsPageInit(void) } default: + { + statisticsmenu.maplist = NULL; break; + } } }