ref: 9caebe584ccb95239b2ed360d4bce3dffc5ecfea
parent: 04f6f45fe3a20b2edc2fff2f0fbfa20ee54ad4df
author: Simon Howard <fraggle@gmail.com>
date: Fri Dec 10 14:15:37 EST 2010
Add "warp" menu to the main menu of the setup tool, like Vanilla setup.exe (thanks Proteh). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2206
--- a/NEWS
+++ b/NEWS
@@ -22,10 +22,12 @@
devices (ie. without a proper keyboard) much more practical.
* There is now a key binding to change the multiplayer spy key
(usually F12).
- * There is now a configuration file parameter to set the OPL I/O
- port, for cards that don't use port 0x388.
+ * The setup tool now has a "warp" button on the main menu, like
* Up to 8 mouse buttons are now supported (including the
mousewheel).
+ Vanilla setup.exe (thanks Proteh).
+ * There is now a configuration file parameter to set the OPL I/O
+ port, for cards that don't use port 0x388.
* The Python scripts used for building Chocolate Doom now work
with Python 3 (but also continue to work with Python 2)
(thanks arin).
--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -162,6 +162,7 @@
{
txt_window_t *window;
txt_window_action_t *quit_action;
+ txt_window_action_t *warp_action;
window = TXT_NewWindow("Main Menu");
@@ -189,8 +190,12 @@
NULL);
quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit");
+ warp_action = TXT_NewWindowAction(KEY_F1, "Warp");
TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL);
+ TXT_SignalConnect(warp_action, "pressed",
+ (TxtWidgetSignalFunc) WarpMenu, NULL);
TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action);
+ TXT_SetWindowAction(window, TXT_HORIZ_CENTER, warp_action);
TXT_SetKeyListener(window, MainMenuKeyPress, NULL);
}
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -189,7 +189,11 @@
}
}
-static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data))
+// Callback function invoked to launch the game.
+// This is used when starting a server and also when starting a
+// single player game via the "warp" menu.
+
+static void StartGame(int multiplayer)
{
execute_context_t *exec;
@@ -201,7 +205,6 @@
AddExtraParameters(exec);
AddIWADParameter(exec);
- AddCmdLineParameter(exec, "-server");
AddCmdLineParameter(exec, "-skill %i", skill + 1);
if (nomonsters)
@@ -219,20 +222,6 @@
AddCmdLineParameter(exec, "-respawn");
}
- if (deathmatch == 1)
- {
- AddCmdLineParameter(exec, "-deathmatch");
- }
- else if (deathmatch == 2)
- {
- AddCmdLineParameter(exec, "-altdeath");
- }
-
- if (timer > 0)
- {
- AddCmdLineParameter(exec, "-timer %i", timer);
- }
-
if (warptype == WARP_DOOM1)
{
// TODO: select IWAD based on warp type
@@ -243,8 +232,28 @@
AddCmdLineParameter(exec, "-warp %i", warpmap);
}
- AddCmdLineParameter(exec, "-port %i", udpport);
+ // Multiplayer-specific options:
+ if (multiplayer)
+ {
+ AddCmdLineParameter(exec, "-server");
+ AddCmdLineParameter(exec, "-port %i", udpport);
+
+ if (deathmatch == 1)
+ {
+ AddCmdLineParameter(exec, "-deathmatch");
+ }
+ else if (deathmatch == 2)
+ {
+ AddCmdLineParameter(exec, "-altdeath");
+ }
+
+ if (timer > 0)
+ {
+ AddCmdLineParameter(exec, "-timer %i", timer);
+ }
+ }
+
AddWADs(exec);
TXT_Shutdown();
@@ -257,6 +266,16 @@
exit(0);
}
+static void StartServerGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
+{
+ StartGame(1);
+}
+
+static void StartSinglePlayerGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
+{
+ StartGame(0);
+}
+
static void UpdateWarpButton(void)
{
char buf[10];
@@ -509,13 +528,28 @@
return result;
}
-static txt_window_action_t *StartGameAction(void)
+// Create the window action button to start the game. This invokes
+// a different callback depending on whether to start a multiplayer
+// or single player game.
+
+static txt_window_action_t *StartGameAction(int multiplayer)
{
txt_window_action_t *action;
+ TxtWidgetSignalFunc callback;
action = TXT_NewWindowAction(KEY_F10, "Start");
- TXT_SignalConnect(action, "pressed", StartGame, NULL);
+ if (multiplayer)
+ {
+ callback = StartServerGame;
+ }
+ else
+ {
+ callback = StartSinglePlayerGame;
+ }
+
+ TXT_SignalConnect(action, "pressed", callback, NULL);
+
return action;
}
@@ -556,7 +590,11 @@
return action;
}
-void StartMultiGame(void)
+// "Start game" menu. This is used for the start server window
+// and the single player warp menu. The parameters specify
+// the window title and whether to display multiplayer options.
+
+static void StartGameMenu(char *window_title, int multiplayer)
{
txt_window_t *window;
txt_table_t *gameopt_table;
@@ -563,7 +601,7 @@
txt_table_t *advanced_table;
txt_widget_t *iwad_selector;
- window = TXT_NewWindow("Start multiplayer game");
+ window = TXT_NewWindow(window_title);
TXT_AddWidgets(window,
gameopt_table = TXT_NewTable(2),
@@ -578,7 +616,7 @@
NULL);
TXT_SetWindowAction(window, TXT_HORIZ_CENTER, WadWindowAction());
- TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction());
+ TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction(multiplayer));
TXT_SetColumnWidths(gameopt_table, 12, 12);
@@ -587,27 +625,43 @@
iwad_selector = IWADSelector(),
TXT_NewLabel("Skill"),
skillbutton = TXT_NewDropdownList(&skill, skills, 5),
- TXT_NewLabel("Game type"),
- TXT_NewDropdownList(&deathmatch, gamemodes, 3),
TXT_NewLabel("Level warp"),
warpbutton = TXT_NewButton2("????", LevelSelectDialog, NULL),
- TXT_NewLabel("Time limit"),
- TXT_NewHorizBox(TXT_NewIntInputBox(&timer, 2),
- TXT_NewLabel("minutes"),
- NULL),
NULL);
+ if (multiplayer)
+ {
+ TXT_AddWidgets(gameopt_table,
+ TXT_NewLabel("Game type"),
+ TXT_NewDropdownList(&deathmatch, gamemodes, 3),
+ TXT_NewLabel("Time limit"),
+ TXT_NewHorizBox(TXT_NewIntInputBox(&timer, 2),
+ TXT_NewLabel("minutes"),
+ NULL),
+ NULL);
+
+ TXT_AddWidgets(advanced_table,
+ TXT_NewLabel("UDP port"),
+ TXT_NewIntInputBox(&udpport, 5),
+ NULL);
+ }
+
TXT_SetColumnWidths(advanced_table, 12, 12);
TXT_SignalConnect(iwad_selector, "changed", UpdateWarpType, NULL);
- TXT_AddWidgets(advanced_table,
- TXT_NewLabel("UDP port"),
- TXT_NewIntInputBox(&udpport, 5),
- NULL);
-
UpdateWarpType(NULL, NULL);
UpdateWarpButton();
+}
+
+void StartMultiGame(void)
+{
+ StartGameMenu("Start multiplayer game", 1);
+}
+
+void WarpMenu(void)
+{
+ StartGameMenu("Level Warp", 0);
}
static void DoJoinGame(void *unused1, void *unused2)
--- a/setup/multiplayer.h
+++ b/setup/multiplayer.h
@@ -26,6 +26,7 @@
extern char *chat_macros[10];
void StartMultiGame(void);
+void WarpMenu(void);
void JoinMultiGame(void);
void MultiplayerConfig(void);