shithub: choc

Download patch

ref: 2f67325278637a349bb86fa6fc388e527a75a5c9
parent: 09f98f80fc8ed9e42ea937804618952f03244bde
author: Simon Howard <[email protected]>
date: Mon Nov 24 14:01:09 EST 2008

Make chocolate-setup use m_controls.c definitions for config file
keyboard/mouse/joystick variables. Make other configuration file
variables static and add bind functions.

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

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -150,6 +150,7 @@
 
 SETUP_FILES=                               \
 m_config.c           m_config.h            \
+m_controls.c         m_controls.h          \
 z_native.c           z_zone.h
 
 chocolate_setup_SOURCES=$(SETUP_FILES) $(COMMON_SOURCE_FILES)
--- a/src/setup/compatibility.c
+++ b/src/setup/compatibility.c
@@ -23,6 +23,7 @@
 
 #include <stdlib.h>
 
+#include "m_config.h"
 #include "textscreen.h"
 
 #include "compatibility.h"
@@ -42,5 +43,11 @@
                    TXT_NewCheckBox("Vanilla demo limit",
                                    &vanilla_demo_limit),
                    NULL);
+}
+
+void BindCompatibilityVariables(void)
+{
+    M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit);
+    M_BindVariable("vanilla_demo_limit",     &vanilla_demo_limit);
 }
 
--- a/src/setup/compatibility.h
+++ b/src/setup/compatibility.h
@@ -22,10 +22,8 @@
 #ifndef SETUP_COMPATIBILITY_H
 #define SETUP_COMPATIBILITY_H
 
-extern int vanilla_savegame_limit;
-extern int vanilla_demo_limit;
-
 void CompatibilitySettings(void);
+void BindCompatibilityVariables(void);
 
 #endif /* #ifndef SETUP_COMPATIBILITY_H */
 
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "textscreen.h"
+#include "m_config.h"
 
 #include "display.h"
 
@@ -65,14 +66,14 @@
 
 static int vidmode = 0;
 
-char *video_driver = "";
-int autoadjust_video_settings = 1;
-int aspect_ratio_correct = 1;
-int fullscreen = 1;
-int screen_width = 320;
-int screen_height = 200;
-int startup_delay = 1000;
-int show_endoom = 1;
+static char *video_driver = "";
+static int autoadjust_video_settings = 1;
+static int aspect_ratio_correct = 1;
+static int fullscreen = 1;
+static int screen_width = 320;
+static int screen_height = 200;
+static int startup_delay = 1000;
+static int show_endoom = 1;
 
 // These are the last screen width/height values that were chosen by the
 // user.  These are used when finding the "nearest" mode, so when 
@@ -434,5 +435,19 @@
     TXT_SignalConnect(ar_checkbox, "changed", GenerateModesTable, modes_table);
 
     GenerateModesTable(NULL, modes_table);
+}
+
+void BindDisplayVariables(void)
+{
+    M_BindVariable("autoadjust_video_settings", &autoadjust_video_settings);
+    M_BindVariable("aspect_ratio_correct",      &aspect_ratio_correct);
+    M_BindVariable("fullscreen",                &fullscreen);
+    M_BindVariable("screen_width",              &screen_width);
+    M_BindVariable("screen_height",             &screen_height);
+    M_BindVariable("startup_delay",             &startup_delay);
+    M_BindVariable("video_driver",              &video_driver);
+
+    // doom, heretic only:
+    M_BindVariable("show_endoom",               &show_endoom);
 }
 
--- a/src/setup/display.h
+++ b/src/setup/display.h
@@ -22,16 +22,9 @@
 #ifndef SETUP_DISPLAY_H 
 #define SETUP_DISPLAY_H
 
-extern int autoadjust_video_settings;
-extern int aspect_ratio_correct;
-extern int fullscreen;
-extern int screen_width, screen_height;
-extern int startup_delay;
-extern int show_endoom;
-extern char *video_driver;
-
 void ConfigDisplay(void);
 void SetDisplayDriver(void);
+void BindDisplayVariables(void);
 
 #endif /* #ifndef SETUP_DISPLAY_H */
 
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 
 #include "doomtype.h"
+#include "m_config.h"
+#include "m_controls.h"
 #include "textscreen.h"
 #include "txt_joybinput.h"
 
@@ -41,17 +43,8 @@
 
 // Joystick enable/disable
 
-int usejoystick = 0;
+static int usejoystick = 0;
 
-// Button mappings
-
-int joybfire = 0;
-int joybstrafe = 1;
-int joybuse = 2;
-int joybspeed = 3;
-int joybstrafeleft = -1;
-int joybstraferight = -1;
-
 // Joystick to use, as an SDL joystick index:
 
 int joystick_index = -1;
@@ -59,14 +52,14 @@
 // Which joystick axis to use for horizontal movement, and whether to
 // invert the direction:
 
-int joystick_x_axis = 0;
-int joystick_x_invert = 0;
+static int joystick_x_axis = 0;
+static int joystick_x_invert = 0;
 
 // Which joystick axis to use for vertical movement, and whether to
 // invert the direction:
 
-int joystick_y_axis = 1;
-int joystick_y_invert = 0;
+static int joystick_y_axis = 1;
+static int joystick_y_invert = 0;
 
 static txt_button_t *joystick_button;
 
@@ -436,5 +429,15 @@
     TXT_SignalConnect(window, "closed", JoystickWindowClosed, NULL);
 
     SetJoystickButtonLabel();
+}
+
+void BindJoystickVariables(void)
+{
+    M_BindVariable("use_joystick",          &usejoystick);
+    M_BindVariable("joystick_index",        &joystick_index);
+    M_BindVariable("joystick_x_axis",       &joystick_x_axis);
+    M_BindVariable("joystick_y_axis",       &joystick_y_axis);
+    M_BindVariable("joystick_x_invert",     &joystick_x_invert);
+    M_BindVariable("joystick_y_invert",     &joystick_y_invert);
 }
 
--- a/src/setup/joystick.h
+++ b/src/setup/joystick.h
@@ -22,21 +22,10 @@
 #ifndef SETUP_JOYSTICK_H
 #define SETUP_JOYSTICK_H
 
-extern int usejoystick;
-extern int joybfire;
-extern int joybstrafe;
-extern int joybuse;
-extern int joybspeed;
-extern int joybstrafeleft;
-extern int joybstraferight;
-
 extern int joystick_index;
-extern int joystick_x_axis;
-extern int joystick_x_invert;
-extern int joystick_y_axis;
-extern int joystick_y_invert;
 
 void ConfigJoystick(void);
+void BindJoystickVariables(void);
 
 #endif /* #ifndef SETUP_JOYSTICK_H */
 
--- a/src/setup/keyboard.c
+++ b/src/setup/keyboard.c
@@ -20,6 +20,8 @@
 //
 #include "textscreen.h"
 #include "doomtype.h"
+#include "m_config.h"
+#include "m_controls.h"
 
 #include "execute.h"
 #include "txt_keyinput.h"
@@ -27,19 +29,8 @@
 #include "joystick.h"
 #include "keyboard.h"
 
-int key_left = KEY_LEFTARROW;
-int key_right = KEY_RIGHTARROW;
-int key_up = KEY_UPARROW;
-int key_down = KEY_DOWNARROW;
-int key_strafeleft = ',';
-int key_straferight = '.';
-int key_fire = KEY_RCTRL;
-int key_use = ' ';
-int key_strafe = KEY_RALT;
-int key_speed = KEY_RSHIFT;
+static int vanilla_keyboard_mapping = 1;
 
-int vanilla_keyboard_mapping = 1;
-
 static int always_run = 0;
 
 static int *allkeys[] = {&key_left, &key_right, &key_up, &key_down, 
@@ -139,5 +130,10 @@
     AddKeyControl(action_table, "Fire", &key_fire);
 
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
+}
+
+void BindKeyboardVariables(void)
+{
+    M_BindVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping);
 }
 
--- a/src/setup/keyboard.h
+++ b/src/setup/keyboard.h
@@ -22,20 +22,8 @@
 #ifndef SETUP_KEYBOARD_H 
 #define SETUP_KEYBOARD_H 
 
-extern int key_left;
-extern int key_right;
-extern int key_up;
-extern int key_down;
-extern int key_strafeleft;
-extern int key_straferight;
-extern int key_fire;
-extern int key_use;
-extern int key_strafe;
-extern int key_speed;
-extern int joybspeed;
-extern int vanilla_keyboard_mapping;
-
 void ConfigKeyboard(void);
+void BindKeyboardVariables(void);
 
 #endif /* #ifndef SETUP_KEYBOARD_H */
 
--- a/src/setup/mouse.c
+++ b/src/setup/mouse.c
@@ -23,6 +23,8 @@
 
 #include "textscreen.h"
 #include "doomtype.h"
+#include "m_config.h"
+#include "m_controls.h"
 
 #include "execute.h"
 #include "txt_mouseinput.h"
@@ -29,24 +31,14 @@
 
 #include "mouse.h"
 
-int usemouse = 1;
+static int usemouse = 1;
 
-int novert = 0;
-int mouseSensitivity = 5;
-float mouse_acceleration = 1.0;
-int mouse_threshold = 10;
-int grabmouse = 1;
+static int novert = 0;
+static int mouseSensitivity = 5;
+static float mouse_acceleration = 1.0;
+static int mouse_threshold = 10;
+static int grabmouse = 1;
 
-int mousebfire = 0;
-int mousebforward = 1;
-int mousebstrafe = 2;
-int mousebstrafeleft = -1;
-int mousebstraferight = -1;
-int mousebbackward = -1;
-int mousebuse = -1;
-
-int dclick_use = 1;
-
 static int *all_mouse_buttons[] = {
     &mousebfire,
     &mousebstrafe,
@@ -153,5 +145,15 @@
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
 
     TXT_SignalConnect(more_buttons, "pressed", ConfigExtraButtons, NULL);
+}
+
+void BindMouseVariables(void)
+{
+    M_BindVariable("use_mouse",            &usemouse);
+    M_BindVariable("novert",               &novert);
+    M_BindVariable("mouse_sensitivity",    &mouseSensitivity);
+    M_BindVariable("mouse_acceleration",   &mouse_acceleration);
+    M_BindVariable("mouse_threshold",      &mouse_threshold);
+    M_BindVariable("grabmouse",            &grabmouse);
 }
 
--- a/src/setup/mouse.h
+++ b/src/setup/mouse.h
@@ -22,24 +22,8 @@
 #ifndef SETUP_MOUSE_H
 #define SETUP_MOUSE_H
 
-extern int usemouse;
-
-extern int novert;
-extern int mouseSensitivity;
-extern float mouse_acceleration;
-extern int mouse_threshold;
-extern int grabmouse;
-extern int mousebfire;
-extern int mousebforward;
-extern int mousebstrafe;
-extern int mousebstrafeleft;
-extern int mousebstraferight;
-extern int mousebbackward;
-extern int mousebuse;
-extern int dclick_use;
-
 void ConfigMouse(void);
-
+void BindMouseVariables(void);
 
 #endif /* #ifndef SETUP_MOUSE_H */