Ping for Y_PlayerStandingsDrawer

TODO: CPU indicator
This commit is contained in:
toaster 2023-05-11 21:39:06 +01:00
parent 36d8bce14d
commit c1eb01c03d
4 changed files with 68 additions and 11 deletions

View file

@ -2343,12 +2343,13 @@ Ping_gfx_color (int lag)
//
// HU_drawPing
//
void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, INT32 flags, boolean offline)
void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, INT32 flags, boolean offline, SINT8 toside)
{
UINT8 *colormap = NULL;
INT32 measureid = cv_pingmeasurement.value ? 1 : 0;
INT32 gfxnum; // gfx to draw
boolean drawlocal = (offline && cv_mindelay.value && lag <= (tic_t)cv_mindelay.value);
fixed_t x2, y2;
if (!server && lag <= (tic_t)cv_mindelay.value)
{
@ -2356,13 +2357,35 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, INT32 flags, boolean offline)
drawlocal = true;
}
x2 = x;
y2 = y + FRACUNIT;
if (toside == 0)
{
if (measureid == 1)
{
x2 += ((11 - pingmeasure[measureid]->width) * FRACUNIT);
}
else
{
x2 += (10 * FRACUNIT);
}
y2 += (8 * FRACUNIT);
}
else if (toside > 0)
{
x2 += (20 * FRACUNIT);
}
//else if (toside < 0)
gfxnum = Ping_gfx_num(lag);
if (measureid == 1)
{
V_DrawFixedPatch(
x + ((11 - pingmeasure[measureid]->width) * FRACUNIT),
y + (9 * FRACUNIT),
x2,
y2,
FRACUNIT, flags,
pingmeasure[measureid],
NULL
@ -2403,9 +2426,9 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, INT32 flags, boolean offline)
lag = (INT32)(lag * (1000.00f / TICRATE));
}
x = V_DrawPingNum(
x + (((measureid == 1) ? 11 - pingmeasure[measureid]->width : 10) * FRACUNIT),
y + (9 * FRACUNIT),
x2 = V_DrawPingNum(
x2,
y2,
flags, lag,
colormap
);
@ -2413,8 +2436,8 @@ void HU_drawPing(fixed_t x, fixed_t y, UINT32 lag, INT32 flags, boolean offline)
if (measureid == 0)
{
V_DrawFixedPatch(
x + ((1 - pingmeasure[measureid]->width) * FRACUNIT),
y + (9 * FRACUNIT),
x2 + ((1 - pingmeasure[measureid]->width) * FRACUNIT),
y2,
FRACUNIT, flags,
pingmeasure[measureid],
NULL

View file

@ -146,7 +146,7 @@ void HU_TickSongCredits(void);
char HU_dequeueChatChar(void);
void HU_Erase(void);
void HU_clearChatChars(void);
void HU_drawPing(fixed_t x, fixed_t y, UINT32 ping, INT32 flags, boolean offline); // Lat': Ping drawer for scoreboard.
void HU_drawPing(fixed_t x, fixed_t y, UINT32 ping, INT32 flags, boolean offline, SINT8 toside); // Lat': Ping drawer for scoreboard.
void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, INT32 flags);
// CECHO interface.

View file

@ -660,7 +660,7 @@ void SCR_DisplayLocalPing(void)
{
INT32 dispy = cv_ticrate.value ? 160 : 181;
offline = (consoleplayer == serverplayer);
HU_drawPing(307 * FRACUNIT, dispy * FRACUNIT, ping, V_SNAPTORIGHT | V_SNAPTOBOTTOM | V_HUDTRANS, offline);
HU_drawPing(307 * FRACUNIT, dispy * FRACUNIT, ping, V_SNAPTORIGHT | V_SNAPTOBOTTOM | V_HUDTRANS, offline, 0);
}
}

View file

@ -413,9 +413,12 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
SINT8 yspacing = 14;
INT32 heightcount = (standings->numplayers - 1);
INT32 x, y, returny;
INT32 x, y;
INT32 x2, returny;
boolean verticalresults = (standings->numplayers < 4);
boolean datarightofcolumn = false;
boolean drawping = (netgame && gamestate == GS_LEVEL);
INT32 hilicol = highlightflags;
@ -424,6 +427,11 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
if (verticalresults)
{
x = (BASEVIDWIDTH/2) - 61;
if (drawping)
{
x += 9;
}
}
else
{
@ -432,6 +440,7 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
}
x += xoffset;
x2 = x - 9;
if (standings->numplayers > 10)
{
@ -535,6 +544,28 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
standings->strval[i]
);
if (drawping)
{
if (players[pnum].bot)
{
/*V_DrawScaledPatch(
x2, y-1,
0,
kp_cpu
);*/
}
else if (pnum != serverplayer || !server_lagless)
{
HU_drawPing(
(x2 - 2) * FRACUNIT, (y-2) * FRACUNIT,
playerpingtable[pnum],
0,
false,
(datarightofcolumn ? 1 : -1)
);
}
}
// Reverse the jitter offset
if (standings->jitter[pnum] > 0)
y++;
@ -546,6 +577,9 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset)
{
x = 169 + xoffset;
y = returny;
datarightofcolumn = true;
x2 = x + 118 + 5;
}
}
}