foxygit / doom Log in
commit 6e9b549b678a6b8abfedeab62e93214ccb4f08ac
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Sep 24 18:31:57 2011 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Sep 24 18:31:57 2011 +0000

    Don't allow menu actions when running with -testcontrols. Quit
    immediately when pressing the window close button.

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2400
---
 src/doom/m_menu.c     | 30 ++++++++++++++++--------------
 src/heretic/mn_menu.c |  5 +++++
 src/hexen/mn_menu.c   |  5 +++++
 src/strife/m_menu.c   | 30 ++++++++++++++++--------------
 4 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c
index d1d0aa05..bae11cc8 100644
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -1428,6 +1428,22 @@ boolean M_Responder (event_t* ev)
     static  int     mousex = 0;
     static  int     lastx = 0;

+    // In testcontrols mode, none of the function keys should do anything
+    // - the only key is escape to quit.
+
+    if (testcontrols)
+    {
+        if (ev->type == ev_quit
+         || (ev->type == ev_keydown
+          && (ev->data1 == key_menu_activate || ev->data1 == key_menu_quit)))
+        {
+            I_Quit();
+            return true;
+        }
+
+        return false;
+    }
+
     // "close" button pressed on window?
     if (ev->type == ev_quit)
     {
@@ -1533,20 +1549,6 @@ boolean M_Responder (event_t* ev)
     if (key == -1)
 	return false;

-    // In testcontrols mode, none of the function keys should do anything
-    // - the only key is escape to quit.
-
-    if (testcontrols)
-    {
-        if (key == key_menu_activate || key == key_menu_quit)
-        {
-            I_Quit();
-            return true;
-        }
-
-        return false;
-    }
-
     // Save Game string input
     if (saveStringEnter)
     {
diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c
index 4d394db1..4db108cf 100644
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -1046,6 +1046,9 @@ boolean MN_Responder(event_t * event)
     extern void G_CheckDemoStatus(void);
     char *textBuffer;

+    // In testcontrols mode, none of the function keys should do anything
+    // - the only key is escape to quit.
+
     if (testcontrols)
     {
         if (event->type == ev_quit
@@ -1056,6 +1059,8 @@ boolean MN_Responder(event_t * event)
             I_Quit();
             return true;
         }
+
+        return false;
     }

     // "close" button pressed on window?
diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c
index c7a8bef9..0bd942a4 100644
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -1142,6 +1142,9 @@ boolean MN_Responder(event_t * event)
     extern void G_CheckDemoStatus(void);
     char *textBuffer;

+    // In testcontrols mode, none of the function keys should do anything
+    // - the only key is escape to quit.
+
     if (testcontrols)
     {
         if (event->type == ev_quit
@@ -1152,6 +1155,8 @@ boolean MN_Responder(event_t * event)
             I_Quit();
             return true;
         }
+
+        return false;
     }

     // "close" button pressed on window?
diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c
index 1fb3eeaf..1593bdf2 100644
--- a/src/strife/m_menu.c
+++ b/src/strife/m_menu.c
@@ -1667,6 +1667,22 @@ boolean M_Responder (event_t* ev)
     static  int     mousex = 0;
     static  int     lastx = 0;

+    // In testcontrols mode, none of the function keys should do anything
+    // - the only key is escape to quit.
+
+    if (testcontrols)
+    {
+        if (ev->type == ev_quit
+         || (ev->type == ev_keydown
+          && (ev->data1 == key_menu_activate || ev->data1 == key_menu_quit)))
+        {
+            I_Quit();
+            return true;
+        }
+
+        return false;
+    }
+
     // "close" button pressed on window?
     if (ev->type == ev_quit)
     {
@@ -1773,20 +1789,6 @@ boolean M_Responder (event_t* ev)
     if (key == -1)
         return false;

-    // In testcontrols mode, none of the function keys should do anything
-    // - the only key is escape to quit.
-
-    if (testcontrols)
-    {
-        if (key == key_menu_activate || key == key_menu_quit)
-        {
-            I_Quit();
-            return true;
-        }
-
-        return false;
-    }
-
     // Save Game string input
     if (saveStringEnter)
     {