From 32b2e84fdcd84052ecf9017280496630181ec184 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Oct 2022 17:09:45 +0200 Subject: [PATCH] - added episode and total episode time display to alt HUD --- source/core/gamecontrol.cpp | 1 + source/core/mapinfo.h | 1 + source/core/statistics.cpp | 17 +++++++++++++++++ source/core/statistics.h | 1 + source/games/blood/src/sbar.cpp | 2 ++ source/games/duke/src/sbar.cpp | 1 + source/games/exhumed/src/status.cpp | 2 ++ source/games/sw/src/game.cpp | 1 + source/games/sw/src/sbar.cpp | 1 + wadsrc/static/zscript/alt_hud.zs | 16 +++++++++------- wadsrc/static/zscript/razebase.zs | 3 ++- 11 files changed, 38 insertions(+), 8 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 5d608e88f..5d0611b2a 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1584,6 +1584,7 @@ DEFINE_FIELD_X(SummaryInfo, SummaryInfo, maxsecrets) DEFINE_FIELD_X(SummaryInfo, SummaryInfo, supersecrets) DEFINE_FIELD_X(SummaryInfo, SummaryInfo, playercount) DEFINE_FIELD_X(SummaryInfo, SummaryInfo, time) +DEFINE_FIELD_X(SummaryInfo, SummaryInfo, totaltime) DEFINE_FIELD_X(SummaryInfo, SummaryInfo, cheated) DEFINE_FIELD_X(SummaryInfo, SummaryInfo, endofgame) diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index b856fd7d4..b8c2f7922 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -197,6 +197,7 @@ struct SummaryInfo int maxsecrets; int supersecrets; int time; + int totaltime; int playercount; bool cheated; bool endofgame; diff --git a/source/core/statistics.cpp b/source/core/statistics.cpp index 01e61f40f..2dcfb60f9 100644 --- a/source/core/statistics.cpp +++ b/source/core/statistics.cpp @@ -457,12 +457,29 @@ void STAT_Update(bool endofgame) } } +//========================================================================== +// +// +// +//========================================================================== + void STAT_Cancel() { LevelData.Clear(); StartEpisode = LevelName = ""; } +int STAT_GetTotalTime() +{ + int statval = 0; + StoreLevelStats(); + for (unsigned i = 0; i < LevelData.Size(); i++) + { + statval += LevelData[i].leveltime; + } + return statval * 1000; +} + //========================================================================== // // saves statistics info to savegames diff --git a/source/core/statistics.h b/source/core/statistics.h index 61ed2b864..21e4efd83 100644 --- a/source/core/statistics.h +++ b/source/core/statistics.h @@ -5,6 +5,7 @@ void STAT_StartNewGame(const char *episode, int skill); void STAT_NewLevel(const char* mapname); void STAT_Update(bool endofgame); void STAT_Cancel(); +int STAT_GetTotalTime(); class FSerializer; void InitStatistics(); diff --git a/source/games/blood/src/sbar.cpp b/source/games/blood/src/sbar.cpp index 1e58b0143..76117a77e 100644 --- a/source/games/blood/src/sbar.cpp +++ b/source/games/blood/src/sbar.cpp @@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "automap.h" #include "v_draw.h" #include "gamecvars.h" +#include "statistics.h" CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE/*|CVAR_FRONTEND_BLOOD*/, "enable/disable displaying the remaining seconds for power-ups") CVAR(Bool, hud_ctf_vanilla, false, CVAR_ARCHIVE) @@ -93,6 +94,7 @@ void UpdateStatusBar(PLAYER* pPlayer) sum.supersecrets = gSecretMgr.Super; sum.maxsecrets = max(gSecretMgr.Founds, gSecretMgr.Total); // If we found more than there are, increase the total. Some levels have a bugged counter. sum.time = Scale(PlayClock, 1000, 120); + sum.totaltime = STAT_GetTotalTime(); UpdateStatusBar(&sum); } diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index b6952bb2d..3534ff007 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -97,6 +97,7 @@ void DrawStatusBar() info.secrets = ps[0].secret_rooms; info.maxsecrets = ps[0].max_secret_rooms; info.time = Scale(PlayClock, 1000, 120); + info.totaltime = STAT_GetTotalTime(); UpdateStatusBar(&info); } diff --git a/source/games/exhumed/src/status.cpp b/source/games/exhumed/src/status.cpp index 5ea50c1d9..f27d1df7d 100644 --- a/source/games/exhumed/src/status.cpp +++ b/source/games/exhumed/src/status.cpp @@ -177,6 +177,8 @@ void DrawStatusBar() info.maxkills = nCreaturesTotal; // got no secrets in the game info.time = Scale(PlayClock, 1000, 120); + info.totaltime = STAT_GetTotalTime(); + UpdateStatusBar(&info); if (nSnakeCam >= 0) diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 9fbbeb66a..623aa7d9c 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -627,6 +627,7 @@ void GameInterface::LevelCompleted(MapRecord* map, int skill) info.maxsecrets = LevelSecrets; info.time = PlayClock / 120; + ShowIntermission(currentLevel, map, &info, [=](bool) { if (map == nullptr) diff --git a/source/games/sw/src/sbar.cpp b/source/games/sw/src/sbar.cpp index 2fd766bcb..d6978d1c0 100644 --- a/source/games/sw/src/sbar.cpp +++ b/source/games/sw/src/sbar.cpp @@ -89,6 +89,7 @@ void UpdateStatusBar() info.secrets = Player[screenpeek].SecretsFound; info.maxsecrets = LevelSecrets; info.time = Scale(PlayClock, 1000, 120); + info.totaltime = STAT_GetTotalTime(); ::UpdateStatusBar(&info); diff --git a/wadsrc/static/zscript/alt_hud.zs b/wadsrc/static/zscript/alt_hud.zs index 2c5229a15..de0320935 100644 --- a/wadsrc/static/zscript/alt_hud.zs +++ b/wadsrc/static/zscript/alt_hud.zs @@ -635,24 +635,26 @@ class AltHud ui String volname; if (cluster) volname = cluster.name; - let allname = levname .. volname; - font = generic_ui? NewSmallFont : StatFont.CanPrint(allname)? StatFont : OriginalSmallFont; + let allname = amstr .. volname; + let myfont = generic_ui? NewSmallFont : StatFont.CanPrint(allname)? StatFont : OriginalSmallFont; + int bottom = hudheight - 1; + int fonth = myfont.GetHeight() + 1; + double fontscale = generic_ui? 1. : currentStats.info.fontscale; -/* if (am_showtotaltime) { - DrawTimeString(font, hudcolor_ttim, curentstats.totaltime / 1000, hudwidth-2, bottom, 1, currentStats.info.fontscale); + let seconds = summary.totaltime / 1000; + DrawTimeString(myfont, hudcolor_ttim, seconds, hudwidth-2, bottom, 1, fontscale); bottom -= fonth; } -*/ if (am_showtime) { let seconds = summary.time / 1000; - DrawTimeString(font, hudcolor_ltim, seconds, hudwidth-2, bottom, 1, fontscale); + DrawTimeString(myfont, hudcolor_ltim, seconds, hudwidth-2, bottom, 1, fontscale); } - screen.DrawText(font, Font.CR_BRICK, 2, hudheight - fonth - 1, amstr, + screen.DrawText(myfont, Font.CR_BRICK, 2, hudheight - fonth - 1, amstr, DTA_KeepRatio, true, DTA_ScaleX, fontscale, DTA_ScaleY, fontscale, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index e3bb0754b..29fb01954 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -130,7 +130,8 @@ struct SummaryInfo native native readonly int secrets; native readonly int maxsecrets; native readonly int supersecrets; - native readonly int time; + native readonly int time; + native readonly int totaltime; native readonly int playercount; native readonly bool cheated; native readonly bool endofgame;