From 5801d677061581dc5fc00ed748cdf59a104fa7af Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Sun, 20 Feb 2022 15:23:08 +0100 Subject: [PATCH] Add profile # and player name on the card --- src/hu_stuff.c | 3 +++ src/hu_stuff.h | 1 + src/k_menudraw.c | 8 ++++++++ src/k_profiles.c | 12 ++++++++++++ src/k_profiles.h | 4 +++- src/v_video.c | 17 +++++++++++++++++ src/v_video.h | 2 ++ 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 45b5c079c..d41c6028f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -290,6 +290,9 @@ void HU_Init(void) PR ("PINGN"); REG; + PR ("PRFN"); + REG; + DIG (3); ADIM (KART); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 0704185f3..db1de2447 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -66,6 +66,7 @@ enum X (TALLNUM), X (NIGHTSNUM), X (PINGNUM), + X (PROFNUM), X (KART), X (GM), diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 6c01c5be2..4c0f60ddf 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1121,6 +1121,14 @@ static void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p) // Card bottom to overlay the skin preview V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT, 0, cardbot, colormap); + + // Profile number & player name + + if (p != NULL) + { + V_DrawProfileNum(x + 37 + 10, y + 131, 0, PR_GetProfileNum(p)); + V_DrawCenteredThinString(x, y + 151, V_GRAYMAP|V_6WIDTHSPACE, p->playername); + } } void M_DrawCharacterSelect(void) diff --git a/src/k_profiles.c b/src/k_profiles.c index 158d21e78..ef8382036 100644 --- a/src/k_profiles.c +++ b/src/k_profiles.c @@ -154,3 +154,15 @@ void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum) // set controls... memcpy(&gamecontrol[playernum], p->controls, sizeof(gamecontroldefault)); } + +UINT8 PR_GetProfileNum(profile_t *p) +{ + UINT8 i; + for (i = 0; i < MAXPROFILES+1; i++) + { + profile_t *comp = PR_GetProfile(i); + if (comp == p) + return i; + } + return 0; +} \ No newline at end of file diff --git a/src/k_profiles.h b/src/k_profiles.h index 4cd0a5f1d..33c4575d8 100644 --- a/src/k_profiles.h +++ b/src/k_profiles.h @@ -108,6 +108,8 @@ void PR_LoadProfiles(void); // Applies the given profile's settings to the given player. void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum); - +// PR_GetProfileNum(profile_t *p) +// Gets the profile's index # in profilesList +UINT8 PR_GetProfileNum(profile_t *p); #endif diff --git a/src/v_video.c b/src/v_video.c index 832a945b6..2b5371a25 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2650,6 +2650,23 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) } while (--digits); } +void V_DrawProfileNum(INT32 x, INT32 y, INT32 flags, UINT8 num) +{ + UINT8 digits = 3; + INT32 w = fontv[PROFNUM_FONT].font[0]->width; + + if (flags & V_NOSCALESTART) + w *= vid.dupx; + + // draw the number + do + { + x -= (w-1); + V_DrawScaledPatch(x, y, flags, fontv[PROFNUM_FONT].font[num % 10]); + num /= 10; + } while (--digits); +} + // Draws a number using the PING font thingy. // TODO: Merge number drawing functions into one with "font name" selection. diff --git a/src/v_video.h b/src/v_video.h index 7319a58b0..a0d19c625 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -316,6 +316,8 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) // 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); +void V_DrawProfileNum(INT32 x, INT32 y, INT32 flags, UINT8 num); + #define V_DrawCreditString( x,y,option,string ) \ V__DrawOneScaleString (x,y,FRACUNIT,option,NULL,CRED_FONT,string)