From a33d23591953d7fbb0041544f4bbe7b807654bb8 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 27 Nov 2008 19:45:58 +0000 Subject: Add -game command-line parameter to control what game to configure settings for. Subversion-branch: /branches/raven-branch Subversion-revision: 1389 --- src/Makefile.am | 1 + src/setup/Makefile.am | 1 + src/setup/compatibility.c | 8 ++- src/setup/display.c | 14 +++- src/setup/mainmenu.c | 38 ++--------- src/setup/mode.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++ src/setup/mode.h | 33 +++++++++ 7 files changed, 225 insertions(+), 38 deletions(-) create mode 100644 src/setup/mode.c create mode 100644 src/setup/mode.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3438099f..64be4ee7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -149,6 +149,7 @@ chocolate_hexen_LDADD = hexen/libhexen.a $(EXTRA_LIBS) # Source files needed for chocolate-setup: SETUP_FILES= \ +d_mode.c d_mode.h \ m_config.c m_config.h \ m_controls.c m_controls.h \ z_native.c z_zone.h diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am index 6028eab7..a39a1812 100644 --- a/src/setup/Makefile.am +++ b/src/setup/Makefile.am @@ -9,6 +9,7 @@ SOURCE_FILES = \ joystick.c joystick.h \ keyboard.c keyboard.h \ mainmenu.c \ + mode.c mode.h \ mouse.c mouse.h \ multiplayer.c multiplayer.h \ sound.c sound.h \ diff --git a/src/setup/compatibility.c b/src/setup/compatibility.c index 4553f6bb..722088e8 100644 --- a/src/setup/compatibility.c +++ b/src/setup/compatibility.c @@ -25,6 +25,7 @@ #include "m_config.h" #include "textscreen.h" +#include "mode.h" #include "compatibility.h" @@ -47,7 +48,10 @@ void CompatibilitySettings(void) void BindCompatibilityVariables(void) { - M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); - M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); + if (gamemission == doom) + { + M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); + M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); + } } diff --git a/src/setup/display.c b/src/setup/display.c index a8865c30..8ce472bd 100644 --- a/src/setup/display.c +++ b/src/setup/display.c @@ -23,6 +23,7 @@ #include "textscreen.h" #include "m_config.h" +#include "mode.h" #include "display.h" @@ -449,7 +450,16 @@ void BindDisplayVariables(void) M_BindVariable("video_driver", &video_driver); M_BindVariable("usegamma", &usegamma); - // doom, heretic only: - M_BindVariable("show_endoom", &show_endoom); + + if (gamemission == doom || gamemission == heretic) + { + M_BindVariable("show_endoom", &show_endoom); + } + + if (gamemission == heretic || gamemission == hexen) + { + M_BindVariable("graphical_startup", &show_endoom); + } + } diff --git a/src/setup/mainmenu.c b/src/setup/mainmenu.c index 7564fe36..1a82b507 100644 --- a/src/setup/mainmenu.c +++ b/src/setup/mainmenu.c @@ -28,9 +28,9 @@ #include "m_argv.h" #include "m_config.h" -#include "m_controls.h" #include "setup_icon.c" +#include "mode.h" #include "compatibility.h" #include "display.h" @@ -40,19 +40,6 @@ #include "multiplayer.h" #include "sound.h" -// Miscellaneous variables that aren't used in setup. - -static int showMessages = 1; -static int screenblocks = 9; -static int detailLevel = 0; - -static void BindMiscVariables(void) -{ - M_BindVariable("show_messages", &showMessages); - M_BindVariable("screenblocks", &screenblocks); - M_BindVariable("detaillevel", &detailLevel); -} - static void DoQuit(void *widget, void *dosave) { if (dosave != NULL) @@ -146,31 +133,14 @@ void MainMenu(void) TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action); } -// -// Initialise all configuration variables, load config file, etc -// - static void InitConfig(void) { + SetupMission(); + InitBindings(); + SetChatMacroDefaults(); SetPlayerNameDefault(); - // Keyboard, mouse, joystick controls - - M_BindBaseControls(); - - // All other variables - - BindCompatibilityVariables(); - BindDisplayVariables(); - BindJoystickVariables(); - BindKeyboardVariables(); - BindMouseVariables(); - BindSoundVariables(); - BindMiscVariables(); - BindMultiplayerVariables(); - - M_SetConfigFilenames("default.cfg", "chocolate-doom.cfg"); M_SetConfigDir(); M_LoadDefaults(); } diff --git a/src/setup/mode.c b/src/setup/mode.c new file mode 100644 index 00000000..d0d82580 --- /dev/null +++ b/src/setup/mode.c @@ -0,0 +1,168 @@ +// 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. +// + +#include + +#include "doomtype.h" +#include "d_mode.h" +#include "i_system.h" +#include "m_argv.h" +#include "m_config.h" +#include "m_controls.h" + +#include "compatibility.h" +#include "display.h" +#include "joystick.h" +#include "keyboard.h" +#include "mouse.h" +#include "multiplayer.h" +#include "sound.h" + +#include "mode.h" + +GameMission_t gamemission; + +typedef struct +{ + GameMission_t mission; + char *name; + char *config_file; + char *extra_config_file; +} mission_config_t; + +static mission_config_t config_files[] = +{ + { doom, "doom", "default.cfg", "chocolate-doom.cfg" }, + { heretic, "heretic", "heretic.cfg", "chocolate-heretic.cfg" }, + { hexen, "hexen", "hexen.cfg", "chocolate-hexen.cfg" }, +}; + +// Miscellaneous variables that aren't used in setup. + +static int showMessages = 1; +static int screenblocks = 9; +static int detailLevel = 0; +static char *savedir = NULL; + +static void BindMiscVariables(void) +{ + M_BindVariable("screenblocks", &screenblocks); + + if (gamemission == doom) + { + M_BindVariable("detaillevel", &detailLevel); + M_BindVariable("show_messages", &showMessages); + } + + if (gamemission == hexen) + { + M_BindVariable("savedir", &savedir); + M_BindVariable("messageson", &showMessages); + } +} + +// +// Initialise all configuration file bindings. +// + +void InitBindings(void) +{ + // Keyboard, mouse, joystick controls + + M_BindBaseControls(); + + if (gamemission == heretic || gamemission == hexen) + { + M_BindHereticControls(); + } + + if (gamemission == hexen) + { + M_BindHexenControls(); + } + + // All other variables + + BindCompatibilityVariables(); + BindDisplayVariables(); + BindJoystickVariables(); + BindKeyboardVariables(); + BindMouseVariables(); + BindSoundVariables(); + BindMiscVariables(); + BindMultiplayerVariables(); +} + +static void SetMission(mission_config_t *config) +{ + gamemission = config->mission; + M_SetConfigFilenames(config->config_file, config->extra_config_file); +} + +static mission_config_t *GetMissionForName(char *name) +{ + int i; + + for (i=0; i + // + // Specify the game to configure the settings for. Valid + // values are 'doom', 'heretic' and 'hexen'. + // + + p = M_CheckParm("-game"); + + if (p > 0) + { + mission_name = myargv[p + 1]; + } + else + { + mission_name = "doom"; + } + + config = GetMissionForName(mission_name); + + if (config == NULL) + { + I_Error("Invalid parameter - '%s'", mission_name); + } + + SetMission(config); +} + diff --git a/src/setup/mode.h b/src/setup/mode.h new file mode 100644 index 00000000..c6d0dc66 --- /dev/null +++ b/src/setup/mode.h @@ -0,0 +1,33 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 2008 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_MODE_H +#define SETUP_MODE_H + +#include "d_mode.h" + +extern GameMission_t gamemission; + +void SetupMission(void); +void InitBindings(void); + +#endif /* #ifndef SETUP_MODE_H */ + -- cgit v1.2.3