Don't make TAB exit game if bound to inventory.
authorAuke Kok <sofar@foo-projects.org>
Sat, 15 Apr 2017 05:16:57 +0000 (22:16 -0700)
committerAuke Kok <sofar+github@foo-projects.org>
Tue, 18 Apr 2017 04:45:40 +0000 (21:45 -0700)
I play with the TAB key bound to the inventory. However, the
code here assumes that TAB means "close formspec" in all contexts,
including the main menu. This causes my game to exit when I attempt
to TAB in between USERNAME and PASSWORD fields.

We know when m_client != NULL that the game is a client game and
not in the main menu, and then it's OK to use the INVENTORY bound
key to exit the formspec, since it's not the main menu.

src/guiFormSpecMenu.cpp

index 330124fe1aebf7441a9c6531fa7e2b6de27c1f9e..3fe3c5cc2c1d59c9d184b33a554b6e7caf54ed57 100644 (file)
@@ -3296,8 +3296,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
 {
        if (event.EventType==EET_KEY_INPUT_EVENT) {
                KeyPress kp(event.KeyInput);
-               if (event.KeyInput.PressedDown && ( (kp == EscapeKey) ||
-                               (kp == getKeySetting("keymap_inventory")) || (kp == CancelKey))) {
+               if (event.KeyInput.PressedDown && (
+                               (kp == EscapeKey) || (kp == CancelKey) ||
+                               ((m_client != NULL) && (kp == getKeySetting("keymap_inventory"))))) {
                        tryClose();
                        return true;
                } else if (m_client != NULL && event.KeyInput.PressedDown &&