ref: 144849eee5804a0306d23f07a5be9877f242a1bf
parent: 21d67cd73010165b0da5bf0c10439db2fb4f882a
author: Simon Howard <[email protected]>
date: Tue May 12 14:03:20 EDT 2009
Add option to "join game" dialog in setup tool to autojoin a LAN game. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1521
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -48,6 +48,12 @@
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 @@
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 @@
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 @@
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,9 +682,18 @@
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());