From fc4b0d87767027e4675db3863071bbeea462b4ed Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Fri, 22 Jul 2022 13:57:48 +0200 Subject: [PATCH] Add page system on csel when alone to make alts easier to see --- src/k_menu.h | 4 ++++ src/k_menudraw.c | 25 ++++++++++++++++++------- src/k_menufunc.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index fe104bac5..772f159ab 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -559,6 +559,10 @@ extern setup_player_t setup_player[MAXSPLITSCREENPLAYERS]; extern UINT8 setup_numplayers; extern tic_t setup_animcounter; +// for charsel pages. +extern UINT8 setup_page; +extern UINT8 setup_maxpage; + #define CSROTATETICS 6 // The selection spawns 3 explosions in 4 directions, and there's 4 players -- 3 * 4 * 4 = 48 diff --git a/src/k_menudraw.c b/src/k_menudraw.c index ad9e92738..98e5140fc 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1123,8 +1123,13 @@ static boolean M_DrawFollowerSprite(INT16 x, INT16 y, INT32 num, INT32 addflags, static void M_DrawCharSelectSprite(UINT8 num, INT16 x, INT16 y) { setup_player_t *p = &setup_player[num]; + UINT8 cnum = p->clonenum; - SINT8 skin = setup_chargrid[p->gridx][p->gridy].skinlist[p->clonenum]; + // for p1 alone don't try to preview things on pages that don't exist lol. + if (p->mdepth == CSSTEP_CHARS && setup_numplayers == 1) + cnum = setup_page; + + INT16 skin = setup_chargrid[p->gridx][p->gridy].skinlist[cnum]; UINT8 color = p->color; UINT8 *colormap = R_GetTranslationColormap(skin, color, GTC_MENUCACHE); INT32 flags = 0; @@ -1449,6 +1454,11 @@ void M_DrawCharacterSelect(void) SINT8 skin; INT32 basex = optionsmenu.profile != NULL ? 64 : 0; + // Draw page num. + // @TODO: make it fancier than the default string lol. + if (setup_numplayers < 2) + V_DrawCenteredString(160, 1, 0, va("%d/%d", setup_page+1, setup_maxpage+1)); + if (setup_numplayers > 0) { priority = setup_animcounter % setup_numplayers; @@ -1459,7 +1469,7 @@ void M_DrawCharacterSelect(void) { for (j = 0; j < 9; j++) { - skin = setup_chargrid[i][j].skinlist[0]; + skin = setup_chargrid[i][j].skinlist[setup_page]; quadx = 4 * (i / 3); quady = 4 * (j / 3); @@ -1467,9 +1477,9 @@ void M_DrawCharacterSelect(void) // 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[0] != -1) - && (setup_chargrid[i][j+1].skinlist[0] != -1) - && (setup_chargrid[i+1][j+1].skinlist[0] != -1)) + 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; } @@ -1492,7 +1502,7 @@ void M_DrawCharacterSelect(void) break; // k == setup_numplayers means no one has it selected } - skin = setup_chargrid[i][j].skinlist[0]; + skin = setup_chargrid[i][j].skinlist[setup_page]; quadx = 4 * (i / 3); quady = 4 * (j / 3); @@ -1507,7 +1517,8 @@ void M_DrawCharacterSelect(void) V_DrawMappedPatch(basex + 82 + (i*16) + quadx, 22 + (j*16) + quady, 0, faceprefix[skin][FACE_RANK], colormap); - if (setup_chargrid[i][j].numskins > 1) + // draw dot if there are more alts behind there! + if (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/k_menufunc.c b/src/k_menufunc.c index a20d88492..ba87477f3 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -2148,6 +2148,9 @@ struct setup_explosions_s setup_explosions[48]; UINT8 setup_numplayers = 0; // This variable is very important, it was extended to determine how many players exist in ALL menus. tic_t setup_animcounter = 0; +UINT8 setup_page = 0; +UINT8 setup_maxpage = 0; // For charsel page to identify alts easier... + // sets up the grid pos for the skin used by the profile. static void M_SetupProfileGridPos(setup_player_t *p) { @@ -2210,6 +2213,7 @@ static void M_SetupMidGameGridPos(setup_player_t *p, UINT8 num) void M_CharacterSelectInit(void) { UINT8 i, j; + setup_maxpage = 0; // While we're editing profiles, don't unset the devices for p1 if (gamestate == GS_MENU) @@ -2263,6 +2267,8 @@ void M_CharacterSelectInit(void) { setup_chargrid[x][y].skinlist[setup_chargrid[x][y].numskins] = i; setup_chargrid[x][y].numskins++; + + setup_maxpage = max(setup_maxpage, setup_chargrid[x][y].numskins-1); } for (j = 0; j < MAXSPLITSCREENPLAYERS; j++) @@ -2295,6 +2301,8 @@ void M_CharacterSelectInit(void) } } } + + setup_page = 0; } void M_CharacterSelect(INT32 choice) @@ -2595,6 +2603,7 @@ static void M_HandleCharAskChange(setup_player_t *p, UINT8 num) static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num) { UINT8 numclones; + INT32 skin; if (cv_splitdevice.value) num = 0; @@ -2633,6 +2642,9 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num) M_SetMenuDelay(num); } + // try to set the clone num to the page # if possible. + p->clonenum = setup_page; + // Process this after possible pad movement, // this makes sure we don't have a weird ghost hover on a character with no clones. numclones = setup_chargrid[p->gridx][p->gridy].numskins; @@ -2642,14 +2654,15 @@ static boolean M_HandleCharacterGrid(setup_player_t *p, UINT8 num) if (M_MenuConfirmPressed(num) /*|| M_MenuButtonPressed(num, MBT_START)*/) { - if (setup_chargrid[p->gridx][p->gridy].numskins == 0) + 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 { - if (setup_chargrid[p->gridx][p->gridy].numskins == 1) - p->mdepth = CSSTEP_COLORS; // Skip clones menu + 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; @@ -2677,6 +2690,30 @@ 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 (M_MenuButtonPressed(num, MBT_L)) + { + if (setup_page == 0) + setup_page = setup_maxpage; + else + setup_page--; + + S_StartSound(NULL, sfx_s3k63); + M_SetMenuDelay(num); + } + else if (M_MenuButtonPressed(num, MBT_R)) + { + if (setup_page == setup_maxpage) + setup_page = 0; + else + setup_page++; + + S_StartSound(NULL, sfx_s3k63); + M_SetMenuDelay(num); + } + } + return false; } @@ -2994,6 +3031,7 @@ boolean M_CharacterSelectHandler(INT32 choice) if (playersChanged == true) { + setup_page = 0; // reset that. break; } }