diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index b8416dd5d..764e427d3 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -57,6 +57,9 @@ class AWeapon; void ST_SetNeedRefresh(); +bool ST_IsTimeVisible(); +bool ST_IsLatencyVisible(); + // HUD Message base object -------------------------------------------------- class DHUDMessage : public DObject diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 0fe8a4588..344f5b0ec 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -59,6 +59,7 @@ EXTERN_CVAR(Bool,am_follow) EXTERN_CVAR (Int, con_scaletext) EXTERN_CVAR (Bool, idmypos) +EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, am_showtime) EXTERN_CVAR (Bool, am_showtotaltime) @@ -868,7 +869,7 @@ static void DrawCoordinates(player_t * CPlayer) static void DrawTime() { - if (hud_showtime <= 0 || hud_showtime > 9) + if (!ST_IsTimeVisible()) { return; } @@ -935,6 +936,21 @@ static void DrawTime() DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, height, FRACUNIT); } +static bool IsAltHUDTextVisible() +{ + return hud_althud + && !automapactive + && (SCREENHEIGHT == viewheight) + && (11 == screenblocks); +} + +bool ST_IsTimeVisible() +{ + return IsAltHUDTextVisible() + && (hud_showtime > 0) + && (hud_showtime <= 9); +} + //--------------------------------------------------------------------------- // // Draw in-game latency @@ -943,9 +959,7 @@ static void DrawTime() static void DrawLatency() { - if (hud_showlag <= 0 || - (hud_showlag == 1 && !netgame) || - hud_showlag > 2) + if (!ST_IsLatencyVisible()) { return; } @@ -975,11 +989,19 @@ static void DrawLatency() const int characterCount = (int)strlen(tempstr); const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border - const int height = SmallFont->GetHeight() * 2; + const int height = SmallFont->GetHeight() * (ST_IsTimeVisible() ? 2 : 1); DrawHudText(SmallFont, color, tempstr, hudwidth - width, height, FRACUNIT); } +bool ST_IsLatencyVisible() +{ + return IsAltHUDTextVisible() + && (hud_showlag > 0) + && (hud_showlag != 1 || netgame) + && (hud_showlag <= 2); +} + //--------------------------------------------------------------------------- //