-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM_MENU.C
2919 lines (2483 loc) · 75.3 KB
/
M_MENU.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// m_menu.c :
// DOOM selection menu, options, episode etc.
// Sliders and icons. Kinda widget stuff.
//
// NOTE:
// All V_DrawPatchDirect () has been replaced by V_DrawScaledPatch ()
// so that the menu is scaled to the screen size. The scaling is always
// an integer multiple of the original size, so that the graphics look
// good.
#ifndef __WIN32__
#include <unistd.h>
#endif
#include <fcntl.h>
#include "am_map.h"
#include "doomdef.h"
#include "dstrings.h"
#include "d_main.h"
#include "console.h"
#include "r_local.h"
#include "hu_stuff.h"
#include "g_game.h"
#include "g_input.h"
#include "m_argv.h"
// Data.
#include "sounds.h"
#include "s_sound.h"
#include "i_system.h"
#include "m_menu.h"
#include "v_video.h"
#include "i_video.h"
#include "keys.h"
#include "z_zone.h"
#include "w_wad.h"
#include "p_local.h"
#include "p_fab.h"
#ifdef __WIN32__
#include "win32/hwr_main.h"
#endif
extern boolean chat_on; // in heads-up code
extern byte* whitemap; //initted by console
extern byte* graymap; //initted by console
// -1 = no quicksave slot picked!
int quickSaveSlot;
boolean menuactive;
#define SKULLXOFF -32
#define LINEHEIGHT 16
#define SMALLLINEHEIGHT 8
#define SLIDER_RANGE 10
#define SLIDER_WIDTH (8*SLIDER_RANGE+6)
// we are going to be entering a savegame string
int saveStringEnter;
int saveSlot; // which slot to save in
int saveCharIndex; // which char we're editing
// old save description before edit
char saveOldString[SAVESTRINGSIZE];
boolean inhelpscreens;
char savegamestrings[10][SAVESTRINGSIZE];
char endstring[160];
// flags for items in the menu
#define IT_TYPE 14 // (2+4+8)
#define IT_CALL 0
#define IT_ARROWS 2
#define IT_KEYHANDLER 4
#define IT_SUBMENU 6 // (2+4)
#define IT_CVAR 8
#define IT_SPACE 10
#define IT_MSGHANDLER 12
#define IT_DISPLAY (48+64) // 16+32+64
#define IT_NOTHING 0
#define IT_PATCH 16
#define IT_STRING 32
#define IT_WHITESTRING 48
#define IT_DYBIGSPACE 64
#define IT_DYLITLSPACE (16+64)
#define IT_STRING2 (32+64)
#define IT_GRAYPATCH (16+32+64)
//consvar specific
#define IT_CVARTYPE (128+256+512)
#define IT_CV_NORMAL 0
#define IT_CV_SLIDER 128
#define IT_CV_STRING 256
#define IT_CV_NOPRINT (128+256)
#define IT_CV_NOMOD 512
// in short for some common use
#define IT_BIGSPACE (IT_SPACE +IT_DYBIGSPACE)
#define IT_LITLSPACE (IT_SPACE +IT_DYLITLSPACE)
#define IT_CONTROL (IT_STRING2+IT_CALL)
#define IT_CVARMAX (IT_CVAR +IT_CV_NOMOD)
#define IT_DISABLED (IT_SPACE +IT_GRAYPATCH)
typedef union
{
struct menu_s *submenu; // IT_SUBMENU
consvar_t *cvar; // IT_CVAR
void (*routine)(int choice); // IT_CALL, IT_KEYHANDLER, IT_ARROWS
} itemaction_t;
//
// MENU TYPEDEFS
//
typedef struct menuitem_s
{
// show IT_xxx
short status;
char *name;
// FIXME: should be itemaction_t !!!
void *itemaction;
// hotkey in menu
unsigned char alphaKey;
} menuitem_t;
typedef struct menu_s
{
char *menutitlepic;
short numitems; // # of menu items
struct menu_s* prevMenu; // previous menu
menuitem_t* menuitems; // menu items
void (*drawroutine)(void); // draw routine
short x;
short y; // x,y of menu
short lastOn; // last item user was on in menu
boolean (*quitroutine)(void); // called before quit a menu return true if we can
} menu_t;
// current menudef
menu_t* currentMenu;
short itemOn; // menu item skull is on
short skullAnimCounter; // skull animation counter
short whichSkull; // which skull to draw
// graphic name of skulls
char skullName[8][9] = {"M_SKULL1","M_SKULL2","M_SKULL3","M_SKULL4","M_SKULL5","M_SKULL6","M_SKULL7","M_SKULL8"}; // Tails 9-24-99 Future anims?
//
// PROTOTYPES
//
void M_DrawSaveLoadBorder(int x,int y);
void M_SetupNextMenu(menu_t *menudef);
void M_DrawTextBox (int x, int y, int width, int lines); //added:06-02-98:
void M_DrawThermo(int x,int y,int thermWidth,int thermDot);
void M_DrawEmptyCell(menu_t *menu,int item);
void M_DrawSelCell(menu_t *menu,int item);
void M_DrawSlider (int x, int y, int range);
void M_CentreText(int y, char* string); //added:30-01-98:writetext centered
void M_StartControlPanel(void);
void M_StartMessage(char *string,void *routine,int itemtype);
void M_StopMessage(int choice);
void M_ClearMenus (void);
int M_StringHeight(char* string);
void M_GameOption(int choice);
void M_NetOption(int choice);
menu_t MainDef,SinglePlayerDef,MultiPlayerDef,SetupMultiPlayerDef,
EpiDef,NewDef,OptionsDef,VidModeDef,ControlDef,SoundDef,
ReadDef2,ReadDef1,SaveDef,LoadDef,ControlDef2,GameOptionDef,
NetOptionDef;
//===========================================================================
//Generic Stuffs (more easy to create menus :))
//===========================================================================
void M_DrawGenericMenu(void)
{
int x,y,i,cursory;
// DRAW MENU
x = currentMenu->x;
y = currentMenu->y;
// draw title (or big pic)
if( currentMenu->menutitlepic )
{
patch_t* p = W_CachePatchName(currentMenu->menutitlepic,PU_CACHE);
V_DrawScaledPatch ((BASEVIDWIDTH-p->width)/2,(y-p->height)/2,0,p);
}
for (i=0;i<currentMenu->numitems;i++)
{
if (i==itemOn)
cursory=y;
switch (currentMenu->menuitems[i].status & IT_DISPLAY) {
case IT_PATCH :
if( currentMenu->menuitems[i].name &&
currentMenu->menuitems[i].name[0] )
V_DrawScaledPatch (x,y,0,
W_CachePatchName(currentMenu->menuitems[i].name ,PU_CACHE));
case IT_DYBIGSPACE:
y += LINEHEIGHT;
break;
case IT_STRING :
V_DrawString (x,y+currentMenu->menuitems[i].alphaKey,
currentMenu->menuitems[i].name);
// Cvar specific handling
switch (currentMenu->menuitems[i].status & IT_TYPE)
case IT_CVAR:
{
consvar_t *cv=(consvar_t *)currentMenu->menuitems[i].itemaction;
switch (currentMenu->menuitems[i].status & IT_CVARTYPE) {
case IT_CV_SLIDER :
M_DrawSlider (BASEVIDWIDTH-x-SLIDER_WIDTH,
y+currentMenu->menuitems[i].alphaKey,
( (cv->value - cv->PossibleValue[0].value) * 100 /
(cv->PossibleValue[1].value - cv->PossibleValue[0].value)));
case IT_CV_NOPRINT:
break;
default:
//added:08-02-98: BIG HACK : use alphaKey member as coord y for option
V_DrawStringWhite(BASEVIDWIDTH-x-V_StringWidth (cv->string),
y+currentMenu->menuitems[i].alphaKey,
cv->string);
break;
}
break;
}
break;
case IT_STRING2:
V_DrawString (x,y,currentMenu->menuitems[i].name);
case IT_DYLITLSPACE:
y+=SMALLLINEHEIGHT;
break;
case IT_WHITESTRING :
V_DrawStringWhite (x,currentMenu->y+currentMenu->menuitems[i].alphaKey,
currentMenu->menuitems[i].name);
break;
case IT_GRAYPATCH:
if( currentMenu->menuitems[i].name &&
currentMenu->menuitems[i].name[0] )
V_DrawMappedPatch (x,y,0,
W_CachePatchName(currentMenu->menuitems[i].name ,PU_CACHE),
graymap);
y += LINEHEIGHT;
break;
}
}
// DRAW THE SKULL CURSOR
if (((currentMenu->menuitems[itemOn].status & IT_DISPLAY)==IT_PATCH)
||((currentMenu->menuitems[itemOn].status & IT_DISPLAY)==IT_NOTHING) )
{
V_DrawScaledPatch(currentMenu->x + SKULLXOFF,
currentMenu->y - 5 + itemOn*LINEHEIGHT,
0,
W_CachePatchName(skullName[whichSkull],PU_CACHE) );
}
else
if (skullAnimCounter<4) //blink cursor
{
if ((currentMenu->menuitems[itemOn].status & IT_DISPLAY)==IT_STRING2)
y=cursory;
else
y=currentMenu->y+currentMenu->menuitems[itemOn].alphaKey;
V_DrawMappedPatch(currentMenu->x - 10,
y,
0,
W_CachePatchName( "STCFN042" ,PU_CACHE),
whitemap);
}
}
//===========================================================================
//MAIN MENU
//===========================================================================
void M_QuitDOOM(int choice);
enum
{
singleplr = 0,
multiplr,
options,
readthis,
quitdoom,
main_end
} main_e;
menuitem_t MainMenu[]=
{
{IT_SUBMENU | IT_PATCH,"M_SINGLE",&SinglePlayerDef ,'s'},
{IT_SUBMENU | IT_PATCH,"M_MULTI" ,&MultiPlayerDef ,'m'},
{IT_SUBMENU | IT_PATCH,"M_OPTION",&OptionsDef ,'o'},
{IT_SUBMENU | IT_PATCH,"M_RDTHIS",&ReadDef1 ,'r'}, // Another hickup with Special edition.
{IT_CALL | IT_PATCH,"M_QUITG" ,M_QuitDOOM ,'q'}
};
menu_t MainDef =
{
"M_DOOM",
main_end,
NULL,
MainMenu,
M_DrawGenericMenu,
97,64,
0
};
//===========================================================================
//SINGLE PLAYER MENU
//===========================================================================
void M_NewGame(int choice);
void M_LoadGame(int choice);
void M_SaveGame(int choice);
void M_EndGame(int choice);
enum
{
newgame = 0,
loadgame,
savegame,
endgame,
single_end
} single_e;
menuitem_t SinglePlayerMenu[] =
{
{IT_CALL | IT_PATCH,"M_NGAME" ,M_NewGame ,'n'},
{IT_CALL | IT_PATCH,"M_LOADG" ,M_LoadGame,'l'},
{IT_CALL | IT_PATCH,"M_SAVEG" ,M_SaveGame,'s'},
{IT_CALL | IT_PATCH,"M_ENDGAM",M_EndGame ,'e'}
};
menu_t SinglePlayerDef =
{
"M_SINGLE",
single_end,
NULL,
SinglePlayerMenu,
M_DrawGenericMenu,
97,64,
0
};
//===========================================================================
// MULTI PLAYER MENU
//===========================================================================
void M_SetupMultiPlayer (int choice);
void M_SetupMultiPlayerBis (int choice);
void M_Splitscreen(int choise);
enum {
startsplitscreengame=0,
setupplayer1,
setupplayer2,
multiplayeroptions,
multiplayer_end
} multiplayer_e;
menuitem_t MultiPlayerMenu[] =
{
{IT_CALL | IT_PATCH,"M_2PLAYR",M_Splitscreen ,'n'},
{IT_CALL | IT_PATCH,"M_SETUPA",M_SetupMultiPlayer ,'s'},
{IT_CALL | IT_PATCH,"M_SETUPB",M_SetupMultiPlayerBis ,'t'},
{IT_CALL | IT_PATCH,"M_OPTTTL",M_NetOption ,'o'}
};
menu_t MultiPlayerDef =
{
"M_MULTI",
multiplayer_end, //sizeof(MultiPlayerMenu)/sizeof(menuitem_t),
NULL,
MultiPlayerMenu,
M_DrawGenericMenu,
65,64,
0
};
extern boolean StartSplitScreenGame;
void M_Splitscreen(int choise)
{
if (netgame)
{
M_StartMessage(NEWGAME,NULL,false);
return;
}
if ( gamemode == commercial )
M_SetupNextMenu(&NewDef);
else
M_SetupNextMenu(&EpiDef);
StartSplitScreenGame=true;
}
//===========================================================================
//MULTI PLAYER SETUP MENU
//===========================================================================
void M_DrawSetupMultiPlayerMenu(void);
void M_HandleSetupMultiPlayer(int choice);
void M_SetupControlsMenu(int choice);
boolean M_QuitMutliPlayerMenu(void);
menuitem_t SetupMultiPlayerMenu[] =
{
{IT_KEYHANDLER | IT_STRING ,"Your name" ,M_HandleSetupMultiPlayer,0},
{IT_CVAR | IT_STRING | IT_CV_NOPRINT,"Your color",&cv_playercolor ,16},
{IT_KEYHANDLER | IT_STRING ,"Your skin" ,M_HandleSetupMultiPlayer,96},
/* this line calls the setup controls for secondary player, only if numitems is > 3 */
{IT_CALL | IT_WHITESTRING, "Setup Controls...", M_SetupControlsMenu, 120}
};
enum {
setupmultiplayer_name = 0,
setupmultiplayer_color,
setupmultiplayer_skin,
setupmultiplayer_controls,
setupmulti_end
};
menu_t SetupMultiPlayerDef =
{
"M_MULTI",
sizeof(SetupMultiPlayerMenu)/sizeof(menuitem_t),
&MultiPlayerDef,
SetupMultiPlayerMenu,
M_DrawSetupMultiPlayerMenu,
27,40,
0,
M_QuitMutliPlayerMenu
};
#define PLBOXW 8
#define PLBOXH 9
static int multi_tics;
static state_t* multi_state;
// this is set before entering the MultiPlayer setup menu,
// for either player 1 or 2
static char setupm_name[MAXPLAYERNAME+1];
static player_t* setupm_player;
static consvar_t* setupm_cvskin;
static consvar_t* setupm_cvcolor;
static consvar_t* setupm_cvname;
void M_SetupMultiPlayer (int choice)
{
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
strcpy(setupm_name, cv_playername.string);
SetupMultiPlayerDef.numitems = setupmulti_end - 1; //remove player2 setup controls
// set for player 1
SetupMultiPlayerMenu[setupmultiplayer_color].itemaction = &cv_playercolor;
setupm_player = &players[consoleplayer];
setupm_cvskin = &cv_skin;
setupm_cvcolor = &cv_playercolor;
setupm_cvname = &cv_playername;
M_SetupNextMenu (&SetupMultiPlayerDef);
}
// start the multiplayer setup menu, for secondary player (splitscreen mode)
void M_SetupMultiPlayerBis (int choice)
{
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
strcpy (setupm_name, cv_playername2.string);
SetupMultiPlayerDef.numitems = setupmulti_end; //activate the setup controls for player 2
// set for splitscreen secondary player
SetupMultiPlayerMenu[setupmultiplayer_color].itemaction = &cv_playercolor2;
setupm_player = &players[secondarydisplayplayer];
setupm_cvskin = &cv_skin2;
setupm_cvcolor = &cv_playercolor2;
setupm_cvname = &cv_playername2;
M_SetupNextMenu (&SetupMultiPlayerDef);
}
// called at splitscreen changes
void M_SwitchSplitscreen(void)
{
// activate setup for player 2
if (cv_splitscreen.value)
MultiPlayerMenu[setupplayer2].status = IT_CALL | IT_PATCH;
else
MultiPlayerMenu[setupplayer2].status = IT_DISABLED;
if( MultiPlayerDef.lastOn==setupplayer2)
MultiPlayerDef.lastOn=setupplayer1;
}
//
// Draw the multi player setup menu, had some fun with player anim
//
void M_DrawSetupMultiPlayerMenu(void)
{
int mx,my;
spritedef_t* sprdef;
spriteframe_t* sprframe;
int lump;
patch_t* patch;
int st;
byte* colormap;
mx = SetupMultiPlayerDef.x;
my = SetupMultiPlayerDef.y;
// use generic drawer for cursor, items and title
M_DrawGenericMenu();
// draw name string
M_DrawTextBox(mx+90,my-8,MAXPLAYERNAME,1);
V_DrawString (mx+98,my,setupm_name);
// draw skin string
V_DrawString (mx+90, my+96, setupm_cvskin->string);
// draw text cursor for name
if (itemOn==0 &&
skullAnimCounter<4) //blink cursor
V_DrawMappedPatch (mx+98+V_StringWidth(setupm_name),my,0,
W_CachePatchName("STCFN095",PU_CACHE),
whitemap);
// anim the player in the box
if (--multi_tics<=0)
{
st = multi_state->nextstate;
if (st!=S_NULL)
multi_state = &states[st];
multi_tics = multi_state->tics;
if (multi_tics==-1)
multi_tics=15;
}
// skin 0 is default player sprite
sprdef = &skins[R_SkinAvailable(setupm_cvskin->string)].spritedef;
sprframe = &sprdef->spriteframes[ multi_state->frame & FF_FRAMEMASK];
lump = sprframe->lumppat[0];
patch = W_CachePatchNum (lump, PU_CACHE);
// draw box around guy
M_DrawTextBox(mx+90,my+8, PLBOXW, PLBOXH);
if (setupm_cvcolor->value==0)
colormap = colormaps;
else
colormap = (byte *) translationtables - 256 + (setupm_cvcolor->value<<8);
// draw player sprite
V_DrawMappedPatch (mx+98+(PLBOXW*8/2),my+16+(PLBOXH*8)-8,0,patch,colormap);
}
//
// Handle Setup MultiPlayer Menu
//
void M_HandleSetupMultiPlayer (int choice)
{
int l;
boolean exitmenu = false; // exit to previous menu and send name change
int myskin;
myskin = setupm_cvskin->value;
switch( choice )
{
case KEY_DOWNARROW:
S_StartSound(NULL,sfx_pstop);
if (itemOn+1 >= SetupMultiPlayerDef.numitems)
itemOn = 0;
else itemOn++;
break;
case KEY_UPARROW:
S_StartSound(NULL,sfx_pstop);
if (!itemOn)
itemOn = SetupMultiPlayerDef.numitems-1;
else itemOn--;
break;
case KEY_LEFTARROW:
if (itemOn==2) //player skin
{
S_StartSound(NULL,sfx_stnmov);
myskin--;
}
break;
case KEY_RIGHTARROW:
if (itemOn==2) //player skin
{
S_StartSound(NULL,sfx_stnmov);
myskin++;
}
break;
case KEY_ENTER:
S_StartSound(NULL,sfx_stnmov);
exitmenu = true;
break;
case KEY_ESCAPE:
S_StartSound(NULL,sfx_swtchx);
exitmenu = true;
break;
case KEY_BACKSPACE:
if ( (l=strlen(setupm_name))!=0 && itemOn==0)
{
S_StartSound(NULL,sfx_stnmov);
setupm_name[l-1]=0;
}
break;
default:
if (choice < 32 || choice > 127 || itemOn!=0)
break;
l = strlen(setupm_name);
if (l<MAXPLAYERNAME-1)
{
S_StartSound(NULL,sfx_stnmov);
setupm_name[l]=choice;
setupm_name[l+1]=0;
}
break;
}
// check skin
if (myskin <0)
myskin = numskins-1;
if (myskin >numskins-1)
myskin = 0;
// check skin change
if (myskin != setupm_player->skin)
COM_BufAddText ( va("%s \"%s\"",setupm_cvskin->name ,skins[myskin].name));
if (exitmenu)
{
if (currentMenu->prevMenu)
M_SetupNextMenu (currentMenu->prevMenu);
else
M_ClearMenus ();
}
}
boolean M_QuitMutliPlayerMenu(void)
{
int l;
// send name if changed
if (strcmp(setupm_name, setupm_cvname->string))
{
// remove trailing whitespaces
for (l= strlen(setupm_name)-1;
l>=0 && setupm_name[l]==' '; l--)
setupm_name[l]=0;
COM_BufAddText ( va("%s \"%s\"",setupm_cvname->name ,setupm_name));
}
return true;
}
//===========================================================================
// EPISODE SELECT
//===========================================================================
void M_Episode(int choice);
enum
{
ep1,
ep2,
ep3,
ep4,
ep_end
} episodes_e;
menuitem_t EpisodeMenu[]=
{
{IT_CALL | IT_PATCH,"M_EPI1", M_Episode,'k'},
{IT_CALL | IT_PATCH,"M_EPI2", M_Episode,'t'},
{IT_CALL | IT_PATCH,"M_EPI3", M_Episode,'i'},
{IT_CALL | IT_PATCH,"M_EPI4", M_Episode,'t'}
};
menu_t EpiDef =
{
"M_EPISOD",
ep_end, // # of menu items
&MainDef, // previous menu
EpisodeMenu, // menuitem_t ->
M_DrawGenericMenu, // drawing routine ->
48,63, // x,y
ep1 // lastOn, flags
};
//
// M_Episode
//
int epi;
void M_Episode(int choice)
{
if ( (gamemode == shareware)
&& choice)
{
M_SetupNextMenu(&ReadDef1);
M_StartMessage(SWSTRING,NULL,false);
return;
}
// Yet another hack...
if ( (gamemode == registered)
&& (choice > 2))
{
I_Error("M_Episode: 4th episode requires UltimateDOOM\n");
choice = 0;
}
epi = choice;
M_SetupNextMenu(&NewDef);
}
//===========================================================================
// NEW GAME FOR SINGLE PLAYER
//===========================================================================
void M_DrawNewGame(void);
void M_ChooseSkill(int choice);
enum
{
killthings,
toorough,
hurtme,
violence,
nightmare,
newg_end
} newgame_e;
menuitem_t NewGameMenu[]=
{
{IT_CALL | IT_PATCH,"M_JKILL",M_ChooseSkill, 'i'},
{IT_CALL | IT_PATCH,"M_ROUGH",M_ChooseSkill, 'h'},
{IT_CALL | IT_PATCH,"M_HURT" ,M_ChooseSkill, 'h'},
{IT_CALL | IT_PATCH,"M_ULTRA",M_ChooseSkill, 'u'},
{IT_CALL | IT_PATCH,"M_NMARE",M_ChooseSkill, 'n'}
};
menu_t NewDef =
{
"M_NEWG",
newg_end, // # of menu items
&EpiDef, // previous menu
NewGameMenu, // menuitem_t ->
M_DrawNewGame, // drawing routine ->
48,63, // x,y
violence // lastOn
};
void M_DrawNewGame(void)
{
patch_t* p;
//faB: testing with glide
p = W_CachePatchName("M_SKILL",PU_CACHE);
V_DrawScaledPatch ((BASEVIDWIDTH-p->width)/2,38,0,p);
// V_DrawScaledPatch (54,38,0,W_CachePatchName("M_SKILL",PU_CACHE));
M_DrawGenericMenu();
}
void M_NewGame(int choice)
{
if (netgame)
{
M_StartMessage(NEWGAME,NULL,false);
return;
}
if ( gamemode == commercial )
M_SetupNextMenu(&NewDef);
else
M_SetupNextMenu(&EpiDef);
}
void M_VerifyNightmare(int ch);
void M_ChooseSkill(int choice)
{
if (choice == nightmare)
{
M_StartMessage(NIGHTMARE,M_VerifyNightmare,true);
return;
}
G_DeferedInitNew(choice, G_BuildMapName(epi+1,1));
M_ClearMenus ();
}
void M_VerifyNightmare(int ch)
{
if (ch != 'y')
return;
G_DeferedInitNew (nightmare, G_BuildMapName(epi+1,1));
M_ClearMenus ();
}
//===========================================================================
// OPTIONS MENU
//===========================================================================
//
// M_Options
//
//added:10-02-98: note: alphaKey member is the y offset
menuitem_t OptionsMenu[]=
{
{IT_STRING | IT_CVAR,"Messages:" ,&cv_showmessages ,0},
{IT_STRING | IT_CVAR
| IT_CV_SLIDER ,"Screen Size" ,&cv_viewsize ,10},
{IT_STRING | IT_CVAR
| IT_CV_SLIDER ,"Brightness" ,&cv_usegamma ,20},
{IT_STRING | IT_CVAR
| IT_CV_SLIDER ,"Mouse Speed" ,&cv_mousesens ,30},
{IT_STRING | IT_CVAR,"Always Run" ,&cv_autorun ,40},
{IT_STRING | IT_CVAR,"Always MouseLook",&cv_alwaysfreelook ,50},
{IT_STRING | IT_CVAR,"Invert Mouse" ,&cv_invertmouse ,60},
{IT_STRING | IT_CVAR
| IT_CV_SLIDER ,"Mlook Speed" ,&cv_mlooksens ,70},
{IT_STRING | IT_CVAR,"Crosshair" ,&cv_crosshair ,80},
{IT_STRING | IT_CVAR,"Autoaim" ,&cv_autoaim ,90},
{IT_CALL | IT_WHITESTRING,"Game Options..." ,M_GameOption,110},
{IT_SUBMENU | IT_WHITESTRING,"Sound Volume..." ,&SoundDef ,120},
{IT_SUBMENU | IT_WHITESTRING,"Video Options..." ,&VidModeDef,130},
{IT_CALL | IT_WHITESTRING,"Setup Controls...",M_SetupControlsMenu,140}
};
menu_t OptionsDef =
{
"M_OPTTTL",
sizeof(OptionsMenu)/sizeof(menuitem_t),
&MainDef,
OptionsMenu,
M_DrawGenericMenu,
60,40,
0
};
//
// A smaller 'Thermo', with range given as percents (0-100)
//
void M_DrawSlider (int x, int y, int range)
{
int i;
if (range < 0)
range = 0;
if (range > 100)
range = 100;
V_DrawScaledPatch (x-8, y, 0, W_CachePatchName( "M_SLIDEL" ,PU_CACHE) );
for (i=0 ; i<SLIDER_RANGE ; i++)
V_DrawScaledPatch (x+i*8, y, 0,
W_CachePatchName( "M_SLIDEM" ,PU_CACHE) );
V_DrawScaledPatch (x+SLIDER_RANGE*8, y, 0,
W_CachePatchName( "M_SLIDER" ,PU_CACHE) );
// draw the slider cursor
V_DrawMappedPatch (x + ((SLIDER_RANGE-1)*8*range)/100, y, 0,
W_CachePatchName( "M_SLIDEC" ,PU_CACHE),
whitemap);
}
//===========================================================================
// Game OPTIONS MENU
//===========================================================================
menuitem_t GameOptionsMenu[]=
{
{IT_STRING | IT_CVAR,"Item Respawn" ,&cv_itemrespawn ,0},
{IT_STRING | IT_CVAR,"Item Respawn time" ,&cv_itemrespawntime ,10},
{IT_STRING | IT_CVAR,"Monster Respawn" ,&cv_respawnmonsters ,20},
{IT_STRING | IT_CVAR,"Monster Respawn time",&cv_respawnmonsterstime,30},
{IT_STRING | IT_CVAR,"Fast Monsters" ,&cv_fastmonsters ,40},
{IT_STRING | IT_CVAR,"Gravity" ,&cv_gravity ,50},
{IT_STRING | IT_CVAR,"Solid corpse" ,&cv_solidcorpse ,60},
{IT_STRING | IT_CVAR,"BloodTime" ,&cv_bloodtime ,70},
{IT_CALL | IT_WHITESTRING,"Network Options..." ,M_NetOption ,110}
};
menu_t GameOptionDef =
{
"M_OPTTTL",
sizeof(GameOptionsMenu)/sizeof(menuitem_t),
&OptionsDef,
GameOptionsMenu,
M_DrawGenericMenu,
60,40,
0
};
void M_GameOption(int choice)
{
if(!server)
{
M_StartMessage("You are not the server\nYou can't change the options\n",NULL,false);
return;
}
M_SetupNextMenu(&GameOptionDef);
}
//===========================================================================
// Network OPTIONS MENU
//===========================================================================
menuitem_t NetOptionsMenu[]=
{
{IT_STRING | IT_CVAR,"Allow Jump" ,&cv_allowjump ,0},
{IT_STRING | IT_CVAR,"Allow autoaim" ,&cv_allowautoaim ,10},
{IT_STRING | IT_CVAR,"Teamplay" ,&cv_teamplay ,20},
{IT_STRING | IT_CVAR,"TeamDamage" ,&cv_teamdamage ,30},
{IT_STRING | IT_CVAR,"Fraglimit" ,&cv_fraglimit ,40},
{IT_STRING | IT_CVAR,"Timelimit" ,&cv_timelimit ,50},
{IT_STRING | IT_CVAR,"Deathmatch Type" ,&cv_deathmatch ,60},
{IT_CALL | IT_WHITESTRING,"Games Options..." ,M_GameOption,110},
};
menu_t NetOptionDef =
{
"M_OPTTTL",
sizeof(NetOptionsMenu)/sizeof(menuitem_t),
&MultiPlayerDef,
NetOptionsMenu,
M_DrawGenericMenu,
60,40,
0
};
void M_NetOption(int choice)
{
if(!server)
{
M_StartMessage("You are not the server\nYou can't change the options\n",NULL,false);
return;
}
M_SetupNextMenu(&NetOptionDef);
}
//===========================================================================
// Read This! MENU 1
//===========================================================================
void M_DrawReadThis1(void);
void M_DrawReadThis2(void);
enum
{
rdthsempty1,
read1_end
} read_e;
menuitem_t ReadMenu1[] =
{
{IT_SUBMENU | IT_NOTHING,"",&ReadDef2,0}
};
menu_t ReadDef1 =
{
NULL,