From 5948168a4013bb6846482c05a6976a33a32bbda9 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 10 Jan 2024 01:33:10 -0800 Subject: [PATCH] Fix delayed notification of NDM unlock No Death Mode is intended to be unlocked by getting at least S-rank in at least 4 time trials. Before 2.3, completing a time trial put you at the main menu, so you would always be notified of having unlocked No Death Mode once you went to the play menu again. But since 2.3, completing a time trial puts you back at the Time Trial selection screen, which isn't the play menu, so you would need to back all the way out first in order to get the notification. And since you don't actually unlock No Death Mode until you see the notification, this would be required to be able to play No Death Mode. To fix this, I decided to do something a bit kludge-y and just re-use the code to check and unlock No Death Mode when the player presses ACTION on the Time Trial complete screen (and there's also another path by pressing Escape). At least I put it in a function, so it's not a pure copy-paste, although it might as well be. I don't have time to think of a proper solution, but it would probably involve disentangling unlock notifications from Menu::play, for starters. But that's for later. --- desktop_version/src/Game.cpp | 45 +++++++++++++++++++++++++---------- desktop_version/src/Game.h | 2 ++ desktop_version/src/Input.cpp | 9 +++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 60751186..7474cf73 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6206,6 +6206,7 @@ void Game::returnmenu(void) { music.play(Music_PRESENTINGVVVVVV); } + enum Menu::MenuName camefrom = currentmenuname; MenuStackFrame& frame = menustack[menustack.size()-1]; @@ -6221,6 +6222,15 @@ void Game::returnmenu(void) { menustack.pop_back(); } + + /* FIXME: Even more horrible kludge! */ + if (camefrom == Menu::timetrialcomplete3) + { + if (can_unlock_ndm()) + { + unlock_ndm(); + } + } } void Game::returntomenu(enum Menu::MenuName t) @@ -6858,20 +6868,9 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) else { //Alright, we haven't unlocked any time trials. How about no death mode? - temp = 0; - if (bestrank[TimeTrial_SPACESTATION1] >= 2) temp++; - if (bestrank[TimeTrial_LABORATORY] >= 2) temp++; - if (bestrank[TimeTrial_TOWER] >= 2) temp++; - if (bestrank[TimeTrial_SPACESTATION2] >= 2) temp++; - if (bestrank[TimeTrial_WARPZONE] >= 2) temp++; - if (bestrank[TimeTrial_FINALLEVEL] >= 2) temp++; - if (temp >= 4 && !unlocknotify[Unlock_NODEATHMODE]) + if (can_unlock_ndm()) { - //Unlock No Death Mode - unlocknotify[Unlock_NODEATHMODE] = true; - unlock[Unlock_NODEATHMODE] = true; - createmenu(Menu::unlocknodeathmode, true); - savestatsandsettings(); + unlock_ndm(); } //Alright then! Flip mode? else if (unlock[UnlockTrophy_GAME_COMPLETE] @@ -7078,6 +7077,26 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) menuxoff = (320-menuwidth)/2; } +bool Game::can_unlock_ndm(void) +{ + int temp = 0; + if (bestrank[TimeTrial_SPACESTATION1] >= 2) temp++; + if (bestrank[TimeTrial_LABORATORY] >= 2) temp++; + if (bestrank[TimeTrial_TOWER] >= 2) temp++; + if (bestrank[TimeTrial_SPACESTATION2] >= 2) temp++; + if (bestrank[TimeTrial_WARPZONE] >= 2) temp++; + if (bestrank[TimeTrial_FINALLEVEL] >= 2) temp++; + return temp >= 4 && !unlocknotify[Unlock_NODEATHMODE]; +} + +void Game::unlock_ndm(void) +{ + unlocknotify[Unlock_NODEATHMODE] = true; + unlock[Unlock_NODEATHMODE] = true; + createmenu(Menu::unlocknodeathmode, true); + savestatsandsettings(); +} + void Game::deletequick(void) { if (inspecial() || map.custommode) diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 0a7215c3..dfce1d7c 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -214,6 +214,8 @@ public: void returnmenu(void); void returntomenu(enum Menu::MenuName t); void createmenu(enum Menu::MenuName t, bool samemenu = false); + bool can_unlock_ndm(void); + void unlock_ndm(void); void lifesequence(void); diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 904071c3..aaa09e0b 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2217,6 +2217,15 @@ static void menuactionpress(void) music.play(Music_PRESENTINGVVVVVV); game.returntomenu(Menu::timetrials); map.nexttowercolour(); + + /* FIXME: This is kinda bad kludge... but if we unlocked No Death Mode + * while in a Time Trial, the player wouldn't be notified until they went + * back to Menu::play first. This is the only case where something can be + * unlocked without being immediately notified after returning to title. */ + if (game.can_unlock_ndm()) + { + game.unlock_ndm(); + } break; case 1: /* Replay time trial */