2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 void (*vid_menudrawfn)(void);
27 void (*vid_menukeyfn)(int key);
35 enum m_state_e m_state;
37 void M_Menu_Main_f (void);
38 void M_Menu_SinglePlayer_f (void);
39 void M_Menu_Load_f (void);
40 void M_Menu_Save_f (void);
41 void M_Menu_MultiPlayer_f (void);
42 void M_Menu_Setup_f (void);
43 void M_Menu_Net_f (void);
44 void M_Menu_Options_f (void);
45 void M_Menu_Keys_f (void);
46 void M_Menu_Video_f (void);
47 void M_Menu_Help_f (void);
48 void M_Menu_Quit_f (void);
49 void M_Menu_LanConfig_f (void);
50 void M_Menu_GameOptions_f (void);
51 void M_Menu_Search_f (void);
52 void M_Menu_ServerList_f (void);
54 void M_Main_Draw (void);
55 void M_SinglePlayer_Draw (void);
56 void M_Load_Draw (void);
57 void M_Save_Draw (void);
58 void M_MultiPlayer_Draw (void);
59 void M_Setup_Draw (void);
60 void M_Net_Draw (void);
61 void M_Options_Draw (void);
62 void M_Keys_Draw (void);
63 void M_Video_Draw (void);
64 void M_Help_Draw (void);
65 void M_Quit_Draw (void);
66 void M_LanConfig_Draw (void);
67 void M_GameOptions_Draw (void);
68 void M_Search_Draw (void);
69 void M_ServerList_Draw (void);
71 void M_Main_Key (int key);
72 void M_SinglePlayer_Key (int key);
73 void M_Load_Key (int key);
74 void M_Save_Key (int key);
75 void M_MultiPlayer_Key (int key);
76 void M_Setup_Key (int key);
77 void M_Net_Key (int key);
78 void M_Options_Key (int key);
79 void M_Keys_Key (int key);
80 void M_Video_Key (int key);
81 void M_Help_Key (int key);
82 void M_Quit_Key (int key);
83 void M_LanConfig_Key (int key);
84 void M_GameOptions_Key (int key);
85 void M_Search_Key (int key);
86 void M_ServerList_Key (int key);
88 qboolean m_entersound; // play after drawing a frame, so caching
89 // won't disrupt the sound
92 qboolean m_return_onerror;
93 char m_return_reason [32];
95 #define StartingGame (m_multiplayer_cursor == 1)
96 #define JoiningGame (m_multiplayer_cursor == 0)
97 #define IPXConfig (m_net_cursor == 0)
98 #define TCPIPConfig (m_net_cursor == 1)
100 void M_ConfigureNetSubsystem(void);
103 #define NumberOfNehahraDemos 34
108 } nehahrademonames_t;
110 nehahrademonames_t NehahraDemos[NumberOfNehahraDemos] =
112 {"intro", "Prologue"},
113 {"genf", "The Beginning"},
114 {"genlab", "A Doomed Project"},
115 {"nehcre", "The New Recruits"},
116 {"maxneh", "Breakthrough"},
117 {"maxchar", "Renewal and Duty"},
118 {"crisis", "Worlds Collide"},
119 {"postcris", "Darkening Skies"},
120 {"hearing", "The Hearing"},
121 {"getjack", "On a Mexican Radio"},
122 {"prelude", "Honor and Justice"},
123 {"abase", "A Message Sent"},
124 {"effect", "The Other Side"},
125 {"uhoh", "Missing in Action"},
126 {"prepare", "The Response"},
127 {"vision", "Farsighted Eyes"},
128 {"maxturns", "Enter the Immortal"},
129 {"backlot", "Separate Ways"},
130 {"maxside", "The Ancient Runes"},
131 {"counter", "The New Initiative"},
132 {"warprep", "Ghosts to the World"},
133 {"counter1", "A Fate Worse Than Death"},
134 {"counter2", "Friendly Fire"},
135 {"counter3", "Minor Setback"},
136 {"madmax", "Scores to Settle"},
137 {"quake", "One Man"},
138 {"cthmm", "Shattered Masks"},
139 {"shades", "Deal with the Dead"},
140 {"gophil", "An Unlikely Hero"},
141 {"cstrike", "War in Hell"},
142 {"shubset", "The Conspiracy"},
143 {"shubdie", "Even Death May Die"},
144 {"newranks", "An Empty Throne"},
145 {"seal", "The Seal is Broken"}
148 float menu_x, menu_y, menu_width, menu_height;
150 void M_DrawBackground(void)
154 menu_x = (vid.conwidth - menu_width) * 0.5;
155 menu_y = (vid.conheight - menu_height) * 0.5;
156 //DrawQ_Fill(menu_x, menu_y, menu_width, menu_height, 0, 0, 0, 0.5, 0);
157 DrawQ_Fill(0, 0, vid.conwidth, vid.conheight, 0, 0, 0, 0.5, 0);
164 Draws one solid graphics character
167 void M_DrawCharacter (float cx, float cy, int num)
172 DrawQ_String(menu_x + cx, menu_y + cy, temp, 1, 8, 8, 1, 1, 1, 1, 0);
175 void M_Print (float cx, float cy, char *str)
180 M_DrawCharacter (cx, cy, (*str++)+128);
184 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0);
187 void M_PrintWhite (float cx, float cy, char *str)
189 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0);
192 void M_ItemPrint (float cx, float cy, char *str, int unghosted)
197 M_DrawCharacter (cx, cy, (*str++)+128);
202 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0);
204 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 0.4, 0.4, 0.4, 1, 0);
207 void M_DrawPic (float cx, float cy, char *picname)
209 DrawQ_Pic (menu_x + cx, menu_y + cy, picname, 0, 0, 1, 1, 1, 1, 0);
212 qbyte identityTable[256];
213 qbyte translationTable[256];
215 void M_BuildTranslationTable(int top, int bottom)
218 qbyte *dest, *source;
220 for (j = 0; j < 256; j++)
221 identityTable[j] = j;
222 dest = translationTable;
223 source = identityTable;
224 memcpy (dest, source, 256);
226 // LordHavoc: corrected skin color ranges
227 if (top < 128 || (top >= 224 && top < 240)) // the artists made some backwards ranges. sigh.
228 memcpy (dest + TOP_RANGE, source + top, 16);
230 for (j=0 ; j<16 ; j++)
231 dest[TOP_RANGE+j] = source[top+15-j];
233 // LordHavoc: corrected skin color ranges
234 if (bottom < 128 || (bottom >= 224 && bottom < 240))
235 memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
237 for (j=0 ; j<16 ; j++)
238 dest[BOTTOM_RANGE+j] = source[bottom+15-j];
242 void M_DrawPicTranslate (float cx, float cy, char *picname)
244 DrawQ_PicTranslate (menu_x + cx, menu_y + cy, picname, translationTable);
248 void M_DrawTextBox (float x, float y, float width, float height)
256 M_DrawPic (cx, cy, "gfx/box_tl.lmp");
257 for (n = 0; n < height; n++)
260 M_DrawPic (cx, cy, "gfx/box_ml.lmp");
262 M_DrawPic (cx, cy+8, "gfx/box_bl.lmp");
269 M_DrawPic (cx, cy, "gfx/box_tm.lmp");
270 for (n = 0; n < height; n++)
274 M_DrawPic (cx, cy, "gfx/box_mm2.lmp");
276 M_DrawPic (cx, cy, "gfx/box_mm.lmp");
278 M_DrawPic (cx, cy+8, "gfx/box_bm.lmp");
285 M_DrawPic (cx, cy, "gfx/box_tr.lmp");
286 for (n = 0; n < height; n++)
289 M_DrawPic (cx, cy, "gfx/box_mr.lmp");
291 M_DrawPic (cx, cy+8, "gfx/box_br.lmp");
294 //=============================================================================
303 void M_ToggleMenu_f (void)
307 if (key_dest == key_menu)
309 if (m_state != m_main)
318 if (key_dest == key_console)
320 Con_ToggleConsole_f ();
328 // LordHavoc: FIXME: finish this menu stuff
330 #define MAXMENUITEMS 128
332 typedef struct menuitem_s
334 char *string; // may be text, or an image to use, or a cvar name, depending on the functions used
336 char *command; // used by command items mainly (when used, this command is executed)
337 cvar_t *cvar; // used for cvar items (sliders, number boxes), value is retrieved from the cvar itself
338 int selectable; // purely decorative if this is false
339 int selected; // true if this menu item is currently selected, used by funcs so they don't need to know anything but fields in the menuitem
340 float selecttime; // the time that this menu item was activated (copied from realtime), used for animating selection flashs and such
341 float color[4]; // current color for the item (may be different than base color, due to selection flash effects)
342 float basecolor[4]; // the base color
343 float x, y, width, height; // width and height are used for mouse selection
344 void(*drawfunc)(struct menuitem_s *item);
345 void(*activefunc)(struct menuitem_s *item);
346 // void(*selectfunc)(struct menuitem_s *item);
347 // void(*deselectfunc)(struct menuitem_s *item);
348 void(*usefunc)(struct menuitem_s *item);
352 menuitem_t menuitem[MAXMENUITEMS];
355 void menuitem_text_drawfunc(struct menuitem_s *item)
357 // FIXME: handle color flashs and such when selected
358 M_Print (item->x, item->y, item->string);
361 void menuitem_image_drawfunc(struct menuitem_s *item)
363 // FIXME: handle color flashs and such when selected
364 M_DrawPic (item->x, item->y, item->string);
367 void menuitem_command_usefunc(struct menuitem_s *item)
369 Cbuf_AddText (item->command);
374 void M_Demo_Draw (void)
378 for (i=0; i < NumberOfNehahraDemos; i++)
379 M_Print (16, 16 + 8*i, NehahraDemos[i].desc);
382 M_DrawCharacter (8, 16 + demo_cursor*8, 12+((int)(realtime*4)&1));
386 void M_Menu_Demos_f (void)
393 void M_Demo_Key (int k)
402 S_LocalSound ("misc/menu2.wav");
405 Cbuf_AddText (va ("playdemo %s\n", NehahraDemos[demo_cursor].name));
410 S_LocalSound ("misc/menu1.wav");
413 demo_cursor = NumberOfNehahraDemos;
418 S_LocalSound ("misc/menu1.wav");
420 if (demo_cursor > NumberOfNehahraDemos)
426 //=============================================================================
430 //#define MAIN_ITEMS 5
432 int MAIN_ITEMS = 4; // Nehahra: Menu Disable
434 void M_Menu_Main_f (void)
436 if (gamemode == GAME_NEHAHRA)
438 if (NehGameType == TYPE_DEMO)
440 else if (NehGameType == TYPE_GAME)
448 if (key_dest != key_menu)
450 m_save_demonum = cls.demonum;
459 void M_Main_Draw (void)
464 M_DrawPic (16, 4, "gfx/qplaque.lmp");
465 p = Draw_CachePic ("gfx/ttl_main.lmp");
466 M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_main.lmp");
468 if (gamemode == GAME_NEHAHRA)
470 if (NehGameType == TYPE_BOTH)
471 M_DrawPic (72, 32, "gfx/mainmenu.lmp");
472 else if (NehGameType == TYPE_GAME)
473 M_DrawPic (72, 32, "gfx/gamemenu.lmp");
475 M_DrawPic (72, 32, "gfx/demomenu.lmp");
478 M_DrawPic (72, 32, "gfx/mainmenu.lmp");
480 f = (int)(realtime * 10)%6;
482 M_DrawPic (54, 32 + m_main_cursor * 20, va("gfx/menudot%i.lmp", f+1));
486 void M_Main_Key (int key)
493 cls.demonum = m_save_demonum;
494 if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
499 S_LocalSound ("misc/menu1.wav");
500 if (++m_main_cursor >= MAIN_ITEMS)
505 S_LocalSound ("misc/menu1.wav");
506 if (--m_main_cursor < 0)
507 m_main_cursor = MAIN_ITEMS - 1;
513 if (gamemode == GAME_NEHAHRA)
518 switch (m_main_cursor)
521 M_Menu_SinglePlayer_f ();
529 M_Menu_MultiPlayer_f ();
539 Cbuf_AddText ("disconnect\n");
540 Cbuf_AddText ("playdemo endcred\n");
549 switch (m_main_cursor)
552 M_Menu_SinglePlayer_f ();
556 M_Menu_MultiPlayer_f ();
566 Cbuf_AddText ("disconnect\n");
567 Cbuf_AddText ("playdemo endcred\n");
576 switch (m_main_cursor)
585 Cbuf_AddText ("disconnect\n");
586 Cbuf_AddText ("playdemo endcred\n");
602 switch (m_main_cursor)
605 M_Menu_SinglePlayer_f ();
609 M_Menu_MultiPlayer_f ();
628 //=============================================================================
629 /* SINGLE PLAYER MENU */
631 int m_singleplayer_cursor;
632 #define SINGLEPLAYER_ITEMS 3
635 void M_Menu_SinglePlayer_f (void)
638 m_state = m_singleplayer;
643 void M_SinglePlayer_Draw (void)
648 M_DrawPic (16, 4, "gfx/qplaque.lmp");
649 p = Draw_CachePic ("gfx/ttl_sgl.lmp");
650 M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_sgl.lmp");
651 M_DrawPic (72, 32, "gfx/sp_menu.lmp");
653 f = (int)(realtime * 10)%6;
655 M_DrawPic (54, 32 + m_singleplayer_cursor * 20, va("gfx/menudot%i.lmp", f+1));
659 void M_SinglePlayer_Key (int key)
668 S_LocalSound ("misc/menu1.wav");
669 if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
670 m_singleplayer_cursor = 0;
674 S_LocalSound ("misc/menu1.wav");
675 if (--m_singleplayer_cursor < 0)
676 m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
682 switch (m_singleplayer_cursor)
687 Cbuf_AddText ("disconnect\n");
688 Cbuf_AddText ("maxplayers 1\n");
689 Cbuf_AddText ("deathmatch 0\n");
690 Cbuf_AddText ("coop 0\n");
691 if (gamemode == GAME_NEHAHRA)
692 Cbuf_AddText ("map nehstart\n");
694 Cbuf_AddText ("map start\n");
708 //=============================================================================
711 int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES
713 #define MAX_SAVEGAMES 12
714 char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
715 int loadable[MAX_SAVEGAMES];
717 void M_ScanSaves (void)
720 char name[MAX_OSPATH];
725 for (i=0 ; i<MAX_SAVEGAMES ; i++)
727 strcpy (m_filenames[i], "--- UNUSED SLOT ---");
729 sprintf (name, "%s/s%i.sav", com_gamedir, i);
730 f = Qopen (name, "rz");
734 sscanf (str, "%i\n", &version);
736 strncpy (m_filenames[i], str, sizeof(m_filenames[i])-1);
738 // change _ back to space
739 for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
740 if (m_filenames[i][j] == '_')
741 m_filenames[i][j] = ' ';
747 void M_Menu_Load_f (void)
756 void M_Menu_Save_f (void)
762 if (svs.maxclients != 1)
771 void M_Load_Draw (void)
776 p = Draw_CachePic ("gfx/p_load.lmp");
777 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_load.lmp");
779 for (i=0 ; i< MAX_SAVEGAMES; i++)
780 M_Print (16, 32 + 8*i, m_filenames[i]);
783 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
787 void M_Save_Draw (void)
792 p = Draw_CachePic ("gfx/p_save.lmp");
793 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_save.lmp");
795 for (i=0 ; i<MAX_SAVEGAMES ; i++)
796 M_Print (16, 32 + 8*i, m_filenames[i]);
799 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
803 void M_Load_Key (int k)
808 M_Menu_SinglePlayer_f ();
812 S_LocalSound ("misc/menu2.wav");
813 if (!loadable[load_cursor])
818 // issue the load command
819 Cbuf_AddText (va ("load s%i\n", load_cursor) );
824 S_LocalSound ("misc/menu1.wav");
827 load_cursor = MAX_SAVEGAMES-1;
832 S_LocalSound ("misc/menu1.wav");
834 if (load_cursor >= MAX_SAVEGAMES)
841 void M_Save_Key (int k)
846 M_Menu_SinglePlayer_f ();
852 Cbuf_AddText (va("save s%i\n", load_cursor));
857 S_LocalSound ("misc/menu1.wav");
860 load_cursor = MAX_SAVEGAMES-1;
865 S_LocalSound ("misc/menu1.wav");
867 if (load_cursor >= MAX_SAVEGAMES)
873 //=============================================================================
874 /* MULTIPLAYER MENU */
876 int m_multiplayer_cursor;
877 #define MULTIPLAYER_ITEMS 3
880 void M_Menu_MultiPlayer_f (void)
883 m_state = m_multiplayer;
888 void M_MultiPlayer_Draw (void)
893 M_DrawPic (16, 4, "gfx/qplaque.lmp");
894 p = Draw_CachePic ("gfx/p_multi.lmp");
895 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
896 M_DrawPic (72, 32, "gfx/mp_menu.lmp");
898 f = (int)(realtime * 10)%6;
900 M_DrawPic (54, 32 + m_multiplayer_cursor * 20, va("gfx/menudot%i.lmp", f+1));
902 if (ipxAvailable || tcpipAvailable)
904 M_PrintWhite ((320/2) - ((27*8)/2), 148, "No Communications Available");
908 void M_MultiPlayer_Key (int key)
917 S_LocalSound ("misc/menu1.wav");
918 if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
919 m_multiplayer_cursor = 0;
923 S_LocalSound ("misc/menu1.wav");
924 if (--m_multiplayer_cursor < 0)
925 m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
930 switch (m_multiplayer_cursor)
933 if (ipxAvailable || tcpipAvailable)
938 if (ipxAvailable || tcpipAvailable)
949 //=============================================================================
952 int setup_cursor = 4;
953 int setup_cursor_table[] = {40, 56, 80, 104, 140};
955 char setup_hostname[16];
956 char setup_myname[16];
962 #define NUM_SETUP_CMDS 5
964 void M_Menu_Setup_f (void)
969 strcpy(setup_myname, cl_name.string);
970 strcpy(setup_hostname, hostname.string);
971 setup_top = setup_oldtop = cl_color.integer >> 4;
972 setup_bottom = setup_oldbottom = cl_color.integer & 15;
976 void M_Setup_Draw (void)
980 M_DrawPic (16, 4, "gfx/qplaque.lmp");
981 p = Draw_CachePic ("gfx/p_multi.lmp");
982 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
984 M_Print (64, 40, "Hostname");
985 M_DrawTextBox (160, 32, 16, 1);
986 M_Print (168, 40, setup_hostname);
988 M_Print (64, 56, "Your name");
989 M_DrawTextBox (160, 48, 16, 1);
990 M_Print (168, 56, setup_myname);
992 M_Print (64, 80, "Shirt color");
993 M_Print (64, 104, "Pants color");
995 M_DrawTextBox (64, 140-8, 14, 1);
996 M_Print (72, 140, "Accept Changes");
998 M_DrawPic (160, 64, "gfx/bigbox.lmp");
999 M_BuildTranslationTable(setup_top*16, setup_bottom*16);
1000 M_DrawPicTranslate (172, 72, "gfx/menuplyr.lmp");
1002 M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
1004 if (setup_cursor == 0)
1005 M_DrawCharacter (168 + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
1007 if (setup_cursor == 1)
1008 M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
1012 void M_Setup_Key (int k)
1019 M_Menu_MultiPlayer_f ();
1023 S_LocalSound ("misc/menu1.wav");
1025 if (setup_cursor < 0)
1026 setup_cursor = NUM_SETUP_CMDS-1;
1030 S_LocalSound ("misc/menu1.wav");
1032 if (setup_cursor >= NUM_SETUP_CMDS)
1037 if (setup_cursor < 2)
1039 S_LocalSound ("misc/menu3.wav");
1040 if (setup_cursor == 2)
1041 setup_top = setup_top - 1;
1042 if (setup_cursor == 3)
1043 setup_bottom = setup_bottom - 1;
1046 if (setup_cursor < 2)
1049 S_LocalSound ("misc/menu3.wav");
1050 if (setup_cursor == 2)
1051 setup_top = setup_top + 1;
1052 if (setup_cursor == 3)
1053 setup_bottom = setup_bottom + 1;
1057 if (setup_cursor == 0 || setup_cursor == 1)
1060 if (setup_cursor == 2 || setup_cursor == 3)
1063 // setup_cursor == 4 (OK)
1064 if (strcmp(cl_name.string, setup_myname) != 0)
1065 Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
1066 if (strcmp(hostname.string, setup_hostname) != 0)
1067 Cvar_Set("hostname", setup_hostname);
1068 if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
1069 Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
1070 m_entersound = true;
1071 M_Menu_MultiPlayer_f ();
1075 if (setup_cursor == 0)
1077 if (strlen(setup_hostname))
1078 setup_hostname[strlen(setup_hostname)-1] = 0;
1081 if (setup_cursor == 1)
1083 if (strlen(setup_myname))
1084 setup_myname[strlen(setup_myname)-1] = 0;
1089 if (k < 32 || k > 127)
1091 if (setup_cursor == 0)
1093 l = strlen(setup_hostname);
1096 setup_hostname[l+1] = 0;
1097 setup_hostname[l] = k;
1100 if (setup_cursor == 1)
1102 l = strlen(setup_myname);
1105 setup_myname[l+1] = 0;
1106 setup_myname[l] = k;
1115 if (setup_bottom > 13)
1117 if (setup_bottom < 0)
1121 //=============================================================================
1126 int m_net_saveHeight;
1128 char *net_helpMessage [] =
1130 /* .........1.........2.... */
1131 " Novell network LANs ",
1132 " or Windows 95 DOS-box. ",
1134 "(LAN=Local Area Network)",
1136 " Commonly used to play ",
1137 " over the Internet, but ",
1138 " also used on a Local ",
1142 void M_Menu_Net_f (void)
1144 key_dest = key_menu;
1146 m_entersound = true;
1149 if (m_net_cursor >= m_net_items)
1152 M_Net_Key (K_DOWNARROW);
1156 void M_Net_Draw (void)
1161 M_DrawPic (16, 4, "gfx/qplaque.lmp");
1162 p = Draw_CachePic ("gfx/p_multi.lmp");
1163 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
1168 M_DrawPic (72, f, "gfx/netmen3.lmp");
1170 M_DrawPic (72, f, "gfx/dim_ipx.lmp");
1174 M_DrawPic (72, f, "gfx/netmen4.lmp");
1176 M_DrawPic (72, f, "gfx/dim_tcp.lmp");
1178 if (m_net_items == 5) // JDC, could just be removed
1181 M_DrawPic (72, f, "gfx/netmen5.lmp");
1185 M_DrawTextBox (f, 134, 24, 4);
1187 M_Print (f, 142, net_helpMessage[m_net_cursor*4+0]);
1188 M_Print (f, 150, net_helpMessage[m_net_cursor*4+1]);
1190 f = (int)(realtime * 10)%6;
1191 M_DrawPic (54, 32 + m_net_cursor * 20, va("gfx/menudot%i.lmp", f+1));
1195 void M_Net_Key (int k)
1201 M_Menu_MultiPlayer_f ();
1205 S_LocalSound ("misc/menu1.wav");
1206 if (++m_net_cursor >= m_net_items)
1211 S_LocalSound ("misc/menu1.wav");
1212 if (--m_net_cursor < 0)
1213 m_net_cursor = m_net_items - 1;
1217 m_entersound = true;
1219 switch (m_net_cursor)
1222 M_Menu_LanConfig_f ();
1226 M_Menu_LanConfig_f ();
1235 if (m_net_cursor == 0 && !ipxAvailable)
1237 if (m_net_cursor == 1 && !tcpipAvailable)
1241 //=============================================================================
1244 #define OPTIONS_ITEMS 27
1246 #define SLIDER_RANGE 10
1250 void M_Menu_Options_f (void)
1252 key_dest = key_menu;
1253 m_state = m_options;
1254 m_entersound = true;
1258 void M_AdjustSliders (int dir)
1260 S_LocalSound ("misc/menu3.wav");
1262 switch (options_cursor)
1265 Cvar_SetValueQuick (&scr_2dresolution, bound(0, scr_2dresolution.value + dir * 0.2, 1));
1268 Cvar_SetValueQuick (&scr_viewsize, bound(30, scr_viewsize.value + dir * 10, 120));
1271 Cvar_SetValueQuick (&r_skyquality, bound(0, r_skyquality.integer + dir, 2));
1274 Cvar_SetValueQuick (&r_ser, !r_ser.integer);
1277 Cvar_SetValueQuick (&v_overbrightbits, bound(0, v_overbrightbits.integer + dir, 4));
1280 Cvar_SetValueQuick (&gl_combine, !gl_combine.integer);
1283 Cvar_SetValueQuick (&gl_dither, !gl_dither.integer);
1286 Cvar_SetValueQuick (&v_hwgamma, !v_hwgamma.integer);
1289 Cvar_SetValueQuick (&v_gamma, bound(1, v_gamma.value + dir * 0.25, 5));
1292 Cvar_SetValueQuick (&v_contrast, bound(0.5, v_contrast.value + dir * 0.25, 5));
1295 Cvar_SetValueQuick (&v_brightness, bound(0, v_brightness.value + dir * 0.05, 0.8));
1297 case 15: // music volume
1299 Cvar_SetValueQuick (&bgmvolume, bound(0, bgmvolume.value + dir * 1.0, 1));
1301 Cvar_SetValueQuick (&bgmvolume, bound(0, bgmvolume.value + dir * 0.1, 1));
1304 case 16: // sfx volume
1305 Cvar_SetValueQuick (&volume, bound(0, volume.value + dir * 0.1, 1));
1308 Cvar_SetValueQuick (&crosshair, bound(0, crosshair.integer + dir, 5));
1311 Cvar_SetValueQuick (&crosshair_size, bound(1, crosshair_size.value + dir, 5));
1313 case 19: // show framerate
1314 Cvar_SetValueQuick (&showfps, !showfps.integer);
1316 case 20: // always run
1317 if (cl_forwardspeed.value > 200)
1319 Cvar_SetValueQuick (&cl_forwardspeed, 200);
1320 Cvar_SetValueQuick (&cl_backspeed, 200);
1324 Cvar_SetValueQuick (&cl_forwardspeed, 400);
1325 Cvar_SetValueQuick (&cl_backspeed, 400);
1328 case 21: // lookspring
1329 Cvar_SetValueQuick (&lookspring, !lookspring.integer);
1331 case 22: // lookstrafe
1332 Cvar_SetValueQuick (&lookstrafe, !lookstrafe.integer);
1334 case 23: // mouse speed
1335 Cvar_SetValueQuick (&sensitivity, bound(1, sensitivity.value + dir * 0.5, 50));
1337 case 24: // mouse look
1338 Cvar_SetValueQuick (&freelook, !freelook.integer);
1340 case 25: // invert mouse
1341 Cvar_SetValueQuick (&m_pitch, -m_pitch.value);
1343 case 26: // windowed mouse
1344 Cvar_SetValueQuick (&vid_mouse, !vid_mouse.integer);
1350 void M_DrawSlider (int x, int y, float range)
1358 M_DrawCharacter (x-8, y, 128);
1359 for (i=0 ; i<SLIDER_RANGE ; i++)
1360 M_DrawCharacter (x + i*8, y, 129);
1361 M_DrawCharacter (x+i*8, y, 130);
1362 M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
1365 void M_DrawCheckbox (int x, int y, int on)
1369 M_DrawCharacter (x, y, 131);
1371 M_DrawCharacter (x, y, 129);
1374 M_Print (x, y, "on");
1376 M_Print (x, y, "off");
1394 int M_Num2DResolutions(void)
1396 return sizeof(m_2dres) / sizeof(int[2]);
1399 float M_Classify2DResolution(void)
1401 int i, num, *res, best, bestdist, diff[3];
1402 num = M_Num2DResolutions();
1404 bestdist = 1000000000;
1405 for (i = 0;i < num;i++)
1407 res = m_2dres + i * 2;
1408 diff[0] = res[0] - vid.conwidth;
1409 diff[1] = res[1] - vid.conheight;
1411 dist = DotProduct(diff, diff);
1412 if (bestdist > dist)
1421 void M_Adjust2DResolution(int dir)
1424 i = M_Classify2DResolution() + dir;
1425 num = M_Num2DResolutions() - 1;
1426 i = bound(0, i, num);
1427 Cvar_SetValue("v_2dwidth", m_2dres[i*2]);
1428 Cvar_SetValue("v_2dheight", m_2dres[i*2+1]);
1432 void M_Options_Draw (void)
1437 M_DrawPic(16, 4, "gfx/qplaque.lmp");
1438 p = Draw_CachePic("gfx/p_option.lmp");
1439 M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
1442 M_Print(16, y, " Customize controls");y += 8;
1443 M_Print(16, y, " Go to console");y += 8;
1444 M_Print(16, y, " Reset to defaults");y += 8;
1445 M_ItemPrint(16, y, " Video Options", vid_menudrawfn != NULL);y += 8;
1446 M_Print(16, y, " 2D Resolution");M_DrawSlider(220, y, scr_2dresolution.value);y += 8;
1447 M_Print(16, y, " Screen size");M_DrawSlider(220, y, (scr_viewsize.value - 30) /(120 - 30));y += 8;
1448 M_Print(16, y, " Sky Quality");M_DrawSlider(220, y, r_skyquality.value / 2);y += 8;
1449 M_Print(16, y, "Hidden Surface Removal");M_DrawCheckbox(220, y, r_ser.integer);y += 8;
1450 M_Print(16, y, " Overbright Bits");M_DrawSlider(220, y, (v_overbrightbits.value) / 4);y += 8;
1451 M_Print(16, y, " Texture Combine");M_DrawCheckbox(220, y, gl_combine.integer);y += 8;
1452 M_Print(16, y, " Dithering");M_DrawCheckbox(220, y, gl_dither.integer);y += 8;
1453 M_ItemPrint(16, y, "Hardware Gamma Control", hardwaregammasupported);M_DrawCheckbox(220, y, v_hwgamma.integer);y += 8;
1454 M_ItemPrint(16, y, " Gamma", v_hwgamma.integer);M_DrawSlider(220, y, (v_gamma.value - 1) / 4);y += 8;
1455 M_Print(16, y, " Contrast");M_DrawSlider(220, y, (v_contrast.value - 0.5) / (5 - 0.5));y += 8;
1456 M_Print(16, y, " Brightness");M_DrawSlider(220, y, v_brightness.value / 0.8);y += 8;
1457 M_ItemPrint(16, y, " CD Music Volume", cdaudioinitialized);M_DrawSlider(220, y, bgmvolume.value);y += 8;
1458 M_ItemPrint(16, y, " Sound Volume", snd_initialized);M_DrawSlider(220, y, volume.value);y += 8;
1459 M_Print(16, y, " Crosshair");M_DrawSlider(220, y, crosshair.value / 5);y += 8;
1460 M_Print(16, y, " Crosshair Size");M_DrawSlider(220, y, (crosshair_size.value - 1) / 4);y += 8;
1461 M_Print(16, y, " Show Framerate");M_DrawCheckbox(220, y, showfps.integer);y += 8;
1462 M_Print(16, y, " Always Run");M_DrawCheckbox(220, y, cl_forwardspeed.value > 200);y += 8;
1463 M_Print(16, y, " Lookspring");M_DrawCheckbox(220, y, lookspring.integer);y += 8;
1464 M_Print(16, y, " Lookstrafe");M_DrawCheckbox(220, y, lookstrafe.integer);y += 8;
1465 M_Print(16, y, " Mouse Speed");M_DrawSlider(220, y, (sensitivity.value - 1)/50);y += 8;
1466 M_Print(16, y, " Mouse Look");M_DrawCheckbox(220, y, freelook.integer);y += 8;
1467 M_Print(16, y, " Invert Mouse");M_DrawCheckbox(220, y, m_pitch.value < 0);y += 8;
1468 M_Print(16, y, " Use Mouse");M_DrawCheckbox(220, y, vid_mouse.integer);y += 8;
1471 M_DrawCharacter(200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
1475 void M_Options_Key (int k)
1484 m_entersound = true;
1485 switch (options_cursor)
1492 Con_ToggleConsole_f ();
1495 Cbuf_AddText ("exec default.cfg\n");
1502 M_AdjustSliders (1);
1508 S_LocalSound ("misc/menu1.wav");
1510 if (options_cursor < 0)
1511 options_cursor = OPTIONS_ITEMS-1;
1515 S_LocalSound ("misc/menu1.wav");
1517 if (options_cursor >= OPTIONS_ITEMS)
1522 M_AdjustSliders (-1);
1526 M_AdjustSliders (1);
1531 //=============================================================================
1534 char *bindnames[][2] =
1536 {"+attack", "attack"},
1537 {"impulse 10", "change weapon"},
1538 {"+jump", "jump / swim up"},
1539 {"+forward", "walk forward"},
1540 {"+back", "backpedal"},
1541 {"+left", "turn left"},
1542 {"+right", "turn right"},
1544 {"+moveleft", "step left"},
1545 {"+moveright", "step right"},
1546 {"+strafe", "sidestep"},
1547 {"+lookup", "look up"},
1548 {"+lookdown", "look down"},
1549 {"centerview", "center view"},
1550 {"+mlook", "mouse look"},
1551 {"+klook", "keyboard look"},
1552 {"+moveup", "swim up"},
1553 {"+movedown", "swim down"}
1556 #define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
1561 void M_Menu_Keys_f (void)
1563 key_dest = key_menu;
1565 m_entersound = true;
1569 void M_FindKeysForCommand (char *command, int *twokeys)
1575 twokeys[0] = twokeys[1] = -1;
1578 for (j=0 ; j<256 ; j++)
1583 if (!strcmp (b, command) )
1593 void M_UnbindCommand (char *command)
1598 for (j=0 ; j<256 ; j++)
1603 if (!strcmp (b, command))
1604 Key_SetBinding (j, "");
1609 void M_Keys_Draw (void)
1617 p = Draw_CachePic ("gfx/ttl_cstm.lmp");
1618 M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_cstm.lmp");
1621 M_Print (12, 32, "Press a key or button for this action");
1623 M_Print (18, 32, "Enter to change, backspace to clear");
1625 // search for known bindings
1626 for (i=0 ; i<NUMCOMMANDS ; i++)
1630 M_Print (16, y, bindnames[i][1]);
1632 l = strlen (bindnames[i][0]);
1634 M_FindKeysForCommand (bindnames[i][0], keys);
1638 M_Print (140, y, "???");
1642 name = Key_KeynumToString (keys[0]);
1643 M_Print (140, y, name);
1644 x = strlen(name) * 8;
1647 M_Print (140 + x + 8, y, "or");
1648 M_Print (140 + x + 32, y, Key_KeynumToString (keys[1]));
1654 M_DrawCharacter (130, 48 + keys_cursor*8, '=');
1656 M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
1660 void M_Keys_Key (int k)
1667 S_LocalSound ("misc/menu1.wav");
1674 sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
1675 Cbuf_InsertText (cmd);
1685 M_Menu_Options_f ();
1690 S_LocalSound ("misc/menu1.wav");
1692 if (keys_cursor < 0)
1693 keys_cursor = NUMCOMMANDS-1;
1698 S_LocalSound ("misc/menu1.wav");
1700 if (keys_cursor >= NUMCOMMANDS)
1704 case K_ENTER: // go into bind mode
1705 M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
1706 S_LocalSound ("misc/menu2.wav");
1708 M_UnbindCommand (bindnames[keys_cursor][0]);
1712 case K_BACKSPACE: // delete bindings
1713 case K_DEL: // delete bindings
1714 S_LocalSound ("misc/menu2.wav");
1715 M_UnbindCommand (bindnames[keys_cursor][0]);
1720 //=============================================================================
1723 void M_Menu_Video_f (void)
1725 key_dest = key_menu;
1727 m_entersound = true;
1731 void M_Video_Draw (void)
1733 (*vid_menudrawfn) ();
1737 void M_Video_Key (int key)
1739 (*vid_menukeyfn) (key);
1742 //=============================================================================
1746 #define NUM_HELP_PAGES 6
1749 void M_Menu_Help_f (void)
1751 key_dest = key_menu;
1753 m_entersound = true;
1759 void M_Help_Draw (void)
1761 M_DrawPic (0, 0, va("gfx/help%i.lmp", help_page));
1765 void M_Help_Key (int key)
1775 m_entersound = true;
1776 if (++help_page >= NUM_HELP_PAGES)
1782 m_entersound = true;
1783 if (--help_page < 0)
1784 help_page = NUM_HELP_PAGES-1;
1790 //=============================================================================
1794 int m_quit_prevstate;
1795 qboolean wasInMenus;
1798 char *quitMessage [] =
1800 /* .........1.........2.... */
1802 " Are you gonna quit ",
1803 " this game just like ",
1804 " everything else? ",
1807 " Milord, methinks that ",
1808 " thou art a lowly ",
1809 " quitter. Is this true? ",
1812 " Do I need to bust your ",
1813 " face open for trying ",
1817 " Man, I oughta smack you",
1818 " for trying to quit! ",
1822 " Press Y to quit like a ",
1823 " big loser in life. ",
1824 " Press N to stay proud ",
1825 " and successful! ",
1827 " If you press Y to ",
1828 " quit, I will summon ",
1829 " Satan all over your ",
1832 " Um, Asmodeus dislikes ",
1833 " his children trying to ",
1834 " quit. Press Y to return",
1835 " to your Tinkertoys. ",
1837 " If you quit now, I'll ",
1838 " throw a blanket-party ",
1839 " for you next time! ",
1843 /* .........1.........2.... */
1845 " Tired of fragging ",
1850 " Quit now and forfeit ",
1851 " your bodycount? ",
1855 " Are you sure you ",
1860 " Off to do something ",
1866 void M_Menu_Quit_f (void)
1868 if (m_state == m_quit)
1870 wasInMenus = (key_dest == key_menu);
1871 key_dest = key_menu;
1872 m_quit_prevstate = m_state;
1874 m_entersound = true;
1875 msgNumber = rand()&3; //&7;
1879 void M_Quit_Key (int key)
1888 m_state = m_quit_prevstate;
1889 m_entersound = true;
1893 key_dest = key_game;
1900 key_dest = key_console;
1911 void M_Quit_Draw (void)
1915 M_DrawTextBox (0, 0, 38, 23);
1916 M_PrintWhite (16, 12, " Quake version 1.09 by id Software\n\n");
1917 M_PrintWhite (16, 28, "Programming Art \n");
1918 M_Print (16, 36, " John Carmack Adrian Carmack\n");
1919 M_Print (16, 44, " Michael Abrash Kevin Cloud\n");
1920 M_Print (16, 52, " John Cash Paul Steed\n");
1921 M_Print (16, 60, " Dave 'Zoid' Kirsch\n");
1922 M_PrintWhite (16, 68, "Design Biz\n");
1923 M_Print (16, 76, " John Romero Jay Wilbur\n");
1924 M_Print (16, 84, " Sandy Petersen Mike Wilson\n");
1925 M_Print (16, 92, " American McGee Donna Jackson\n");
1926 M_Print (16, 100, " Tim Willits Todd Hollenshead\n");
1927 M_PrintWhite (16, 108, "Support Projects\n");
1928 M_Print (16, 116, " Barrett Alexander Shawn Green\n");
1929 M_PrintWhite (16, 124, "Sound Effects\n");
1930 M_Print (16, 132, " Trent Reznor and Nine Inch Nails\n\n");
1931 M_PrintWhite (16, 140, "Quake is a trademark of Id Software,\n");
1932 M_PrintWhite (16, 148, "inc., (c)1996 Id Software, inc. All\n");
1933 M_PrintWhite (16, 156, "rights reserved. NIN logo is a\n");
1934 M_PrintWhite (16, 164, "registered trademark licensed to\n");
1935 M_PrintWhite (16, 172, "Nothing Interactive, Inc. All rights\n");
1936 M_PrintWhite (16, 180, "reserved. Press y to exit\n");
1939 M_DrawTextBox (56, 76, 24, 4);
1940 M_Print (64, 84, quitMessage[msgNumber*4+0]);
1941 M_Print (64, 92, quitMessage[msgNumber*4+1]);
1942 M_Print (64, 100, quitMessage[msgNumber*4+2]);
1943 M_Print (64, 108, quitMessage[msgNumber*4+3]);
1947 //=============================================================================
1948 /* LAN CONFIG MENU */
1950 int lanConfig_cursor = -1;
1951 int lanConfig_cursor_table [] = {72, 92, 124};
1952 #define NUM_LANCONFIG_CMDS 3
1955 char lanConfig_portname[6];
1956 char lanConfig_joinname[22];
1958 void M_Menu_LanConfig_f (void)
1960 key_dest = key_menu;
1961 m_state = m_lanconfig;
1962 m_entersound = true;
1963 if (lanConfig_cursor == -1)
1965 if (JoiningGame && TCPIPConfig)
1966 lanConfig_cursor = 2;
1968 lanConfig_cursor = 1;
1970 if (StartingGame && lanConfig_cursor == 2)
1971 lanConfig_cursor = 1;
1972 lanConfig_port = DEFAULTnet_hostport;
1973 sprintf(lanConfig_portname, "%u", lanConfig_port);
1975 m_return_onerror = false;
1976 m_return_reason[0] = 0;
1980 void M_LanConfig_Draw (void)
1987 M_DrawPic (16, 4, "gfx/qplaque.lmp");
1988 p = Draw_CachePic ("gfx/p_multi.lmp");
1989 basex = (320-p->width)/2;
1990 M_DrawPic (basex, 4, "gfx/p_multi.lmp");
1993 startJoin = "New Game";
1995 startJoin = "Join Game";
1999 protocol = "TCP/IP";
2000 M_Print (basex, 32, va ("%s - %s", startJoin, protocol));
2003 M_Print (basex, 52, "Address:");
2005 M_Print (basex+9*8, 52, my_ipx_address);
2007 M_Print (basex+9*8, 52, my_tcpip_address);
2009 M_Print (basex, lanConfig_cursor_table[0], "Port");
2010 M_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
2011 M_Print (basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
2015 M_Print (basex, lanConfig_cursor_table[1], "Search for local games...");
2016 M_Print (basex, 108, "Join game at:");
2017 M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
2018 M_Print (basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
2022 M_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
2023 M_Print (basex+8, lanConfig_cursor_table[1], "OK");
2026 M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
2028 if (lanConfig_cursor == 0)
2029 M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
2031 if (lanConfig_cursor == 2)
2032 M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
2034 if (*m_return_reason)
2035 M_PrintWhite (basex, 148, m_return_reason);
2039 void M_LanConfig_Key (int key)
2050 S_LocalSound ("misc/menu1.wav");
2052 if (lanConfig_cursor < 0)
2053 lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
2057 S_LocalSound ("misc/menu1.wav");
2059 if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
2060 lanConfig_cursor = 0;
2064 if (lanConfig_cursor == 0)
2067 m_entersound = true;
2069 M_ConfigureNetSubsystem ();
2071 if (lanConfig_cursor == 1)
2075 M_Menu_GameOptions_f ();
2082 if (lanConfig_cursor == 2)
2084 m_return_state = m_state;
2085 m_return_onerror = true;
2086 key_dest = key_game;
2088 Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
2095 if (lanConfig_cursor == 0)
2097 if (strlen(lanConfig_portname))
2098 lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
2101 if (lanConfig_cursor == 2)
2103 if (strlen(lanConfig_joinname))
2104 lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
2109 if (key < 32 || key > 127)
2112 if (lanConfig_cursor == 2)
2114 l = strlen(lanConfig_joinname);
2117 lanConfig_joinname[l+1] = 0;
2118 lanConfig_joinname[l] = key;
2122 if (key < '0' || key > '9')
2124 if (lanConfig_cursor == 0)
2126 l = strlen(lanConfig_portname);
2129 lanConfig_portname[l+1] = 0;
2130 lanConfig_portname[l] = key;
2135 if (StartingGame && lanConfig_cursor == 2)
2137 if (key == K_UPARROW)
2138 lanConfig_cursor = 1;
2140 lanConfig_cursor = 0;
2143 l = atoi(lanConfig_portname);
2148 sprintf(lanConfig_portname, "%u", lanConfig_port);
2151 //=============================================================================
2152 /* GAME OPTIONS MENU */
2171 episode_t *episodes;
2176 level_t quakelevels[] =
2178 {"start", "Entrance"}, // 0
2180 {"e1m1", "Slipgate Complex"}, // 1
2181 {"e1m2", "Castle of the Damned"},
2182 {"e1m3", "The Necropolis"},
2183 {"e1m4", "The Grisly Grotto"},
2184 {"e1m5", "Gloom Keep"},
2185 {"e1m6", "The Door To Chthon"},
2186 {"e1m7", "The House of Chthon"},
2187 {"e1m8", "Ziggurat Vertigo"},
2189 {"e2m1", "The Installation"}, // 9
2190 {"e2m2", "Ogre Citadel"},
2191 {"e2m3", "Crypt of Decay"},
2192 {"e2m4", "The Ebon Fortress"},
2193 {"e2m5", "The Wizard's Manse"},
2194 {"e2m6", "The Dismal Oubliette"},
2195 {"e2m7", "Underearth"},
2197 {"e3m1", "Termination Central"}, // 16
2198 {"e3m2", "The Vaults of Zin"},
2199 {"e3m3", "The Tomb of Terror"},
2200 {"e3m4", "Satan's Dark Delight"},
2201 {"e3m5", "Wind Tunnels"},
2202 {"e3m6", "Chambers of Torment"},
2203 {"e3m7", "The Haunted Halls"},
2205 {"e4m1", "The Sewage System"}, // 23
2206 {"e4m2", "The Tower of Despair"},
2207 {"e4m3", "The Elder God Shrine"},
2208 {"e4m4", "The Palace of Hate"},
2209 {"e4m5", "Hell's Atrium"},
2210 {"e4m6", "The Pain Maze"},
2211 {"e4m7", "Azure Agony"},
2212 {"e4m8", "The Nameless City"},
2214 {"end", "Shub-Niggurath's Pit"}, // 31
2216 {"dm1", "Place of Two Deaths"}, // 32
2217 {"dm2", "Claustrophobopolis"},
2218 {"dm3", "The Abandoned Base"},
2219 {"dm4", "The Bad Place"},
2220 {"dm5", "The Cistern"},
2221 {"dm6", "The Dark Zone"}
2224 episode_t quakeepisodes[] =
2226 {"Welcome to Quake", 0, 1},
2227 {"Doomed Dimension", 1, 8},
2228 {"Realm of Black Magic", 9, 7},
2229 {"Netherworld", 16, 7},
2230 {"The Elder World", 23, 8},
2231 {"Final Level", 31, 1},
2232 {"Deathmatch Arena", 32, 6}
2235 //MED 01/06/97 added hipnotic levels
2236 level_t hipnoticlevels[] =
2238 {"start", "Command HQ"}, // 0
2240 {"hip1m1", "The Pumping Station"}, // 1
2241 {"hip1m2", "Storage Facility"},
2242 {"hip1m3", "The Lost Mine"},
2243 {"hip1m4", "Research Facility"},
2244 {"hip1m5", "Military Complex"},
2246 {"hip2m1", "Ancient Realms"}, // 6
2247 {"hip2m2", "The Black Cathedral"},
2248 {"hip2m3", "The Catacombs"},
2249 {"hip2m4", "The Crypt"},
2250 {"hip2m5", "Mortum's Keep"},
2251 {"hip2m6", "The Gremlin's Domain"},
2253 {"hip3m1", "Tur Torment"}, // 12
2254 {"hip3m2", "Pandemonium"},
2255 {"hip3m3", "Limbo"},
2256 {"hip3m4", "The Gauntlet"},
2258 {"hipend", "Armagon's Lair"}, // 16
2260 {"hipdm1", "The Edge of Oblivion"} // 17
2263 //MED 01/06/97 added hipnotic episodes
2264 episode_t hipnoticepisodes[] =
2266 {"Scourge of Armagon", 0, 1},
2267 {"Fortress of the Dead", 1, 5},
2268 {"Dominion of Darkness", 6, 6},
2269 {"The Rift", 12, 4},
2270 {"Final Level", 16, 1},
2271 {"Deathmatch Arena", 17, 1}
2274 //PGM 01/07/97 added rogue levels
2275 //PGM 03/02/97 added dmatch level
2276 level_t roguelevels[] =
2278 {"start", "Split Decision"},
2279 {"r1m1", "Deviant's Domain"},
2280 {"r1m2", "Dread Portal"},
2281 {"r1m3", "Judgement Call"},
2282 {"r1m4", "Cave of Death"},
2283 {"r1m5", "Towers of Wrath"},
2284 {"r1m6", "Temple of Pain"},
2285 {"r1m7", "Tomb of the Overlord"},
2286 {"r2m1", "Tempus Fugit"},
2287 {"r2m2", "Elemental Fury I"},
2288 {"r2m3", "Elemental Fury II"},
2289 {"r2m4", "Curse of Osiris"},
2290 {"r2m5", "Wizard's Keep"},
2291 {"r2m6", "Blood Sacrifice"},
2292 {"r2m7", "Last Bastion"},
2293 {"r2m8", "Source of Evil"},
2294 {"ctf1", "Division of Change"}
2297 //PGM 01/07/97 added rogue episodes
2298 //PGM 03/02/97 added dmatch episode
2299 episode_t rogueepisodes[] =
2301 {"Introduction", 0, 1},
2302 {"Hell's Fortress", 1, 7},
2303 {"Corridors of Time", 8, 8},
2304 {"Deathmatch Arena", 16, 1}
2307 level_t nehahralevels[] =
2309 {"nehstart", "Welcome to Nehahra"},
2310 {"neh1m1", "Forge City1: Slipgates"},
2311 {"neh1m2", "Forge City2: Boiler"},
2312 {"neh1m3", "Forge City3: Escape"},
2313 {"neh1m4", "Grind Core"},
2314 {"neh1m5", "Industrial Silence"},
2315 {"neh1m6", "Locked-Up Anger"},
2316 {"neh1m7", "Wanderer of the Wastes"},
2317 {"neh1m8", "Artemis System Net"},
2318 {"neh1m9", "To the Death"},
2319 {"neh2m1", "The Gates of Ghoro"},
2320 {"neh2m2", "Sacred Trinity"},
2321 {"neh2m3", "Realm of the Ancients"},
2322 {"neh2m4", "Temple of the Ancients"},
2323 {"neh2m5", "Dreams Made Flesh"},
2324 {"neh2m6", "Your Last Cup of Sorrow"},
2325 {"nehsec", "Ogre's Bane"},
2326 {"nehahra", "Nehahra's Den"},
2327 {"nehend", "Quintessence"}
2330 episode_t nehahraepisodes[] =
2332 {"Welcome to Nehahra", 0, 1},
2333 {"The Fall of Forge", 1, 9},
2334 {"The Outlands", 10, 7},
2335 {"Dimension of the Lost", 17, 2}
2338 // these are placeholders for bloodbath developers to fill in more correctly
2339 level_t bloodbathlevels[] =
2341 {"start", "Welcome to BloodBath"},
2342 {"bb1m1", "Level 1"}
2345 episode_t bloodbathepisodes[] =
2347 {"Welcome to BloodBath", 0, 1},
2348 {"BloodBath Episode 1", 1, 1}
2351 gamelevels_t sharewarequakegame = {"Shareware Quake", quakelevels, quakeepisodes, 2};
2352 gamelevels_t registeredquakegame = {"Quake", quakelevels, quakeepisodes, 7};
2353 gamelevels_t hipnoticgame = {"Scourge of Armagon", hipnoticlevels, hipnoticepisodes, 6};
2354 gamelevels_t roguegame = {"Dissolution of Eternity", roguelevels, rogueepisodes, 4};
2355 gamelevels_t nehahragame = {"Nehahra", nehahralevels, nehahraepisodes, 4};
2356 gamelevels_t bloodbathgame = {"BloodBath", bloodbathlevels, bloodbathepisodes, 2};
2361 gamelevels_t *notregistered;
2362 gamelevels_t *registered;
2366 gameinfo_t gamelist[] =
2368 {GAME_NORMAL, &sharewarequakegame, ®isteredquakegame},
2369 {GAME_HIPNOTIC, &hipnoticgame, &hipnoticgame},
2370 {GAME_ROGUE, &roguegame, &roguegame},
2371 {GAME_NEHAHRA, &nehahragame, &nehahragame},
2372 {GAME_FIENDARENA, &sharewarequakegame, ®isteredquakegame},
2373 {GAME_ZYMOTIC, &sharewarequakegame, ®isteredquakegame},
2374 {GAME_BLOODBATH, &bloodbathgame, &bloodbathgame},
2375 {-1, &sharewarequakegame, ®isteredquakegame} // final fallback
2378 gamelevels_t *lookupgameinfo(void)
2381 for (i = 0;gamelist[i].gameid >= 0 && gamelist[i].gameid != gamemode;i++);
2382 if (registered.integer)
2383 return gamelist[i].registered;
2385 return gamelist[i].notregistered;
2391 qboolean m_serverInfoMessage = false;
2392 double m_serverInfoMessageTime;
2394 void M_Menu_GameOptions_f (void)
2396 key_dest = key_menu;
2397 m_state = m_gameoptions;
2398 m_entersound = true;
2399 if (maxplayers == 0)
2400 maxplayers = svs.maxclients;
2402 maxplayers = svs.maxclientslimit;
2406 int gameoptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 112, 120};
2407 #define NUM_GAMEOPTIONS 9
2408 int gameoptions_cursor;
2410 void M_GameOptions_Draw (void)
2416 M_DrawPic (16, 4, "gfx/qplaque.lmp");
2417 p = Draw_CachePic ("gfx/p_multi.lmp");
2418 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
2420 M_DrawTextBox (152, 32, 10, 1);
2421 M_Print (160, 40, "begin game");
2423 M_Print (0, 56, " Max players");
2424 M_Print (160, 56, va("%i", maxplayers) );
2426 M_Print (0, 64, " Game Type");
2427 if (!coop.integer && !deathmatch.integer)
2428 Cvar_SetValue("deathmatch", 1);
2430 M_Print (160, 64, "Cooperative");
2432 M_Print (160, 64, "Deathmatch");
2434 M_Print (0, 72, " Teamplay");
2435 if (gamemode == GAME_ROGUE)
2439 switch((int)teamplay.integer)
2441 case 1: msg = "No Friendly Fire"; break;
2442 case 2: msg = "Friendly Fire"; break;
2443 case 3: msg = "Tag"; break;
2444 case 4: msg = "Capture the Flag"; break;
2445 case 5: msg = "One Flag CTF"; break;
2446 case 6: msg = "Three Team CTF"; break;
2447 default: msg = "Off"; break;
2449 M_Print (160, 72, msg);
2455 switch((int)teamplay.integer)
2457 case 1: msg = "No Friendly Fire"; break;
2458 case 2: msg = "Friendly Fire"; break;
2459 default: msg = "Off"; break;
2461 M_Print (160, 72, msg);
2464 M_Print (0, 80, " Skill");
2465 if (skill.integer == 0)
2466 M_Print (160, 80, "Easy difficulty");
2467 else if (skill.integer == 1)
2468 M_Print (160, 80, "Normal difficulty");
2469 else if (skill.integer == 2)
2470 M_Print (160, 80, "Hard difficulty");
2472 M_Print (160, 80, "Nightmare difficulty");
2474 M_Print (0, 88, " Frag Limit");
2475 if (fraglimit.integer == 0)
2476 M_Print (160, 88, "none");
2478 M_Print (160, 88, va("%i frags", fraglimit.integer));
2480 M_Print (0, 96, " Time Limit");
2481 if (timelimit.integer == 0)
2482 M_Print (160, 96, "none");
2484 M_Print (160, 96, va("%i minutes", timelimit.integer));
2486 g = lookupgameinfo();
2488 M_Print (0, 112, " Episode");
2489 M_Print (160, 112, g->episodes[startepisode].description);
2491 M_Print (0, 120, " Level");
2492 M_Print (160, 120, g->levels[g->episodes[startepisode].firstLevel + startlevel].description);
2493 M_Print (160, 128, g->levels[g->episodes[startepisode].firstLevel + startlevel].name);
2496 M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
2498 if (m_serverInfoMessage)
2500 if ((realtime - m_serverInfoMessageTime) < 5.0)
2503 M_DrawTextBox (x, 138, 24, 4);
2505 M_Print (x, 146, " More than 64 players?? ");
2506 M_Print (x, 154, " First, question your ");
2507 M_Print (x, 162, " sanity, then email ");
2508 M_Print (x, 170, " havoc@gamevisions.com ");
2510 M_Print (x, 146, " More than 4 players ");
2511 M_Print (x, 154, " requires using command ");
2512 M_Print (x, 162, "line parameters; please ");
2513 M_Print (x, 170, " see techinfo.txt. ");
2518 m_serverInfoMessage = false;
2524 void M_NetStart_Change (int dir)
2529 switch (gameoptions_cursor)
2533 if (maxplayers > svs.maxclientslimit)
2535 maxplayers = svs.maxclientslimit;
2536 m_serverInfoMessage = true;
2537 m_serverInfoMessageTime = realtime;
2544 if (deathmatch.integer) // changing from deathmatch to coop
2546 Cvar_SetValueQuick (&coop, 1);
2547 Cvar_SetValueQuick (&deathmatch, 0);
2549 else // changing from coop to deathmatch
2551 Cvar_SetValueQuick (&coop, 0);
2552 Cvar_SetValueQuick (&deathmatch, 1);
2557 if (gamemode == GAME_ROGUE)
2562 Cvar_SetValueQuick (&teamplay, teamplay.integer + dir);
2563 if (teamplay.integer > count)
2564 Cvar_SetValueQuick (&teamplay, 0);
2565 else if (teamplay.integer < 0)
2566 Cvar_SetValueQuick (&teamplay, count);
2570 Cvar_SetValueQuick (&skill, skill.integer + dir);
2571 if (skill.integer > 3)
2572 Cvar_SetValueQuick (&skill, 0);
2573 if (skill.integer < 0)
2574 Cvar_SetValueQuick (&skill, 3);
2578 Cvar_SetValueQuick (&fraglimit, fraglimit.integer + dir*10);
2579 if (fraglimit.integer > 100)
2580 Cvar_SetValueQuick (&fraglimit, 0);
2581 if (fraglimit.integer < 0)
2582 Cvar_SetValueQuick (&fraglimit, 100);
2586 Cvar_SetValueQuick (&timelimit, timelimit.value + dir*5);
2587 if (timelimit.value > 60)
2588 Cvar_SetValueQuick (&timelimit, 0);
2589 if (timelimit.value < 0)
2590 Cvar_SetValueQuick (&timelimit, 60);
2594 startepisode += dir;
2595 g = lookupgameinfo();
2597 if (startepisode < 0)
2598 startepisode = g->numepisodes - 1;
2600 if (startepisode >= g->numepisodes)
2608 g = lookupgameinfo();
2611 startlevel = g->episodes[startepisode].levels - 1;
2613 if (startlevel >= g->episodes[startepisode].levels)
2619 void M_GameOptions_Key (int key)
2630 S_LocalSound ("misc/menu1.wav");
2631 gameoptions_cursor--;
2632 if (gameoptions_cursor < 0)
2633 gameoptions_cursor = NUM_GAMEOPTIONS-1;
2637 S_LocalSound ("misc/menu1.wav");
2638 gameoptions_cursor++;
2639 if (gameoptions_cursor >= NUM_GAMEOPTIONS)
2640 gameoptions_cursor = 0;
2644 if (gameoptions_cursor == 0)
2646 S_LocalSound ("misc/menu3.wav");
2647 M_NetStart_Change (-1);
2651 if (gameoptions_cursor == 0)
2653 S_LocalSound ("misc/menu3.wav");
2654 M_NetStart_Change (1);
2658 S_LocalSound ("misc/menu2.wav");
2659 if (gameoptions_cursor == 0)
2662 Cbuf_AddText ("disconnect\n");
2663 Cbuf_AddText ("listen 0\n"); // so host_netport will be re-examined
2664 Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) );
2666 g = lookupgameinfo();
2667 Cbuf_AddText ( va ("map %s\n", g->levels[g->episodes[startepisode].firstLevel + startlevel].name) );
2671 M_NetStart_Change (1);
2676 //=============================================================================
2679 qboolean searchComplete = false;
2680 double searchCompleteTime;
2682 void M_Menu_Search_f (void)
2684 key_dest = key_menu;
2686 m_entersound = false;
2689 searchComplete = false;
2695 void M_Search_Draw (void)
2700 p = Draw_CachePic ("gfx/p_multi.lmp");
2701 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
2702 x = (320/2) - ((12*8)/2) + 4;
2703 M_DrawTextBox (x-8, 32, 12, 1);
2704 M_Print (x, 40, "Searching...");
2712 if (! searchComplete)
2714 searchComplete = true;
2715 searchCompleteTime = realtime;
2720 M_Menu_ServerList_f ();
2724 M_PrintWhite ((320/2) - ((22*8)/2), 64, "No Quake servers found");
2725 if ((realtime - searchCompleteTime) < 3.0)
2728 M_Menu_LanConfig_f ();
2732 void M_Search_Key (int key)
2736 //=============================================================================
2740 qboolean slist_sorted;
2742 void M_Menu_ServerList_f (void)
2744 key_dest = key_menu;
2746 m_entersound = true;
2748 m_return_onerror = false;
2749 m_return_reason[0] = 0;
2750 slist_sorted = false;
2754 void M_ServerList_Draw (void)
2762 if (hostCacheCount > 1)
2766 for (i = 0; i < hostCacheCount; i++)
2767 for (j = i+1; j < hostCacheCount; j++)
2768 if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
2770 memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
2771 memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
2772 memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
2775 slist_sorted = true;
2778 p = Draw_CachePic ("gfx/p_multi.lmp");
2779 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
2780 for (n = 0; n < hostCacheCount; n++)
2782 if (hostcache[n].maxusers)
2783 sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
2785 sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
2786 M_Print (16, 32 + 8*n, string);
2788 M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1));
2790 if (*m_return_reason)
2791 M_PrintWhite (16, 148, m_return_reason);
2795 void M_ServerList_Key (int k)
2800 M_Menu_LanConfig_f ();
2809 S_LocalSound ("misc/menu1.wav");
2811 if (slist_cursor < 0)
2812 slist_cursor = hostCacheCount - 1;
2817 S_LocalSound ("misc/menu1.wav");
2819 if (slist_cursor >= hostCacheCount)
2824 S_LocalSound ("misc/menu2.wav");
2825 m_return_state = m_state;
2826 m_return_onerror = true;
2827 slist_sorted = false;
2828 key_dest = key_game;
2830 Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
2839 //=============================================================================
2840 /* Menu Subsystem */
2845 Cmd_AddCommand ("togglemenu", M_ToggleMenu_f);
2847 Cmd_AddCommand ("menu_main", M_Menu_Main_f);
2848 Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f);
2849 Cmd_AddCommand ("menu_load", M_Menu_Load_f);
2850 Cmd_AddCommand ("menu_save", M_Menu_Save_f);
2851 Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
2852 Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
2853 Cmd_AddCommand ("menu_options", M_Menu_Options_f);
2854 Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
2855 Cmd_AddCommand ("menu_video", M_Menu_Video_f);
2856 Cmd_AddCommand ("help", M_Menu_Help_f);
2857 Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
2859 if (gamemode == GAME_NEHAHRA)
2861 if (COM_FileExists("maps/neh1m4.bsp"))
2863 if (COM_FileExists("hearing.dem"))
2865 Con_Printf("Nehahra movie and game detected.\n");
2866 NehGameType = TYPE_BOTH;
2870 Con_Printf("Nehahra game detected.\n");
2871 NehGameType = TYPE_GAME;
2876 if (COM_FileExists("hearing.dem"))
2878 Con_Printf("Nehahra movie detected.\n");
2879 NehGameType = TYPE_DEMO;
2883 Con_Printf("Nehahra not found.\n");
2884 NehGameType = TYPE_GAME; // could just complain, but...
2892 if (m_state == m_none || key_dest != key_menu)
2910 case m_singleplayer:
2911 M_SinglePlayer_Draw ();
2923 M_MultiPlayer_Draw ();
2955 M_LanConfig_Draw ();
2959 M_GameOptions_Draw ();
2967 M_ServerList_Draw ();
2973 S_LocalSound ("misc/menu2.wav");
2974 m_entersound = false;
2981 void M_Keydown (int key)
2996 case m_singleplayer:
2997 M_SinglePlayer_Key (key);
3009 M_MultiPlayer_Key (key);
3021 M_Options_Key (key);
3041 M_LanConfig_Key (key);
3045 M_GameOptions_Key (key);
3053 M_ServerList_Key (key);
3059 void M_ConfigureNetSubsystem(void)
3061 // enable/disable net systems to match desired config
3063 Cbuf_AddText ("stopdemo\n");
3065 if (IPXConfig || TCPIPConfig)
3066 net_hostport = lanConfig_port;