shithub: choc

Download patch

ref: 350fe185784d6d0350ed8b675630440ff425a6ca
parent: 69b0c4526e6f2d6fe6920f1efa3b32e27b3db0bc
author: Simon Howard <[email protected]>
date: Tue Sep 23 13:54:13 EDT 2008

Add heretic key controls to config file list. Add key binding code to
heretic/d_main.c and change g_game.c to use the common definitions.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1265

--- a/src/heretic/ct_chat.h
+++ b/src/heretic/ct_chat.h
@@ -24,6 +24,9 @@
 // Chat mode stuff
 //
 
+#ifndef HERETIC_CT_CHAT_H
+#define HERETIC_CT_CHAT_H
+
 #define CT_PLR_GREEN	1
 #define CT_PLR_YELLOW	2
 #define CT_PLR_RED		3
@@ -35,3 +38,8 @@
 #define CT_KEY_RED		'r'
 #define CT_KEY_BLUE		'b'
 #define CT_KEY_ALL		't'
+
+extern char *chat_macros[10];
+
+#endif /* #ifndef HERETIC_CT_CHAT_H */
+
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -26,9 +26,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "ct_chat.h"
 #include "doomdef.h"
+#include "i_system.h"
 #include "i_video.h"
 #include "m_argv.h"
+#include "m_config.h"
+#include "m_controls.h"
 #include "p_local.h"
 #include "s_sound.h"
 #include "v_video.h"
@@ -701,6 +705,35 @@
     exit(1);
 }
 #endif
+
+//
+// Add configuration file variable bindings.
+//
+
+void D_BindVariables(void)
+{
+    extern int screenblocks;
+    extern int snd_Channels;
+    int i;
+
+    I_BindVariables();
+    M_BindBaseControls();
+    M_BindHereticControls();
+
+    M_BindVariable("mouse_sensitivity",      &mouseSensitivity);
+    M_BindVariable("sfx_volume",             &snd_MaxVolume);
+    M_BindVariable("music_volume",           &snd_MusicVolume);
+    M_BindVariable("screenblocks",           &screenblocks);
+    M_BindVariable("snd_channels",           &snd_Channels);
+
+    for (i=0; i<10; ++i)
+    {
+        char buf[12];
+
+        sprintf(buf, "chatmacro%i", i);
+        M_BindVariable(buf, &chat_macros[i]);
+    }
+}
 
 //---------------------------------------------------------------------------
 //
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -29,6 +29,7 @@
 #include "doomkeys.h"
 #include "i_timer.h"
 #include "i_system.h"
+#include "m_controls.h"
 #include "m_misc.h"
 #include "m_random.h"
 #include "p_local.h"
@@ -134,21 +135,6 @@
 //
 // controls (have defaults)
 //
-int key_right, key_left, key_up, key_down;
-int key_strafeleft, key_straferight;
-int key_fire, key_use, key_strafe, key_speed;
-int key_flyup, key_flydown, key_flycenter;
-int key_lookup, key_lookdown, key_lookcenter;
-int key_invleft, key_invright, key_useartifact;
-
-int mousebfire;
-int mousebstrafe;
-int mousebforward;
-
-int joybfire;
-int joybstrafe;
-int joybuse;
-int joybspeed;
 
 
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -174,6 +174,60 @@
     CONFIG_VARIABLE_KEY(key_straferight),
 
     //!
+    // Keyboard key to fly upward.
+    //
+
+    CONFIG_VARIABLE_KEY(key_flyup),
+
+    //!
+    // Keyboard key to fly downwards.
+    //
+
+    CONFIG_VARIABLE_KEY(key_flydown),
+    
+    //!
+    // Keyboard key to center flying.
+    //
+
+    CONFIG_VARIABLE_KEY(key_flycenter),
+
+    //!
+    // Keyboard key to look up.
+    //
+
+    CONFIG_VARIABLE_KEY(key_lookup),
+
+    //!
+    // Keyboard key to look down.
+    //
+
+    CONFIG_VARIABLE_KEY(key_lookdown),
+
+    //!
+    // Keyboard key to center the view.
+    //
+
+    CONFIG_VARIABLE_KEY(key_lookcenter),
+
+    //!
+    // Keyboard key to scroll left in the inventory.
+    //
+
+    CONFIG_VARIABLE_KEY(key_invleft),
+
+    //!
+    // Keyboard key to scroll right in the inventory.
+    //
+
+    CONFIG_VARIABLE_KEY(key_invright),
+
+    //!
+    // Keyboard key to use the current item in the inventory.
+    //
+
+    CONFIG_VARIABLE_KEY(key_useartifact),
+
+    //!
     // Keyboard key to fire the currently selected weapon.
     //
 
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -41,7 +41,23 @@
 int key_use = ' ';
 int key_strafe = KEY_RALT;
 int key_speed = KEY_RSHIFT; 
+
+// 
+// Heretic keyboard controls
+//
  
+int key_flyup = KEY_PGUP;
+int key_flydown = KEY_INS;
+int key_flycenter = KEY_HOME;
+
+int key_lookup = KEY_PGDN;
+int key_lookdown = KEY_DEL;
+int key_lookcenter = KEY_END;
+
+int key_invleft = '[';
+int key_invright = ']';
+int key_useartifact = KEY_ENTER;
+
 //
 // Mouse controls
 //
@@ -114,5 +130,20 @@
     M_BindVariable("mouseb_backward",    &mousebbackward);
     M_BindVariable("dclick_use",         &dclick_use);
     M_BindVariable("novert",             &novert);
+}
+
+void M_BindHereticControls(void)
+{
+    M_BindVariable("key_flyup",          &key_flyup);
+    M_BindVariable("key_flydown",        &key_flydown);
+    M_BindVariable("key_flycenter",      &key_flycenter);
+
+    M_BindVariable("key_lookup",         &key_lookup);
+    M_BindVariable("key_lookdown",       &key_lookdown);
+    M_BindVariable("key_lookcenter",     &key_lookcenter);
+
+    M_BindVariable("key_invleft",        &key_invleft);
+    M_BindVariable("key_invright",       &key_invright);
+    M_BindVariable("key_useartifact",    &key_useartifact);
 }
 
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -35,6 +35,16 @@
 extern int key_use;
 extern int key_strafe;
 extern int key_speed;
+
+extern int key_flyup;
+extern int key_flydown;
+extern int key_flycenter;
+extern int key_lookup;
+extern int key_lookdown;
+extern int key_lookcenter;
+extern int key_invleft;
+extern int key_invright;
+extern int key_useartifact;
  
 extern int mousebfire;
 extern int mousebstrafe;
@@ -56,6 +66,7 @@
 extern int novert;
  
 void M_BindBaseControls(void);
+void M_BindHereticControls(void);
 
 #endif /* #ifndef __M_CONTROLS_H__ */