- added episode and total episode time display to alt HUD

This commit is contained in:
Christoph Oelckers 2022-10-25 17:09:45 +02:00
parent fa3a8ca0d7
commit 32b2e84fdc
11 changed files with 38 additions and 8 deletions

View file

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

View file

@ -197,6 +197,7 @@ struct SummaryInfo
int maxsecrets;
int supersecrets;
int time;
int totaltime;
int playercount;
bool cheated;
bool endofgame;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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