From f9f4d56850926f9f14a6b7a72d91db6281a3b764 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 23 Feb 2023 15:56:37 +0000 Subject: [PATCH 01/13] m_cond.c/h: Copyright notice update Intended to do this in my previous `unlockables-undefeatable` branch but forgot --- src/m_cond.c | 1 + src/m_cond.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/m_cond.c b/src/m_cond.c index abc228d3a..ffcbca21b 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1,5 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- +// Copyright (C) 2022-2023 by Vivian "toaster" Grannell. // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2012-2020 by Sonic Team Junior. // diff --git a/src/m_cond.h b/src/m_cond.h index 735894c71..eb8ebe7c5 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -1,5 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- +// Copyright (C) 2022-2023 by Vivian "toaster" Grannell. // Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2012-2020 by Sonic Team Junior. // From d66a4cff8182536307df2d11aa12a9a76d39b8c7 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 23 Feb 2023 16:55:36 +0000 Subject: [PATCH 02/13] M_DrawChallenges: Scrolling question mark background --- src/k_menudraw.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 32476585a..100d1dcc9 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4828,8 +4828,25 @@ void M_DrawChallenges(void) INT16 offset; { - patch_t *bg = W_CachePatchName("BGUNLCK2", PU_CACHE); +#define questionslow 4 // slows down the scroll by this factor +#define questionloop (questionslow*100) // modulo + INT32 questionoffset = (challengesmenu.ticker % questionloop); + patch_t *bg = W_CachePatchName("BGUNLCKG", PU_CACHE); + patch_t *qm = W_CachePatchName("BGUNLSC", PU_CACHE); + + // Background gradient V_DrawFixedPatch(0, 0, FRACUNIT, 0, bg, NULL); + + // Scrolling question mark overlay + V_DrawFixedPatch( + -((160 + questionoffset)*FRACUNIT)/questionslow, + -(4*FRACUNIT) - (245*(FixedDiv((questionloop - questionoffset)*FRACUNIT, questionloop*FRACUNIT))), + FRACUNIT, + V_MODULATE, + qm, + NULL); +#undef questionslow +#undef questionloop } if (gamedata->challengegrid == NULL || challengesmenu.extradata == NULL) From d17525fac78488d86f90e989c6c35bfc2d9b139d Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 23 Feb 2023 17:24:11 +0000 Subject: [PATCH 03/13] M_DrawChallenges: reimplement dark areas for contrast/readability Now uses V_DrawFadeFill and MENUHINT patch directly. --- src/k_menudraw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 100d1dcc9..b3b750f45 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4819,6 +4819,8 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) } } +#define challengetransparentstrength 8 + void M_DrawChallenges(void) { INT32 x = currentMenu->x, explodex, selectx; @@ -4855,6 +4857,8 @@ void M_DrawChallenges(void) goto challengedesc; } + V_DrawFadeFill(0, y-2, BASEVIDWIDTH, 90, 0, 31, challengetransparentstrength); + x -= 16; x += challengesmenu.offset; @@ -4939,6 +4943,12 @@ challengedesc: { y = 120; + V_DrawScaledPatch(0, y, + (10-challengetransparentstrength)< Date: Thu, 23 Feb 2023 17:57:01 +0000 Subject: [PATCH 04/13] Challenge Grid: set height to 4 - In anticipation of next steps of menu redesign - g_game.c: Increment GD_VERSIONMINOR and burn old challenge grid data --- src/g_game.c | 42 ++++++++++++++++++++++++++++++------------ src/m_cond.h | 2 +- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ecf088eaf..189f22fa4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4354,7 +4354,7 @@ void G_LoadGameSettings(void) } #define GD_VERSIONCHECK 0xBA5ED123 // Change every major version, as usual -#define GD_VERSIONMINOR 0 // Change every format update +#define GD_VERSIONMINOR 1 // Change every format update // G_LoadGameData // Loads the main data file, which stores information such as emblems found, etc. @@ -4364,6 +4364,7 @@ void G_LoadGameData(void) UINT32 versionID; UINT8 versionMinor; UINT8 rtemp; + boolean gridunusable = false; savebuffer_t save = {0}; //For records @@ -4418,6 +4419,10 @@ void G_LoadGameData(void) P_SaveBufferFree(&save); I_Error("Game data is from the future! (expected %d, got %d)", GD_VERSIONMINOR, versionMinor); } + if (versionMinor == 0) + { + gridunusable = true; + } gamedata->totalplaytime = READUINT32(save.p); gamedata->matchesplayed = READUINT32(save.p); @@ -4464,21 +4469,34 @@ void G_LoadGameData(void) i += j; } - gamedata->challengegridwidth = READUINT16(save.p); - Z_Free(gamedata->challengegrid); - if (gamedata->challengegridwidth) + if (gridunusable) { - gamedata->challengegrid = Z_Malloc( - (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(UINT8)), - PU_STATIC, NULL); - for (i = 0; i < (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT); i++) - { - gamedata->challengegrid[i] = READUINT8(save.p); - } + UINT16 burn = READUINT16(save.p); // Previous challengegridwidth + UINT8 height = (versionMinor > 0) ? CHALLENGEGRIDHEIGHT : 5; + save.p += (burn * height * sizeof(UINT8)); // Step over previous grid data + + gamedata->challengegridwidth = 0; + Z_Free(gamedata->challengegrid); + gamedata->challengegrid = NULL; } else { - gamedata->challengegrid = NULL; + gamedata->challengegridwidth = READUINT16(save.p); + Z_Free(gamedata->challengegrid); + if (gamedata->challengegridwidth) + { + gamedata->challengegrid = Z_Malloc( + (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(UINT8)), + PU_STATIC, NULL); + for (i = 0; i < (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT); i++) + { + gamedata->challengegrid[i] = READUINT8(save.p); + } + } + else + { + gamedata->challengegrid = NULL; + } } gamedata->timesBeaten = READUINT32(save.p); diff --git a/src/m_cond.h b/src/m_cond.h index eb8ebe7c5..9439cfe86 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -139,7 +139,7 @@ typedef enum #define MAXEMBLEMS 512 #define MAXUNLOCKABLES MAXCONDITIONSETS -#define CHALLENGEGRIDHEIGHT 5 +#define CHALLENGEGRIDHEIGHT 4 #ifdef DEVELOP #define CHALLENGEGRIDLOOPWIDTH 3 #else From 287540039761ad0d66d5b0deee91cd6e2a065b3f Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 23 Feb 2023 21:39:55 +0000 Subject: [PATCH 05/13] Challenges Grid: New tile borders + selection reticule M_DrawChallenges: Adjust all offsets to new 22x22 bordered system (from 16x16) M_DrawChallengeTile: Border, colorization, and reticule --- src/k_hud.h | 1 - src/k_menudraw.c | 124 +++++++++++++++++++++++++++++++---------------- 2 files changed, 82 insertions(+), 43 deletions(-) diff --git a/src/k_hud.h b/src/k_hud.h index b80760c2c..e9b0603f2 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -46,7 +46,6 @@ void K_DrawMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, UINT16 map, void K_DrawLikeMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, patch_t *patch, UINT8 *colormap); void K_drawTargetHUD(const vector3_t *origin, player_t *player); -extern patch_t *kp_facehighlight[8]; extern patch_t *kp_capsuletarget_arrow[2][2]; extern patch_t *kp_capsuletarget_icon[2]; extern patch_t *kp_capsuletarget_far[2]; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index b3b750f45..dc37e7c70 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4519,7 +4519,7 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili UINT8 *colormap = NULL; fixed_t siz; UINT8 id, num; - UINT32 edgelength; + boolean unlockedyet; id = (i * CHALLENGEGRIDHEIGHT) + j; num = gamedata->challengegrid[id]; @@ -4533,14 +4533,36 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili // Okay, this is what we want to draw. ref = &unlockables[num]; - edgelength = (ref->majorunlock ? 30 : 14); + unlockedyet = !((gamedata->unlocked[num] == false) + || (challengesmenu.pending && num == challengesmenu.currentunlock && challengesmenu.unlockanim <= UNLOCKTIME)); - // ...unless we simply aren't unlocked yet. - if ((gamedata->unlocked[num] == false) - || (challengesmenu.pending && num == challengesmenu.currentunlock && challengesmenu.unlockanim <= UNLOCKTIME)) + pat = W_CachePatchName( + (ref->majorunlock ? "UN_BORDB" : "UN_BORDA"), + PU_CACHE); + + if (!unlockedyet) + { + UINT16 col = (challengesmenu.extradata[id] == CHE_HINT) ? SKINCOLOR_BLUE : SKINCOLOR_BLACK; + colormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); + } + else + { + colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_SILVER, GTC_MENUCACHE); + } + + V_DrawFixedPatch( + x*FRACUNIT, y*FRACUNIT, + FRACUNIT, + 0, pat, + colormap + ); + + pat = missingpat; + colormap = NULL; + + // If we aren't unlocked yet, return early. + if (!unlockedyet) { - V_DrawFill(x+1, y+1, edgelength, edgelength, - ((challengesmenu.extradata[id] == CHE_HINT) ? 132 : 11)); goto drawborder; } @@ -4588,22 +4610,27 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili } siz = (SHORT(pat->width) << FRACBITS); - siz = FixedDiv(((ref->majorunlock) ? 32 : 16) << FRACBITS, siz); - V_SetClipRect( - (x+1) << FRACBITS, (y+1) << FRACBITS, - edgelength << FRACBITS, edgelength << FRACBITS, - 0 - ); - - V_DrawFixedPatch( - x*FRACUNIT, y*FRACUNIT, - siz, - 0, pat, - colormap - ); - - V_ClearClipRect(); + if (!siz) + ; // prevent div/0 + else if (ref->majorunlock) + { + V_DrawFixedPatch( + (x + 5)*FRACUNIT, (y + 5)*FRACUNIT, + FixedDiv(32 << FRACBITS, siz), + 0, pat, + colormap + ); + } + else + { + V_DrawFixedPatch( + (x + 2)*FRACUNIT, (y + 2)*FRACUNIT, + FixedDiv(16 << FRACBITS, siz), + 0, pat, + colormap + ); + } drawborder: if (!hili) @@ -4611,12 +4638,23 @@ drawborder: return; } - V_DrawFixedPatch( - x*FRACUNIT, y*FRACUNIT, - ((ref != NULL && ref->majorunlock) ? FRACUNIT*2 : FRACUNIT), - 0, kp_facehighlight[(challengesmenu.ticker / 4) % 8], - NULL - ); + { + boolean maj = (ref != NULL && ref->majorunlock); + char buffer[9]; + sprintf(buffer, "UN_RETA1"); + buffer[6] = maj ? 'B' : 'A'; + buffer[7] = (skullAnimCounter/5) ? '2' : '1'; + pat = W_CachePatchName(buffer, PU_CACHE); + + colormap = R_GetTranslationColormap(TC_DEFAULT, cv_playercolor[0].value, GTC_MENUCACHE); + + V_DrawFixedPatch( + x*FRACUNIT, y*FRACUNIT, + FRACUNIT, + 0, pat, + colormap + ); + } } static void M_DrawChallengePreview(INT32 x, INT32 y) @@ -4820,6 +4858,7 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) } #define challengetransparentstrength 8 +#define challengesgridstep 22 void M_DrawChallenges(void) { @@ -4859,41 +4898,41 @@ void M_DrawChallenges(void) V_DrawFadeFill(0, y-2, BASEVIDWIDTH, 90, 0, 31, challengetransparentstrength); - x -= 16; + x -= (challengesgridstep-1); x += challengesmenu.offset; if (challengegridloops) { if (!challengesmenu.col && challengesmenu.hilix) - x -= gamedata->challengegridwidth*16; + x -= gamedata->challengegridwidth*challengesgridstep; i = challengesmenu.col + challengesmenu.focusx; - explodex = x - (i*16); + explodex = x - (i*challengesgridstep); - while (x < BASEVIDWIDTH-16) + while (x < BASEVIDWIDTH-challengesgridstep) { i = (i + 1) % gamedata->challengegridwidth; - x += 16; + x += challengesgridstep; } } else { if (gamedata->challengegridwidth & 1) - x += 8; + x += (challengesgridstep/2); i = gamedata->challengegridwidth-1; - explodex = x - (i*16)/2; - x += (i*16)/2; + explodex = x - (i*challengesgridstep)/2; + x += (i*challengesgridstep)/2; } - selectx = explodex + (challengesmenu.hilix*16); + selectx = explodex + (challengesmenu.hilix*challengesgridstep); - while (i >= 0 && x >= -32) + while (i >= 0 && x >= -(challengesgridstep*2)) { - y = currentMenu->y-16; + y = currentMenu->y-challengesgridstep; for (j = 0; j < CHALLENGEGRIDHEIGHT; j++) { - y += 16; + y += challengesgridstep; if (challengesmenu.extradata[(i * CHALLENGEGRIDHEIGHT) + j] & CHE_DONTDRAW) { @@ -4908,7 +4947,7 @@ void M_DrawChallenges(void) M_DrawChallengeTile(i, j, x, y, false); } - x -= 16; + x -= challengesgridstep; i--; if (challengegridloops && i < 0) { @@ -4924,7 +4963,7 @@ void M_DrawChallenges(void) challengesmenu.hilix, challengesmenu.hiliy, selectx, - currentMenu->y + (challengesmenu.hiliy*16), + currentMenu->y + (challengesmenu.hiliy*challengesgridstep), true); M_DrawCharSelectExplosions(false, explodex, currentMenu->y); @@ -4989,6 +5028,7 @@ challengedesc: } #undef challengetransparentstrength +#undef challengesgridstep // Statistics menu From 2164121ce6a209ee4d2dd6ecff19c1bab40e8392 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 23 Feb 2023 23:38:06 +0000 Subject: [PATCH 06/13] M_DrawChallengeTile: Have different appearance for hovered over tile (current behaviour) and category information --- src/k_menudraw.c | 152 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 122 insertions(+), 30 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index dc37e7c70..d617e87cd 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4516,10 +4516,11 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili { unlockable_t *ref = NULL; patch_t *pat = missingpat; - UINT8 *colormap = NULL; + UINT8 *colormap = NULL, *bgmap = NULL; fixed_t siz; UINT8 id, num; boolean unlockedyet; + boolean categoryside; id = (i * CHALLENGEGRIDHEIGHT) + j; num = gamedata->challengegrid[id]; @@ -4543,22 +4544,21 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili if (!unlockedyet) { UINT16 col = (challengesmenu.extradata[id] == CHE_HINT) ? SKINCOLOR_BLUE : SKINCOLOR_BLACK; - colormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); + bgmap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); } else { - colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_SILVER, GTC_MENUCACHE); + bgmap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_SILVER, GTC_MENUCACHE); } V_DrawFixedPatch( x*FRACUNIT, y*FRACUNIT, FRACUNIT, 0, pat, - colormap + bgmap ); pat = missingpat; - colormap = NULL; // If we aren't unlocked yet, return early. if (!unlockedyet) @@ -4566,7 +4566,54 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili goto drawborder; } - if (ref->icon != NULL && ref->icon[0]) + categoryside = !hili; // temporary + + if (categoryside) + { + char categoryid = '8'; + colormap = bgmap; + switch (ref->type) + { + case SECRET_SKIN: + categoryid = '1'; + break; + case SECRET_FOLLOWER: + categoryid = '2'; + break; + /*case SECRET_COLOR: + categoryid = '3'; + break;*/ + case SECRET_CUP: + categoryid = '4'; + break; + //case SECRET_MASTERBOTS: + case SECRET_HARDSPEED: + case SECRET_ENCORE: + categoryid = '5'; + break; + case SECRET_ALTTITLE: + case SECRET_SOUNDTEST: + categoryid = '6'; + break; + case SECRET_TIMEATTACK: + case SECRET_BREAKTHECAPSULES: + case SECRET_SPECIALATTACK: + categoryid = '7'; + break; + } + pat = W_CachePatchName(va("UN_RR0%c%c", + categoryid, + (ref->majorunlock) ? 'B' : 'A'), + PU_CACHE); + if (pat == missingpat) + { + pat = W_CachePatchName(va("UN_RR0%c%c", + categoryid, + (ref->majorunlock) ? 'A' : 'B'), + PU_CACHE); + } + } + else if (ref->icon != NULL && ref->icon[0]) { pat = W_CachePatchName(ref->icon, PU_CACHE); if (ref->color != SKINCOLOR_NONE && ref->color < numskincolors) @@ -4574,38 +4621,83 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili colormap = R_GetTranslationColormap(TC_DEFAULT, ref->color, GTC_MENUCACHE); } } - else switch (ref->type) + else { - case SECRET_SKIN: + UINT8 iconid = 0; + switch (ref->type) { - INT32 skin = M_UnlockableSkinNum(ref); - if (skin != -1) + case SECRET_SKIN: { - colormap = R_GetTranslationColormap(skin, skins[skin].prefcolor, GTC_MENUCACHE); - pat = faceprefix[skin][(ref->majorunlock) ? FACE_WANTED : FACE_RANK]; + INT32 skin = M_UnlockableSkinNum(ref); + if (skin != -1) + { + colormap = R_GetTranslationColormap(skin, skins[skin].prefcolor, GTC_MENUCACHE); + pat = faceprefix[skin][(ref->majorunlock) ? FACE_WANTED : FACE_RANK]; + } + break; + } + case SECRET_FOLLOWER: + { + INT32 skin = M_UnlockableFollowerNum(ref); + if (skin != -1) + { + UINT16 col = K_GetEffectiveFollowerColor(followers[skin].defaultcolor, cv_playercolor[0].value); + colormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); + pat = W_CachePatchName(followers[skin].icon, PU_CACHE); + } + break; + } + + /*case SECRET_MASTERBOTS: + iconid = 4; + break;*/ + case SECRET_HARDSPEED: + iconid = 3; + break; + case SECRET_ENCORE: + iconid = 5; + break; + + case SECRET_ALTTITLE: + iconid = 6; + break; + case SECRET_SOUNDTEST: + iconid = 1; + break; + + case SECRET_TIMEATTACK: + iconid = 7; + break; + case SECRET_BREAKTHECAPSULES: + iconid = 8; + break; + case SECRET_SPECIALATTACK: + iconid = 9; + break; + + default: + { + if (!colormap && ref->color != SKINCOLOR_NONE && ref->color < numskincolors) + { + colormap = R_GetTranslationColormap(TC_RAINBOW, ref->color, GTC_MENUCACHE); + } + break; } - break; } - case SECRET_FOLLOWER: + + if (pat == missingpat) { - INT32 skin = M_UnlockableFollowerNum(ref); - if (skin != -1) + pat = W_CachePatchName(va("UN_IC%02u%c", + iconid, + ref->majorunlock ? 'B' : 'A'), + PU_CACHE); + if (pat == missingpat) { - UINT16 col = K_GetEffectiveFollowerColor(followers[skin].defaultcolor, cv_playercolor[0].value); - colormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); - pat = W_CachePatchName(followers[skin].icon, PU_CACHE); + pat = W_CachePatchName(va("UN_IC%02u%c", + iconid, + ref->majorunlock ? 'A' : 'B'), + PU_CACHE); } - break; - } - default: - { - pat = W_CachePatchName(va("UN_RR00%c", ref->majorunlock ? 'B' : 'A'), PU_CACHE); - if (ref->color != SKINCOLOR_NONE && ref->color < numskincolors) - { - //CONS_Printf(" color for %d is %s\n", num, skincolors[unlockables[num].color].name); - colormap = R_GetTranslationColormap(TC_RAINBOW, ref->color, GTC_MENUCACHE); - } - break; } } From 9cb176de36186359bdc930c25fddf6fbfcc82c70 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 24 Feb 2023 00:16:39 +0000 Subject: [PATCH 07/13] M_DrawCharSelectExplosions: Fix alignment of explosions for Challenges Grid --- src/k_menudraw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index d617e87cd..2d9f570b3 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1479,7 +1479,7 @@ static void M_DrawCharSelectPreview(UINT8 num) static void M_DrawCharSelectExplosions(boolean charsel, INT16 basex, INT16 basey) { UINT8 i; - INT16 quadx = 0, quady = 0; + INT16 quadx = 2, quady = 2, mul = 22; for (i = 0; i < CSEXPLOSIONS; i++) { @@ -1495,13 +1495,14 @@ static void M_DrawCharSelectExplosions(boolean charsel, INT16 basex, INT16 basey { quadx = 4 * (setup_explosions[i].x / 3); quady = 4 * (setup_explosions[i].y / 3); + mul = 16; } colormap = R_GetTranslationColormap(TC_DEFAULT, setup_explosions[i].color, GTC_MENUCACHE); V_DrawMappedPatch( - basex + (setup_explosions[i].x*16) + quadx - 6, - basey + (setup_explosions[i].y*16) + quady - 6, + basex + (setup_explosions[i].x*mul) + quadx - 6, + basey + (setup_explosions[i].y*mul) + quady - 6, 0, W_CachePatchName(va("CHCNFRM%d", frame), PU_CACHE), colormap ); From 4380876959f881f4d9722a745b94d95d957005ab Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 24 Feb 2023 17:38:08 +0000 Subject: [PATCH 08/13] Challenges Grid: create dedicated struct for menu extradata - challengegridextradata_t - Existing UINT8 data per entry has been converted to "flags" property - This is a tool that will help us later. --- src/k_menu.h | 2 +- src/k_menudraw.c | 6 ++--- src/m_cond.c | 43 +++++++++++++++++++++-------------- src/m_cond.h | 10 +++++++- src/menus/extras-challenges.c | 22 +++++++++--------- src/typedef.h | 1 + 6 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index ec6a96111..33b08da0a 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1151,7 +1151,7 @@ extern struct challengesmenu_s { SINT8 row, hilix, focusx; UINT8 col, hiliy; - UINT8 *extradata; + challengegridextradata_t *extradata; boolean pending; boolean requestnew; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 2d9f570b3..56709a7ed 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4544,7 +4544,7 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili if (!unlockedyet) { - UINT16 col = (challengesmenu.extradata[id] == CHE_HINT) ? SKINCOLOR_BLUE : SKINCOLOR_BLACK; + UINT16 col = (challengesmenu.extradata[id].flags == CHE_HINT) ? SKINCOLOR_BLUE : SKINCOLOR_BLACK; bgmap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); } else @@ -5027,7 +5027,7 @@ void M_DrawChallenges(void) { y += challengesgridstep; - if (challengesmenu.extradata[(i * CHALLENGEGRIDHEIGHT) + j] & CHE_DONTDRAW) + if (challengesmenu.extradata[(i * CHALLENGEGRIDHEIGHT) + j].flags & CHE_DONTDRAW) { continue; } @@ -5112,7 +5112,7 @@ challengedesc: && challengesmenu.currentunlock < MAXUNLOCKABLES && ((gamedata->unlocked[challengesmenu.currentunlock] == true) || ((challengesmenu.extradata != NULL) - && (challengesmenu.extradata[i] & CHE_HINT)) + && (challengesmenu.extradata[i].flags & CHE_HINT)) ) ) { diff --git a/src/m_cond.c b/src/m_cond.c index ffcbca21b..26d91d6a0 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -260,10 +260,10 @@ quickcheckagain: } } -UINT8 *M_ChallengeGridExtraData(void) +challengegridextradata_t *M_ChallengeGridExtraData(void) { UINT8 i, j, num, id, tempid, work; - UINT8 *extradata; + challengegridextradata_t *extradata; boolean idchange; if (!gamedata->challengegrid) @@ -272,7 +272,7 @@ UINT8 *M_ChallengeGridExtraData(void) } extradata = Z_Malloc( - (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(UINT8)), + (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(challengegridextradata_t)), PU_STATIC, NULL); if (!extradata) @@ -282,6 +282,17 @@ UINT8 *M_ChallengeGridExtraData(void) //CONS_Printf(" --- \n"); + // Pre-wipe flags. + for (i = 0; i < gamedata->challengegridwidth; i++) + { + for (j = 0; j < CHALLENGEGRIDHEIGHT; j++) + { + id = (i * CHALLENGEGRIDHEIGHT) + j; + extradata[id].flags = CHE_NONE; + } + } + + // Populate extra data. for (i = 0; i < gamedata->challengegridwidth; i++) { for (j = 0; j < CHALLENGEGRIDHEIGHT; j++) @@ -290,8 +301,6 @@ UINT8 *M_ChallengeGridExtraData(void) num = gamedata->challengegrid[id]; idchange = false; - extradata[id] = CHE_NONE; - // Empty spots in the grid are always unconnected. if (num >= MAXUNLOCKABLES) { @@ -305,13 +314,13 @@ UINT8 *M_ChallengeGridExtraData(void) work = gamedata->challengegrid[tempid]; if (work == num) { - extradata[id] = CHE_CONNECTEDUP; + extradata[id].flags = CHE_CONNECTEDUP; // Get the id to write extra hint data to. // This check is safe because extradata's order of population - if (extradata[tempid] & CHE_CONNECTEDLEFT) + if (extradata[tempid].flags & CHE_CONNECTEDLEFT) { - extradata[id] |= CHE_CONNECTEDLEFT; + extradata[id].flags |= CHE_CONNECTEDLEFT; //CONS_Printf(" %d - %d above %d is invalid, check to left\n", num, tempid, id); if (i > 0) { @@ -328,14 +337,14 @@ UINT8 *M_ChallengeGridExtraData(void) id = tempid; idchange = true; - if (extradata[id] == CHE_HINT) + if (extradata[id].flags == CHE_HINT) { continue; } } else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) { - extradata[id] = CHE_HINT; + extradata[id].flags = CHE_HINT; } } @@ -357,11 +366,11 @@ UINT8 *M_ChallengeGridExtraData(void) { //CONS_Printf(" %d - %d to left of %d is valid\n", work, tempid, id); // If we haven't already updated our id, it's the one to our left. - if (extradata[id] == CHE_HINT) + if (extradata[id].flags == CHE_HINT) { - extradata[tempid] = CHE_HINT; + extradata[tempid].flags = CHE_HINT; } - extradata[id] = CHE_CONNECTEDLEFT; + extradata[id].flags = CHE_CONNECTEDLEFT; id = tempid; } /*else @@ -369,13 +378,13 @@ UINT8 *M_ChallengeGridExtraData(void) } else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) { - extradata[id] = CHE_HINT; + extradata[id].flags = CHE_HINT; continue; } } // Since we're not modifying id past this point, the conditions become much simpler. - if (extradata[id] == CHE_HINT) + if ((extradata[id].flags & (CHE_HINT|CHE_DONTDRAW)) == CHE_HINT) { continue; } @@ -392,7 +401,7 @@ UINT8 *M_ChallengeGridExtraData(void) } else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) { - extradata[id] = CHE_HINT; + extradata[id].flags = CHE_HINT; continue; } } @@ -415,7 +424,7 @@ UINT8 *M_ChallengeGridExtraData(void) } else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) { - extradata[id] = CHE_HINT; + extradata[id].flags = CHE_HINT; continue; } } diff --git a/src/m_cond.h b/src/m_cond.h index 9439cfe86..4d8ac1c2b 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -193,12 +193,20 @@ void M_NewGameDataStruct(void); // Challenges menu stuff void M_PopulateChallengeGrid(void); -UINT8 *M_ChallengeGridExtraData(void); + +struct challengegridextradata_t +{ + UINT8 flags; +}; + +challengegridextradata_t *M_ChallengeGridExtraData(void); + #define CHE_NONE 0 #define CHE_HINT 1 #define CHE_CONNECTEDLEFT (1<<1) #define CHE_CONNECTEDUP (1<<2) #define CHE_DONTDRAW (CHE_CONNECTEDLEFT|CHE_CONNECTEDUP) + char *M_BuildConditionSetString(UINT8 unlockid); #define DESCRIPTIONWIDTH 170 diff --git a/src/menus/extras-challenges.c b/src/menus/extras-challenges.c index 583dc7a1a..e38415bdf 100644 --- a/src/menus/extras-challenges.c +++ b/src/menus/extras-challenges.c @@ -72,7 +72,7 @@ static void M_ChallengesAutoFocus(UINT8 unlockid, boolean fresh) continue; } - if (challengesmenu.extradata[i] & CHE_CONNECTEDLEFT) + if (challengesmenu.extradata[i].flags & CHE_CONNECTEDLEFT) { // no need to check for CHE_CONNECTEDUP in linear iteration continue; @@ -461,8 +461,8 @@ boolean M_ChallengesInputs(INT32 ch) } if (!(challengesmenu.extradata[ (challengesmenu.col * CHALLENGEGRIDHEIGHT) - + challengesmenu.row] - & CHE_CONNECTEDUP)) + + challengesmenu.row + ].flags & CHE_CONNECTEDUP)) { break; } @@ -475,8 +475,8 @@ boolean M_ChallengesInputs(INT32 ch) { i = (challengesmenu.extradata[ (challengesmenu.col * CHALLENGEGRIDHEIGHT) - + challengesmenu.row] - & CHE_CONNECTEDUP) ? 2 : 1; + + challengesmenu.row + ].flags & CHE_CONNECTEDUP) ? 2 : 1; while (i > 0) { if (challengesmenu.row > 0) @@ -516,8 +516,8 @@ boolean M_ChallengesInputs(INT32 ch) if (!(challengesmenu.extradata[ (challengesmenu.col * CHALLENGEGRIDHEIGHT) - + challengesmenu.row] - & CHE_CONNECTEDLEFT)) + + challengesmenu.row + ].flags & CHE_CONNECTEDLEFT)) { break; } @@ -531,8 +531,8 @@ boolean M_ChallengesInputs(INT32 ch) { i = (challengesmenu.extradata[ (challengesmenu.col * CHALLENGEGRIDHEIGHT) - + challengesmenu.row] - & CHE_CONNECTEDLEFT) ? 2 : 1; + + challengesmenu.row + ].flags & CHE_CONNECTEDLEFT) ? 2 : 1; while (i > 0) { // Slide the focus counter to movement, if we can. @@ -570,12 +570,12 @@ boolean M_ChallengesInputs(INT32 ch) { // Adjust highlight coordinates up/to the left for large tiles. - if (challengesmenu.hiliy > 0 && (challengesmenu.extradata[i] & CHE_CONNECTEDUP)) + if (challengesmenu.hiliy > 0 && (challengesmenu.extradata[i].flags & CHE_CONNECTEDUP)) { challengesmenu.hiliy--; } - if ((challengesmenu.extradata[i] & CHE_CONNECTEDLEFT)) + if ((challengesmenu.extradata[i].flags & CHE_CONNECTEDLEFT)) { if (challengesmenu.hilix > 0) { diff --git a/src/typedef.h b/src/typedef.h index a38b018a0..632684d1e 100644 --- a/src/typedef.h +++ b/src/typedef.h @@ -209,6 +209,7 @@ TYPEDEF (conditionset_t); TYPEDEF (emblem_t); TYPEDEF (unlockable_t); TYPEDEF (gamedata_t); +TYPEDEF (challengegridextradata_t); // m_dllist.h TYPEDEF (mdllistitem_t); From e65bb87ec557a820165be7a2586d4054b08722d8 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 24 Feb 2023 18:15:38 +0000 Subject: [PATCH 09/13] M_DrawChallengeTile: Change the appearance of locked tiles - Question mark - If next to an unlocked tile (ie, hint mode) - Have ring around when highlighted, per hint ring - ELSE, make blink-colormapped + subtractive --- src/k_menudraw.c | 49 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 56709a7ed..7ebc481a5 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4538,19 +4538,44 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili unlockedyet = !((gamedata->unlocked[num] == false) || (challengesmenu.pending && num == challengesmenu.currentunlock && challengesmenu.unlockanim <= UNLOCKTIME)); + { + UINT32 flags = 0; + + if (challengesmenu.extradata[id].flags != CHE_HINT) + { + colormap = R_GetTranslationColormap(TC_BLINK, SKINCOLOR_BLACK, GTC_CACHE); + flags = V_SUBTRACT|V_90TRANS; + } + + pat = W_CachePatchName( + va("UN_HNT%c%c", + (hili && !colormap) ? '1' : '2', + ref->majorunlock ? 'B' : 'A' + ), + PU_CACHE); + + V_DrawFixedPatch( + x*FRACUNIT, y*FRACUNIT, + FRACUNIT, + flags, pat, + colormap + ); + + pat = missingpat; + colormap = NULL; + } + + // If we aren't unlocked yet, return early. + if (!unlockedyet) + { + goto drawborder; + } + pat = W_CachePatchName( (ref->majorunlock ? "UN_BORDB" : "UN_BORDA"), PU_CACHE); - if (!unlockedyet) - { - UINT16 col = (challengesmenu.extradata[id].flags == CHE_HINT) ? SKINCOLOR_BLUE : SKINCOLOR_BLACK; - bgmap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE); - } - else - { - bgmap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_SILVER, GTC_MENUCACHE); - } + bgmap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_SILVER, GTC_MENUCACHE); V_DrawFixedPatch( x*FRACUNIT, y*FRACUNIT, @@ -4561,12 +4586,6 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili pat = missingpat; - // If we aren't unlocked yet, return early. - if (!unlockedyet) - { - goto drawborder; - } - categoryside = !hili; // temporary if (categoryside) From 8dc4971c2a6303c148cf7a0bb5888dd161da79da Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 24 Feb 2023 19:06:45 +0000 Subject: [PATCH 10/13] M_DrawChallengeTile: Don't draw the ? stuff if not yet unlocked --- src/k_menudraw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 7ebc481a5..fc44aadde 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4538,6 +4538,8 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili unlockedyet = !((gamedata->unlocked[num] == false) || (challengesmenu.pending && num == challengesmenu.currentunlock && challengesmenu.unlockanim <= UNLOCKTIME)); + // If we aren't unlocked yet, return early. + if (!unlockedyet) { UINT32 flags = 0; @@ -4563,11 +4565,7 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili pat = missingpat; colormap = NULL; - } - // If we aren't unlocked yet, return early. - if (!unlockedyet) - { goto drawborder; } From 339617a54e6fce9dc5f099c4b8db07c0b6651f49 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 24 Feb 2023 19:10:44 +0000 Subject: [PATCH 11/13] extras-challenges.c, M_UpdateChallengeGridExtraData: Be less lazy about reallocation - Z_Calloc once, on menu load, instead of every time data changes - Free once, on menu exit, instead of every time data changes --- src/m_cond.c | 17 +++++------------ src/m_cond.h | 2 +- src/menus/extras-challenges.c | 22 +++++++++++++++------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/m_cond.c b/src/m_cond.c index 26d91d6a0..f948f400d 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -260,24 +260,19 @@ quickcheckagain: } } -challengegridextradata_t *M_ChallengeGridExtraData(void) +void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) { UINT8 i, j, num, id, tempid, work; - challengegridextradata_t *extradata; boolean idchange; - if (!gamedata->challengegrid) + if (gamedata->challengegrid == NULL) { - return NULL; + return; } - extradata = Z_Malloc( - (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(challengegridextradata_t)), - PU_STATIC, NULL); - - if (!extradata) + if (extradata == NULL) { - I_Error("M_ChallengeGridExtraData: was not able to allocate extradata"); + return; } //CONS_Printf(" --- \n"); @@ -430,8 +425,6 @@ challengegridextradata_t *M_ChallengeGridExtraData(void) } } } - - return extradata; } void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1, INT16 x2) diff --git a/src/m_cond.h b/src/m_cond.h index 4d8ac1c2b..f8fa531d2 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -199,7 +199,7 @@ struct challengegridextradata_t UINT8 flags; }; -challengegridextradata_t *M_ChallengeGridExtraData(void); +void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata); #define CHE_NONE 0 #define CHE_HINT 1 diff --git a/src/menus/extras-challenges.c b/src/menus/extras-challenges.c index e38415bdf..fb8598eff 100644 --- a/src/menus/extras-challenges.c +++ b/src/menus/extras-challenges.c @@ -174,7 +174,12 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu) M_PopulateChallengeGrid(); if (gamedata->challengegrid) - challengesmenu.extradata = M_ChallengeGridExtraData(); + { + challengesmenu.extradata = Z_Calloc( + (gamedata->challengegridwidth * CHALLENGEGRIDHEIGHT * sizeof(challengegridextradata_t)), + PU_STATIC, NULL); + M_UpdateChallengeGridExtraData(challengesmenu.extradata); + } memset(setup_explosions, 0, sizeof(setup_explosions)); memset(&challengesmenu.unlockcount, 0, sizeof(challengesmenu.unlockcount)); @@ -318,11 +323,15 @@ void M_ChallengesTick(void) challengesmenu.unlockcount[CC_TALLY]++; challengesmenu.unlockcount[CC_ANIM]++; - Z_Free(challengesmenu.extradata); - if ((challengesmenu.extradata = M_ChallengeGridExtraData())) + if (challengesmenu.extradata) { - unlockable_t *ref = &unlockables[challengesmenu.currentunlock]; - UINT16 bombcolor = SKINCOLOR_NONE; + unlockable_t *ref; + UINT16 bombcolor; + + M_UpdateChallengeGridExtraData(challengesmenu.extradata); + + ref = &unlockables[challengesmenu.currentunlock]; + bombcolor = SKINCOLOR_NONE; if (ref->color != SKINCOLOR_NONE && ref->color < numskincolors) { @@ -413,8 +422,7 @@ boolean M_ChallengesInputs(INT32 ch) gamedata->challengegrid = NULL; gamedata->challengegridwidth = 0; M_PopulateChallengeGrid(); - Z_Free(challengesmenu.extradata); - challengesmenu.extradata = M_ChallengeGridExtraData(); + M_UpdateChallengeGridExtraData(challengesmenu.extradata); M_ChallengesAutoFocus(challengesmenu.currentunlock, true); From 9779d6066ca576222751492e157893a7241ea500 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 25 Feb 2023 00:21:28 +0000 Subject: [PATCH 12/13] Challenge Grid: Introduce flipping tiles - When a tile is selected, flips from category side to specific icon side - Flips back when unselected - Hold R (drift) to flip all tiles to visible side --- src/k_menu.h | 2 ++ src/k_menudraw.c | 31 +++++++++++++++++++------- src/m_cond.h | 1 + src/menus/extras-challenges.c | 42 ++++++++++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 33b08da0a..fb08ff4ab 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1137,6 +1137,8 @@ void M_DrawAddons(void); #define CC_ANIM 3 #define CC_MAX 4 +#define TILEFLIP_MAX 16 + // Keep track of some pause menu data for visual goodness. extern struct challengesmenu_s { diff --git a/src/k_menudraw.c b/src/k_menudraw.c index fc44aadde..5f5f69726 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4518,7 +4518,7 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili unlockable_t *ref = NULL; patch_t *pat = missingpat; UINT8 *colormap = NULL, *bgmap = NULL; - fixed_t siz; + fixed_t siz, accordion; UINT8 id, num; boolean unlockedyet; boolean categoryside; @@ -4569,14 +4569,26 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili goto drawborder; } + accordion = FRACUNIT; + + if (challengesmenu.extradata[id].flip != 0 + && challengesmenu.extradata[id].flip != (TILEFLIP_MAX/2)) + { + angle_t bad = (FixedAngle((fixed_t)(challengesmenu.extradata[id].flip) * (360*FRACUNIT/TILEFLIP_MAX)) >> ANGLETOFINESHIFT) & FINEMASK; + accordion = FINECOSINE(bad); + if (accordion < 0) + accordion = -accordion; + } + pat = W_CachePatchName( (ref->majorunlock ? "UN_BORDB" : "UN_BORDA"), PU_CACHE); bgmap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_SILVER, GTC_MENUCACHE); - V_DrawFixedPatch( - x*FRACUNIT, y*FRACUNIT, + V_DrawStretchyFixedPatch( + (x*FRACUNIT) + (SHORT(pat->width)*(FRACUNIT-accordion)/2), y*FRACUNIT, + accordion, FRACUNIT, 0, pat, bgmap @@ -4584,7 +4596,8 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili pat = missingpat; - categoryside = !hili; // temporary + categoryside = (challengesmenu.extradata[id].flip <= TILEFLIP_MAX/4 + || challengesmenu.extradata[id].flip > (3*TILEFLIP_MAX)/4); if (categoryside) { @@ -4725,8 +4738,9 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili ; // prevent div/0 else if (ref->majorunlock) { - V_DrawFixedPatch( - (x + 5)*FRACUNIT, (y + 5)*FRACUNIT, + V_DrawStretchyFixedPatch( + ((x + 5)*FRACUNIT) + (32*(FRACUNIT-accordion)/2), (y + 5)*FRACUNIT, + FixedDiv(32*accordion, siz), FixedDiv(32 << FRACBITS, siz), 0, pat, colormap @@ -4734,8 +4748,9 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili } else { - V_DrawFixedPatch( - (x + 2)*FRACUNIT, (y + 2)*FRACUNIT, + V_DrawStretchyFixedPatch( + ((x + 2)*FRACUNIT) + (16*(FRACUNIT-accordion)/2), (y + 2)*FRACUNIT, + FixedDiv(16*accordion, siz), FixedDiv(16 << FRACBITS, siz), 0, pat, colormap diff --git a/src/m_cond.h b/src/m_cond.h index f8fa531d2..367f3d720 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -197,6 +197,7 @@ void M_PopulateChallengeGrid(void); struct challengegridextradata_t { UINT8 flags; + UINT8 flip; }; void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata); diff --git a/src/menus/extras-challenges.c b/src/menus/extras-challenges.c index fb8598eff..a9d056cd4 100644 --- a/src/menus/extras-challenges.c +++ b/src/menus/extras-challenges.c @@ -84,6 +84,16 @@ static void M_ChallengesAutoFocus(UINT8 unlockid, boolean fresh) challengesmenu.col = challengesmenu.hilix = i/CHALLENGEGRIDHEIGHT; challengesmenu.row = challengesmenu.hiliy = i%CHALLENGEGRIDHEIGHT; + // Begin animation + if (challengesmenu.extradata[i].flip == 0) + { + challengesmenu.extradata[i].flip = + (challengesmenu.pending + ? (TILEFLIP_MAX/2) + : 1 + ); + } + if (fresh) { // We're just entering the menu. Immediately jump to the desired position... @@ -261,7 +271,8 @@ void M_Challenges(INT32 choice) void M_ChallengesTick(void) { const UINT8 pid = 0; - UINT8 i, newunlock = MAXUNLOCKABLES; + UINT16 i; + UINT8 newunlock = MAXUNLOCKABLES; // Ticking challengesmenu.ticker++; @@ -275,6 +286,29 @@ void M_ChallengesTick(void) challengesmenu.unlockcount[CC_ANIM]--; M_CupSelectTick(); + // Update tile flip state. + if (challengesmenu.extradata != NULL) + { + UINT16 id = (challengesmenu.hilix * CHALLENGEGRIDHEIGHT) + challengesmenu.hiliy; + boolean seeeveryone = M_MenuButtonHeld(pid, MBT_R); + boolean allthewaythrough; + UINT8 maxflip; + for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++) + { + allthewaythrough = (!seeeveryone && !challengesmenu.pending && i != id); + maxflip = ((seeeveryone || !allthewaythrough) ? (TILEFLIP_MAX/2) : TILEFLIP_MAX); + if ((seeeveryone || (challengesmenu.extradata[i].flip > 0)) + && (challengesmenu.extradata[i].flip != maxflip)) + { + challengesmenu.extradata[i].flip++; + if (challengesmenu.extradata[i].flip >= TILEFLIP_MAX) + { + challengesmenu.extradata[i].flip = 0; + } + } + } + } + if (challengesmenu.pending) { // Pending mode. @@ -594,8 +628,14 @@ boolean M_ChallengesInputs(INT32 ch) challengesmenu.hilix = gamedata->challengegridwidth-1; } } + + i = (challengesmenu.hilix * CHALLENGEGRIDHEIGHT) + challengesmenu.hiliy; } + // Begin animation + if (challengesmenu.extradata[i].flip == 0) + challengesmenu.extradata[i].flip++; + return true; } From 182768aa32cbd7d7709aee815b74e43d6f6f93eb Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 25 Feb 2023 00:33:56 +0000 Subject: [PATCH 13/13] Unlockable sounds updated - Use sfx_achiev when any Challenge is completed - If picking up MT_EMBLEM *doesn't* immediately complete a challenge, use sfx_ncitem as before - Bugfix: this sound is played even when online, which it wasn't previously doing (because the object couldn't be destroyed and play its sound) --- src/info.c | 2 +- src/m_cond.c | 2 +- src/p_inter.c | 3 ++- src/sounds.c | 1 + src/sounds.h | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index 2c22b4bf4..4807869e6 100644 --- a/src/info.c +++ b/src/info.c @@ -8037,7 +8037,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // missilestate S_SPRK1, // deathstate S_NULL, // xdeathstate - sfx_ncitem, // deathsound + sfx_None, // deathsound 1, // speed 16*FRACUNIT, // radius 30*FRACUNIT, // height diff --git a/src/m_cond.c b/src/m_cond.c index f948f400d..070c5b9ea 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -912,7 +912,7 @@ boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud) { if (loud) { - S_StartSound(NULL, sfx_ncitem); + S_StartSound(NULL, sfx_achiev); } return true; } diff --git a/src/p_inter.c b/src/p_inter.c index 64f96100a..25ddaa59b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -552,7 +552,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (P_IsLocalPlayer(player) && !gamedata->collected[special->health-1]) { gamedata->collected[special->health-1] = gotcollected = true; - M_UpdateUnlockablesAndExtraEmblems(true); + if (!M_UpdateUnlockablesAndExtraEmblems(true)) + S_StartSound(NULL, sfx_ncitem); G_SaveGameData(); } diff --git a/src/sounds.c b/src/sounds.c index 207d2713c..0fc59206a 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1101,6 +1101,7 @@ sfxinfo_t S_sfx[NUMSFX] = {"typri1", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SA2 boss typewriting 1 {"typri2", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SA2 final boss-type typewriting {"eggspr", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Sonic Unleashed Trap Spring + {"achiev", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Achievement"}, // SRB2Kart - Drop target sounds {"kdtrg1", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Low energy, SF_X8AWAYSOUND diff --git a/src/sounds.h b/src/sounds.h index b6f910c6f..46f1eedf8 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1168,6 +1168,7 @@ typedef enum sfx_typri1, sfx_typri2, sfx_eggspr, + sfx_achiev, // SRB2Kart - Drop target sounds sfx_kdtrg1,