From f66343134b4fb0de0cf236360358c2c3accd62e2 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Wed, 3 Sep 2025 11:59:24 -0400 Subject: [PATCH] Add back old tabrankings as toggle and other stuff --- src/d_clisrv.h | 4 +- src/hu_stuff.c | 13 ++++-- src/k_hud.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++-- src/k_hud.h | 3 ++ 4 files changed, 135 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 2c9d55af2..2a0ae8c7c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -45,7 +45,7 @@ applications may follow different packet versions. #define MAXSERVERCONTACT 320 #define MAXSERVERDESCRIPTION 320 #define MAXSERVERDESCRIPTIONLINE 40 -#define DEFAULTDESCSTRING "Welcome to my SRB2Kart server!" +#define DEFAULTDESCSTRING "Welcome to my SRB2Kart server!\n" #define MAXSERVERMODS 255 #define MAXSERVERMODNAME 13 @@ -54,7 +54,7 @@ struct servermods_t { char modname[MAXSERVERMODNAME]; consvar_t *cvar; - SINT8 active; // -1 is N/A, 0 is off, 1 is on. + SINT8 active; // -1 is N/A (example:if using cvar activation), 0 is off, 1 is on. boolean valid; }; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7f9819e5a..2d308f4d2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2616,10 +2616,15 @@ static void HU_DrawRankings(void) #endif } - INT32 xoffset = K_DrawNeoTabRankings(0, 33, tab, scorelines, whiteplayer, hilicol, true); - - K_DrawServerDescrption(xoffset+10, 33); - //V_DrawThinString(xoffset+10, 33, V_SNAPTORIGHT|V_6WIDTHSPACE|V_ALLOWLOWERCASE, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + if (cv_newtabranking.value) + { + INT32 xoffset = K_DrawNeoTabRankings(0, 33, tab, scorelines, whiteplayer, hilicol, true); + K_DrawServerDescrption(xoffset+10, 33); + } + else + { + K_DrawTabRankings(((scorelines > 8) ? 32 : 40), 33, tab, scorelines, whiteplayer, hilicol); + } // draw spectators in a ticker across the bottom if (netgame && G_GametypeHasSpectators()) diff --git a/src/k_hud.c b/src/k_hud.c index b683106dc..002a36789 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -100,6 +100,8 @@ consvar_t cv_driftgaugeoffset = CVAR_INIT ("kartdriftgaugeoffset", "-10", CV_SAV static CV_PossibleValue_t HudColor_cons_t[MAXSKINCOLORS+1]; consvar_t cv_colorizedhudcolor = CVAR_INIT ("colorizedhudcolor", "Skin Color", CV_SAVE, HudColor_cons_t, NULL); +consvar_t cv_newtabranking = CVAR_INIT ("newtabranking", "On", CV_SAVE, CV_OnOff, NULL); + //{ Patch Definitions static patch_t *kp_nodraw; @@ -254,6 +256,7 @@ void K_RegisterKartHUDStuff(void) CV_RegisterVar(&cv_smoothposition); CV_RegisterVar(&cv_driftgauge); CV_RegisterVar(&cv_driftgaugeoffset); + CV_RegisterVar(&cv_newtabranking); } void K_LoadKartHUDGraphics(void) @@ -2227,8 +2230,6 @@ void K_DrawServerMods(INT32 x, INT32 y) {"Alt. Invin.", NULL, K_GetKartInvinType() == KARTINVIN_ALTERN, true} }; - V_DrawThinString(x, y, V_6WIDTHSPACE|V_ALLOWLOWERCASE|V_GRAYMAP, "Gameplay / Balance Changes:"); - for (j = 0; j < 2; j++) { UINT8 modcount = j == 0 ? BASEMODS : numcustomservermods; @@ -2268,20 +2269,137 @@ void K_DrawServerMods(INT32 x, INT32 y) } } } + + if (numdrawn > 0) + V_DrawThinString(x, y, V_6WIDTHSPACE|V_ALLOWLOWERCASE|V_GRAYMAP, "Gameplay / Balance Changes:"); + } #undef BASEMODS void K_DrawServerDescrption(INT32 x, INT32 y) { + UINT8 i, newlinecount = 0; if (connectedservername[0] != '\0') V_DrawThinString(x, y, V_6WIDTHSPACE|V_ALLOWLOWERCASE, connectedservername); V_DrawSmallString(x, y+10, V_6WIDTHSPACE|V_ALLOWLOWERCASE|V_GRAYMAP, va("Contact: %s", (connectedservercontact[0] != '\0') ? connectedservercontact : "")); if (connectedserverdescription[0] != '\0') + { V_DrawSmallString(x, y+20, V_6WIDTHSPACE|V_ALLOWLOWERCASE, connectedserverdescription); - K_DrawServerMods(x, y + 50); + for (i = 0; connectedserverdescription[i]; i++) + newlinecount += (connectedserverdescription[i] == '\n'); + } + + K_DrawServerMods(x, y + 25 + newlinecount*6); +} + +// The old school one.... +void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol) +{ + INT32 i, rightoffset = 240; + UINT8 *colormap = NULL; + UINT16 hightlightcolor = 0; + INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + int basey = y, basex = x, y2; + + V_DrawFill(1-duptweak, 26, dupadjust-2, 1, 0); // Draw a horizontal line because it looks nice! + + scorelines--; + if (scorelines >= 8) + { + V_DrawFill(160, 26, 1, 147, 0); // Draw a vertical line to separate the two sides. + V_DrawFill(1-duptweak, 173, dupadjust-2, 1, 0); // And a horizontal line near the bottom. + rightoffset = (BASEVIDWIDTH/2) - 4 - x; + x = (BASEVIDWIDTH/2) + 4; + y += 18*(scorelines-8); + } + else + { + y += 18*scorelines; + } + + for (i = scorelines; i >= 0; i--) + { + char playername[MAXPLAYERNAME+1]; + + if (players[tab[i].num].spectator || !players[tab[i].num].mo) + continue; //ignore them. + + if (netgame) // don't draw ping offline + { + if (players[tab[i].num].bot) + { + V_DrawString(x + ((i < 8) ? -25 : rightoffset + 3), y-2, V_SNAPTOLEFT, "CPU"); + } + else if (tab[i].num != serverplayer || !server_lagless) + { + HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], playerdelaytable[tab[i].num], playerpacketlosstable[tab[i].num], 0, true); + } + else if (tab[i].num == serverplayer) + { + V_DrawString(x + ((i < 8) ? -25 : rightoffset + 3), y-2, V_SNAPTOLEFT, "SRV"); + } + } + + STRBUFCPY(playername, tab[i].name); + + y2 = y; + + if (players[tab[i].num].mo->color) + { + colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); + if (players[tab[i].num].mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, players[tab[i].num].mo->color, GTC_CACHE); + else + colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); + + hightlightcolor = skincolors[players[tab[i].num].mo->color].chatcolor; + } + + if (scorelines >= 8) + V_DrawThinString(x + 20, y2, ((tab[i].num == whiteplayer) ? hightlightcolor : 0)|V_ALLOWLOWERCASE|V_6WIDTHSPACE, playername); + else + V_DrawString(x + 20, y2, ((tab[i].num == whiteplayer) ? hightlightcolor : 0)|V_ALLOWLOWERCASE, playername); + + V_DrawMappedPatch(x, y-4, 0, faceprefix[players[tab[i].num].skin][FACE_RANK], colormap); + + /*if (gametype == GT_BATTLE && players[tab[i].num].bumper > 0) -- not enough space for this + { + INT32 bumperx = x+19; + V_DrawMappedPatch(bumperx-2, y-4, 0, kp_tinybumper[0], colormap); + for (j = 1; j < players[tab[i].num].bumper; j++) + { + bumperx += 5; + V_DrawMappedPatch(bumperx, y-4, 0, kp_tinybumper[1], colormap); + } + }*/ + + if (tab[i].num == whiteplayer) + V_DrawScaledPatch(x, y-4, 0, kp_facehighlight[(leveltime / 4) % 8]); + + if (gametype == GT_BATTLE && players[tab[i].num].bumper <= 0) + V_DrawScaledPatch(x-4, y-7, 0, kp_ranknobumpers); + else + { + INT32 pos = players[tab[i].num].position; + if (pos < 0 || pos > MAXPLAYERS) + pos = 0; + // Draws the little number over the face + V_DrawScaledPatch(x-5, y+6, 0, kp_facenum[pos]); + } + + if (tab[i].string[0] != '\0') + V_DrawRightAlignedThinString(x+rightoffset, y-1, V_6WIDTHSPACE, tab[i].string); + + y -= 18; + if (i == 8) + { + y = basey + 7*18; + x = basex; + } + } } static void K_drawKartLaps(void) diff --git a/src/k_hud.h b/src/k_hud.h index 5398ddd39..7052614d4 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -62,6 +62,8 @@ extern consvar_t cv_colorizeditembox; extern consvar_t cv_darkitembox; extern consvar_t cv_colorizedhudcolor; +extern consvar_t cv_newtabranking; + struct trackingResult_t { fixed_t x, y; @@ -98,6 +100,7 @@ void K_drawKartHUD(void); void K_drawKartFreePlay(void); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode); INT32 K_DrawNeoTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol, boolean split); +void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); void K_DrawServerDescrption(INT32 x, INT32 y);