From 5b1016465940bde81f36713f6a3317289ab78a7a Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 2 Sep 2021 12:21:46 -0700 Subject: [PATCH] Prevent user-initiated map menu changes during menu animations This makes it so it's not even possible to stay on the TELEPORTERMODE screen by opening the map while it's being brought down. It also makes it so the map animation is able to be canceled when being brought up just by opening the map and closing it. Fixes #833. --- desktop_version/src/Game.cpp | 9 ++++++++- desktop_version/src/Game.h | 2 +- desktop_version/src/Input.cpp | 8 ++++---- desktop_version/src/Script.cpp | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 4d8dc244..968dce0e 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6857,8 +6857,15 @@ void Game::unlockAchievement(const char *name) { #endif } -void Game::mapmenuchange(const int newgamestate) +void Game::mapmenuchange(const int newgamestate, const bool user_initiated) { + if (user_initiated + && graphics.menuoffset > 0 + && graphics.menuoffset < (map.extrarow ? 230 : 240)) + { + return; + } + prevgamestate = gamestate; gamestate = newgamestate; graphics.resumegamemode = false; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 7baa1c53..07493cf7 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -245,7 +245,7 @@ public: int tapleft, tapright; //Menu interaction stuff - void mapmenuchange(const int newgamestate); + void mapmenuchange(const int newgamestate, const bool user_initiated); bool mapheld; int menupage; int lastsaved; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index fabf0b5e..7277389f 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2128,7 +2128,7 @@ void gameinput(void) else if (game.companion == 0) { //Alright, normal teleporting - game.mapmenuchange(TELEPORTERMODE); + game.mapmenuchange(TELEPORTERMODE, true); game.useteleporter = true; game.initteleportermode(); @@ -2315,7 +2315,7 @@ void gameinput(void) //quitting the super gravitron game.mapheld = true; //Quit menu, same conditions as in game menu - game.mapmenuchange(MAPMODE); + game.mapmenuchange(MAPMODE, true); game.gamesaved = false; game.gamesavefailed = false; game.menupage = 20; // The Map Page @@ -2335,7 +2335,7 @@ void gameinput(void) else { //Normal map screen, do transition later - game.mapmenuchange(MAPMODE); + game.mapmenuchange(MAPMODE, true); map.cursordelay = 0; map.cursorstate = 0; game.gamesaved = false; @@ -2356,7 +2356,7 @@ void gameinput(void) { game.mapheld = true; //Quit menu, same conditions as in game menu - game.mapmenuchange(MAPMODE); + game.mapmenuchange(MAPMODE, true); game.gamesaved = false; game.gamesavefailed = false; game.menupage = 30; // Pause screen diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 54dec167..62a100a2 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -1115,7 +1115,7 @@ void scriptclass::run(void) { if (words[1] == "teleporter") { - game.mapmenuchange(TELEPORTERMODE); + game.mapmenuchange(TELEPORTERMODE, false); game.useteleporter = false; //good heavens don't actually use it }