From 04746751098dcb0ffd3249561b5eb5c672a2c283 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 17 Feb 2023 17:07:33 +0000 Subject: [PATCH] Character Select menu: Forceskin is now reflected on the menu Matches cvar updates in real time, so can't change what's written to setup_chargrid --- src/k_menudraw.c | 54 ++++++++++++++++++++++++------------ src/menus/play-char-select.c | 53 ++++++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 28 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e09bc5873..32476585a 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -50,6 +50,7 @@ #include "k_follower.h" #include "d_player.h" // KITEM_ constants #include "doomstat.h" // MAXSPLITSCREENPLAYERS +#include "k_grandprix.h" // K_CanChangeRules #include "i_joy.h" // for joystick menu controls @@ -1689,6 +1690,7 @@ void M_DrawCharacterSelect(void) INT16 quadx, quady; INT16 skin; INT32 basex = optionsmenu.profile != NULL ? 64 : 0; + boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1); if (setup_numplayers > 0) { @@ -1696,26 +1698,29 @@ void M_DrawCharacterSelect(void) } // We have to loop twice -- first time to draw the drop shadows, a second time to draw the icons. - for (i = 0; i < 9; i++) + if (forceskin == false) { - for (j = 0; j < 9; j++) + for (i = 0; i < 9; i++) { - skin = setup_chargrid[i][j].skinlist[setup_page]; - quadx = 4 * (i / 3); - quady = 4 * (j / 3); - - // Here's a quick little cheat to save on drawing time! - // Don't draw a shadow if it'll get covered by another icon - if ((i % 3 < 2) && (j % 3 < 2)) + for (j = 0; j < 9; j++) { - if ((setup_chargrid[i+1][j].skinlist[setup_page] != -1) - && (setup_chargrid[i][j+1].skinlist[setup_page] != -1) - && (setup_chargrid[i+1][j+1].skinlist[setup_page] != -1)) - continue; - } + skin = setup_chargrid[i][j].skinlist[setup_page]; + quadx = 4 * (i / 3); + quady = 4 * (j / 3); - if (skin != -1) - V_DrawScaledPatch(basex+ 82 + (i*16) + quadx + 1, 22 + (j*16) + quady + 1, 0, W_CachePatchName("ICONBACK", PU_CACHE)); + // Here's a quick little cheat to save on drawing time! + // Don't draw a shadow if it'll get covered by another icon + if ((i % 3 < 2) && (j % 3 < 2)) + { + if ((setup_chargrid[i+1][j].skinlist[setup_page] != -1) + && (setup_chargrid[i][j+1].skinlist[setup_page] != -1) + && (setup_chargrid[i+1][j+1].skinlist[setup_page] != -1)) + continue; + } + + if (skin != -1) + V_DrawScaledPatch(basex+ 82 + (i*16) + quadx + 1, 22 + (j*16) + quady + 1, 0, W_CachePatchName("ICONBACK", PU_CACHE)); + } } } @@ -1725,8 +1730,22 @@ void M_DrawCharacterSelect(void) // Draw the icons now for (i = 0; i < 9; i++) { + if ((forceskin == true) && (i != skins[cv_forceskin.value].kartspeed-1)) + continue; + for (j = 0; j < 9; j++) { + if (forceskin == true) + { + if (j != skins[cv_forceskin.value].kartweight-1) + continue; + skin = cv_forceskin.value; + } + else + { + skin = setup_chargrid[i][j].skinlist[setup_page]; + } + for (k = 0; k < setup_numplayers; k++) { if (setup_player[k].mdepth < CSSTEP_ASKCHANGES) @@ -1736,7 +1755,6 @@ void M_DrawCharacterSelect(void) break; // k == setup_numplayers means no one has it selected } - skin = setup_chargrid[i][j].skinlist[setup_page]; quadx = 4 * (i / 3); quady = 4 * (j / 3); @@ -1752,7 +1770,7 @@ void M_DrawCharacterSelect(void) V_DrawMappedPatch(basex + 82 + (i*16) + quadx, 22 + (j*16) + quady, 0, faceprefix[skin][FACE_RANK], colormap); // draw dot if there are more alts behind there! - if (setup_page+1 < setup_chargrid[i][j].numskins) + if (forceskin == false && setup_page+1 < setup_chargrid[i][j].numskins) V_DrawScaledPatch(basex + 82 + (i*16) + quadx, 22 + (j*16) + quady + 11, 0, W_CachePatchName("ALTSDOT", PU_CACHE)); } } diff --git a/src/menus/play-char-select.c b/src/menus/play-char-select.c index 0fd67dc45..50da1bfde 100644 --- a/src/menus/play-char-select.c +++ b/src/menus/play-char-select.c @@ -4,6 +4,7 @@ #include "../k_menu.h" #include "../r_skins.h" #include "../s_sound.h" +#include "../k_grandprix.h" // K_CanChangeRules menuitem_t PLAY_CharSelect[] = { @@ -789,6 +790,7 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num) { UINT8 numclones; INT32 skin; + boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1); if (cv_splitdevice.value) num = 0; @@ -848,19 +850,35 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num) if (M_MenuConfirmPressed(num) /*|| M_MenuButtonPressed(num, MBT_START)*/) { - skin = setup_chargrid[p->gridx][p->gridy].skinlist[setup_page]; - if (setup_page >= setup_chargrid[p->gridx][p->gridy].numskins || skin == -1) + if (forceskin) { - S_StartSound(NULL, sfx_s3k7b); //sfx_s3kb2 + if ((p->gridx != skins[cv_forceskin.value].kartspeed-1) + || (p->gridy != skins[cv_forceskin.value].kartweight-1)) + { + S_StartSound(NULL, sfx_s3k7b); //sfx_s3kb2 + } + else + { + p->mdepth = CSSTEP_COLORS; + S_StartSound(NULL, sfx_s3k63); + } } else { - if (setup_page+1 == setup_chargrid[p->gridx][p->gridy].numskins) - p->mdepth = CSSTEP_COLORS; // Skip clones menu if there are none on this page. + skin = setup_chargrid[p->gridx][p->gridy].skinlist[setup_page]; + if (setup_page >= setup_chargrid[p->gridx][p->gridy].numskins || skin == -1) + { + S_StartSound(NULL, sfx_s3k7b); //sfx_s3kb2 + } else - p->mdepth = CSSTEP_ALTS; + { + if (setup_page+1 == setup_chargrid[p->gridx][p->gridy].numskins) + p->mdepth = CSSTEP_COLORS; // Skip clones menu if there are none on this page. + else + p->mdepth = CSSTEP_ALTS; - S_StartSound(NULL, sfx_s3k63); + S_StartSound(NULL, sfx_s3k63); + } } M_SetMenuDelay(num); @@ -884,7 +902,7 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num) M_SetMenuDelay(num); } - if (num == 0 && setup_numplayers == 1 && setup_maxpage) // ONLY one player. + if (num == 0 && setup_numplayers == 1 && setup_maxpage && !forceskin) // ONLY one player. { if (M_MenuButtonPressed(num, MBT_L)) { @@ -961,6 +979,8 @@ static void M_HandleCharRotate(setup_player_t *p, UINT8 num) static void M_HandleColorRotate(setup_player_t *p, UINT8 num) { + boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1); + if (cv_splitdevice.value) num = 0; @@ -987,7 +1007,8 @@ static void M_HandleColorRotate(setup_player_t *p, UINT8 num) } else if (M_MenuBackPressed(num)) { - if (setup_chargrid[p->gridx][p->gridy].numskins == 1) + if (forceskin + || setup_chargrid[p->gridx][p->gridy].numskins == 1) { p->mdepth = CSSTEP_CHARS; // Skip clones menu } @@ -1253,6 +1274,7 @@ static void M_HandleFollowerColorRotate(setup_player_t *p, UINT8 num) boolean M_CharacterSelectHandler(INT32 choice) { INT32 i; + boolean forceskin = (Playing() && K_CanChangeRules(true) == true) && (cv_forceskin.value != -1); (void)choice; @@ -1318,7 +1340,18 @@ boolean M_CharacterSelectHandler(INT32 choice) } // Just makes it easier to access later - p->skin = setup_chargrid[p->gridx][p->gridy].skinlist[p->clonenum]; + if (forceskin) + { + if (p->gridx != skins[cv_forceskin.value].kartspeed-1 + || p->gridy != skins[cv_forceskin.value].kartweight-1) + p->skin = -1; + else + p->skin = cv_forceskin.value; + } + else + { + p->skin = setup_chargrid[p->gridx][p->gridy].skinlist[p->clonenum]; + } // Keep profile colour. /*if (p->mdepth < CSSTEP_COLORS)