mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-29 12:40:40 +00:00
New visuals for ping and fps display alike [REDO]
This commit is contained in:
parent
3349b9b196
commit
07e56e550e
8 changed files with 107 additions and 42 deletions
|
@ -932,7 +932,7 @@ static void IdentifyVersion(void)
|
|||
D_AddFile(va(pandf,srb2waddir,"chars.kart"));
|
||||
D_AddFile(va(pandf,srb2waddir,"maps.kart"));
|
||||
#ifdef USE_PATCH_KART
|
||||
D_AddFile(va(pandf,srb2waddir,"patch.kart"));
|
||||
D_AddFile(va(pandf,srb2waddir,"patchping.kart")); // also don't forget to change that, this is to avoid conflicting with our regular patch.kart
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
|
||||
|
|
|
@ -74,6 +74,14 @@ patch_t *nightsnum[10]; // 0-9
|
|||
patch_t *lt_font[LT_FONTSIZE];
|
||||
patch_t *cred_font[CRED_FONTSIZE];
|
||||
|
||||
// ping font
|
||||
// Note: I'd like to adress that at this point we might *REALLY* want to work towards a common drawString function that can take any font we want because this is really turning into a MESS. :V -Lat'
|
||||
patch_t *pingnum[10];
|
||||
patch_t *pinggfx[5]; // small ping graphic
|
||||
|
||||
patch_t *framecounter;
|
||||
patch_t *frameslash; // framerate stuff. Used in screen.c
|
||||
|
||||
static player_t *plr;
|
||||
boolean chat_on; // entering a chat message?
|
||||
static char w_chat[HU_MAXMSGLEN];
|
||||
|
@ -263,6 +271,8 @@ void HU_LoadGraphics(void)
|
|||
tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
|
||||
sprintf(buffer, "NGTNUM%d", i);
|
||||
nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX);
|
||||
sprintf(buffer, "PINGN%d", i);
|
||||
pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX);
|
||||
}
|
||||
|
||||
// minus for negative tallnums
|
||||
|
@ -295,6 +305,17 @@ void HU_LoadGraphics(void)
|
|||
tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX);
|
||||
|
||||
songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX);
|
||||
|
||||
// cache ping gfx:
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
sprintf(buffer, "PINGGFX%d", i+1);
|
||||
pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
|
||||
}
|
||||
|
||||
// fps stuff
|
||||
framecounter = W_CachePatchName("FRAMER", PU_HUDGFX);
|
||||
frameslash = W_CachePatchName("FRAMESL", PU_HUDGFX);;
|
||||
}
|
||||
|
||||
// Initialise Heads up
|
||||
|
@ -2183,14 +2204,14 @@ static void HU_DrawSongCredits(void)
|
|||
|
||||
void HU_drawLocalPing(void)
|
||||
{
|
||||
if (!cv_showping.value || !netgame || consoleplayer == serverplayer) // we don't want to see it or aren't in a netgame, or are the server
|
||||
if (!cv_showping.value || !netgame || consoleplayer != serverplayer) // we don't want to see it or aren't in a netgame, or are the server
|
||||
return;
|
||||
|
||||
INT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P
|
||||
if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level
|
||||
{
|
||||
INT32 dispx = cv_ticrate.value ? 260 : 290;
|
||||
HU_drawPing(dispx, 190, ping, false);
|
||||
INT32 dispy = cv_ticrate.value ? 160 : 181;
|
||||
HU_drawPing(307, dispy, ping, V_SNAPTORIGHT|V_SNAPTOBOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2388,41 +2409,25 @@ void HU_Erase(void)
|
|||
//
|
||||
// HU_drawPing
|
||||
//
|
||||
void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext)
|
||||
void HU_drawPing(INT32 x, INT32 y, INT32 ping, INT32 flags)
|
||||
{
|
||||
UINT8 numbars = 1; // how many ping bars do we draw?
|
||||
UINT8 barcolor = 128; // color we use for the bars (green, yellow or red)
|
||||
SINT8 i = 0;
|
||||
SINT8 yoffset = 6;
|
||||
INT32 dx = x+1 - (V_SmallStringWidth(va("%dms", ping), V_ALLOWLOWERCASE)/2);
|
||||
boolean highping = (servermaxping && ping > servermaxping) ? true : false;
|
||||
INT32 gfxnum = 4; // gfx to draw
|
||||
UINT8 const *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SALMON, GTC_CACHE);
|
||||
|
||||
if (ping < 128)
|
||||
{
|
||||
numbars = 3;
|
||||
barcolor = 184;
|
||||
}
|
||||
if (ping < 76)
|
||||
gfxnum = 0;
|
||||
else if (ping < 137)
|
||||
gfxnum = 1;
|
||||
else if (ping < 256)
|
||||
{
|
||||
numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it.
|
||||
barcolor = 103;
|
||||
}
|
||||
else if (highping) // yikes...!
|
||||
{
|
||||
numbars = 0;
|
||||
}
|
||||
gfxnum = 2;
|
||||
else if (ping < 500)
|
||||
gfxnum = 3;
|
||||
|
||||
if (!notext || vid.width >= 640) // how sad, we're using a shit resolution.
|
||||
V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|((highping && hu_tick < 4) ? V_REDMAP : 0), va("%dms", ping));
|
||||
|
||||
for (i=0; (i<3); i++) // Draw the ping bar
|
||||
{
|
||||
V_DrawFill(x+2 *(i-1), y+yoffset-4, 2, 8-yoffset, (highping && hu_tick < 4) ? 128 : 31);
|
||||
if (i < numbars)
|
||||
V_DrawFill(x+2 *(i-1), y+yoffset-3, 1, 8-yoffset-1, barcolor);
|
||||
|
||||
yoffset -= 2;
|
||||
}
|
||||
V_DrawScaledPatch(x, y, flags, pinggfx[gfxnum]);
|
||||
if (servermaxping && ping > servermaxping && hu_tick < 4) // flash ping red if too high
|
||||
V_DrawPingNum(x, y+9, flags, ping, colormap);
|
||||
else
|
||||
V_DrawPingNum(x, y+9, flags, ping, NULL);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -80,7 +80,11 @@ extern boolean chat_on;
|
|||
|
||||
extern patch_t *hu_font[HU_FONTSIZE], *kart_font[KART_FONTSIZE], *tny_font[HU_FONTSIZE]; // SRB2kart
|
||||
extern patch_t *tallnum[10];
|
||||
extern patch_t *pingnum[10];
|
||||
extern patch_t *pinggfx[5];
|
||||
extern patch_t *nightsnum[10];
|
||||
extern patch_t *framecounter;
|
||||
extern patch_t *frameslash;
|
||||
extern patch_t *lt_font[LT_FONTSIZE];
|
||||
extern patch_t *cred_font[CRED_FONTSIZE];
|
||||
extern patch_t *emeraldpics[7];
|
||||
|
@ -109,7 +113,7 @@ void HU_Drawer(void);
|
|||
char HU_dequeueChatChar(void);
|
||||
void HU_Erase(void);
|
||||
void HU_clearChatChars(void);
|
||||
void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext); // Lat': Ping drawer for scoreboard.
|
||||
void HU_drawPing(INT32 x, INT32 y, INT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard.
|
||||
//void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer);
|
||||
//void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer);
|
||||
void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol);
|
||||
|
|
|
@ -4682,6 +4682,7 @@ static void K_KartDrift(player_t *player, boolean onground)
|
|||
player->kartstuff[k_driftend] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Incease/decrease the drift value to continue drifting in that direction
|
||||
if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0)
|
||||
{
|
||||
|
@ -7168,7 +7169,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
|
|||
|
||||
if (netgame // don't draw it offline
|
||||
&& tab[i].num != serverplayer)
|
||||
HU_drawPing(x + ((i < 8) ? -19 : rightoffset + 13), y+2, playerpingtable[tab[i].num], false);
|
||||
HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0);
|
||||
|
||||
STRBUFCPY(strtime, tab[i].name);
|
||||
|
||||
|
|
|
@ -410,6 +410,24 @@ static int libd_drawPaddedNum(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int libd_drawPingNum(lua_State *L)
|
||||
{
|
||||
INT32 x, y, flags, num;
|
||||
const UINT8 *colormap = NULL;
|
||||
HUDONLY
|
||||
x = luaL_checkinteger(L, 1);
|
||||
y = luaL_checkinteger(L, 2);
|
||||
num = luaL_checkinteger(L, 3);
|
||||
flags = luaL_optinteger(L, 4, 0);
|
||||
flags &= ~V_PARAMMASK; // Don't let crashes happen.
|
||||
if (!lua_isnoneornil(L, 5))
|
||||
colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP));
|
||||
|
||||
V_DrawPingNum(x, y, flags, num, colormap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int libd_drawFill(lua_State *L)
|
||||
{
|
||||
INT32 x = luaL_optinteger(L, 1, 0);
|
||||
|
@ -613,6 +631,7 @@ static luaL_Reg lib_draw[] = {
|
|||
{"drawScaled", libd_drawScaled},
|
||||
{"drawNum", libd_drawNum},
|
||||
{"drawPaddedNum", libd_drawPaddedNum},
|
||||
{"drawPingNum", libd_drawPingNum},
|
||||
{"drawFill", libd_drawFill},
|
||||
{"fadeScreen", libd_fadeScreen},
|
||||
{"drawString", libd_drawString},
|
||||
|
|
20
src/screen.c
20
src/screen.c
|
@ -403,7 +403,7 @@ void SCR_DisplayTicRate(void)
|
|||
tic_t i;
|
||||
tic_t ontic = I_GetTime();
|
||||
tic_t totaltics = 0;
|
||||
INT32 ticcntcolor = 0;
|
||||
const UINT8 *ticcntcolor = NULL;
|
||||
|
||||
for (i = lasttic + 1; i < TICRATE+lasttic && i < ontic; ++i)
|
||||
fpsgraph[i % TICRATE] = false;
|
||||
|
@ -414,13 +414,23 @@ void SCR_DisplayTicRate(void)
|
|||
if (fpsgraph[i])
|
||||
++totaltics;
|
||||
|
||||
if (totaltics <= TICRATE/2) ticcntcolor = V_REDMAP;
|
||||
else if (totaltics == TICRATE) ticcntcolor = V_GREENMAP;
|
||||
if (totaltics <= TICRATE/2) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SALMON, GTC_CACHE);
|
||||
else if (totaltics == TICRATE) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE);
|
||||
|
||||
V_DrawString(vid.width-(24*vid.dupx), vid.height-(16*vid.dupy),
|
||||
/*V_DrawString(vid.width-(24*vid.dupx), vid.height-(16*vid.dupy),
|
||||
V_YELLOWMAP|V_NOSCALESTART, "FPS");
|
||||
V_DrawString(vid.width-(40*vid.dupx), vid.height-( 8*vid.dupy),
|
||||
ticcntcolor|V_NOSCALESTART, va("%02d/%02u", totaltics, TICRATE));
|
||||
ticcntcolor|V_NOSCALESTART, va("%02d/%02u", totaltics, TICRATE));*/
|
||||
|
||||
// draw "FPS"
|
||||
V_DrawFixedPatch(306<<FRACBITS, 183<<FRACBITS, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTORIGHT, framecounter, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_YELLOW, GTC_CACHE));
|
||||
// draw total frame:
|
||||
V_DrawPingNum(318, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT, TICRATE, ticcntcolor);
|
||||
// draw "/"
|
||||
V_DrawFixedPatch(306<<FRACBITS, 190<<FRACBITS, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTORIGHT, frameslash, ticcntcolor);
|
||||
// draw our actual framerate
|
||||
V_DrawPingNum(306, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT, totaltics, ticcntcolor);
|
||||
|
||||
|
||||
lasttic = ontic;
|
||||
}
|
||||
|
|
|
@ -2015,6 +2015,28 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits)
|
|||
} while (--digits);
|
||||
}
|
||||
|
||||
// Draws a number using the PING font thingy.
|
||||
// TODO: Merge number drawing functions into one with "font name" selection.
|
||||
|
||||
void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colormap)
|
||||
{
|
||||
INT32 w = SHORT(pingnum[0]->width); // this SHOULD always be 5 but I guess custom graphics exist.
|
||||
|
||||
if (flags & V_NOSCALESTART)
|
||||
w *= vid.dupx;
|
||||
|
||||
if (num < 0)
|
||||
num = -num;
|
||||
|
||||
// draw the number
|
||||
do
|
||||
{
|
||||
x -= (w-1); // Oni wanted their outline to intersect.
|
||||
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, flags, pingnum[num%10], colormap);
|
||||
num /= 10;
|
||||
} while (num);
|
||||
}
|
||||
|
||||
// Write a string using the credit font
|
||||
// NOTE: the text is centered for screens larger than the base width
|
||||
//
|
||||
|
|
|
@ -190,6 +190,10 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
|
|||
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);
|
||||
void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits);
|
||||
|
||||
// Draw ping numbers. Used by the scoreboard and that one ping option. :P
|
||||
// This is a separate function because IMO lua should have access to it as well.
|
||||
void V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *colormap);
|
||||
|
||||
// Find string width from lt_font chars
|
||||
INT32 V_LevelNameWidth(const char *string);
|
||||
INT32 V_LevelNameHeight(const char *string);
|
||||
|
|
Loading…
Reference in a new issue