-
Notifications
You must be signed in to change notification settings - Fork 2
/
m_menu.c
5873 lines (4954 loc) · 155 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
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id: m_menu.c,v 1.3 2000-08-12 21:29:28 fraggle Exp $
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// DESCRIPTION:
// DOOM selection menu, options, episode etc. (aka Big Font menus)
// Sliders and icons. Kinda widget stuff.
// Setup Menus.
// Extended HELP screens.
// Dynamic HELP screen.
//
//-----------------------------------------------------------------------------
static const char
rcsid[] = "$Id: m_menu.c,v 1.3 2000-08-12 21:29:28 fraggle Exp $";
#include <fcntl.h>
#include <unistd.h>
#include "doomdef.h"
#include "doomstat.h"
#include "dstrings.h"
#include "d_main.h"
#include "i_system.h"
#include "i_video.h"
#include "v_video.h"
#include "w_wad.h"
#include "r_main.h"
#include "hu_stuff.h"
#include "g_game.h"
#include "s_sound.h"
#include "sounds.h"
#include "m_menu.h"
#include "d_deh.h"
#include "m_misc.h"
extern patch_t* hu_font[HU_FONTSIZE];
extern boolean message_dontfuckwithme;
extern boolean chat_on; // in heads-up code
extern int hud_active; // in heads-up code
extern int hud_displayed; // in heads-up code
extern int hud_distributed; // in heads-up code
extern int HU_MoveHud(void); // jff 3/9/98 avoid glitch in HUD display
//
// defaulted values
//
int mouseSensitivity_horiz; // has default // killough
int mouseSensitivity_vert; // has default
int showMessages; // Show messages has default, 0 = off, 1 = on
int traditional_menu;
int hide_setup=1; // killough 5/15/98
// Blocky mode, has default, 0 = high, 1 = normal
//int detailLevel; obsolete -- killough
int screenblocks; // has default
int screenSize; // temp for screenblocks (0-9)
int quickSaveSlot; // -1 = no quicksave slot picked!
int messageToPrint; // 1 = message to be printed
char* messageString; // ...and here is the message string!
// message x & y
int messx;
int messy;
int messageLastMenuActive;
boolean messageNeedsInput; // timed message = no input from user
void (*messageRoutine)(int response);
#define SAVESTRINGSIZE 24
// killough 8/15/98: when changes are allowed to sync-critical variables
static int allow_changes(void)
{
return !(demoplayback || demorecording || netgame);
}
int warning_about_changes, print_warning_about_changes;
// 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; // indicates we are in or just left a help screen
boolean menuactive; // The menus are up
#define SKULLXOFF -32
#define LINEHEIGHT 16
#define EP_SIGIL_LINEHEIGHT 19
#define EP_SIGIL2_LINEHEIGHT 20
char savegamestrings[10][SAVESTRINGSIZE];
//
// MENU TYPEDEFS
//
typedef struct
{
short status; // 0 = no cursor here, 1 = ok, 2 = arrows ok
char name[10];
// choice = menu item #.
// if status = 2,
// choice=0:leftarrow,1:rightarrow
void (*routine)(int choice);
char alphaKey; // hotkey in menu
} menuitem_t;
typedef struct menu_s
{
short numitems; // # of menu items
struct menu_s* prevMenu; // previous menu
menuitem_t* menuitems; // menu items
void (*routine)(); // draw routine
short x;
short y; // x,y of menu
short lastOn; // last item user was on in menu
} menu_t;
short itemOn; // menu item skull is on (for Big Font menus)
short skullAnimCounter; // skull animation counter
short whichSkull; // which skull to draw (he blinks)
// graphic name of skulls
char skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"};
menu_t* currentMenu; // current menudef
// jff 3/24/98
extern int defaultskill; // config file specified skill
// killough 3/6/98: preserve autorun across games
extern int autorun; // always running?
extern int key_right;
extern int key_left;
extern int key_up;
extern int key_down;
extern int key_menu_right; // phares 3/7/98
extern int key_menu_left; // |
extern int key_menu_up; // V
extern int key_menu_down;
extern int key_menu_backspace; // ^
extern int key_menu_escape; // |
extern int key_menu_enter; // phares 3/7/98
extern int key_strafeleft;
extern int key_straferight;
extern int key_fire;
extern int key_use;
extern int key_strafe;
extern int key_speed;
extern int key_escape;
extern int key_savegame;
extern int key_loadgame;
extern int key_autorun;
extern int key_reverse;
extern int key_zoomin;
extern int key_zoomout;
extern int key_chat;
extern int key_backspace;
extern int key_enter;
extern int key_help;
extern int key_soundvolume;
extern int key_hud;
extern int key_quicksave;
extern int key_endgame;
extern int key_messages;
extern int key_quickload;
extern int key_quit;
extern int key_gamma;
extern int key_spy;
extern int key_pause;
extern int key_forward;
extern int key_leftturn;
extern int key_rightturn;
extern int key_backward;
extern int key_weapontoggle;
extern int key_weapon1;
extern int key_weapon2;
extern int key_weapon3;
extern int key_weapon4;
extern int key_weapon5;
extern int key_weapon6;
extern int key_weapon7;
extern int key_weapon8;
extern int key_weapon9;
extern int key_map_right; // phares
extern int key_map_left; // |
extern int key_map_up; // V
extern int key_map_down;
extern int key_map_zoomin;
extern int key_map_zoomout;
extern int key_map;
extern int key_map_gobig;
extern int key_map_follow;
extern int key_map_mark; // ^
extern int key_map_clear; // |
extern int key_map_grid; // phares
extern int key_screenshot; // killough 2/22/98
extern int key_setup; // killough 10/98
// phares 3/30/98
// externs added for setup menus
extern int destination_keys[MAXPLAYERS];
extern int mousebfire;
extern int mousebstrafe;
extern int mousebforward;
extern int joybfire;
extern int joybstrafe;
extern int joybuse;
extern int joybspeed;
extern int default_weapon_recoil; // weapon recoil
extern int weapon_recoil; // weapon recoil
extern int default_player_bobbing; // whether player bobs or not
extern int player_bobbing; // whether player bobs or not
extern int weapon_preferences[2][NUMWEAPONS+1];
extern int health_red; // health amount less than which status is red
extern int health_yellow; // health amount less than which status is yellow
extern int health_green; // health amount above is blue, below is green
extern int armor_red; // armor amount less than which status is red
extern int armor_yellow; // armor amount less than which status is yellow
extern int armor_green; // armor amount above is blue, below is green
extern int ammo_red; // ammo percent less than which status is red
extern int ammo_yellow; // ammo percent less is yellow more green
extern int sts_always_red;// status numbers do not change colors
extern int sts_pct_always_gray;// status percents do not change colors
extern int hud_nosecrets; // status does not list secrets/items/kills
extern int sts_traditional_keys; // display keys the traditional way
extern int hud_list_bgon; // solid window background for list of messages
extern int hud_msg_lines; // number of message lines in window up to 16
extern int hud_msg_scrollup; // killough 11/98: whether list scrolls upwards
extern int mapcolor_back; // map background
extern int mapcolor_grid; // grid lines color
extern int mapcolor_wall; // normal 1s wall color
extern int mapcolor_fchg; // line at floor height change color
extern int mapcolor_cchg; // line at ceiling height change color
extern int mapcolor_clsd; // line at sector with floor=ceiling color
extern int mapcolor_rkey; // red key color
extern int mapcolor_bkey; // blue key color
extern int mapcolor_ykey; // yellow key color
extern int mapcolor_rdor; // red door color (diff from keys to allow option)
extern int mapcolor_bdor; // blue door color (of enabling one but not other )
extern int mapcolor_ydor; // yellow door color
extern int mapcolor_tele; // teleporter line color
extern int mapcolor_secr; // secret sector boundary color
extern int mapcolor_exit; // jff 4/23/98 exit line
extern int mapcolor_unsn; // computer map unseen line color
extern int mapcolor_flat; // line with no floor/ceiling changes
extern int mapcolor_sprt; // general sprite color
extern int mapcolor_hair; // crosshair color
extern int mapcolor_sngl; // single player arrow color
extern int mapcolor_plyr[4];// colors for player arrows in multiplayer
extern int hudcolor_titl; // color range of automap level title
extern int hudcolor_xyco; // color range of new coords on automap
extern int hudcolor_mesg; // color range of scrolling messages
extern int hudcolor_chat; // color range of chat lines
extern int hudcolor_list; // color of list of past messages
extern int mapcolor_frnd; // friends colors // killough 8/8/98
extern int default_monsters_remember;
extern int monsters_remember;
extern int map_show_coordinates; // sakitoshi 2019
extern int map_point_coordinates; // killough 10/98
extern char* chat_macros[]; // chat macros
extern char *wad_files[], *deh_files[]; // killough 10/98
extern const char* shiftxform;
extern int map_secret_after; //secrets do not appear til after bagged
extern default_t defaults[];
// end of externs added for setup menus
//
// PROTOTYPES
//
void M_NewGame(int choice);
void M_Episode(int choice);
void M_ChooseSkill(int choice);
void M_LoadGame(int choice);
void M_SaveGame(int choice);
void M_Options(int choice);
void M_EndGame(int choice);
void M_ReadThis(int choice);
void M_ReadThis2(int choice);
void M_QuitDOOM(int choice);
void M_ChangeMessages(int choice);
void M_ChangeSensitivity(int choice);
void M_SfxVol(int choice);
void M_MusicVol(int choice);
/* void M_ChangeDetail(int choice); unused -- killough */
void M_SizeDisplay(int choice);
void M_StartGame(int choice);
void M_Sound(int choice);
void M_Mouse(int choice, int *sens); /* killough */
void M_MouseVert(int choice);
void M_MouseHoriz(int choice);
void M_ChangeSensitivity(int choice);
void M_DrawMouse(void);
void M_FinishReadThis(int choice);
void M_FinishHelp(int choice); // killough 10/98
void M_LoadSelect(int choice);
void M_SaveSelect(int choice);
void M_ReadSaveStrings(void);
void M_QuickSave(void);
void M_QuickLoad(void);
void M_DrawMainMenu(void);
void M_DrawReadThis1(void);
void M_DrawReadThis2(void);
void M_DrawNewGame(void);
void M_DrawEpisode(void);
void M_DrawOptions(void);
void M_DrawSound(void);
void M_DrawLoad(void);
void M_DrawSave(void);
void M_DrawSetup(void); // phares 3/21/98
void M_DrawHelp (void); // phares 5/04/98
void M_DrawCredits(void); // killough 10/98
void M_DrawSaveLoadBorder(int x,int y);
void M_SetupNextMenu(menu_t *menudef);
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_WriteText(int x, int y, char *string);
int M_StringWidth(char *string);
int M_StringHeight(char *string);
void M_StartControlPanel(void);
void M_StartMessage(char *string,void *routine,boolean input);
void M_StopMessage(void);
void M_ClearMenus (void);
// phares 3/30/98
// prototypes added to support Setup Menus and Extended HELP screens
int M_GetKeyString(int,int);
void M_Setup(int choice);
void M_KeyBindings(int choice);
void M_Weapons(int);
void M_StatusBar(int);
void M_Automap(int);
void M_Enemy(int);
void M_Messages(int);
void M_ChatStrings(int);
void M_InitExtendedHelp(void);
void M_ExtHelpNextScreen(int);
void M_ExtHelp(int);
int M_GetPixelWidth(char*);
void M_DrawKeybnd(void);
void M_DrawWeapons(void);
void M_DrawMenuString(int,int,int);
void M_DrawStatusHUD(void);
void M_DrawExtHelp(void);
void M_DrawAutoMap(void);
void M_DrawEnemy(void);
void M_DrawMessages(void);
void M_DrawChatStrings(void);
void M_Compat(int); // killough 10/98
void M_General(int); // killough 10/98
void M_DrawCompat(void); // killough 10/98
void M_DrawGeneral(void); // killough 10/98
void M_Trans(void); // killough 10/98
void M_ResetMenu(void); // killough 10/98
menu_t NewDef; // phares 5/04/98
// end of prototypes added to support Setup Menus and Extended HELP screens
static char menu_buffer[64];
/////////////////////////////////////////////////////////////////////////////
//
// DOOM MENUS
//
/////////////////////////////
//
// MAIN MENU
//
// main_e provides numerical values for which Big Font screen you're on
enum
{
newgame = 0,
loadgame,
savegame,
options,
readthis,
quitdoom,
main_end
} main_e;
//
// MainMenu is the definition of what the main menu Screen should look
// like. Each entry shows that the cursor can land on each item (1), the
// built-in graphic lump (i.e. "M_NGAME") that should be displayed,
// the program which takes over when an item is selected, and the hotkey
// associated with the item.
//
menuitem_t MainMenu[]=
{
{1,"M_NGAME", M_NewGame, 'n'},
{1,"M_LOADG", M_LoadGame,'l'},
{1,"M_SAVEG", M_SaveGame,'s'},
{1,"M_OPTION",M_Options, 'o'},
// Another hickup with Special edition.
{1,"M_RDTHIS",M_ReadThis,'r'},
{1,"M_QUITG", M_QuitDOOM,'q'}
};
menu_t MainDef =
{
main_end, // number of menu items
NULL, // previous menu screen
MainMenu, // table that defines menu items
M_DrawMainMenu, // drawing routine
97,64, // initial cursor position
0 // last menu item the user was on
};
//
// M_DrawMainMenu
//
void M_DrawMainMenu(void)
{
V_DrawPatchDirect (94,2,0,W_CacheLumpName("M_DOOM",PU_CACHE));
}
/////////////////////////////
//
// Read This! MENU 1 & 2
//
// There are no menu items on the Read This! screens, so read_e just
// provides a placeholder to maintain structure.
enum
{
rdthsempty1,
read1_end
} read_e;
enum
{
rdthsempty2,
read2_end
} read_e2;
enum // killough 10/98
{
helpempty,
help_end
} help_e;
// The definitions of the Read This! screens
menuitem_t ReadMenu1[] =
{
{1,"",M_ReadThis2,0}
};
menuitem_t ReadMenu2[]=
{
{1,"",M_FinishReadThis,0}
};
menuitem_t HelpMenu[]= // killough 10/98
{
{1,"",M_FinishHelp,0}
};
menu_t ReadDef1 =
{
read1_end,
&MainDef,
ReadMenu1,
M_DrawReadThis1,
330,175,
//280,185, // killough 2/21/98: fix help screens
0
};
menu_t ReadDef2 =
{
read2_end,
&ReadDef1,
ReadMenu2,
M_DrawReadThis2,
330,175,
0
};
menu_t HelpDef = // killough 10/98
{
help_end,
&HelpDef,
HelpMenu,
M_DrawHelp,
330,175,
0
};
//
// M_ReadThis
//
void M_ReadThis(int choice)
{
M_SetupNextMenu(&ReadDef1);
}
void M_ReadThis2(int choice)
{
M_SetupNextMenu(&ReadDef2);
}
void M_FinishReadThis(int choice)
{
M_SetupNextMenu(&MainDef);
}
void M_FinishHelp(int choice) // killough 10/98
{
M_SetupNextMenu(&MainDef);
}
//
// Read This Menus
// Had a "quick hack to fix romero bug"
//
// killough 10/98: updated with new screens
// Sakitoshi 2019: use the same screens as og doom.
void M_DrawReadThis1(void)
{
inhelpscreens = true;
if (gamemode == retail)
V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE));
else
V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE));
}
//
// Read This Menus - optional second page.
//
// killough 10/98: updated with new screens
void M_DrawReadThis2(void)
{
inhelpscreens = true;
if (gamemode != retail)
V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE));
}
/////////////////////////////
//
// EPISODE SELECT
//
//
// episodes_e provides numbers for the episode menu items. The default is
// now 6, to accomodate Sigil & Sigil II. If the user is running anything else,
// this is accounted for in the code.
//
enum
{
ep1,
ep2,
ep3,
ep4,
ep5,
ep6,
ep_end
} episodes_e;
// The definitions of the Episodes menu
menuitem_t EpisodeMenu[]=
{
{1,"M_EPI1", M_Episode,'k'},
{1,"M_EPI2", M_Episode,'t'},
{1,"M_EPI3", M_Episode,'i'},
{1,"M_EPI4", M_Episode,'t'},
{1,"M_EPI5", M_Episode,'s'},
{1,"M_EPI6", M_Episode,'s'}
};
menu_t EpiDef =
{
ep_end, // # of menu items
&MainDef, // previous menu
EpisodeMenu, // menuitem_t ->
M_DrawEpisode, // drawing routine ->
48,63, // x,y
ep1 // lastOn
};
//
// M_Episode
//
int epi;
void M_DrawEpisode(void)
{
V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_EPISOD",PU_CACHE));
}
void M_Episode(int choice)
{
if ( (gamemode == shareware) && choice)
{
M_StartMessage(s_SWSTRING,NULL,false); // Ty 03/27/98 - externalized
M_SetupNextMenu(&ReadDef1);
return;
}
// Yet another hack...
if (gamemode == registered && choice > 2)
choice = 0; // killough 8/8/98
epi = choice;
M_SetupNextMenu(&NewDef);
}
/////////////////////////////
//
// NEW GAME
//
// numerical values for the New Game menu items
enum
{
killthings,
toorough,
hurtme,
violence,
nightmare,
newg_end
} newgame_e;
// The definitions of the New Game menu
menuitem_t NewGameMenu[]=
{
{1,"M_JKILL", M_ChooseSkill, 'i'},
{1,"M_ROUGH", M_ChooseSkill, 'h'},
{1,"M_HURT", M_ChooseSkill, 'h'},
{1,"M_ULTRA", M_ChooseSkill, 'u'},
{1,"M_NMARE", M_ChooseSkill, 'n'}
};
menu_t NewDef =
{
newg_end, // # of menu items
&EpiDef, // previous menu
NewGameMenu, // menuitem_t ->
M_DrawNewGame, // drawing routine ->
48,63, // x,y
hurtme // lastOn
};
//
// M_NewGame
//
void M_DrawNewGame(void)
{
V_DrawPatchDirect (96,14,0,W_CacheLumpName("M_NEWG",PU_CACHE));
V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_SKILL",PU_CACHE));
}
void M_NewGame(int choice)
{
if (netgame && !demoplayback)
{
M_StartMessage(s_NEWGAME,NULL,false); // Ty 03/27/98 - externalized
return;
}
if (demorecording) // killough 5/26/98: exclude during demo recordings
{
M_StartMessage("you can't start a new game\n"
"while recording a demo!\n\n"PRESSKEY,
NULL, false); // killough 5/26/98: not externalized
return;
}
if ( gamemode == commercial )
M_SetupNextMenu(&NewDef);
else
M_SetupNextMenu(&EpiDef);
}
void M_VerifyNightmare(int ch)
{
if (ch != 'y')
return;
//jff 3/24/98 remember last skill selected
// killough 10/98 moved to here
defaultskill = nightmare+1;
G_DeferedInitNew(nightmare,epi+1,1);
M_ClearMenus ();
}
void M_ChooseSkill(int choice)
{
if (choice == nightmare)
{ // Ty 03/27/98 - externalized
M_StartMessage(s_NIGHTMARE,M_VerifyNightmare,true);
return;
}
//jff 3/24/98 remember last skill selected
// killough 10/98 moved to here
defaultskill = choice+1;
G_DeferedInitNew(choice,epi+1,1);
M_ClearMenus ();
}
/////////////////////////////
//
// LOAD GAME MENU
//
// numerical values for the Load Game slots
enum
{
load1,
load2,
load3,
load4,
load5,
load6,
load7, //jff 3/15/98 extend number of slots
load8,
load_end
} load_e;
// The definitions of the Load Game screen
menuitem_t LoadMenu[]=
{
{1,"", M_LoadSelect,'1'},
{1,"", M_LoadSelect,'2'},
{1,"", M_LoadSelect,'3'},
{1,"", M_LoadSelect,'4'},
{1,"", M_LoadSelect,'5'},
{1,"", M_LoadSelect,'6'},
{1,"", M_LoadSelect,'7'}, //jff 3/15/98 extend number of slots
{1,"", M_LoadSelect,'8'},
};
menu_t LoadDef =
{
load_end,
&MainDef,
LoadMenu,
M_DrawLoad,
80,34, //jff 3/15/98 move menu up
0
};
#define LOADGRAPHIC_Y 8
//
// M_LoadGame & Cie.
//
void M_DrawLoad(void)
{
int i;
//jff 3/15/98 use symbolic load position
V_DrawPatchDirect (72,LOADGRAPHIC_Y,0,W_CacheLumpName("M_LOADG",PU_CACHE));
for (i = 0 ; i < load_end ; i++)
{
M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);
M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);
}
}
//
// Draw border for the savegame description
//
void M_DrawSaveLoadBorder(int x,int y)
{
int i;
V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE));
for (i = 0 ; i < 24 ; i++)
{
V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE));
x += 8;
}
V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE));
}
//
// User wants to load this game
//
void M_LoadSelect(int choice)
{
char name[PATH_MAX+1]; // killough 3/22/98
G_SaveGameName(name,choice);
G_LoadGame(name, choice, false); // killough 3/16/98, 5/15/98: add slot, cmd
M_ClearMenus ();
}
//
// killough 5/15/98: add forced loadgames
//
static void M_VerifyForcedLoadGame(int ch)
{
if (ch=='y')
G_ForcedLoadGame();
free(messageString); // free the message strdup()'ed below
M_ClearMenus();
}
void M_ForcedLoadGame(const char *msg)
{
M_StartMessage(strdup(msg), M_VerifyForcedLoadGame, true); // free()'d above
}
//
// Selected from DOOM menu
//
void M_LoadGame (int choice)
{
if (netgame && !demoplayback) // killough 5/26/98: add !demoplayback
{
M_StartMessage(s_LOADNET,NULL,false); // Ty 03/27/98 - externalized
return;
}
if (demorecording) // killough 5/26/98: exclude during demo recordings
{
M_StartMessage("you can't load a game\n"
"while recording a demo!\n\n"PRESSKEY,
NULL, false); // killough 5/26/98: not externalized
return;
}
M_SetupNextMenu(&LoadDef);
M_ReadSaveStrings();
}
/////////////////////////////
//
// SAVE GAME MENU
//
// The definitions of the Save Game screen
menuitem_t SaveMenu[]=
{
{1,"", M_SaveSelect,'1'},
{1,"", M_SaveSelect,'2'},
{1,"", M_SaveSelect,'3'},
{1,"", M_SaveSelect,'4'},
{1,"", M_SaveSelect,'5'},
{1,"", M_SaveSelect,'6'},
{1,"", M_SaveSelect,'7'}, //jff 3/15/98 extend number of slots
{1,"", M_SaveSelect,'8'},
};
menu_t SaveDef =
{
load_end, // same number of slots as the Load Game screen
&MainDef,
SaveMenu,
M_DrawSave,
80,34, //jff 3/15/98 move menu up
0
};
//
// M_ReadSaveStrings
// read the strings from the savegame files
//
void M_ReadSaveStrings(void)
{
int i;
for (i = 0 ; i < load_end ; i++)
{
char name[PATH_MAX+1]; // killough 3/22/98
FILE *fp; // killough 11/98: change to use stdio
G_SaveGameName(name,i); // killough 3/22/98
fp = fopen(name,"rb");
if (!fp)
{ // Ty 03/27/98 - externalized:
strcpy(&savegamestrings[i][0],s_EMPTYSTRING);
LoadMenu[i].status = 0;
continue;
}
fread(&savegamestrings[i], SAVESTRINGSIZE, 1, fp);
fclose(fp);
LoadMenu[i].status = 1;
}
}
//
// M_SaveGame & Cie.
//
void M_DrawSave(void)
{
int i;
//jff 3/15/98 use symbolic load position
V_DrawPatchDirect (72,LOADGRAPHIC_Y,0,W_CacheLumpName("M_SAVEG",PU_CACHE));
for (i = 0 ; i < load_end ; i++)
{
M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);
M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);
}
if (saveStringEnter)
{
i = M_StringWidth(savegamestrings[saveSlot]);
M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_");
}
}
//
// M_Responder calls this when user is finished
//
void M_DoSave(int slot)
{
G_SaveGame (slot,savegamestrings[slot]);
M_ClearMenus ();
// PICK QUICKSAVE SLOT YET?
if (quickSaveSlot == -2)
quickSaveSlot = slot;
}
//
// User wants to save. Start string input for M_Responder
//
void M_SaveSelect(int choice)
{