From 75326ca2eee7fbc48aa744d3e0ddae63b7a8a82c Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 22 Jun 2020 17:14:01 -0700 Subject: [PATCH] Save BG vars to temp vars when entering menu and revert them upon exit Since the exact same tower background is also used on the menu, we need to save the current state of the background when entering the menu (before overwriting it), and then put it back when we're done. Maybe we ought to separate the in-game and menu tower backgrounds... This also fixes a semi-hilarious bug where you could make Panic Room go in the other direction by simply going to the options menu in-game. This is accomplished by adding convenience functions mapclass::bg_to_kludge() and mapclass::kludge_to_bg(). --- desktop_version/src/Input.cpp | 4 ++++ desktop_version/src/Map.h | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 2f417651..f78ad935 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -380,6 +380,7 @@ void menuactionpress() { game.ingame_titlemode = false; game.gamestate = MAPMODE; + map.kludge_to_bg(); } else { @@ -594,6 +595,7 @@ void menuactionpress() { game.ingame_titlemode = false; game.gamestate = MAPMODE; + map.kludge_to_bg(); } else { @@ -2119,6 +2121,8 @@ void mapmenuactionpress() { game.createmenu(Menu::options); } + map.bg_to_kludge(); + map.nexttowercolour(); map.scrolldir = 0; diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index 5ef7e64d..79536310 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -168,6 +168,22 @@ public: //Map cursor int cursorstate, cursordelay; + + int kludge_bypos; + int kludge_colstate; + int kludge_scrolldir; + void inline bg_to_kludge() + { + kludge_bypos = bypos; + kludge_colstate = colstate; + kludge_scrolldir = scrolldir; + } + void inline kludge_to_bg() + { + bypos = kludge_bypos; + colstate = kludge_colstate; + scrolldir = kludge_scrolldir; + } }; extern mapclass map;