diff options
Diffstat (limited to 'setup')
-rw-r--r-- | setup/Makefile.am | 5 | ||||
-rw-r--r-- | setup/configfile.c | 138 | ||||
-rw-r--r-- | setup/configfile.h | 2 | ||||
-rw-r--r-- | setup/display.c | 22 | ||||
-rw-r--r-- | setup/execute.c | 154 | ||||
-rw-r--r-- | setup/keyboard.c | 245 | ||||
-rw-r--r-- | setup/keyboard.h | 57 | ||||
-rw-r--r-- | setup/mainmenu.c | 17 | ||||
-rw-r--r-- | setup/multiplayer.c | 42 | ||||
-rw-r--r-- | setup/txt_keyinput.c | 12 |
10 files changed, 639 insertions, 55 deletions
diff --git a/setup/Makefile.am b/setup/Makefile.am index b7b05520..22bcb224 100644 --- a/setup/Makefile.am +++ b/setup/Makefile.am @@ -31,7 +31,10 @@ else chocolate_setup_SOURCES=$(SOURCE_FILES) endif -chocolate_setup_LDADD = ../textscreen/libtextscreen.a @LDFLAGS@ +chocolate_setup_LDADD = \ + ../wince/libc_wince.a \ + ../textscreen/libtextscreen.a \ + @LDFLAGS@ .rc.o: $(WINDRES) $^ -o $@ diff --git a/setup/configfile.c b/setup/configfile.c index 3f75d7f1..fe3c13de 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -35,6 +35,8 @@ #ifdef _WIN32 #include <io.h> +#define WIN32_LEAN_AND_MEAN +#include <windows.h> #else #include <sys/stat.h> #include <sys/types.h> @@ -74,7 +76,7 @@ void M_MakeDirectory(char *path) // -// SetConfigDir: +// M_SetConfigDir: // // Sets the location of the configuration directory, where configuration // files are stored - default.cfg, chocolate-doom.cfg, savegames, etc. @@ -82,9 +84,11 @@ void M_MakeDirectory(char *path) void M_SetConfigDir(void) { -#ifndef _WIN32 - // Ignore the HOME environment variable on Windows - just behave - // like Vanilla Doom. +#if !defined(_WIN32) || defined(_WIN32_WCE) + + // Configuration settings are stored in ~/.chocolate-doom/, + // except on Windows, where we behave like Vanilla Doom and + // save in the current directory. char *homedir; @@ -97,7 +101,8 @@ void M_SetConfigDir(void) configdir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5); - sprintf(configdir, "%s/.%s/", homedir, PACKAGE_TARNAME); + sprintf(configdir, "%s%c.%s%c", homedir, DIR_SEPARATOR, + PACKAGE_TARNAME, DIR_SEPARATOR); // make the directory if it doesnt already exist @@ -106,7 +111,7 @@ void M_SetConfigDir(void) else #endif /* #ifndef _WIN32 */ { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) // when given the -cdrom option, save config+savegames in // c:\doomdata. This only applies under Windows. @@ -239,6 +244,7 @@ static default_t doom_defaults_list[] = {"chatmacro7", &chat_macros[7], DEFAULT_STRING, 0, 0 }, {"chatmacro8", &chat_macros[8], DEFAULT_STRING, 0, 0 }, {"chatmacro9", &chat_macros[9], DEFAULT_STRING, 0, 0 }, + }; static default_collection_t doom_defaults = @@ -282,6 +288,52 @@ static default_t extra_defaults_list[] = {"mouseb_use", &mousebuse, DEFAULT_INT, 0, 0}, {"mouseb_backward", &mousebbackward, DEFAULT_INT, 0, 0}, {"use_libsamplerate", &use_libsamplerate, DEFAULT_INT, 0, 0}, + + {"key_pause", &key_pause, DEFAULT_KEY, 0, 0}, + {"key_menu_activate", &key_menu_activate, DEFAULT_KEY, 0, 0}, + {"key_menu_up", &key_menu_up, DEFAULT_KEY, 0, 0}, + {"key_menu_down", &key_menu_down, DEFAULT_KEY, 0, 0}, + {"key_menu_left", &key_menu_left, DEFAULT_KEY, 0, 0}, + {"key_menu_right", &key_menu_right, DEFAULT_KEY, 0, 0}, + {"key_menu_back", &key_menu_back, DEFAULT_KEY, 0, 0}, + {"key_menu_forward", &key_menu_forward, DEFAULT_KEY, 0, 0}, + {"key_menu_confirm", &key_menu_confirm, DEFAULT_KEY, 0, 0}, + {"key_menu_abort", &key_menu_abort, DEFAULT_KEY, 0, 0}, + {"key_menu_help", &key_menu_help, DEFAULT_KEY, 0, 0}, + {"key_menu_save", &key_menu_save, DEFAULT_KEY, 0, 0}, + {"key_menu_load", &key_menu_load, DEFAULT_KEY, 0, 0}, + {"key_menu_volume", &key_menu_volume, DEFAULT_KEY, 0, 0}, + {"key_menu_detail", &key_menu_detail, DEFAULT_KEY, 0, 0}, + {"key_menu_qsave", &key_menu_qsave, DEFAULT_KEY, 0, 0}, + {"key_menu_endgame", &key_menu_endgame, DEFAULT_KEY, 0, 0}, + {"key_menu_messages", &key_menu_messages, DEFAULT_KEY, 0, 0}, + {"key_menu_qload", &key_menu_qload, DEFAULT_KEY, 0, 0}, + {"key_menu_quit", &key_menu_quit, DEFAULT_KEY, 0, 0}, + {"key_menu_gamma", &key_menu_gamma, DEFAULT_KEY, 0, 0}, + {"key_menu_incscreen", &key_menu_incscreen, DEFAULT_KEY, 0, 0}, + {"key_menu_decscreen", &key_menu_decscreen, DEFAULT_KEY, 0, 0}, + + {"key_map_toggle", &key_map_toggle, DEFAULT_KEY, 0, 0}, + {"key_map_north", &key_map_north, DEFAULT_KEY, 0, 0}, + {"key_map_south", &key_map_south, DEFAULT_KEY, 0, 0}, + {"key_map_east", &key_map_east, DEFAULT_KEY, 0, 0}, + {"key_map_west", &key_map_west, DEFAULT_KEY, 0, 0}, + {"key_map_zoomin", &key_map_zoomin, DEFAULT_KEY, 0, 0}, + {"key_map_zoomout", &key_map_zoomout, DEFAULT_KEY, 0, 0}, + {"key_map_maxzoom", &key_map_maxzoom, DEFAULT_KEY, 0, 0}, + {"key_map_follow", &key_map_follow, DEFAULT_KEY, 0, 0}, + {"key_map_grid", &key_map_grid, DEFAULT_KEY, 0, 0}, + {"key_map_mark", &key_map_mark, DEFAULT_KEY, 0, 0}, + {"key_map_clearmark", &key_map_clearmark, DEFAULT_KEY, 0, 0}, + {"key_weapon1", &key_weapon1, DEFAULT_KEY, 0, 0}, + {"key_weapon2", &key_weapon2, DEFAULT_KEY, 0, 0}, + {"key_weapon3", &key_weapon3, DEFAULT_KEY, 0, 0}, + {"key_weapon4", &key_weapon4, DEFAULT_KEY, 0, 0}, + {"key_weapon5", &key_weapon5, DEFAULT_KEY, 0, 0}, + {"key_weapon6", &key_weapon6, DEFAULT_KEY, 0, 0}, + {"key_weapon7", &key_weapon7, DEFAULT_KEY, 0, 0}, + {"key_weapon8", &key_weapon8, DEFAULT_KEY, 0, 0}, + {"key_message_refresh", &key_message_refresh, DEFAULT_KEY, 0, 0}, }; static default_collection_t extra_defaults = @@ -597,3 +649,77 @@ void M_SaveExtraDefaults(char *filename) extra_defaults.filename = main_filename; } +#ifdef _WIN32_WCE + +static int SystemHasKeyboard(void) +{ + HKEY key; + DWORD valtype; + DWORD valsize; + DWORD result; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, + L"\\Software\\Microsoft\\Shell", 0, + KEY_READ, &key) != ERROR_SUCCESS) + { + return 0; + } + + valtype = REG_SZ; + valsize = sizeof(DWORD); + + if (RegQueryValueExW(key, L"HasKeyboard", NULL, &valtype, + (LPBYTE) &result, &valsize) != ERROR_SUCCESS) + { + result = 0; + } + + // Close the key + + RegCloseKey(key); + + return result; +} + +// +// Apply custom defaults for Windows CE. +// + +static void M_ApplyWindowsCEDefaults(void) +{ + // If the system doesn't have a keyboard, patch the default + // configuration to use the hardware keys. + + if (!SystemHasKeyboard()) + { + key_use = KEY_F1; + key_fire = KEY_F2; + key_menu_activate = KEY_F3; + key_map_toggle = KEY_F4; + + key_menu_help = 0; + key_menu_save = 0; + key_menu_load = 0; + key_menu_volume = 0; + + key_menu_confirm = KEY_ENTER; + key_menu_back = KEY_F2; + key_menu_abort = KEY_F2; + } +} + + +#endif + +// +// Apply custom patches to the default values depending on the +// platform we are running on. +// + +void M_ApplyPlatformDefaults(void) +{ +#ifdef _WIN32_WCE + M_ApplyWindowsCEDefaults(); +#endif +} + diff --git a/setup/configfile.h b/setup/configfile.h index f7c6156e..3ef2cf9b 100644 --- a/setup/configfile.h +++ b/setup/configfile.h @@ -38,5 +38,7 @@ void M_SetConfigDir(void); void M_SaveMainDefaults(char *filename); void M_SaveExtraDefaults(char *filename); +void M_ApplyPlatformDefaults(void); + #endif diff --git a/setup/display.c b/setup/display.c index 5e9d4fcf..596b8a43 100644 --- a/setup/display.c +++ b/setup/display.c @@ -21,6 +21,10 @@ #include <string.h> +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + #include "textscreen.h" #include "display.h" @@ -116,7 +120,7 @@ void SetDisplayDriver(void) } else { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) // On Windows, use DirectX over windib by default. putenv("SDL_VIDEODRIVER=directx"); @@ -187,7 +191,14 @@ static void BuildFullscreenModesList(void) modes = SDL_ListModes(NULL, SDL_FULLSCREEN); - for (num_modes=0; modes[num_modes] != NULL; ++num_modes); + if (modes == NULL || modes == (SDL_Rect **) -1) + { + num_modes = 0; + } + else + { + for (num_modes=0; modes[num_modes] != NULL; ++num_modes); + } // Build the screen_modes_fullscreen array @@ -305,7 +316,7 @@ static void GenerateModesTable(TXT_UNCAST_ARG(widget), screen_height = modes[vidmode].h; } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) static int win32_video_driver = 0; @@ -384,7 +395,8 @@ void ConfigDisplay(void) window = TXT_NewWindow("Display Configuration"); - TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, 40, 5); + TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, + TXT_SCREEN_W / 2, 5); TXT_AddWidgets(window, fs_checkbox = TXT_NewCheckBox("Fullscreen", &fullscreen), @@ -397,7 +409,7 @@ void ConfigDisplay(void) // On Windows, there is an extra control to change between // the Windows GDI and DirectX video drivers. -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) { txt_table_t *driver_table; txt_dropdown_list_t *driver_list; diff --git a/setup/execute.c b/setup/execute.c index b5b8a7c6..03a4f65c 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -28,11 +28,21 @@ #include <sys/types.h> -#ifndef _WIN32 - #include <sys/wait.h> - #include <unistd.h> +#if defined(_WIN32_WCE) +#include "libc_wince.h" +#endif + +#ifdef _WIN32 + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <process.h> + #else - #include <process.h> + +#include <sys/wait.h> +#include <unistd.h> + #endif #include "textscreen.h" @@ -71,7 +81,6 @@ static char *TempFile(char *s) char *tempdir; #ifdef _WIN32 - // Check the TEMP environment variable to find the location. tempdir = getenv("TEMP"); @@ -139,19 +148,131 @@ void AddCmdLineParameter(execute_context_t *context, char *s, ...) fprintf(context->stream, "\n"); } -#ifdef _WIN32 +#if defined(_WIN32) -static int ExecuteCommand(const char **argv) +// Wait for the specified process to exit. Returns the exit code. + +static unsigned int WaitForProcessExit(HANDLE subprocess) { - return _spawnv(_P_WAIT, argv[0], argv); + DWORD exit_code; + + for (;;) + { + WaitForSingleObject(subprocess, INFINITE); + + if (!GetExitCodeProcess(subprocess, &exit_code)) + { + return -1; + } + + if (exit_code != STILL_ACTIVE) + { + return exit_code; + } + } +} + +static wchar_t *GetFullExePath(const char *program) +{ + wchar_t *result; + unsigned int path_len; + char *sep; + + // Find the full path to the EXE to execute, by taking the path + // to this program and concatenating the EXE name: + + sep = strrchr(myargv[0], DIR_SEPARATOR); + + if (sep == NULL) + { + path_len = 0; + result = calloc(strlen(program) + 1, sizeof(wchar_t)); + } + else + { + path_len = sep - myargv[0] + 1; + + result = calloc(path_len + strlen(program) + 1, + sizeof(wchar_t)); + MultiByteToWideChar(CP_OEMCP, 0, + myargv[0], path_len, + result, path_len); + } + + MultiByteToWideChar(CP_OEMCP, 0, + program, strlen(program) + 1, + result + path_len, strlen(program) + 1); + + return result; +} + +// Convert command line argument to wchar_t string and add surrounding +// "" quotes: + +static wchar_t *GetPaddedWideArg(const char *arg) +{ + wchar_t *result; + unsigned int len = strlen(arg); + + // Convert the command line arg to a wide char string: + + result = calloc(len + 3, sizeof(wchar_t)); + MultiByteToWideChar(CP_OEMCP, 0, + arg, len + 1, + result + 1, len + 1); + + // Surrounding quotes: + + result[0] = '"'; + result[len + 1] = '"'; + result[len + 2] = 0; + + return result; +} + +static int ExecuteCommand(const char *program, const char *arg) +{ + PROCESS_INFORMATION proc_info; + wchar_t *exe_path; + wchar_t *warg; + int result = 0; + + exe_path = GetFullExePath(program); + warg = GetPaddedWideArg(arg); + + // Invoke the program: + + memset(&proc_info, 0, sizeof(proc_info)); + + if (!CreateProcessW(exe_path, warg, + NULL, NULL, FALSE, 0, NULL, NULL, NULL, + &proc_info)) + { + result = -1; + } + else + { + // Wait for the process to finish, and save the exit code. + + result = WaitForProcessExit(proc_info.hProcess); + + CloseHandle(proc_info.hProcess); + CloseHandle(proc_info.hThread); + } + + free(exe_path); + free(warg); + + return result; } #else -static int ExecuteCommand(const char **argv) +static int ExecuteCommand(const char *program, const char *arg) { pid_t childpid; int result; + const char *argv[] = { program, arg, NULL }; childpid = fork(); @@ -185,7 +306,6 @@ static int ExecuteCommand(const char **argv) int ExecuteDoom(execute_context_t *context) { - const char *argv[3]; char *response_file_arg; int result; @@ -196,17 +316,13 @@ int ExecuteDoom(execute_context_t *context) response_file_arg = malloc(strlen(context->response_file) + 2); sprintf(response_file_arg, "@%s", context->response_file); - argv[0] = DOOM_BINARY; - argv[1] = response_file_arg; - argv[2] = NULL; - // Run Doom - result = ExecuteCommand(argv); + result = ExecuteCommand(DOOM_BINARY, response_file_arg); free(response_file_arg); - - // Destroy context + + // Destroy context remove(context->response_file); free(context->response_file); free(context); @@ -242,8 +358,8 @@ static void TestCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data)) exec = NewExecuteContext(); AddCmdLineParameter(exec, "-testcontrols"); - AddCmdLineParameter(exec, "-config %s", main_cfg); - AddCmdLineParameter(exec, "-extraconfig %s", extra_cfg); + AddCmdLineParameter(exec, "-config \"%s\"", main_cfg); + AddCmdLineParameter(exec, "-extraconfig \"%s\"", extra_cfg); ExecuteDoom(exec); TXT_CloseWindow(testwindow); diff --git a/setup/keyboard.c b/setup/keyboard.c index 3a7ccb8f..79cb90e7 100644 --- a/setup/keyboard.c +++ b/setup/keyboard.c @@ -18,6 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. // + #include "textscreen.h" #include "doomtype.h" @@ -38,13 +39,89 @@ int key_use = ' '; int key_strafe = KEY_RALT; int key_speed = KEY_RSHIFT; +int key_pause = KEY_PAUSE; + +// Menu keys: + +int key_menu_activate = KEY_ESCAPE; +int key_menu_up = KEY_UPARROW; +int key_menu_down = KEY_DOWNARROW; +int key_menu_left = KEY_LEFTARROW; +int key_menu_right = KEY_RIGHTARROW; +int key_menu_back = KEY_BACKSPACE; +int key_menu_forward = KEY_ENTER; +int key_menu_confirm = 'y'; +int key_menu_abort = 'n'; + +int key_menu_help = KEY_F1; +int key_menu_save = KEY_F2; +int key_menu_load = KEY_F3; +int key_menu_volume = KEY_F4; +int key_menu_detail = KEY_F5; +int key_menu_qsave = KEY_F6; +int key_menu_endgame = KEY_F7; +int key_menu_messages = KEY_F8; +int key_menu_qload = KEY_F9; +int key_menu_quit = KEY_F10; +int key_menu_gamma = KEY_F11; + +int key_menu_incscreen = KEY_EQUALS; +int key_menu_decscreen = KEY_MINUS; + +int key_map_north = KEY_UPARROW; +int key_map_south = KEY_DOWNARROW; +int key_map_east = KEY_RIGHTARROW; +int key_map_west = KEY_LEFTARROW; +int key_map_zoomin = '='; +int key_map_zoomout = '-'; +int key_map_toggle = KEY_TAB; +int key_map_maxzoom = '0'; +int key_map_follow = 'f'; +int key_map_grid = 'g'; +int key_map_mark = 'm'; +int key_map_clearmark = 'c'; + +int key_weapon1 = '1'; +int key_weapon2 = '2'; +int key_weapon3 = '3'; +int key_weapon4 = '4'; +int key_weapon5 = '5'; +int key_weapon6 = '6'; +int key_weapon7 = '7'; +int key_weapon8 = '8'; + +int key_message_refresh = KEY_ENTER; + int vanilla_keyboard_mapping = 1; 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}; +// Keys within these groups cannot have the same value. + +static int *controls[] = { &key_left, &key_right, &key_up, &key_down, + &key_strafeleft, &key_straferight, &key_fire, + &key_use, &key_strafe, &key_speed, + &key_pause, + &key_weapon1, &key_weapon2, &key_weapon3, + &key_weapon4, &key_weapon5, &key_weapon6, + &key_weapon7, &key_weapon8, NULL }; + +static int *menu_nav[] = { &key_menu_activate, &key_menu_up, &key_menu_down, + &key_menu_left, &key_menu_right, &key_menu_back, + &key_menu_forward, NULL }; + +static int *shortcuts[] = { &key_menu_help, &key_menu_save, &key_menu_load, + &key_menu_volume, &key_menu_detail, &key_menu_qsave, + &key_menu_endgame, &key_menu_messages, + &key_menu_qload, &key_menu_quit, &key_menu_gamma, + &key_menu_incscreen, &key_menu_decscreen, + &key_message_refresh, NULL }; + +static int *map_keys[] = { &key_map_north, &key_map_south, &key_map_east, + &key_map_west, &key_map_zoomin, &key_map_zoomout, + &key_map_toggle, &key_map_maxzoom, &key_map_follow, + &key_map_grid, &key_map_mark, &key_map_clearmark, + NULL }; static void UpdateJoybSpeed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(var)) { @@ -66,26 +143,61 @@ static void UpdateJoybSpeed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(var)) } } -// Callback invoked when a key control is set +static int VarInGroup(int *variable, int **group) +{ + unsigned int i; -static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) + for (i=0; group[i] != NULL; ++i) + { + if (group[i] == variable) + { + return 1; + } + } + + return 0; +} + +static void CheckKeyGroup(int *variable, int **group) { - TXT_CAST_ARG(int, variable); unsigned int i; - for (i=0; i<arrlen(allkeys); ++i) + // Don't check unless the variable is in this group. + + if (!VarInGroup(variable, group)) + { + return; + } + + // If another variable has the same value as the new value, reset it. + + for (i=0; group[i] != NULL; ++i) { - if (*variable == *allkeys[i] && allkeys[i] != variable) + if (*variable == *group[i] && group[i] != variable) { // A different key has the same value. Clear the existing // value. This ensures that no two keys can have the same // value. - *allkeys[i] = 0; + *group[i] = 0; } } } +// Callback invoked when a key control is set + +static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) +{ + TXT_CAST_ARG(int, variable); + + CheckKeyGroup(variable, controls); + CheckKeyGroup(variable, menu_nav); + CheckKeyGroup(variable, shortcuts); + CheckKeyGroup(variable, map_keys); +} + +// Add a label and keyboard input to the specified table. + static void AddKeyControl(txt_table_t *table, char *name, int *var) { txt_key_input_t *key_input; @@ -93,9 +205,99 @@ static void AddKeyControl(txt_table_t *table, char *name, int *var) TXT_AddWidget(table, TXT_NewLabel(name)); key_input = TXT_NewKeyInput(var); TXT_AddWidget(table, key_input); + TXT_SignalConnect(key_input, "set", KeySetCallback, var); } +static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) +{ + txt_window_t *window; + txt_table_t *table; + txt_scrollpane_t *scrollpane; + + window = TXT_NewWindow("Other keys"); + + table = TXT_NewTable(2); + + TXT_SetColumnWidths(table, 25, 10); + + TXT_AddWidgets(table, TXT_NewLabel(" - Weapons - "), + TXT_NewStrut(0, 0), + NULL); + + AddKeyControl(table, "Weapon 1", &key_weapon1); + AddKeyControl(table, "Weapon 2", &key_weapon2); + AddKeyControl(table, "Weapon 3", &key_weapon3); + AddKeyControl(table, "Weapon 4", &key_weapon4); + AddKeyControl(table, "Weapon 5", &key_weapon5); + AddKeyControl(table, "Weapon 6", &key_weapon6); + AddKeyControl(table, "Weapon 7", &key_weapon7); + AddKeyControl(table, "Weapon 8", &key_weapon8); + + TXT_AddWidgets(table, TXT_NewStrut(0, 1), + TXT_NewStrut(0, 1), + TXT_NewLabel(" - Menu navigation - "), + TXT_NewStrut(0, 0), + NULL); + + AddKeyControl(table, "Activate menu", &key_menu_activate); + AddKeyControl(table, "Move cursor up", &key_menu_up); + AddKeyControl(table, "Move cursor down", &key_menu_down); + AddKeyControl(table, "Move slider left", &key_menu_left); + AddKeyControl(table, "Move slider right", &key_menu_right); + AddKeyControl(table, "Go to previous menu", &key_menu_back); + AddKeyControl(table, "Activate menu item", &key_menu_forward); + AddKeyControl(table, "Confirm action", &key_menu_confirm); + AddKeyControl(table, "Cancel action", &key_menu_abort); + + TXT_AddWidgets(table, TXT_NewStrut(0, 1), + TXT_NewStrut(0, 1), + TXT_NewLabel(" - Shortcut keys - "), + TXT_NewStrut(0, 0), + NULL); + + AddKeyControl(table, "Pause game", &key_pause); + AddKeyControl(table, "Help screen", &key_menu_help); + AddKeyControl(table, "Save game", &key_menu_save); + AddKeyControl(table, "Load game", &key_menu_load); + AddKeyControl(table, "Sound volume", &key_menu_volume); + AddKeyControl(table, "Toggle detail", &key_menu_detail); + AddKeyControl(table, "Quick save", &key_menu_qsave); + AddKeyControl(table, "End game", &key_menu_endgame); + AddKeyControl(table, "Toggle messages", &key_menu_messages); + AddKeyControl(table, "Quick load", &key_menu_qload); + AddKeyControl(table, "Quit game", &key_menu_quit); + AddKeyControl(table, "Toggle gamma", &key_menu_gamma); + + AddKeyControl(table, "Increase screen size", &key_menu_incscreen); + AddKeyControl(table, "Decrease screen size", &key_menu_decscreen); + + AddKeyControl(table, "Display last message", &key_message_refresh); + + TXT_AddWidgets(table, TXT_NewStrut(0, 1), + TXT_NewStrut(0, 1), + TXT_NewLabel(" - Map - "), + TXT_NewStrut(0, 0), + NULL); + + AddKeyControl(table, "Toggle map", &key_map_toggle); + AddKeyControl(table, "Zoom in", &key_map_zoomin); + AddKeyControl(table, "Zoom out", &key_map_zoomout); + AddKeyControl(table, "Maximum zoom out", &key_map_maxzoom); + AddKeyControl(table, "Follow mode", &key_map_follow); + AddKeyControl(table, "Pan north", &key_map_north); + AddKeyControl(table, "Pan south", &key_map_south); + AddKeyControl(table, "Pan east", &key_map_east); + AddKeyControl(table, "Pan west", &key_map_west); + AddKeyControl(table, "Toggle grid", &key_map_grid); + AddKeyControl(table, "Mark location", &key_map_mark); + AddKeyControl(table, "Clear all marks", &key_map_clearmark); + + scrollpane = TXT_NewScrollPane(0, 12, table); + + TXT_AddWidget(window, scrollpane); +} + void ConfigKeyboard(void) { txt_window_t *window; @@ -107,36 +309,39 @@ void ConfigKeyboard(void) window = TXT_NewWindow("Keyboard configuration"); - TXT_AddWidgets(window, + TXT_AddWidgets(window, TXT_NewSeparator("Movement"), - movement_table = TXT_NewTable(2), + movement_table = TXT_NewTable(4), TXT_NewSeparator("Action"), - action_table = TXT_NewTable(2), + action_table = TXT_NewTable(4), + TXT_NewButton2("Other keys...", OtherKeysDialog, NULL), + NULL); + TXT_AddWidgets(window, TXT_NewSeparator("Misc."), run_control = TXT_NewCheckBox("Always run", &always_run), TXT_NewInvertedCheckBox("Use native keyboard mapping", &vanilla_keyboard_mapping), NULL); - TXT_SetColumnWidths(movement_table, 20, 8); + TXT_SetColumnWidths(movement_table, 15, 4, 15, 4); TXT_SignalConnect(run_control, "changed", UpdateJoybSpeed, NULL); AddKeyControl(movement_table, "Move Forward", &key_up); + AddKeyControl(movement_table, " Strafe Left", &key_strafeleft); AddKeyControl(movement_table, "Move Backward", &key_down); + AddKeyControl(movement_table, " Strafe Right", &key_straferight); AddKeyControl(movement_table, "Turn Left", &key_left); + AddKeyControl(movement_table, " Speed On", &key_speed); AddKeyControl(movement_table, "Turn Right", &key_right); - AddKeyControl(movement_table, "Strafe Left", &key_strafeleft); - AddKeyControl(movement_table, "Strafe Right", &key_straferight); - AddKeyControl(movement_table, "Speed On", &key_speed); - AddKeyControl(movement_table, "Strafe On", &key_strafe); + AddKeyControl(movement_table, " Strafe On", &key_strafe); - TXT_SetColumnWidths(action_table, 20, 8); + TXT_SetColumnWidths(action_table, 15, 4, 15, 4); - AddKeyControl(action_table, "Use", &key_use); - AddKeyControl(action_table, "Fire", &key_fire); + AddKeyControl(action_table, "Fire/Attack", &key_fire); + AddKeyControl(action_table, " Use", &key_use); TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction()); } diff --git a/setup/keyboard.h b/setup/keyboard.h index 6442e1e4..fa3c0db3 100644 --- a/setup/keyboard.h +++ b/setup/keyboard.h @@ -35,6 +35,63 @@ extern int key_speed; extern int joybspeed; extern int vanilla_keyboard_mapping; +extern int key_pause; + +// Menu keys: + +extern int key_menu_activate; +extern int key_menu_up; +extern int key_menu_down; +extern int key_menu_left; +extern int key_menu_right; +extern int key_menu_back; +extern int key_menu_forward; +extern int key_menu_confirm; +extern int key_menu_abort; + +extern int key_menu_help; +extern int key_menu_save; +extern int key_menu_load; +extern int key_menu_volume; +extern int key_menu_detail; +extern int key_menu_qsave; +extern int key_menu_endgame; +extern int key_menu_messages; +extern int key_menu_qload; +extern int key_menu_quit; +extern int key_menu_gamma; + +extern int key_menu_incscreen; +extern int key_menu_decscreen; + +// Automap keys: + +extern int key_map_north; +extern int key_map_south; +extern int key_map_east; +extern int key_map_west; +extern int key_map_zoomin; +extern int key_map_zoomout; +extern int key_map_toggle; +extern int key_map_maxzoom; +extern int key_map_follow; +extern int key_map_grid; +extern int key_map_mark; +extern int key_map_clearmark; + +// Weapon keys: + +extern int key_weapon1; +extern int key_weapon2; +extern int key_weapon3; +extern int key_weapon4; +extern int key_weapon5; +extern int key_weapon6; +extern int key_weapon7; +extern int key_weapon8; + +extern int key_message_refresh; + void ConfigKeyboard(void); #endif /* #ifndef SETUP_KEYBOARD_H */ diff --git a/setup/mainmenu.c b/setup/mainmenu.c index d4dfe0db..c7e4f48d 100644 --- a/setup/mainmenu.c +++ b/setup/mainmenu.c @@ -18,7 +18,13 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. // + #include <stdlib.h> +#include <string.h> + +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif #include "config.h" #include "textscreen.h" @@ -137,6 +143,8 @@ void MainMenu(void) static void InitConfig(void) { + M_ApplyPlatformDefaults(); + SetChatMacroDefaults(); SetPlayerNameDefault(); @@ -212,6 +220,15 @@ int main(int argc, char *argv[]) myargc = argc; myargv = argv; +#ifdef _WIN32_WCE + + // Windows CE has no environment, but SDL provides an implementation. + // Populate the environment with the values we normally find. + + PopulateEnvironment(); + +#endif + InitConfig(); RunGUI(); diff --git a/setup/multiplayer.c b/setup/multiplayer.c index cbc76dde..ee46c3f1 100644 --- a/setup/multiplayer.c +++ b/setup/multiplayer.c @@ -48,6 +48,12 @@ typedef enum WARP_DOOM2, } warptype_t; +typedef enum +{ + JOIN_AUTO_LAN, + JOIN_ADDRESS, +} jointype_t; + static iwad_t iwads[] = { { "doom.wad", "Doom", IWAD_DOOM }, @@ -98,6 +104,8 @@ static char *gamemodes[] = char *net_player_name; char *chat_macros[10]; +static int jointype = JOIN_ADDRESS; + static char *wads[NUM_WADS]; static char *extra_params[NUM_EXTRA_PARAMS]; static int skill = 2; @@ -608,7 +616,14 @@ static void DoJoinGame(void *unused1, void *unused2) exec = NewExecuteContext(); - AddCmdLineParameter(exec, "-connect %s", connect_address); + if (jointype == JOIN_ADDRESS) + { + AddCmdLineParameter(exec, "-connect %s", connect_address); + } + else if (jointype == JOIN_AUTO_LAN) + { + AddCmdLineParameter(exec, "-autojoin"); + } // Extra parameters come first, so that they can be used to override // the other parameters. @@ -638,18 +653,28 @@ static txt_window_action_t *JoinGameAction(void) return action; } +// When an address is entered, select "address" mode. + +static void SelectAddressJoin(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) +{ + jointype = JOIN_ADDRESS; +} + void JoinMultiGame(void) { txt_window_t *window; txt_table_t *gameopt_table; + txt_table_t *serveropt_table; + txt_inputbox_t *address_box; window = TXT_NewWindow("Join multiplayer game"); TXT_AddWidgets(window, gameopt_table = TXT_NewTable(2), + TXT_NewSeparator("Server"), + serveropt_table = TXT_NewTable(2), TXT_NewStrut(0, 1), TXT_NewButton2("Add extra parameters...", OpenExtraParamsWindow, NULL), - // TXT_NewButton2("Add WADs...", OpenWadsWindow, NULL), NULL); TXT_SetColumnWidths(gameopt_table, 12, 12); @@ -657,10 +682,19 @@ void JoinMultiGame(void) TXT_AddWidgets(gameopt_table, TXT_NewLabel("Game"), IWADSelector(), - TXT_NewLabel("Server address "), - TXT_NewInputBox(&connect_address, 40), NULL); + TXT_AddWidgets(serveropt_table, + TXT_NewRadioButton("Connect to address:", + &jointype, JOIN_ADDRESS), + address_box = TXT_NewInputBox(&connect_address, 30), + TXT_NewRadioButton("Auto-join LAN game", + &jointype, JOIN_AUTO_LAN), + NULL); + + TXT_SignalConnect(address_box, "changed", SelectAddressJoin, NULL); + TXT_SelectWidget(window, address_box); + TXT_SetWindowAction(window, TXT_HORIZ_CENTER, WadWindowAction()); TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, JoinGameAction()); } diff --git a/setup/txt_keyinput.c b/setup/txt_keyinput.c index b7e68f44..e385cc59 100644 --- a/setup/txt_keyinput.c +++ b/setup/txt_keyinput.c @@ -57,6 +57,11 @@ static int KeyPressCallback(txt_window_t *window, int key, } } +static void ReleaseGrab(TXT_UNCAST_ARG(window), TXT_UNCAST_ARG(unused)) +{ + SDL_WM_GrabInput(SDL_GRAB_OFF); +} + static void OpenPromptWindow(txt_key_input_t *key_input) { txt_window_t *window; @@ -78,6 +83,13 @@ static void OpenPromptWindow(txt_key_input_t *key_input) // Disable key mappings while we prompt for the key press TXT_EnableKeyMapping(0); + + // Grab input while reading the key. On Windows Mobile + // handheld devices, the hardware keypresses are only + // detected when input is grabbed. + + SDL_WM_GrabInput(SDL_GRAB_ON); + TXT_SignalConnect(window, "closed", ReleaseGrab, NULL); } static void TXT_KeyInputSizeCalc(TXT_UNCAST_ARG(key_input)) |