From 144849eee5804a0306d23f07a5be9877f242a1bf Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 12 May 2009 18:03:20 +0000 Subject: Add option to "join game" dialog in setup tool to autojoin a LAN game. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1521 --- setup/multiplayer.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'setup') 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()); } -- cgit v1.2.3 From bd20fc62a36475e7a9fff269784d0f1e5c1128b4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 21 May 2009 19:18:38 +0000 Subject: Set display settings window position based on screen dimensions, rather than hard coding position. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1527 --- setup/display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/display.c b/setup/display.c index 5e9d4fcf..7bcf0d5b 100644 --- a/setup/display.c +++ b/setup/display.c @@ -384,7 +384,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), -- cgit v1.2.3 From adcd838e72854528dec15016b32b6e0bfa292fcd Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 20:45:54 +0000 Subject: Add dialog to setup tool for editing menu shortcuts. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1546 --- setup/configfile.c | 23 +++++++++++++++ setup/keyboard.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++- setup/keyboard.h | 25 ++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/configfile.c b/setup/configfile.c index 3f75d7f1..97e06744 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -239,6 +239,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 +283,28 @@ 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_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}, }; static default_collection_t extra_defaults = diff --git a/setup/keyboard.c b/setup/keyboard.c index 3a7ccb8f..c4d4fbec 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,6 +39,33 @@ int key_use = ' '; int key_strafe = KEY_RALT; int key_speed = KEY_RSHIFT; +// 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 vanilla_keyboard_mapping = 1; static int always_run = 0; @@ -86,16 +114,72 @@ static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) } } -static void AddKeyControl(txt_table_t *table, char *name, int *var) +// Add a label and keyboard input to the specified table. + +static txt_key_input_t *AddKeyInput(txt_table_t *table, char *name, int *var) { txt_key_input_t *key_input; TXT_AddWidget(table, TXT_NewLabel(name)); key_input = TXT_NewKeyInput(var); TXT_AddWidget(table, key_input); + + return key_input; +} + +// Add a keyboard input for a game control. Each key can only be bound +// to one game control at a time. + +static void AddKeyControl(txt_table_t *table, char *name, int *var) +{ + txt_key_input_t *key_input; + + key_input = AddKeyInput(table, name, var); TXT_SignalConnect(key_input, "set", KeySetCallback, var); } +static void MenuKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) +{ + txt_window_t *window; + txt_table_t *table; + txt_scrollpane_t *scrollpane; + + window = TXT_NewWindow("Menu keys"); + + table = TXT_NewTable(2); + + TXT_SetColumnWidths(table, 25, 10); + + AddKeyInput(table, "Activate menu", &key_menu_activate); + AddKeyInput(table, "Move cursor up", &key_menu_up); + AddKeyInput(table, "Move cursor down", &key_menu_down); + AddKeyInput(table, "Move slider left", &key_menu_left); + AddKeyInput(table, "Move slider right", &key_menu_right); + AddKeyInput(table, "Go to previous menu", &key_menu_back); + AddKeyInput(table, "Activate menu item", &key_menu_forward); + AddKeyInput(table, "Confirm action", &key_menu_confirm); + AddKeyInput(table, "Cancel action", &key_menu_abort); + + AddKeyInput(table, "Help screen", &key_menu_help); + AddKeyInput(table, "Save game", &key_menu_save); + AddKeyInput(table, "Load game", &key_menu_load); + AddKeyInput(table, "Sound volume", &key_menu_volume); + AddKeyInput(table, "Toggle detail", &key_menu_detail); + AddKeyInput(table, "Quick save", &key_menu_qsave); + AddKeyInput(table, "End game", &key_menu_endgame); + AddKeyInput(table, "Toggle messages", &key_menu_messages); + AddKeyInput(table, "Quick load", &key_menu_qload); + AddKeyInput(table, "Quit game", &key_menu_quit); + AddKeyInput(table, "Toggle gamma", &key_menu_gamma); + + AddKeyInput(table, "Increase screen size", &key_menu_incscreen); + AddKeyInput(table, "Decrease screen size", &key_menu_decscreen); + + scrollpane = TXT_NewScrollPane(0, 10, table); + + TXT_AddWidget(window, scrollpane); +} + void ConfigKeyboard(void) { txt_window_t *window; @@ -113,6 +197,7 @@ void ConfigKeyboard(void) TXT_NewSeparator("Action"), action_table = TXT_NewTable(2), + TXT_NewButton2("Menu keys...", MenuKeysDialog, NULL), TXT_NewSeparator("Misc."), run_control = TXT_NewCheckBox("Always run", &always_run), diff --git a/setup/keyboard.h b/setup/keyboard.h index 6442e1e4..19ce7147 100644 --- a/setup/keyboard.h +++ b/setup/keyboard.h @@ -35,6 +35,31 @@ extern int key_speed; extern int joybspeed; extern int vanilla_keyboard_mapping; +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; + void ConfigKeyboard(void); #endif /* #ifndef SETUP_KEYBOARD_H */ -- cgit v1.2.3 From 3c2e7735a0134c5ce6af9624b65b7f3d27c752f1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 23:20:37 +0000 Subject: Add unique key groups for menu navigation and shortcuts. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1548 --- setup/keyboard.c | 137 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 52 deletions(-) (limited to 'setup') diff --git a/setup/keyboard.c b/setup/keyboard.c index c4d4fbec..2e791c7a 100644 --- a/setup/keyboard.c +++ b/setup/keyboard.c @@ -70,9 +70,21 @@ 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, 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 void UpdateJoybSpeed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(var)) { @@ -94,47 +106,68 @@ 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 -#ifndef _WIN32 - #include - #include +#if defined(_WIN32_WCE) + +#include "libc_wince.h" + +#elif defined(_WIN32) + +#include +#include + #else - #include + +#include + #endif #include "textscreen.h" @@ -139,7 +147,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/setup/mainmenu.c b/setup/mainmenu.c index d4dfe0db..d340661b 100644 --- a/setup/mainmenu.c +++ b/setup/mainmenu.c @@ -18,7 +18,9 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. // + #include +#include #include "config.h" #include "textscreen.h" -- cgit v1.2.3 From ad9f8107f4d9d4ea636eb238205f31270cc1514a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 16:35:43 +0000 Subject: Don't try to use the SDL DirectX driver under Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1568 --- setup/display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/display.c b/setup/display.c index 7bcf0d5b..befec91f 100644 --- a/setup/display.c +++ b/setup/display.c @@ -116,7 +116,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"); -- cgit v1.2.3 From ef459ab99b18d26f502d423a31cd744f5bed6a88 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 17:33:19 +0000 Subject: Fix setup tool display configuration dialog when fullscreen is not supported. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1572 --- setup/display.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/display.c b/setup/display.c index befec91f..38f301a1 100644 --- a/setup/display.c +++ b/setup/display.c @@ -187,7 +187,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 -- cgit v1.2.3 From 0e3e4653f8df775fdd41e18e956f465fd334f275 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 17:53:25 +0000 Subject: Use home dir to store configuration and savegames under Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1573 --- setup/configfile.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'setup') diff --git a/setup/configfile.c b/setup/configfile.c index 5013e3ce..3714a35f 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -74,7 +74,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 +82,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 +99,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 +109,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. -- cgit v1.2.3 From ea3b0114bd51314ee649a74d78ce080aa581429f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 18:18:02 +0000 Subject: Don't add DirectX/Windib selector on Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1574 --- setup/display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setup') diff --git a/setup/display.c b/setup/display.c index 38f301a1..a0960dfe 100644 --- a/setup/display.c +++ b/setup/display.c @@ -312,7 +312,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; @@ -405,7 +405,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; -- cgit v1.2.3 From d9be068243f518d50bd4577db58693219b3acd57 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 19:08:08 +0000 Subject: Fix header includes (thanks exp[x]) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1575 --- setup/execute.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setup') diff --git a/setup/execute.c b/setup/execute.c index 8f082de7..cbcab29e 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -34,12 +34,12 @@ #elif defined(_WIN32) -#include -#include +#include #else -#include +#include +#include #endif -- cgit v1.2.3 From a91a1c60f544d26195c2df9dd9cd1ef042deacf9 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 8 Jun 2009 18:15:57 +0000 Subject: Use SDL's getenv/putenv implementation, and populate at startup. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1577 --- setup/mainmenu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'setup') diff --git a/setup/mainmenu.c b/setup/mainmenu.c index d340661b..6a1f01c2 100644 --- a/setup/mainmenu.c +++ b/setup/mainmenu.c @@ -22,6 +22,10 @@ #include #include +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + #include "config.h" #include "textscreen.h" @@ -214,6 +218,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(); -- cgit v1.2.3 From ac28eb407daaee8a92fb9efb28ac2426c4edb97b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 10 Jun 2009 19:03:08 +0000 Subject: Add key bindings for pause, message refresh. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1586 --- setup/configfile.c | 2 ++ setup/keyboard.c | 11 ++++++++++- setup/keyboard.h | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'setup') diff --git a/setup/configfile.c b/setup/configfile.c index 3714a35f..3b6007f5 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -287,6 +287,7 @@ static default_t extra_defaults_list[] = {"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}, @@ -330,6 +331,7 @@ static default_t extra_defaults_list[] = {"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 = diff --git a/setup/keyboard.c b/setup/keyboard.c index 27ade663..79cb90e7 100644 --- a/setup/keyboard.c +++ b/setup/keyboard.c @@ -39,6 +39,8 @@ 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; @@ -88,6 +90,8 @@ 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; @@ -97,6 +101,7 @@ static int always_run = 0; 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 }; @@ -109,7 +114,8 @@ 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 }; + &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, @@ -250,6 +256,7 @@ static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) 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); @@ -265,6 +272,8 @@ static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) 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 - "), diff --git a/setup/keyboard.h b/setup/keyboard.h index 29ff2a1a..fa3c0db3 100644 --- a/setup/keyboard.h +++ b/setup/keyboard.h @@ -35,6 +35,8 @@ extern int key_speed; extern int joybspeed; extern int vanilla_keyboard_mapping; +extern int key_pause; + // Menu keys: extern int key_menu_activate; @@ -88,6 +90,8 @@ 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 */ -- cgit v1.2.3 From 3a4db2509420fa89c2ee940cc0998d0d614d63a5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 11 Jun 2009 18:19:05 +0000 Subject: Include libc_wince.h on Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1593 --- setup/display.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setup') diff --git a/setup/display.c b/setup/display.c index a0960dfe..596b8a43 100644 --- a/setup/display.c +++ b/setup/display.c @@ -21,6 +21,10 @@ #include +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + #include "textscreen.h" #include "display.h" -- cgit v1.2.3 From 779a2157c0e5afe358b03c8236e88a661b35bca0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 11 Jun 2009 19:41:20 +0000 Subject: Grab the input in setup when reading a new key binding, so that Windows CE buttons are read properly. Map buttons to PC function keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1594 --- setup/txt_keyinput.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'setup') 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)) -- cgit v1.2.3 From d4863b4c4ac47766b5fd3b8b0949be7af792e3d0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 19:07:55 +0000 Subject: On Windows CE systems without a keyboard, patch the default settings to use hardware keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1600 --- setup/configfile.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/configfile.h | 2 ++ setup/mainmenu.c | 2 ++ 3 files changed, 80 insertions(+) (limited to 'setup') diff --git a/setup/configfile.c b/setup/configfile.c index 3b6007f5..fe3c13de 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -35,6 +35,8 @@ #ifdef _WIN32 #include +#define WIN32_LEAN_AND_MEAN +#include #else #include #include @@ -647,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/mainmenu.c b/setup/mainmenu.c index 6a1f01c2..c7e4f48d 100644 --- a/setup/mainmenu.c +++ b/setup/mainmenu.c @@ -143,6 +143,8 @@ void MainMenu(void) static void InitConfig(void) { + M_ApplyPlatformDefaults(); + SetChatMacroDefaults(); SetPlayerNameDefault(); -- cgit v1.2.3 From e806e6a6497d2e282ff66f78e68cc3a6214a7921 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 7 Jul 2009 19:38:00 +0000 Subject: Fix launching of the game from the setup tool in Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1608 --- setup/execute.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 121 insertions(+), 22 deletions(-) (limited to 'setup') diff --git a/setup/execute.c b/setup/execute.c index cbcab29e..03a4f65c 100644 --- a/setup/execute.c +++ b/setup/execute.c @@ -29,11 +29,13 @@ #include #if defined(_WIN32_WCE) - #include "libc_wince.h" +#endif -#elif defined(_WIN32) +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #include #else @@ -79,7 +81,6 @@ static char *TempFile(char *s) char *tempdir; #ifdef _WIN32 - // Check the TEMP environment variable to find the location. tempdir = getenv("TEMP"); @@ -147,28 +148,131 @@ void AddCmdLineParameter(execute_context_t *context, char *s, ...) fprintf(context->stream, "\n"); } -#if defined(_WIN32_WCE) +#if defined(_WIN32) + +// Wait for the specified process to exit. Returns the exit code. -static int ExecuteCommand(const char **argv) +static unsigned int WaitForProcessExit(HANDLE subprocess) { - // Windows CE version. - // TODO - return 0; + DWORD exit_code; + + for (;;) + { + WaitForSingleObject(subprocess, INFINITE); + + if (!GetExitCodeProcess(subprocess, &exit_code)) + { + return -1; + } + + if (exit_code != STILL_ACTIVE) + { + return exit_code; + } + } } -#elif defined(_WIN32) +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); + } -static int ExecuteCommand(const char **argv) + 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) { - return _spawnv(_P_WAIT, argv[0], argv); + 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(); @@ -202,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; @@ -213,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); @@ -259,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); -- cgit v1.2.3