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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
|
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
//
// 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.
// Sliders and icons. Kinda widget stuff.
//
//-----------------------------------------------------------------------------
#include <stdlib.h>
#include <ctype.h>
#include "doomdef.h"
#include "doomkeys.h"
#include "dstrings.h"
#include "d_main.h"
#include "deh_main.h"
#include "i_swap.h"
#include "i_system.h"
#include "i_timer.h"
#include "i_video.h"
#include "z_zone.h"
#include "v_video.h"
#include "w_wad.h"
#include "r_local.h"
#include "hu_stuff.h"
#include "g_game.h"
#include "m_argv.h"
#include "m_controls.h"
#include "m_misc.h"
#include "m_saves.h" // [STRIFE]
#include "p_saveg.h"
#include "s_sound.h"
#include "doomstat.h"
// Data.
#include "sounds.h"
#include "m_menu.h"
#include "p_dialog.h"
extern void M_QuitStrife(int);
extern patch_t* hu_font[HU_FONTSIZE];
extern boolean message_dontfuckwithme;
extern boolean chat_on; // in heads-up code
extern boolean sendsave; // [STRIFE]
//
// defaulted values
//
int mouseSensitivity = 5;
// [STRIFE]: removed this entirely
// Show messages has default, 0 = off, 1 = on
//int showMessages = 1;
// Blocky mode, has default, 0 = high, 1 = normal
int detailLevel = 0;
int screenblocks = 9;
// temp for screenblocks (0-9)
int screenSize;
// -1 = no quicksave slot picked!
int quickSaveSlot;
// 1 = message to be printed
int messageToPrint;
// ...and here is the message string!
char* messageString;
// message x & y
int messx;
int messy;
int messageLastMenuActive;
// timed message = no input from user
boolean messageNeedsInput;
void (*messageRoutine)(int response);
char gammamsg[5][26] =
{
GAMMALVL0,
GAMMALVL1,
GAMMALVL2,
GAMMALVL3,
GAMMALVL4
};
// 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;
boolean menuactive;
boolean menupause; // haleyjd 08/29/10: [STRIFE] New global
int menupausetime; // haleyjd 09/04/10: [STRIFE] New global
boolean menuindialog; // haleyjd 09/04/10: ditto
// haleyjd 08/27/10: [STRIFE] SKULLXOFF == -28, LINEHEIGHT == 19
#define CURSORXOFF -28
#define LINEHEIGHT 19
extern boolean sendpause;
char savegamestrings[10][SAVESTRINGSIZE];
char endstring[160];
// haleyjd 09/04/10: [STRIFE] Moved menuitem / menu structures into header
// because they are needed externally by the dialog engine.
// haleyjd 08/27/10: [STRIFE] skull* stuff changed to cursor* stuff
short itemOn; // menu item skull is on
short cursorAnimCounter; // skull animation counter
short whichCursor; // which skull to draw
// graphic name of cursors
// haleyjd 08/27/10: [STRIFE] M_SKULL* -> M_CURS*
char *cursorName[8] = {"M_CURS1", "M_CURS2", "M_CURS3", "M_CURS4",
"M_CURS5", "M_CURS6", "M_CURS7", "M_CURS8" };
// haleyjd 20110210 [STRIFE]: skill level for menus
int menuskill;
// current menudef
menu_t* currentMenu;
// haleyjd 03/01/13: [STRIFE] v1.31-only:
// Keeps track of whether the save game menu is being used to name a new
// character slot, or to just save the current game. In the v1.31 disassembly
// this was the new dword_8632C variable.
boolean namingCharacter;
//
// 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_ReadThis3(int choice); // [STRIFE]
//void M_ChangeMessages(int choice); [STRIFE]
void M_ChangeSensitivity(int choice);
void M_SfxVol(int choice);
void M_VoiceVol(int choice); // [STRIFE]
void M_MusicVol(int choice);
void M_SizeDisplay(int choice);
void M_StartGame(int choice);
void M_Sound(int choice);
//void M_FinishReadThis(int choice); - [STRIFE] unused
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_DrawReadThis3(void); // [STRIFE]
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_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);
int M_StringWidth(char *string);
int M_StringHeight(char *string);
void M_StartMessage(char *string,void *routine,boolean input);
void M_StopMessage(void);
//
// DOOM MENU
//
enum
{
newgame = 0,
options,
loadgame,
savegame,
readthis,
quitdoom,
main_end
} main_e;
menuitem_t MainMenu[]=
{
{1,"M_NGAME",M_NewGame,'n'},
{1,"M_OPTION",M_Options,'o'},
{1,"M_LOADG",M_LoadGame,'l'},
{1,"M_SAVEG",M_SaveGame,'s'},
// Another hickup with Special edition.
{1,"M_RDTHIS",M_ReadThis,'h'}, // haleyjd 08/28/10: 'r' -> 'h'
{1,"M_QUITG",M_QuitStrife,'q'}
};
menu_t MainDef =
{
main_end,
NULL,
MainMenu,
M_DrawMainMenu,
97,45, // haleyjd 08/28/10: [STRIFE] changed y coord
0
};
//
// EPISODE SELECT
//
/*
enum
{
ep1,
ep2,
ep3,
ep4,
ep_end
} episodes_e;
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'}
};
menu_t EpiDef =
{
ep_end, // # of menu items
&MainDef, // previous menu
EpisodeMenu, // menuitem_t ->
M_DrawEpisode, // drawing routine ->
48,63, // x,y
ep1 // lastOn
};
*/
//
// NEW GAME
//
enum
{
killthings,
toorough,
hurtme,
violence,
nightmare,
newg_end
} newgame_e;
menuitem_t NewGameMenu[]=
{
// haleyjd 08/28/10: [STRIFE] changed all shortcut letters
{1,"M_JKILL", M_ChooseSkill, 't'},
{1,"M_ROUGH", M_ChooseSkill, 'r'},
{1,"M_HURT", M_ChooseSkill, 'v'},
{1,"M_ULTRA", M_ChooseSkill, 'e'},
{1,"M_NMARE", M_ChooseSkill, 'b'}
};
menu_t NewDef =
{
newg_end, // # of menu items
&MainDef, // previous menu - haleyjd [STRIFE] changed to MainDef
NewGameMenu, // menuitem_t ->
M_DrawNewGame, // drawing routine ->
48,63, // x,y
toorough // lastOn - haleyjd [STRIFE]: default to skill 1
};
//
// OPTIONS MENU
//
enum
{
// haleyjd 08/28/10: [STRIFE] Removed messages, mouse sens., detail.
endgame,
scrnsize,
option_empty1,
soundvol,
opt_end
} options_e;
menuitem_t OptionsMenu[]=
{
// haleyjd 08/28/10: [STRIFE] Removed messages, mouse sens., detail.
{1,"M_ENDGAM", M_EndGame,'e'},
{2,"M_SCRNSZ", M_SizeDisplay,'s'},
{-1,"",0,'\0'},
{1,"M_SVOL", M_Sound,'s'}
};
menu_t OptionsDef =
{
opt_end,
&MainDef,
OptionsMenu,
M_DrawOptions,
60,37,
0
};
//
// Read This! MENU 1 & 2 & [STRIFE] 3
//
enum
{
rdthsempty1,
read1_end
} read_e;
menuitem_t ReadMenu1[] =
{
{1,"",M_ReadThis2,0}
};
menu_t ReadDef1 =
{
read1_end,
&MainDef,
ReadMenu1,
M_DrawReadThis1,
280,185,
0
};
enum
{
rdthsempty2,
read2_end
} read_e2;
menuitem_t ReadMenu2[]=
{
{1,"",M_ReadThis3,0} // haleyjd 08/28/10: [STRIFE] Go to ReadThis3
};
menu_t ReadDef2 =
{
read2_end,
&ReadDef1,
ReadMenu2,
M_DrawReadThis2,
250,185, // haleyjd 08/28/10: [STRIFE] changed coords
0
};
// haleyjd 08/28/10: Added Read This! menu 3
enum
{
rdthsempty3,
read3_end
} read_e3;
menuitem_t ReadMenu3[]=
{
{1,"",M_ClearMenus,0}
};
menu_t ReadDef3 =
{
read3_end,
&ReadDef2,
ReadMenu3,
M_DrawReadThis3,
250, 185,
0
};
//
// SOUND VOLUME MENU
//
enum
{
sfx_vol,
sfx_empty1,
music_vol,
sfx_empty2,
voice_vol,
sfx_empty3,
sfx_mouse,
sfx_empty4,
sound_end
} sound_e;
// haleyjd 08/29/10:
// [STRIFE]
// * Added voice volume
// * Moved mouse sensitivity here (who knows why...)
menuitem_t SoundMenu[]=
{
{2,"M_SFXVOL",M_SfxVol,'s'},
{-1,"",0,'\0'},
{2,"M_MUSVOL",M_MusicVol,'m'},
{-1,"",0,'\0'},
{2,"M_VOIVOL",M_VoiceVol,'v'},
{-1,"",0,'\0'},
{2,"M_MSENS",M_ChangeSensitivity,'m'},
{-1,"",0,'\0'}
};
menu_t SoundDef =
{
sound_end,
&OptionsDef,
SoundMenu,
M_DrawSound,
80,35, // [STRIFE] changed y coord 64 -> 35
0
};
//
// LOAD GAME MENU
//
enum
{
load1,
load2,
load3,
load4,
load5,
load6,
load_end
} load_e;
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'}
};
menu_t LoadDef =
{
load_end,
&MainDef,
LoadMenu,
M_DrawLoad,
80,54,
0
};
//
// SAVE GAME MENU
//
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'}
};
menu_t SaveDef =
{
load_end,
&MainDef,
SaveMenu,
M_DrawSave,
80,54,
0
};
void M_DrawNameChar(void);
//
// NAME CHARACTER MENU
//
// [STRIFE]
// haleyjd 20110210: New "Name Your Character" Menu
//
menu_t NameCharDef =
{
load_end,
&NewDef,
SaveMenu,
M_DrawNameChar,
80,54,
0
};
//
// M_ReadSaveStrings
// read the strings from the savegame files
//
// [STRIFE]
// haleyjd 20110210: Rewritten to read "name" file in each slot directory
//
void M_ReadSaveStrings(void)
{
FILE *handle;
int i;
char *fname = NULL;
for(i = 0; i < load_end; i++)
{
if(fname)
Z_Free(fname);
fname = M_SafeFilePath(savegamedir, M_MakeStrifeSaveDir(i, "\\name"));
handle = fopen(fname, "rb");
if(handle == NULL)
{
M_StringCopy(savegamestrings[i], EMPTYSTRING,
sizeof(savegamestrings[i]));
LoadMenu[i].status = 0;
continue;
}
fread(savegamestrings[i], 1, SAVESTRINGSIZE, handle);
fclose(handle);
LoadMenu[i].status = 1;
}
if(fname)
Z_Free(fname);
}
//
// M_DrawNameChar
//
// haleyjd 09/22/10: [STRIFE] New function
// Handler for drawing the "Name Your Character" menu.
//
void M_DrawNameChar(void)
{
int i;
M_WriteText(72, 28, DEH_String("Name Your Character"));
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[quickSaveSlot]);
M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*quickSaveSlot,"_");
}
}
//
// M_DoNameChar
//
// haleyjd 09/22/10: [STRIFE] New function
// Handler for items in the "Name Your Character" menu.
//
void M_DoNameChar(int choice)
{
int map;
// 20130301: clear naming character flag for 1.31 save logic
if(gameversion == exe_strife_1_31)
namingCharacter = false;
sendsave = 1;
ClearTmp();
G_WriteSaveName(choice, savegamestrings[choice]);
quickSaveSlot = choice;
SaveDef.lastOn = choice;
ClearSlot();
FromCurr();
if(isdemoversion)
map = 33;
else
map = 2;
G_DeferedInitNew(menuskill, map);
M_ClearMenus(0);
}
//
// M_LoadGame & Cie.
//
void M_DrawLoad(void)
{
int i;
V_DrawPatchDirect(72, 28,
W_CacheLumpName(DEH_String("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,
W_CacheLumpName(DEH_String("M_LSLEFT"), PU_CACHE));
for (i = 0;i < 24;i++)
{
V_DrawPatchDirect(x, y + 7,
W_CacheLumpName(DEH_String("M_LSCNTR"), PU_CACHE));
x += 8;
}
V_DrawPatchDirect(x, y + 7,
W_CacheLumpName(DEH_String("M_LSRGHT"), PU_CACHE));
}
//
// User wants to load this game
//
void M_LoadSelect(int choice)
{
// [STRIFE]: completely rewritten
char *name = NULL;
G_WriteSaveName(choice, savegamestrings[choice]);
ToCurr();
// use safe & portable filepath concatenation for Choco
name = M_SafeFilePath(savegamedir, M_MakeStrifeSaveDir(choice, ""));
G_ReadCurrent(name);
quickSaveSlot = choice;
M_ClearMenus(0);
Z_Free(name);
}
//
// Selected from DOOM menu
//
// [STRIFE] Verified unmodified
//
void M_LoadGame (int choice)
{
if (netgame)
{
M_StartMessage(DEH_String(LOADNET), NULL, false);
return;
}
M_SetupNextMenu(&LoadDef);
M_ReadSaveStrings();
}
//
// M_SaveGame & Cie.
//
void M_DrawSave(void)
{
int i;
V_DrawPatchDirect(72, 28, W_CacheLumpName(DEH_String("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[quickSaveSlot]);
M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*quickSaveSlot,"_");
}
}
//
// M_Responder calls this when user is finished
//
void M_DoSave(int slot)
{
// [STRIFE]: completely rewritten
if(slot >= 0)
{
sendsave = 1;
G_WriteSaveName(slot, savegamestrings[slot]);
M_ClearMenus(0);
quickSaveSlot = slot;
// haleyjd 20130922: slight divergence. We clear the destination slot
// of files here, which vanilla did not do. As a result, 1.31 had
// broken save behavior to the point of unusability. fraggle agrees
// this is detrimental enough to be fixed - unconditionally, for now.
ClearSlot();
FromCurr();
}
else
M_StartMessage(DEH_String(QSAVESPOT), NULL, false);
}
//
// User wants to save. Start string input for M_Responder
//
void M_SaveSelect(int choice)
{
// we are going to be intercepting all chars
saveStringEnter = 1;
// [STRIFE]
quickSaveSlot = choice;
//saveSlot = choice;
M_StringCopy(saveOldString, savegamestrings[choice], sizeof(saveOldString));
if (!strcmp(savegamestrings[choice],EMPTYSTRING))
savegamestrings[choice][0] = 0;
saveCharIndex = strlen(savegamestrings[choice]);
}
//
// Selected from DOOM menu
//
void M_SaveGame (int choice)
{
// [STRIFE]
if (netgame)
{
// haleyjd 20110211: Hooray for Rogue's awesome multiplayer support...
M_StartMessage(DEH_String("You can't save a netgame"), NULL, false);
return;
}
if (!usergame)
{
M_StartMessage(DEH_String(SAVEDEAD),NULL,false);
return;
}
if (gamestate != GS_LEVEL)
return;
// [STRIFE]
if(gameversion == exe_strife_1_31)
{
// haleyjd 20130301: in 1.31, we can choose a slot again.
M_SetupNextMenu(&SaveDef);
M_ReadSaveStrings();
}
else
{
// In 1.2 and lower, you save over your character slot exclusively
M_ReadSaveStrings();
M_DoSave(quickSaveSlot);
}
}
//
// M_QuickSave
//
char tempstring[80];
void M_QuickSaveResponse(int key)
{
if (key == key_menu_confirm)
{
M_DoSave(quickSaveSlot);
S_StartSound(NULL, sfx_mtalht); // [STRIFE] sound
}
}
void M_QuickSave(void)
{
if (netgame)
{
// haleyjd 20110211 [STRIFE]: More fun...
M_StartMessage(DEH_String("You can't save a netgame"), NULL, false);
return;
}
if (!usergame)
{
S_StartSound(NULL, sfx_oof);
return;
}
if (gamestate != GS_LEVEL)
return;
if (quickSaveSlot < 0)
{
M_StartControlPanel();
M_ReadSaveStrings();
M_SetupNextMenu(&SaveDef);
quickSaveSlot = -2; // means to pick a slot now
return;
}
DEH_snprintf(tempstring, 80, QSPROMPT, savegamestrings[quickSaveSlot]);
M_StartMessage(tempstring,M_QuickSaveResponse,true);
}
//
// M_QuickLoadResponse
//
void M_QuickLoadResponse(int key)
{
if (key == key_menu_confirm)
{
M_LoadSelect(quickSaveSlot);
S_StartSound(NULL, sfx_mtalht); // [STRIFE] sound
}
}
//
// M_QuickLoad
//
// [STRIFE] Verified unmodified
//
void M_QuickLoad(void)
{
if (netgame)
{
M_StartMessage(DEH_String(QLOADNET),NULL,false);
return;
}
if (quickSaveSlot < 0)
{
M_StartMessage(DEH_String(QSAVESPOT),NULL,false);
return;
}
DEH_snprintf(tempstring, 80, QLPROMPT, savegamestrings[quickSaveSlot]);
M_StartMessage(tempstring,M_QuickLoadResponse,true);
}
//
// Read This Menus
// Had a "quick hack to fix romero bug"
// haleyjd 08/28/10: [STRIFE] Draw HELP1, unconditionally.
//
void M_DrawReadThis1(void)
{
inhelpscreens = true;
V_DrawPatchDirect (0, 0, W_CacheLumpName(DEH_String("HELP1"), PU_CACHE));
}
//
// Read This Menus
// haleyjd 08/28/10: [STRIFE] Not optional, draws HELP2
//
void M_DrawReadThis2(void)
{
inhelpscreens = true;
V_DrawPatchDirect(0, 0, W_CacheLumpName(DEH_String("HELP2"), PU_CACHE));
}
//
// Read This Menus
// haleyjd 08/28/10: [STRIFE] New function to draw HELP3.
//
void M_DrawReadThis3(void)
{
inhelpscreens = true;
V_DrawPatchDirect(0, 0, W_CacheLumpName(DEH_String("HELP3"), PU_CACHE));
}
//
// Change Sfx & Music volumes
//
// haleyjd 08/29/10: [STRIFE]
// * Changed title graphic coordinates
// * Added voice volume and sensitivity sliders
//
void M_DrawSound(void)
{
V_DrawPatchDirect (100, 10, W_CacheLumpName(DEH_String("M_SVOL"), PU_CACHE));
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1),
16,sfxVolume);
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1),
16,musicVolume);
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(voice_vol+1),
16,voiceVolume);
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_mouse+1),
16,mouseSensitivity);
}
void M_Sound(int choice)
{
M_SetupNextMenu(&SoundDef);
}
void M_SfxVol(int choice)
{
switch(choice)
{
case 0:
if (sfxVolume)
sfxVolume--;
break;
case 1:
if (sfxVolume < 15)
sfxVolume++;
break;
}
S_SetSfxVolume(sfxVolume * 8);
}
//
// M_VoiceVol
//
// haleyjd 08/29/10: [STRIFE] New function
// Sets voice volume level.
//
void M_VoiceVol(int choice)
{
switch(choice)
{
case 0:
if (voiceVolume)
voiceVolume--;
break;
case 1:
if (voiceVolume < 15)
voiceVolume++;
break;
}
S_SetVoiceVolume(voiceVolume * 8);
}
void M_MusicVol(int choice)
{
switch(choice)
{
case 0:
if (musicVolume)
musicVolume--;
break;
case 1:
if (musicVolume < 15)
musicVolume++;
break;
}
S_SetMusicVolume(musicVolume * 8);
}
//
// M_DrawMainMenu
//
// haleyjd 08/27/10: [STRIFE] Changed x coordinate; M_DOOM -> M_STRIFE
//
void M_DrawMainMenu(void)
{
V_DrawPatchDirect(84, 2,
W_CacheLumpName(DEH_String("M_STRIFE"), PU_CACHE));
}
//
// M_NewGame
//
// haleyjd 08/31/10: [STRIFE] Changed M_NEWG -> M_NGAME
//
void M_DrawNewGame(void)
{
V_DrawPatchDirect(96, 14, W_CacheLumpName(DEH_String("M_NGAME"), PU_CACHE));
V_DrawPatchDirect(54, 38, W_CacheLumpName(DEH_String("M_SKILL"), PU_CACHE));
}
void M_NewGame(int choice)
{
if (netgame && !demoplayback)
{
M_StartMessage(DEH_String(NEWGAME),NULL,false);
return;
}
// haleyjd 09/07/10: [STRIFE] Removed Chex Quest and DOOM gamemodes
if(gameversion == exe_strife_1_31)
namingCharacter = true; // for 1.31 save logic
M_SetupNextMenu(&NewDef);
}
//
// M_Episode
//
// haleyjd: [STRIFE] Unused
/*
int epi;
void M_DrawEpisode(void)
{
V_DrawPatchDirect(54, 38, W_CacheLumpName(DEH_String("M_EPISOD"), PU_CACHE));
}
void M_VerifyNightmare(int key)
{
if (key != key_menu_confirm)
return;
G_DeferedInitNew(nightmare, 1);
M_ClearMenus (0);
}
*/
void M_ChooseSkill(int choice)
{
// haleyjd 09/07/10: Removed nightmare confirmation
// [STRIFE]: start "Name Your Character" menu
menuskill = choice;
currentMenu = &NameCharDef;
itemOn = NameCharDef.lastOn;
M_ReadSaveStrings();
}
/*
// haleyjd [STRIFE] Unused
void M_Episode(int choice)
{
if ( (gamemode == shareware)
&& choice)
{
M_StartMessage(DEH_String(SWSTRING),NULL,false);
M_SetupNextMenu(&ReadDef1);
return;
}
// Yet another hack...
if ( (gamemode == registered)
&& (choice > 2))
{
fprintf( stderr,
"M_Episode: 4th episode requires UltimateDOOM\n");
choice = 0;
}
epi = choice;
M_SetupNextMenu(&NewDef);
}
*/
//
// M_Options
//
char detailNames[2][9] = {"M_GDHIGH","M_GDLOW"};
char msgNames[2][9] = {"M_MSGOFF","M_MSGON"};
void M_DrawOptions(void)
{
// haleyjd 08/27/10: [STRIFE] M_OPTTTL -> M_OPTION
V_DrawPatchDirect(108, 15,
W_CacheLumpName(DEH_String("M_OPTION"), PU_CACHE));
// haleyjd 08/26/10: [STRIFE] Removed messages, sensitivity, detail.
M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1),
9,screenSize);
}
void M_Options(int choice)
{
M_SetupNextMenu(&OptionsDef);
}
//
// M_AutoUseHealth
//
// [STRIFE] New function
// haleyjd 20110211: toggle autouse health state
//
void M_AutoUseHealth(void)
{
if(!netgame && usergame)
{
players[consoleplayer].cheats ^= CF_AUTOHEALTH;
if(players[consoleplayer].cheats & CF_AUTOHEALTH)
players[consoleplayer].message = DEH_String("Auto use health ON");
else
players[consoleplayer].message = DEH_String("Auto use health OFF");
}
}
//
// M_ChangeShowText
//
// [STRIFE] New function
//
void M_ChangeShowText(void)
{
dialogshowtext ^= true;
if(dialogshowtext)
players[consoleplayer].message = DEH_String("Conversation Text On");
else
players[consoleplayer].message = DEH_String("Conversation Text Off");
}
//
// Toggle messages on/off
//
// [STRIFE] Messages cannot be disabled in Strife
/*
void M_ChangeMessages(int choice)
{
// warning: unused parameter `int choice'
choice = 0;
showMessages = 1 - showMessages;
if (!showMessages)
players[consoleplayer].message = DEH_String(MSGOFF);
else
players[consoleplayer].message = DEH_String(MSGON);
message_dontfuckwithme = true;
}
*/
//
// M_EndGame
//
void M_EndGameResponse(int key)
{
if (key != key_menu_confirm)
return;
currentMenu->lastOn = itemOn;
M_ClearMenus (0);
D_StartTitle ();
}
void M_EndGame(int choice)
{
choice = 0;
if (!usergame)
{
S_StartSound(NULL,sfx_oof);
return;
}
if (netgame)
{
M_StartMessage(DEH_String(NETEND),NULL,false);
return;
}
M_StartMessage(DEH_String(ENDGAME),M_EndGameResponse,true);
}
//
// M_ReadThis
//
void M_ReadThis(int choice)
{
choice = 0;
M_SetupNextMenu(&ReadDef1);
}
//
// M_ReadThis2
//
// haleyjd 08/28/10: [STRIFE] Eliminated DOOM stuff.
//
void M_ReadThis2(int choice)
{
choice = 0;
M_SetupNextMenu(&ReadDef2);
}
//
// M_ReadThis3
//
// haleyjd 08/28/10: [STRIFE] New function.
//
void M_ReadThis3(int choice)
{
choice = 0;
M_SetupNextMenu(&ReadDef3);
}
/*
// haleyjd 08/28/10: [STRIFE] Not used.
void M_FinishReadThis(int choice)
{
choice = 0;
M_SetupNextMenu(&MainDef);
}
*/
#if 0
extern void F_StartCast(void);
//
// M_CheckStartCast
//
// [STRIFE] New but unused function. Was going to start a cast
// call from within the menu system... not functional even in
// the earliest demo version.
//
void M_CheckStartCast()
{
if(usergame)
{
M_StartMessage(DEH_String("You have to end your game first."), NULL, false);
return;
}
F_StartCast();
M_ClearMenus(0);
}
#endif
//
// M_QuitResponse
//
// haleyjd 09/11/10: [STRIFE] Modifications to start up endgame
// demosequence.
//
void M_QuitResponse(int key)
{
char buffer[20];
if (key != key_menu_confirm)
return;
if(netgame)
I_Quit();
else
{
DEH_snprintf(buffer, sizeof(buffer), "qfmrm%i", gametic % 8 + 1);
I_StartVoice(buffer);
D_QuitGame();
}
}
/*
// haleyjd 09/11/10: [STRIFE] Unused
static char *M_SelectEndMessage(void)
{
}
*/
//
// M_QuitStrife
//
// [STRIFE] Renamed from M_QuitDOOM
// haleyjd 09/11/10: No randomized text message; that's taken care of
// by the randomized voice message after confirmation.
//
void M_QuitStrife(int choice)
{
DEH_snprintf(endstring, sizeof(endstring),
"Do you really want to leave?\n\n" DOSY);
M_StartMessage(endstring, M_QuitResponse, true);
}
void M_ChangeSensitivity(int choice)
{
switch(choice)
{
case 0:
if (mouseSensitivity)
mouseSensitivity--;
break;
case 1:
if (mouseSensitivity < 9)
mouseSensitivity++;
break;
}
}
/*
// haleyjd [STRIFE] Unused
void M_ChangeDetail(int choice)
{
choice = 0;
detailLevel = 1 - detailLevel;
R_SetViewSize (screenblocks, detailLevel);
if (!detailLevel)
players[consoleplayer].message = DEH_String(DETAILHI);
else
players[consoleplayer].message = DEH_String(DETAILLO);
}
*/
// [STRIFE] Verified unmodified
void M_SizeDisplay(int choice)
{
switch(choice)
{
case 0:
if (screenSize > 0)
{
screenblocks--;
screenSize--;
}
break;
case 1:
if (screenSize < 8)
{
screenblocks++;
screenSize++;
}
break;
}
R_SetViewSize (screenblocks, detailLevel);
}
//
// Menu Functions
//
//
// M_DrawThermo
//
// haleyjd 08/28/10: [STRIFE] Changes to some patch coordinates.
//
void
M_DrawThermo
( int x,
int y,
int thermWidth,
int thermDot )
{
int xx;
int yy; // [STRIFE] Needs a temp y coordinate variable
int i;
xx = x;
yy = y + 6; // [STRIFE] +6 to y coordinate
V_DrawPatchDirect(xx, yy, W_CacheLumpName(DEH_String("M_THERML"), PU_CACHE));
xx += 8;
for (i=0;i<thermWidth;i++)
{
V_DrawPatchDirect(xx, yy, W_CacheLumpName(DEH_String("M_THERMM"), PU_CACHE));
xx += 8;
}
V_DrawPatchDirect(xx, yy, W_CacheLumpName(DEH_String("M_THERMR"), PU_CACHE));
// [STRIFE] +2 to initial y coordinate
V_DrawPatchDirect((x + 8) + thermDot * 8, y + 2,
W_CacheLumpName(DEH_String("M_THERMO"), PU_CACHE));
}
// haleyjd: These are from DOOM v0.5 and the prebeta! They drew those ugly red &
// blue checkboxes... preserved for historical interest, as not in Strife.
void
M_DrawEmptyCell
( menu_t* menu,
int item )
{
V_DrawPatchDirect(menu->x - 10, menu->y + item * LINEHEIGHT - 1,
W_CacheLumpName(DEH_String("M_CELL1"), PU_CACHE));
}
void
M_DrawSelCell
( menu_t* menu,
int item )
{
V_DrawPatchDirect(menu->x - 10, menu->y + item * LINEHEIGHT - 1,
W_CacheLumpName(DEH_String("M_CELL2"), PU_CACHE));
}
void
M_StartMessage
( char* string,
void* routine,
boolean input )
{
messageLastMenuActive = menuactive;
messageToPrint = 1;
messageString = string;
messageRoutine = routine;
messageNeedsInput = input;
menuactive = true;
return;
}
void M_StopMessage(void)
{
menuactive = messageLastMenuActive;
messageToPrint = 0;
}
//
// Find string width from hu_font chars
//
int M_StringWidth(char* string)
{
size_t i;
int w = 0;
int c;
for (i = 0;i < strlen(string);i++)
{
c = toupper(string[i]) - HU_FONTSTART;
if (c < 0 || c >= HU_FONTSIZE)
w += 4;
else
w += SHORT (hu_font[c]->width);
}
return w;
}
//
// Find string height from hu_font chars
//
int M_StringHeight(char* string)
{
size_t i;
int h;
int height = SHORT(hu_font[0]->height);
h = height;
for (i = 0;i < strlen(string);i++)
if (string[i] == '\n')
h += height;
return h;
}
//
// M_WriteText
//
// Write a string using the hu_font
// haleyjd 09/04/10: [STRIFE]
// * Rogue made a lot of changes to this for the dialog system.
//
int
M_WriteText
( int x,
int y,
const char* string) // haleyjd: made const for safety w/dialog engine
{
int w;
const char* ch;
int c;
int cx;
int cy;
ch = string;
cx = x;
cy = y;
while(1)
{
c = *ch++;
if (!c)
break;
// haleyjd 09/04/10: [STRIFE] Don't draw spaces at the start of lines.
if(c == ' ' && cx == x)
continue;
if (c == '\n')
{
cx = x;
cy += 11; // haleyjd 09/04/10: [STRIFE]: Changed 12 -> 11
continue;
}
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c>= HU_FONTSIZE)
{
cx += 4;
continue;
}
w = SHORT (hu_font[c]->width);
// haleyjd 09/04/10: [STRIFE] Different linebreak handling
if (cx + w > SCREENWIDTH - 20)
{
cx = x;
cy += 11;
--ch;
}
else
{
V_DrawPatchDirect(cx, cy, hu_font[c]);
cx += w;
}
}
// [STRIFE] Return final y coordinate.
return cy + 12;
}
//
// M_DialogDimMsg
//
// [STRIFE] New function
// haleyjd 09/04/10: Painstakingly transformed from the assembly code, as the
// decompiler could not touch it. Redimensions a string to fit on screen, leaving
// at least a 20 pixel margin on the right side. The string passed in must be
// writable.
//
void M_DialogDimMsg(int x, int y, char *str, boolean useyfont)
{
int rightbound = (SCREENWIDTH - 20) - x;
patch_t **fontarray; // ebp
int linewidth = 0; // esi
int i = 0; // edx
char *message = str; // edi
char bl; // bl
if(useyfont)
fontarray = yfont;
else
fontarray = hu_font;
bl = toupper(*message);
if(!bl)
return;
// outer loop - run to end of string
do
{
if(bl != '\n')
{
int charwidth; // eax
int tempwidth; // ecx
if(bl < HU_FONTSTART || bl > HU_FONTEND)
charwidth = 4;
else
charwidth = SHORT(fontarray[bl - HU_FONTSTART]->width);
tempwidth = linewidth + charwidth;
// Test if the line still fits within the boundary...
if(tempwidth >= rightbound)
{
// Doesn't fit...
char *tempptr = &message[i]; // ebx
char al; // al
// inner loop - run backward til a space (or the start of the
// string) is found, subtracting width off the current line.
// BUG: shouldn't we stop at a previous '\n' too?
while(*tempptr != ' ' && i > 0)
{
tempptr--;
// BUG: they didn't add the first char to linewidth yet...
linewidth -= charwidth;
i--;
al = toupper(*tempptr);
if(al < HU_FONTSTART || al > HU_FONTEND)
charwidth = 4;
else
charwidth = SHORT(fontarray[al - HU_FONTSTART]->width);
}
// Replace the space with a linebreak.
// BUG: what if i is zero? ... infinite loop time!
message[i] = '\n';
linewidth = 0;
}
else
{
// The line does fit.
// Spaces at the start of a line don't count though.
if(!(bl == ' ' && linewidth == 0))
linewidth += charwidth;
}
}
else
linewidth = 0; // '\n' seen, so reset the line width
}
while((bl = toupper(message[++i])) != 0); // step to the next character
}
// These keys evaluate to a "null" key in Vanilla Doom that allows weird
// jumping in the menus. Preserve this behavior for accuracy.
static boolean IsNullKey(int key)
{
return key == KEY_PAUSE || key == KEY_CAPSLOCK
|| key == KEY_SCRLCK || key == KEY_NUMLOCK;
}
//
// CONTROL PANEL
//
//
// M_Responder
//
boolean M_Responder (event_t* ev)
{
int ch;
int key;
int i;
static int joywait = 0;
static int mousewait = 0;
static int mousey = 0;
static int lasty = 0;
static int mousex = 0;
static int lastx = 0;
// In testcontrols mode, none of the function keys should do anything
// - the only key is escape to quit.
if (testcontrols)
{
if (ev->type == ev_quit
|| (ev->type == ev_keydown
&& (ev->data1 == key_menu_activate || ev->data1 == key_menu_quit)))
{
I_Quit();
return true;
}
return false;
}
// "close" button pressed on window?
if (ev->type == ev_quit)
{
// First click on close button = bring up quit confirm message.
// Second click on close button = confirm quit
if (menuactive && messageToPrint && messageRoutine == M_QuitResponse)
{
M_QuitResponse(key_menu_confirm);
}
else
{
S_StartSound(NULL, sfx_swtchn);
M_QuitStrife(0);
}
return true;
}
// key is the key pressed, ch is the actual character typed
ch = 0;
key = -1;
if (ev->type == ev_joystick && joywait < I_GetTime())
{
if (ev->data3 < 0)
{
key = key_menu_up;
joywait = I_GetTime() + 5;
}
else if (ev->data3 > 0)
{
key = key_menu_down;
joywait = I_GetTime() + 5;
}
if (ev->data2 < 0)
{
key = key_menu_left;
joywait = I_GetTime() + 2;
}
else if (ev->data2 > 0)
{
key = key_menu_right;
joywait = I_GetTime() + 2;
}
if (ev->data1&1)
{
key = key_menu_forward;
joywait = I_GetTime() + 5;
}
if (ev->data1&2)
{
key = key_menu_back;
joywait = I_GetTime() + 5;
}
if (joybmenu >= 0 && (ev->data1 & (1 << joybmenu)) != 0)
{
key = key_menu_activate;
joywait = I_GetTime() + 5;
}
}
else
{
if (ev->type == ev_mouse && mousewait < I_GetTime())
{
mousey += ev->data3;
if (mousey < lasty-30)
{
key = key_menu_down;
mousewait = I_GetTime() + 5;
mousey = lasty -= 30;
}
else if (mousey > lasty+30)
{
key = key_menu_up;
mousewait = I_GetTime() + 5;
mousey = lasty += 30;
}
mousex += ev->data2;
if (mousex < lastx-30)
{
key = key_menu_left;
mousewait = I_GetTime() + 5;
mousex = lastx -= 30;
}
else if (mousex > lastx+30)
{
key = key_menu_right;
mousewait = I_GetTime() + 5;
mousex = lastx += 30;
}
if (ev->data1&1)
{
key = key_menu_forward;
mousewait = I_GetTime() + 15;
mouse_fire_countdown = 5; // villsa [STRIFE]
}
if (ev->data1&2)
{
key = key_menu_back;
mousewait = I_GetTime() + 15;
}
}
else
{
if (ev->type == ev_keydown)
{
key = ev->data1;
ch = ev->data2;
}
}
}
if (key == -1)
return false;
// Save Game string input
if (saveStringEnter)
{
switch(key)
{
case KEY_BACKSPACE:
if (saveCharIndex > 0)
{
saveCharIndex--;
savegamestrings[quickSaveSlot][saveCharIndex] = 0;
}
break;
case KEY_ESCAPE:
saveStringEnter = 0;
M_StringCopy(savegamestrings[quickSaveSlot], saveOldString,
sizeof(savegamestrings[quickSaveSlot]));
break;
case KEY_ENTER:
// [STRIFE]
saveStringEnter = 0;
if(gameversion == exe_strife_1_31 && !namingCharacter)
{
// In 1.31, we can be here as a result of normal saving again,
// whereas in 1.2 this only ever happens when naming your
// character to begin a new game.
M_DoSave(quickSaveSlot);
return true;
}
if (savegamestrings[quickSaveSlot][0])
M_DoNameChar(quickSaveSlot);
break;
default:
// This is complicated.
// Vanilla has a bug where the shift key is ignored when entering
// a savegame name. If vanilla_keyboard_mapping is on, we want
// to emulate this bug by using 'data1'. But if it's turned off,
// it implies the user doesn't care about Vanilla emulation: just
// use the correct 'data2'.
if (vanilla_keyboard_mapping)
{
ch = key;
}
ch = toupper(ch);
if (ch != ' '
&& (ch - HU_FONTSTART < 0 || ch - HU_FONTSTART >= HU_FONTSIZE))
{
break;
}
if (ch >= 32 && ch <= 127 &&
saveCharIndex < SAVESTRINGSIZE-1 &&
M_StringWidth(savegamestrings[quickSaveSlot]) <
(SAVESTRINGSIZE-2)*8)
{
savegamestrings[quickSaveSlot][saveCharIndex++] = ch;
savegamestrings[quickSaveSlot][saveCharIndex] = 0;
}
break;
}
return true;
}
// Take care of any messages that need input
if (messageToPrint)
{
if (messageNeedsInput)
{
if (key != ' ' && key != KEY_ESCAPE
&& key != key_menu_confirm && key != key_menu_abort)
{
return false;
}
}
menuactive = messageLastMenuActive;
messageToPrint = 0;
if (messageRoutine)
messageRoutine(key);
menupause = false; // [STRIFE] unpause
menuactive = false;
S_StartSound(NULL, sfx_mtalht); // [STRIFE] sound
return true;
}
// [STRIFE]:
// * In v1.2 this is moved to F9 (quickload)
// * In v1.31 it is moved to F12 with DM spy, and quicksave
// functionality is restored separate from normal saving
/*
if (devparm && key == key_menu_help)
{
G_ScreenShot ();
return true;
}
*/
// F-Keys
if (!menuactive)
{
if (key == key_menu_decscreen) // Screen size down
{
if (automapactive || chat_on)
return false;
M_SizeDisplay(0);
S_StartSound(NULL, sfx_stnmov);
return true;
}
else if (key == key_menu_incscreen) // Screen size up
{
if (automapactive || chat_on)
return false;
M_SizeDisplay(1);
S_StartSound(NULL, sfx_stnmov);
return true;
}
else if (key == key_menu_help) // Help key
{
M_StartControlPanel ();
// haleyjd 08/29/10: [STRIFE] always ReadDef1
currentMenu = &ReadDef1;
itemOn = 0;
S_StartSound(NULL, sfx_swtchn);
return true;
}
else if (key == key_menu_save) // Save
{
// [STRIFE]: Hub saves
if(gameversion == exe_strife_1_31)
namingCharacter = false; // just saving normally, in 1.31
if(netgame || players[consoleplayer].health <= 0 ||
players[consoleplayer].cheats & CF_ONFIRE)
{
S_StartSound(NULL, sfx_oof);
}
else
{
M_StartControlPanel();
S_StartSound(NULL, sfx_swtchn);
M_SaveGame(0);
}
return true;
}
else if (key == key_menu_load) // Load
{
// [STRIFE]: Hub saves
if(gameversion == exe_strife_1_31)
{
// 1.31: normal save loading
namingCharacter = false;
M_StartControlPanel();
M_LoadGame(0);
S_StartSound(NULL, sfx_swtchn);
}
else
{
// Pre 1.31: quickload only
S_StartSound(NULL, sfx_swtchn);
M_QuickLoad();
}
return true;
}
else if (key == key_menu_volume) // Sound Volume
{
M_StartControlPanel ();
currentMenu = &SoundDef;
itemOn = sfx_vol;
S_StartSound(NULL, sfx_swtchn);
return true;
}
else if (key == key_menu_detail) // Detail toggle
{
//M_ChangeDetail(0);
M_AutoUseHealth(); // [STRIFE]
S_StartSound(NULL, sfx_swtchn);
return true;
}
else if (key == key_menu_qsave) // Quicksave
{
// [STRIFE]: Hub saves
if(gameversion == exe_strife_1_31)
namingCharacter = false; // for 1.31 save changes
if(netgame || players[consoleplayer].health <= 0 ||
players[consoleplayer].cheats & CF_ONFIRE)
{
S_StartSound(NULL, sfx_oof);
}
else
{
S_StartSound(NULL, sfx_swtchn);
M_QuickSave();
}
return true;
}
else if (key == key_menu_endgame) // End game
{
S_StartSound(NULL, sfx_swtchn);
M_EndGame(0);
return true;
}
else if (key == key_menu_messages) // Toggle messages
{
//M_ChangeMessages(0);
M_ChangeShowText(); // [STRIFE]
S_StartSound(NULL, sfx_swtchn);
return true;
}
else if (key == key_menu_qload) // Quickload
{
// [STRIFE]
// * v1.2: takes a screenshot
// * v1.31: does quickload again
if(gameversion == exe_strife_1_31)
{
namingCharacter = false;
S_StartSound(NULL, sfx_swtchn);
M_QuickLoad();
}
else
G_ScreenShot();
return true;
}
else if (key == key_menu_quit) // Quit DOOM
{
S_StartSound(NULL, sfx_swtchn);
M_QuitStrife(0);
return true;
}
else if (key == key_menu_gamma) // gamma toggle
{
usegamma++;
if (usegamma > 4)
usegamma = 0;
players[consoleplayer].message = DEH_String(gammamsg[usegamma]);
I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE));
return true;
}
else if(gameversion == exe_strife_1_31 && key == key_spy)
{
// haleyjd 20130301: 1.31 moved screenshots to F12.
G_ScreenShot();
return true;
}
else if (key != 0 && key == key_menu_screenshot)
{
G_ScreenShot();
return true;
}
}
// Pop-up menu?
if (!menuactive)
{
if (key == key_menu_activate)
{
M_StartControlPanel ();
S_StartSound(NULL, sfx_swtchn);
return true;
}
return false;
}
// Keys usable within menu
if (key == key_menu_down)
{
// Move down to next item
do
{
if (itemOn+1 > currentMenu->numitems-1)
itemOn = 0;
else itemOn++;
S_StartSound(NULL, sfx_pstop);
} while(currentMenu->menuitems[itemOn].status==-1);
return true;
}
else if (key == key_menu_up)
{
// Move back up to previous item
do
{
if (!itemOn)
itemOn = currentMenu->numitems-1;
else itemOn--;
S_StartSound(NULL, sfx_pstop);
} while(currentMenu->menuitems[itemOn].status==-1);
return true;
}
else if (key == key_menu_left)
{
// Slide slider left
if (currentMenu->menuitems[itemOn].routine &&
currentMenu->menuitems[itemOn].status == 2)
{
S_StartSound(NULL, sfx_stnmov);
currentMenu->menuitems[itemOn].routine(0);
}
return true;
}
else if (key == key_menu_right)
{
// Slide slider right
if (currentMenu->menuitems[itemOn].routine &&
currentMenu->menuitems[itemOn].status == 2)
{
S_StartSound(NULL, sfx_stnmov);
currentMenu->menuitems[itemOn].routine(1);
}
return true;
}
else if (key == key_menu_forward)
{
// Activate menu item
if (currentMenu->menuitems[itemOn].routine &&
currentMenu->menuitems[itemOn].status)
{
currentMenu->lastOn = itemOn;
if (currentMenu->menuitems[itemOn].status == 2)
{
currentMenu->menuitems[itemOn].routine(1); // right arrow
S_StartSound(NULL, sfx_stnmov);
}
else
{
currentMenu->menuitems[itemOn].routine(itemOn);
//S_StartSound(NULL, sfx_swish); [STRIFE] No sound is played here.
}
}
return true;
}
else if (key == key_menu_activate)
{
// Deactivate menu
if(gameversion == exe_strife_1_31) // [STRIFE]: 1.31 saving
namingCharacter = false;
if(menuindialog) // [STRIFE] - Get out of dialog engine semi-gracefully
P_DialogDoChoice(-1);
currentMenu->lastOn = itemOn;
M_ClearMenus (0);
S_StartSound(NULL, sfx_mtalht); // villsa [STRIFE]: sounds
return true;
}
else if (key == key_menu_back)
{
// Go back to previous menu
currentMenu->lastOn = itemOn;
if (currentMenu->prevMenu)
{
currentMenu = currentMenu->prevMenu;
itemOn = currentMenu->lastOn;
S_StartSound(NULL, sfx_swtchn);
}
return true;
}
// Keyboard shortcut?
// Vanilla Strife has a weird behavior where it jumps to the scroll bars
// when certain keys are pressed, so emulate this.
else if (ch != 0 || IsNullKey(key))
{
// Keyboard shortcut?
for (i = itemOn+1;i < currentMenu->numitems;i++)
{
if (currentMenu->menuitems[i].alphaKey == ch)
{
itemOn = i;
S_StartSound(NULL, sfx_pstop);
return true;
}
}
for (i = 0;i <= itemOn;i++)
{
if (currentMenu->menuitems[i].alphaKey == ch)
{
itemOn = i;
S_StartSound(NULL, sfx_pstop);
return true;
}
}
}
return false;
}
//
// M_StartControlPanel
//
void M_StartControlPanel (void)
{
// intro might call this repeatedly
if (menuactive)
return;
menuactive = 1;
menupause = true;
currentMenu = &MainDef; // JDC
itemOn = currentMenu->lastOn; // JDC
}
//
// M_Drawer
// Called after the view has been rendered,
// but before it has been blitted.
//
void M_Drawer (void)
{
static short x;
static short y;
unsigned int i;
unsigned int max;
char string[80];
char *name;
int start;
inhelpscreens = false;
// Horiz. & Vertically center string and print it.
if (messageToPrint)
{
start = 0;
y = 100 - M_StringHeight(messageString) / 2;
while (messageString[start] != '\0')
{
int foundnewline = 0;
for (i = 0; i < strlen(messageString + start); i++)
{
if (messageString[start + i] == '\n')
{
M_StringCopy(string, messageString + start,
sizeof(string));
if (i < sizeof(string))
{
string[i] = '\0';
}
foundnewline = 1;
start += i + 1;
break;
}
}
if (!foundnewline)
{
M_StringCopy(string, messageString + start,
sizeof(string));
start += strlen(string);
}
x = 160 - M_StringWidth(string) / 2;
M_WriteText(x, y, string);
y += SHORT(hu_font[0]->height);
}
return;
}
if (!menuactive)
return;
if (currentMenu->routine)
currentMenu->routine(); // call Draw routine
// DRAW MENU
x = currentMenu->x;
y = currentMenu->y;
max = currentMenu->numitems;
for (i=0;i<max;i++)
{
name = DEH_String(currentMenu->menuitems[i].name);
if (name[0])
{
V_DrawPatchDirect (x, y, W_CacheLumpName(name, PU_CACHE));
}
y += LINEHEIGHT;
}
// haleyjd 08/27/10: [STRIFE] Adjust to draw spinning Sigil
// DRAW SIGIL
V_DrawPatchDirect(x + CURSORXOFF, currentMenu->y - 5 + itemOn*LINEHEIGHT,
W_CacheLumpName(DEH_String(cursorName[whichCursor]),
PU_CACHE));
}
//
// M_ClearMenus
//
// haleyjd 08/28/10: [STRIFE] Added an int param so this can be called by menus.
// 09/08/10: Added menupause.
//
void M_ClearMenus (int choice)
{
choice = 0; // haleyjd: for no warning; not from decompilation.
menuactive = 0;
menupause = 0;
}
//
// M_SetupNextMenu
//
void M_SetupNextMenu(menu_t *menudef)
{
currentMenu = menudef;
itemOn = currentMenu->lastOn;
}
//
// M_Ticker
//
// haleyjd 08/27/10: [STRIFE] Rewritten for Sigil cursor
//
void M_Ticker (void)
{
if (--cursorAnimCounter <= 0)
{
whichCursor = (whichCursor + 1) % 8;
cursorAnimCounter = 5;
}
}
//
// M_Init
//
// haleyjd 08/27/10: [STRIFE] Removed DOOM gamemode stuff
//
void M_Init (void)
{
currentMenu = &MainDef;
menuactive = 0;
itemOn = currentMenu->lastOn;
whichCursor = 0;
cursorAnimCounter = 10;
screenSize = screenblocks - 3;
messageToPrint = 0;
messageString = NULL;
messageLastMenuActive = menuactive; // STRIFE-FIXME: assigns 0 here...
quickSaveSlot = -1;
// [STRIFE]: Initialize savegame paths and clear temporary directory
G_WriteSaveName(5, "ME");
ClearTmp();
// Here we could catch other version dependencies,
// like HELP1/2, and four episodes.
}
|