From 5655db11abc113b0e7075070116e5cfaebb4e44e Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 21 Jun 2020 09:30:55 +0200 Subject: [PATCH 1/2] Tweak display of hidden items in "1 Player" menu If an option in the "1 Player" menu is unavailable in an add-on, lower the above options to close the gap from the invisible option Also make Marathon Run display as question marks if locked And also change "sploadgame" to "spstartgame" --- src/m_menu.c | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 61b41d75b..e9c214019 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -761,14 +761,14 @@ static menuitem_t SP_MainMenu[] = {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 76}, {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 84}, {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 92}, - {IT_CALL | IT_STRING | IT_CALL_NOTMODIFIED, NULL, "Marathon Run", M_Marathon, 100}, + {IT_SECRET, NULL, "Marathon Run", M_Marathon, 100}, {IT_CALL | IT_STRING, NULL, "Tutorial", M_StartTutorial, 108}, {IT_CALL | IT_STRING | IT_CALL_NOTMODIFIED, NULL, "Statistics", M_Statistics, 116} }; enum { - sploadgame, + spstartgame, sprecordattack, spnightsmode, spmarathon, @@ -8040,29 +8040,55 @@ static void M_SinglePlayerMenu(INT32 choice) { (void)choice; + levellistmode = LLM_RECORDATTACK; if (M_GametypeHasLevels(-1)) SP_MainMenu[sprecordattack].status = (M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING : IT_SECRET; - else - SP_MainMenu[sprecordattack].status = IT_NOTHING|IT_DISABLED; + else // If Record Attack is nonexistent in the current add-on... + { + SP_MainMenu[sprecordattack].status = IT_NOTHING|IT_DISABLED; // ...hide and disable the Record Attack option... + SP_MainMenu[spstartgame].alphaKey += 8; // ...and lower Start Game by 8 pixels to close the gap + } + levellistmode = LLM_NIGHTSATTACK; if (M_GametypeHasLevels(-1)) SP_MainMenu[spnightsmode].status = (M_SecretUnlocked(SECRET_NIGHTSMODE)) ? IT_CALL|IT_STRING : IT_SECRET; - else - SP_MainMenu[spnightsmode].status = IT_NOTHING|IT_DISABLED; + else // If NiGHTS Mode is nonexistent in the current add-on... + { + SP_MainMenu[spnightsmode].status = IT_NOTHING|IT_DISABLED; // ...hide and disable the NiGHTS Mode option... + // ...and lower the above options' display positions by 8 pixels to close the gap + SP_MainMenu[spstartgame] .alphaKey += 8; + SP_MainMenu[sprecordattack].alphaKey += 8; + } - SP_MainMenu[sptutorial].status = tutorialmap ? IT_CALL|IT_STRING : IT_NOTHING|IT_DISABLED; // If the FIRST stage immediately leads to the ending, or itself (which gets converted to the title screen in G_DoCompleted for marathonmode only), there's no point in having this option on the menu. You should use Record Attack in that circumstance, although if marathonnext is set this behaviour can be overridden if you make some weird mod that requires multiple playthroughs of the same map in sequence and has some in-level mechanism to break the cycle. - if (!M_SecretUnlocked(SECRET_RECORDATTACK) // also if record attack is locked - || (mapheaderinfo[spmarathon_start-1] + if (mapheaderinfo[spmarathon_start-1] && !mapheaderinfo[spmarathon_start-1]->marathonnext && (mapheaderinfo[spmarathon_start-1]->nextlevel == spmarathon_start - || mapheaderinfo[spmarathon_start-1]->nextlevel >= 1100))) - SP_MainMenu[spmarathon].status = IT_NOTHING|IT_DISABLED; - else - SP_MainMenu[spmarathon].status = IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED; + || mapheaderinfo[spmarathon_start-1]->nextlevel >= 1100)) + { + SP_MainMenu[spmarathon].status = IT_NOTHING|IT_DISABLED; // Hide and disable the Marathon Run option... + // ...and lower the above options' display positions by 8 pixels to close the gap + SP_MainMenu[spstartgame] .alphaKey += 8; + SP_MainMenu[sprecordattack].alphaKey += 8; + SP_MainMenu[spnightsmode] .alphaKey += 8; + } + else if (M_SecretUnlocked(SECRET_RECORDATTACK)) // Otherwise, if Marathon Run is allowed and Record Attack is unlocked... + SP_MainMenu[spmarathon].status = IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED; // ...unlock Marathon Run! + + + if (!tutorialmap) // If there's no tutorial available in the current add-on... + { + SP_MainMenu[sptutorial].status = IT_NOTHING|IT_DISABLED; // ...hide and disable the Tutorial option... + // ...and lower the above options' display positions by 8 pixels to close the gap + SP_MainMenu[spstartgame] .alphaKey += 8; + SP_MainMenu[sprecordattack].alphaKey += 8; + SP_MainMenu[spnightsmode] .alphaKey += 8; + SP_MainMenu[spmarathon] .alphaKey += 8; + } + M_SetupNextMenu(&SP_MainDef); } From ae474b6945f3aae3f5d289207d5b655d011f0d03 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 21 Jun 2020 16:16:12 +0200 Subject: [PATCH 2/2] Fix re-opening 1 Player menu re-lowering options If an add-on disabled an option, re-opening the 1 Player menu multiple times would lower the above options multiple times Also fix Marathon Run and Tutorial being "perma-(un)lock"-able --- src/m_menu.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e9c214019..ed04d402b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -758,6 +758,7 @@ static menuitem_t SR_EmblemHintMenu[] = // Single Player Main static menuitem_t SP_MainMenu[] = { + // Note: If changing the positions here, also change them in M_SinglePlayerMenu() {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 76}, {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 84}, {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 92}, @@ -8041,6 +8042,16 @@ static void M_SinglePlayerMenu(INT32 choice) (void)choice; + // Reset the item positions, to avoid them sinking farther down every time the menu is opened if one is unavailable + // Note that they're reset, not simply "not moved again", in case mid-game add-ons re-enable an option + SP_MainMenu[spstartgame] .alphaKey = 76; + SP_MainMenu[sprecordattack].alphaKey = 84; + SP_MainMenu[spnightsmode] .alphaKey = 92; + SP_MainMenu[spmarathon] .alphaKey = 100; + //SP_MainMenu[sptutorial] .alphaKey = 108; // Not needed + //SP_MainMenu[spstatistics].alphaKey = 116; // Not needed + + levellistmode = LLM_RECORDATTACK; if (M_GametypeHasLevels(-1)) SP_MainMenu[sprecordattack].status = (M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING : IT_SECRET; @@ -8075,11 +8086,13 @@ static void M_SinglePlayerMenu(INT32 choice) SP_MainMenu[sprecordattack].alphaKey += 8; SP_MainMenu[spnightsmode] .alphaKey += 8; } - else if (M_SecretUnlocked(SECRET_RECORDATTACK)) // Otherwise, if Marathon Run is allowed and Record Attack is unlocked... - SP_MainMenu[spmarathon].status = IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED; // ...unlock Marathon Run! + else // Otherwise, if Marathon Run is allowed and Record Attack is unlocked, unlock Marathon Run! + SP_MainMenu[spmarathon].status = (M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED : IT_SECRET; - if (!tutorialmap) // If there's no tutorial available in the current add-on... + if (tutorialmap) // If there's a tutorial available in the current add-on... + SP_MainMenu[sptutorial].status = IT_CALL | IT_STRING; // ...always unlock Tutorial + else // But if there's no tutorial available in the current add-on... { SP_MainMenu[sptutorial].status = IT_NOTHING|IT_DISABLED; // ...hide and disable the Tutorial option... // ...and lower the above options' display positions by 8 pixels to close the gap