From f9e0c0a4449b4b417003f3ad73a451dbc25754fe Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 4 Jan 2023 17:22:57 +0000 Subject: [PATCH 1/6] Challenges menu visual adjustment * Use the new background * Use clipped rectangles instead of black pixel overdraw, so pre-baked darkened areas in the new background can be visible instead --- src/k_menudraw.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 0f1514cba..3a2a5d078 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1926,8 +1926,6 @@ static void M_DrawCupPreview(INT16 y, levelsearch_t *levelsearch) INT16 map, start = M_GetFirstLevelInList(&i, levelsearch); UINT8 starti = i; - V_DrawFill(0, y, BASEVIDWIDTH, 54, 31); - if (levelsearch->cup && maxlevels > 0) { add = (cupgrid.previewanim / 82) % maxlevels; @@ -2060,7 +2058,9 @@ void M_DrawCupSelect(void) templevelsearch.cup = cupgrid.builtgrid[CUPMENU_CURSORID]; + V_DrawFill(0, 146 + (24*menutransition.tics), BASEVIDWIDTH, 54, 31); M_DrawCupPreview(146 + (24*menutransition.tics), &templevelsearch); + M_DrawCupTitle(120 - (24*menutransition.tics), &templevelsearch); } @@ -4518,7 +4518,8 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili patch_t *pat = missingpat; UINT8 *colormap = NULL; fixed_t siz; - UINT8 id, num, work; + UINT8 id, num; + UINT32 edgelength; id = (i * CHALLENGEGRIDHEIGHT) + j; num = gamedata->challengegrid[id]; @@ -4526,19 +4527,19 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili // Empty spots in the grid are always unconnected. if (num >= MAXUNLOCKABLES) { - V_DrawFill(x, y, 16, 16, challengesbordercolor); goto drawborder; } // Okay, this is what we want to draw. ref = &unlockables[num]; + edgelength = (ref->majorunlock ? 30 : 14); + // ...unless we simply aren't unlocked yet. if ((gamedata->unlocked[num] == false) || (challengesmenu.pending && num == challengesmenu.currentunlock && challengesmenu.unlockanim <= UNLOCKTIME)) { - work = (ref->majorunlock) ? 2 : 1; - V_DrawFill(x, y, 16*work, 16*work, + V_DrawFill(x+1, y+1, edgelength, edgelength, ((challengesmenu.extradata[id] == CHE_HINT) ? 132 : 11)); goto drawborder; } @@ -4589,6 +4590,12 @@ 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, @@ -4596,19 +4603,11 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili colormap ); + V_ClearClipRect(); + drawborder: if (!hili) { - if (ref != NULL) - { - work = 16 * (ref->majorunlock ? 2 : 1); - // Horizontal - V_DrawFill(x, y , work, 1, challengesbordercolor); - V_DrawFill(x, y + work-1, work, 1, challengesbordercolor); - // Vertical - V_DrawFill(x , y+1, 1, work-2, challengesbordercolor); - V_DrawFill(x + work-1, y+1, 1, work-2, challengesbordercolor); - } return; } @@ -4628,7 +4627,6 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) if (challengesmenu.currentunlock >= MAXUNLOCKABLES) { - V_DrawFill(0, 146, BASEVIDWIDTH, 54, challengesbordercolor); return; } @@ -4638,13 +4636,9 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) if (!gamedata->unlocked[challengesmenu.currentunlock]) { // todo draw some sort of question mark? - V_DrawFill(0, 146, BASEVIDWIDTH, 54, challengesbordercolor); return; } - if (ref->type != SECRET_CUP) - V_DrawFill(0, 146, BASEVIDWIDTH, 54, challengesbordercolor); - switch (ref->type) { case SECRET_SKIN: @@ -4812,7 +4806,7 @@ void M_DrawChallenges(void) INT16 offset; { - patch_t *bg = W_CachePatchName("M_XTRABG", PU_CACHE); + patch_t *bg = W_CachePatchName("BGUNLCK2", PU_CACHE); V_DrawFixedPatch(0, 0, FRACUNIT, 0, bg, NULL); } @@ -4847,15 +4841,10 @@ void M_DrawChallenges(void) i = gamedata->challengegridwidth-1; explodex = x - (i*16)/2; x += (i*16)/2; - - V_DrawFill(0, currentMenu->y, explodex, (CHALLENGEGRIDHEIGHT*16), challengesbordercolor); - V_DrawFill((x+16), currentMenu->y, BASEVIDWIDTH - (x+16), (CHALLENGEGRIDHEIGHT*16), challengesbordercolor); } selectx = explodex + (challengesmenu.hilix*16); - V_DrawFill(0, (currentMenu->y)-1 , BASEVIDWIDTH, 1, challengesbordercolor); - V_DrawFill(0, (currentMenu->y) + (CHALLENGEGRIDHEIGHT*16), BASEVIDWIDTH, 1, challengesbordercolor); while (i >= 0 && x >= -32) { y = currentMenu->y-16; @@ -4910,7 +4899,6 @@ challengedesc: // Name bar { y = 120; - V_DrawScaledPatch(0, y, 0, W_CachePatchName("MENUHINT", PU_CACHE)); if (challengesmenu.currentunlock < MAXUNLOCKABLES) { From 06e7eb35671b349b497904afa065158af00aaec0 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 4 Jan 2023 17:23:18 +0000 Subject: [PATCH 2/6] Add a funny little rotating question mark ala SA1 character select --- src/info.c | 2 ++ src/info.h | 2 ++ src/k_menudraw.c | 24 +++++++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 8e3757190..7cee3d58b 100644 --- a/src/info.c +++ b/src/info.c @@ -789,6 +789,8 @@ char sprnames[NUMSPRITES + 1][5] = "UFOA", "UFOS", + "UQMK", + // First person view sprites; this is a sprite so that it can be replaced by a specialized MD2 draw later "VIEW", }; diff --git a/src/info.h b/src/info.h index d0d5228e3..9cc7a3911 100644 --- a/src/info.h +++ b/src/info.h @@ -1340,6 +1340,8 @@ typedef enum sprite SPR_UFOA, SPR_UFOS, + SPR_UQMK, + // First person view sprites; this is a sprite so that it can be replaced by a specialized MD2 draw later SPR_VIEW, diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 3a2a5d078..af7c141a2 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4633,9 +4633,31 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) // Okay, this is what we want to draw. ref = &unlockables[challengesmenu.currentunlock]; + // Funny question mark? if (!gamedata->unlocked[challengesmenu.currentunlock]) { - // todo draw some sort of question mark? + spritedef_t *sprdef = &sprites[SPR_UQMK]; + spriteframe_t *sprframe; + patch_t *patch; + UINT32 useframe; + UINT32 addflags = 0; + + if (!sprdef->numframes) + { + return; + } + + useframe = (challengesmenu.ticker / 2) % sprdef->numframes; + + sprframe = &sprdef->spriteframes[useframe]; + patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); + + if (sprframe->flip & 1) // Only for first sprite + { + addflags ^= V_FLIP; // This sprite is left/right flipped! + } + + V_DrawFixedPatch(x*FRACUNIT, (y+6)*FRACUNIT, FRACUNIT, addflags, patch, NULL); return; } From 20b6a8389b57ae4d474f1691f5cddcf63bf033df Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 4 Jan 2023 17:28:45 +0000 Subject: [PATCH 3/6] Challenge grid population improvement * Correctly identify that two columns with only one major unlock will have 6 empty tile slots, not two. This will result in less underutilised Challenges grid space. --- src/m_cond.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/m_cond.c b/src/m_cond.c index 14ad2b6b4..d93ff8d55 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -97,21 +97,27 @@ void M_PopulateChallengeGrid(void) { // Getting the number of 2-highs you can fit into two adjacent columns. UINT8 majorpad = (CHALLENGEGRIDHEIGHT/2); - majorpad = (nummajorunlocks+1)/majorpad; + numempty = nummajorunlocks%majorpad; + majorpad = (nummajorunlocks+(majorpad-1))/majorpad; gamedata->challengegridwidth = majorpad*2; + numempty *= 4; #if (CHALLENGEGRIDHEIGHT % 2) - // One empty per column. - numempty = gamedata->challengegridwidth; + // One extra empty per column. + numempty += gamedata->challengegridwidth; #endif + + //CONS_Printf("%d major unlocks means width of %d, numempty of %d\n", nummajorunlocks, gamedata->challengegridwidth, numempty); } if (numunlocks > numempty) { // Getting the number of extra columns to store normal unlocks - gamedata->challengegridwidth += ((numunlocks - numempty) + (CHALLENGEGRIDHEIGHT-1))/CHALLENGEGRIDHEIGHT; + UINT16 temp = ((numunlocks - numempty) + (CHALLENGEGRIDHEIGHT-1))/CHALLENGEGRIDHEIGHT; + gamedata->challengegridwidth += temp; majorcompact = 1; + //CONS_Printf("%d normal unlocks means %d extra entries, additional width of %d\n", numunlocks, (numunlocks - numempty), temp); } else if (challengegridloops) { From 6274b1f31f818c46893b7541101017604a83622a Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 4 Jan 2023 17:45:24 +0000 Subject: [PATCH 4/6] Fast forward through the unlock sequence by holding the Extra button. Based on VC complaints. --- src/k_menufunc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 191542ca7..28fb0b50c 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -1219,18 +1219,33 @@ static boolean M_MenuConfirmPressed(UINT8 pid) return M_MenuButtonPressed(pid, MBT_A); } +/*static boolean M_MenuConfirmHeld(UINT8 pid) +{ + return M_MenuButtonHeld(pid, MBT_A); +}*/ + // Returns true if we press the Cancel button static boolean M_MenuBackPressed(UINT8 pid) { return (M_MenuButtonPressed(pid, MBT_B) || M_MenuButtonPressed(pid, MBT_X)); } +/*static boolean M_MenuBackHeld(UINT8 pid) +{ + return (M_MenuButtonHeld(pid, MBT_B) || M_MenuButtonHeld(pid, MBT_X)); +}*/ + // Retrurns true if we press the tertiary option button (C) static boolean M_MenuExtraPressed(UINT8 pid) { return M_MenuButtonPressed(pid, MBT_C); } +static boolean M_MenuExtraHeld(UINT8 pid) +{ + return M_MenuButtonHeld(pid, MBT_C); +} + // Updates the x coordinate of the keybord so prevent it from going in weird places static void M_UpdateKeyboardX(void) @@ -7369,6 +7384,7 @@ void M_Challenges(INT32 choice) void M_ChallengesTick(void) { + const UINT8 pid = 0; UINT8 i, newunlock = MAXUNLOCKABLES; boolean fresh = (challengesmenu.currentunlock >= MAXUNLOCKABLES); @@ -7412,8 +7428,9 @@ void M_ChallengesTick(void) else { // Unlock sequence. + tic_t nexttime = M_MenuExtraHeld(pid) ? (UNLOCKTIME*2) : MAXUNLOCKTIME; - if (++challengesmenu.unlockanim >= MAXUNLOCKTIME) + if (++challengesmenu.unlockanim >= nexttime) { challengesmenu.requestnew = true; } From c628014c472d469a0b09661b69dfca892ee27969 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 4 Jan 2023 17:52:28 +0000 Subject: [PATCH 5/6] Add an extra guard for unlock condition string drawing to prevent hypothetical out of bounds read --- src/k_menudraw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index af7c141a2..6da10157a 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4950,6 +4950,7 @@ challengedesc: i = (challengesmenu.hilix * CHALLENGEGRIDHEIGHT) + challengesmenu.hiliy; if (challengesmenu.unlockcondition != NULL + && challengesmenu.currentunlock < MAXUNLOCKABLES && ((gamedata->unlocked[challengesmenu.currentunlock] == true) || ((challengesmenu.extradata != NULL) && (challengesmenu.extradata[i] & CHE_HINT)) From 91a40268711d958e06b7452764ea7494b2cce387 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 4 Jan 2023 18:04:38 +0000 Subject: [PATCH 6/6] Remove now-unused definition for challengesbordercolor --- src/k_menudraw.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 6da10157a..7cdbb91a7 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4510,8 +4510,6 @@ void M_DrawAddons(void) // Challenges Menu -#define challengesbordercolor 27 - static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili) { unlockable_t *ref = NULL;