Browse Source

Automap: Don't close automap when pressing spacebar with other windows open (#6713)

* GameMenu: Add a flag to notify that game menu is on/off

This patch adds a simple flag so other source files can see if game menu
is currently off or on.

* Automap: Don't close automap when pressing space with other windows open

Currently if we open a lot of windows and have automap enabled, and we
press space - all of the windows along with automap get closed. This
patch removes that, and allows to close automap with spacebar, but only
if every window is closed.
pull/6748/head
lithraal 3 years ago committed by GitHub
parent
commit
8b141d927b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      Source/diablo.cpp
  2. 5
      Source/gamemenu.cpp
  3. 2
      Source/gamemenu.h

22
Source/diablo.cpp

@ -1581,6 +1581,18 @@ bool CanPlayerTakeAction()
{
return !IsPlayerDead() && IsGameRunning();
}
bool CanAutomapBeToggledOff()
{
// check if every window is closed - if yes, automap can be toggled off
if (!QuestLogIsOpen && !IsWithdrawGoldOpen && !IsStashOpen && !chrflag
&& !sbookflag && !invflag && !isGameMenuOpen && !qtextflag && !spselflag
&& !ChatLogFlag && !HelpFlag)
return true;
return false;
}
} // namespace
void InitKeymapActions()
@ -1757,6 +1769,9 @@ void InitKeymapActions()
N_("Hide all info screens."),
SDLK_SPACE,
[] {
if (CanAutomapBeToggledOff())
AutomapActive = false;
ClosePanels();
HelpFlag = false;
ChatLogFlag = false;
@ -1765,7 +1780,7 @@ void InitKeymapActions()
qtextflag = false;
stream_stop();
}
AutomapActive = false;
CancelCurrentDiabloMsg();
gamemenu_off();
doom_close();
@ -2231,6 +2246,9 @@ void InitPadmapActions()
N_("Hide all info screens."),
ControllerButton_NONE,
[] {
if (CanAutomapBeToggledOff())
AutomapActive = false;
ClosePanels();
HelpFlag = false;
ChatLogFlag = false;
@ -2239,7 +2257,7 @@ void InitPadmapActions()
qtextflag = false;
stream_stop();
}
AutomapActive = false;
CancelCurrentDiabloMsg();
gamemenu_off();
doom_close();

5
Source/gamemenu.cpp

@ -20,6 +20,9 @@
#include "utils/language.h"
namespace devilution {
bool isGameMenuOpen = false;
namespace {
// Forward-declare menu handlers, used by the global menu structs below.
@ -346,6 +349,7 @@ void gamemenu_save_game(bool /*bActivate*/)
void gamemenu_on()
{
isGameMenuOpen = true;
if (!gbIsMultiplayer) {
gmenu_set_items(sgSingleMenu, GamemenuUpdateSingle);
} else {
@ -356,6 +360,7 @@ void gamemenu_on()
void gamemenu_off()
{
isGameMenuOpen = false;
gmenu_set_items(nullptr, nullptr);
}

2
Source/gamemenu.h

@ -14,4 +14,6 @@ void gamemenu_quit_game(bool bActivate);
void gamemenu_load_game(bool bActivate);
void gamemenu_save_game(bool bActivate);
extern bool isGameMenuOpen;
} // namespace devilution

Loading…
Cancel
Save