diff options
Diffstat (limited to 'src/setup')
-rw-r--r-- | src/setup/display.c | 15 | ||||
-rw-r--r-- | src/setup/execute.c | 27 | ||||
-rw-r--r-- | src/setup/keyboard.c | 223 | ||||
-rw-r--r-- | src/setup/keyboard.h | 53 | ||||
-rw-r--r-- | src/setup/mainmenu.c | 5 |
5 files changed, 299 insertions, 24 deletions
diff --git a/src/setup/display.c b/src/setup/display.c index 3efe3ec1..4918d045 100644 --- a/src/setup/display.c +++ b/src/setup/display.c @@ -121,7 +121,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"); @@ -192,7 +192,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 @@ -310,7 +317,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; @@ -403,7 +410,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/src/setup/execute.c b/src/setup/execute.c index 0b5faa65..1b510f2e 100644 --- a/src/setup/execute.c +++ b/src/setup/execute.c @@ -28,11 +28,19 @@ #include <sys/types.h> -#ifndef _WIN32 - #include <sys/wait.h> - #include <unistd.h> +#if defined(_WIN32_WCE) + +#include "libc_wince.h" + +#elif defined(_WIN32) + +#include <process.h> + #else - #include <process.h> + +#include <sys/wait.h> +#include <unistd.h> + #endif #include "textscreen.h" @@ -126,7 +134,16 @@ void AddCmdLineParameter(execute_context_t *context, char *s, ...) fprintf(context->stream, "\n"); } -#ifdef _WIN32 +#if defined(_WIN32_WCE) + +static int ExecuteCommand(const char **argv) +{ + // Windows CE version. + // TODO + return 0; +} + +#elif defined(_WIN32) static int ExecuteCommand(const char **argv) { diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index 22fc8a02..e6d0143d 100644 --- a/src/setup/keyboard.c +++ b/src/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" #include "m_config.h" @@ -32,16 +33,85 @@ static int vanilla_keyboard_mapping = 1; +// 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'; + static int always_run = 0; -static int *allkeys[] = { - &key_left, &key_right, &key_up, &key_down, - &key_strafeleft, &key_straferight, &key_strafe, - &key_jump, &key_fire, &key_use, &key_speed, - &key_flyup, &key_flydown, &key_flycenter, - &key_lookup, &key_lookdown, &key_lookcenter, - &key_invleft, &key_invright, &key_useartifact -}; +// 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_jump, + &key_flyup, &key_flydown, &key_flycenter, + &key_lookup, &key_lookdown, &key_lookcenter, + &key_invleft, &key_invright, &key_useartifact, + &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, 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)) { @@ -63,26 +133,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)) { - if (*variable == *allkeys[i] && allkeys[i] != variable) + return; + } + + // If another variable has the same value as the new value, reset it. + + for (i=0; group[i] != NULL; ++i) + { + 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; @@ -90,6 +195,7 @@ 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); } @@ -130,6 +236,92 @@ static void ConfigExtraKeys(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) AddKeyControl(inv_table, "Use artifact", &key_useartifact); } +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, "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); + + 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; @@ -141,12 +333,13 @@ void ConfigKeyboard(void) window = TXT_NewWindow("Keyboard configuration"); - TXT_AddWidgets(window, + TXT_AddWidgets(window, TXT_NewSeparator("Movement"), movement_table = TXT_NewTable(4), TXT_NewSeparator("Action"), action_table = TXT_NewTable(4), + TXT_NewButton2("Other keys...", OtherKeysDialog, NULL), NULL); // Look up/down, inventory and flying controls are only in Heretic/Hexen diff --git a/src/setup/keyboard.h b/src/setup/keyboard.h index 12059bf8..2797ba8f 100644 --- a/src/setup/keyboard.h +++ b/src/setup/keyboard.h @@ -22,6 +22,59 @@ #ifndef SETUP_KEYBOARD_H #define SETUP_KEYBOARD_H +// 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; + void ConfigKeyboard(void); void BindKeyboardVariables(void); diff --git a/src/setup/mainmenu.c b/src/setup/mainmenu.c index d7b8e676..3b79bc94 100644 --- a/src/setup/mainmenu.c +++ b/src/setup/mainmenu.c @@ -22,6 +22,10 @@ #include <stdlib.h> #include <string.h> +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + #include "config.h" #include "textscreen.h" @@ -252,6 +256,7 @@ static void MissionSet(void) void D_DoomMain(void) { SetupMission(MissionSet); + RunGUI(); } |