shithub: choc

Download patch

ref: 9af0a3c8fd56dcf170698c3867a376a822f39d08
parent: df88eb04af3ec3b4abf8d4d4befa580d818902b9
author: Simon Howard <[email protected]>
date: Sat Sep 24 13:55:32 EDT 2011

Add -testcontrols to Hexen.

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

--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -175,6 +175,9 @@
 static int TempEpisode;
 static int TempMap;
 
+boolean testcontrols = false;
+int testcontrols_mousespeed;
+
 //=============================================================================
 /*
 ====================
@@ -535,6 +538,12 @@
     {
         cmd->angleturn -= mousex * 0x8;
     }
+
+    if (mousex == 0)
+    {
+        testcontrols_mousespeed = 0;
+    }
+
     forward += mousey;
     mousex = mousey = 0;
 
@@ -632,6 +641,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);
+    }
 }
 
 
@@ -691,6 +705,11 @@
         {                       // Automap ate the event
             return (true);
         }
+    }
+
+    if (ev->type == ev_mouse)
+    {
+        testcontrols_mousespeed = abs(ev->data2);
     }
 
     switch (ev->type)
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -92,6 +92,7 @@
 static void ExecOptionSCRIPTS(char **args, int tag);
 static void ExecOptionSKILL(char **args, int tag);
 static void ExecOptionPLAYDEMO(char **args, int tag);
+static void ExecOptionTestControls(char **args, int tag);
 static void CreateSavePath(void);
 static void WarpCheck(void);
 
@@ -137,6 +138,7 @@
     {"-skill", ExecOptionSKILL, 1, 0},
     {"-playdemo", ExecOptionPLAYDEMO, 1, 0},
     {"-timedemo", ExecOptionPLAYDEMO, 1, 0},
+    {"-testcontrols", ExecOptionTestControls, 0, 0},
     {NULL, NULL, 0, 0}          // Terminator
 };
 
@@ -517,6 +519,18 @@
 
 //==========================================================================
 //
+// ExecOptionTestControls
+//
+//==========================================================================
+
+static void ExecOptionTestControls(char **args, int tag)
+{
+    autostart = true;
+    testcontrols = true;
+}
+
+//==========================================================================
+//
 // ExecOptionSCRIPTS
 //
 //==========================================================================
@@ -654,6 +668,11 @@
         case GS_DEMOSCREEN:
             PageDrawer();
             break;
+    }
+
+    if (testcontrols)
+    {
+        V_DrawMouseSpeedBox(testcontrols_mousespeed);
     }
 
     if (paused && !MenuActive && !askforquit)
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -739,6 +739,9 @@
 extern int startmap;
 extern boolean autostart;
 
+extern boolean testcontrols;
+extern int testcontrols_mousespeed;
+
 /*
 ===============================================================================
 
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -1142,6 +1142,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)
     {