mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
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:
parent
66f053f131
commit
1bf1fc199b
2 changed files with 30 additions and 5 deletions
|
@ -57,6 +57,9 @@ class AWeapon;
|
|||
|
||||
void ST_SetNeedRefresh();
|
||||
|
||||
bool ST_IsTimeVisible();
|
||||
bool ST_IsLatencyVisible();
|
||||
|
||||
// HUD Message base object --------------------------------------------------
|
||||
|
||||
class DHUDMessage : public DObject
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue