diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e59a362b8..0afd4efa3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6207,6 +6207,7 @@ static void FollowerAny_OnChange(UINT8 pnum) return; // don't send anything there. SendNameAndColor(pnum); + G_SetPlayerGamepadIndicatorToPlayerColor(pnum); } // sends the follower change for players @@ -6358,6 +6359,8 @@ static void Color_OnChange(void) } } lastgoodcolor[0] = cv_playercolor[0].value; + + G_SetPlayerGamepadIndicatorToPlayerColor(0); } /** Sends a color change for the secondary splitscreen player, unless that @@ -6386,6 +6389,8 @@ static void Color2_OnChange(void) } } lastgoodcolor[1] = cv_playercolor[1].value; + + G_SetPlayerGamepadIndicatorToPlayerColor(1); } static void Color3_OnChange(void) @@ -6409,6 +6414,8 @@ static void Color3_OnChange(void) } } lastgoodcolor[2] = cv_playercolor[2].value; + + G_SetPlayerGamepadIndicatorToPlayerColor(2); } static void Color4_OnChange(void) @@ -6432,6 +6439,8 @@ static void Color4_OnChange(void) } } lastgoodcolor[3] = cv_playercolor[3].value; + + G_SetPlayerGamepadIndicatorToPlayerColor(3); } /** Displays the result of the chat being muted or unmuted. diff --git a/src/g_input.c b/src/g_input.c index 7d9d09c35..df87ae4f9 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -19,6 +19,8 @@ #include "d_net.h" #include "console.h" #include "i_joy.h" // JOYAXISRANGE +#include "r_draw.h" // GTC_ macros for assigning gamepad indicator colors +#include "v_video.h" // V_GetColor for assigning gamepad indictaor colors #include "z_zone.h" #define MAXMOUSESENSITIVITY 100 // sensitivity steps @@ -210,6 +212,37 @@ void G_SetDeviceForPlayer(INT32 player, INT32 device) } } +void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player) +{ + INT32 device; + INT32 skin; + UINT16 skincolor; + UINT8 *colormap; + byteColor_t byte_color; + + I_Assert(player >= 0 && player < MAXSPLITSCREENPLAYERS); + + device = G_GetDeviceForPlayer(player); + + if (device <= 0) + { + return; + } + + skin = cv_skin[player].value; + skincolor = cv_playercolor[player].value; + colormap = R_GetTranslationColormap(skin, skincolor, GTC_MENUCACHE); + + if (colormap == NULL) + { + return; + } + + byte_color = V_GetColor(colormap[104]).s; + + I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); +} + INT32* G_GetDeviceGameKeyDownArray(INT32 device) { int i; diff --git a/src/g_input.h b/src/g_input.h index 30ed3be27..55b22b0a1 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -154,6 +154,8 @@ INT32 G_GetDeviceForPlayer(INT32 player); /// Set the given player index's assigned device. If the device is in use by another player, that player is unassigned. void G_SetDeviceForPlayer(INT32 player, INT32 device); +void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player); + /// Get the gamekeydown array (NUMINPUTS values) for the given device, or NULL if the device id is invalid. INT32* G_GetDeviceGameKeyDownArray(INT32 device); diff --git a/src/menus/play-char-select.c b/src/menus/play-char-select.c index 693938528..b2b869dbe 100644 --- a/src/menus/play-char-select.c +++ b/src/menus/play-char-select.c @@ -1488,6 +1488,8 @@ void M_CharacterSelectTick(void) else CV_StealthSet(&cv_follower[i], followers[setup_player[i].followern].name); CV_StealthSetValue(&cv_followercolor[i], setup_player[i].followercolor); + + G_SetPlayerGamepadIndicatorToPlayerColor(i); } CV_StealthSetValue(&cv_splitplayers, setup_numplayers);