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.
23 #include "mprogdefs.h"
29 mempool_t *menu_mempool;
33 enum m_state_e m_state;
35 void M_Menu_Main_f (void);
36 void M_Menu_SinglePlayer_f (void);
37 void M_Menu_Load_f (void);
38 void M_Menu_Save_f (void);
39 void M_Menu_MultiPlayer_f (void);
40 void M_Menu_Setup_f (void);
41 void M_Menu_Options_f (void);
42 void M_Menu_Options_Effects_f (void);
43 void M_Menu_Options_ColorControl_f (void);
44 void M_Menu_Keys_f (void);
45 void M_Menu_Video_f (void);
46 void M_Menu_Help_f (void);
47 void M_Menu_Quit_f (void);
48 void M_Menu_LanConfig_f (void);
49 void M_Menu_GameOptions_f (void);
50 void M_Menu_ServerList_f (void);
52 void M_Main_Draw (void);
53 void M_SinglePlayer_Draw (void);
54 void M_Load_Draw (void);
55 void M_Save_Draw (void);
56 void M_MultiPlayer_Draw (void);
57 void M_Setup_Draw (void);
58 void M_Options_Draw (void);
59 void M_Options_Effects_Draw (void);
60 void M_Options_ColorControl_Draw (void);
61 void M_Keys_Draw (void);
62 void M_Video_Draw (void);
63 void M_Help_Draw (void);
64 void M_Quit_Draw (void);
65 void M_LanConfig_Draw (void);
66 void M_GameOptions_Draw (void);
67 void M_ServerList_Draw (void);
69 void M_Main_Key (int key, char ascii);
70 void M_SinglePlayer_Key (int key, char ascii);
71 void M_Load_Key (int key, char ascii);
72 void M_Save_Key (int key, char ascii);
73 void M_MultiPlayer_Key (int key, char ascii);
74 void M_Setup_Key (int key, char ascii);
75 void M_Options_Key (int key, char ascii);
76 void M_Options_Effects_Key (int key, char ascii);
77 void M_Options_ColorControl_Key (int key, char ascii);
78 void M_Keys_Key (int key, char ascii);
79 void M_Video_Key (int key, char ascii);
80 void M_Help_Key (int key, char ascii);
81 void M_Quit_Key (int key, char ascii);
82 void M_LanConfig_Key (int key, char ascii);
83 void M_GameOptions_Key (int key, char ascii);
84 void M_ServerList_Key (int key, char ascii);
86 qboolean m_entersound; // play after drawing a frame, so caching
87 // won't disrupt the sound
89 char m_return_reason [32];
91 #define StartingGame (m_multiplayer_cursor == 1)
92 #define JoiningGame (m_multiplayer_cursor == 0)
95 #define NumberOfNehahraDemos 34
100 } nehahrademonames_t;
102 nehahrademonames_t NehahraDemos[NumberOfNehahraDemos] =
104 {"intro", "Prologue"},
105 {"genf", "The Beginning"},
106 {"genlab", "A Doomed Project"},
107 {"nehcre", "The New Recruits"},
108 {"maxneh", "Breakthrough"},
109 {"maxchar", "Renewal and Duty"},
110 {"crisis", "Worlds Collide"},
111 {"postcris", "Darkening Skies"},
112 {"hearing", "The Hearing"},
113 {"getjack", "On a Mexican Radio"},
114 {"prelude", "Honor and Justice"},
115 {"abase", "A Message Sent"},
116 {"effect", "The Other Side"},
117 {"uhoh", "Missing in Action"},
118 {"prepare", "The Response"},
119 {"vision", "Farsighted Eyes"},
120 {"maxturns", "Enter the Immortal"},
121 {"backlot", "Separate Ways"},
122 {"maxside", "The Ancient Runes"},
123 {"counter", "The New Initiative"},
124 {"warprep", "Ghosts to the World"},
125 {"counter1", "A Fate Worse Than Death"},
126 {"counter2", "Friendly Fire"},
127 {"counter3", "Minor Setback"},
128 {"madmax", "Scores to Settle"},
129 {"quake", "One Man"},
130 {"cthmm", "Shattered Masks"},
131 {"shades", "Deal with the Dead"},
132 {"gophil", "An Unlikely Hero"},
133 {"cstrike", "War in Hell"},
134 {"shubset", "The Conspiracy"},
135 {"shubdie", "Even Death May Die"},
136 {"newranks", "An Empty Throne"},
137 {"seal", "The Seal is Broken"}
140 float menu_x, menu_y, menu_width, menu_height;
142 void M_Background(int width, int height)
145 menu_height = height;
146 menu_x = (vid.conwidth - menu_width) * 0.5;
147 menu_y = (vid.conheight - menu_height) * 0.5;
148 //DrawQ_Fill(menu_x, menu_y, menu_width, menu_height, 0, 0, 0, 0.5, 0);
149 DrawQ_Fill(0, 0, vid.conwidth, vid.conheight, 0, 0, 0, 0.5, 0);
156 Draws one solid graphics character
159 void M_DrawCharacter (float cx, float cy, int num)
164 DrawQ_String(menu_x + cx, menu_y + cy, temp, 1, 8, 8, 1, 1, 1, 1, 0);
167 void M_Print(float cx, float cy, const char *str)
169 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0);
172 void M_PrintRed (float cx, float cy, const char *str)
174 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 0, 0, 1, 0);
177 void M_ItemPrint(float cx, float cy, char *str, int unghosted)
180 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0);
182 DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 0.4, 0.4, 0.4, 1, 0);
185 void M_DrawPic (float cx, float cy, char *picname)
187 DrawQ_Pic (menu_x + cx, menu_y + cy, picname, 0, 0, 1, 1, 1, 1, 0);
190 qbyte identityTable[256];
191 qbyte translationTable[256];
193 void M_BuildTranslationTable(int top, int bottom)
196 qbyte *dest, *source;
198 for (j = 0; j < 256; j++)
199 identityTable[j] = j;
200 dest = translationTable;
201 source = identityTable;
202 memcpy (dest, source, 256);
204 // LordHavoc: corrected skin color ranges
205 if (top < 128 || (top >= 224 && top < 240)) // the artists made some backwards ranges. sigh.
206 memcpy (dest + TOP_RANGE, source + top, 16);
208 for (j=0 ; j<16 ; j++)
209 dest[TOP_RANGE+j] = source[top+15-j];
211 // LordHavoc: corrected skin color ranges
212 if (bottom < 128 || (bottom >= 224 && bottom < 240))
213 memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
215 for (j=0 ; j<16 ; j++)
216 dest[BOTTOM_RANGE+j] = source[bottom+15-j];
220 void M_DrawTextBox (float x, float y, float width, float height)
228 M_DrawPic (cx, cy, "gfx/box_tl.lmp");
229 for (n = 0; n < height; n++)
232 M_DrawPic (cx, cy, "gfx/box_ml.lmp");
234 M_DrawPic (cx, cy+8, "gfx/box_bl.lmp");
241 M_DrawPic (cx, cy, "gfx/box_tm.lmp");
242 for (n = 0; n < height; n++)
246 M_DrawPic (cx, cy, "gfx/box_mm2.lmp");
248 M_DrawPic (cx, cy, "gfx/box_mm.lmp");
250 M_DrawPic (cx, cy+8, "gfx/box_bm.lmp");
257 M_DrawPic (cx, cy, "gfx/box_tr.lmp");
258 for (n = 0; n < height; n++)
261 M_DrawPic (cx, cy, "gfx/box_mr.lmp");
263 M_DrawPic (cx, cy+8, "gfx/box_br.lmp");
266 //=============================================================================
268 //int m_save_demonum;
275 void M_ToggleMenu_f (void)
279 if (key_dest != key_menu || m_state != m_main)
290 void M_Demo_Draw (void)
294 M_Background(320, 200);
296 for (i = 0;i < NumberOfNehahraDemos;i++)
297 M_Print(16, 16 + 8*i, NehahraDemos[i].desc);
300 M_DrawCharacter (8, 16 + demo_cursor*8, 12+((int)(realtime*4)&1));
304 void M_Menu_Demos_f (void)
311 void M_Demo_Key (int k, char ascii)
320 S_LocalSound ("misc/menu2.wav");
323 Cbuf_AddText (va ("playdemo %s\n", NehahraDemos[demo_cursor].name));
328 S_LocalSound ("misc/menu1.wav");
331 demo_cursor = NumberOfNehahraDemos-1;
336 S_LocalSound ("misc/menu1.wav");
338 if (demo_cursor >= NumberOfNehahraDemos)
344 //=============================================================================
349 int MAIN_ITEMS = 4; // Nehahra: Menu Disable
351 void M_Menu_Main_f (void)
353 if (gamemode == GAME_NEHAHRA)
355 if (NehGameType == TYPE_DEMO)
357 else if (NehGameType == TYPE_GAME)
366 if (key_dest != key_menu)
368 m_save_demonum = cls.demonum;
378 void M_Main_Draw (void)
383 M_Background(320, 200);
385 M_DrawPic (16, 4, "gfx/qplaque.lmp");
386 p = Draw_CachePic ("gfx/ttl_main.lmp");
387 M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_main.lmp");
389 if (gamemode == GAME_NEHAHRA)
391 if (NehGameType == TYPE_BOTH)
392 M_DrawPic (72, 32, "gfx/mainmenu.lmp");
393 else if (NehGameType == TYPE_GAME)
394 M_DrawPic (72, 32, "gfx/gamemenu.lmp");
396 M_DrawPic (72, 32, "gfx/demomenu.lmp");
399 M_DrawPic (72, 32, "gfx/mainmenu.lmp");
401 f = (int)(realtime * 10)%6;
403 M_DrawPic (54, 32 + m_main_cursor * 20, va("gfx/menudot%i.lmp", f+1));
407 void M_Main_Key (int key, char ascii)
414 //cls.demonum = m_save_demonum;
415 //if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
420 S_LocalSound ("misc/menu1.wav");
421 if (++m_main_cursor >= MAIN_ITEMS)
426 S_LocalSound ("misc/menu1.wav");
427 if (--m_main_cursor < 0)
428 m_main_cursor = MAIN_ITEMS - 1;
434 if (gamemode == GAME_NEHAHRA)
439 switch (m_main_cursor)
442 M_Menu_SinglePlayer_f ();
450 M_Menu_MultiPlayer_f ();
460 Cbuf_AddText ("disconnect\n");
461 Cbuf_AddText ("playdemo endcred\n");
470 switch (m_main_cursor)
473 M_Menu_SinglePlayer_f ();
477 M_Menu_MultiPlayer_f ();
487 Cbuf_AddText ("disconnect\n");
488 Cbuf_AddText ("playdemo endcred\n");
497 switch (m_main_cursor)
506 Cbuf_AddText ("disconnect\n");
507 Cbuf_AddText ("playdemo endcred\n");
523 switch (m_main_cursor)
526 M_Menu_SinglePlayer_f ();
530 M_Menu_MultiPlayer_f ();
549 //=============================================================================
550 /* SINGLE PLAYER MENU */
552 int m_singleplayer_cursor;
553 #define SINGLEPLAYER_ITEMS 3
556 void M_Menu_SinglePlayer_f (void)
559 m_state = m_singleplayer;
564 void M_SinglePlayer_Draw (void)
568 M_Background(320, 200);
570 M_DrawPic (16, 4, "gfx/qplaque.lmp");
571 p = Draw_CachePic ("gfx/ttl_sgl.lmp");
573 // Transfusion doesn't have a single player mode
574 if (gamemode == GAME_TRANSFUSION || gamemode == GAME_NEXUIZ || gamemode == GAME_GOODVSBAD2 || gamemode == GAME_BATTLEMECH)
576 M_DrawPic ((320 - p->width) / 2, 4, "gfx/ttl_sgl.lmp");
578 M_DrawTextBox (60, 8 * 8, 23, 4);
579 if (gamemode == GAME_NEXUIZ)
580 M_Print(95, 10 * 8, "Nexuiz is for");
581 else if (gamemode == GAME_GOODVSBAD2)
582 M_Print(95, 10 * 8, "Good Vs Bad 2 is for");
583 else if (gamemode == GAME_BATTLEMECH)
584 M_Print(95, 10 * 8, "Battlemech is for");
586 M_Print(95, 10 * 8, "Transfusion is for");
587 M_Print(83, 11 * 8, "multiplayer play only");
593 M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_sgl.lmp");
594 M_DrawPic (72, 32, "gfx/sp_menu.lmp");
596 f = (int)(realtime * 10)%6;
598 M_DrawPic (54, 32 + m_singleplayer_cursor * 20, va("gfx/menudot%i.lmp", f+1));
603 void M_SinglePlayer_Key (int key, char ascii)
605 if (gamemode == GAME_TRANSFUSION || gamemode == GAME_NEXUIZ || gamemode == GAME_GOODVSBAD2 || gamemode == GAME_BATTLEMECH)
607 if (key == K_ESCAPE || key == K_ENTER)
619 S_LocalSound ("misc/menu1.wav");
620 if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
621 m_singleplayer_cursor = 0;
625 S_LocalSound ("misc/menu1.wav");
626 if (--m_singleplayer_cursor < 0)
627 m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
633 switch (m_singleplayer_cursor)
638 Cbuf_AddText ("disconnect\n");
639 Cbuf_AddText ("maxplayers 1\n");
640 Cbuf_AddText ("deathmatch 0\n");
641 Cbuf_AddText ("coop 0\n");
642 if (gamemode == GAME_NEHAHRA)
643 Cbuf_AddText ("map nehstart\n");
645 Cbuf_AddText ("map start\n");
659 //=============================================================================
662 int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES
664 #define MAX_SAVEGAMES 12
665 char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
666 int loadable[MAX_SAVEGAMES];
668 void M_ScanSaves (void)
671 char name[MAX_OSPATH];
676 for (i=0 ; i<MAX_SAVEGAMES ; i++)
678 strcpy (m_filenames[i], "--- UNUSED SLOT ---");
680 sprintf (name, "s%i.sav", i);
681 f = FS_Open (name, "r", false);
684 str = FS_Getline (f);
685 sscanf (str, "%i\n", &version);
686 str = FS_Getline (f);
687 strlcpy (m_filenames[i], str, sizeof (m_filenames[i]));
689 // change _ back to space
690 for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
691 if (m_filenames[i][j] == '_')
692 m_filenames[i][j] = ' ';
698 void M_Menu_Load_f (void)
707 void M_Menu_Save_f (void)
722 void M_Load_Draw (void)
727 M_Background(320, 200);
729 p = Draw_CachePic ("gfx/p_load.lmp");
730 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_load.lmp");
732 for (i=0 ; i< MAX_SAVEGAMES; i++)
733 M_Print(16, 32 + 8*i, m_filenames[i]);
736 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
740 void M_Save_Draw (void)
745 M_Background(320, 200);
747 p = Draw_CachePic ("gfx/p_save.lmp");
748 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_save.lmp");
750 for (i=0 ; i<MAX_SAVEGAMES ; i++)
751 M_Print(16, 32 + 8*i, m_filenames[i]);
754 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
758 void M_Load_Key (int k, char ascii)
763 M_Menu_SinglePlayer_f ();
767 S_LocalSound ("misc/menu2.wav");
768 if (!loadable[load_cursor])
773 // issue the load command
774 Cbuf_AddText (va ("load s%i\n", load_cursor) );
779 S_LocalSound ("misc/menu1.wav");
782 load_cursor = MAX_SAVEGAMES-1;
787 S_LocalSound ("misc/menu1.wav");
789 if (load_cursor >= MAX_SAVEGAMES)
796 void M_Save_Key (int k, char ascii)
801 M_Menu_SinglePlayer_f ();
807 Cbuf_AddText (va("save s%i\n", load_cursor));
812 S_LocalSound ("misc/menu1.wav");
815 load_cursor = MAX_SAVEGAMES-1;
820 S_LocalSound ("misc/menu1.wav");
822 if (load_cursor >= MAX_SAVEGAMES)
828 //=============================================================================
829 /* MULTIPLAYER MENU */
831 int m_multiplayer_cursor;
832 #define MULTIPLAYER_ITEMS 3
835 void M_Menu_MultiPlayer_f (void)
838 m_state = m_multiplayer;
843 void M_MultiPlayer_Draw (void)
848 M_Background(320, 200);
850 M_DrawPic (16, 4, "gfx/qplaque.lmp");
851 p = Draw_CachePic ("gfx/p_multi.lmp");
852 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
853 M_DrawPic (72, 32, "gfx/mp_menu.lmp");
855 f = (int)(realtime * 10)%6;
857 M_DrawPic (54, 32 + m_multiplayer_cursor * 20, va("gfx/menudot%i.lmp", f+1));
861 void M_MultiPlayer_Key (int key, char ascii)
870 S_LocalSound ("misc/menu1.wav");
871 if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
872 m_multiplayer_cursor = 0;
876 S_LocalSound ("misc/menu1.wav");
877 if (--m_multiplayer_cursor < 0)
878 m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
883 switch (m_multiplayer_cursor)
887 M_Menu_LanConfig_f ();
897 //=============================================================================
900 int setup_cursor = 4;
901 int setup_cursor_table[] = {40, 64, 88, 124, 140};
903 char setup_myname[32];
910 #define NUM_SETUP_CMDS 5
912 void M_Menu_Setup_f (void)
917 strcpy(setup_myname, cl_name.string);
918 setup_top = setup_oldtop = cl_color.integer >> 4;
919 setup_bottom = setup_oldbottom = cl_color.integer & 15;
920 setup_rate = cl_rate.integer;
923 static int menuplyr_width, menuplyr_height, menuplyr_top, menuplyr_bottom, menuplyr_load;
924 static qbyte *menuplyr_pixels;
925 static unsigned int *menuplyr_translated;
927 typedef struct ratetable_s
934 #define RATES ((int)(sizeof(setup_ratetable)/sizeof(setup_ratetable[0])))
935 static ratetable_t setup_ratetable[] =
938 {1500, "28.8 mediocre"},
940 {2500, "33.6 mediocre"},
943 {4000, "56k mediocre"},
944 {4500, "56k adequate"},
947 {15000, "128k ISDN"},
951 static int setup_rateindex(int rate)
954 for (i = 0;i < RATES;i++)
955 if (setup_ratetable[i].rate > setup_rate)
957 return bound(1, i, RATES) - 1;
960 void M_Setup_Draw (void)
965 M_Background(320, 200);
967 M_DrawPic (16, 4, "gfx/qplaque.lmp");
968 p = Draw_CachePic ("gfx/p_multi.lmp");
969 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
971 M_Print(64, 40, "Your name");
972 M_DrawTextBox (160, 32, 16, 1);
973 M_Print(168, 40, setup_myname);
975 if (gamemode != GAME_GOODVSBAD2)
977 M_Print(64, 64, "Shirt color");
978 M_Print(64, 88, "Pants color");
981 M_Print(64, 124-8, "Network speed limit");
982 M_Print(168, 124, va("%i (%s)", setup_rate, setup_ratetable[setup_rateindex(setup_rate)].name));
984 M_DrawTextBox (64, 140-8, 14, 1);
985 M_Print(72, 140, "Accept Changes");
987 // LordHavoc: rewrote this code greatly
991 menuplyr_load = false;
993 menuplyr_bottom = -1;
994 if ((f = FS_LoadFile("gfx/menuplyr.lmp", true)))
996 data = LoadLMPAs8Bit (f, 0, 0);
997 menuplyr_width = image_width;
998 menuplyr_height = image_height;
1000 menuplyr_pixels = Mem_Alloc(menu_mempool, menuplyr_width * menuplyr_height);
1001 menuplyr_translated = Mem_Alloc(menu_mempool, menuplyr_width * menuplyr_height * 4);
1002 memcpy(menuplyr_pixels, data, menuplyr_width * menuplyr_height);
1007 if (menuplyr_pixels)
1009 if (menuplyr_top != setup_top || menuplyr_bottom != setup_bottom)
1011 menuplyr_top = setup_top;
1012 menuplyr_bottom = setup_bottom;
1013 M_BuildTranslationTable(menuplyr_top*16, menuplyr_bottom*16);
1014 for (i = 0;i < menuplyr_width * menuplyr_height;i++)
1015 menuplyr_translated[i] = palette_complete[translationTable[menuplyr_pixels[i]]];
1016 Draw_NewPic("gfx/menuplyr.lmp", menuplyr_width, menuplyr_height, true, (qbyte *)menuplyr_translated);
1018 M_DrawPic(160, 48, "gfx/bigbox.lmp");
1019 M_DrawPic(172, 56, "gfx/menuplyr.lmp");
1022 if (setup_cursor == 0)
1023 M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
1025 M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
1029 void M_Setup_Key (int k, char ascii)
1036 M_Menu_MultiPlayer_f ();
1040 S_LocalSound ("misc/menu1.wav");
1042 if (setup_cursor < 0)
1043 setup_cursor = NUM_SETUP_CMDS-1;
1047 S_LocalSound ("misc/menu1.wav");
1049 if (setup_cursor >= NUM_SETUP_CMDS)
1054 if (setup_cursor < 1)
1056 S_LocalSound ("misc/menu3.wav");
1057 if (setup_cursor == 1)
1058 setup_top = setup_top - 1;
1059 if (setup_cursor == 2)
1060 setup_bottom = setup_bottom - 1;
1061 if (setup_cursor == 3)
1063 l = setup_rateindex(setup_rate) - 1;
1066 setup_rate = setup_ratetable[l].rate;
1070 if (setup_cursor < 1)
1073 S_LocalSound ("misc/menu3.wav");
1074 if (setup_cursor == 1)
1075 setup_top = setup_top + 1;
1076 if (setup_cursor == 2)
1077 setup_bottom = setup_bottom + 1;
1078 if (setup_cursor == 3)
1080 l = setup_rateindex(setup_rate) + 1;
1083 setup_rate = setup_ratetable[l].rate;
1088 if (setup_cursor == 0)
1091 if (setup_cursor == 1 || setup_cursor == 2 || setup_cursor == 3)
1094 // setup_cursor == 4 (Accept changes)
1095 if (strcmp(cl_name.string, setup_myname) != 0)
1096 Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
1097 if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
1098 Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
1099 m_entersound = true;
1100 M_Menu_MultiPlayer_f ();
1104 if (setup_cursor == 0)
1106 if (strlen(setup_myname))
1107 setup_myname[strlen(setup_myname)-1] = 0;
1112 if (ascii < 32 || ascii > 126)
1114 if (setup_cursor == 0)
1116 l = strlen(setup_myname);
1119 setup_myname[l+1] = 0;
1120 setup_myname[l] = ascii;
1129 if (setup_bottom > 15)
1131 if (setup_bottom < 0)
1135 //=============================================================================
1138 #define SLIDER_RANGE 10
1140 void M_DrawSlider (int x, int y, float num, float rangemin, float rangemax)
1145 range = bound(0, (num - rangemin) / (rangemax - rangemin), 1);
1146 M_DrawCharacter (x-8, y, 128);
1147 for (i = 0;i < SLIDER_RANGE;i++)
1148 M_DrawCharacter (x + i*8, y, 129);
1149 M_DrawCharacter (x+i*8, y, 130);
1150 M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
1151 if (fabs((int)num - num) < 0.01)
1152 sprintf(text, "%i", (int)num);
1154 sprintf(text, "%.2f", num);
1155 M_Print(x + (SLIDER_RANGE+2) * 8, y, text);
1158 void M_DrawCheckbox (int x, int y, int on)
1161 M_Print(x, y, "on");
1163 M_Print(x, y, "off");
1167 #define OPTIONS_ITEMS 34
1171 void M_Menu_Options_f (void)
1173 key_dest = key_menu;
1174 m_state = m_options;
1175 m_entersound = true;
1178 extern cvar_t snd_staticvolume;
1179 extern cvar_t gl_delayfinish;
1180 extern cvar_t slowmo;
1181 extern dllhandle_t jpeg_dll;
1182 extern cvar_t gl_texture_anisotropy;
1184 void M_Menu_Options_AdjustSliders (int dir)
1187 S_LocalSound ("misc/menu3.wav");
1190 if (options_cursor == optnum++)
1191 Cvar_SetValueQuick (&vid_conwidth, bound(320, vid_conwidth.value + dir * 64, 2048));
1192 else if (options_cursor == optnum++)
1193 Cvar_SetValueQuick (&vid_conheight, bound(240, vid_conheight.value + dir * 48, 1536));
1194 else if (options_cursor == optnum++)
1195 Cvar_SetValueQuick (&scr_conspeed, bound(0, scr_conspeed.value + dir * 100, 1000));
1196 else if (options_cursor == optnum++)
1197 Cvar_SetValueQuick (&scr_conalpha, bound(0, scr_conalpha.value + dir * 0.2, 1));
1198 else if (options_cursor == optnum++)
1199 Cvar_SetValueQuick (&scr_conbrightness, bound(0, scr_conbrightness.value + dir * 0.2, 1));
1200 else if (options_cursor == optnum++)
1201 Cvar_SetValueQuick (&scr_viewsize, bound(30, scr_viewsize.value + dir * 10, 120));
1202 else if (options_cursor == optnum++)
1203 Cvar_SetValueQuick (&scr_screenshot_jpeg, !scr_screenshot_jpeg.integer);
1204 else if (options_cursor == optnum++)
1205 Cvar_SetValueQuick (&scr_screenshot_jpeg_quality, bound(0, scr_screenshot_jpeg_quality.value + dir * 0.1, 1));
1206 else if (options_cursor == optnum++)
1207 Cvar_SetValueQuick (&r_sky, !r_sky.integer);
1208 else if (options_cursor == optnum++)
1209 Cvar_SetValueQuick (&gl_combine, !gl_combine.integer);
1210 else if (options_cursor == optnum++)
1211 Cvar_SetValueQuick (&gl_dither, !gl_dither.integer);
1212 else if (options_cursor == optnum++)
1213 Cvar_SetValueQuick (&gl_delayfinish, !gl_delayfinish.integer);
1214 else if (options_cursor == optnum++)
1215 Cvar_SetValueQuick (&gl_texture_anisotropy, bound(0, gl_texture_anisotropy.value + dir, 8));
1216 else if (options_cursor == optnum++)
1217 Cvar_SetValueQuick (&slowmo, bound(0, slowmo.value + dir * 0.25, 5));
1218 else if (options_cursor == optnum++)
1220 Cvar_SetValueQuick (&bgmvolume, bound(0, bgmvolume.value + dir * 1.0, 1));
1222 Cvar_SetValueQuick (&bgmvolume, bound(0, bgmvolume.value + dir * 0.1, 1));
1224 else if (options_cursor == optnum++)
1225 Cvar_SetValueQuick (&volume, bound(0, volume.value + dir * 0.1, 1));
1226 else if (options_cursor == optnum++)
1227 Cvar_SetValueQuick (&snd_staticvolume, bound(0, snd_staticvolume.value + dir * 0.1, 1));
1228 else if (options_cursor == optnum++)
1229 Cvar_SetValueQuick (&crosshair, bound(0, crosshair.integer + dir, 5));
1230 else if (options_cursor == optnum++)
1231 Cvar_SetValueQuick (&crosshair_size, bound(1, crosshair_size.value + dir, 5));
1232 else if (options_cursor == optnum++)
1233 Cvar_SetValueQuick (&crosshair_static, !crosshair_static.integer);
1234 else if (options_cursor == optnum++)
1235 Cvar_SetValueQuick (&showfps, !showfps.integer);
1236 else if (options_cursor == optnum++)
1238 if (cl_forwardspeed.value > 200)
1240 Cvar_SetValueQuick (&cl_forwardspeed, 200);
1241 Cvar_SetValueQuick (&cl_backspeed, 200);
1245 Cvar_SetValueQuick (&cl_forwardspeed, 400);
1246 Cvar_SetValueQuick (&cl_backspeed, 400);
1249 else if (options_cursor == optnum++)
1250 Cvar_SetValueQuick (&lookspring, !lookspring.integer);
1251 else if (options_cursor == optnum++)
1252 Cvar_SetValueQuick (&lookstrafe, !lookstrafe.integer);
1253 else if (options_cursor == optnum++)
1254 Cvar_SetValueQuick (&sensitivity, bound(1, sensitivity.value + dir * 0.5, 50));
1255 else if (options_cursor == optnum++)
1256 Cvar_SetValueQuick (&freelook, !freelook.integer);
1257 else if (options_cursor == optnum++)
1258 Cvar_SetValueQuick (&m_pitch, -m_pitch.value);
1259 else if (options_cursor == optnum++)
1260 Cvar_SetValueQuick (&vid_mouse, !vid_mouse.integer);
1267 void M_Options_PrintCommand(char *s, int enabled)
1271 DrawQ_Fill(menu_x, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
1272 M_ItemPrint(0, opty, s, enabled);
1278 void M_Options_PrintCheckbox(char *s, int enabled, int yes)
1282 DrawQ_Fill(menu_x, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
1283 M_ItemPrint(0, opty, s, enabled);
1284 M_DrawCheckbox(0 + strlen(s) * 8 + 8, opty, yes);
1290 void M_Options_PrintSlider(char *s, int enabled, float value, float minvalue, float maxvalue)
1294 DrawQ_Fill(menu_x, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
1295 M_ItemPrint(0, opty, s, enabled);
1296 M_DrawSlider(0 + strlen(s) * 8 + 8, opty, value, minvalue, maxvalue);
1302 void M_Options_Draw (void)
1307 M_Background(320, 240);
1309 M_DrawPic(16, 4, "gfx/qplaque.lmp");
1310 p = Draw_CachePic("gfx/p_option.lmp");
1311 M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
1314 optcursor = options_cursor;
1315 visible = (vid.conheight - 32) / 8;
1316 opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_ITEMS - visible)) * 8;
1318 M_Options_PrintCommand( "Customize controls", true);
1319 M_Options_PrintCommand( " Go to console", true);
1320 M_Options_PrintCommand( " Reset to defaults", true);
1321 M_Options_PrintCommand( " Video", true);
1322 M_Options_PrintCommand( " Effects", true);
1323 M_Options_PrintCommand( " Color Control", true);
1324 M_Options_PrintSlider( " 2D Screen Width ", true, vid_conwidth.value, 320, 2048);
1325 M_Options_PrintSlider( " 2D Screen Height", true, vid_conheight.value, 240, 1536);
1326 M_Options_PrintSlider( " Console Speed", true, scr_conspeed.value, 0, 1000);
1327 M_Options_PrintSlider( " Console Alpha", true, scr_conalpha.value, 0, 1);
1328 M_Options_PrintSlider( "Conback Brightness", true, scr_conbrightness.value, 0, 1);
1329 M_Options_PrintSlider( " Screen size", true, scr_viewsize.value, 30, 120);
1330 M_Options_PrintCheckbox(" JPEG screenshots", jpeg_dll != NULL, scr_screenshot_jpeg.integer);
1331 M_Options_PrintSlider( " JPEG quality", jpeg_dll != NULL, scr_screenshot_jpeg_quality.value, 0, 1);
1332 M_Options_PrintCheckbox(" Sky", true, r_sky.integer);
1333 M_Options_PrintCheckbox(" Texture Combine", true, gl_combine.integer);
1334 M_Options_PrintCheckbox(" Dithering", true, gl_dither.integer);
1335 M_Options_PrintCheckbox("Delay gfx (faster)", true, gl_delayfinish.integer);
1336 M_Options_PrintSlider( "Anisotropic Filter", gl_support_anisotropy, gl_texture_anisotropy.value, 0, 8);
1337 M_Options_PrintSlider( " Game Speed", sv.active, slowmo.value, 0, 5);
1338 M_Options_PrintSlider( " CD Music Volume", cdaudioinitialized.integer, bgmvolume.value, 0, 1);
1339 M_Options_PrintSlider( " Sound Volume", snd_initialized.integer, volume.value, 0, 1);
1340 M_Options_PrintSlider(gamemode == GAME_GOODVSBAD2 ? " Music Volume" : " Ambient Volume", snd_initialized.integer, snd_staticvolume.value, 0, 1);
1341 M_Options_PrintSlider( " Crosshair", true, crosshair.value, 0, 5);
1342 M_Options_PrintSlider( " Crosshair Size", true, crosshair_size.value, 1, 5);
1343 M_Options_PrintCheckbox(" Static Crosshair", true, crosshair_static.integer);
1344 M_Options_PrintCheckbox(" Show Framerate", true, showfps.integer);
1345 M_Options_PrintCheckbox(" Always Run", true, cl_forwardspeed.value > 200);
1346 M_Options_PrintCheckbox(" Lookspring", true, lookspring.integer);
1347 M_Options_PrintCheckbox(" Lookstrafe", true, lookstrafe.integer);
1348 M_Options_PrintSlider( " Mouse Speed", true, sensitivity.value, 1, 50);
1349 M_Options_PrintCheckbox(" Mouse Look", true, freelook.integer);
1350 M_Options_PrintCheckbox(" Invert Mouse", true, m_pitch.value < 0);
1351 M_Options_PrintCheckbox(" Use Mouse", true, vid_mouse.integer);
1355 void M_Options_Key (int k, char ascii)
1364 m_entersound = true;
1365 switch (options_cursor)
1372 key_dest = key_game;
1373 Con_ToggleConsole_f ();
1376 Cbuf_AddText ("exec default.cfg\n");
1382 M_Menu_Options_Effects_f ();
1385 M_Menu_Options_ColorControl_f ();
1388 M_Menu_Options_AdjustSliders (1);
1394 S_LocalSound ("misc/menu1.wav");
1396 if (options_cursor < 0)
1397 options_cursor = OPTIONS_ITEMS-1;
1401 S_LocalSound ("misc/menu1.wav");
1403 if (options_cursor >= OPTIONS_ITEMS)
1408 M_Menu_Options_AdjustSliders (-1);
1412 M_Menu_Options_AdjustSliders (1);
1417 #define OPTIONS_EFFECTS_ITEMS 22
1419 int options_effects_cursor;
1421 void M_Menu_Options_Effects_f (void)
1423 key_dest = key_menu;
1424 m_state = m_options_effects;
1425 m_entersound = true;
1429 extern cvar_t r_detailtextures;
1430 extern cvar_t cl_particles;
1431 extern cvar_t cl_explosions;
1432 extern cvar_t cl_stainmaps;
1433 extern cvar_t cl_decals;
1434 extern cvar_t r_explosionclip;
1435 extern cvar_t r_modellights;
1436 extern cvar_t r_coronas;
1437 extern cvar_t gl_flashblend;
1438 extern cvar_t cl_particles_quality;
1439 extern cvar_t cl_particles_bulletimpacts;
1440 extern cvar_t cl_particles_smoke;
1441 extern cvar_t cl_particles_sparks;
1442 extern cvar_t cl_particles_bubbles;
1443 extern cvar_t cl_particles_blood;
1444 extern cvar_t cl_particles_blood_alpha;
1445 extern cvar_t cl_particles_blood_bloodhack;
1447 void M_Menu_Options_Effects_AdjustSliders (int dir)
1450 S_LocalSound ("misc/menu3.wav");
1453 if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_modellights, bound(0, r_modellights.value + dir, 8));
1454 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_coronas, bound(0, r_coronas.value + dir * 0.125, 4));
1455 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&gl_flashblend, !gl_flashblend.integer);
1456 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles, !cl_particles.integer);
1457 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_quality, bound(1, cl_particles_quality.value + dir * 0.5, 4));
1458 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_explosions, !cl_explosions.integer);
1459 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_explosionclip, !r_explosionclip.integer);
1460 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_stainmaps, !cl_stainmaps.integer);
1461 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_decals, !cl_decals.integer);
1462 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_detailtextures, !r_detailtextures.integer);
1463 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_bulletimpacts, !cl_particles_bulletimpacts.integer);
1464 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_smoke, !cl_particles_smoke.integer);
1465 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_sparks, !cl_particles_sparks.integer);
1466 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_bubbles, !cl_particles_bubbles.integer);
1467 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_blood, !cl_particles_blood.integer);
1468 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_blood_alpha, bound(0.2, cl_particles_blood_alpha.value + dir * 0.1, 1));
1469 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&cl_particles_blood_bloodhack, !cl_particles_blood_bloodhack.integer);
1470 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_lerpmodels, !r_lerpmodels.integer);
1471 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_lerpsprites, !r_lerpsprites.integer);
1472 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_wateralpha, bound(0, r_wateralpha.value + dir * 0.1, 1));
1473 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_waterscroll, bound(0, r_waterscroll.value + dir * 0.5, 10));
1474 else if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_watershader, bound(0, r_watershader.value + dir * 0.25, 10));
1477 void M_Options_Effects_Draw (void)
1482 M_Background(320, 200);
1484 M_DrawPic(16, 4, "gfx/qplaque.lmp");
1485 p = Draw_CachePic("gfx/p_option.lmp");
1486 M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
1488 optcursor = options_effects_cursor;
1490 visible = (vid.conheight - 32) / 8;
1491 opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_EFFECTS_ITEMS - visible)) * 8;
1493 M_Options_PrintSlider( " Lights Per Model", true, r_modellights.value, 0, 8);
1494 M_Options_PrintSlider( " Corona Intensity", true, r_coronas.value, 0, 4);
1495 M_Options_PrintCheckbox(" Use Only Coronas", true, gl_flashblend.integer);
1496 M_Options_PrintCheckbox(" Particles", true, cl_particles.integer);
1497 M_Options_PrintSlider( " Particles Quality", true, cl_particles_quality.value, 1, 4);
1498 M_Options_PrintCheckbox(" Explosions", true, cl_explosions.integer);
1499 M_Options_PrintCheckbox(" Explosion Clipping", true, r_explosionclip.integer);
1500 M_Options_PrintCheckbox(" Stainmaps", true, cl_stainmaps.integer);
1501 M_Options_PrintCheckbox(" Decals", true, cl_decals.integer);
1502 M_Options_PrintCheckbox(" Detail Texturing", true, r_detailtextures.integer);
1503 M_Options_PrintCheckbox(" Bullet Impacts", true, cl_particles_bulletimpacts.integer);
1504 M_Options_PrintCheckbox(" Smoke", true, cl_particles_smoke.integer);
1505 M_Options_PrintCheckbox(" Sparks", true, cl_particles_sparks.integer);
1506 M_Options_PrintCheckbox(" Bubbles", true, cl_particles_bubbles.integer);
1507 M_Options_PrintCheckbox(" Blood", true, cl_particles_blood.integer);
1508 M_Options_PrintSlider( " Blood Opacity", true, cl_particles_blood_alpha.value, 0.2, 1);
1509 M_Options_PrintCheckbox("Force New Blood Effect", true, cl_particles_blood_bloodhack.integer);
1510 M_Options_PrintCheckbox(" Model Interpolation", true, r_lerpmodels.integer);
1511 M_Options_PrintCheckbox(" Sprite Interpolation", true, r_lerpsprites.integer);
1512 M_Options_PrintSlider( " Water Alpha (opacity)", true, r_wateralpha.value, 0, 1);
1513 M_Options_PrintSlider( " Water Movement", true, r_waterscroll.value, 0, 10);
1514 M_Options_PrintSlider( " GeForce3 Water Shader", true, r_watershader.value, 0, 10);
1518 void M_Options_Effects_Key (int k, char ascii)
1523 M_Menu_Options_f ();
1527 M_Menu_Options_Effects_AdjustSliders (1);
1531 S_LocalSound ("misc/menu1.wav");
1532 options_effects_cursor--;
1533 if (options_effects_cursor < 0)
1534 options_effects_cursor = OPTIONS_EFFECTS_ITEMS-1;
1538 S_LocalSound ("misc/menu1.wav");
1539 options_effects_cursor++;
1540 if (options_effects_cursor >= OPTIONS_EFFECTS_ITEMS)
1541 options_effects_cursor = 0;
1545 M_Menu_Options_Effects_AdjustSliders (-1);
1549 M_Menu_Options_Effects_AdjustSliders (1);
1558 #define OPTIONS_COLORCONTROL_ITEMS 18
1560 int options_colorcontrol_cursor;
1562 // intensity value to match up to 50% dither to 'correct' quake
1563 cvar_t menu_options_colorcontrol_correctionvalue = {0, "menu_options_colorcontrol_correctionvalue", "0.25"};
1565 void M_Menu_Options_ColorControl_f (void)
1567 key_dest = key_menu;
1568 m_state = m_options_colorcontrol;
1569 m_entersound = true;
1573 void M_Menu_Options_ColorControl_AdjustSliders (int dir)
1577 S_LocalSound ("misc/menu3.wav");
1580 if (options_colorcontrol_cursor == optnum++)
1581 Cvar_SetValueQuick (&v_hwgamma, !v_hwgamma.integer);
1582 else if (options_colorcontrol_cursor == optnum++)
1584 Cvar_SetValueQuick (&v_color_enable, 0);
1585 Cvar_SetValueQuick (&v_gamma, bound(1, v_gamma.value + dir * 0.125, 5));
1587 else if (options_colorcontrol_cursor == optnum++)
1589 Cvar_SetValueQuick (&v_color_enable, 0);
1590 Cvar_SetValueQuick (&v_contrast, bound(1, v_contrast.value + dir * 0.125, 5));
1592 else if (options_colorcontrol_cursor == optnum++)
1594 Cvar_SetValueQuick (&v_color_enable, 0);
1595 Cvar_SetValueQuick (&v_brightness, bound(0, v_brightness.value + dir * 0.05, 0.8));
1597 else if (options_colorcontrol_cursor == optnum++)
1599 Cvar_SetValueQuick (&v_color_enable, !v_color_enable.integer);
1601 else if (options_colorcontrol_cursor == optnum++)
1603 Cvar_SetValueQuick (&v_color_enable, 1);
1604 Cvar_SetValueQuick (&v_color_black_r, bound(0, v_color_black_r.value + dir * 0.0125, 0.8));
1606 else if (options_colorcontrol_cursor == optnum++)
1608 Cvar_SetValueQuick (&v_color_enable, 1);
1609 Cvar_SetValueQuick (&v_color_black_g, bound(0, v_color_black_g.value + dir * 0.0125, 0.8));
1611 else if (options_colorcontrol_cursor == optnum++)
1613 Cvar_SetValueQuick (&v_color_enable, 1);
1614 Cvar_SetValueQuick (&v_color_black_b, bound(0, v_color_black_b.value + dir * 0.0125, 0.8));
1616 else if (options_colorcontrol_cursor == optnum++)
1618 Cvar_SetValueQuick (&v_color_enable, 1);
1619 f = bound(0, (v_color_black_r.value + v_color_black_g.value + v_color_black_b.value) / 3 + dir * 0.0125, 0.8);
1620 Cvar_SetValueQuick (&v_color_black_r, f);
1621 Cvar_SetValueQuick (&v_color_black_g, f);
1622 Cvar_SetValueQuick (&v_color_black_b, f);
1624 else if (options_colorcontrol_cursor == optnum++)
1626 Cvar_SetValueQuick (&v_color_enable, 1);
1627 Cvar_SetValueQuick (&v_color_grey_r, bound(0, v_color_grey_r.value + dir * 0.0125, 0.95));
1629 else if (options_colorcontrol_cursor == optnum++)
1631 Cvar_SetValueQuick (&v_color_enable, 1);
1632 Cvar_SetValueQuick (&v_color_grey_g, bound(0, v_color_grey_g.value + dir * 0.0125, 0.95));
1634 else if (options_colorcontrol_cursor == optnum++)
1636 Cvar_SetValueQuick (&v_color_enable, 1);
1637 Cvar_SetValueQuick (&v_color_grey_b, bound(0, v_color_grey_b.value + dir * 0.0125, 0.95));
1639 else if (options_colorcontrol_cursor == optnum++)
1641 Cvar_SetValueQuick (&v_color_enable, 1);
1642 f = bound(0, (v_color_grey_r.value + v_color_grey_g.value + v_color_grey_b.value) / 3 + dir * 0.0125, 0.95);
1643 Cvar_SetValueQuick (&v_color_grey_r, f);
1644 Cvar_SetValueQuick (&v_color_grey_g, f);
1645 Cvar_SetValueQuick (&v_color_grey_b, f);
1647 else if (options_colorcontrol_cursor == optnum++)
1649 Cvar_SetValueQuick (&v_color_enable, 1);
1650 Cvar_SetValueQuick (&v_color_white_r, bound(1, v_color_white_r.value + dir * 0.125, 5));
1652 else if (options_colorcontrol_cursor == optnum++)
1654 Cvar_SetValueQuick (&v_color_enable, 1);
1655 Cvar_SetValueQuick (&v_color_white_g, bound(1, v_color_white_g.value + dir * 0.125, 5));
1657 else if (options_colorcontrol_cursor == optnum++)
1659 Cvar_SetValueQuick (&v_color_enable, 1);
1660 Cvar_SetValueQuick (&v_color_white_b, bound(1, v_color_white_b.value + dir * 0.125, 5));
1662 else if (options_colorcontrol_cursor == optnum++)
1664 Cvar_SetValueQuick (&v_color_enable, 1);
1665 f = bound(1, (v_color_white_r.value + v_color_white_g.value + v_color_white_b.value) / 3 + dir * 0.125, 5);
1666 Cvar_SetValueQuick (&v_color_white_r, f);
1667 Cvar_SetValueQuick (&v_color_white_g, f);
1668 Cvar_SetValueQuick (&v_color_white_b, f);
1672 void M_Options_ColorControl_Draw (void)
1675 float x, c, s, t, u, v;
1678 M_Background(320, 256);
1680 M_DrawPic(16, 4, "gfx/qplaque.lmp");
1681 p = Draw_CachePic("gfx/p_option.lmp");
1682 M_DrawPic((320-p->width)/2, 4, "gfx/p_option.lmp");
1684 optcursor = options_colorcontrol_cursor;
1686 visible = (vid.conheight - 32) / 8;
1687 opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_COLORCONTROL_ITEMS - visible)) * 8;
1689 M_Options_PrintCommand( " Reset to defaults", true);
1690 M_Options_PrintCheckbox("Hardware Gamma Control", vid_hardwaregammasupported.integer, v_hwgamma.integer);
1691 M_Options_PrintSlider( " Gamma", !v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_gamma.value, 1, 5);
1692 M_Options_PrintSlider( " Contrast", !v_color_enable.integer, v_contrast.value, 1, 5);
1693 M_Options_PrintSlider( " Brightness", !v_color_enable.integer, v_brightness.value, 0, 0.8);
1694 M_Options_PrintCheckbox(" Color Level Controls", true, v_color_enable.integer);
1695 M_Options_PrintSlider( " Black: Red ", v_color_enable.integer, v_color_black_r.value, 0, 0.8);
1696 M_Options_PrintSlider( " Black: Green", v_color_enable.integer, v_color_black_g.value, 0, 0.8);
1697 M_Options_PrintSlider( " Black: Blue ", v_color_enable.integer, v_color_black_b.value, 0, 0.8);
1698 M_Options_PrintSlider( " Black: Grey ", v_color_enable.integer, (v_color_black_r.value + v_color_black_g.value + v_color_black_b.value) / 3, 0, 0.8);
1699 M_Options_PrintSlider( " Grey: Red ", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_color_grey_r.value, 0, 0.95);
1700 M_Options_PrintSlider( " Grey: Green", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_color_grey_g.value, 0, 0.95);
1701 M_Options_PrintSlider( " Grey: Blue ", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_color_grey_b.value, 0, 0.95);
1702 M_Options_PrintSlider( " Grey: Grey ", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, (v_color_grey_r.value + v_color_grey_g.value + v_color_grey_b.value) / 3, 0, 0.95);
1703 M_Options_PrintSlider( " White: Red ", v_color_enable.integer, v_color_white_r.value, 1, 5);
1704 M_Options_PrintSlider( " White: Green", v_color_enable.integer, v_color_white_g.value, 1, 5);
1705 M_Options_PrintSlider( " White: Blue ", v_color_enable.integer, v_color_white_b.value, 1, 5);
1706 M_Options_PrintSlider( " White: Grey ", v_color_enable.integer, (v_color_white_r.value + v_color_white_g.value + v_color_white_b.value) / 3, 1, 5);
1709 DrawQ_Fill(menu_x, menu_y + opty, 320, 4 + 64 + 8 + 64 + 4, 0, 0, 0, 1, 0);opty += 4;
1710 s = (float) 312 / 2 * vid.realwidth / vid.conwidth;
1711 t = (float) 4 / 2 * vid.realheight / vid.conheight;
1712 DrawQ_SuperPic(menu_x + 4, menu_y + opty, "gfx/colorcontrol/ditherpattern.tga", 312, 4, 0,0, 1,0,0,1, s,0, 1,0,0,1, 0,t, 1,0,0,1, s,t, 1,0,0,1, 0);opty += 4;
1713 DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL , 312, 4, 0,0, 0,0,0,1, 1,0, 1,0,0,1, 0,1, 0,0,0,1, 1,1, 1,0,0,1, 0);opty += 4;
1714 DrawQ_SuperPic(menu_x + 4, menu_y + opty, "gfx/colorcontrol/ditherpattern.tga", 312, 4, 0,0, 0,1,0,1, s,0, 0,1,0,1, 0,t, 0,1,0,1, s,t, 0,1,0,1, 0);opty += 4;
1715 DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL , 312, 4, 0,0, 0,0,0,1, 1,0, 0,1,0,1, 0,1, 0,0,0,1, 1,1, 0,1,0,1, 0);opty += 4;
1716 DrawQ_SuperPic(menu_x + 4, menu_y + opty, "gfx/colorcontrol/ditherpattern.tga", 312, 4, 0,0, 0,0,1,1, s,0, 0,0,1,1, 0,t, 0,0,1,1, s,t, 0,0,1,1, 0);opty += 4;
1717 DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL , 312, 4, 0,0, 0,0,0,1, 1,0, 0,0,1,1, 0,1, 0,0,0,1, 1,1, 0,0,1,1, 0);opty += 4;
1718 DrawQ_SuperPic(menu_x + 4, menu_y + opty, "gfx/colorcontrol/ditherpattern.tga", 312, 4, 0,0, 1,1,1,1, s,0, 1,1,1,1, 0,t, 1,1,1,1, s,t, 1,1,1,1, 0);opty += 4;
1719 DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL , 312, 4, 0,0, 0,0,0,1, 1,0, 1,1,1,1, 0,1, 0,0,0,1, 1,1, 1,1,1,1, 0);opty += 4;
1721 c = menu_options_colorcontrol_correctionvalue.value; // intensity value that should be matched up to a 50% dither to 'correct' quake
1722 s = (float) 48 / 2 * vid.realwidth / vid.conwidth;
1723 t = (float) 48 / 2 * vid.realheight / vid.conheight;
1728 DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, c, 0, 0, 1, 0);
1729 DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 1,0,0,1, s,0, 1,0,0,1, 0,t, 1,0,0,1, s,t, 1,0,0,1, 0);
1730 DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 1,0,0,1, u,0, 1,0,0,1, 0,v, 1,0,0,1, u,v, 1,0,0,1, 0);
1732 DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, 0, c, 0, 1, 0);
1733 DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 0,1,0,1, s,0, 0,1,0,1, 0,t, 0,1,0,1, s,t, 0,1,0,1, 0);
1734 DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 0,1,0,1, u,0, 0,1,0,1, 0,v, 0,1,0,1, u,v, 0,1,0,1, 0);
1736 DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, 0, 0, c, 1, 0);
1737 DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 0,0,1,1, s,0, 0,0,1,1, 0,t, 0,0,1,1, s,t, 0,0,1,1, 0);
1738 DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 0,0,1,1, u,0, 0,0,1,1, 0,v, 0,0,1,1, u,v, 0,0,1,1, 0);
1740 DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, c, c, c, 1, 0);
1741 DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 1,1,1,1, s,0, 1,1,1,1, 0,t, 1,1,1,1, s,t, 1,1,1,1, 0);
1742 DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, "gfx/colorcontrol/ditherpattern.tga", 16, 16, 0,0, 1,1,1,1, u,0, 1,1,1,1, 0,v, 1,1,1,1, u,v, 1,1,1,1, 0);
1746 void M_Options_ColorControl_Key (int k, char ascii)
1751 M_Menu_Options_f ();
1755 m_entersound = true;
1756 switch (options_colorcontrol_cursor)
1759 Cvar_SetValueQuick(&v_hwgamma, 1);
1760 Cvar_SetValueQuick(&v_gamma, 1);
1761 Cvar_SetValueQuick(&v_contrast, 1);
1762 Cvar_SetValueQuick(&v_brightness, 0);
1763 Cvar_SetValueQuick(&v_color_enable, 0);
1764 Cvar_SetValueQuick(&v_color_black_r, 0);
1765 Cvar_SetValueQuick(&v_color_black_g, 0);
1766 Cvar_SetValueQuick(&v_color_black_b, 0);
1767 Cvar_SetValueQuick(&v_color_grey_r, 0);
1768 Cvar_SetValueQuick(&v_color_grey_g, 0);
1769 Cvar_SetValueQuick(&v_color_grey_b, 0);
1770 Cvar_SetValueQuick(&v_color_white_r, 1);
1771 Cvar_SetValueQuick(&v_color_white_g, 1);
1772 Cvar_SetValueQuick(&v_color_white_b, 1);
1775 M_Menu_Options_ColorControl_AdjustSliders (1);
1781 S_LocalSound ("misc/menu1.wav");
1782 options_colorcontrol_cursor--;
1783 if (options_colorcontrol_cursor < 0)
1784 options_colorcontrol_cursor = OPTIONS_COLORCONTROL_ITEMS-1;
1788 S_LocalSound ("misc/menu1.wav");
1789 options_colorcontrol_cursor++;
1790 if (options_colorcontrol_cursor >= OPTIONS_COLORCONTROL_ITEMS)
1791 options_colorcontrol_cursor = 0;
1795 M_Menu_Options_ColorControl_AdjustSliders (-1);
1799 M_Menu_Options_ColorControl_AdjustSliders (1);
1805 //=============================================================================
1808 char *quakebindnames[][2] =
1810 {"+attack", "attack"},
1811 {"impulse 10", "next weapon"},
1812 {"impulse 12", "previous weapon"},
1813 {"+jump", "jump / swim up"},
1814 {"+forward", "walk forward"},
1815 {"+back", "backpedal"},
1816 {"+left", "turn left"},
1817 {"+right", "turn right"},
1819 {"+moveleft", "step left"},
1820 {"+moveright", "step right"},
1821 {"+strafe", "sidestep"},
1822 {"+lookup", "look up"},
1823 {"+lookdown", "look down"},
1824 {"centerview", "center view"},
1825 {"+mlook", "mouse look"},
1826 {"+klook", "keyboard look"},
1827 {"+moveup", "swim up"},
1828 {"+movedown", "swim down"}
1831 char *transfusionbindnames[][2] =
1833 {"", "Movement"}, // Movement commands
1834 {"+forward", "walk forward"},
1835 {"+back", "backpedal"},
1836 {"+left", "turn left"},
1837 {"+right", "turn right"},
1838 {"+moveleft", "step left"},
1839 {"+moveright", "step right"},
1840 {"+jump", "jump / swim up"},
1841 {"+movedown", "swim down"},
1842 {"", "Combat"}, // Combat commands
1843 {"impulse 1", "Pitch Fork"},
1844 {"impulse 2", "Flare Gun"},
1845 {"impulse 3", "Shotgun"},
1846 {"impulse 4", "Machine Gun"},
1847 {"impulse 5", "Incinerator"},
1848 {"impulse 6", "Bombs (TNT)"},
1849 {"impulse 35", "Proximity Bomb"},
1850 {"impulse 36", "Remote Detonator"},
1851 {"impulse 7", "Aerosol Can"},
1852 {"impulse 8", "Tesla Cannon"},
1853 {"impulse 9", "Life Leech"},
1854 {"impulse 10", "Voodoo Doll"},
1855 {"impulse 21", "next weapon"},
1856 {"impulse 22", "previous weapon"},
1857 {"+attack", "attack"},
1858 {"+button3", "altfire"},
1859 {"", "Inventory"}, // Inventory commands
1860 {"impulse 40", "Dr.'s Bag"},
1861 {"impulse 41", "Crystal Ball"},
1862 {"impulse 42", "Beast Vision"},
1863 {"impulse 43", "Jump Boots"},
1864 {"impulse 23", "next item"},
1865 {"impulse 24", "previous item"},
1866 {"impulse 25", "use item"},
1867 {"", "Misc"}, // Misc commands
1868 {"+button4", "use"},
1869 {"impulse 50", "add bot (red)"},
1870 {"impulse 51", "add bot (blue)"},
1871 {"impulse 52", "kick a bot"},
1872 {"impulse 26", "next armor type"},
1873 {"impulse 27", "identify player"},
1874 {"impulse 55", "voting menu"},
1875 {"impulse 56", "observer mode"}
1878 char *goodvsbad2bindnames[][2] =
1880 {"impulse 69", "Power 1"},
1881 {"impulse 70", "Power 2"},
1882 {"impulse 71", "Power 3"},
1883 {"+jump", "jump / swim up"},
1884 {"+forward", "walk forward"},
1885 {"+back", "backpedal"},
1886 {"+left", "turn left"},
1887 {"+right", "turn right"},
1889 {"+moveleft", "step left"},
1890 {"+moveright", "step right"},
1891 {"+strafe", "sidestep"},
1892 {"+lookup", "look up"},
1893 {"+lookdown", "look down"},
1894 {"centerview", "center view"},
1895 {"+mlook", "mouse look"},
1896 {"kill", "kill yourself"},
1897 {"+moveup", "swim up"},
1898 {"+movedown", "swim down"}
1902 char *(*bindnames)[2];
1905 typedef struct binditem_s
1907 char *command, *description;
1908 struct binditem_s *next;
1912 typedef struct bindcategory_s
1916 struct bindcategory_s *next;
1920 bindcategory_t *bindcategories = NULL;
1922 void M_ClearBinds (void)
1924 for (c = bindcategories;c;c = cnext)
1927 for (b = c->binds;b;b = bnext)
1934 bindcategories = NULL;
1937 void M_AddBindToCategory(bindcategory_t *c, char *command, char *description)
1939 for (b = &c->binds;*b;*b = &(*b)->next);
1940 *b = Z_Alloc(sizeof(binditem_t) + strlen(command) + 1 + strlen(description) + 1);
1941 *b->command = (char *)((*b) + 1);
1942 *b->description = *b->command + strlen(command) + 1;
1943 strcpy(*b->command, command);
1944 strcpy(*b->description, description);
1947 void M_AddBind (char *category, char *command, char *description)
1949 for (c = &bindcategories;*c;c = &(*c)->next)
1951 if (!strcmp(category, (*c)->name))
1953 M_AddBindToCategory(*c, command, description);
1957 *c = Z_Alloc(sizeof(bindcategory_t));
1958 M_AddBindToCategory(*c, command, description);
1961 void M_DefaultBinds (void)
1964 M_AddBind("movement", "+jump", "jump / swim up");
1965 M_AddBind("movement", "+forward", "walk forward");
1966 M_AddBind("movement", "+back", "backpedal");
1967 M_AddBind("movement", "+left", "turn left");
1968 M_AddBind("movement", "+right", "turn right");
1969 M_AddBind("movement", "+speed", "run");
1970 M_AddBind("movement", "+moveleft", "step left");
1971 M_AddBind("movement", "+moveright", "step right");
1972 M_AddBind("movement", "+strafe", "sidestep");
1973 M_AddBind("movement", "+lookup", "look up");
1974 M_AddBind("movement", "+lookdown", "look down");
1975 M_AddBind("movement", "centerview", "center view");
1976 M_AddBind("movement", "+mlook", "mouse look");
1977 M_AddBind("movement", "+klook", "keyboard look");
1978 M_AddBind("movement", "+moveup", "swim up");
1979 M_AddBind("movement", "+movedown", "swim down");
1980 M_AddBind("weapons", "+attack", "attack");
1981 M_AddBind("weapons", "impulse 10", "next weapon");
1982 M_AddBind("weapons", "impulse 12", "previous weapon");
1983 M_AddBind("weapons", "impulse 1", "select weapon 1 (axe)");
1984 M_AddBind("weapons", "impulse 2", "select weapon 2 (shotgun)");
1985 M_AddBind("weapons", "impulse 3", "select weapon 3 (super )");
1986 M_AddBind("weapons", "impulse 4", "select weapon 4 (nailgun)");
1987 M_AddBind("weapons", "impulse 5", "select weapon 5 (super nailgun)");
1988 M_AddBind("weapons", "impulse 6", "select weapon 6 (grenade launcher)");
1989 M_AddBind("weapons", "impulse 7", "select weapon 7 (rocket launcher)");
1990 M_AddBind("weapons", "impulse 8", "select weapon 8 (lightning gun)");
1998 void M_Menu_Keys_f (void)
2000 key_dest = key_menu;
2002 m_entersound = true;
2007 void M_FindKeysForCommand (char *command, int *keys)
2013 for (j = 0;j < NUMKEYS;j++)
2018 for (j = 0; j < (int)sizeof (keybindings[0]) / (int)sizeof (keybindings[0][0]); j++)
2020 b = keybindings[0][j];
2023 if (!strcmp (b, command) )
2026 if (count == NUMKEYS)
2032 void M_UnbindCommand (char *command)
2037 for (j = 0; j < (int)sizeof (keybindings[0]) / (int)sizeof (keybindings[0][0]); j++)
2039 b = keybindings[0][j];
2042 if (!strcmp (b, command))
2043 Key_SetBinding (j, 0, "");
2048 void M_Keys_Draw (void)
2054 char keystring[1024];
2056 M_Background(320, 48 + 8 * numcommands);
2058 p = Draw_CachePic ("gfx/ttl_cstm.lmp");
2059 M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_cstm.lmp");
2062 M_Print(12, 32, "Press a key or button for this action");
2064 M_Print(18, 32, "Enter to change, backspace to clear");
2066 // search for known bindings
2067 for (i=0 ; i<numcommands ; i++)
2071 // If there's no command, it's just a section
2072 if (bindnames[i][0][0] == '\0')
2074 M_PrintRed (4, y, "\x0D"); // #13 is the little arrow pointing to the right
2075 M_PrintRed (16, y, bindnames[i][1]);
2079 M_Print(16, y, bindnames[i][1]);
2081 M_FindKeysForCommand (bindnames[i][0], keys);
2083 // LordHavoc: redesigned to print more than 2 keys, inspired by Tomaz's MiniRacer
2085 strcpy(keystring, "???");
2089 for (j = 0;j < NUMKEYS;j++)
2094 strcat(keystring, " or ");
2095 strcat(keystring, Key_KeynumToString (keys[j]));
2099 M_Print(150, y, keystring);
2103 M_DrawCharacter (140, 48 + keys_cursor*8, '=');
2105 M_DrawCharacter (140, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
2109 void M_Keys_Key (int k, char ascii)
2116 S_LocalSound ("misc/menu1.wav");
2121 else //if (k != '`')
2123 sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
2124 Cbuf_InsertText (cmd);
2134 M_Menu_Options_f ();
2139 S_LocalSound ("misc/menu1.wav");
2143 if (keys_cursor < 0)
2144 keys_cursor = numcommands-1;
2146 while (bindnames[keys_cursor][0][0] == '\0'); // skip sections
2151 S_LocalSound ("misc/menu1.wav");
2155 if (keys_cursor >= numcommands)
2158 while (bindnames[keys_cursor][0][0] == '\0'); // skip sections
2161 case K_ENTER: // go into bind mode
2162 M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
2163 S_LocalSound ("misc/menu2.wav");
2164 if (keys[NUMKEYS - 1] != -1)
2165 M_UnbindCommand (bindnames[keys_cursor][0]);
2169 case K_BACKSPACE: // delete bindings
2170 case K_DEL: // delete bindings
2171 S_LocalSound ("misc/menu2.wav");
2172 M_UnbindCommand (bindnames[keys_cursor][0]);
2177 //=============================================================================
2180 #define VIDEO_ITEMS 4
2182 int video_cursor = 0;
2183 int video_cursor_table[] = {56, 68, 80, 100};
2184 // note: if modes are added to the beginning of this list, update the
2185 // video_resolution = x; in M_Menu_Video_f below
2186 unsigned short video_resolutions[][2] = {{320,240}, {400,300}, {512,384}, {640,480}, {800,600}, {1024,768}, {1152,864}, {1280,960}, {1280,1024}, {1600,1200}, {1792,1344}, {1920,1440}, {2048,1536}, {0,0}};
2187 // this is the number of the 640x480 mode in the list
2189 #define VID_RES_COUNT ((int)(sizeof(video_resolutions) / sizeof(video_resolutions[0])) - 1)
2190 int video_resolution;
2192 extern int current_vid_fullscreen;
2193 extern int current_vid_width;
2194 extern int current_vid_height;
2195 extern int current_vid_bitsperpixel;
2198 void M_Menu_Video_f (void)
2200 key_dest = key_menu;
2202 m_entersound = true;
2204 // Look for the current resolution
2205 for (video_resolution = 0; video_resolution < VID_RES_COUNT; video_resolution++)
2207 if (video_resolutions[video_resolution][0] == current_vid_width &&
2208 video_resolutions[video_resolution][1] == current_vid_height)
2212 // Default to VID_640 if we didn't find it
2213 if (video_resolution == VID_RES_COUNT)
2215 // may need to update this number if mode list changes
2216 video_resolution = VID_640;
2217 Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution][0]);
2218 Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution][1]);
2223 void M_Video_Draw (void)
2228 M_Background(320, 200);
2230 M_DrawPic(16, 4, "gfx/qplaque.lmp");
2231 p = Draw_CachePic("gfx/vidmodes.lmp");
2232 M_DrawPic((320-p->width)/2, 4, "gfx/vidmodes.lmp");
2235 M_Print(16, video_cursor_table[0], " Resolution");
2236 string = va("%dx%d", video_resolutions[video_resolution][0], video_resolutions[video_resolution][1]);
2237 M_Print(220, video_cursor_table[0], string);
2240 M_Print(16, video_cursor_table[1], " Bits per pixel");
2241 M_Print(220, video_cursor_table[1], (vid_bitsperpixel.integer == 32) ? "32" : "16");
2244 M_Print(16, video_cursor_table[2], " Fullscreen");
2245 M_DrawCheckbox(220, video_cursor_table[2], vid_fullscreen.integer);
2248 M_Print(220, video_cursor_table[3], "Apply");
2251 M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(realtime*4)&1));
2255 void M_Menu_Video_AdjustSliders (int dir)
2257 S_LocalSound ("misc/menu3.wav");
2259 switch (video_cursor)
2264 int new_resolution = video_resolution + dir;
2265 if (gamemode == GAME_FNIGGIUM ? new_resolution < VID_640 : new_resolution < 0)
2266 video_resolution = VID_RES_COUNT - 1;
2267 else if (new_resolution > VID_RES_COUNT - 1)
2268 video_resolution = gamemode == GAME_FNIGGIUM ? VID_640 : 0;
2270 video_resolution = new_resolution;
2272 Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution][0]);
2273 Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution][1]);
2279 Cvar_SetValueQuick (&vid_bitsperpixel, (vid_bitsperpixel.integer == 32) ? 16 : 32);
2282 Cvar_SetValueQuick (&vid_fullscreen, !vid_fullscreen.integer);
2288 void M_Video_Key (int key, char ascii)
2293 // vid_shared.c has a copy of the current video config. We restore it
2294 Cvar_SetValueQuick(&vid_fullscreen, current_vid_fullscreen);
2295 Cvar_SetValueQuick(&vid_width, current_vid_width);
2296 Cvar_SetValueQuick(&vid_height, current_vid_height);
2297 Cvar_SetValueQuick(&vid_bitsperpixel, current_vid_bitsperpixel);
2299 S_LocalSound ("misc/menu1.wav");
2300 M_Menu_Options_f ();
2304 m_entersound = true;
2305 switch (video_cursor)
2308 Cbuf_AddText ("vid_restart\n");
2309 M_Menu_Options_f ();
2312 M_Menu_Video_AdjustSliders (1);
2317 S_LocalSound ("misc/menu1.wav");
2319 if (video_cursor < 0)
2320 video_cursor = VIDEO_ITEMS-1;
2324 S_LocalSound ("misc/menu1.wav");
2326 if (video_cursor >= VIDEO_ITEMS)
2331 M_Menu_Video_AdjustSliders (-1);
2335 M_Menu_Video_AdjustSliders (1);
2340 //=============================================================================
2344 #define NUM_HELP_PAGES 6
2347 void M_Menu_Help_f (void)
2349 key_dest = key_menu;
2351 m_entersound = true;
2357 void M_Help_Draw (void)
2359 M_Background(320, 200);
2360 M_DrawPic (0, 0, va("gfx/help%i.lmp", help_page));
2364 void M_Help_Key (int key, char ascii)
2374 m_entersound = true;
2375 if (++help_page >= NUM_HELP_PAGES)
2381 m_entersound = true;
2382 if (--help_page < 0)
2383 help_page = NUM_HELP_PAGES-1;
2389 //=============================================================================
2392 char *m_quit_message[9];
2393 int m_quit_prevstate;
2394 qboolean wasInMenus;
2397 int M_QuitMessage(char *line1, char *line2, char *line3, char *line4, char *line5, char *line6, char *line7, char *line8)
2399 m_quit_message[0] = line1;
2400 m_quit_message[1] = line2;
2401 m_quit_message[2] = line3;
2402 m_quit_message[3] = line4;
2403 m_quit_message[4] = line5;
2404 m_quit_message[5] = line6;
2405 m_quit_message[6] = line7;
2406 m_quit_message[7] = line8;
2407 m_quit_message[8] = NULL;
2411 int M_ChooseQuitMessage(int request)
2419 if (request-- == 0) return M_QuitMessage("Are you gonna quit","this game just like","everything else?",NULL,NULL,NULL,NULL,NULL);
2420 if (request-- == 0) return M_QuitMessage("Milord, methinks that","thou art a lowly","quitter. Is this true?",NULL,NULL,NULL,NULL,NULL);
2421 if (request-- == 0) return M_QuitMessage("Do I need to bust your","face open for trying","to quit?",NULL,NULL,NULL,NULL,NULL);
2422 if (request-- == 0) return M_QuitMessage("Man, I oughta smack you","for trying to quit!","Press Y to get","smacked out.",NULL,NULL,NULL,NULL);
2423 if (request-- == 0) return M_QuitMessage("Press Y to quit like a","big loser in life.","Press N to stay proud","and successful!",NULL,NULL,NULL,NULL);
2424 if (request-- == 0) return M_QuitMessage("If you press Y to","quit, I will summon","Satan all over your","hard drive!",NULL,NULL,NULL,NULL);
2425 if (request-- == 0) return M_QuitMessage("Um, Asmodeus dislikes","his children trying to","quit. Press Y to return","to your Tinkertoys.",NULL,NULL,NULL,NULL);
2426 if (request-- == 0) return M_QuitMessage("If you quit now, I'll","throw a blanket-party","for you next time!",NULL,NULL,NULL,NULL,NULL);
2428 case GAME_GOODVSBAD2:
2429 if (request-- == 0) return M_QuitMessage("Press Yes To Quit","...","Yes",NULL,NULL,NULL,NULL,NULL);
2430 if (request-- == 0) return M_QuitMessage("Do you really want to","Quit?","Play Good vs bad 3!",NULL,NULL,NULL,NULL,NULL);
2431 if (request-- == 0) return M_QuitMessage("All your quit are","belong to long duck","dong",NULL,NULL,NULL,NULL,NULL);
2432 if (request-- == 0) return M_QuitMessage("Press Y to quit","","But are you too legit?",NULL,NULL,NULL,NULL,NULL);
2433 if (request-- == 0) return M_QuitMessage("This game was made by","e@chip-web.com","It is by far the best","game ever made.",NULL,NULL,NULL,NULL);
2434 if (request-- == 0) return M_QuitMessage("Even I really dont","know of a game better","Press Y to quit","like rougue chedder",NULL,NULL,NULL,NULL);
2435 if (request-- == 0) return M_QuitMessage("After you stop playing","tell the guys who made","counterstrike to just","kill themselves now",NULL,NULL,NULL,NULL);
2436 if (request-- == 0) return M_QuitMessage("Press Y to exit to DOS","","SSH login as user Y","to exit to Linux",NULL,NULL,NULL,NULL);
2437 if (request-- == 0) return M_QuitMessage("Press Y like you","were waanderers","from Ys'",NULL,NULL,NULL,NULL,NULL);
2438 if (request-- == 0) return M_QuitMessage("This game was made in","Nippon like the SS","announcer's saying ipon",NULL,NULL,NULL,NULL,NULL);
2439 if (request-- == 0) return M_QuitMessage("you","want to quit?",NULL,NULL,NULL,NULL,NULL,NULL);
2440 if (request-- == 0) return M_QuitMessage("Please stop playing","this stupid game",NULL,NULL,NULL,NULL,NULL,NULL);
2442 case GAME_BATTLEMECH:
2443 if (request-- == 0) return M_QuitMessage("? WHY ?","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL,NULL);
2444 if (request-- == 0) return M_QuitMessage("Leave now and your mech is scrap!","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL,NULL);
2445 if (request-- == 0) return M_QuitMessage("Accept Defeat?","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL,NULL);
2446 if (request-- == 0) return M_QuitMessage("Wait! There are more mechs to destroy!","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL,NULL);
2447 if (request-- == 0) return M_QuitMessage("Where's your bloodlust?","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL,NULL);
2448 if (request-- == 0) return M_QuitMessage("Your mech here is way more impressive","than your car out there...","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL);
2449 if (request-- == 0) return M_QuitMessage("Quitting won't reduce your debt","Press Y to quit, N to keep fraggin'",NULL,NULL,NULL,NULL,NULL,NULL);
2452 if (request-- == 0) return M_QuitMessage("Tired of fragging already?",NULL,NULL,NULL,NULL,NULL,NULL,NULL);
2453 if (request-- == 0) return M_QuitMessage("Quit now and forfeit your bodycount?",NULL,NULL,NULL,NULL,NULL,NULL,NULL);
2454 if (request-- == 0) return M_QuitMessage("Are you sure you want to quit?",NULL,NULL,NULL,NULL,NULL,NULL,NULL);
2455 if (request-- == 0) return M_QuitMessage("Off to do something constructive?",NULL,NULL,NULL,NULL,NULL,NULL,NULL);
2461 void M_Menu_Quit_f (void)
2464 if (m_state == m_quit)
2466 wasInMenus = (key_dest == key_menu);
2467 key_dest = key_menu;
2468 m_quit_prevstate = m_state;
2470 m_entersound = true;
2471 // count how many there are
2472 for (n = 0;M_ChooseQuitMessage(n);n++);
2474 M_ChooseQuitMessage(rand() % n);
2478 void M_Quit_Key (int key, char ascii)
2487 m_state = m_quit_prevstate;
2488 m_entersound = true;
2492 key_dest = key_game;
2507 void M_Quit_Draw (void)
2509 int i, l, linelength, firstline, lastline, lines;
2510 for (i = 0, linelength = 0, firstline = 9999, lastline = -1;m_quit_message[i];i++)
2512 if ((l = strlen(m_quit_message[i])))
2522 lines = (lastline - firstline) + 1;
2523 M_Background(linelength * 8 + 16, lines * 8 + 16);
2524 M_DrawTextBox(0, 0, linelength, lines);
2525 for (i = 0, l = firstline;i < lines;i++, l++)
2526 M_Print(8 + 4 * (linelength - strlen(m_quit_message[l])), 8 + 8 * i, m_quit_message[l]);
2529 //=============================================================================
2530 /* LAN CONFIG MENU */
2532 int lanConfig_cursor = -1;
2533 int lanConfig_cursor_table [] = {56, 76, 112};
2534 #define NUM_LANCONFIG_CMDS 3
2537 char lanConfig_portname[6];
2538 char lanConfig_joinname[22];
2540 void M_Menu_LanConfig_f (void)
2542 key_dest = key_menu;
2543 m_state = m_lanconfig;
2544 m_entersound = true;
2545 if (lanConfig_cursor == -1)
2548 lanConfig_cursor = 1;
2551 lanConfig_cursor = 1;
2552 lanConfig_port = 26000;
2553 sprintf(lanConfig_portname, "%u", lanConfig_port);
2555 m_return_reason[0] = 0;
2559 void M_LanConfig_Draw (void)
2566 M_Background(320, 200);
2568 M_DrawPic (16, 4, "gfx/qplaque.lmp");
2569 p = Draw_CachePic ("gfx/p_multi.lmp");
2570 basex = (320-p->width)/2;
2571 M_DrawPic (basex, 4, "gfx/p_multi.lmp");
2574 startJoin = "New Game";
2576 startJoin = "Join Game";
2577 protocol = "TCP/IP";
2578 M_Print(basex, 32, va ("%s - %s", startJoin, protocol));
2581 M_Print(basex, lanConfig_cursor_table[0], "Port");
2582 M_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
2583 M_Print(basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
2587 M_Print(basex, lanConfig_cursor_table[1], "Search for games...");
2588 M_Print(basex, lanConfig_cursor_table[2]-16, "Join game at:");
2589 M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
2590 M_Print(basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
2594 M_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
2595 M_Print(basex+8, lanConfig_cursor_table[1], "OK");
2598 M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
2600 if (lanConfig_cursor == 0)
2601 M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
2603 if (lanConfig_cursor == 2)
2604 M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
2606 if (*m_return_reason)
2607 M_Print(basex, 168, m_return_reason);
2611 void M_LanConfig_Key (int key, char ascii)
2618 M_Menu_MultiPlayer_f ();
2622 S_LocalSound ("misc/menu1.wav");
2624 if (lanConfig_cursor < 0)
2625 lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
2629 S_LocalSound ("misc/menu1.wav");
2631 if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
2632 lanConfig_cursor = 0;
2636 if (lanConfig_cursor == 0)
2639 m_entersound = true;
2641 Cbuf_AddText ("stopdemo\n");
2643 Cvar_SetValue("port", lanConfig_port);
2645 if (lanConfig_cursor == 1)
2649 M_Menu_GameOptions_f ();
2652 M_Menu_ServerList_f();
2656 if (lanConfig_cursor == 2)
2657 Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
2661 if (lanConfig_cursor == 0)
2663 if (strlen(lanConfig_portname))
2664 lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
2667 if (lanConfig_cursor == 2)
2669 if (strlen(lanConfig_joinname))
2670 lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
2675 if (ascii < 32 || ascii > 126)
2678 if (lanConfig_cursor == 2)
2680 l = strlen(lanConfig_joinname);
2683 lanConfig_joinname[l+1] = 0;
2684 lanConfig_joinname[l] = ascii;
2688 if (ascii < '0' || ascii > '9')
2690 if (lanConfig_cursor == 0)
2692 l = strlen(lanConfig_portname);
2695 lanConfig_portname[l+1] = 0;
2696 lanConfig_portname[l] = ascii;
2701 if (StartingGame && lanConfig_cursor == 2)
2703 if (key == K_UPARROW)
2704 lanConfig_cursor = 1;
2706 lanConfig_cursor = 0;
2709 l = atoi(lanConfig_portname);
2712 sprintf(lanConfig_portname, "%u", lanConfig_port);
2715 //=============================================================================
2716 /* GAME OPTIONS MENU */
2735 episode_t *episodes;
2740 level_t quakelevels[] =
2742 {"start", "Entrance"}, // 0
2744 {"e1m1", "Slipgate Complex"}, // 1
2745 {"e1m2", "Castle of the Damned"},
2746 {"e1m3", "The Necropolis"},
2747 {"e1m4", "The Grisly Grotto"},
2748 {"e1m5", "Gloom Keep"},
2749 {"e1m6", "The Door To Chthon"},
2750 {"e1m7", "The House of Chthon"},
2751 {"e1m8", "Ziggurat Vertigo"},
2753 {"e2m1", "The Installation"}, // 9
2754 {"e2m2", "Ogre Citadel"},
2755 {"e2m3", "Crypt of Decay"},
2756 {"e2m4", "The Ebon Fortress"},
2757 {"e2m5", "The Wizard's Manse"},
2758 {"e2m6", "The Dismal Oubliette"},
2759 {"e2m7", "Underearth"},
2761 {"e3m1", "Termination Central"}, // 16
2762 {"e3m2", "The Vaults of Zin"},
2763 {"e3m3", "The Tomb of Terror"},
2764 {"e3m4", "Satan's Dark Delight"},
2765 {"e3m5", "Wind Tunnels"},
2766 {"e3m6", "Chambers of Torment"},
2767 {"e3m7", "The Haunted Halls"},
2769 {"e4m1", "The Sewage System"}, // 23
2770 {"e4m2", "The Tower of Despair"},
2771 {"e4m3", "The Elder God Shrine"},
2772 {"e4m4", "The Palace of Hate"},
2773 {"e4m5", "Hell's Atrium"},
2774 {"e4m6", "The Pain Maze"},
2775 {"e4m7", "Azure Agony"},
2776 {"e4m8", "The Nameless City"},
2778 {"end", "Shub-Niggurath's Pit"}, // 31
2780 {"dm1", "Place of Two Deaths"}, // 32
2781 {"dm2", "Claustrophobopolis"},
2782 {"dm3", "The Abandoned Base"},
2783 {"dm4", "The Bad Place"},
2784 {"dm5", "The Cistern"},
2785 {"dm6", "The Dark Zone"}
2788 episode_t quakeepisodes[] =
2790 {"Welcome to Quake", 0, 1},
2791 {"Doomed Dimension", 1, 8},
2792 {"Realm of Black Magic", 9, 7},
2793 {"Netherworld", 16, 7},
2794 {"The Elder World", 23, 8},
2795 {"Final Level", 31, 1},
2796 {"Deathmatch Arena", 32, 6}
2799 //MED 01/06/97 added hipnotic levels
2800 level_t hipnoticlevels[] =
2802 {"start", "Command HQ"}, // 0
2804 {"hip1m1", "The Pumping Station"}, // 1
2805 {"hip1m2", "Storage Facility"},
2806 {"hip1m3", "The Lost Mine"},
2807 {"hip1m4", "Research Facility"},
2808 {"hip1m5", "Military Complex"},
2810 {"hip2m1", "Ancient Realms"}, // 6
2811 {"hip2m2", "The Black Cathedral"},
2812 {"hip2m3", "The Catacombs"},
2813 {"hip2m4", "The Crypt"},
2814 {"hip2m5", "Mortum's Keep"},
2815 {"hip2m6", "The Gremlin's Domain"},
2817 {"hip3m1", "Tur Torment"}, // 12
2818 {"hip3m2", "Pandemonium"},
2819 {"hip3m3", "Limbo"},
2820 {"hip3m4", "The Gauntlet"},
2822 {"hipend", "Armagon's Lair"}, // 16
2824 {"hipdm1", "The Edge of Oblivion"} // 17
2827 //MED 01/06/97 added hipnotic episodes
2828 episode_t hipnoticepisodes[] =
2830 {"Scourge of Armagon", 0, 1},
2831 {"Fortress of the Dead", 1, 5},
2832 {"Dominion of Darkness", 6, 6},
2833 {"The Rift", 12, 4},
2834 {"Final Level", 16, 1},
2835 {"Deathmatch Arena", 17, 1}
2838 //PGM 01/07/97 added rogue levels
2839 //PGM 03/02/97 added dmatch level
2840 level_t roguelevels[] =
2842 {"start", "Split Decision"},
2843 {"r1m1", "Deviant's Domain"},
2844 {"r1m2", "Dread Portal"},
2845 {"r1m3", "Judgement Call"},
2846 {"r1m4", "Cave of Death"},
2847 {"r1m5", "Towers of Wrath"},
2848 {"r1m6", "Temple of Pain"},
2849 {"r1m7", "Tomb of the Overlord"},
2850 {"r2m1", "Tempus Fugit"},
2851 {"r2m2", "Elemental Fury I"},
2852 {"r2m3", "Elemental Fury II"},
2853 {"r2m4", "Curse of Osiris"},
2854 {"r2m5", "Wizard's Keep"},
2855 {"r2m6", "Blood Sacrifice"},
2856 {"r2m7", "Last Bastion"},
2857 {"r2m8", "Source of Evil"},
2858 {"ctf1", "Division of Change"}
2861 //PGM 01/07/97 added rogue episodes
2862 //PGM 03/02/97 added dmatch episode
2863 episode_t rogueepisodes[] =
2865 {"Introduction", 0, 1},
2866 {"Hell's Fortress", 1, 7},
2867 {"Corridors of Time", 8, 8},
2868 {"Deathmatch Arena", 16, 1}
2871 level_t nehahralevels[] =
2873 {"nehstart", "Welcome to Nehahra"},
2874 {"neh1m1", "Forge City1: Slipgates"},
2875 {"neh1m2", "Forge City2: Boiler"},
2876 {"neh1m3", "Forge City3: Escape"},
2877 {"neh1m4", "Grind Core"},
2878 {"neh1m5", "Industrial Silence"},
2879 {"neh1m6", "Locked-Up Anger"},
2880 {"neh1m7", "Wanderer of the Wastes"},
2881 {"neh1m8", "Artemis System Net"},
2882 {"neh1m9", "To the Death"},
2883 {"neh2m1", "The Gates of Ghoro"},
2884 {"neh2m2", "Sacred Trinity"},
2885 {"neh2m3", "Realm of the Ancients"},
2886 {"neh2m4", "Temple of the Ancients"},
2887 {"neh2m5", "Dreams Made Flesh"},
2888 {"neh2m6", "Your Last Cup of Sorrow"},
2889 {"nehsec", "Ogre's Bane"},
2890 {"nehahra", "Nehahra's Den"},
2891 {"nehend", "Quintessence"}
2894 episode_t nehahraepisodes[] =
2896 {"Welcome to Nehahra", 0, 1},
2897 {"The Fall of Forge", 1, 9},
2898 {"The Outlands", 10, 7},
2899 {"Dimension of the Lost", 17, 2}
2902 // Map list for Transfusion
2903 level_t transfusionlevels[] =
2905 {"bb1", "The Stronghold"},
2906 {"bb2", "Winter Wonderland"},
2908 {"bb4", "The Tower"},
2910 {"bb6", "Twin Fortress"},
2912 {"bb8", "Fun With Heads"},
2914 {"e1m1", "Cradle to Grave"},
2915 {"e1m2", "Wrong Side of the Tracks"},
2916 {"e1m7", "Altar of Stone"},
2917 {"e2m8", "The Lair of Shial"},
2918 {"e3m7", "The Pit of Cerberus"},
2919 {"e4m1", "Butchery Loves Company"},
2920 {"e4m7", "In the Flesh"},
2921 {"e4m8", "The Hall of the Epiphany"},
2922 {"e4m9", "Mall of the Dead"},
2924 {"dm1", "Monolith Building 11"},
2927 {"e6m1", "Welcome to Your Life"},
2928 {"e6m8", "Beauty and the Beast"},
2929 {"e6m9", "Forgotten Catacombs"},
2931 {"cpbb01", "Crypt of Despair"},
2932 {"cpbb03", "Unholy Cathedral"},
2934 {"b2a15", "Area 15 (B2)"},
2935 {"barena", "Blood Arena"},
2936 {"bkeep", "Blood Keep"},
2937 {"bstar", "Brown Star"},
2938 {"crypt", "The Crypt"},
2940 {"bb3_2k1", "Bodies Infusion"},
2941 {"captasao", "Captasao"},
2942 {"curandero", "Curandero"},
2943 {"dcamp", "DeathCamp"},
2944 {"highnoon", "HighNoon"},
2945 {"qbb1", "The Confluence"},
2946 {"qbb2", "KathartiK"},
2947 {"qbb3", "Caleb's Woodland Retreat"},
2949 {"dranzbb6", "Black Coffee"},
2950 {"fragm", "Frag'M"},
2952 {"qe1m7", "The House of Chthon"},
2953 {"qmorbias", "Dm-Morbias"},
2954 {"simple", "Dead Simple"}
2957 episode_t transfusionepisodes[] =
2960 {"Blood Single Player", 8, 9},
2961 {"Plasma Pack", 17, 6},
2962 {"Cryptic Passage", 23, 2},
2964 {"Transfusion", 30, 8},
2965 {"Conversions", 38, 6}
2968 level_t goodvsbad2levels[] =
2970 {"rts", "Many Paths"}, // 0
2971 {"chess", "Chess, Scott Hess"}, // 1
2972 {"dot", "Big Wall"},
2973 {"city2", "The Big City"},
2974 {"bwall", "0 G like Psychic TV"},
2975 {"snow", "Wireframed"},
2976 {"telep", "Infinite Falling"},
2977 {"faces", "Facing Bases"},
2978 {"island", "Adventure Islands"},
2981 episode_t goodvsbad2episodes[] =
2983 {"Levels? Bevels!", 0, 8},
2986 level_t battlemechlevels[] =
2988 {"start", "Parking Level"},
2989 {"dm1", "Hot Dump"}, // 1
2990 {"dm2", "The Pits"},
2991 {"dm3", "Dimber Died"},
2992 {"dm4", "Fire in the Hole"},
2993 {"dm5", "Clubhouses"},
2994 {"dm6", "Army go Underground"},
2997 episode_t battlemechepisodes[] =
2999 {"Time for Battle", 0, 7},
3002 gamelevels_t sharewarequakegame = {"Shareware Quake", quakelevels, quakeepisodes, 2};
3003 gamelevels_t registeredquakegame = {"Quake", quakelevels, quakeepisodes, 7};
3004 gamelevels_t hipnoticgame = {"Scourge of Armagon", hipnoticlevels, hipnoticepisodes, 6};
3005 gamelevels_t roguegame = {"Dissolution of Eternity", roguelevels, rogueepisodes, 4};
3006 gamelevels_t nehahragame = {"Nehahra", nehahralevels, nehahraepisodes, 4};
3007 gamelevels_t transfusiongame = {"Transfusion", transfusionlevels, transfusionepisodes, 7};
3008 gamelevels_t goodvsbad2game = {"Good Vs. Bad 2", goodvsbad2levels, goodvsbad2episodes, 1};
3009 gamelevels_t battlemechgame = {"Battlemech", battlemechlevels, battlemechepisodes, 1};
3014 gamelevels_t *notregistered;
3015 gamelevels_t *registered;
3019 gameinfo_t gamelist[] =
3021 {GAME_NORMAL, &sharewarequakegame, ®isteredquakegame},
3022 {GAME_HIPNOTIC, &hipnoticgame, &hipnoticgame},
3023 {GAME_ROGUE, &roguegame, &roguegame},
3024 {GAME_NEHAHRA, &nehahragame, &nehahragame},
3025 {GAME_TRANSFUSION, &transfusiongame, &transfusiongame},
3026 {GAME_GOODVSBAD2, &goodvsbad2game, &goodvsbad2game},
3027 {GAME_BATTLEMECH, &battlemechgame, &battlemechgame},
3028 {-1, &sharewarequakegame, ®isteredquakegame} // final fallback
3031 gamelevels_t *lookupgameinfo(void)
3034 for (i = 0;gamelist[i].gameid >= 0 && gamelist[i].gameid != gamemode;i++);
3035 if (registered.integer)
3036 return gamelist[i].registered;
3038 return gamelist[i].notregistered;
3044 qboolean m_serverInfoMessage = false;
3045 double m_serverInfoMessageTime;
3047 extern cvar_t sv_public;
3049 void M_Menu_GameOptions_f (void)
3051 key_dest = key_menu;
3052 m_state = m_gameoptions;
3053 m_entersound = true;
3054 if (maxplayers == 0)
3055 maxplayers = svs.maxclients;
3057 maxplayers = min(8, MAX_SCOREBOARD);
3061 int gameoptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 104, 132, 152, 160};
3062 #define NUM_GAMEOPTIONS 11
3063 int gameoptions_cursor;
3065 void M_GameOptions_Draw (void)
3071 M_Background(320, 200);
3073 M_DrawPic (16, 4, "gfx/qplaque.lmp");
3074 p = Draw_CachePic ("gfx/p_multi.lmp");
3075 M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi.lmp");
3077 M_DrawTextBox (152, 32, 10, 1);
3078 M_Print(160, 40, "begin game");
3080 M_Print(0, 56, " Max players");
3081 M_Print(160, 56, va("%i", maxplayers) );
3083 if (gamemode != GAME_GOODVSBAD2)
3085 M_Print(0, 64, " Game Type");
3086 if (gamemode == GAME_TRANSFUSION)
3088 if (!deathmatch.integer)
3089 Cvar_SetValue("deathmatch", 1);
3090 if (deathmatch.integer == 2)
3091 M_Print(160, 64, "Capture the Flag");
3093 M_Print(160, 64, "Blood Bath");
3095 else if (gamemode == GAME_BATTLEMECH)
3097 if (!deathmatch.integer)
3098 Cvar_SetValue("deathmatch", 1);
3099 if (deathmatch.integer == 2)
3100 M_Print(160, 64, "Rambo Match");
3102 M_Print(160, 64, "Deathmatch");
3106 if (!coop.integer && !deathmatch.integer)
3107 Cvar_SetValue("deathmatch", 1);
3109 M_Print(160, 64, "Cooperative");
3111 M_Print(160, 64, "Deathmatch");
3114 M_Print(0, 72, " Teamplay");
3115 if (gamemode == GAME_ROGUE)
3119 switch((int)teamplay.integer)
3121 case 1: msg = "No Friendly Fire"; break;
3122 case 2: msg = "Friendly Fire"; break;
3123 case 3: msg = "Tag"; break;
3124 case 4: msg = "Capture the Flag"; break;
3125 case 5: msg = "One Flag CTF"; break;
3126 case 6: msg = "Three Team CTF"; break;
3127 default: msg = "Off"; break;
3129 M_Print(160, 72, msg);
3135 switch (teamplay.integer)
3137 case 0: msg = "Off"; break;
3138 case 2: msg = "Friendly Fire"; break;
3139 default: msg = "No Friendly Fire"; break;
3141 M_Print(160, 72, msg);
3144 M_Print(0, 80, " Skill");
3145 if (skill.integer == 0)
3146 M_Print(160, 80, "Easy difficulty");
3147 else if (skill.integer == 1)
3148 M_Print(160, 80, "Normal difficulty");
3149 else if (skill.integer == 2)
3150 M_Print(160, 80, "Hard difficulty");
3152 M_Print(160, 80, "Nightmare difficulty");
3154 M_Print(0, 88, " Frag Limit");
3155 if (fraglimit.integer == 0)
3156 M_Print(160, 88, "none");
3158 M_Print(160, 88, va("%i frags", fraglimit.integer));
3160 M_Print(0, 96, " Time Limit");
3161 if (timelimit.integer == 0)
3162 M_Print(160, 96, "none");
3164 M_Print(160, 96, va("%i minutes", timelimit.integer));
3167 M_Print(0, 104, " Public server");
3168 M_Print(160, 104, (sv_public.integer == 0) ? "no" : "yes");
3170 M_Print(0, 120, " Server name");
3171 M_DrawTextBox (0, 124, 38, 1);
3172 M_Print(8, 132, hostname.string);
3174 g = lookupgameinfo();
3176 if (gamemode != GAME_GOODVSBAD2)
3178 M_Print(0, 152, " Episode");
3179 M_Print(160, 152, g->episodes[startepisode].description);
3182 M_Print(0, 160, " Level");
3183 M_Print(160, 160, g->levels[g->episodes[startepisode].firstLevel + startlevel].description);
3184 M_Print(160, 168, g->levels[g->episodes[startepisode].firstLevel + startlevel].name);
3187 if (gameoptions_cursor == 8)
3188 M_DrawCharacter (8 + 8 * strlen(hostname.string), gameoptions_cursor_table[gameoptions_cursor], 10+((int)(realtime*4)&1));
3190 M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
3192 if (m_serverInfoMessage)
3194 if ((realtime - m_serverInfoMessageTime) < 5.0)
3197 M_DrawTextBox (x, 138, 24, 4);
3199 M_Print(x, 146, " More than 64 players?? ");
3200 M_Print(x, 154, " First, question your ");
3201 M_Print(x, 162, " sanity, then email ");
3202 M_Print(x, 170, " havoc@telefragged.com ");
3205 m_serverInfoMessage = false;
3210 void M_NetStart_Change (int dir)
3215 switch (gameoptions_cursor)
3219 if (maxplayers > MAX_SCOREBOARD)
3221 maxplayers = MAX_SCOREBOARD;
3222 m_serverInfoMessage = true;
3223 m_serverInfoMessageTime = realtime;
3230 if (gamemode == GAME_GOODVSBAD2)
3232 if (gamemode == GAME_TRANSFUSION)
3234 if (deathmatch.integer == 2) // changing from CTF to BloodBath
3235 Cvar_SetValueQuick (&deathmatch, 0);
3236 else // changing from BloodBath to CTF
3237 Cvar_SetValueQuick (&deathmatch, 2);
3239 else if (gamemode == GAME_BATTLEMECH)
3241 if (deathmatch.integer == 2) // changing from Rambo to Deathmatch
3242 Cvar_SetValueQuick (&deathmatch, 0);
3243 else // changing from Deathmatch to Rambo
3244 Cvar_SetValueQuick (&deathmatch, 2);
3248 if (deathmatch.integer) // changing from deathmatch to coop
3250 Cvar_SetValueQuick (&coop, 1);
3251 Cvar_SetValueQuick (&deathmatch, 0);
3253 else // changing from coop to deathmatch
3255 Cvar_SetValueQuick (&coop, 0);
3256 Cvar_SetValueQuick (&deathmatch, 1);
3262 if (gamemode == GAME_GOODVSBAD2)
3264 if (gamemode == GAME_ROGUE)
3269 Cvar_SetValueQuick (&teamplay, teamplay.integer + dir);
3270 if (teamplay.integer > count)
3271 Cvar_SetValueQuick (&teamplay, 0);
3272 else if (teamplay.integer < 0)
3273 Cvar_SetValueQuick (&teamplay, count);
3277 if (gamemode == GAME_GOODVSBAD2)
3279 Cvar_SetValueQuick (&skill, skill.integer + dir);
3280 if (skill.integer > 3)
3281 Cvar_SetValueQuick (&skill, 0);
3282 if (skill.integer < 0)
3283 Cvar_SetValueQuick (&skill, 3);
3287 if (gamemode == GAME_GOODVSBAD2)
3289 Cvar_SetValueQuick (&fraglimit, fraglimit.integer + dir*10);
3290 if (fraglimit.integer > 100)
3291 Cvar_SetValueQuick (&fraglimit, 0);
3292 if (fraglimit.integer < 0)
3293 Cvar_SetValueQuick (&fraglimit, 100);
3297 if (gamemode == GAME_GOODVSBAD2)
3299 Cvar_SetValueQuick (&timelimit, timelimit.value + dir*5);
3300 if (timelimit.value > 60)
3301 Cvar_SetValueQuick (&timelimit, 0);
3302 if (timelimit.value < 0)
3303 Cvar_SetValueQuick (&timelimit, 60);
3307 Cvar_SetValueQuick (&sv_public, !sv_public.integer);
3314 if (gamemode == GAME_GOODVSBAD2)
3316 startepisode += dir;
3317 g = lookupgameinfo();
3319 if (startepisode < 0)
3320 startepisode = g->numepisodes - 1;
3322 if (startepisode >= g->numepisodes)
3330 g = lookupgameinfo();
3333 startlevel = g->episodes[startepisode].levels - 1;
3335 if (startlevel >= g->episodes[startepisode].levels)
3341 void M_GameOptions_Key (int key, char ascii)
3345 char hostnamebuf[128];
3350 M_Menu_MultiPlayer_f ();
3354 S_LocalSound ("misc/menu1.wav");
3355 gameoptions_cursor--;
3356 if (gameoptions_cursor < 0)
3357 gameoptions_cursor = NUM_GAMEOPTIONS-1;
3361 S_LocalSound ("misc/menu1.wav");
3362 gameoptions_cursor++;
3363 if (gameoptions_cursor >= NUM_GAMEOPTIONS)
3364 gameoptions_cursor = 0;
3368 if (gameoptions_cursor == 0)
3370 S_LocalSound ("misc/menu3.wav");
3371 M_NetStart_Change (-1);
3375 if (gameoptions_cursor == 0)
3377 S_LocalSound ("misc/menu3.wav");
3378 M_NetStart_Change (1);
3382 S_LocalSound ("misc/menu2.wav");
3383 if (gameoptions_cursor == 0)
3386 Cbuf_AddText ("disconnect\n");
3387 Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) );
3389 g = lookupgameinfo();
3390 Cbuf_AddText ( va ("map %s\n", g->levels[g->episodes[startepisode].firstLevel + startlevel].name) );
3394 M_NetStart_Change (1);
3398 if (gameoptions_cursor == 8)
3400 l = strlen(hostname.string);
3404 memcpy(hostnamebuf, hostname.string, l);
3406 Cvar_Set("hostname", hostnamebuf);
3412 if (ascii < 32 || ascii > 126)
3414 if (gameoptions_cursor == 8)
3416 l = strlen(hostname.string);
3419 memcpy(hostnamebuf, hostname.string, l);
3420 hostnamebuf[l] = ascii;
3421 hostnamebuf[l+1] = 0;
3422 Cvar_Set("hostname", hostnamebuf);
3428 //=============================================================================
3433 void M_Menu_ServerList_f (void)
3435 key_dest = key_menu;
3437 m_entersound = true;
3439 m_return_reason[0] = 0;
3444 void M_ServerList_Draw (void)
3446 int n, y, visible, start, end;
3450 // use as much vertical space as available
3451 M_Background(640, vid.conheight);
3452 // scroll the list as the cursor moves
3453 s = va("%i/%i masters %i/%i servers", masterreplycount, masterquerycount, serverreplycount, serverquerycount);
3454 M_PrintRed((640 - strlen(s) * 8) / 2, 32, s);
3455 if (*m_return_reason)
3456 M_Print(16, vid.conheight - 8, m_return_reason);
3458 visible = (vid.conheight - 16 - y) / 8;
3459 start = bound(0, slist_cursor - (visible >> 1), hostCacheCount - visible);
3460 end = min(start + visible, hostCacheCount);
3462 p = Draw_CachePic("gfx/p_multi.lmp");
3463 M_DrawPic((640 - p->width) / 2, 4, "gfx/p_multi.lmp");
3466 for (n = start;n < end;n++)
3468 DrawQ_Fill(menu_x, menu_y + y, 640, 16, n == slist_cursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
3469 M_Print(0, y, hostcache[n].line1);y += 8;
3470 M_Print(0, y, hostcache[n].line2);y += 8;
3473 else if (realtime - masterquerytime < 3)
3475 if (masterquerycount)
3476 M_Print(0, y, "No servers found");
3478 M_Print(0, y, "No master servers found (network problem?)");
3483 void M_ServerList_Key(int k, char ascii)
3488 M_Menu_LanConfig_f();
3497 S_LocalSound("misc/menu1.wav");
3499 if (slist_cursor < 0)
3500 slist_cursor = hostCacheCount - 1;
3505 S_LocalSound("misc/menu1.wav");
3507 if (slist_cursor >= hostCacheCount)
3512 S_LocalSound("misc/menu2.wav");
3513 Cbuf_AddText(va("connect \"%s\"\n", hostcache[slist_cursor].cname));
3522 //=============================================================================
3523 /* Menu Subsystem */
3525 void M_Keydown(int key, char ascii);
3527 void M_ToggleMenu_f(void);
3528 void M_Shutdown(void);
3532 menu_mempool = Mem_AllocPool("Menu");
3533 menuplyr_load = true;
3534 menuplyr_pixels = NULL;
3536 Cmd_AddCommand ("menu_main", M_Menu_Main_f);
3537 Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f);
3538 Cmd_AddCommand ("menu_load", M_Menu_Load_f);
3539 Cmd_AddCommand ("menu_save", M_Menu_Save_f);
3540 Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
3541 Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
3542 Cmd_AddCommand ("menu_options", M_Menu_Options_f);
3543 Cmd_AddCommand ("menu_options_effects", M_Menu_Options_Effects_f);
3544 Cmd_AddCommand ("menu_options_colorcontrol", M_Menu_Options_ColorControl_f);
3545 Cvar_RegisterVariable (&menu_options_colorcontrol_correctionvalue);
3546 Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
3547 Cmd_AddCommand ("menu_video", M_Menu_Video_f);
3548 Cmd_AddCommand ("help", M_Menu_Help_f);
3549 Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
3551 if (gamemode == GAME_TRANSFUSION)
3553 numcommands = sizeof(transfusionbindnames) / sizeof(transfusionbindnames[0]);
3554 bindnames = transfusionbindnames;
3556 else if (gamemode == GAME_GOODVSBAD2)
3558 numcommands = sizeof(goodvsbad2bindnames) / sizeof(goodvsbad2bindnames[0]);
3559 bindnames = goodvsbad2bindnames;
3563 numcommands = sizeof(quakebindnames) / sizeof(quakebindnames[0]);
3564 bindnames = quakebindnames;
3567 // Make sure "keys_cursor" doesn't start on a section in the binding list
3569 while (bindnames[keys_cursor][0][0] == '\0')
3573 // Only sections? There may be a problem somewhere...
3574 if (keys_cursor >= numcommands)
3575 Sys_Error ("M_Init: The key binding list only contains sections");
3579 if (gamemode == GAME_NEHAHRA)
3581 if (FS_FileExists("maps/neh1m4.bsp"))
3583 if (FS_FileExists("hearing.dem"))
3585 Con_Print("Nehahra movie and game detected.\n");
3586 NehGameType = TYPE_BOTH;
3590 Con_Print("Nehahra game detected.\n");
3591 NehGameType = TYPE_GAME;
3596 if (FS_FileExists("hearing.dem"))
3598 Con_Print("Nehahra movie detected.\n");
3599 NehGameType = TYPE_DEMO;
3603 Con_Print("Nehahra not found.\n");
3604 NehGameType = TYPE_GAME; // could just complain, but...
3612 if (key_dest != key_menu)
3615 if (m_state == m_none)
3631 case m_singleplayer:
3632 M_SinglePlayer_Draw ();
3644 M_MultiPlayer_Draw ();
3655 case m_options_effects:
3656 M_Options_Effects_Draw ();
3659 case m_options_colorcontrol:
3660 M_Options_ColorControl_Draw ();
3680 M_LanConfig_Draw ();
3684 M_GameOptions_Draw ();
3688 M_ServerList_Draw ();
3694 S_LocalSound ("misc/menu2.wav");
3695 m_entersound = false;
3702 void M_Keydown (int key, char ascii)
3710 M_Main_Key (key, ascii);
3714 M_Demo_Key (key, ascii);
3717 case m_singleplayer:
3718 M_SinglePlayer_Key (key, ascii);
3722 M_Load_Key (key, ascii);
3726 M_Save_Key (key, ascii);
3730 M_MultiPlayer_Key (key, ascii);
3734 M_Setup_Key (key, ascii);
3738 M_Options_Key (key, ascii);
3741 case m_options_effects:
3742 M_Options_Effects_Key (key, ascii);
3745 case m_options_colorcontrol:
3746 M_Options_ColorControl_Key (key, ascii);
3750 M_Keys_Key (key, ascii);
3754 M_Video_Key (key, ascii);
3758 M_Help_Key (key, ascii);
3762 M_Quit_Key (key, ascii);
3766 M_LanConfig_Key (key, ascii);
3770 M_GameOptions_Key (key, ascii);
3774 M_ServerList_Key (key, ascii);
3779 void M_Shutdown(void)
3782 key_dest = key_game;
3785 void M_Restart(void)
3789 //============================================================================
3790 // Menu prog handling
3791 mfunction_t *PRVM_ED_FindFunction(const char *);
3793 #define M_F_INIT "m_init"
3794 #define M_F_KEYDOWN "m_keydown"
3795 #define M_F_DRAW "m_draw"
3796 #define M_F_TOGGLE "m_toggle"
3797 #define M_F_SHUTDOWN "m_shutdown"
3799 static char *m_required_func[] = {
3807 static int m_numrequiredfunc = sizeof(m_required_func) / sizeof(char*);
3809 static func_t m_draw,m_keydown;
3811 void MR_SetRouting (qboolean forceold);
3815 // fall back to the normal menu
3818 Con_Print("Falling back to normal menu\n");
3820 key_dest = key_game;
3824 // init the normal menu now -> this will also correct the menu router pointers
3825 MR_SetRouting (TRUE);
3828 void MP_Keydown (int key, char ascii)
3831 PRVM_SetProg(PRVM_MENUPROG);
3834 *prog->time = realtime;
3837 prog->globals[OFS_PARM0] = (float) key;
3838 prog->globals[OFS_PARM1] = (float) ascii;
3839 PRVM_ExecuteProgram(m_keydown, M_F_KEYDOWN"(float key, float ascii) required\n");
3847 PRVM_SetProg(PRVM_MENUPROG);
3850 *prog->time = realtime;
3852 PRVM_ExecuteProgram(m_draw,"");
3857 void MP_ToggleMenu_f (void)
3860 PRVM_SetProg(PRVM_MENUPROG);
3863 *prog->time = realtime;
3865 PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_TOGGLE) - prog->functions),"");
3870 void MP_Shutdown (void)
3873 PRVM_SetProg(PRVM_MENUPROG);
3876 *prog->time = realtime;
3878 PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_SHUTDOWN) - prog->functions),"");
3881 key_dest = key_game;
3883 // AK not using this cause Im not sure whether this is useful at all instead :
3892 PRVM_InitProg(PRVM_MENUPROG);
3894 prog->crc = M_PROGHEADER_CRC;
3895 prog->edictprivate_size = 0; // no private struct used
3896 prog->name = M_NAME;
3897 prog->limit_edicts = M_MAX_EDICTS;
3898 prog->extensionstring = vm_m_extensions;
3899 prog->builtins = vm_m_builtins;
3900 prog->numbuiltins = vm_m_numbuiltins;
3901 prog->init_cmd = VM_M_Cmd_Init;
3902 prog->reset_cmd = VM_M_Cmd_Reset;
3903 prog->error_cmd = MP_Error;
3905 // allocate the mempools
3906 prog->edicts_mempool = Mem_AllocPool(M_NAME " edicts mempool");
3907 prog->edictstring_mempool = Mem_AllocPool( M_NAME " edict string mempool");
3908 prog->progs_mempool = Mem_AllocPool(M_PROG_FILENAME);
3910 PRVM_LoadProgs(M_PROG_FILENAME, m_numrequiredfunc, m_required_func);
3912 // set m_draw and m_keydown
3913 m_draw = (func_t) (PRVM_ED_FindFunction(M_F_DRAW) - prog->functions);
3914 m_keydown = (func_t) (PRVM_ED_FindFunction(M_F_KEYDOWN) - prog->functions);
3917 *prog->time = realtime;
3919 // call the prog init
3920 PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_INIT) - prog->functions),"");
3925 void MP_Restart(void)
3931 //============================================================================
3934 static cvar_t forceqmenu = { 0, "forceqmenu", "0" };
3936 void MR_SetRouting(qboolean forceold)
3938 static qboolean m_init = FALSE, mp_init = FALSE;
3940 // if the menu prog isnt available or forceqmenu ist set, use the old menu
3941 if(!FS_FileExists(M_PROG_FILENAME) || forceqmenu.integer || forceold)
3943 // set menu router function pointers
3944 MR_Keydown = M_Keydown;
3946 MR_ToggleMenu_f = M_ToggleMenu_f;
3947 MR_Shutdown = M_Shutdown;
3960 // set menu router function pointers
3961 MR_Keydown = MP_Keydown;
3963 MR_ToggleMenu_f = MP_ToggleMenu_f;
3964 MR_Shutdown = MP_Shutdown;
3976 void MR_Restart(void)
3979 MR_SetRouting (FALSE);
3982 void Call_MR_ToggleMenu_f(void)
3990 // set router console commands
3991 Cvar_RegisterVariable (&forceqmenu);
3992 Cmd_AddCommand ("menu_restart",MR_Restart);
3993 Cmd_AddCommand ("togglemenu", Call_MR_ToggleMenu_f);
3995 // use -forceqmenu to use always the normal quake menu (it sets forceqmenu to 1)
3996 if(COM_CheckParm("-forceqmenu"))
3997 Cvar_SetValueQuick(&forceqmenu,1);
3998 // use -useqmenu for debugging proposes, cause it starts
3999 // the normal quake menu only the first time
4000 else if(COM_CheckParm("-useqmenu"))
4001 MR_SetRouting (TRUE);
4003 MR_SetRouting (FALSE);