From bb58e40a23c68f51f396babe10db7a6e62cf67f3 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 5 Dec 2008 23:34:04 +0000 Subject: Auto-select the game type based on detected IWADs. If IWADs from multiple games are detected, pop up a dialog box to prompt the user to select a game to configure. Subversion-branch: /branches/raven-branch Subversion-revision: 1408 --- src/Makefile.am | 2 + src/d_iwad.c | 37 ++++++++++++++ src/d_iwad.h | 1 + src/setup/mainmenu.c | 11 +++-- src/setup/mode.c | 137 ++++++++++++++++++++++++++++++++++++++++++++------- src/setup/mode.h | 3 +- 6 files changed, 167 insertions(+), 24 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 64be4ee7..5a2267b9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -149,7 +149,9 @@ chocolate_hexen_LDADD = hexen/libhexen.a $(EXTRA_LIBS) # Source files needed for chocolate-setup: SETUP_FILES= \ +deh_str.c deh_str.h \ d_mode.c d_mode.h \ +d_iwad.c d_iwad.h \ m_config.c m_config.h \ m_controls.c m_controls.h \ z_native.c z_zone.h diff --git a/src/d_iwad.c b/src/d_iwad.c index fdec8cb9..a9a1e2bd 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -635,3 +635,40 @@ char *D_FindIWAD(int mask, GameMission_t *mission) return result; } +// Find all IWADs in the IWAD search path matching the given mask. + +iwad_t **D_FindAllIWADs(int mask) +{ + iwad_t **result; + int result_len; + char *filename; + int i; + + result = malloc(sizeof(iwad_t *) * (arrlen(iwads) + 1)); + result_len = 0; + + // Try to find all IWADs + + for (i=0; i #include "config.h" +#include "textscreen.h" #include "doomtype.h" #include "d_mode.h" +#include "d_iwad.h" #include "i_system.h" #include "m_argv.h" #include "m_config.h" @@ -44,19 +46,48 @@ GameMission_t gamemission; typedef struct { + char *label; GameMission_t mission; + int mask; char *name; char *config_file; char *extra_config_file; } mission_config_t; -static mission_config_t config_files[] = +// Default mission to fall back on, if no IWADs are found at all: + +#define DEFAULT_MISSION (&mission_configs[0]) + +static mission_config_t mission_configs[] = { - { doom, "doom", "default.cfg", PROGRAM_PREFIX "doom.cfg" }, - { heretic, "heretic", "heretic.cfg", PROGRAM_PREFIX "heretic.cfg" }, - { hexen, "hexen", "hexen.cfg", PROGRAM_PREFIX "hexen.cfg" }, + { + "Doom", + doom, + IWAD_MASK_DOOM, + "doom", + "default.cfg", + PROGRAM_PREFIX "doom.cfg" + }, + { + "Heretic", + heretic, + IWAD_MASK_HERETIC, + "heretic", + "heretic.cfg", + PROGRAM_PREFIX "heretic.cfg" + }, + { + "Hexen", + hexen, + IWAD_MASK_HEXEN, + "hexen", + "hexen.cfg", + PROGRAM_PREFIX "hexen.cfg" + } }; +static GameSelectCallback game_selected_callback; + // Miscellaneous variables that aren't used in setup. static int showMessages = 1; @@ -123,18 +154,85 @@ static mission_config_t *GetMissionForName(char *name) { int i; - for (i=0; i 0) + if (p > 0) { mission_name = myargv[p + 1]; - } - else - { - mission_name = "doom"; - } - config = GetMissionForName(mission_name); + config = GetMissionForName(mission_name); + + if (config == NULL) + { + I_Error("Invalid parameter - '%s'", mission_name); + } - if (config == NULL) + SetMission(config); + callback(); + } + else { - I_Error("Invalid parameter - '%s'", mission_name); + OpenGameSelectDialog(callback); } - - SetMission(config); } diff --git a/src/setup/mode.h b/src/setup/mode.h index c6d0dc66..a78a5bc2 100644 --- a/src/setup/mode.h +++ b/src/setup/mode.h @@ -24,9 +24,10 @@ #include "d_mode.h" +typedef void (*GameSelectCallback)(void); extern GameMission_t gamemission; -void SetupMission(void); +void SetupMission(GameSelectCallback callback); void InitBindings(void); #endif /* #ifndef SETUP_MODE_H */ -- cgit v1.2.3