Adjust latency position depending on time visibility

Latency placement is no longer fixed:
* If time is visible, it is placed on top of the screen and latency is placed below
* If time is not visible, latency is placed on top of the screen
Both are displayed on alternative HUD only
This commit is contained in:
alexey.lysiuk 2016-02-03 11:24:49 +02:00
parent 66f053f131
commit 1bf1fc199b
2 changed files with 30 additions and 5 deletions

View file

@ -57,6 +57,9 @@ class AWeapon;
void ST_SetNeedRefresh(); void ST_SetNeedRefresh();
bool ST_IsTimeVisible();
bool ST_IsLatencyVisible();
// HUD Message base object -------------------------------------------------- // HUD Message base object --------------------------------------------------
class DHUDMessage : public DObject class DHUDMessage : public DObject

View file

@ -59,6 +59,7 @@
EXTERN_CVAR(Bool,am_follow) EXTERN_CVAR(Bool,am_follow)
EXTERN_CVAR (Int, con_scaletext) EXTERN_CVAR (Int, con_scaletext)
EXTERN_CVAR (Bool, idmypos) EXTERN_CVAR (Bool, idmypos)
EXTERN_CVAR (Int, screenblocks)
EXTERN_CVAR (Bool, am_showtime) EXTERN_CVAR (Bool, am_showtime)
EXTERN_CVAR (Bool, am_showtotaltime) EXTERN_CVAR (Bool, am_showtotaltime)
@ -868,7 +869,7 @@ static void DrawCoordinates(player_t * CPlayer)
static void DrawTime() static void DrawTime()
{ {
if (hud_showtime <= 0 || hud_showtime > 9) if (!ST_IsTimeVisible())
{ {
return; return;
} }
@ -935,6 +936,21 @@ static void DrawTime()
DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, height, FRACUNIT); 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 // Draw in-game latency
@ -943,9 +959,7 @@ static void DrawTime()
static void DrawLatency() static void DrawLatency()
{ {
if (hud_showlag <= 0 || if (!ST_IsLatencyVisible())
(hud_showlag == 1 && !netgame) ||
hud_showlag > 2)
{ {
return; return;
} }
@ -975,11 +989,19 @@ static void DrawLatency()
const int characterCount = (int)strlen(tempstr); const int characterCount = (int)strlen(tempstr);
const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border 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); DrawHudText(SmallFont, color, tempstr, hudwidth - width, height, FRACUNIT);
} }
bool ST_IsLatencyVisible()
{
return IsAltHUDTextVisible()
&& (hud_showlag > 0)
&& (hud_showlag != 1 || netgame)
&& (hud_showlag <= 2);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //