foxygit / doom Log in
commit 17d75c2915ec75077e86dbd7a356061961552b53
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Sep 24 17:40:59 2011 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Sep 24 17:40:59 2011 +0000

    Add -testcontrols to Heretic.

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2396
---
 src/heretic/d_main.c  | 15 ++++++++++++++-
 src/heretic/doomdef.h |  3 +++
 src/heretic/g_game.c  | 20 ++++++++++++++++++++
 src/heretic/mn_menu.c | 12 ++++++++++++
 src/v_video.c         |  3 ++-
 5 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 97eb37ed..62e4892e 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -182,6 +182,11 @@ void D_Display(void)
             break;
     }

+    if (testcontrols)
+    {
+        V_DrawMouseSpeedBox(testcontrols_mousespeed);
+    }
+
     if (paused && !MenuActive && !askforquit)
     {
         if (!netgame)
@@ -774,7 +779,7 @@ static void D_Endoom(void)

     // Disable ENDOOM?

-    if (!show_endoom)
+    if (!show_endoom || testcontrols)
     {
         return;
     }
@@ -1036,6 +1041,14 @@ void D_DoomMain(void)
 	free(filename);
     }

+    if (M_ParmExists("-testcontrols"))
+    {
+        startepisode = 1;
+        startmap = 1;
+        autostart = true;
+        testcontrols = true;
+    }
+
     // Check valid episode and map
     if (autostart || netgame)
     {
diff --git a/src/heretic/doomdef.h b/src/heretic/doomdef.h
index b2508335..12290970 100644
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -631,6 +631,9 @@ extern int startepisode;
 extern int startmap;
 extern boolean autostart;

+extern boolean testcontrols;
+extern int testcontrols_mousespeed;
+
 /*
 ===============================================================================

diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c
index 9b3e3799..ff5a79c3 100644
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -137,6 +137,9 @@ short consistancy[MAXPLAYERS][BACKUPTICS];
 char *savegamedir;
 byte *savebuffer, *save_p;

+boolean testcontrols = false;
+int testcontrols_mousespeed;
+

 //
 // controls (have defaults)
@@ -501,6 +504,13 @@ void G_BuildTiccmd(ticcmd_t * cmd)
         cmd->angleturn -= mousex * 0x8;
     }

+    // No mouse movement in previous frame?
+
+    if (mousex == 0)
+    {
+        testcontrols_mousespeed = 0;
+    }
+
     forward += mousey;
     mousex = mousey = 0;

@@ -585,6 +595,11 @@ void G_DoLoadLevel(void)
     sendpause = sendsave = paused = false;
     memset(mousebuttons, 0, sizeof(mousebuttons));
     memset(joybuttons, 0, sizeof(joybuttons));
+
+    if (testcontrols)
+    {
+        P_SetMessage(&players[consoleplayer], "PRESS ESCAPE TO QUIT.", false);
+    }
 }

 static void SetJoyButtons(unsigned int buttons_mask)
@@ -655,6 +670,11 @@ boolean G_Responder(event_t * ev)
         }
     }

+    if (ev->type == ev_mouse)
+    {
+        testcontrols_mousespeed = abs(ev->data2);
+    }
+
     switch (ev->type)
     {
         case ev_keydown:
diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c
index 930df426..4d394db1 100644
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -1046,6 +1046,18 @@ boolean MN_Responder(event_t * event)
     extern void G_CheckDemoStatus(void);
     char *textBuffer;

+    if (testcontrols)
+    {
+        if (event->type == ev_quit
+         || (event->type == ev_keydown
+          && (event->data1 == key_menu_activate
+           || event->data1 == key_menu_quit)))
+        {
+            I_Quit();
+            return true;
+        }
+    }
+
     // "close" button pressed on window?
     if (event->type == ev_quit)
     {
diff --git a/src/v_video.c b/src/v_video.c
index 97d40ec0..56207d64 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -29,6 +29,7 @@

 #include <stdio.h>
 #include <string.h>
+#include <math.h>

 #include "i_system.h"

@@ -766,7 +767,7 @@ void V_DrawMouseSpeedBox(int speed)
     // Calculate box position

     box_x = SCREENWIDTH - MOUSE_SPEED_BOX_WIDTH - 10;
-    box_y = 10;
+    box_y = 15;

     V_DrawFilledBox(box_x, box_y,
                     MOUSE_SPEED_BOX_WIDTH, MOUSE_SPEED_BOX_HEIGHT, bgcolor);