git-svn-id: http://bladebattles.com/kurok/SVN@11 20cd92bb-ff49-0410-b73e-96a06e42c3b9
[kurok.git] / menu.c
blob30fc00dcd998a03ee5eaa9600a07ed085f70c86e
1 /*
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.
20 #include "quakedef.h"
22 #ifdef WIN32
23 #include "winquake.h"
24 #endif
26 #ifdef PSP
27 #include <pspkernel.h>
28 #include <psputility.h>
29 #include "net_dgrm.h"
31 extern cvar_t accesspoint;
32 extern cvar_t r_wateralpha;
33 extern cvar_t r_vsync;
34 extern cvar_t r_mipmaps;
35 extern cvar_t r_mipmaps_bias;
36 extern cvar_t in_freelook_analog;
37 extern cvar_t in_disable_analog;
38 extern cvar_t in_analog_strafe;
39 extern cvar_t lookspring;
41 extern cvar_t in_x_axis_adjust;
42 extern cvar_t in_y_axis_adjust;
43 extern cvar_t r_dithering;
44 extern cvar_t r_i_model_animation;
45 extern cvar_t t_i_model_transform;
46 extern cvar_t show_fps;
47 extern cvar_t sv_aim;
48 extern cvar_t noexit;
50 ////////////////////////////////////////////////////////////////////
51 // Deathmatch flags
52 ////////////////////////////////////////////////////////////////////
54 int items_respawn = 1;
55 int weapons_stay;
56 int pistols;
57 int automatics;
58 int shotguns;
59 int explosives;
60 int snipers;
61 int exit_non_fatal;
62 int infinite_ammo;
63 int all_weapons;
64 int no_reload;
65 int no_armor;
66 int no_health;
67 int armor_regen;
68 int health_regen;
69 int safe_spawn;
70 int no_bots;
72 refdef_t r_refdef;
74 #endif
76 extern qboolean bmg_type_changed;
78 void (*vid_menudrawfn)(void);
79 void (*vid_menukeyfn)(int key);
81 enum {
82 m_none,
83 m_main,
84 m_singleplayer,
85 m_load,
86 m_save,
87 m_multiplayer,
88 m_setup,
89 m_net,
90 m_options,
91 m_video,
92 m_keys,
93 m_help,
94 m_quit,
95 m_serialconfig,
96 m_modemconfig,
97 m_lanconfig,
98 m_gameoptions,
99 m_doptions,
100 m_search,
101 m_slist,
102 m_osk}
103 m_state;
105 void M_Menu_Main_f (void);
106 void M_Menu_SinglePlayer_f (void);
107 void M_Menu_Load_f (void);
108 void M_Menu_Save_f (void);
109 void M_Menu_MultiPlayer_f (void);
110 void M_Menu_Setup_f (void);
111 void M_Menu_Net_f (void);
112 void M_Menu_Options_f (void);
113 void M_Menu_Keys_f (void);
114 void M_Menu_Video_f (void);
115 void M_Menu_Help_f (void);
116 void M_Menu_Quit_f (void);
117 void M_Menu_SerialConfig_f (void);
118 void M_Menu_ModemConfig_f (void);
119 void M_Menu_LanConfig_f (void);
120 void M_Menu_GameOptions_f (void);
121 void M_Menu_DOptions_f (void);
122 void M_Menu_Search_f (void);
123 void M_Menu_ServerList_f (void);
125 void M_Main_Draw (void);
126 void M_SinglePlayer_Draw (void);
127 void M_Load_Draw (void);
128 void M_Save_Draw (void);
129 void M_MultiPlayer_Draw (void);
130 void M_Setup_Draw (void);
131 void M_Net_Draw (void);
132 void M_Options_Draw (void);
133 void M_Keys_Draw (void);
134 void M_Video_Draw (void);
135 void M_Help_Draw (void);
136 void M_Quit_Draw (void);
137 void M_SerialConfig_Draw (void);
138 void M_ModemConfig_Draw (void);
139 void M_LanConfig_Draw (void);
140 void M_GameOptions_Draw (void);
141 void M_DOptions_Draw (void);
142 void M_Search_Draw (void);
143 void M_ServerList_Draw (void);
145 void M_Main_Key (int key);
146 void M_SinglePlayer_Key (int key);
147 void M_Load_Key (int key);
148 void M_Save_Key (int key);
149 void M_MultiPlayer_Key (int key);
150 void M_Setup_Key (int key);
151 void M_Net_Key (int key);
152 void M_Options_Key (int key);
153 void M_Keys_Key (int key);
154 void M_Video_Key (int key);
155 void M_Help_Key (int key);
156 void M_Quit_Key (int key);
157 void M_SerialConfig_Key (int key);
158 void M_ModemConfig_Key (int key);
159 void M_LanConfig_Key (int key);
160 void M_GameOptions_Key (int key);
161 void M_DOptions_Key (int key);
162 void M_Search_Key (int key);
163 void M_ServerList_Key (int key);
165 void Con_SetOSKActive(qboolean active);
166 void M_Menu_OSK_f (char *input, char *output, int outlen);
169 qboolean m_entersound; // play after drawing a frame, so caching
170 // won't disrupt the sound
171 qboolean m_recursiveDraw;
173 int m_return_state;
175 //int track;
177 qboolean m_return_onerror;
178 char m_return_reason [32];
180 #define StartingGame (m_multiplayer_cursor == 1)
181 #define JoiningGame (m_multiplayer_cursor == 0)
182 #define SerialConfig (m_net_cursor == 0)
183 #define DirectConfig (m_net_cursor == 1)
184 #define IPXConfig (m_net_cursor == 2)
185 #define TCPIPConfig (m_net_cursor == 3)
187 void M_ConfigureNetSubsystem(void);
190 ================
191 M_DrawCharacter
193 Draws one solid graphics character
194 ================
196 void M_DrawCharacter (int cx, int line, int num)
198 Draw_Character ( cx + ((vid.width - 320)>>1), line, num);
201 void M_Print (int cx, int cy, char *str)
203 while (*str)
205 M_DrawCharacter (cx, cy, (*str)+128);
206 str++;
207 cx += 8;
211 void M_PrintWhite (int cx, int cy, char *str)
213 while (*str)
215 M_DrawCharacter (cx, cy, *str);
216 str++;
217 cx += 8;
221 void M_DrawTransPic (int x, int y, qpic_t *pic)
223 Draw_TransPic (x + ((vid.width - 320)>>1), y, pic);
226 void M_DrawPic (int x, int y, qpic_t *pic)
228 Draw_Pic (x + ((vid.width - 320)>>1), y, pic);
231 byte identityTable[256];
232 byte translationTable[256];
234 void M_BuildTranslationTable(int top, int bottom)
236 int j;
237 byte *dest, *source;
239 for (j = 0; j < 256; j++)
240 identityTable[j] = j;
241 dest = translationTable;
242 source = identityTable;
243 memcpy (dest, source, 256);
245 if (top < 128) // the artists made some backwards ranges. sigh.
246 memcpy (dest + TOP_RANGE, source + top, 16);
247 else
248 for (j=0 ; j<16 ; j++)
249 dest[TOP_RANGE+j] = source[top+15-j];
251 if (bottom < 128)
252 memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
253 else
254 for (j=0 ; j<16 ; j++)
255 dest[BOTTOM_RANGE+j] = source[bottom+15-j];
259 void M_DrawTransPicTranslate (int x, int y, qpic_t *pic)
261 Draw_TransPicTranslate (x + ((vid.width - 320)>>1), y, pic, translationTable);
265 void M_DrawTextBox (int x, int y, int width, int lines)
267 qpic_t *p;
268 int cx, cy;
269 int n;
271 // draw left side
272 cx = x;
273 cy = y;
274 p = Draw_CachePic ("gfx/box_tl.lmp");
275 M_DrawTransPic (cx, cy, p);
276 p = Draw_CachePic ("gfx/box_ml.lmp");
277 for (n = 0; n < lines; n++)
279 cy += 8;
280 M_DrawTransPic (cx, cy, p);
282 p = Draw_CachePic ("gfx/box_bl.lmp");
283 M_DrawTransPic (cx, cy+8, p);
285 // draw middle
286 cx += 8;
287 while (width > 0)
289 cy = y;
290 p = Draw_CachePic ("gfx/box_tm.lmp");
291 M_DrawTransPic (cx, cy, p);
292 p = Draw_CachePic ("gfx/box_mm.lmp");
293 for (n = 0; n < lines; n++)
295 cy += 8;
296 if (n == 1)
297 p = Draw_CachePic ("gfx/box_mm2.lmp");
298 M_DrawTransPic (cx, cy, p);
300 p = Draw_CachePic ("gfx/box_bm.lmp");
301 M_DrawTransPic (cx, cy+8, p);
302 width -= 2;
303 cx += 16;
306 // draw right side
307 cy = y;
308 p = Draw_CachePic ("gfx/box_tr.lmp");
309 M_DrawTransPic (cx, cy, p);
310 p = Draw_CachePic ("gfx/box_mr.lmp");
311 for (n = 0; n < lines; n++)
313 cy += 8;
314 M_DrawTransPic (cx, cy, p);
316 p = Draw_CachePic ("gfx/box_br.lmp");
317 M_DrawTransPic (cx, cy+8, p);
320 void M_DrawCheckbox (int x, int y, int on)
322 #if 0
323 if (on)
324 M_DrawCharacter (x, y, 131);
325 else
326 M_DrawCharacter (x, y, 129);
327 #endif
328 if (on)
329 M_Print (x, y, "on");
330 else
331 M_Print (x, y, "off");
334 //=============================================================================
336 int m_save_demonum;
339 ================
340 M_ToggleMenu_f
341 ================
343 void M_ToggleMenu_f (void)
345 m_entersound = true;
347 if (key_dest == key_menu)
349 if (m_state != m_main)
351 M_Menu_Main_f ();
352 return;
354 key_dest = key_game;
355 m_state = m_none;
356 return;
358 if (key_dest == key_console)
360 Con_ToggleConsole_f ();
362 else
364 M_Menu_Main_f ();
369 //=============================================================================
370 /* MAIN MENU */
372 int m_main_cursor;
373 #define MAIN_ITEMS 5
375 void M_Menu_Main_f (void)
377 if (key_dest != key_menu)
379 m_save_demonum = cls.demonum;
380 cls.demonum = -1;
382 key_dest = key_menu;
383 m_state = m_main;
384 m_entersound = true;
388 void M_Main_Draw (void)
390 int f;
391 qpic_t *p,*b, *s, *m, *o, *h, *q, *t;
393 if (kurok)
395 t = Draw_CachePic ("gfx/menu/title.lmp");
396 M_DrawPic ((320-t->width)/2, 16, t);
398 if (m_main_cursor == 0)
399 s = Draw_CachePic ("gfx/menu/single_1.lmp");
400 else
401 s = Draw_CachePic ("gfx/menu/single_0.lmp");
402 M_DrawPic ((320-s->width)/2, 160, s);
404 if (m_main_cursor == 1)
405 m = Draw_CachePic ("gfx/menu/multi_1.lmp");
406 else
407 m = Draw_CachePic ("gfx/menu/multi_0.lmp");
408 M_DrawPic ((320-m->width)/2, 176, m);
410 if (m_main_cursor == 2)
411 o = Draw_CachePic ("gfx/menu/option_1.lmp");
412 else
413 o = Draw_CachePic ("gfx/menu/option_0.lmp");
414 M_DrawPic ((320-o->width)/2, 192, o);
416 if (m_main_cursor == 3)
417 h = Draw_CachePic ("gfx/menu/help_1.lmp");
418 else
419 h = Draw_CachePic ("gfx/menu/help_0.lmp");
420 M_DrawPic ((320-h->width)/2, 208, h);
422 if (m_main_cursor == 4)
423 q = Draw_CachePic ("gfx/menu/quit_1.lmp");
424 else
425 q = Draw_CachePic ("gfx/menu/quit_0.lmp");
426 M_DrawPic ((320-q->width)/2, 224, q);
429 else
431 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
433 p = Draw_CachePic ("gfx/ttl_main.lmp");
434 M_DrawPic ( (320-p->width)/2, 4, p);
435 M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mainmenu.lmp") );
437 f = (int)(host_time * 10)%6;
438 M_DrawTransPic (54, 32 + m_main_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
441 b = Draw_CachePic ("gfx/m_bttns.lmp");
442 M_DrawPic ( (320-b->width)/2, 248, b );
444 M_Print (112, 0, va("Version %4.2f", (float) KUR_VERSION));
448 void M_Main_Key (int key)
450 switch (key)
452 case K_ESCAPE:
453 key_dest = key_game;
454 m_state = m_none;
455 cls.demonum = m_save_demonum;
456 if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
457 CL_NextDemo ();
458 break;
460 case K_DOWNARROW:
461 S_LocalSound ("misc/menu1.wav");
462 if (++m_main_cursor >= MAIN_ITEMS)
463 m_main_cursor = 0;
464 break;
466 case K_UPARROW:
467 S_LocalSound ("misc/menu1.wav");
468 if (--m_main_cursor < 0)
469 m_main_cursor = MAIN_ITEMS - 1;
470 break;
472 case K_ENTER:
473 m_entersound = true;
475 switch (m_main_cursor)
477 case 0:
478 M_Menu_SinglePlayer_f ();
479 break;
481 case 1:
482 M_Menu_MultiPlayer_f ();
483 break;
485 case 2:
486 M_Menu_Options_f ();
487 break;
489 case 3:
490 M_Menu_Help_f ();
491 break;
493 // if(!kurok)
494 // {
495 case 4:
496 M_Menu_Quit_f ();
497 break;
498 // }
503 //=============================================================================
504 /* SINGLE PLAYER MENU */
506 int m_singleplayer_cursor;
507 #define SINGLEPLAYER_ITEMS 3
510 void M_Menu_SinglePlayer_f (void)
512 key_dest = key_menu;
513 m_state = m_singleplayer;
514 m_entersound = true;
518 void M_SinglePlayer_Draw (void)
520 int f;
521 qpic_t *p,*b, *n, *l, *s, *t;
523 b = Draw_CachePic ("gfx/m_bttns.lmp");
524 M_DrawPic ( (320-b->width)/2, 248, b );
526 if (kurok)
528 t = Draw_CachePic ("gfx/menu/title.lmp");
529 M_DrawPic ((320-t->width)/2, 16, t);
531 if (m_singleplayer_cursor == 0)
532 n = Draw_CachePic ("gfx/menu/sp/new_1.lmp");
533 else
534 n = Draw_CachePic ("gfx/menu/sp/new_0.lmp");
535 M_DrawPic ((320-n->width)/2, 160, n);
537 if (m_singleplayer_cursor == 1)
538 l = Draw_CachePic ("gfx/menu/sp/load_1.lmp");
539 else
540 l = Draw_CachePic ("gfx/menu/sp/load_0.lmp");
541 M_DrawPic ((320-l->width)/2, 176, l);
543 if (m_singleplayer_cursor == 2)
544 s = Draw_CachePic ("gfx/menu/sp/save_1.lmp");
545 else
546 s = Draw_CachePic ("gfx/menu/sp/save_0.lmp");
547 M_DrawPic ((320-s->width)/2, 192, s);
549 else
551 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
552 p = Draw_CachePic ("gfx/ttl_sgl.lmp");
553 M_DrawPic ( (320-p->width)/2, 4, p);
554 M_DrawTransPic (72, 32, Draw_CachePic ("gfx/sp_menu.lmp") );
556 f = (int)(host_time * 10)%6;
558 M_DrawTransPic (54, 32 + m_singleplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
563 void M_SinglePlayer_Key (int key)
565 switch (key)
567 case K_ESCAPE:
568 M_Menu_Main_f ();
569 break;
571 case K_DOWNARROW:
572 S_LocalSound ("misc/menu1.wav");
573 if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
574 m_singleplayer_cursor = 0;
575 break;
577 case K_UPARROW:
578 S_LocalSound ("misc/menu1.wav");
579 if (--m_singleplayer_cursor < 0)
580 m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
581 break;
583 case K_ENTER:
584 m_entersound = true;
586 switch (m_singleplayer_cursor)
588 case 0:
590 if (sv.active)
591 if (!SCR_ModalMessage("Are you sure you want to\nstart a new game?\n"))
592 break;
594 key_dest = key_game;
595 if (sv.active)
596 Cbuf_AddText ("disconnect\n");
597 Cbuf_AddText ("maxplayers 1\n");
599 if(kurok)
600 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
602 // If we were in a multiplayer game, reset all the deathmatch flags to 0;
604 items_respawn = 1;
605 weapons_stay =
606 pistols =
607 automatics =
608 shotguns =
609 explosives =
610 snipers =
611 exit_non_fatal =
612 infinite_ammo =
613 all_weapons =
614 no_reload =
615 no_armor =
616 no_health =
617 armor_regen =
618 health_regen =
619 safe_spawn =
620 no_bots = 0;
622 Cbuf_AddText ("map start\n");
623 break;
625 case 1:
626 M_Menu_Load_f ();
627 break;
629 case 2:
630 M_Menu_Save_f ();
631 break;
636 //=============================================================================
637 /* LOAD/SAVE MENU */
639 int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES
641 #define MAX_SAVEGAMES 12
642 char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
643 int loadable[MAX_SAVEGAMES];
645 void M_ScanSaves (void)
647 int i, j;
648 char name[MAX_OSPATH];
649 FILE *f;
650 int version;
652 for (i=0 ; i<MAX_SAVEGAMES ; i++)
654 strcpy (m_filenames[i], "--- EMPTY SLOT ---");
655 loadable[i] = false;
656 sprintf (name, "%s/s%i.sav", com_gamedir, i);
657 f = fopen (name, "r");
658 if (!f)
659 continue;
660 fscanf (f, "%i\n", &version);
661 fscanf (f, "%79s\n", name);
662 strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
664 // change _ back to space
665 for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
666 if (m_filenames[i][j] == '_')
667 m_filenames[i][j] = ' ';
668 loadable[i] = true;
669 fclose (f);
673 void M_Menu_Load_f (void)
675 m_entersound = true;
676 m_state = m_load;
677 key_dest = key_menu;
678 M_ScanSaves ();
682 void M_Menu_Save_f (void)
684 if (!sv.active)
685 return;
686 if (cl.intermission)
687 return;
688 if (svs.maxclients != 1)
689 return;
690 m_entersound = true;
691 m_state = m_save;
692 key_dest = key_menu;
693 M_ScanSaves ();
697 void M_Load_Draw (void)
699 int i;
700 qpic_t *p, *b;
702 b = Draw_CachePic ("gfx/m_bttns.lmp");
703 M_DrawPic ( (320-b->width)/2, 248, b );
705 if (kurok)
707 p = Draw_CachePic ("gfx/menu/sp/load_0.lmp");
708 // line cursor
709 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*30)&1));
711 else
713 p = Draw_CachePic ("gfx/p_load.lmp");
714 // line cursor
715 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
717 M_DrawPic ( (320-p->width)/2, 4, p);
719 for (i=0 ; i< MAX_SAVEGAMES; i++)
720 M_Print (16, 32 + 8*i, m_filenames[i]);
726 void M_Save_Draw (void)
728 int i;
729 qpic_t *p, *b;
731 b = Draw_CachePic ("gfx/m_bttns.lmp");
732 M_DrawPic ( (320-b->width)/2, 248, b );
734 if (kurok)
736 p = Draw_CachePic ("gfx/menu/sp/save_0.lmp");
737 // line cursor
738 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*30)&1));
740 else
742 p = Draw_CachePic ("gfx/p_save.lmp");
743 // line cursor
744 M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
746 M_DrawPic ( (320-p->width)/2, 4, p);
748 for (i=0 ; i<MAX_SAVEGAMES ; i++)
749 M_Print (16, 32 + 8*i, m_filenames[i]);
753 void M_Load_Key (int k)
755 switch (k)
757 case K_ESCAPE:
758 M_Menu_SinglePlayer_f ();
759 break;
761 case K_ENTER:
762 S_LocalSound ("misc/menu2.wav");
763 if (!loadable[load_cursor])
764 return;
765 m_state = m_none;
766 key_dest = key_game;
768 // Host_Loadgame_f can't bring up the loading plaque because too much
769 // stack space has been used, so do it now
770 SCR_BeginLoadingPlaque ();
772 if(kurok)
773 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
775 // If we were in a multiplayer game, reset all the deathmatch flags to 0;
777 items_respawn = 1;
778 weapons_stay =
779 pistols =
780 automatics =
781 shotguns =
782 explosives =
783 snipers =
784 exit_non_fatal =
785 infinite_ammo =
786 all_weapons =
787 no_reload =
788 no_armor =
789 no_health =
790 armor_regen =
791 health_regen =
792 safe_spawn =
793 no_bots = 0;
795 // issue the load command
796 Cbuf_AddText (va ("load s%i\n", load_cursor) );
798 return;
800 case K_UPARROW:
801 case K_LEFTARROW:
802 S_LocalSound ("misc/menu1.wav");
803 load_cursor--;
804 if (load_cursor < 0)
805 load_cursor = MAX_SAVEGAMES-1;
806 break;
808 case K_DOWNARROW:
809 case K_RIGHTARROW:
810 S_LocalSound ("misc/menu1.wav");
811 load_cursor++;
812 if (load_cursor >= MAX_SAVEGAMES)
813 load_cursor = 0;
814 break;
819 void M_Save_Key (int k)
821 switch (k)
823 case K_ESCAPE:
824 M_Menu_SinglePlayer_f ();
825 break;
827 case K_ENTER:
828 m_state = m_none;
829 key_dest = key_game;
830 Cbuf_AddText (va("save s%i\n", load_cursor));
831 return;
833 case K_UPARROW:
834 case K_LEFTARROW:
835 S_LocalSound ("misc/menu1.wav");
836 load_cursor--;
837 if (load_cursor < 0)
838 load_cursor = MAX_SAVEGAMES-1;
839 break;
841 case K_DOWNARROW:
842 case K_RIGHTARROW:
843 S_LocalSound ("misc/menu1.wav");
844 load_cursor++;
845 if (load_cursor >= MAX_SAVEGAMES)
846 load_cursor = 0;
847 break;
851 //=============================================================================
852 /* MULTIPLAYER MENU */
854 int m_multiplayer_cursor;
856 #ifdef PSP
857 #define MULTIPLAYER_ITEMS 9
858 #else
859 #define MULTIPLAYER_ITEMS 3
860 #endif
862 void M_Menu_MultiPlayer_f (void)
864 key_dest = key_menu;
865 m_state = m_multiplayer;
866 m_entersound = true;
870 void M_MultiPlayer_Draw (void)
872 int f;
874 qpic_t *p,*b, *j, *c, *t, *i, *a;
876 b = Draw_CachePic ("gfx/m_bttns.lmp");
877 M_DrawPic ( (320-b->width)/2, 248, b );
879 if (kurok)
881 // M_DrawTransPic (72, 32, Draw_CachePic ("gfx/menu/multi_0.lmp") );
883 if (m_multiplayer_cursor == 0)
884 j = Draw_CachePic ("gfx/menu/mp/join_1.lmp");
885 else
886 j = Draw_CachePic ("gfx/menu/mp/join_0.lmp");
887 M_DrawPic ((320-j->width)/2, 72, j);
889 if (m_multiplayer_cursor == 1)
890 c = Draw_CachePic ("gfx/menu/mp/create_1.lmp");
891 else
892 c = Draw_CachePic ("gfx/menu/mp/create_0.lmp");
893 M_DrawPic ((320-c->width)/2, 88, c);
895 if (m_multiplayer_cursor == 2)
896 t = Draw_CachePic ("gfx/menu/mp/setup_1.lmp");
897 else
898 t = Draw_CachePic ("gfx/menu/mp/setup_0.lmp");
899 M_DrawPic ((320-t->width)/2, 104, t);
901 if (m_multiplayer_cursor == 3)
902 i = Draw_CachePic ("gfx/menu/mp/inf_1.lmp");
903 else
904 i = Draw_CachePic ("gfx/menu/mp/inf_0.lmp");
905 M_DrawPic ((320-i->width)/2, 128, i);
907 M_DrawCheckbox ((320/2) - ((3*8)/2), 144, tcpipAvailable && !tcpipAdhoc);
909 if (m_multiplayer_cursor == 4)
910 a = Draw_CachePic ("gfx/menu/mp/adhoc_1.lmp");
911 else
912 a = Draw_CachePic ("gfx/menu/mp/adhoc_0.lmp");
913 M_DrawPic ((320-a->width)/2, 152, a);
915 M_DrawCheckbox ((320/2) - ((3*8)/2), 168, tcpipAvailable && tcpipAdhoc);
917 if (m_multiplayer_cursor == 5)
918 M_PrintWhite ((320/2) - ((8*8)/2), 184, "Add Bot");
919 else
920 M_Print ((320/2) - ((8*8)/2), 184, "Add Bot");
922 if (m_multiplayer_cursor == 6)
923 M_PrintWhite ((320/2) - ((12*8)/2), 192, "Add Team Bot");
924 else
925 M_Print ((320/2) - ((12*8)/2), 192, "Add Team Bot");
927 if (m_multiplayer_cursor == 7)
928 M_PrintWhite ((320/2) - ((10*8)/2), 200, "Remove Bot");
929 else
930 M_Print ((320/2) - ((10*8)/2), 200, "Remove Bot");
932 if (m_multiplayer_cursor == 8)
933 M_PrintWhite ((320/2) - ((26*8)/2), 216, "Co-op Player Camera Change");
934 else
935 M_Print ((320/2) - ((26*8)/2), 216, "Co-op Player Camera Change");
937 if (serialAvailable || ipxAvailable || tcpipAvailable)
938 return;
939 M_PrintWhite ((320/2) - ((27*8)/2), 232, "No Communications Available");
941 else
943 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
945 p = Draw_CachePic ("gfx/p_multi.lmp");
946 M_DrawPic ( (320-p->width)/2, 4, p);
948 M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mp_menu.lmp") );
950 f = (int)(host_time * 10)%6;
952 M_DrawTransPic (54, 32 + m_multiplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
954 #ifdef PSP
955 M_Print (72, 97, "Infrastructure ");
956 M_DrawCheckbox (220, 97, tcpipAvailable && !tcpipAdhoc);
958 M_Print (72, 117, "Adhoc ");
959 M_DrawCheckbox (220, 117, tcpipAvailable && tcpipAdhoc);
960 #endif
962 M_Print (72, 137, "Add Bot ");
963 M_Print (72, 157, "Add Team Bot ");
964 M_Print (72, 177, "Remove Bot ");
965 M_Print (72, 197, "Co-op Player Camera Change");
967 if (serialAvailable || ipxAvailable || tcpipAvailable)
968 return;
969 M_PrintWhite ((320/2) - ((27*8)/2), 207, "No Communications Available");
975 void M_MultiPlayer_Key (int key)
977 switch (key)
979 case K_ESCAPE:
980 M_Menu_Main_f ();
981 break;
983 case K_DOWNARROW:
984 S_LocalSound ("misc/menu1.wav");
985 if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
986 m_multiplayer_cursor = 0;
987 break;
989 case K_UPARROW:
990 S_LocalSound ("misc/menu1.wav");
991 if (--m_multiplayer_cursor < 0)
992 m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
993 break;
995 case K_ENTER:
996 m_entersound = true;
997 switch (m_multiplayer_cursor)
999 case 0:
1000 if (serialAvailable || ipxAvailable || tcpipAvailable)
1001 M_Menu_LanConfig_f ();
1002 break;
1004 case 1:
1005 if (serialAvailable || ipxAvailable || tcpipAvailable)
1006 M_Menu_LanConfig_f ();
1007 else
1008 M_Menu_GameOptions_f ();
1009 break;
1011 case 2:
1012 M_Menu_Setup_f ();
1013 break;
1015 #ifdef PSP
1016 case 3:
1017 Datagram_Shutdown();
1019 tcpipAvailable = !tcpipAvailable;
1021 if(tcpipAvailable) {
1022 tcpipAdhoc = false;
1023 net_driver_to_use = 0;
1024 Datagram_Init();
1027 break;
1029 case 4:
1030 Datagram_Shutdown();
1032 tcpipAvailable = !tcpipAvailable;
1034 if(tcpipAvailable) {
1035 tcpipAdhoc = true;
1036 net_driver_to_use = 1;
1037 Datagram_Init();
1040 break;
1042 case 5: // add bot
1043 Cbuf_AddText ("impulse 101\n");
1044 break;
1046 case 6: // add team bot
1047 Cbuf_AddText ("impulse 100\n");
1048 break;
1050 case 7: // remove bot
1051 Cbuf_AddText ("impulse 102\n");
1052 break;
1054 case 8: // player camera switch
1055 if (coop.value)
1056 Cbuf_AddText ("impulse 103\n");
1057 break;
1059 #endif
1064 //=============================================================================
1065 /* SETUP MENU */
1067 #ifndef PSP
1068 int setup_cursor = 4;
1069 int setup_cursor_table[] = {40, 56, 80, 104, 140};
1070 #else
1071 int setup_cursor = 5;
1072 int setup_cursor_table[] = {40, 56, 72, 96, 120, 156};
1073 #endif
1075 char setup_hostname[16];
1076 char setup_myname[16];
1077 int setup_oldtop;
1078 int setup_oldbottom;
1079 int setup_top;
1080 int setup_bottom;
1082 #ifndef PSP
1083 #define NUM_SETUP_CMDS 5
1084 #else
1085 // Define PSP specific variables
1086 #define NUM_SETUP_CMDS 6
1087 extern int totalAccessPoints;
1088 extern int accessPointNumber[100];
1089 char setup_accesspoint[64];
1090 #endif
1092 void M_Menu_Setup_f (void)
1094 key_dest = key_menu;
1095 m_state = m_setup;
1096 m_entersound = true;
1097 Q_strcpy(setup_myname, cl_name.string);
1098 Q_strcpy(setup_hostname, hostname.string);
1099 setup_top = setup_oldtop = ((int)cl_color.value) >> 4;
1100 setup_bottom = setup_oldbottom = ((int)cl_color.value) & 15;
1102 #ifdef PSP
1103 if(totalAccessPoints)
1105 sceUtilityGetNetParam(accessPointNumber[(int)accesspoint.value], 0, (netData*)setup_accesspoint);
1107 #endif
1110 int M_ColorForMap (int m)
1112 return m < 128 ? m + 8 : m + 8;
1115 void M_Setup_Draw (void)
1117 qpic_t *p,*b;
1118 int offset = 0;
1119 int top, bottom, tc, bc;
1121 if (kurok)
1123 if (setup_cursor == 0+offset)
1124 M_DrawCharacter (168 + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*30)&1));
1126 if (setup_cursor == 1+offset)
1127 M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*30)&1));
1129 else
1131 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
1133 if (setup_cursor == 0+offset)
1134 M_DrawCharacter (168 + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
1136 if (setup_cursor == 1+offset)
1137 M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
1139 b = Draw_CachePic ("gfx/m_bttns.lmp");
1140 M_DrawPic ( (320-b->width)/2, 248, b );
1141 p = Draw_CachePic ("gfx/p_multi.lmp");
1142 M_DrawPic ( (320-p->width)/2, 4, p);
1144 #ifdef PSP
1145 offset = 16;
1147 M_Print (64, 40, "Access Point");
1148 M_DrawTextBox (160, 32, 16, 1);
1149 M_Print (168, 40, setup_accesspoint);
1150 #endif
1152 M_Print (64, 40+offset, "Host name");
1153 M_DrawTextBox (160, 32+offset, 16, 1);
1154 M_Print (168, 56, setup_hostname);
1156 M_Print (64, 56+offset, "Player name");
1157 M_DrawTextBox (160, 48+offset, 16, 1);
1158 M_Print (168, 56+offset, setup_myname);
1160 if(!kurok)
1162 M_Print (64, 80+offset, "Top color");
1163 M_Print (64, 104+offset, "Bottom color");
1165 else
1167 M_Print (64, 80+offset, "Top color");
1168 M_Print (64, 104+offset, "Team color");
1171 M_DrawTextBox (64, 140+offset-8, 14, 1);
1172 M_Print (72, 140+offset, "Accept Changes");
1174 p = Draw_CachePic ("gfx/bigbox.lmp");
1175 M_DrawTransPic (160, 64+offset, p);
1177 tc = (setup_top & 15)<<4;
1178 bc = (setup_bottom & 15)<<4;
1179 top = M_ColorForMap (tc);
1180 bottom = M_ColorForMap (bc);
1182 Draw_Fill ( 248, 72+offset, 56, 28, top);
1183 Draw_Fill ( 248, 72+28+offset, 56, 28, bottom);
1185 if(!kurok)
1187 p = Draw_CachePic ("gfx/menuplyr.lmp");
1188 // M_BuildTranslationTable(setup_top*16, setup_bottom*16);
1189 // M_DrawTransPicTranslate (172, 72+offset, p);
1190 M_DrawTransPic (172, 72+offset, p);
1193 M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
1195 #ifndef PSP
1196 offset = 0;
1197 #else
1198 offset = 1;
1199 #endif
1203 void M_Setup_Key (int k)
1205 int l;
1206 int offset = 0;
1208 switch (k)
1210 case K_ESCAPE:
1211 M_Menu_MultiPlayer_f ();
1212 break;
1214 case K_UPARROW:
1215 S_LocalSound ("misc/menu1.wav");
1216 setup_cursor--;
1217 if (setup_cursor < 0)
1218 setup_cursor = NUM_SETUP_CMDS-1;
1219 break;
1221 case K_DOWNARROW:
1222 S_LocalSound ("misc/menu1.wav");
1223 setup_cursor++;
1224 if (setup_cursor >= NUM_SETUP_CMDS)
1225 setup_cursor = 0;
1226 break;
1228 case K_LEFTARROW:
1229 #ifdef PSP
1230 if (setup_cursor == 0)
1232 S_LocalSound ("misc/menu3.wav");
1233 if(accesspoint.value > 1)
1235 Cvar_SetValue("accesspoint", accesspoint.value-1);
1236 sceUtilityGetNetParam(accessPointNumber[(int)accesspoint.value], 0, (netData*)setup_accesspoint);
1239 offset = 1;
1240 #endif
1241 if (setup_cursor < 2+offset)
1242 return;
1243 S_LocalSound ("misc/menu3.wav");
1244 if (setup_cursor == 2+offset)
1245 setup_top = setup_top - 1;
1246 if (setup_cursor == 3+offset)
1248 if(!kurok)
1249 setup_bottom = setup_bottom - 1;
1250 else
1251 setup_bottom = 4;
1254 break;
1255 case K_RIGHTARROW:
1256 #ifdef PSP
1257 if (setup_cursor == 0)
1259 S_LocalSound ("misc/menu3.wav");
1260 if(accesspoint.value < totalAccessPoints)
1262 Cvar_SetValue("accesspoint", accesspoint.value+1);
1263 sceUtilityGetNetParam(accessPointNumber[(int)accesspoint.value], 0, (netData*)setup_accesspoint);
1267 offset = 1;
1268 #endif
1270 if (setup_cursor < 2+offset)
1271 return;
1272 forward:
1273 S_LocalSound ("misc/menu3.wav");
1274 if (setup_cursor == 2+offset)
1275 setup_top = setup_top + 1;
1276 if (setup_cursor == 3+offset)
1278 if(!kurok)
1279 setup_bottom = setup_bottom + 1;
1280 else
1281 setup_bottom = 13;
1284 break;
1286 case K_INS:
1287 #ifdef PSP
1288 offset = 1;
1289 #endif
1290 if (setup_cursor == 0+offset)
1292 M_Menu_OSK_f(setup_hostname, setup_hostname, 16);
1293 break;
1296 if (setup_cursor == 1+offset)
1298 M_Menu_OSK_f(setup_myname, setup_myname,16);
1299 break;
1301 break;
1303 case K_ENTER:
1304 #ifdef PSP
1305 offset = 1;
1306 #endif
1307 if (setup_cursor == 0+offset || setup_cursor == 1+offset)
1308 return;
1310 if (setup_cursor == 2+offset || setup_cursor == 3+offset)
1311 goto forward;
1313 if (setup_cursor < 4+offset)
1314 break;
1316 // setup_cursor == 4 (OK)
1317 if (Q_strcmp(cl_name.string, setup_myname) != 0)
1318 Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
1319 if (Q_strcmp(hostname.string, setup_hostname) != 0)
1320 Cvar_Set("hostname", setup_hostname);
1321 if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
1322 Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
1323 m_entersound = true;
1324 M_Menu_MultiPlayer_f ();
1325 break;
1327 case K_BACKSPACE:
1328 #ifdef PSP
1329 offset = 1;
1330 #endif
1331 if (setup_cursor == 0+offset)
1333 if (strlen(setup_hostname))
1334 setup_hostname[strlen(setup_hostname)-1] = 0;
1337 if (setup_cursor == 1+offset)
1339 if (strlen(setup_myname))
1340 setup_myname[strlen(setup_myname)-1] = 0;
1342 break;
1344 default:
1345 if (k < 32 || k > 127)
1346 break;
1348 #ifdef PSP
1349 offset = 1;
1350 #endif
1352 if (setup_cursor == 0+offset)
1354 l = strlen(setup_hostname);
1355 if (l < 15)
1357 setup_hostname[l+1] = 0;
1358 setup_hostname[l] = k;
1361 if (setup_cursor == 1+offset)
1363 l = strlen(setup_myname);
1364 if (l < 15)
1366 setup_myname[l+1] = 0;
1367 setup_myname[l] = k;
1372 if (setup_top > 13)
1373 setup_top = 0;
1374 if (setup_top < 0)
1375 setup_top = 13;
1376 if (setup_bottom > 13)
1377 setup_bottom = 0;
1378 if (setup_bottom < 0)
1379 setup_bottom = 13;
1382 //=============================================================================
1383 /* NET MENU */
1385 int m_net_cursor;
1386 int m_net_items;
1387 int m_net_saveHeight;
1389 char *net_helpMessage [] =
1391 /* .........1.........2.... */
1392 " ",
1393 " Two computers connected",
1394 " through two modems. ",
1395 " ",
1397 " ",
1398 " Two computers connected",
1399 " by a null-modem cable. ",
1400 " ",
1402 " Novell network LANs ",
1403 " or Windows 95 DOS-box. ",
1404 " ",
1405 "(LAN=Local Area Network)",
1407 " Commonly used to play ",
1408 " over the Internet, but ",
1409 " also used on a Local ",
1410 " Area Network. "
1413 void M_Menu_Net_f (void)
1415 key_dest = key_menu;
1416 m_state = m_net;
1417 m_entersound = true;
1418 m_net_items = 4;
1420 if (m_net_cursor >= m_net_items)
1421 m_net_cursor = 0;
1422 m_net_cursor--;
1423 M_Net_Key (K_DOWNARROW);
1427 void M_Net_Draw (void)
1429 int f;
1430 qpic_t *p,*b;
1432 if (!kurok)
1434 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
1436 b = Draw_CachePic ("gfx/m_bttns.lmp");
1437 M_DrawPic ( (320-b->width)/2, 248, b );
1438 p = Draw_CachePic ("gfx/p_multi.lmp");
1439 M_DrawPic ( (320-p->width)/2, 4, p);
1441 f = 32;
1443 if (serialAvailable)
1445 p = Draw_CachePic ("gfx/netmen1.lmp");
1447 else
1449 #ifdef WIN32
1450 p = NULL;
1451 #else
1452 p = Draw_CachePic ("gfx/dim_modm.lmp");
1453 #endif
1456 if (p)
1457 M_DrawTransPic (72, f, p);
1459 f += 19;
1461 if (serialAvailable)
1463 p = Draw_CachePic ("gfx/netmen2.lmp");
1465 else
1467 #ifdef WIN32
1468 p = NULL;
1469 #else
1470 p = Draw_CachePic ("gfx/dim_drct.lmp");
1471 #endif
1474 if (p)
1475 M_DrawTransPic (72, f, p);
1477 f += 19;
1478 if (ipxAvailable)
1479 p = Draw_CachePic ("gfx/netmen3.lmp");
1480 else
1481 p = Draw_CachePic ("gfx/dim_ipx.lmp");
1482 M_DrawTransPic (72, f, p);
1484 f += 19;
1485 if (tcpipAvailable)
1486 p = Draw_CachePic ("gfx/netmen4.lmp");
1487 else
1488 p = Draw_CachePic ("gfx/dim_tcp.lmp");
1489 M_DrawTransPic (72, f, p);
1491 if (m_net_items == 5) // JDC, could just be removed
1493 f += 19;
1494 p = Draw_CachePic ("gfx/netmen5.lmp");
1495 M_DrawTransPic (72, f, p);
1498 f = (320-26*8)/2;
1499 M_DrawTextBox (f, 134, 24, 4);
1500 f += 8;
1501 M_Print (f, 142, net_helpMessage[m_net_cursor*4+0]);
1502 M_Print (f, 150, net_helpMessage[m_net_cursor*4+1]);
1503 M_Print (f, 158, net_helpMessage[m_net_cursor*4+2]);
1504 M_Print (f, 166, net_helpMessage[m_net_cursor*4+3]);
1506 f = (int)(host_time * 10)%6;
1507 M_DrawTransPic (54, 32 + m_net_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
1511 void M_Net_Key (int k)
1513 again:
1514 switch (k)
1516 case K_ESCAPE:
1517 M_Menu_MultiPlayer_f ();
1518 break;
1520 case K_DOWNARROW:
1521 S_LocalSound ("misc/menu1.wav");
1522 if (++m_net_cursor >= m_net_items)
1523 m_net_cursor = 0;
1524 break;
1526 case K_UPARROW:
1527 S_LocalSound ("misc/menu1.wav");
1528 if (--m_net_cursor < 0)
1529 m_net_cursor = m_net_items - 1;
1530 break;
1532 case K_ENTER:
1533 m_entersound = true;
1535 switch (m_net_cursor)
1537 case 0:
1538 M_Menu_SerialConfig_f ();
1539 break;
1541 case 1:
1542 M_Menu_SerialConfig_f ();
1543 break;
1545 case 2:
1546 M_Menu_LanConfig_f ();
1547 break;
1549 case 3:
1550 M_Menu_LanConfig_f ();
1551 break;
1553 case 4:
1554 // multiprotocol
1555 break;
1559 if (m_net_cursor == 0 && !serialAvailable)
1560 goto again;
1561 if (m_net_cursor == 1 && !serialAvailable)
1562 goto again;
1563 if (m_net_cursor == 2 && !ipxAvailable)
1564 goto again;
1565 if (m_net_cursor == 3 && !tcpipAvailable)
1566 goto again;
1569 //=============================================================================
1570 /* OPTIONS MENU */
1571 #define SLIDER_RANGE 10
1572 #define NUM_SUBMENU 4
1573 #define KNUM_SUBMENU 4
1574 #ifdef PSP_HARDWARE_VIDEO
1575 enum
1577 OPT_CUSTOMIZE = 0,
1578 OPT_CONSOLE,
1579 OPT_GAP,
1580 OPT_DEFAULTS1,
1581 // OPT_DEFAULTS2,
1582 // OPT_DEFAULTS3,
1583 OPT_GAP1,
1584 OPT_SUBMENU,
1585 OPTIONS_ITEMS
1587 enum
1589 OPT_SUBMENU_0 = OPT_SUBMENU,
1590 OPT_GAP_0,
1591 OPT_MOUSELOOK,
1592 OPT_MOUSESTRAFE,
1593 OPT_AUTOCENTER,
1594 OPT_GAP_0_1,
1595 OPT_IN_SPEED,
1596 OPT_IN_X_ADJUST,
1597 OPT_IN_Y_ADJUST,
1598 OPT_IN_TOLERANCE,
1599 OPT_IN_ACCELERATION,
1600 OPT_GAP_0_2,
1601 OPT_ALWAYRUN,
1602 OPT_INVMOUSE,
1603 OPT_NOMOUSE,
1604 OPTIONS_ITEMS_0
1606 enum
1608 OPT_SUBMENU_1 = OPT_SUBMENU,
1609 OPT_GAP_1,
1610 OPT_GAMMA,
1611 OPT_MAXFPS,
1612 OPT_GAP_1_1,
1613 OPT_DYNAMIC,
1614 OPT_MODEL_BRIGHTNESS,
1615 OPT_SIMPLE_PART,
1616 OPT_MIPMAPS,
1617 OPT_ANTIALIAS,
1618 OPT_VSYNC,
1619 OPT_FPS,
1620 OPTIONS_ITEMS_1
1623 enum
1625 OPT_SUBMENU_2 = OPT_SUBMENU,
1626 OPT_GAP_2,
1627 // OPT_MUSICTRACK,
1628 OPT_MUSICVOL,
1629 OPT_SNDVOL,
1630 OPT_GAP_2_1,
1631 // OPT_MUSICTYPE,
1632 OPTIONS_ITEMS_2
1635 enum
1637 OPT_SUBMENU_3 = OPT_SUBMENU,
1638 OPT_GAP_3,
1639 OPT_FOG_START,
1640 OPT_FOG_END,
1641 OPT_FOG_RED,
1642 OPT_FOG_GREEN,
1643 OPT_FOG_BLUE,
1644 OPT_GAP_3_1,
1645 OPT_SCRSIZE,
1646 OPT_WATERTRANS,
1647 OPT_MIPMAP_BIAS,
1648 OPT_TEX_SCALEDOWN,
1649 OPT_SMOOTH_ANIMS,
1650 OPT_SMOOTH_MOVEMENT,
1651 OPTIONS_ITEMS_3
1654 #else
1655 enum
1657 OPT_CUSTOMIZE = 0,
1658 OPT_CONSOLE,
1659 OPT_DEFAULTS,
1660 OPT_SUBMENU,
1661 OPTIONS_ITEMS
1663 enum
1665 OPT_SUBMENU_0 = OPT_SUBMENU,
1666 //OPT_GAP_0,
1667 OPT_SCRSIZE,
1668 OPT_GAMMA,
1669 OPT_VSYNC,
1670 //OPT_GAP_0_1,
1671 OPT_MUSICTYPE,
1672 OPT_MUSICVOL,
1673 OPT_SNDVOL,
1674 OPTIONS_ITEMS_0
1676 enum
1678 OPT_SUBMENU_1 = OPT_SUBMENU,
1679 //OPT_GAP_1,
1680 OPT_ALWAYRUN,
1681 OPT_IN_SPEED,
1682 OPT_IN_TOLERANCE,
1683 OPT_IN_ACCELERATION,
1684 OPT_INVMOUSE,
1685 OPT_NOMOUSE,
1686 OPT_MOUSELOOK,
1687 OPT_MOUSESTAFE,
1688 OPT_IN_X_ADJUST,
1689 OPT_IN_Y_ADJUST,
1690 OPTIONS_ITEMS_1
1692 #endif
1694 int options_cursor;
1695 int m_submenu = 0;
1697 void M_Menu_Options_f (void)
1699 key_dest = key_menu;
1700 m_state = m_options;
1701 m_entersound = true;
1704 #ifdef PSP_HARDWARE_VIDEO
1705 extern int changeMp3Volume;
1706 #endif
1708 void M_AdjustSliders (int dir)
1710 S_LocalSound ("misc/menu3.wav");
1712 switch (options_cursor)
1714 case OPT_SUBMENU:
1715 m_submenu += dir;
1716 if (kurok)
1718 if (m_submenu > KNUM_SUBMENU-1)
1719 m_submenu = 0;
1720 else if (m_submenu < 0)
1721 m_submenu = KNUM_SUBMENU-1;
1722 break;
1724 else
1726 if (m_submenu > NUM_SUBMENU-1)
1727 m_submenu = 0;
1728 else if (m_submenu < 0)
1729 m_submenu = NUM_SUBMENU-1;
1730 break;
1734 if (m_submenu == 0)
1736 switch (options_cursor)
1738 case OPT_IN_SPEED: // mouse speed
1739 in_sensitivity.value += dir * 1;
1740 if (in_sensitivity.value < 1)
1741 in_sensitivity.value = 1;
1742 if (in_sensitivity.value > 33)
1743 in_sensitivity.value = 33;
1744 Cvar_SetValue ("sensitivity", in_sensitivity.value);
1745 break;
1747 case OPT_IN_TOLERANCE: // mouse tolerance
1748 in_tolerance.value += dir * 0.01;
1749 if (in_tolerance.value < 0)
1750 in_tolerance.value = 0;
1751 if (in_tolerance.value > 0.5)
1752 in_tolerance.value = 0.5;
1753 Cvar_SetValue ("tolerance", in_tolerance.value);
1754 break;
1756 case OPT_IN_ACCELERATION: // mouse tolerance
1757 in_acceleration.value -= dir * 0.25;
1758 if (in_acceleration.value < 0.5)
1759 in_acceleration.value = 0.5;
1760 if (in_acceleration.value > 2)
1761 in_acceleration.value = 2;
1762 Cvar_SetValue ("acceleration", in_acceleration.value);
1763 break;
1765 case OPT_IN_X_ADJUST:
1766 in_x_axis_adjust.value += dir * 1;
1767 if (in_x_axis_adjust.value < 1)
1768 in_x_axis_adjust.value = 1;
1769 if (in_x_axis_adjust.value > 11)
1770 in_x_axis_adjust.value = 11;
1771 Cvar_SetValue ("in_x_axis_adjust", in_x_axis_adjust.value);
1772 break;
1774 case OPT_IN_Y_ADJUST:
1775 in_y_axis_adjust.value += dir * 1;
1776 if (in_y_axis_adjust.value < 1)
1777 in_y_axis_adjust.value = 1;
1778 if (in_y_axis_adjust.value > 11)
1779 in_y_axis_adjust.value = 11;
1780 Cvar_SetValue ("in_y_axis_adjust", in_y_axis_adjust.value);
1781 break;
1783 case OPT_INVMOUSE: // invert mouse
1784 Cvar_SetValue ("m_pitch", -m_pitch.value);
1785 break;
1787 case OPT_NOMOUSE: // disable mouse
1788 Cvar_SetValue ("in_disable_analog", !in_disable_analog.value);
1789 break;
1791 case OPT_AUTOCENTER: // auto center looking for digital keys
1792 Cvar_SetValue ("lookcenter", !lookcenter.value);
1793 break;
1795 case OPT_MOUSESTRAFE:
1796 Cvar_SetValue ("in_analog_strafe", !in_analog_strafe.value);
1797 break;
1799 case OPT_MOUSELOOK:
1800 Cvar_SetValue ("in_freelook_analog", !in_freelook_analog.value);
1801 break;
1803 case OPT_ALWAYRUN: // allways run
1804 if (kurok)
1806 if (cl_forwardspeed.value > 150)
1808 Cvar_SetValue ("cl_forwardspeed", 150);
1809 Cvar_SetValue ("cl_backspeed", 150);
1811 else
1813 Cvar_SetValue ("cl_forwardspeed", 200);
1814 Cvar_SetValue ("cl_backspeed", 200);
1817 else
1819 if (cl_forwardspeed.value > 200)
1821 Cvar_SetValue ("cl_forwardspeed", 200);
1822 Cvar_SetValue ("cl_backspeed", 200);
1824 else
1826 Cvar_SetValue ("cl_forwardspeed", 400);
1827 Cvar_SetValue ("cl_backspeed", 400);
1830 break;
1833 else if (m_submenu == 1)
1835 switch (options_cursor)
1837 case OPT_GAMMA: // gamma
1838 v_gamma.value -= dir * 0.05;
1839 if (v_gamma.value < 0.5)
1840 v_gamma.value = 0.5;
1841 if (v_gamma.value > 1)
1842 v_gamma.value = 1;
1843 Cvar_SetValue ("gamma", v_gamma.value);
1844 break;
1846 case OPT_MAXFPS: // frame rate controller
1847 max_fps.value += dir * 5;
1848 if (max_fps.value < 30)
1849 max_fps.value = 30;
1850 if (max_fps.value > 65)
1851 max_fps.value = 65;
1852 Cvar_SetValue ("max_fps", max_fps.value);
1853 break;
1855 case OPT_VSYNC:
1856 Cvar_SetValue ("r_vsync", !r_vsync.value);
1857 break;
1859 case OPT_MODEL_BRIGHTNESS:
1860 Cvar_SetValue ("r_model_brightness", !r_model_brightness.value);
1861 break;
1863 case OPT_FPS:
1864 Cvar_SetValue ("show_fps", !show_fps.value);
1865 break;
1867 case OPT_DYNAMIC:
1868 Cvar_SetValue ("r_dynamic", !r_dynamic.value);
1869 break;
1870 #ifdef PSP_HARDWARE_VIDEO
1871 case OPT_SIMPLE_PART:
1872 Cvar_SetValue ("r_particles_simple", !r_particles_simple.value);
1873 break;
1875 case OPT_ANTIALIAS:
1876 Cvar_SetValue ("r_antialias", !r_antialias.value);
1877 break;
1879 case OPT_MIPMAPS:
1880 Cvar_SetValue ("r_mipmaps", !r_mipmaps.value);
1881 break;
1882 #endif
1885 else if (m_submenu == 2)
1887 switch (options_cursor)
1890 case OPT_MUSICTRACK:
1891 track += dir * 1;
1892 if (track < 1)
1893 track = 1;
1894 if (track > 13)
1895 track = 13;
1896 Cvar_SetValue ("cd play", track);
1897 break;
1899 case OPT_MUSICVOL: // music volume
1900 #ifdef WIN32
1901 bgmvolume.value += dir * 1.0;
1902 #else
1903 bgmvolume.value += dir * 0.1;
1904 #endif
1905 if (bgmvolume.value < 0)
1906 bgmvolume.value = 0;
1907 if (bgmvolume.value > 1)
1908 bgmvolume.value = 1;
1909 Cvar_SetValue ("bgmvolume", bgmvolume.value);
1910 #ifdef PSP_MP3HARDWARE_MP3LIB
1911 changeMp3Volume = 1;
1912 #endif
1913 break;
1915 case OPT_SNDVOL: // sfx volume
1916 volume.value += dir * 0.1;
1917 if (volume.value < 0)
1918 volume.value = 0;
1919 if (volume.value > 1)
1920 volume.value = 1;
1921 Cvar_SetValue ("volume", volume.value);
1922 break;
1924 case OPT_MUSICTYPE: // bgm type
1925 if (strcmpi(bgmtype.string,"cd") == 0)
1927 Cvar_Set("bgmtype","none");
1928 bmg_type_changed = true;
1930 else
1932 Cvar_Set("bgmtype","cd");
1933 bmg_type_changed = true;
1935 break;
1939 else if (m_submenu == 3)
1941 switch (options_cursor)
1943 case OPT_FOG_START: // Fog start distance from viewpoint
1944 r_refdef.fog_start += dir * 100;
1945 if (r_refdef.fog_start < -5000)
1946 r_refdef.fog_start = -5000;
1947 if (r_refdef.fog_start > 5000)
1948 r_refdef.fog_start = 5000;
1949 break;
1951 case OPT_FOG_END: // Fog end distance from viewpoint
1952 r_refdef.fog_end += dir * 100;
1953 if (r_refdef.fog_end < -5000)
1954 r_refdef.fog_end = -5000;
1955 if (r_refdef.fog_end > 5000)
1956 r_refdef.fog_end = 5000;
1957 break;
1959 case OPT_FOG_RED: // Fog red
1960 r_refdef.fog_red += dir * 5;
1961 if (r_refdef.fog_red < 0)
1962 r_refdef.fog_red = 0;
1963 if (r_refdef.fog_red > 100)
1964 r_refdef.fog_red = 100;
1965 break;
1967 case OPT_FOG_GREEN: // Fog green
1968 r_refdef.fog_green += dir * 5;
1969 if (r_refdef.fog_green < 0)
1970 r_refdef.fog_green = 0;
1971 if (r_refdef.fog_green > 100)
1972 r_refdef.fog_green = 100;
1973 break;
1975 case OPT_FOG_BLUE: // Fog blue
1976 r_refdef.fog_blue += dir * 5;
1977 if (r_refdef.fog_blue < 0)
1978 r_refdef.fog_blue = 0;
1979 if (r_refdef.fog_blue > 100)
1980 r_refdef.fog_blue = 100;
1981 break;
1983 case OPT_SCRSIZE: // screen size
1984 scr_viewsize.value += dir * 10;
1985 if (scr_viewsize.value < 30)
1986 scr_viewsize.value = 30;
1987 if (scr_viewsize.value > 130)
1988 scr_viewsize.value = 130;
1989 Cvar_SetValue ("viewsize", scr_viewsize.value);
1990 break;
1992 case OPT_WATERTRANS: // wateralpha
1993 r_wateralpha.value += dir * 0.1;
1994 if (r_wateralpha.value < 0)
1995 r_wateralpha.value = 0;
1996 if (r_wateralpha.value > 1)
1997 r_wateralpha.value = 1;
1999 Cvar_SetValue ("r_wateralpha", r_wateralpha.value);
2000 break;
2002 case OPT_MIPMAP_BIAS: // mipmapping bais
2003 r_mipmaps_bias.value += dir * 0.5;
2004 if (r_mipmaps_bias.value < -10)
2005 r_mipmaps_bias.value = -10;
2006 if (r_mipmaps_bias.value > 0)
2007 r_mipmaps_bias.value = 0;
2009 Cvar_SetValue ("r_mipmaps_bias", r_mipmaps_bias.value);
2010 break;
2012 case OPT_TEX_SCALEDOWN:
2013 Cvar_SetValue ("r_tex_scale_down", !r_tex_scale_down.value);
2014 break;
2016 case OPT_SMOOTH_ANIMS:
2017 Cvar_SetValue ("r_i_model_animation", !r_i_model_animation.value);
2018 break;
2020 case OPT_SMOOTH_MOVEMENT:
2021 Cvar_SetValue ("r_i_model_transform", !r_i_model_transform.value);
2022 break;
2028 void M_DrawSlider (int x, int y, float range)
2030 int i;
2032 if (range < 0)
2033 range = 0;
2034 if (range > 1)
2035 range = 1;
2036 M_DrawCharacter (x-8, y, 128);
2037 for (i=0 ; i<SLIDER_RANGE ; i++)
2038 M_DrawCharacter (x + i*8, y, 129);
2039 M_DrawCharacter (x+i*8, y, 130);
2040 M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
2043 void M_Options_Draw (void)
2045 float r;
2046 qpic_t *p,*b;
2047 int offset = 32;
2049 if (kurok)
2051 offset = 64;
2052 p = Draw_CachePic ("gfx/menu/option_0.lmp");
2053 M_DrawPic ( (320-p->width)/2, 36, p);
2055 // Cursor
2056 M_DrawCharacter (200, offset + options_cursor*8, 12+((int)(realtime*30)&1));
2058 else
2060 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
2061 p = Draw_CachePic ("gfx/p_option.lmp");
2062 M_DrawPic ( (320-p->width)/2, 4, p);
2064 // Cursor
2065 M_DrawCharacter (200, offset + options_cursor*8, 12+((int)(realtime*4)&1));
2068 b = Draw_CachePic ("gfx/m_bttns.lmp");
2069 M_DrawPic ( (320-b->width)/2, 248, b );
2071 M_Print (16, offset+(OPT_CUSTOMIZE*8), " Customize Buttons");
2072 M_Print (16, offset+(OPT_CONSOLE*8), " Go to console");
2074 M_Print (16, offset+(OPT_DEFAULTS1*8), " Load defaults");
2075 // M_Print (16, offset+(OPT_DEFAULTS2*8), " 'Golden' defaults");
2076 // M_Print (16, offset+(OPT_DEFAULTS3*8), " 'Digital' defaults");
2078 switch (m_submenu)
2080 case 0:
2082 #ifdef PSP
2083 M_Print (16, offset+(OPT_IN_SPEED*8), " Analog Speed");
2084 #else
2085 M_Print (16, offset+(OPT_IN_SPEED*8), " Mouse Speed");
2086 #endif
2087 r = (in_sensitivity.value - 1)/33;
2088 M_DrawSlider (220, offset+(OPT_IN_SPEED*8), r);
2090 M_Print (16, offset+(OPT_IN_ACCELERATION*8), " Analog Acceleration");
2091 r = 1.0f -((in_acceleration.value - 0.5f)/1.5f);
2092 M_DrawSlider (220, offset+(OPT_IN_ACCELERATION*8), r);
2094 M_Print (16, offset+(OPT_IN_TOLERANCE*8), " Analog Tolerance");
2095 r = (in_tolerance.value )/1.0f;
2096 M_DrawSlider (220, offset+(OPT_IN_TOLERANCE*8), r);
2098 M_Print (16, offset+(OPT_IN_X_ADJUST*8), " Analog Speed X Axis");
2099 r = (in_x_axis_adjust.value - 1)/10;
2100 M_DrawSlider (220, offset+(OPT_IN_X_ADJUST*8), r);
2102 M_Print (16, offset+(OPT_IN_Y_ADJUST*8), " Analog Speed Y Axis");
2103 r = (in_y_axis_adjust.value - 1)/10;
2104 M_DrawSlider (220, offset+(OPT_IN_Y_ADJUST*8), r);
2106 #ifdef PSP
2107 M_Print (16, offset+(OPT_INVMOUSE*8), " Invert Analog");
2108 #else
2109 M_Print (16, offset+(OPT_INVMOUSE*8), " Invert Mouse");
2110 #endif
2111 M_DrawCheckbox (220, offset+(OPT_INVMOUSE*8), m_pitch.value < 0);
2113 M_Print (16, offset+(OPT_MOUSELOOK*8), " Analog Mode");
2114 if (in_freelook_analog.value == 1)
2115 M_Print (220, offset+(OPT_MOUSELOOK*8), "Look");
2116 else
2117 M_Print (220, offset+(OPT_MOUSELOOK*8), "Move");
2119 M_Print (16, offset+(OPT_NOMOUSE*8), " Disable Analog");
2120 M_DrawCheckbox (220, offset+(OPT_NOMOUSE*8), in_disable_analog.value );
2122 M_Print (16, offset+(OPT_AUTOCENTER*8), "Autocenter Button Look");
2123 M_DrawCheckbox (220, offset+(OPT_AUTOCENTER*8), !lookcenter.value );
2125 M_Print (16, offset+(OPT_MOUSESTRAFE*8), " Analog Strafing");
2126 M_DrawCheckbox (220, offset+(OPT_MOUSESTRAFE*8), in_analog_strafe.value );
2128 M_Print (16, offset+(OPT_ALWAYRUN*8), " Always Run");
2129 if (kurok)
2130 M_DrawCheckbox (220, offset+(OPT_ALWAYRUN*8), cl_forwardspeed.value > 150);
2131 else
2132 M_DrawCheckbox (220, offset+(OPT_ALWAYRUN*8), cl_forwardspeed.value > 200);
2134 break;
2136 case 1:
2138 M_Print (16, offset+(OPT_GAMMA*8), " Brightness");
2139 r = (1.0 - v_gamma.value) / 0.5;
2140 M_DrawSlider (220, offset+(OPT_GAMMA*8), r);
2142 M_Print (16, offset+(OPT_VSYNC*8), " VSync");
2143 M_DrawCheckbox (220, offset+(OPT_VSYNC*8), r_vsync.value);
2145 M_Print (16, offset+(OPT_DYNAMIC*8), " Dynamic Lighting");
2146 M_DrawCheckbox (220, offset+(OPT_DYNAMIC*8), r_dynamic.value);
2148 M_Print (16, offset+(OPT_MODEL_BRIGHTNESS*8), " Brighter Models");
2149 M_DrawCheckbox (220, offset+(OPT_MODEL_BRIGHTNESS*8), r_model_brightness.value);
2151 M_Print (16, offset+(OPT_MAXFPS*8), " Maximum Frame Rate");
2152 r = (max_fps.value - 30) / (65 - 30);
2153 M_DrawSlider (220, offset+(OPT_MAXFPS*8), r);
2155 M_Print (16, offset+(OPT_FPS*8), " Display Frame rate");
2156 M_DrawCheckbox (220, offset+(OPT_FPS*8), show_fps.value);
2158 #ifdef PSP_HARDWARE_VIDEO
2160 M_Print (16, offset+(OPT_SIMPLE_PART*8), " Simple Particles");
2161 M_DrawCheckbox (220, offset+(OPT_SIMPLE_PART*8), r_particles_simple.value);
2163 M_Print (16, offset+(OPT_ANTIALIAS*8), " Anti-Aliasing");
2164 M_DrawCheckbox (220, offset+(OPT_ANTIALIAS*8), r_antialias.value);
2166 M_Print (16, offset+(OPT_MIPMAPS*8), " MipMapping");
2167 M_DrawCheckbox (220, offset+(OPT_MIPMAPS*8), r_mipmaps.value);
2168 #endif
2170 break;
2172 case 2:
2174 M_Print (16, offset+(OPT_MUSICTRACK*8), " Music Track");
2175 r = (track - 1)/13;
2176 M_DrawSlider (220, offset+(OPT_MUSICTRACK*8), r);
2179 M_Print (16, offset+(OPT_MUSICVOL*8), " MP3 Music Volume");
2180 r = bgmvolume.value;
2181 M_DrawSlider (220, offset+(OPT_MUSICVOL*8), r);
2183 M_Print (16, offset+(OPT_SNDVOL*8), " Sound Volume");
2184 r = volume.value;
2185 M_DrawSlider (220, offset+(OPT_SNDVOL*8), r);
2187 M_Print (16, offset+(OPT_MUSICTYPE*8)," MP3 Playback");
2188 if (strcmpi(bgmtype.string,"cd") == 0)
2189 M_Print (220, offset+(OPT_MUSICTYPE*8), "On");
2190 else
2191 M_Print (220, offset+(OPT_MUSICTYPE*8), "Off");
2193 break;
2195 case 3:
2197 M_Print (16, offset+(OPT_FOG_START*8), " Fog start distance");
2198 r = (r_refdef.fog_start - (-5000)) / ((5000) - (-5000));
2199 M_DrawSlider (220, offset+(OPT_FOG_START*8), r);
2201 M_Print (16, offset+(OPT_FOG_END*8), " Fog end distance");
2202 r = (r_refdef.fog_end - (-5000)) / ((5000) - (-5000));
2203 M_DrawSlider (220, offset+(OPT_FOG_END*8), r);
2205 M_Print (16, offset+(OPT_FOG_RED*8), " Fog red amount");
2206 r = (r_refdef.fog_red) / 100;
2207 M_DrawSlider (220, offset+(OPT_FOG_RED*8), r);
2209 M_Print (16, offset+(OPT_FOG_GREEN*8), " Fog green amount");
2210 r = (r_refdef.fog_green) / 100;
2211 M_DrawSlider (220, offset+(OPT_FOG_GREEN*8), r);
2213 M_Print (16, offset+(OPT_FOG_BLUE*8), " Fog blue amount");
2214 r = (r_refdef.fog_blue) / 100;
2215 M_DrawSlider (220, offset+(OPT_FOG_BLUE*8), r);
2217 M_Print (16, offset+(OPT_SCRSIZE*8), " Screen size");
2218 r = (scr_viewsize.value - 30) / (130 - 30);
2219 M_DrawSlider (220, offset+(OPT_SCRSIZE*8), r);
2221 M_Print (16, offset+(OPT_WATERTRANS*8), " Water tranparency");
2222 M_DrawSlider (220, offset+(OPT_WATERTRANS*8), r_wateralpha.value);
2224 M_Print (16, offset+(OPT_MIPMAP_BIAS*8), " MipMap Amount");
2225 r = (r_mipmaps_bias.value + 10) / 10;
2226 M_DrawSlider (220, offset+(OPT_MIPMAP_BIAS*8), r);
2228 M_Print (16, offset+(OPT_TEX_SCALEDOWN*8), " Texture Scale Down");
2229 M_DrawCheckbox (220, offset+(OPT_TEX_SCALEDOWN*8), r_tex_scale_down.value);
2231 M_Print (16, offset+(OPT_SMOOTH_ANIMS*8), "Smooth Model Animation");
2232 M_DrawCheckbox (220, offset+(OPT_SMOOTH_ANIMS*8), r_i_model_animation.value);
2234 M_Print (16, offset+(OPT_SMOOTH_MOVEMENT*8), " Smooth Model Movement");
2235 M_DrawCheckbox (220, offset+(OPT_SMOOTH_MOVEMENT*8), r_i_model_transform.value);
2237 break;
2241 M_PrintWhite (16, offset+(OPT_SUBMENU*8), " Select Submenu");
2242 switch (m_submenu)
2244 case 0:
2245 M_PrintWhite (220, offset+(OPT_SUBMENU*8), "Control Options");
2246 break;
2247 case 1:
2248 M_PrintWhite (220, offset+(OPT_SUBMENU*8), "Video Options");
2249 break;
2250 case 2:
2251 M_PrintWhite (220, offset+(OPT_SUBMENU*8), "Audio Options");
2252 break;
2253 case 3:
2254 M_PrintWhite (220, offset+(OPT_SUBMENU*8), "Misc. Options");
2255 break;
2256 default:
2257 break;
2262 void M_Options_Key (int k)
2264 switch (k)
2266 case K_ESCAPE:
2267 M_Menu_Main_f ();
2268 break;
2270 case K_ENTER:
2271 m_entersound = true;
2272 switch (options_cursor)
2274 case OPT_CUSTOMIZE:
2275 M_Menu_Keys_f ();
2276 break;
2277 case OPT_CONSOLE:
2278 m_state = m_none;
2279 Con_ToggleConsole_f ();
2280 break;
2281 case OPT_DEFAULTS1:
2282 Cbuf_AddText ("exec default.cfg\n");
2283 // Cbuf_AddText ("-klook\n");
2284 break;
2286 case OPT_DEFAULTS2:
2287 Cbuf_AddText ("exec default2.cfg\n");
2288 Cbuf_AddText ("+klook\n");
2289 break;
2290 case OPT_DEFAULTS3:
2291 Cbuf_AddText ("exec default3.cfg\n");
2292 Cbuf_AddText ("+klook\n");
2293 break;
2295 default:
2296 M_AdjustSliders (1);
2297 break;
2299 return;
2301 case K_UPARROW:
2302 S_LocalSound ("misc/menu1.wav");
2303 options_cursor--;
2305 if (options_cursor == OPT_GAP)
2306 options_cursor = options_cursor -1;
2308 if (options_cursor == OPT_GAP1)
2309 options_cursor = options_cursor -1;
2311 if (m_submenu == 0)
2313 if (options_cursor == OPT_GAP_0)
2314 options_cursor = options_cursor -1;
2315 if (options_cursor == OPT_GAP_0_1)
2316 options_cursor = options_cursor -1;
2317 if (options_cursor == OPT_GAP_0_2)
2318 options_cursor = options_cursor -1;
2321 if (m_submenu == 1)
2323 if (options_cursor == OPT_GAP_1)
2324 options_cursor = options_cursor -1;
2325 if (options_cursor == OPT_GAP_1_1)
2326 options_cursor = options_cursor -1;
2329 if (m_submenu == 2)
2331 if (options_cursor == OPT_GAP_2)
2332 options_cursor = options_cursor -1;
2333 if (options_cursor == OPT_GAP_2_1)
2334 options_cursor = options_cursor -1;
2337 if (m_submenu == 3)
2339 if (options_cursor == OPT_GAP_3)
2340 options_cursor = options_cursor -1;
2341 if (options_cursor == OPT_GAP_3_1)
2342 options_cursor = options_cursor -1;
2345 if (options_cursor < 0) {
2346 if (m_submenu == 0)
2347 options_cursor = OPTIONS_ITEMS_0-1;
2348 if (m_submenu == 1)
2349 options_cursor = OPTIONS_ITEMS_1-1;
2350 if (m_submenu == 2)
2351 options_cursor = OPTIONS_ITEMS_2-1;
2352 if (m_submenu == 3)
2353 options_cursor = OPTIONS_ITEMS_3-1;
2355 break;
2357 case K_DOWNARROW:
2358 S_LocalSound ("misc/menu1.wav");
2359 options_cursor++;
2361 if (options_cursor == OPT_GAP)
2362 options_cursor = options_cursor +1;
2364 if (options_cursor == OPT_GAP1)
2365 options_cursor = options_cursor +1;
2367 if (m_submenu == 0)
2369 if (options_cursor >= OPTIONS_ITEMS_0)
2370 options_cursor = 0;
2371 if (options_cursor == OPT_GAP_0)
2372 options_cursor = options_cursor +1;
2373 if (options_cursor == OPT_GAP_0_1)
2374 options_cursor = options_cursor +1;
2375 if (options_cursor == OPT_GAP_0_2)
2376 options_cursor = options_cursor +1;
2378 if (m_submenu == 1)
2380 if (options_cursor >= OPTIONS_ITEMS_1)
2381 options_cursor = 0;
2382 if (options_cursor == OPT_GAP_1)
2383 options_cursor = options_cursor +1;
2384 if (options_cursor == OPT_GAP_1_1)
2385 options_cursor = options_cursor +1;
2387 if (m_submenu == 2)
2389 if (options_cursor >= OPTIONS_ITEMS_2)
2390 options_cursor = 0;
2391 if (options_cursor == OPT_GAP_2)
2392 options_cursor = options_cursor +1;
2393 if (options_cursor == OPT_GAP_2_1)
2394 options_cursor = options_cursor +1;
2396 if (m_submenu == 3)
2398 if (options_cursor >= OPTIONS_ITEMS_3)
2399 options_cursor = 0;
2400 if (options_cursor == OPT_GAP_3)
2401 options_cursor = options_cursor +1;
2402 if (options_cursor == OPT_GAP_3_1)
2403 options_cursor = options_cursor +1;
2405 break;
2407 case K_LEFTARROW:
2408 M_AdjustSliders (-1);
2409 break;
2411 case K_RIGHTARROW:
2412 M_AdjustSliders (1);
2413 break;
2415 case K_AUX1:
2416 m_submenu--;
2417 options_cursor = OPT_SUBMENU;
2418 if (m_submenu < 0)
2419 m_submenu = 3;
2420 break;
2422 case K_AUX2:
2423 m_submenu++;
2424 options_cursor = OPT_SUBMENU;
2425 if (m_submenu > 3)
2426 m_submenu = 0;
2427 break;
2431 //=============================================================================
2432 /* KEYS MENU */
2434 char *bindnames[][2] =
2436 {"+attack", "Attack"},
2437 {"impulse 10", "Next Weapon"},
2438 {"impulse 12", "Previous Weapon"},
2439 {"+jump", "Jump / Swim Up"},
2440 {"+forward", "Move Forward"},
2441 {"+back", "Move Backwards"},
2442 {"+moveleft", "Move Left"},
2443 {"+moveright", "Move Right"},
2444 {"+left", "Turn Left"},
2445 {"+right", "Turn Right"},
2446 {"+lookup", "Look up"},
2447 {"+lookdown", "Look down"},
2448 {"+moveup", "Swim Up"},
2449 {"+movedown", "Swim Down"},
2450 {"+speed", "Run"},
2451 {"+strafe", "Sidestep"},
2452 {"centerview", "Center view"},
2453 #ifdef PSP
2454 {"+mlook", "Analog Nub Look"},
2455 {"+klook", "D-Pad Look"},
2456 #else
2457 {"+mlook", "Mouse Look"},
2458 {"+klook", "Keyboard Look"},
2459 #endif
2460 {"+showscores", "Show Scores"},
2461 {"screenshot", "Screenshot"},
2462 {"toggleconsole", "Toggle Console"},
2465 char *kbindnames[][2] =
2467 {"+attack", "Attack"},
2468 {"impulse 10", "Next Weapon"},
2469 {"impulse 12", "Previous Weapon"},
2470 {"impulse 13", "Reload / Secondary"},
2471 {"impulse 14", "Zoom"},
2472 {"+jump", "Jump / Swim Up"},
2473 {"+forward", "Move Forward"},
2474 {"+back", "Move Backwards"},
2475 {"+moveleft", "Move Left"},
2476 {"+moveright", "Move Right"},
2477 {"+left", "Turn Left"},
2478 {"+right", "Turn Right"},
2479 {"+lookup", "Look up"},
2480 {"+lookdown", "Look down"},
2481 {"+moveup", "Swim Up"},
2482 {"+movedown", "Swim Down"},
2483 {"+speed", "Run"},
2484 {"+strafe", "Sidestep"},
2485 {"centerview", "Center view"},
2486 #ifdef PSP
2487 {"+mlook", "Analog Nub Look"},
2488 {"+klook", "D-Pad Look"},
2489 #else
2490 {"+mlook", "Mouse Look"},
2491 {"+klook", "Keyboard Look"},
2492 #endif
2493 {"+showscores", "Show Scores"},
2494 {"screenshot", "Screenshot"},
2495 {"toggleconsole", "Toggle Console"},
2498 #define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
2499 #define KNUMCOMMANDS (sizeof(kbindnames)/sizeof(kbindnames[0]))
2501 int keys_cursor;
2502 int bind_grab;
2504 void M_Menu_Keys_f (void)
2506 key_dest = key_menu;
2507 m_state = m_keys;
2508 m_entersound = true;
2512 void M_FindKeysForCommand (char *command, int *twokeys)
2514 int count;
2515 int j;
2516 int l;
2517 char *b;
2519 twokeys[0] = twokeys[1] = -1;
2520 l = strlen(command);
2521 count = 0;
2523 for (j=0 ; j<256 ; j++)
2525 b = keybindings[j];
2526 if (!b)
2527 continue;
2528 if (!strncmp (b, command, l) )
2530 twokeys[count] = j;
2531 count++;
2532 if (count == 2)
2533 break;
2538 void M_UnbindCommand (char *command)
2540 int j;
2541 int l;
2542 char *b;
2544 l = strlen(command);
2546 for (j=0 ; j<256 ; j++)
2548 b = keybindings[j];
2549 if (!b)
2550 continue;
2551 if (!strncmp (b, command, l) )
2552 Key_SetBinding (j, "");
2557 void M_Keys_Draw (void)
2559 int i, l;
2560 int keys[2];
2561 char *name;
2562 int x, y;
2563 qpic_t *p, *b;
2565 p = Draw_CachePic ("gfx/ttl_cstm.lmp");
2566 M_DrawPic ( (320-p->width)/2, 4, p);
2568 b = Draw_CachePic ("gfx/m_bttns.lmp");
2569 M_DrawPic ( (320-b->width)/2, 248, b );
2571 #ifdef PSP
2572 if (bind_grab)
2573 M_Print (12, 32, "Press a button for this action");
2574 else
2575 M_Print (18, 32, "Press CROSS to change, TRIANGLE to clear");
2576 #else
2577 if (bind_grab)
2578 M_Print (12, 32, "Press a key or button for this action");
2579 else
2580 M_Print (18, 32, "Enter to change, backspace to clear");
2581 #endif
2583 // search for known bindings
2584 if (kurok)
2586 if (bind_grab)
2587 M_DrawCharacter (170, 48 + keys_cursor*8, '?');
2588 else
2589 M_DrawCharacter (170, 48 + keys_cursor*8, 12+((int)(realtime*30)&1));
2591 for (i=0 ; i<KNUMCOMMANDS ; i++)
2593 y = 48 + 8*i;
2595 M_Print (16, y, kbindnames[i][1]);
2597 l = strlen (kbindnames[i][0]);
2599 M_FindKeysForCommand (kbindnames[i][0], keys);
2601 if (keys[0] == -1)
2603 M_Print (180, y, "---");
2605 else
2607 name = Key_KeynumToString (keys[0]);
2608 M_Print (180, y, name);
2609 x = strlen(name) * 8;
2610 if (keys[1] != -1)
2612 M_Print (180 + x + 8, y, "or");
2613 M_Print (180 + x + 32, y, Key_KeynumToString (keys[1]));
2618 else
2620 if (bind_grab)
2621 M_DrawCharacter (130, 48 + keys_cursor*8, '=');
2622 else
2623 M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
2625 for (i=0 ; i<NUMCOMMANDS ; i++)
2627 y = 48 + 8*i;
2629 M_Print (16, y, bindnames[i][1]);
2631 l = strlen (bindnames[i][0]);
2633 M_FindKeysForCommand (bindnames[i][0], keys);
2635 if (keys[0] == -1)
2637 M_Print (140, y, "???");
2639 else
2641 name = Key_KeynumToString (keys[0]);
2642 M_Print (140, y, name);
2643 x = strlen(name) * 8;
2644 if (keys[1] != -1)
2646 M_Print (140 + x + 8, y, "or");
2647 M_Print (140 + x + 32, y, Key_KeynumToString (keys[1]));
2655 void M_Keys_Key (int k)
2657 char cmd[80];
2658 int keys[2];
2660 if (bind_grab)
2661 { // defining a key
2662 S_LocalSound ("misc/menu1.wav");
2663 if (k == K_ESCAPE)
2665 bind_grab = false;
2667 else if (k != '`')
2669 if (kurok)
2670 sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), kbindnames[keys_cursor][0]);
2671 else
2672 sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
2673 Cbuf_InsertText (cmd);
2676 bind_grab = false;
2677 return;
2680 switch (k)
2682 case K_ESCAPE:
2683 M_Menu_Options_f ();
2684 break;
2686 case K_LEFTARROW:
2687 case K_UPARROW:
2688 S_LocalSound ("misc/menu1.wav");
2689 keys_cursor--;
2690 if (keys_cursor < 0)
2692 if (kurok)
2693 keys_cursor = KNUMCOMMANDS-1;
2694 else
2695 keys_cursor = NUMCOMMANDS-1;
2697 break;
2699 case K_DOWNARROW:
2700 case K_RIGHTARROW:
2701 S_LocalSound ("misc/menu1.wav");
2702 keys_cursor++;
2703 if (kurok)
2705 if (keys_cursor >= KNUMCOMMANDS)
2706 keys_cursor = 0;
2708 else
2710 if (keys_cursor >= NUMCOMMANDS)
2711 keys_cursor = 0;
2713 break;
2715 case K_ENTER: // go into bind mode
2716 if (kurok)
2717 M_FindKeysForCommand (kbindnames[keys_cursor][0], keys);
2718 else
2719 M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
2720 S_LocalSound ("misc/menu2.wav");
2721 if (keys[1] != -1)
2723 if (kurok)
2724 M_UnbindCommand (kbindnames[keys_cursor][0]);
2725 else
2726 M_UnbindCommand (bindnames[keys_cursor][0]);
2728 bind_grab = true;
2729 break;
2731 case K_BACKSPACE: // delete bindings
2732 case K_DEL: // delete bindings
2733 S_LocalSound ("misc/menu2.wav");
2734 if (kurok)
2735 M_UnbindCommand (kbindnames[keys_cursor][0]);
2736 else
2737 M_UnbindCommand (bindnames[keys_cursor][0]);
2738 break;
2742 //=============================================================================
2743 /* VIDEO MENU */
2745 void M_Menu_Video_f (void)
2747 key_dest = key_menu;
2748 m_state = m_video;
2749 m_entersound = true;
2753 void M_Video_Draw (void)
2755 (*vid_menudrawfn) ();
2759 void M_Video_Key (int key)
2761 (*vid_menukeyfn) (key);
2764 //=============================================================================
2765 /* HELP MENU */
2767 int help_page;
2768 #define NUM_HELP_PAGES 6
2769 #define KNUM_HELP_PAGES 2
2772 void M_Menu_Help_f (void)
2774 key_dest = key_menu;
2775 m_state = m_help;
2776 m_entersound = true;
2777 help_page = 0;
2782 void M_Help_Draw (void)
2784 if (kurok)
2785 M_DrawPic (vid.width - 560, 0, Draw_CachePic ( va("gfx/menu/hp/help%i.lmp", help_page)) );
2786 else
2787 M_DrawPic (0, 0, Draw_CachePic ( va("gfx/help%i.lmp", help_page)) );
2791 void M_Help_Key (int key)
2793 switch (key)
2795 case K_ESCAPE:
2796 M_Menu_Main_f ();
2797 break;
2799 case K_UPARROW:
2800 case K_RIGHTARROW:
2801 m_entersound = true;
2802 if (!kurok)
2804 if (++help_page >= NUM_HELP_PAGES)
2805 help_page = 0;
2807 else
2809 if (++help_page >= KNUM_HELP_PAGES)
2810 help_page = 0;
2812 break;
2814 case K_DOWNARROW:
2815 case K_LEFTARROW:
2816 m_entersound = true;
2817 if (!kurok)
2819 if (--help_page < 0)
2820 help_page = NUM_HELP_PAGES-1;
2822 else
2824 if (--help_page < 0)
2825 help_page = KNUM_HELP_PAGES-1;
2827 break;
2832 //=============================================================================
2833 /* QUIT MENU */
2835 int msgNumber;
2836 int m_quit_prevstate;
2837 qboolean wasInMenus;
2839 #ifndef WIN32
2840 char *quitMessage [] =
2842 /* .........1.........2.... */
2843 " Are you gonna quit ",
2844 " this game just like ",
2845 " everything else? ",
2846 " ",
2848 " Milord, methinks that ",
2849 " thou art a lowly ",
2850 " quitter. Is this true? ",
2851 " ",
2853 " Do I need to bust your ",
2854 " face open for trying ",
2855 " to quit? ",
2856 " ",
2858 " Man, I oughta smack you",
2859 " for trying to quit! ",
2860 " Press Y to get ",
2861 " smacked out. ",
2863 " Press Y to quit like a ",
2864 " big loser in life. ",
2865 " Press N to stay proud ",
2866 " and successful! ",
2868 " If you press Y to ",
2869 " quit, I will summon ",
2870 " Satan all over your ",
2871 " hard drive! ",
2873 " Um, Asmodeus dislikes ",
2874 " his children trying to ",
2875 " quit. Press Y to return",
2876 " to your Tinkertoys. ",
2878 " If you quit now, I'll ",
2879 " throw a blanket-party ",
2880 " for you next time! ",
2883 #endif
2885 void M_Menu_Quit_f (void)
2887 if (m_state == m_quit)
2888 return;
2889 wasInMenus = (key_dest == key_menu);
2890 key_dest = key_menu;
2891 m_quit_prevstate = m_state;
2892 m_state = m_quit;
2893 m_entersound = true;
2894 msgNumber = rand()&7;
2898 void M_Quit_Key (int key)
2900 switch (key)
2902 case K_ESCAPE:
2903 case 'n':
2904 case 'N':
2905 if (wasInMenus)
2907 m_state = m_quit_prevstate;
2908 m_entersound = true;
2910 else
2912 key_dest = key_game;
2913 m_state = m_none;
2915 break;
2917 case 'Y':
2918 case 'y':
2919 #ifdef PSP
2920 case K_ENTER:
2921 #endif
2922 key_dest = key_console;
2923 Host_Quit_f ();
2924 break;
2926 default:
2927 break;
2933 void M_Quit_Draw (void)
2935 if (wasInMenus)
2937 m_state = m_quit_prevstate;
2938 m_recursiveDraw = true;
2939 M_Draw ();
2940 m_state = m_quit;
2943 #ifdef WIN32
2944 M_DrawTextBox (0, 0, 38, 23);
2945 M_PrintWhite (16, 12, " Quake version 1.09 by id Software\n\n");
2946 M_PrintWhite (16, 28, "Programming Art \n");
2947 M_Print (16, 36, " John Carmack Adrian Carmack\n");
2948 M_Print (16, 44, " Michael Abrash Kevin Cloud\n");
2949 M_Print (16, 52, " John Cash Paul Steed\n");
2950 M_Print (16, 60, " Dave 'Zoid' Kirsch\n");
2951 M_PrintWhite (16, 68, "Design Biz\n");
2952 M_Print (16, 76, " John Romero Jay Wilbur\n");
2953 M_Print (16, 84, " Sandy Petersen Mike Wilson\n");
2954 M_Print (16, 92, " American McGee Donna Jackson\n");
2955 M_Print (16, 100, " Tim Willits Todd Hollenshead\n");
2956 M_PrintWhite (16, 108, "Support Projects\n");
2957 M_Print (16, 116, " Barrett Alexander Shawn Green\n");
2958 M_PrintWhite (16, 124, "Sound Effects\n");
2959 M_Print (16, 132, " Trent Reznor and Nine Inch Nails\n\n");
2960 M_PrintWhite (16, 140, "Quake is a trademark of Id Software,\n");
2961 M_PrintWhite (16, 148, "inc., (c)1996 Id Software, inc. All\n");
2962 M_PrintWhite (16, 156, "rights reserved. NIN logo is a\n");
2963 M_PrintWhite (16, 164, "registered trademark licensed to\n");
2964 M_PrintWhite (16, 172, "Nothing Interactive, Inc. All rights\n");
2965 M_PrintWhite (16, 180, "reserved. Press y to exit\n");
2966 #elif defined PSP
2967 M_DrawTextBox (56, 76, 24, 4);
2968 M_Print (64, 84, " Really quit? ");
2969 M_Print (64, 92, " ");
2970 M_Print (64, 100, " Press CROSS to quit, ");
2971 M_Print (64, 108, " or CIRCLE to continue. ");
2972 #else
2973 M_DrawTextBox (56, 76, 24, 4);
2974 M_Print (64, 84, quitMessage[msgNumber*4+0]);
2975 M_Print (64, 92, quitMessage[msgNumber*4+1]);
2976 M_Print (64, 100, quitMessage[msgNumber*4+2]);
2977 M_Print (64, 108, quitMessage[msgNumber*4+3]);
2978 #endif
2980 //=============================================================================
2981 /* OSK IMPLEMENTATION */
2982 #define CHAR_SIZE 8
2983 #define MAX_Y 8
2984 #define MAX_X 12
2986 #define MAX_CHAR_LINE 36
2987 #define MAX_CHAR 72
2989 int osk_pos_x = 0;
2990 int osk_pos_y = 0;
2991 int max_len = 0;
2992 int m_old_state = 0;
2994 char* osk_out_buff = NULL;
2995 char osk_buffer[128];
2997 char *osk_text [] =
2999 " 1 2 3 4 5 6 7 8 9 0 - = ` ",
3000 " q w e r t y u i o p [ ] ",
3001 " a s d f g h j k l ; ' \\ ",
3002 " z x c v b n m , . / ",
3003 " ",
3004 " ! @ # $ % ^ & * ( ) _ + ~ ",
3005 " Q W E R T Y U I O P { } ",
3006 " A S D F G H J K L : \" | ",
3007 " Z X C V B N M < > ? "
3010 char *osk_help [] =
3012 "CONFIRM: ",
3013 " SQUARE ",
3014 "CANCEL: ",
3015 " CIRCLE ",
3016 "DELETE: ",
3017 " TRIAGLE ",
3018 "ADD CHAR:",
3019 " CROSS ",
3023 void M_Menu_OSK_f (char *input, char *output, int outlen)
3025 key_dest = key_menu;
3026 m_old_state = m_state;
3027 m_state = m_osk;
3028 m_entersound = false;
3029 max_len = outlen;
3030 strncpy(osk_buffer,input,max_len);
3031 osk_buffer[outlen] = '\0';
3032 osk_out_buff = output;
3035 void Con_OSK_f (char *input, char *output, int outlen)
3037 max_len = outlen;
3038 strncpy(osk_buffer,input,max_len);
3039 osk_buffer[outlen] = '\0';
3040 osk_out_buff = output;
3044 void M_OSK_Draw (void)
3046 #ifdef PSP
3047 int x,y;
3048 int i;
3050 char *selected_line = osk_text[osk_pos_y];
3051 char selected_char[2];
3053 selected_char[0] = selected_line[1+(2*osk_pos_x)];
3054 selected_char[1] = '\0';
3055 if (selected_char[0] == ' ' || selected_char[0] == '\t')
3056 selected_char[0] = 'X';
3058 y = 20;
3059 x = 16;
3061 M_DrawTextBox (10, 10, 26, 10);
3062 M_DrawTextBox (10+(26*CHAR_SIZE), 10, 10, 10);
3063 M_DrawTextBox (10, 10+(10*CHAR_SIZE),36, 3);
3065 for(i=0;i<=MAX_Y;i++)
3067 M_PrintWhite (x, y+(CHAR_SIZE*i), osk_text[i]);
3068 if (i % 2 == 0)
3069 M_Print (x+(27*CHAR_SIZE), y+(CHAR_SIZE*i), osk_help[i]);
3070 else
3071 M_PrintWhite (x+(27*CHAR_SIZE), y+(CHAR_SIZE*i), osk_help[i]);
3074 int text_len = strlen(osk_buffer);
3075 if (text_len > MAX_CHAR_LINE) {
3077 char oneline[MAX_CHAR_LINE+1];
3078 strncpy(oneline,osk_buffer,MAX_CHAR_LINE);
3079 oneline[MAX_CHAR_LINE] = '\0';
3081 M_Print (x+4, y+4+(CHAR_SIZE*(MAX_Y+2)), oneline );
3083 strncpy(oneline,osk_buffer+MAX_CHAR_LINE, text_len - MAX_CHAR_LINE);
3084 oneline[text_len - MAX_CHAR_LINE] = '\0';
3086 M_Print (x+4, y+4+(CHAR_SIZE*(MAX_Y+3)), oneline );
3087 M_PrintWhite (x+4+(CHAR_SIZE*(text_len - MAX_CHAR_LINE)), y+4+(CHAR_SIZE*(MAX_Y+3)),"_");
3089 else {
3090 M_Print (x+4, y+4+(CHAR_SIZE*(MAX_Y+2)), osk_buffer );
3091 M_PrintWhite (x+4+(CHAR_SIZE*(text_len)), y+4+(CHAR_SIZE*(MAX_Y+2)),"_");
3093 M_Print (x+((((osk_pos_x)*2)+1)*CHAR_SIZE), y+(osk_pos_y*CHAR_SIZE), selected_char);
3095 #endif
3098 void M_OSK_Key (int key)
3100 #ifdef PSP
3101 switch (key)
3103 case K_RIGHTARROW:
3104 osk_pos_x++;
3105 if (osk_pos_x > MAX_X)
3106 osk_pos_x = MAX_X;
3107 break;
3108 case K_LEFTARROW:
3109 osk_pos_x--;
3110 if (osk_pos_x < 0)
3111 osk_pos_x = 0;
3112 break;
3113 case K_DOWNARROW:
3114 osk_pos_y++;
3115 if (osk_pos_y > MAX_Y)
3116 osk_pos_y = MAX_Y;
3117 break;
3118 case K_UPARROW:
3119 osk_pos_y--;
3120 if (osk_pos_y < 0)
3121 osk_pos_y = 0;
3122 break;
3123 case K_ENTER:
3124 if (max_len > strlen(osk_buffer)) {
3125 char *selected_line = osk_text[osk_pos_y];
3126 char selected_char[2];
3128 selected_char[0] = selected_line[1+(2*osk_pos_x)];
3130 if (selected_char[0] == '\t')
3131 selected_char[0] = ' ';
3133 selected_char[1] = '\0';
3134 strcat(osk_buffer,selected_char);
3136 break;
3137 case K_DEL:
3138 if (strlen(osk_buffer) > 0) {
3139 osk_buffer[strlen(osk_buffer)-1] = '\0';
3141 break;
3142 case K_INS:
3143 strncpy(osk_out_buff,osk_buffer,max_len);
3145 m_state = m_old_state;
3146 break;
3147 case K_ESCAPE:
3148 m_state = m_old_state;
3149 break;
3150 default:
3151 break;
3153 #endif
3156 void Con_OSK_Key (int key)
3158 #ifdef PSP
3159 switch (key)
3161 case K_RIGHTARROW:
3162 osk_pos_x++;
3163 if (osk_pos_x > MAX_X)
3164 osk_pos_x = MAX_X;
3165 break;
3166 case K_LEFTARROW:
3167 osk_pos_x--;
3168 if (osk_pos_x < 0)
3169 osk_pos_x = 0;
3170 break;
3171 case K_DOWNARROW:
3172 osk_pos_y++;
3173 if (osk_pos_y > MAX_Y)
3174 osk_pos_y = MAX_Y;
3175 break;
3176 case K_UPARROW:
3177 osk_pos_y--;
3178 if (osk_pos_y < 0)
3179 osk_pos_y = 0;
3180 break;
3181 case K_ENTER:
3182 if (max_len > strlen(osk_buffer)) {
3183 char *selected_line = osk_text[osk_pos_y];
3184 char selected_char[2];
3186 selected_char[0] = selected_line[1+(2*osk_pos_x)];
3188 if (selected_char[0] == '\t')
3189 selected_char[0] = ' ';
3191 selected_char[1] = '\0';
3192 strcat(osk_buffer,selected_char);
3194 break;
3195 case K_DEL:
3196 if (strlen(osk_buffer) > 0) {
3197 osk_buffer[strlen(osk_buffer)-1] = '\0';
3199 break;
3200 case K_INS:
3201 strncpy(osk_out_buff,osk_buffer,max_len);
3202 Con_SetOSKActive(false);
3203 break;
3204 case K_ESCAPE:
3205 Con_SetOSKActive(false);
3206 break;
3207 default:
3208 break;
3210 #endif
3213 //=============================================================================
3215 /* SERIAL CONFIG MENU */
3217 int serialConfig_cursor;
3218 int serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132};
3219 #define NUM_SERIALCONFIG_CMDS 6
3221 static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8};
3222 static int ISA_IRQs[] = {4,3,4,3};
3223 int serialConfig_baudrate[] = {9600,14400,19200,28800,38400,57600};
3225 int serialConfig_comport;
3226 int serialConfig_irq ;
3227 int serialConfig_baud;
3228 char serialConfig_phone[16];
3230 void M_Menu_SerialConfig_f (void)
3232 int n;
3233 int port;
3234 int baudrate;
3235 qboolean useModem;
3237 key_dest = key_menu;
3238 m_state = m_serialconfig;
3239 m_entersound = true;
3240 if (JoiningGame && SerialConfig)
3241 serialConfig_cursor = 4;
3242 else
3243 serialConfig_cursor = 5;
3245 (*GetComPortConfig) (0, &port, &serialConfig_irq, &baudrate, &useModem);
3247 // map uart's port to COMx
3248 for (n = 0; n < 4; n++)
3249 if (ISA_uarts[n] == port)
3250 break;
3251 if (n == 4)
3253 n = 0;
3254 serialConfig_irq = 4;
3256 serialConfig_comport = n + 1;
3258 // map baudrate to index
3259 for (n = 0; n < 6; n++)
3260 if (serialConfig_baudrate[n] == baudrate)
3261 break;
3262 if (n == 6)
3263 n = 5;
3264 serialConfig_baud = n;
3266 m_return_onerror = false;
3267 m_return_reason[0] = 0;
3271 void M_SerialConfig_Draw (void)
3273 qpic_t *p,*b;
3274 int basex;
3275 char *startJoin;
3276 char *directModem;
3278 if (!kurok)
3279 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
3281 b = Draw_CachePic ("gfx/m_bttns.lmp");
3282 M_DrawPic ( (320-b->width)/2, 248, b );
3283 p = Draw_CachePic ("gfx/p_multi.lmp");
3284 basex = (320-p->width)/2;
3285 M_DrawPic (basex, 4, p);
3287 if (StartingGame)
3288 startJoin = "New Game";
3289 else
3290 startJoin = "Join Game";
3291 if (SerialConfig)
3292 directModem = "Modem";
3293 else
3294 directModem = "Direct Connect";
3295 M_Print (basex, 32, va ("%s - %s", startJoin, directModem));
3296 basex += 8;
3298 M_Print (basex, serialConfig_cursor_table[0], "Port");
3299 M_DrawTextBox (160, 40, 4, 1);
3300 M_Print (168, serialConfig_cursor_table[0], va("COM%u", serialConfig_comport));
3302 M_Print (basex, serialConfig_cursor_table[1], "IRQ");
3303 M_DrawTextBox (160, serialConfig_cursor_table[1]-8, 1, 1);
3304 M_Print (168, serialConfig_cursor_table[1], va("%u", serialConfig_irq));
3306 M_Print (basex, serialConfig_cursor_table[2], "Baud");
3307 M_DrawTextBox (160, serialConfig_cursor_table[2]-8, 5, 1);
3308 M_Print (168, serialConfig_cursor_table[2], va("%u", serialConfig_baudrate[serialConfig_baud]));
3310 if (SerialConfig)
3312 M_Print (basex, serialConfig_cursor_table[3], "Modem Setup...");
3313 if (JoiningGame)
3315 M_Print (basex, serialConfig_cursor_table[4], "Phone number");
3316 M_DrawTextBox (160, serialConfig_cursor_table[4]-8, 16, 1);
3317 M_Print (168, serialConfig_cursor_table[4], serialConfig_phone);
3321 if (JoiningGame)
3323 M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 7, 1);
3324 M_Print (basex+8, serialConfig_cursor_table[5], "Connect");
3326 else
3328 M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 2, 1);
3329 M_Print (basex+8, serialConfig_cursor_table[5], "OK");
3332 M_DrawCharacter (basex-8, serialConfig_cursor_table [serialConfig_cursor], 12+((int)(realtime*4)&1));
3334 if (serialConfig_cursor == 4)
3335 M_DrawCharacter (168 + 8*strlen(serialConfig_phone), serialConfig_cursor_table [serialConfig_cursor], 10+((int)(realtime*4)&1));
3337 if (*m_return_reason)
3338 M_PrintWhite (basex, 148, m_return_reason);
3342 void M_SerialConfig_Key (int key)
3344 int l;
3346 switch (key)
3348 case K_ESCAPE:
3349 M_Menu_Net_f ();
3350 break;
3352 case K_UPARROW:
3353 S_LocalSound ("misc/menu1.wav");
3354 serialConfig_cursor--;
3355 if (serialConfig_cursor < 0)
3356 serialConfig_cursor = NUM_SERIALCONFIG_CMDS-1;
3357 break;
3359 case K_DOWNARROW:
3360 S_LocalSound ("misc/menu1.wav");
3361 serialConfig_cursor++;
3362 if (serialConfig_cursor >= NUM_SERIALCONFIG_CMDS)
3363 serialConfig_cursor = 0;
3364 break;
3366 case K_LEFTARROW:
3367 if (serialConfig_cursor > 2)
3368 break;
3369 S_LocalSound ("misc/menu3.wav");
3371 if (serialConfig_cursor == 0)
3373 serialConfig_comport--;
3374 if (serialConfig_comport == 0)
3375 serialConfig_comport = 4;
3376 serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
3379 if (serialConfig_cursor == 1)
3381 serialConfig_irq--;
3382 if (serialConfig_irq == 6)
3383 serialConfig_irq = 5;
3384 if (serialConfig_irq == 1)
3385 serialConfig_irq = 7;
3388 if (serialConfig_cursor == 2)
3390 serialConfig_baud--;
3391 if (serialConfig_baud < 0)
3392 serialConfig_baud = 5;
3395 break;
3397 case K_RIGHTARROW:
3398 if (serialConfig_cursor > 2)
3399 break;
3400 forward:
3401 S_LocalSound ("misc/menu3.wav");
3403 if (serialConfig_cursor == 0)
3405 serialConfig_comport++;
3406 if (serialConfig_comport > 4)
3407 serialConfig_comport = 1;
3408 serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
3411 if (serialConfig_cursor == 1)
3413 serialConfig_irq++;
3414 if (serialConfig_irq == 6)
3415 serialConfig_irq = 7;
3416 if (serialConfig_irq == 8)
3417 serialConfig_irq = 2;
3420 if (serialConfig_cursor == 2)
3422 serialConfig_baud++;
3423 if (serialConfig_baud > 5)
3424 serialConfig_baud = 0;
3427 break;
3429 case K_ENTER:
3430 if (serialConfig_cursor < 3)
3431 goto forward;
3433 m_entersound = true;
3435 if (serialConfig_cursor == 3)
3437 (*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
3439 M_Menu_ModemConfig_f ();
3440 break;
3443 if (serialConfig_cursor == 4)
3445 serialConfig_cursor = 5;
3446 break;
3449 // serialConfig_cursor == 5 (OK/CONNECT)
3450 (*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
3452 M_ConfigureNetSubsystem ();
3454 if (StartingGame)
3456 M_Menu_GameOptions_f ();
3457 break;
3460 m_return_state = m_state;
3461 m_return_onerror = true;
3462 key_dest = key_game;
3463 m_state = m_none;
3465 // If we were in a multiplayer game, reset all the deathmatch flags to 0;
3467 items_respawn = 1;
3468 weapons_stay =
3469 pistols =
3470 automatics =
3471 shotguns =
3472 explosives =
3473 snipers =
3474 exit_non_fatal =
3475 infinite_ammo =
3476 all_weapons =
3477 no_reload =
3478 no_armor =
3479 no_health =
3480 armor_regen =
3481 health_regen =
3482 safe_spawn =
3483 no_bots = 0;
3485 if (SerialConfig)
3487 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
3488 Cbuf_AddText (va ("connect \"%s\"\n", serialConfig_phone));
3490 else
3492 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
3493 Cbuf_AddText ("connect\n");
3495 break;
3497 case K_BACKSPACE:
3498 if (serialConfig_cursor == 4)
3500 if (strlen(serialConfig_phone))
3501 serialConfig_phone[strlen(serialConfig_phone)-1] = 0;
3503 break;
3505 default:
3506 if (key < 32 || key > 127)
3507 break;
3508 if (serialConfig_cursor == 4)
3510 l = strlen(serialConfig_phone);
3511 if (l < 15)
3513 serialConfig_phone[l+1] = 0;
3514 serialConfig_phone[l] = key;
3519 if (DirectConfig && (serialConfig_cursor == 3 || serialConfig_cursor == 4))
3521 if (key == K_UPARROW)
3522 serialConfig_cursor = 2;
3523 else
3524 serialConfig_cursor = 5;
3526 if (SerialConfig && StartingGame && serialConfig_cursor == 4)
3528 if (key == K_UPARROW)
3529 serialConfig_cursor = 3;
3530 else
3531 serialConfig_cursor = 5;
3535 //=============================================================================
3536 /* MODEM CONFIG MENU */
3538 int modemConfig_cursor;
3539 int modemConfig_cursor_table [] = {40, 56, 88, 120, 156};
3540 #define NUM_MODEMCONFIG_CMDS 5
3542 char modemConfig_dialing;
3543 char modemConfig_clear [16];
3544 char modemConfig_init [32];
3545 char modemConfig_hangup [16];
3547 void M_Menu_ModemConfig_f (void)
3549 key_dest = key_menu;
3550 m_state = m_modemconfig;
3551 m_entersound = true;
3552 (*GetModemConfig) (0, &modemConfig_dialing, modemConfig_clear, modemConfig_init, modemConfig_hangup);
3556 void M_ModemConfig_Draw (void)
3558 qpic_t *p,*b;
3559 int basex;
3561 if (!kurok)
3562 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
3564 b = Draw_CachePic ("gfx/m_bttns.lmp");
3565 M_DrawPic ( (320-b->width)/2, 248, b );
3566 p = Draw_CachePic ("gfx/p_multi.lmp");
3567 basex = (320-p->width)/2;
3568 M_DrawPic (basex, 4, p);
3569 basex += 8;
3571 if (modemConfig_dialing == 'P')
3572 M_Print (basex, modemConfig_cursor_table[0], "Pulse Dialing");
3573 else
3574 M_Print (basex, modemConfig_cursor_table[0], "Touch Tone Dialing");
3576 M_Print (basex, modemConfig_cursor_table[1], "Clear");
3577 M_DrawTextBox (basex, modemConfig_cursor_table[1]+4, 16, 1);
3578 M_Print (basex+8, modemConfig_cursor_table[1]+12, modemConfig_clear);
3579 if (modemConfig_cursor == 1)
3580 M_DrawCharacter (basex+8 + 8*strlen(modemConfig_clear), modemConfig_cursor_table[1]+12, 10+((int)(realtime*4)&1));
3582 M_Print (basex, modemConfig_cursor_table[2], "Init");
3583 M_DrawTextBox (basex, modemConfig_cursor_table[2]+4, 30, 1);
3584 M_Print (basex+8, modemConfig_cursor_table[2]+12, modemConfig_init);
3585 if (modemConfig_cursor == 2)
3586 M_DrawCharacter (basex+8 + 8*strlen(modemConfig_init), modemConfig_cursor_table[2]+12, 10+((int)(realtime*4)&1));
3588 M_Print (basex, modemConfig_cursor_table[3], "Hangup");
3589 M_DrawTextBox (basex, modemConfig_cursor_table[3]+4, 16, 1);
3590 M_Print (basex+8, modemConfig_cursor_table[3]+12, modemConfig_hangup);
3591 if (modemConfig_cursor == 3)
3592 M_DrawCharacter (basex+8 + 8*strlen(modemConfig_hangup), modemConfig_cursor_table[3]+12, 10+((int)(realtime*4)&1));
3594 M_DrawTextBox (basex, modemConfig_cursor_table[4]-8, 2, 1);
3595 M_Print (basex+8, modemConfig_cursor_table[4], "OK");
3597 M_DrawCharacter (basex-8, modemConfig_cursor_table [modemConfig_cursor], 12+((int)(realtime*4)&1));
3601 void M_ModemConfig_Key (int key)
3603 int l;
3605 switch (key)
3607 case K_ESCAPE:
3608 M_Menu_SerialConfig_f ();
3609 break;
3611 case K_UPARROW:
3612 S_LocalSound ("misc/menu1.wav");
3613 modemConfig_cursor--;
3614 if (modemConfig_cursor < 0)
3615 modemConfig_cursor = NUM_MODEMCONFIG_CMDS-1;
3616 break;
3618 case K_DOWNARROW:
3619 S_LocalSound ("misc/menu1.wav");
3620 modemConfig_cursor++;
3621 if (modemConfig_cursor >= NUM_MODEMCONFIG_CMDS)
3622 modemConfig_cursor = 0;
3623 break;
3625 case K_LEFTARROW:
3626 case K_RIGHTARROW:
3627 if (modemConfig_cursor == 0)
3629 if (modemConfig_dialing == 'P')
3630 modemConfig_dialing = 'T';
3631 else
3632 modemConfig_dialing = 'P';
3633 S_LocalSound ("misc/menu1.wav");
3635 break;
3637 case K_ENTER:
3638 if (modemConfig_cursor == 0)
3640 if (modemConfig_dialing == 'P')
3641 modemConfig_dialing = 'T';
3642 else
3643 modemConfig_dialing = 'P';
3644 m_entersound = true;
3647 if (modemConfig_cursor == 4)
3649 (*SetModemConfig) (0, va ("%c", modemConfig_dialing), modemConfig_clear, modemConfig_init, modemConfig_hangup);
3650 m_entersound = true;
3651 M_Menu_SerialConfig_f ();
3653 break;
3655 case K_BACKSPACE:
3656 if (modemConfig_cursor == 1)
3658 if (strlen(modemConfig_clear))
3659 modemConfig_clear[strlen(modemConfig_clear)-1] = 0;
3662 if (modemConfig_cursor == 2)
3664 if (strlen(modemConfig_init))
3665 modemConfig_init[strlen(modemConfig_init)-1] = 0;
3668 if (modemConfig_cursor == 3)
3670 if (strlen(modemConfig_hangup))
3671 modemConfig_hangup[strlen(modemConfig_hangup)-1] = 0;
3673 break;
3675 default:
3676 if (key < 32 || key > 127)
3677 break;
3679 if (modemConfig_cursor == 1)
3681 l = strlen(modemConfig_clear);
3682 if (l < 15)
3684 modemConfig_clear[l+1] = 0;
3685 modemConfig_clear[l] = key;
3689 if (modemConfig_cursor == 2)
3691 l = strlen(modemConfig_init);
3692 if (l < 29)
3694 modemConfig_init[l+1] = 0;
3695 modemConfig_init[l] = key;
3699 if (modemConfig_cursor == 3)
3701 l = strlen(modemConfig_hangup);
3702 if (l < 15)
3704 modemConfig_hangup[l+1] = 0;
3705 modemConfig_hangup[l] = key;
3711 //=============================================================================
3712 /* LAN CONFIG MENU */
3714 int lanConfig_cursor = -1;
3715 int lanConfig_cursor_table [] = {72, 92, 124};
3716 #define NUM_LANCONFIG_CMDS 3
3718 int lanConfig_port;
3719 char lanConfig_portname[6];
3720 char lanConfig_joinname[22];
3722 void M_Menu_LanConfig_f (void)
3724 key_dest = key_menu;
3725 m_state = m_lanconfig;
3726 m_entersound = true;
3727 if (lanConfig_cursor == -1)
3729 if (JoiningGame && TCPIPConfig)
3730 lanConfig_cursor = 2;
3731 else
3732 lanConfig_cursor = 1;
3734 if (StartingGame && lanConfig_cursor == 2)
3735 lanConfig_cursor = 1;
3736 lanConfig_port = DEFAULTnet_hostport;
3737 sprintf(lanConfig_portname, "%u", lanConfig_port);
3739 m_return_onerror = false;
3740 m_return_reason[0] = 0;
3744 void M_LanConfig_Draw (void)
3746 qpic_t *p,*b;
3747 int basex;
3748 char *startJoin;
3749 char *protocol;
3751 if (!kurok)
3752 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
3754 b = Draw_CachePic ("gfx/m_bttns.lmp");
3755 M_DrawPic ( (320-b->width)/2, 248, b );
3756 p = Draw_CachePic ("gfx/p_multi.lmp");
3757 basex = (320-p->width)/2;
3758 M_DrawPic (basex, 4, p);
3760 if (StartingGame)
3761 startJoin = "New Game";
3762 else
3763 startJoin = "Join Game";
3764 if (IPXConfig)
3765 protocol = "IPX";
3766 else
3767 protocol = "TCP/IP";
3768 M_PrintWhite (basex, 32, va ("%s - %s", startJoin, protocol));
3769 basex += 8;
3771 M_PrintWhite (basex, 52, "Address:");
3772 if (IPXConfig)
3773 M_Print (basex+9*8, 52, my_ipx_address);
3774 else
3775 M_Print (basex+9*8, 52, my_tcpip_address);
3777 M_PrintWhite (basex, lanConfig_cursor_table[0], "Port");
3778 M_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
3779 M_PrintWhite (basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
3781 if (JoiningGame)
3783 M_PrintWhite (basex, lanConfig_cursor_table[1], "Search for local games...");
3784 M_PrintWhite (basex, 108, "Join game at:");
3785 M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
3786 M_PrintWhite (basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
3788 else
3790 M_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
3791 M_PrintWhite (basex+8, lanConfig_cursor_table[1], "OK");
3794 if (*m_return_reason)
3795 M_PrintWhite (basex, 148, m_return_reason);
3797 if (kurok)
3799 M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*30)&1));
3801 if (lanConfig_cursor == 0)
3802 M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*30)&1));
3804 if (lanConfig_cursor == 2)
3805 M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*30)&1));
3807 else
3809 M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
3811 if (lanConfig_cursor == 0)
3812 M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
3814 if (lanConfig_cursor == 2)
3815 M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
3821 void M_LanConfig_Key (int key)
3823 int l;
3825 switch (key)
3827 case K_ESCAPE:
3828 // M_Menu_Net_f ();
3829 M_Menu_MultiPlayer_f ();
3830 break;
3832 case K_UPARROW:
3833 S_LocalSound ("misc/menu1.wav");
3834 lanConfig_cursor--;
3835 if (lanConfig_cursor < 0)
3836 lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
3837 break;
3839 case K_DOWNARROW:
3840 S_LocalSound ("misc/menu1.wav");
3841 lanConfig_cursor++;
3842 if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
3843 lanConfig_cursor = 0;
3844 break;
3846 case K_INS:
3847 if (lanConfig_cursor == 0)
3849 M_Menu_OSK_f(lanConfig_portname, lanConfig_portname, 6);
3850 break;
3853 if (lanConfig_cursor == 2)
3855 M_Menu_OSK_f(lanConfig_joinname, lanConfig_joinname, 22);
3856 break;
3858 break;
3860 case K_ENTER:
3861 if (lanConfig_cursor == 0)
3862 break;
3864 m_entersound = true;
3866 M_ConfigureNetSubsystem ();
3868 if (lanConfig_cursor == 1)
3870 if (StartingGame)
3872 M_Menu_GameOptions_f ();
3873 break;
3875 M_Menu_Search_f();
3876 break;
3879 if (lanConfig_cursor == 2)
3881 m_return_state = m_state;
3882 m_return_onerror = true;
3883 key_dest = key_game;
3884 m_state = m_none;
3886 // If we were in a multiplayer game, reset all the deathmatch flags to 0;
3888 items_respawn = 1;
3889 weapons_stay =
3890 pistols =
3891 automatics =
3892 shotguns =
3893 explosives =
3894 snipers =
3895 exit_non_fatal =
3896 infinite_ammo =
3897 all_weapons =
3898 no_reload =
3899 no_armor =
3900 no_health =
3901 armor_regen =
3902 health_regen =
3903 safe_spawn =
3904 no_bots = 0;
3906 if(kurok)
3907 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
3909 Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
3910 break;
3913 break;
3915 case K_BACKSPACE:
3916 if (lanConfig_cursor == 0)
3918 if (strlen(lanConfig_portname))
3919 lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
3922 if (lanConfig_cursor == 2)
3924 if (strlen(lanConfig_joinname))
3925 lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
3927 break;
3929 default:
3930 if (key < 32 || key > 127)
3931 break;
3933 if (lanConfig_cursor == 2)
3935 l = strlen(lanConfig_joinname);
3936 if (l < 21)
3938 lanConfig_joinname[l+1] = 0;
3939 lanConfig_joinname[l] = key;
3943 if (key < '0' || key > '9')
3944 break;
3945 if (lanConfig_cursor == 0)
3947 l = strlen(lanConfig_portname);
3948 if (l < 5)
3950 lanConfig_portname[l+1] = 0;
3951 lanConfig_portname[l] = key;
3956 if (StartingGame && lanConfig_cursor == 2)
3958 if (key == K_UPARROW)
3959 lanConfig_cursor = 1;
3960 else
3961 lanConfig_cursor = 0;
3964 l = Q_atoi(lanConfig_portname);
3965 if (l > 65535)
3966 l = lanConfig_port;
3967 else
3968 lanConfig_port = l;
3969 sprintf(lanConfig_portname, "%u", lanConfig_port);
3972 //=============================================================================
3973 /* GAME OPTIONS MENU */
3975 typedef struct
3977 char *name;
3978 char *description;
3979 } level_t;
3981 level_t levels[] =
3983 {"start", "Entrance"}, // 0
3985 {"e1m1", "Slipgate Complex"}, // 1
3986 {"e1m2", "Castle of the Damned"},
3987 {"e1m3", "The Necropolis"},
3988 {"e1m4", "The Grisly Grotto"},
3989 {"e1m5", "Gloom Keep"},
3990 {"e1m6", "The Door To Chthon"},
3991 {"e1m7", "The House of Chthon"},
3992 {"e1m8", "Ziggurat Vertigo"},
3994 {"e2m1", "The Installation"}, // 9
3995 {"e2m2", "Ogre Citadel"},
3996 {"e2m3", "Crypt of Decay"},
3997 {"e2m4", "The Ebon Fortress"},
3998 {"e2m5", "The Wizard's Manse"},
3999 {"e2m6", "The Dismal Oubliette"},
4000 {"e2m7", "Underearth"},
4002 {"e3m1", "Termination Central"}, // 16
4003 {"e3m2", "The Vaults of Zin"},
4004 {"e3m3", "The Tomb of Terror"},
4005 {"e3m4", "Satan's Dark Delight"},
4006 {"e3m5", "Wind Tunnels"},
4007 {"e3m6", "Chambers of Torment"},
4008 {"e3m7", "The Haunted Halls"},
4010 {"e4m1", "The Sewage System"}, // 23
4011 {"e4m2", "The Tower of Despair"},
4012 {"e4m3", "The Elder God Shrine"},
4013 {"e4m4", "The Palace of Hate"},
4014 {"e4m5", "Hell's Atrium"},
4015 {"e4m6", "The Pain Maze"},
4016 {"e4m7", "Azure Agony"},
4017 {"e4m8", "The Nameless City"},
4019 {"end", "Shub-Niggurath's Pit"}, // 31
4021 {"dm1", "Place of Two Deaths"}, // 32
4022 {"dm2", "Claustrophobopolis"},
4023 {"dm3", "The Abandoned Base"},
4024 {"dm4", "The Bad Place"},
4025 {"dm5", "The Cistern"},
4026 {"dm6", "The Dark Zone"}
4029 level_t kuroklevels[] =
4031 {"start", "Entrance"}, // 0
4032 {"e1m1", "Base Entrance"},
4033 {"e1m2", "Base"},
4034 {"e1m3", "Canyon Testing Grounds"},
4035 {"e1m4", "Cavern Testing Grounds"},
4036 {"e1m5", "Underground Base"},
4037 {"e1m6", "Experiment Rex"},
4038 {"e1m7", "Escape"},
4040 {"kdm1", "Canyon Arena"}, // 8
4041 {"kdm2", "Base Arena"},
4042 {"kdm3", "Ruins Arena"},
4043 {"kdm4", "GE: Complex"},
4044 {"kdm5", "RF: Lobby"},
4045 {"kdm6", "HL:Crossfire"},
4046 {"kdm7", "PD: Area 52"}
4049 //MED 01/06/97 added hipnotic levels
4050 level_t hipnoticlevels[] =
4052 {"start", "Command HQ"}, // 0
4054 {"hip1m1", "The Pumping Station"}, // 1
4055 {"hip1m2", "Storage Facility"},
4056 {"hip1m3", "The Lost Mine"},
4057 {"hip1m4", "Research Facility"},
4058 {"hip1m5", "Military Complex"},
4060 {"hip2m1", "Ancient Realms"}, // 6
4061 {"hip2m2", "The Black Cathedral"},
4062 {"hip2m3", "The Catacombs"},
4063 {"hip2m4", "The Crypt"},
4064 {"hip2m5", "Mortum's Keep"},
4065 {"hip2m6", "The Gremlin's Domain"},
4067 {"hip3m1", "Tur Torment"}, // 12
4068 {"hip3m2", "Pandemonium"},
4069 {"hip3m3", "Limbo"},
4070 {"hip3m4", "The Gauntlet"},
4072 {"hipend", "Armagon's Lair"}, // 16
4074 {"hipdm1", "The Edge of Oblivion"} // 17
4077 //PGM 01/07/97 added rogue levels
4078 //PGM 03/02/97 added dmatch level
4079 level_t roguelevels[] =
4081 {"start", "Split Decision"},
4082 {"r1m1", "Deviant's Domain"},
4083 {"r1m2", "Dread Portal"},
4084 {"r1m3", "Judgement Call"},
4085 {"r1m4", "Cave of Death"},
4086 {"r1m5", "Towers of Wrath"},
4087 {"r1m6", "Temple of Pain"},
4088 {"r1m7", "Tomb of the Overlord"},
4089 {"r2m1", "Tempus Fugit"},
4090 {"r2m2", "Elemental Fury I"},
4091 {"r2m3", "Elemental Fury II"},
4092 {"r2m4", "Curse of Osiris"},
4093 {"r2m5", "Wizard's Keep"},
4094 {"r2m6", "Blood Sacrifice"},
4095 {"r2m7", "Last Bastion"},
4096 {"r2m8", "Source of Evil"},
4097 {"ctf1", "Division of Change"}
4100 typedef struct
4102 char *description;
4103 int firstLevel;
4104 int levels;
4105 } episode_t;
4107 episode_t episodes[] =
4109 {"Welcome to Quake", 0, 1},
4110 {"Doomed Dimension", 1, 8},
4111 {"Realm of Black Magic", 9, 7},
4112 {"Netherworld", 16, 7},
4113 {"The Elder World", 23, 8},
4114 {"Final Level", 31, 1},
4115 {"Deathmatch Arena", 32, 6}
4118 episode_t kurokepisodes[] =
4120 {"Kurok Hub", 0, 1},
4121 {"Jungle Base Chapter", 1, 7},
4122 {"Kurok Arena", 8, 7}
4125 //MED 01/06/97 added hipnotic episodes
4126 episode_t hipnoticepisodes[] =
4128 {"Scourge of Armagon", 0, 1},
4129 {"Fortress of the Dead", 1, 5},
4130 {"Dominion of Darkness", 6, 6},
4131 {"The Rift", 12, 4},
4132 {"Final Level", 16, 1},
4133 {"Deathmatch Arena", 17, 1}
4136 //PGM 01/07/97 added rogue episodes
4137 //PGM 03/02/97 added dmatch episode
4138 episode_t rogueepisodes[] =
4140 {"Introduction", 0, 1},
4141 {"Hell's Fortress", 1, 7},
4142 {"Corridors of Time", 8, 8},
4143 {"Deathmatch Arena", 16, 1}
4146 int startepisode;
4147 int startlevel;
4148 int maxplayers;
4149 qboolean m_serverInfoMessage = false;
4150 double m_serverInfoMessageTime;
4152 void M_Menu_GameOptions_f (void)
4154 key_dest = key_menu;
4155 m_state = m_gameoptions;
4156 m_entersound = true;
4157 if (maxplayers == 0)
4158 maxplayers = svs.maxclients;
4159 if (maxplayers < 2)
4160 maxplayers = svs.maxclientslimit;
4163 int gameoptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 104, 112, 144, 152};
4164 int gameoptions_cursor_tablek[] = {40, 56, 64, 72, 80, 88, 96, 104, 112, 128, 144, 152};
4165 #define NUM_GAMEOPTIONS 11
4166 #define NUM_KGAMEOPTIONS 12
4167 int gameoptions_cursor;
4169 void M_GameOptions_Draw (void)
4171 qpic_t *p,*b;
4172 int x;
4173 // int r;
4175 if (kurok)
4176 // line cursor
4177 M_DrawCharacter (144, gameoptions_cursor_tablek[gameoptions_cursor], 12+((int)(realtime*30)&1));
4178 else
4180 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
4181 // line cursor
4182 M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
4185 b = Draw_CachePic ("gfx/m_bttns.lmp");
4186 M_DrawPic ( (320-b->width)/2, 248, b );
4187 p = Draw_CachePic ("gfx/p_multi.lmp");
4188 M_DrawPic ( (320-p->width)/2, 4, p);
4190 M_DrawTextBox (152, 32, 10, 1);
4191 M_PrintWhite (160, 40, "begin game");
4193 M_PrintWhite (0, 56, " Max players");
4194 M_Print (160, 56, va("%i", maxplayers) );
4196 M_PrintWhite (0, 64, " Game Type");
4197 if (coop.value)
4198 M_Print (160, 64, "Cooperative");
4199 else
4200 M_Print (160, 64, "Deathmatch");
4202 M_PrintWhite (0, 72, " Teamplay");
4203 if (rogue)
4205 char *msg;
4207 switch((int)teamplay.value)
4209 case 1: msg = "No Friendly Fire"; break;
4210 case 2: msg = "Friendly Fire"; break;
4211 case 3: msg = "Tag"; break;
4212 case 4: msg = "Capture the Flag"; break;
4213 case 5: msg = "One Flag CTF"; break;
4214 case 6: msg = "Three Team CTF"; break;
4215 default: msg = "Off"; break;
4217 M_Print (160, 72, msg);
4219 else
4221 char *msg;
4223 switch((int)teamplay.value)
4225 case 1: msg = "No Friendly Fire"; break;
4226 case 2: msg = "Friendly Fire"; break;
4227 default: msg = "Off"; break;
4229 M_Print (160, 72, msg);
4232 M_PrintWhite (0, 80, " Skill");
4233 if (skill.value == 0)
4234 M_Print (160, 80, "Easy difficulty");
4235 else if (skill.value == 1)
4236 M_Print (160, 80, "Normal difficulty");
4237 else if (skill.value == 2)
4238 M_Print (160, 80, "Hard difficulty");
4239 else
4241 if (kurok)
4242 M_Print (160, 80, "Insane difficulty");
4243 else
4244 M_Print (160, 80, "Nightmare difficulty");
4247 M_PrintWhite (0, 88, " Frag Limit");
4248 if (fraglimit.value == 0)
4249 M_Print (160, 88, "none");
4250 else
4251 M_Print (160, 88, va("%i frags", (int)fraglimit.value));
4253 M_PrintWhite (0, 96, " Time Limit");
4254 if (timelimit.value == 0)
4255 M_Print (160, 96, "none");
4256 else
4257 M_Print (160, 96, va("%i minutes", (int)timelimit.value));
4259 M_PrintWhite (0, 104, " Auto Aim");
4260 if (sv_aim.value == 1)
4261 M_Print (160, 104, "Off");
4262 else
4263 M_Print (160, 104, "On");
4265 M_PrintWhite (0, 112, " Level Exits");
4266 if (noexit.value == 1)
4267 M_Print (160, 112, "Off");
4268 else
4269 M_Print (160, 112, "On");
4271 if(kurok)
4273 M_DrawTextBox (152, 120, 18, 1);
4274 M_PrintWhite (160, 128, "Deathmatch Options");
4277 M_PrintWhite (0, 144, " Episode");
4278 //MED 01/06/97 added hipnotic episodes
4279 if (hipnotic)
4280 M_Print (160, 144, hipnoticepisodes[startepisode].description);
4281 //PGM 01/07/97 added rogue episodes
4282 else if (rogue)
4283 M_Print (160, 144, rogueepisodes[startepisode].description);
4284 else if (kurok)
4285 M_Print (160, 144, kurokepisodes[startepisode].description);
4286 else
4287 M_Print (160, 144, episodes[startepisode].description);
4289 M_PrintWhite (0, 152, " Level");
4290 //MED 01/06/97 added hipnotic episodes
4291 if (hipnotic)
4293 M_Print (160, 152, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].description);
4294 M_Print (160, 160, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name);
4296 //PGM 01/07/97 added rogue episodes
4297 else if (rogue)
4299 M_Print (160, 152, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].description);
4300 M_Print (160, 160, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name);
4302 else if (kurok)
4304 M_Print (160, 152, kuroklevels[kurokepisodes[startepisode].firstLevel + startlevel].description);
4305 M_Print (160, 160, kuroklevels[kurokepisodes[startepisode].firstLevel + startlevel].name);
4307 else
4309 M_Print (160, 152, levels[episodes[startepisode].firstLevel + startlevel].description);
4310 M_Print (160, 160, levels[episodes[startepisode].firstLevel + startlevel].name);
4313 if (m_serverInfoMessage)
4315 if ((realtime - m_serverInfoMessageTime) < 5.0)
4317 x = (320-26*8)/2;
4318 M_DrawTextBox (x, 138, 24, 4);
4319 x += 8;
4320 M_Print (x, 146, " More than 4 players ");
4321 M_Print (x, 154, " requires using command ");
4322 M_Print (x, 162, " line -listen. Use ");
4323 M_Print (x, 170, " -listen 8 for example. ");
4325 else
4327 m_serverInfoMessage = false;
4333 void M_NetStart_Change (int dir)
4335 int count;
4337 switch (gameoptions_cursor)
4339 case 1:
4340 maxplayers += dir;
4341 if (maxplayers > svs.maxclientslimit)
4343 maxplayers = svs.maxclientslimit;
4344 m_serverInfoMessage = true;
4345 m_serverInfoMessageTime = realtime;
4347 if (maxplayers < 2)
4348 maxplayers = 2;
4349 break;
4351 case 2:
4352 Cvar_SetValue ("coop", coop.value ? 0 : 1);
4353 break;
4355 case 3:
4356 if (rogue)
4357 count = 6;
4358 else
4359 count = 2;
4361 Cvar_SetValue ("teamplay", teamplay.value + dir);
4362 if (teamplay.value > count)
4363 Cvar_SetValue ("teamplay", 0);
4364 else if (teamplay.value < 0)
4365 Cvar_SetValue ("teamplay", count);
4366 break;
4368 case 4:
4369 Cvar_SetValue ("skill", skill.value + dir);
4370 if (skill.value > 3)
4371 Cvar_SetValue ("skill", 0);
4372 if (skill.value < 0)
4373 Cvar_SetValue ("skill", 3);
4374 break;
4376 case 5:
4377 Cvar_SetValue ("fraglimit", fraglimit.value + dir*10);
4378 if (fraglimit.value > 100)
4379 Cvar_SetValue ("fraglimit", 0);
4380 if (fraglimit.value < 0)
4381 Cvar_SetValue ("fraglimit", 100);
4382 break;
4384 case 6:
4385 Cvar_SetValue ("timelimit", timelimit.value + dir*5);
4386 if (timelimit.value > 60)
4387 Cvar_SetValue ("timelimit", 0);
4388 if (timelimit.value < 0)
4389 Cvar_SetValue ("timelimit", 60);
4390 break;
4392 case 7:
4393 Cvar_SetValue ("sv_aim", sv_aim.value + dir * 0.01);
4394 if (sv_aim.value > 1)
4395 Cvar_SetValue ("sv_aim", 0.99);
4396 if (sv_aim.value < 0.99)
4397 Cvar_SetValue ("sv_aim", 1);
4398 break;
4400 case 8:
4401 Cvar_SetValue ("noexit", noexit.value ? 0 : 1);
4402 break;
4404 case 9:
4405 if (kurok)
4406 break;
4408 startepisode += dir;
4409 //MED 01/06/97 added hipnotic count
4410 if (hipnotic)
4411 count = 6;
4412 //PGM 01/07/97 added rogue count
4413 //PGM 03/02/97 added 1 for dmatch episode
4414 else if (rogue)
4415 count = 4;
4416 else if (kurok)
4417 count = 3;
4418 else if (registered.value)
4419 count = 7;
4420 else
4421 count = 2;
4423 if (startepisode < 0)
4424 startepisode = count - 1;
4426 if (startepisode >= count)
4427 startepisode = 0;
4429 startlevel = 0;
4430 break;
4432 case 10:
4433 if (kurok)
4435 startepisode += dir;
4436 //MED 01/06/97 added hipnotic count
4437 if (hipnotic)
4438 count = 6;
4439 //PGM 01/07/97 added rogue count
4440 //PGM 03/02/97 added 1 for dmatch episode
4441 else if (rogue)
4442 count = 4;
4443 else if (kurok)
4444 count = 3;
4445 else if (registered.value)
4446 count = 7;
4447 else
4448 count = 2;
4450 if (startepisode < 0)
4451 startepisode = count - 1;
4453 if (startepisode >= count)
4454 startepisode = 0;
4456 startlevel = 0;
4457 break;
4459 else
4461 startlevel += dir;
4462 //MED 01/06/97 added hipnotic episodes
4463 if (hipnotic)
4464 count = hipnoticepisodes[startepisode].levels;
4465 //PGM 01/06/97 added hipnotic episodes
4466 else if (rogue)
4467 count = rogueepisodes[startepisode].levels;
4468 else if (kurok)
4469 count = kurokepisodes[startepisode].levels;
4470 else
4471 count = episodes[startepisode].levels;
4473 if (startlevel < 0)
4474 startlevel = count - 1;
4476 if (startlevel >= count)
4477 startlevel = 0;
4478 break;
4480 case 11:
4481 startlevel += dir;
4482 //MED 01/06/97 added hipnotic episodes
4483 if (hipnotic)
4484 count = hipnoticepisodes[startepisode].levels;
4485 //PGM 01/06/97 added hipnotic episodes
4486 else if (rogue)
4487 count = rogueepisodes[startepisode].levels;
4488 else if (kurok)
4489 count = kurokepisodes[startepisode].levels;
4490 else
4491 count = episodes[startepisode].levels;
4493 if (startlevel < 0)
4494 startlevel = count - 1;
4496 if (startlevel >= count)
4497 startlevel = 0;
4498 break;
4502 void M_GameOptions_Key (int key)
4504 switch (key)
4506 case K_ESCAPE:
4507 // M_Menu_Net_f ();
4508 M_Menu_MultiPlayer_f ();
4509 break;
4511 case K_UPARROW:
4512 S_LocalSound ("misc/menu1.wav");
4513 gameoptions_cursor--;
4514 if (kurok)
4516 if (gameoptions_cursor < 0)
4517 gameoptions_cursor = NUM_KGAMEOPTIONS-1;
4519 else
4521 if (gameoptions_cursor < 0)
4522 gameoptions_cursor = NUM_GAMEOPTIONS-1;
4524 break;
4526 case K_DOWNARROW:
4527 S_LocalSound ("misc/menu1.wav");
4528 gameoptions_cursor++;
4529 if (kurok)
4531 if (gameoptions_cursor >= NUM_KGAMEOPTIONS)
4532 gameoptions_cursor = 0;
4534 else
4536 if (gameoptions_cursor >= NUM_GAMEOPTIONS)
4537 gameoptions_cursor = 0;
4539 break;
4541 case K_LEFTARROW:
4542 if (kurok)
4544 if (gameoptions_cursor == (0 || 9))
4545 break;
4547 else
4549 if (gameoptions_cursor == 0)
4550 break;
4552 S_LocalSound ("misc/menu3.wav");
4553 M_NetStart_Change (-1);
4554 break;
4556 case K_RIGHTARROW:
4557 if (kurok)
4559 if (gameoptions_cursor == (0 || 9))
4560 break;
4562 else
4564 if (gameoptions_cursor == 0)
4565 break;
4567 S_LocalSound ("misc/menu3.wav");
4568 M_NetStart_Change (1);
4569 break;
4571 case K_ENTER:
4572 S_LocalSound ("misc/menu2.wav");
4573 if (gameoptions_cursor == 0)
4575 if (sv.active)
4576 Cbuf_AddText ("disconnect\n");
4577 Cbuf_AddText ("listen 0\n"); // so host_netport will be re-examined
4578 Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) );
4579 SCR_BeginLoadingPlaque ();
4581 if(kurok)
4582 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
4584 if (hipnotic)
4585 Cbuf_AddText ( va ("map %s\n", hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name) );
4586 else if (rogue)
4587 Cbuf_AddText ( va ("map %s\n", roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name) );
4588 else if (kurok)
4589 Cbuf_AddText ( va ("map %s\n", kuroklevels[kurokepisodes[startepisode].firstLevel + startlevel].name) );
4590 else
4591 Cbuf_AddText ( va ("map %s\n", levels[episodes[startepisode].firstLevel + startlevel].name) );
4593 return;
4596 if (kurok)
4598 if (gameoptions_cursor == 9)
4600 M_Menu_DOptions_f();
4601 break;
4605 M_NetStart_Change (1);
4606 break;
4612 ----------------------------------------------------------------------------------------------
4613 DEATHMATCH OPTIONS
4614 ----------------------------------------------------------------------------------------------
4617 int DM_RESPAWN = 1;
4618 int DM_WEAPONS_STAY = 2;
4619 int DM_PISTOLS = 4;
4620 int DM_AUTOMATICS = 8;
4621 int DM_SHOTGUNS = 16;
4622 int DM_EXPLOSIVES = 32;
4623 int DM_SNIPERS = 64;
4624 int DM_EXIT_NON_FATAL = 128;
4625 int DM_INFINITE_AMMO = 256;
4626 int DM_ALL_WEAPONS = 512;
4627 int DM_NO_RELOAD = 1024;
4628 int DM_NO_ARMOR = 2048;
4629 int DM_NO_HEALTH = 4096;
4630 int DM_ARMOR_REGEN = 8192;
4631 int DM_HEALTH_REGEN = 16384;
4632 int DM_SAFE_SPAWN = 32768;
4633 int DM_NO_BOTS = 65536;
4635 qboolean m_dOptionsInfoMessage = false;
4636 double m_dOptionsInfoMessageTime;
4638 int doptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 104, 112, 128, 136, 144, 152, 160, 168, 176, 184, 192};
4639 #define NUM_DOPTIONS 18
4640 int doptions_cursor;
4642 void M_Menu_DOptions_f (void)
4644 key_dest = key_menu;
4645 m_state = m_doptions;
4646 m_entersound = true;
4649 void M_AdjustDSliders (int dir)
4651 S_LocalSound ("misc/menu3.wav");
4653 switch (doptions_cursor)
4656 case 1: // Item Respawns
4657 if (deathmatch.value > 1)
4659 items_respawn += dir * 1;
4661 if (items_respawn < 0)
4663 items_respawn = 0;
4664 break;
4666 if (items_respawn > 1)
4668 items_respawn = 1;
4669 break;
4672 if (items_respawn == 0)
4673 deathmatch.value = deathmatch.value - DM_RESPAWN;
4674 if (items_respawn == 1)
4675 deathmatch.value = deathmatch.value + DM_RESPAWN;
4677 Cvar_SetValue ("deathmatch", deathmatch.value);
4679 else
4681 items_respawn = 1;
4682 deathmatch.value = 1;
4683 Cvar_SetValue ("deathmatch", deathmatch.value);
4685 m_dOptionsInfoMessage = true;
4686 m_dOptionsInfoMessageTime = realtime;
4688 break;
4690 case 2: // Weapon stays
4691 weapons_stay += dir * 1;
4693 if (weapons_stay < 0)
4695 weapons_stay = 0;
4696 break;
4698 if (weapons_stay > 1)
4700 weapons_stay = 1;
4701 break;
4704 if (items_respawn == 0 && (deathmatch.value <= DM_WEAPONS_STAY && weapons_stay == 0))
4706 items_respawn = 1;
4708 if (weapons_stay == 0)
4709 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_WEAPONS_STAY;
4710 if (weapons_stay == 1)
4711 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_WEAPONS_STAY;
4712 Cvar_SetValue ("deathmatch", deathmatch.value);
4713 break;
4716 if (weapons_stay == 0)
4717 deathmatch.value = deathmatch.value - DM_WEAPONS_STAY;
4718 if (weapons_stay == 1)
4719 deathmatch.value = deathmatch.value + DM_WEAPONS_STAY;
4721 Cvar_SetValue ("deathmatch", deathmatch.value);
4722 break;
4724 case 3: // Pistols
4725 pistols += dir * 1;
4727 if (pistols < 0)
4729 pistols = 0;
4730 break;
4732 if (pistols > 1)
4734 pistols = 1;
4735 break;
4738 if (items_respawn == 0 && (deathmatch.value <= DM_PISTOLS && pistols == 0))
4740 items_respawn = 1;
4742 if (pistols == 0)
4743 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_PISTOLS;
4744 if (pistols == 1)
4745 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_PISTOLS;
4746 Cvar_SetValue ("deathmatch", deathmatch.value);
4747 break;
4750 if (pistols == 0)
4751 deathmatch.value = deathmatch.value - DM_PISTOLS;
4752 if (pistols == 1)
4753 deathmatch.value = deathmatch.value + DM_PISTOLS;
4755 Cvar_SetValue ("deathmatch", deathmatch.value);
4756 break;
4758 case 4: // Automatics
4759 automatics += dir * 1;
4761 if (automatics < 0)
4763 automatics = 0;
4764 break;
4766 if (automatics > 1)
4768 automatics = 1;
4769 break;
4772 if (items_respawn == 0 && (deathmatch.value <= DM_AUTOMATICS && automatics == 0))
4774 items_respawn = 1;
4776 if (automatics == 0)
4777 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_AUTOMATICS;
4778 if (automatics == 1)
4779 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_AUTOMATICS;
4780 Cvar_SetValue ("deathmatch", deathmatch.value);
4781 break;
4784 if (automatics == 0)
4785 deathmatch.value = deathmatch.value - DM_AUTOMATICS;
4786 if (automatics == 1)
4787 deathmatch.value = deathmatch.value + DM_AUTOMATICS;
4789 Cvar_SetValue ("deathmatch", deathmatch.value);
4790 break;
4792 case 5: // Shotguns
4793 shotguns += dir * 1;
4795 if (shotguns < 0)
4797 shotguns = 0;
4798 break;
4800 if (shotguns > 1)
4802 shotguns = 1;
4803 break;
4806 if (items_respawn == 0 && (deathmatch.value <= DM_SHOTGUNS && shotguns == 0))
4808 items_respawn = 1;
4810 if (shotguns == 0)
4811 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_SHOTGUNS;
4812 if (shotguns == 1)
4813 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_SHOTGUNS;
4814 Cvar_SetValue ("deathmatch", deathmatch.value);
4815 break;
4818 if (shotguns == 0)
4819 deathmatch.value = deathmatch.value - DM_SHOTGUNS;
4820 if (shotguns == 1)
4821 deathmatch.value = deathmatch.value + DM_SHOTGUNS;
4823 Cvar_SetValue ("deathmatch", deathmatch.value);
4824 break;
4826 case 6: // Explosives
4827 explosives += dir * 1;
4829 if (explosives < 0)
4831 explosives = 0;
4832 break;
4834 if (explosives > 1)
4836 explosives = 1;
4837 break;
4840 if (items_respawn == 0 && (deathmatch.value <= DM_EXPLOSIVES && explosives == 0))
4842 items_respawn = 1;
4844 if (explosives == 0)
4845 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_EXPLOSIVES;
4846 if (explosives == 1)
4847 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_EXPLOSIVES;
4848 Cvar_SetValue ("deathmatch", deathmatch.value);
4849 break;
4852 if (explosives == 0)
4853 deathmatch.value = deathmatch.value - DM_EXPLOSIVES;
4854 if (explosives == 1)
4855 deathmatch.value = deathmatch.value + DM_EXPLOSIVES;
4857 Cvar_SetValue ("deathmatch", deathmatch.value);
4858 break;
4860 case 7: // Snipers
4861 snipers += dir * 1;
4863 if (snipers < 0)
4865 snipers = 0;
4866 break;
4868 if (snipers > 1)
4870 snipers = 1;
4871 break;
4874 if (items_respawn == 0 && (deathmatch.value <= DM_SNIPERS && snipers == 0))
4876 items_respawn = 1;
4878 if (snipers == 0)
4879 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_SNIPERS;
4880 if (snipers == 1)
4881 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_SNIPERS;
4882 Cvar_SetValue ("deathmatch", deathmatch.value);
4883 break;
4886 if (snipers == 0)
4887 deathmatch.value = deathmatch.value - DM_SNIPERS;
4888 if (snipers == 1)
4889 deathmatch.value = deathmatch.value + DM_SNIPERS;
4891 Cvar_SetValue ("deathmatch", deathmatch.value);
4892 break;
4894 case 8: // Exit non fatal
4895 exit_non_fatal += dir * 1;
4897 if (exit_non_fatal < 0)
4899 exit_non_fatal = 0;
4900 break;
4902 if (exit_non_fatal > 1)
4904 exit_non_fatal = 1;
4905 break;
4908 if (items_respawn == 0 && (deathmatch.value <= DM_EXIT_NON_FATAL && exit_non_fatal == 0))
4910 items_respawn = 1;
4912 if (exit_non_fatal == 0)
4913 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_EXIT_NON_FATAL;
4914 if (exit_non_fatal == 1)
4915 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_EXIT_NON_FATAL;
4916 Cvar_SetValue ("deathmatch", deathmatch.value);
4917 break;
4920 if (exit_non_fatal == 0)
4921 deathmatch.value = deathmatch.value - DM_EXIT_NON_FATAL;
4922 if (exit_non_fatal == 1)
4923 deathmatch.value = deathmatch.value + DM_EXIT_NON_FATAL;
4925 Cvar_SetValue ("deathmatch", deathmatch.value);
4926 break;
4928 case 9: // Infinite Ammo
4929 infinite_ammo += dir * 1;
4931 if (infinite_ammo < 0)
4933 infinite_ammo = 0;
4934 break;
4936 if (infinite_ammo > 1)
4938 infinite_ammo = 1;
4939 break;
4942 if (items_respawn == 0 && (deathmatch.value <= DM_INFINITE_AMMO && infinite_ammo == 0))
4944 items_respawn = 1;
4946 if (infinite_ammo == 0)
4947 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_INFINITE_AMMO;
4948 if (infinite_ammo == 1)
4949 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_INFINITE_AMMO;
4950 Cvar_SetValue ("deathmatch", deathmatch.value);
4951 break;
4954 if (infinite_ammo == 0)
4955 deathmatch.value = deathmatch.value - DM_INFINITE_AMMO;
4956 if (infinite_ammo == 1)
4957 deathmatch.value = deathmatch.value + DM_INFINITE_AMMO;
4959 Cvar_SetValue ("deathmatch", deathmatch.value);
4960 break;
4962 case 10: // All weapons
4963 all_weapons += dir * 1;
4965 if (all_weapons < 0)
4967 all_weapons = 0;
4968 break;
4970 if (all_weapons > 1)
4972 all_weapons = 1;
4973 break;
4976 if (items_respawn == 0 && (deathmatch.value <= DM_ALL_WEAPONS && all_weapons == 0))
4978 items_respawn = 1;
4980 if (all_weapons == 0)
4981 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_ALL_WEAPONS;
4982 if (all_weapons == 1)
4983 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_ALL_WEAPONS;
4984 Cvar_SetValue ("deathmatch", deathmatch.value);
4985 break;
4988 if (all_weapons == 0)
4989 deathmatch.value = deathmatch.value - DM_ALL_WEAPONS;
4990 if (all_weapons == 1)
4991 deathmatch.value = deathmatch.value + DM_ALL_WEAPONS;
4993 Cvar_SetValue ("deathmatch", deathmatch.value);
4994 break;
4996 case 11: // No reloading
4997 no_reload += dir * 1;
4999 if (no_reload < 0)
5001 no_reload = 0;
5002 break;
5004 if (no_reload > 1)
5006 no_reload = 1;
5007 break;
5010 if (items_respawn == 0 && (deathmatch.value <= DM_NO_RELOAD && no_reload == 0))
5012 items_respawn = 1;
5014 if (no_reload == 0)
5015 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_NO_RELOAD;
5016 if (no_reload == 1)
5017 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_NO_RELOAD;
5018 Cvar_SetValue ("deathmatch", deathmatch.value);
5019 break;
5022 if (no_reload == 0)
5023 deathmatch.value = deathmatch.value - DM_NO_RELOAD;
5024 if (no_reload == 1)
5025 deathmatch.value = deathmatch.value + DM_NO_RELOAD;
5027 Cvar_SetValue ("deathmatch", deathmatch.value);
5028 break;
5030 case 12: // No armor
5031 no_armor += dir * 1;
5033 if (no_armor < 0)
5035 no_armor = 0;
5036 break;
5038 if (no_armor > 1)
5040 no_armor = 1;
5041 break;
5044 if (items_respawn == 0 && (deathmatch.value <= DM_NO_ARMOR && no_armor == 0))
5046 items_respawn = 1;
5048 if (no_armor == 0)
5049 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_NO_ARMOR;
5050 if (no_armor == 1)
5051 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_NO_ARMOR;
5052 Cvar_SetValue ("deathmatch", deathmatch.value);
5053 break;
5056 if (no_armor == 0)
5057 deathmatch.value = deathmatch.value - DM_NO_ARMOR;
5058 if (no_armor == 1)
5059 deathmatch.value = deathmatch.value + DM_NO_ARMOR;
5061 Cvar_SetValue ("deathmatch", deathmatch.value);
5062 break;
5064 case 13: // No health
5065 no_health += dir * 1;
5067 if (no_health < 0)
5069 no_health = 0;
5070 break;
5072 if (no_health > 1)
5074 no_health = 1;
5075 break;
5078 if (items_respawn == 0 && (deathmatch.value <= DM_NO_HEALTH && no_health == 0))
5080 items_respawn = 1;
5082 if (no_health == 0)
5083 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_NO_HEALTH;
5084 if (no_health == 1)
5085 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_NO_HEALTH;
5086 Cvar_SetValue ("deathmatch", deathmatch.value);
5087 break;
5090 if (no_health == 0)
5091 deathmatch.value = deathmatch.value - DM_NO_HEALTH;
5092 if (no_health == 1)
5093 deathmatch.value = deathmatch.value + DM_NO_HEALTH;
5095 Cvar_SetValue ("deathmatch", deathmatch.value);
5096 break;
5098 case 14: // Armor regen
5099 armor_regen += dir * 1;
5101 if (armor_regen < 0)
5103 armor_regen = 0;
5104 break;
5106 if (armor_regen > 1)
5108 armor_regen = 1;
5109 break;
5112 if (items_respawn == 0 && (deathmatch.value <= DM_ARMOR_REGEN && armor_regen == 0))
5114 items_respawn = 1;
5116 if (armor_regen == 0)
5117 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_ARMOR_REGEN;
5118 if (armor_regen == 1)
5119 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_ARMOR_REGEN;
5120 Cvar_SetValue ("deathmatch", deathmatch.value);
5121 break;
5124 if (armor_regen == 0)
5125 deathmatch.value = deathmatch.value - DM_ARMOR_REGEN;
5126 if (armor_regen == 1)
5127 deathmatch.value = deathmatch.value + DM_ARMOR_REGEN;
5129 Cvar_SetValue ("deathmatch", deathmatch.value);
5130 break;
5132 case 15: // Health regen
5133 health_regen += dir * 1;
5135 if (health_regen < 0)
5137 health_regen = 0;
5138 break;
5140 if (health_regen > 1)
5142 health_regen = 1;
5143 break;
5146 if (items_respawn == 0 && (deathmatch.value <= DM_HEALTH_REGEN && health_regen == 0))
5148 items_respawn = 1;
5150 if (health_regen == 0)
5151 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_HEALTH_REGEN;
5152 if (health_regen == 1)
5153 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_HEALTH_REGEN;
5154 Cvar_SetValue ("deathmatch", deathmatch.value);
5155 break;
5158 if (health_regen == 0)
5159 deathmatch.value = deathmatch.value - DM_HEALTH_REGEN;
5160 if (health_regen == 1)
5161 deathmatch.value = deathmatch.value + DM_HEALTH_REGEN;
5163 Cvar_SetValue ("deathmatch", deathmatch.value);
5164 break;
5166 case 16: // Safe spawn
5167 safe_spawn += dir * 1;
5169 if (safe_spawn < 0)
5171 safe_spawn = 0;
5172 break;
5174 if (safe_spawn > 1)
5176 safe_spawn = 1;
5177 break;
5180 if (items_respawn == 0 && (deathmatch.value <= DM_SAFE_SPAWN && safe_spawn == 0))
5182 items_respawn = 1;
5184 if (safe_spawn == 0)
5185 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_SAFE_SPAWN;
5186 if (safe_spawn == 1)
5187 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_SAFE_SPAWN;
5188 Cvar_SetValue ("deathmatch", deathmatch.value);
5189 break;
5192 if (safe_spawn == 0)
5193 deathmatch.value = deathmatch.value - DM_SAFE_SPAWN;
5194 if (safe_spawn == 1)
5195 deathmatch.value = deathmatch.value + DM_SAFE_SPAWN;
5197 Cvar_SetValue ("deathmatch", deathmatch.value);
5198 break;
5200 case 17: // No bots
5201 no_bots += dir * 1;
5203 if (no_bots < 0)
5205 no_bots = 0;
5206 break;
5208 if (no_bots > 1)
5210 no_bots = 1;
5211 break;
5214 if (items_respawn == 0 && (deathmatch.value <= DM_NO_BOTS && no_bots == 0))
5216 items_respawn = 1;
5218 if (no_bots == 0)
5219 deathmatch.value = deathmatch.value + DM_RESPAWN - DM_NO_BOTS;
5220 if (no_bots == 1)
5221 deathmatch.value = deathmatch.value + DM_RESPAWN + DM_NO_BOTS;
5222 Cvar_SetValue ("deathmatch", deathmatch.value);
5223 break;
5226 if (no_bots == 0)
5227 deathmatch.value = deathmatch.value - DM_NO_BOTS;
5228 if (no_bots == 1)
5229 deathmatch.value = deathmatch.value + DM_NO_BOTS;
5231 Cvar_SetValue ("deathmatch", deathmatch.value);
5232 break;
5236 void M_DOptions_Draw (void)
5238 qpic_t *p;
5239 int x;
5241 if(!kurok)
5242 M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
5243 p = Draw_CachePic ("gfx/p_multi.lmp");
5244 M_DrawPic ( (320-p->width)/2, 4, p);
5246 M_DrawTextBox (152, 32, 4, 1);
5247 M_PrintWhite (160, 40, "Back");
5249 M_PrintWhite (0, 56, " Item Respawn");
5250 M_DrawCheckbox (208, 56, items_respawn == 1);
5252 M_PrintWhite (0, 64, " Weapons Stay");
5253 M_DrawCheckbox (208, 64, weapons_stay == 1);
5255 M_PrintWhite (0, 72, " Pistols Only");
5256 M_DrawCheckbox (208, 72, pistols == 1);
5258 M_PrintWhite (0, 80, " Automatics Only");
5259 M_DrawCheckbox (208, 80, automatics == 1);
5261 M_PrintWhite (0, 88, " Shotguns Only");
5262 M_DrawCheckbox (208, 88, shotguns == 1);
5264 M_PrintWhite (0, 96, " Explosives Only");
5265 M_DrawCheckbox (208, 96, explosives == 1);
5267 M_PrintWhite (0, 104, " Snipers Only");
5268 M_DrawCheckbox (208, 104, snipers == 1);
5270 M_PrintWhite (0, 112, " Exits don't kill");
5271 M_DrawCheckbox (208, 112, exit_non_fatal == 1);
5273 M_PrintWhite (0, 128, " Infinite Ammo");
5274 M_DrawCheckbox (208, 128, infinite_ammo == 1);
5276 M_PrintWhite (0, 136, " All Weapons");
5277 M_DrawCheckbox (208, 136, all_weapons == 1);
5279 M_PrintWhite (0, 144, " No Reload");
5280 M_DrawCheckbox (208, 144, no_reload == 1);
5282 M_PrintWhite (0, 152, " No Armor Items");
5283 M_DrawCheckbox (208, 152, no_armor == 1);
5285 M_PrintWhite (0, 160, " No Health Items");
5286 M_DrawCheckbox (208, 160, no_health == 1);
5288 M_PrintWhite (0, 168, " Armor Regenerates");
5289 M_DrawCheckbox (208, 168, armor_regen == 1);
5291 M_PrintWhite (0, 176, " Health Regenerates");
5292 M_DrawCheckbox (208, 176, health_regen == 1);
5294 M_PrintWhite (0, 184, " Safe Spawn");
5295 M_DrawCheckbox (208, 184, safe_spawn == 1);
5297 M_PrintWhite (0, 192, " No Bots");
5298 M_DrawCheckbox (208, 192, no_bots == 1);
5300 // line cursor
5301 if(doptions_cursor == 0)
5302 M_DrawCharacter (152, doptions_cursor_table[doptions_cursor], 12+((int)(realtime*30)&1));
5303 else
5304 M_DrawCharacter (192, doptions_cursor_table[doptions_cursor], 12+((int)(realtime*30)&1));
5307 if (m_dOptionsInfoMessage)
5309 if ((realtime - m_dOptionsInfoMessageTime) < 2.0)
5311 x = (320-26*8)/2;
5312 M_DrawTextBox (x, 138, 24, 4);
5313 x += 8;
5314 M_Print (x, 146, " Cannot turn off ");
5315 M_Print (x, 154, " item respawns if no ");
5316 M_Print (x, 162, " no other deathmatch ");
5317 M_Print (x, 170, " options are set! ");
5319 else
5321 m_dOptionsInfoMessage = false;
5326 void M_DOptions_Key (int key)
5328 switch (key)
5330 case K_ESCAPE:
5331 M_Menu_GameOptions_f();
5332 break;
5334 case K_UPARROW:
5335 S_LocalSound ("misc/menu1.wav");
5336 doptions_cursor--;
5338 if (doptions_cursor < 0)
5339 doptions_cursor = NUM_DOPTIONS-1;
5341 break;
5343 case K_DOWNARROW:
5344 S_LocalSound ("misc/menu1.wav");
5345 doptions_cursor++;
5347 if (doptions_cursor >= NUM_DOPTIONS)
5348 doptions_cursor = 0;
5350 break;
5352 case K_LEFTARROW:
5353 if (doptions_cursor == 0)
5354 break;
5355 M_AdjustDSliders (-1);
5356 break;
5358 case K_RIGHTARROW:
5359 if (doptions_cursor == 0)
5360 break;
5361 M_AdjustDSliders (1);
5362 break;
5364 case K_ENTER:
5365 S_LocalSound ("misc/menu2.wav");
5366 if (doptions_cursor == 0)
5368 M_Menu_GameOptions_f();
5369 return;
5371 M_AdjustDSliders (1);
5372 break;
5376 //=============================================================================
5377 /* SEARCH MENU */
5379 qboolean searchComplete = false;
5380 double searchCompleteTime;
5382 void M_Menu_Search_f (void)
5384 key_dest = key_menu;
5385 m_state = m_search;
5386 m_entersound = false;
5387 slistSilent = true;
5388 slistLocal = false;
5389 searchComplete = false;
5390 NET_Slist_f();
5395 void M_Search_Draw (void)
5397 qpic_t *p;
5398 int x;
5400 p = Draw_CachePic ("gfx/p_multi.lmp");
5401 M_DrawPic ( (320-p->width)/2, 4, p);
5402 x = (320/2) - ((12*8)/2) + 4;
5403 M_DrawTextBox (x-8, 32, 12, 1);
5404 M_Print (x, 40, "Searching...");
5406 if(slistInProgress)
5408 NET_Poll();
5409 return;
5412 if (! searchComplete)
5414 searchComplete = true;
5415 searchCompleteTime = realtime;
5418 if (hostCacheCount)
5420 M_Menu_ServerList_f ();
5421 return;
5424 if (kurok)
5426 M_PrintWhite ((320/2) - ((22*8)/2), 64, "No Kurok servers found");
5427 if ((realtime - searchCompleteTime) < 3.0)
5428 return;
5431 else
5433 M_PrintWhite ((320/2) - ((22*8)/2), 64, "No servers found");
5434 if ((realtime - searchCompleteTime) < 3.0)
5435 return;
5438 M_Menu_LanConfig_f ();
5442 void M_Search_Key (int key)
5446 //=============================================================================
5447 /* SLIST MENU */
5449 int slist_cursor;
5450 qboolean slist_sorted;
5452 void M_Menu_ServerList_f (void)
5454 key_dest = key_menu;
5455 m_state = m_slist;
5456 m_entersound = true;
5457 slist_cursor = 0;
5458 m_return_onerror = false;
5459 m_return_reason[0] = 0;
5460 slist_sorted = false;
5464 void M_ServerList_Draw (void)
5466 int n;
5467 char string [64];
5468 qpic_t *p;
5470 if (!slist_sorted)
5472 if (hostCacheCount > 1)
5474 int i,j;
5475 hostcache_t temp;
5476 for (i = 0; i < hostCacheCount; i++)
5477 for (j = i+1; j < hostCacheCount; j++)
5478 if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
5480 Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
5481 Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
5482 Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
5485 slist_sorted = true;
5488 if(kurok)
5489 M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*30)&1));
5490 else
5491 M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1));
5493 p = Draw_CachePic ("gfx/p_multi.lmp");
5494 M_DrawPic ( (320-p->width)/2, 4, p);
5495 for (n = 0; n < hostCacheCount; n++)
5497 if (hostcache[n].maxusers)
5498 sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
5499 else
5500 sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
5501 M_Print (16, 32 + 8*n, string);
5504 if (*m_return_reason)
5505 M_PrintWhite (16, 148, m_return_reason);
5509 void M_ServerList_Key (int k)
5511 switch (k)
5513 case K_ESCAPE:
5514 M_Menu_LanConfig_f ();
5515 break;
5517 case K_SPACE:
5518 M_Menu_Search_f ();
5519 break;
5521 case K_UPARROW:
5522 case K_LEFTARROW:
5523 S_LocalSound ("misc/menu1.wav");
5524 slist_cursor--;
5525 if (slist_cursor < 0)
5526 slist_cursor = hostCacheCount - 1;
5527 break;
5529 case K_DOWNARROW:
5530 case K_RIGHTARROW:
5531 S_LocalSound ("misc/menu1.wav");
5532 slist_cursor++;
5533 if (slist_cursor >= hostCacheCount)
5534 slist_cursor = 0;
5535 break;
5537 case K_ENTER:
5538 S_LocalSound ("misc/menu2.wav");
5539 m_return_state = m_state;
5540 m_return_onerror = true;
5541 slist_sorted = false;
5542 key_dest = key_game;
5543 m_state = m_none;
5545 // If we were in a multiplayer game, reset all the deathmatch flags to 0;
5547 items_respawn = 1;
5548 weapons_stay =
5549 pistols =
5550 automatics =
5551 shotguns =
5552 explosives =
5553 snipers =
5554 exit_non_fatal =
5555 infinite_ammo =
5556 all_weapons =
5557 no_reload =
5558 no_armor =
5559 no_health =
5560 armor_regen =
5561 health_regen =
5562 safe_spawn =
5563 no_bots = 0;
5565 if(kurok)
5566 Cbuf_AddText ("viewsize 120\n cl_gunpitch 0\n fov 90\n scr_ofsy 0\n cl_autoaim 1\n chase_active 0\n");
5568 Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
5569 break;
5571 default:
5572 break;
5577 //=============================================================================
5578 /* Menu Subsystem */
5581 void M_Init (void)
5583 Cmd_AddCommand ("togglemenu", M_ToggleMenu_f);
5585 Cmd_AddCommand ("menu_main", M_Menu_Main_f);
5586 Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f);
5587 Cmd_AddCommand ("menu_load", M_Menu_Load_f);
5588 Cmd_AddCommand ("menu_save", M_Menu_Save_f);
5589 Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
5590 Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
5591 Cmd_AddCommand ("menu_options", M_Menu_Options_f);
5592 Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
5593 Cmd_AddCommand ("menu_video", M_Menu_Video_f);
5594 Cmd_AddCommand ("help", M_Menu_Help_f);
5595 Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
5599 void M_Draw (void)
5601 if (m_state == m_none || key_dest != key_menu)
5602 return;
5604 if (!m_recursiveDraw)
5606 scr_copyeverything = 1;
5608 if (scr_con_current)
5610 Draw_ConsoleBackground (vid.height);
5611 VID_UnlockBuffer ();
5612 S_ExtraUpdate ();
5613 VID_LockBuffer ();
5615 else
5617 if (kurok)
5618 Draw_FadeScreen2 ();
5619 else
5620 Draw_FadeScreen ();
5622 scr_fullupdate = 0;
5624 else
5626 m_recursiveDraw = false;
5629 switch (m_state)
5631 case m_none:
5632 break;
5634 case m_main:
5635 M_Main_Draw ();
5636 break;
5638 case m_singleplayer:
5639 M_SinglePlayer_Draw ();
5640 break;
5642 case m_load:
5643 M_Load_Draw ();
5644 break;
5646 case m_save:
5647 M_Save_Draw ();
5648 break;
5650 case m_multiplayer:
5651 M_MultiPlayer_Draw ();
5652 break;
5654 case m_setup:
5655 M_Setup_Draw ();
5656 break;
5658 case m_net:
5659 M_Net_Draw ();
5660 break;
5662 case m_options:
5663 M_Options_Draw ();
5664 break;
5666 case m_keys:
5667 M_Keys_Draw ();
5668 break;
5670 case m_video:
5671 M_Video_Draw ();
5672 break;
5674 case m_help:
5675 M_Help_Draw ();
5676 break;
5678 case m_quit:
5679 M_Quit_Draw ();
5680 break;
5682 case m_serialconfig:
5683 M_SerialConfig_Draw ();
5684 break;
5686 case m_modemconfig:
5687 M_ModemConfig_Draw ();
5688 break;
5690 case m_lanconfig:
5691 M_LanConfig_Draw ();
5692 break;
5694 case m_gameoptions:
5695 M_GameOptions_Draw ();
5696 break;
5698 case m_doptions:
5699 M_DOptions_Draw ();
5700 break;
5702 case m_search:
5703 M_Search_Draw ();
5704 break;
5706 case m_slist:
5707 M_ServerList_Draw ();
5708 break;
5710 case m_osk:
5711 M_OSK_Draw();
5712 break;
5715 if (m_entersound)
5717 S_LocalSound ("misc/menu2.wav");
5718 m_entersound = false;
5721 VID_UnlockBuffer ();
5722 S_ExtraUpdate ();
5723 VID_LockBuffer ();
5727 void M_Keydown (int key)
5729 switch (m_state)
5731 case m_none:
5732 return;
5734 case m_main:
5735 M_Main_Key (key);
5736 return;
5738 case m_singleplayer:
5739 M_SinglePlayer_Key (key);
5740 return;
5742 case m_load:
5743 M_Load_Key (key);
5744 return;
5746 case m_save:
5747 M_Save_Key (key);
5748 return;
5750 case m_multiplayer:
5751 M_MultiPlayer_Key (key);
5752 return;
5754 case m_setup:
5755 M_Setup_Key (key);
5756 return;
5758 case m_net:
5759 M_Net_Key (key);
5760 return;
5762 case m_options:
5763 M_Options_Key (key);
5764 return;
5766 case m_keys:
5767 M_Keys_Key (key);
5768 return;
5770 case m_video:
5771 M_Video_Key (key);
5772 return;
5774 case m_help:
5775 M_Help_Key (key);
5776 return;
5778 case m_quit:
5779 M_Quit_Key (key);
5780 return;
5782 case m_serialconfig:
5783 M_SerialConfig_Key (key);
5784 return;
5786 case m_modemconfig:
5787 M_ModemConfig_Key (key);
5788 return;
5790 case m_lanconfig:
5791 M_LanConfig_Key (key);
5792 return;
5794 case m_gameoptions:
5795 M_GameOptions_Key (key);
5796 return;
5798 case m_doptions:
5799 M_DOptions_Key (key);
5800 return;
5802 case m_search:
5803 M_Search_Key (key);
5804 break;
5806 case m_slist:
5807 M_ServerList_Key (key);
5808 return;
5810 case m_osk:
5811 M_OSK_Key(key);
5816 void M_ConfigureNetSubsystem(void)
5818 // enable/disable net systems to match desired config
5820 Cbuf_AddText ("stopdemo\n");
5821 if (SerialConfig || DirectConfig)
5823 Cbuf_AddText ("com1 enable\n");
5826 if (IPXConfig || TCPIPConfig)
5827 net_hostport = lanConfig_port;