shithub: choc

Download patch

ref: 17d75c2915ec75077e86dbd7a356061961552b53
parent: 73f27119add06b37dadc4a62343e1301585a828f
author: Simon Howard <[email protected]>
date: Sat Sep 24 13:40:59 EDT 2011

Add -testcontrols to Heretic.

Subversion-branch: /branches/v2-branch
Subversion-revision: 2396

--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -182,6 +182,11 @@
             break;
     }
 
+    if (testcontrols)
+    {
+        V_DrawMouseSpeedBox(testcontrols_mousespeed);
+    }
+
     if (paused && !MenuActive && !askforquit)
     {
         if (!netgame)
@@ -774,7 +779,7 @@
 
     // Disable ENDOOM?
 
-    if (!show_endoom)
+    if (!show_endoom || testcontrols)
     {
         return;
     }
@@ -1034,6 +1039,14 @@
 	filename = SV_Filename(myargv[p + 1][0] - '0');
         G_LoadGame(filename);
 	free(filename);
+    }
+
+    if (M_ParmExists("-testcontrols"))
+    {
+        startepisode = 1;
+        startmap = 1;
+        autostart = true;
+        testcontrols = true;
     }
 
     // Check valid episode and map
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -631,6 +631,9 @@
 extern int startmap;
 extern boolean autostart;
 
+extern boolean testcontrols;
+extern int testcontrols_mousespeed;
+
 /*
 ===============================================================================
 
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -137,7 +137,10 @@
 char *savegamedir;
 byte *savebuffer, *save_p;
 
+boolean testcontrols = false;
+int testcontrols_mousespeed;
 
+
 //
 // controls (have defaults)
 //
@@ -501,6 +504,13 @@
         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 @@
     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)
@@ -653,6 +668,11 @@
         {                       // Automap ate the event
             return (true);
         }
+    }
+
+    if (ev->type == ev_mouse)
+    {
+        testcontrols_mousespeed = abs(ev->data2);
     }
 
     switch (ev->type)
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -1046,6 +1046,18 @@
     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)
     {
--- 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 @@
     // 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);