shithub: choc

Download patch

ref: c4c79440c404fabc7a77e1d4561ff707e223233a
parent: 14b01ab612caf0cbedd845ab3ae6bd5cec3a1bd3
author: Simon Howard <fraggle@gmail.com>
date: Sun Oct 22 18:10:08 EDT 2006

Standardise setup config variable names on the same variable names used
in Doom. Add header files for source files where they are needed. Make
variables static where appropriate. General cleanups etc.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 712

--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -7,13 +7,13 @@
 
 chocolate_setup_LDADD = @LDFLAGS@ @SDL_LIBS@ ../textscreen/libtextscreen.a
 chocolate_setup_SOURCES =                       \
-    compatibility.c                             \
-    display.c                                   \
-    keyboard.c                                  \
+    compatibility.c   compatibility.h           \
+    display.c         display.h                 \
+    keyboard.c        keyboard.h                \
     mainmenu.c                                  \
-    mouse.c                                     \
-    multiplayer.c                               \
-    sound.c                                     \
+    mouse.c           mouse.h                   \
+    multiplayer.c     multiplayer.h             \
+    sound.c           sound.h                   \
     testconfig.c      testconfig.h              \
     txt_keyinput.c    txt_keyinput.h            \
     txt_mouseinput.c  txt_mouseinput.h
--- a/setup/compatibility.c
+++ b/setup/compatibility.c
@@ -25,20 +25,22 @@
 
 #include "textscreen.h"
 
+#include "compatibility.h"
+
 int vanilla_savegame_limit = 1;
 int vanilla_demo_limit = 1;
 
 void CompatibilitySettings(void)
 {
-        txt_window_t *window;
+    txt_window_t *window;
 
-        window = TXT_NewWindow("Compatibility");
+    window = TXT_NewWindow("Compatibility");
 
-        TXT_AddWidgets(window, 
-                       TXT_NewCheckBox("Vanilla savegame limit",
-                                       &vanilla_savegame_limit),
-                       TXT_NewCheckBox("Vanilla demo limit",
-                                       &vanilla_demo_limit),
-                       NULL);
+    TXT_AddWidgets(window, 
+                   TXT_NewCheckBox("Vanilla savegame limit",
+                                   &vanilla_savegame_limit),
+                   TXT_NewCheckBox("Vanilla demo limit",
+                                   &vanilla_demo_limit),
+                   NULL);
 }
 
--- /dev/null
+++ b/setup/compatibility.h
@@ -1,0 +1,31 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2006 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+
+#ifndef SETUP_COMPATIBILITY_H
+#define SETUP_COMPATIBILITY_H
+
+extern int vanilla_savegame_limit;
+extern int vanilla_demo_limit;
+
+void CompatibilitySettings(void);
+
+#endif /* #ifndef SETUP_COMPATIBILITY_H */
+
--- a/setup/display.c
+++ b/setup/display.c
@@ -20,62 +20,65 @@
 //
 #include "textscreen.h"
 
+#include "display.h"
+
 typedef struct 
 {
-        char *description;
-        int fullscreen;
-        int screenmult;
+    char *description;
+    int fullscreen;
+    int screenmultiply;
 } vidmode_t;
 
 static vidmode_t modes[] = 
 {
-        { "320x200",  0, 1 },
-        { "640x400",  0, 2 },
-        { "960x600",  0, 3 },
-        { "1280x800", 0, 4 },
-        { "320x200",  1, 1 },
-        { "320x240",  2, 1 },
-        { "640x400",  1, 2 },
-        { "640x480",  2, 2 },
-        { "960x600",  1, 3 },
-        { "960x720",  2, 3 },
-        { "1280x800", 1, 4 },
-        { "1280x960", 2, 4 },
-        { NULL,       0, 0 },
+    { "320x200",  0, 1 },
+    { "640x400",  0, 2 },
+    { "960x600",  0, 3 },
+    { "1280x800", 0, 4 },
+    { "320x200",  1, 1 },
+    { "320x240",  2, 1 },
+    { "640x400",  1, 2 },
+    { "640x480",  2, 2 },
+    { "960x600",  1, 3 },
+    { "960x720",  2, 3 },
+    { "1280x800", 1, 4 },
+    { "1280x960", 2, 4 },
+    { NULL,       0, 0 },
 };
 
 static int vidmode = 0;
-static int fullscreen = 0;
-static int screenmult = 1;
-static int startup_delay = 0;
-static int show_endoom = 1;
 
-// Given the video settings (fullscreen, screenmult, etc), find the
+int fullscreen = 0;
+int screenmultiply = 1;
+int startup_delay = 0;
+int show_endoom = 1;
+
+// Given the video settings (fullscreen, screenmultiply, etc), find the
 // current video mode
 
 static void SetCurrentMode(void)
 {
-        int i;
+    int i;
 
-        vidmode = 0;
+    vidmode = 0;
 
-        for (i=0; modes[i].description != NULL; ++i)
+    for (i=0; modes[i].description != NULL; ++i)
+    {
+        if (fullscreen == modes[i].fullscreen
+         && screenmultiply == modes[i].screenmultiply)
         {
-                if (fullscreen == modes[i].fullscreen
-                 && screenmult == modes[i].screenmult)
-                {
-                        vidmode = i;
-                        break;
-                }
+            vidmode = i;
+            break;
         }
+    }
 }
 
 static void ModeSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(mode))
 {
-        TXT_CAST_ARG(vidmode_t, mode);
+    TXT_CAST_ARG(vidmode_t, mode);
 
-        fullscreen = mode->fullscreen;
-        screenmult = mode->screenmult;
+    fullscreen = mode->fullscreen;
+    screenmultiply = mode->screenmultiply;
 }
 
 void ConfigDisplay(void)
--- /dev/null
+++ b/setup/display.h
@@ -1,0 +1,33 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2006 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+
+#ifndef SETUP_DISPLAY_H 
+#define SETUP_DISPLAY_H
+
+extern int fullscreen;
+extern int screenmultiply;
+extern int startup_delay;
+extern int show_endoom;
+
+void ConfigDisplay(void);
+
+#endif /* #ifndef SETUP_DISPLAY_H */
+
--- a/setup/keyboard.c
+++ b/setup/keyboard.c
@@ -23,6 +23,8 @@
 #include "testconfig.h"
 #include "txt_keyinput.h"
 
+#include "keyboard.h"
+
 int key_left = KEY_LEFTARROW;
 int key_right = KEY_RIGHTARROW;
 int key_up = KEY_UPARROW;
@@ -33,12 +35,26 @@
 int key_use = ' ';
 int key_strafe = KEY_RALT;
 int key_speed = KEY_RSHIFT;
-int always_run = 0;
+int joybspeed = 3;
 
+static int always_run = 0;
+
 static int *allkeys[] = {&key_left, &key_right, &key_up, &key_down, 
                          &key_strafeleft, &key_straferight, &key_fire, 
                          &key_use, &key_strafe, &key_speed};
 
+static void UpdateJoybSpeed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(var))
+{
+    if (always_run)
+    {
+       joybspeed = 31;
+    }
+    else
+    {
+       joybspeed = 0;
+    }
+}
+
 // Callback invoked when a key control is set
 
 static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
@@ -74,13 +90,16 @@
     txt_window_t *window;
     txt_table_t *movement_table;
     txt_table_t *action_table;
+    txt_checkbox_t *run_control;
 
+    always_run = joybspeed > 30;
+
     window = TXT_NewWindow("Keyboard configuration");
 
     TXT_AddWidgets(window, 
                    TXT_NewSeparator("Movement"),
                    movement_table = TXT_NewTable(2),
-                   TXT_NewCheckBox("Always run", &always_run),
+                   run_control = TXT_NewCheckBox("Always run", &always_run),
 
                    TXT_NewSeparator("Action"),
                    action_table = TXT_NewTable(2),
@@ -87,6 +106,8 @@
                    NULL);
 
     TXT_SetColumnWidths(movement_table, 20, 8);
+
+    TXT_SignalConnect(run_control, "changed", UpdateJoybSpeed, NULL);
 
     AddKeyControl(movement_table, "Move Forward", &key_up);
     AddKeyControl(movement_table, "Move Backward", &key_down);
--- /dev/null
+++ b/setup/keyboard.h
@@ -1,0 +1,40 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2006 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+
+#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;
+
+void ConfigKeyboard(void);
+
+#endif /* #ifndef SETUP_KEYBOARD_H */
+
--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -23,6 +23,13 @@
 #include "config.h"
 #include "textscreen.h"
 
+#include "compatibility.h"
+#include "display.h"
+#include "keyboard.h"
+#include "mouse.h"
+#include "multiplayer.h"
+#include "sound.h"
+
 void DoQuit(void *widget, void *dosave)
 {
     if (dosave != NULL)
@@ -60,15 +67,6 @@
                         TXT_NewWindowAbortAction(window));
     TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL);
 }
-
-extern void ConfigDisplay();
-extern void ConfigKeyboard();
-extern void ConfigMouse();
-extern void ConfigSound();
-extern void CompatibilitySettings();
-extern void StartMultiGame();
-extern void JoinMultiGame();
-extern void MultiplayerConfig();
 
 void MainMenu(void)
 {
--- a/setup/mouse.c
+++ b/setup/mouse.c
@@ -26,20 +26,22 @@
 #include "testconfig.h"
 #include "txt_mouseinput.h"
 
+#include "mouse.h"
+
 int use_mouse = 1;
 
-int novert;
-int speed;
-float accel;
-int threshold;
+int novert = 0;
+int mouseSensitivity = 5;
+float mouse_acceleration = 1.0;
+int mouse_threshold = 10;
 int grabmouse = 1;
 
-int mouseb_fire = 0;
-int mouseb_forward = 1;
-int mouseb_strafe = 2;
+int mousebfire = 0;
+int mousebforward = 1;
+int mousebstrafe = 2;
 
-static int *all_mouse_buttons[] = {&mouseb_fire, &mouseb_strafe, 
-                                   &mouseb_forward};
+static int *all_mouse_buttons[] = {&mousebfire, &mousebstrafe, 
+                                   &mousebforward};
 
 static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
 {
@@ -98,18 +100,18 @@
 
     TXT_AddWidgets(motion_table,
                    TXT_NewLabel("Speed"),
-                   TXT_NewSpinControl(&speed, 1, 256),
+                   TXT_NewSpinControl(&mouseSensitivity, 1, 256),
                    TXT_NewLabel("Acceleration"),
-                   TXT_NewFloatSpinControl(&accel, 1.0, 5.0),
+                   TXT_NewFloatSpinControl(&mouse_acceleration, 1.0, 5.0),
                    TXT_NewLabel("Acceleration threshold"),
-                   TXT_NewSpinControl(&threshold, 0, 32),
+                   TXT_NewSpinControl(&mouse_threshold, 0, 32),
                    NULL);
 
     TXT_SetColumnWidths(button_table, 27, 5);
 
-    AddMouseControl(button_table, "Fire weapon", &mouseb_fire);
-    AddMouseControl(button_table, "Move forward", &mouseb_forward);
-    AddMouseControl(button_table, "Strafe on", &mouseb_strafe);
+    AddMouseControl(button_table, "Fire weapon", &mousebfire);
+    AddMouseControl(button_table, "Move forward", &mousebforward);
+    AddMouseControl(button_table, "Strafe on", &mousebstrafe);
     
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
 }
--- /dev/null
+++ b/setup/mouse.h
@@ -1,0 +1,40 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2006 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+
+#ifndef SETUP_MOUSE_H
+#define SETUP_MOUSE_H
+
+extern int use_mouse;
+
+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;
+
+void ConfigMouse(void);
+
+
+#endif /* #ifndef SETUP_MOUSE_H */
+
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -25,6 +25,8 @@
 #include "d_englsh.h"
 #include "textscreen.h"
 
+#include "multiplayer.h"
+
 #define NUM_WADS 10
 #define NUM_EXTRA_PARAMS 10
 
@@ -53,24 +55,24 @@
 char *player_name;
 char *chatmacros[10];
 
-char *wads[NUM_WADS] = {};
-char *extra_params[NUM_EXTRA_PARAMS] = {};
-int skill = 0;
-int nomonsters = 0;
-int deathmatch = 0;
-int fast = 0;
-int respawn = 0;
-int udpport = 4815;
-int timer = 0;
+static char *wads[NUM_WADS] = {};
+static char *extra_params[NUM_EXTRA_PARAMS] = {};
+static int skill = 0;
+static int nomonsters = 0;
+static int deathmatch = 0;
+static int fast = 0;
+static int respawn = 0;
+static int udpport = 4815;
+static int timer = 0;
 
-txt_button_t *warpbutton;
-warptype_t warptype = WARP_DOOM2;
-int warpepisode = 1;
-int warpmap = 1;
+static txt_button_t *warpbutton;
+static warptype_t warptype = WARP_DOOM2;
+static int warpepisode = 1;
+static int warpmap = 1;
 
 // Address to connect to when joining a game
 
-char *connect_address = NULL;
+static char *connect_address = NULL;
 
 static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data))
 {
--- /dev/null
+++ b/setup/multiplayer.h
@@ -1,0 +1,33 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2006 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+
+#ifndef SETUP_MULTIPLAYER_H
+#define SETUP_MULTIPLAYER_H
+
+extern char *player_name;
+extern char *chatmacros[10];
+
+void StartMultiGame(void);
+void JoinMultiGame(void);
+void MultiplayerConfig(void);
+
+#endif /* #ifndef SETUP_MULTIPLAYER_H */
+
--- a/setup/sound.c
+++ b/setup/sound.c
@@ -25,44 +25,82 @@
 
 #include "textscreen.h"
 
-int snd_sfxenabled;
+#include "sound.h"
+
+int snd_sfxdevice = 3;
 int snd_channels = 8;
 int sfx_volume = 15;
 
-int snd_musicenabled;
+int snd_musicdevice = 3;
 int music_volume = 15;
 
+static int snd_sfxenabled;
+static int snd_musicenabled;
+
+static void UpdateSndDevices(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
+{
+    if (snd_sfxenabled)
+    {
+        snd_sfxdevice = 3;
+    }
+    else
+    {
+        snd_sfxdevice = 0;
+    }
+
+    if (snd_musicenabled)
+    {
+        snd_musicdevice = 3;
+    }
+    else
+    {
+        snd_musicdevice = 0;
+    }
+}
+
 void ConfigSound(void)
 {
-        txt_window_t *window;
-        txt_table_t *sfx_table;
-        txt_table_t *music_table;
+    txt_window_t *window;
+    txt_table_t *sfx_table;
+    txt_table_t *music_table;
+    txt_checkbox_t *sfx_enabled_control;
+    txt_checkbox_t *music_enabled_control;
 
-        window = TXT_NewWindow("Sound configuration");
+    snd_sfxenabled = snd_sfxdevice != 0;
+    snd_musicenabled = snd_musicdevice != 0;
 
-        TXT_AddWidgets(window,
-                   TXT_NewSeparator("Sound effects"),
-                   TXT_NewCheckBox("Sound effects enabled", &snd_sfxenabled),
-                   sfx_table = TXT_NewTable(2),
-                   TXT_NewSeparator("Music"),
-                   TXT_NewCheckBox("Music enabled", &snd_musicenabled),
-                   music_table = TXT_NewTable(2),
-                   NULL);
+    window = TXT_NewWindow("Sound configuration");
 
-        TXT_SetColumnWidths(sfx_table, 20, 5);
+    TXT_AddWidgets(window,
+               TXT_NewSeparator("Sound effects"),
+               sfx_enabled_control = TXT_NewCheckBox("Sound effects enabled", 
+                                                     &snd_sfxenabled),
+               sfx_table = TXT_NewTable(2),
+               TXT_NewSeparator("Music"),
+               music_enabled_control = TXT_NewCheckBox("Music enabled", 
+                                                       &snd_musicenabled),
+               music_table = TXT_NewTable(2),
+               NULL);
 
-        TXT_AddWidgets(sfx_table, 
-                       TXT_NewLabel("Sound channels"),
-                       TXT_NewSpinControl(&snd_channels, 1, 8),
-                       TXT_NewLabel("SFX volume"),
-                       TXT_NewSpinControl(&sfx_volume, 0, 15),
-                       NULL);
+    TXT_SetColumnWidths(sfx_table, 20, 5);
 
-        TXT_SetColumnWidths(music_table, 20, 5);
+    TXT_SignalConnect(sfx_enabled_control, "changed", 
+                      UpdateSndDevices, NULL);
+    TXT_SignalConnect(music_enabled_control, "changed", 
+                      UpdateSndDevices, NULL);
 
-        TXT_AddWidgets(music_table,
-                       TXT_NewLabel("Music volume"),
-                       TXT_NewSpinControl(&music_volume, 0, 15),
-                       NULL);
+    TXT_AddWidgets(sfx_table, 
+                   TXT_NewLabel("Sound channels"),
+                   TXT_NewSpinControl(&snd_channels, 1, 8),
+                   TXT_NewLabel("SFX volume"),
+                   TXT_NewSpinControl(&sfx_volume, 0, 15),
+                   NULL);
+
+    TXT_SetColumnWidths(music_table, 20, 5);
+
+    TXT_AddWidgets(music_table,
+                   TXT_NewLabel("Music volume"),
+                   TXT_NewSpinControl(&music_volume, 0, 15),
+                   NULL);
 }
 
--- /dev/null
+++ b/setup/sound.h
@@ -1,0 +1,35 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2006 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+
+#ifndef SETUP_SOUND_H
+#define SETUP_SOUND_H
+
+extern int snd_sfxdevice;
+extern int snd_channels;
+extern int sfx_volume;
+
+extern int snd_musicdevice;
+extern int music_volume;
+
+void ConfigSound(void);
+
+#endif /* #ifndef SETUP_SOUND_H */
+