MN_MENU.C 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  1. // MN_menu.c
  2. #include <ctype.h>
  3. #include "DoomDef.h"
  4. #include "P_local.h"
  5. #include "R_local.h"
  6. #include "soundst.h"
  7. // Macros
  8. #define LEFT_DIR 0
  9. #define RIGHT_DIR 1
  10. #define ITEM_HEIGHT 20
  11. #define SELECTOR_XOFFSET (-28)
  12. #define SELECTOR_YOFFSET (-1)
  13. #define SLOTTEXTLEN 16
  14. #define ASCII_CURSOR '['
  15. // Types
  16. typedef enum
  17. {
  18. ITT_EMPTY,
  19. ITT_EFUNC,
  20. ITT_LRFUNC,
  21. ITT_SETMENU,
  22. ITT_INERT
  23. } ItemType_t;
  24. typedef enum
  25. {
  26. MENU_MAIN,
  27. MENU_EPISODE,
  28. MENU_SKILL,
  29. MENU_OPTIONS,
  30. MENU_OPTIONS2,
  31. MENU_FILES,
  32. MENU_LOAD,
  33. MENU_SAVE,
  34. MENU_NONE
  35. } MenuType_t;
  36. typedef struct
  37. {
  38. ItemType_t type;
  39. char *text;
  40. boolean (*func)(int option);
  41. int option;
  42. MenuType_t menu;
  43. } MenuItem_t;
  44. typedef struct
  45. {
  46. int x;
  47. int y;
  48. void (*drawFunc)(void);
  49. int itemCount;
  50. MenuItem_t *items;
  51. int oldItPos;
  52. MenuType_t prevMenu;
  53. } Menu_t;
  54. // Private Functions
  55. static void InitFonts(void);
  56. static void SetMenu(MenuType_t menu);
  57. static boolean SCNetCheck(int option);
  58. static boolean SCQuitGame(int option);
  59. static boolean SCEpisode(int option);
  60. static boolean SCSkill(int option);
  61. static boolean SCMouseSensi(int option);
  62. static boolean SCSfxVolume(int option);
  63. static boolean SCMusicVolume(int option);
  64. static boolean SCScreenSize(int option);
  65. static boolean SCLoadGame(int option);
  66. static boolean SCSaveGame(int option);
  67. static boolean SCMessages(int option);
  68. static boolean SCEndGame(int option);
  69. static boolean SCInfo(int option);
  70. static void DrawMainMenu(void);
  71. static void DrawEpisodeMenu(void);
  72. static void DrawSkillMenu(void);
  73. static void DrawOptionsMenu(void);
  74. static void DrawOptions2Menu(void);
  75. static void DrawFileSlots(Menu_t *menu);
  76. static void DrawFilesMenu(void);
  77. static void MN_DrawInfo(void);
  78. static void DrawLoadMenu(void);
  79. static void DrawSaveMenu(void);
  80. static void DrawSlider(Menu_t *menu, int item, int width, int slot);
  81. void MN_LoadSlotText(void);
  82. // External Data
  83. extern int detailLevel;
  84. extern int screenblocks;
  85. // Public Data
  86. boolean MenuActive;
  87. int InfoType;
  88. boolean messageson;
  89. // Private Data
  90. static int FontABaseLump;
  91. static int FontBBaseLump;
  92. static int SkullBaseLump;
  93. static Menu_t *CurrentMenu;
  94. static int CurrentItPos;
  95. static int MenuEpisode;
  96. static int MenuTime;
  97. static boolean soundchanged;
  98. boolean askforquit;
  99. boolean typeofask;
  100. static boolean FileMenuKeySteal;
  101. static boolean slottextloaded;
  102. static char SlotText[6][SLOTTEXTLEN+2];
  103. static char oldSlotText[SLOTTEXTLEN+2];
  104. static int SlotStatus[6];
  105. static int slotptr;
  106. static int currentSlot;
  107. static int quicksave;
  108. static int quickload;
  109. static MenuItem_t MainItems[] =
  110. {
  111. { ITT_EFUNC, "NEW GAME", SCNetCheck, 1, MENU_EPISODE },
  112. { ITT_SETMENU, "OPTIONS", NULL, 0, MENU_OPTIONS },
  113. { ITT_SETMENU, "GAME FILES", NULL, 0, MENU_FILES },
  114. { ITT_EFUNC, "INFO", SCInfo, 0, MENU_NONE },
  115. { ITT_EFUNC, "QUIT GAME", SCQuitGame, 0, MENU_NONE }
  116. };
  117. static Menu_t MainMenu =
  118. {
  119. 110, 56,
  120. DrawMainMenu,
  121. 5, MainItems,
  122. 0,
  123. MENU_NONE
  124. };
  125. static MenuItem_t EpisodeItems[] =
  126. {
  127. { ITT_EFUNC, "CITY OF THE DAMNED", SCEpisode, 1, MENU_NONE },
  128. { ITT_EFUNC, "HELL'S MAW", SCEpisode, 2, MENU_NONE },
  129. { ITT_EFUNC, "THE DOME OF D'SPARIL", SCEpisode, 3, MENU_NONE },
  130. { ITT_EFUNC, "THE OSSUARY", SCEpisode, 4, MENU_NONE },
  131. { ITT_EFUNC, "THE STAGNANT DEMESNE", SCEpisode, 5, MENU_NONE }
  132. };
  133. static Menu_t EpisodeMenu =
  134. {
  135. 80, 50,
  136. DrawEpisodeMenu,
  137. 3, EpisodeItems,
  138. 0,
  139. MENU_MAIN
  140. };
  141. static MenuItem_t FilesItems[] =
  142. {
  143. { ITT_EFUNC, "LOAD GAME", SCNetCheck, 2, MENU_LOAD },
  144. { ITT_SETMENU, "SAVE GAME", NULL, 0, MENU_SAVE }
  145. };
  146. static Menu_t FilesMenu =
  147. {
  148. 110, 60,
  149. DrawFilesMenu,
  150. 2, FilesItems,
  151. 0,
  152. MENU_MAIN
  153. };
  154. static MenuItem_t LoadItems[] =
  155. {
  156. { ITT_EFUNC, NULL, SCLoadGame, 0, MENU_NONE },
  157. { ITT_EFUNC, NULL, SCLoadGame, 1, MENU_NONE },
  158. { ITT_EFUNC, NULL, SCLoadGame, 2, MENU_NONE },
  159. { ITT_EFUNC, NULL, SCLoadGame, 3, MENU_NONE },
  160. { ITT_EFUNC, NULL, SCLoadGame, 4, MENU_NONE },
  161. { ITT_EFUNC, NULL, SCLoadGame, 5, MENU_NONE }
  162. };
  163. static Menu_t LoadMenu =
  164. {
  165. 70, 30,
  166. DrawLoadMenu,
  167. 6, LoadItems,
  168. 0,
  169. MENU_FILES
  170. };
  171. static MenuItem_t SaveItems[] =
  172. {
  173. { ITT_EFUNC, NULL, SCSaveGame, 0, MENU_NONE },
  174. { ITT_EFUNC, NULL, SCSaveGame, 1, MENU_NONE },
  175. { ITT_EFUNC, NULL, SCSaveGame, 2, MENU_NONE },
  176. { ITT_EFUNC, NULL, SCSaveGame, 3, MENU_NONE },
  177. { ITT_EFUNC, NULL, SCSaveGame, 4, MENU_NONE },
  178. { ITT_EFUNC, NULL, SCSaveGame, 5, MENU_NONE }
  179. };
  180. static Menu_t SaveMenu =
  181. {
  182. 70, 30,
  183. DrawSaveMenu,
  184. 6, SaveItems,
  185. 0,
  186. MENU_FILES
  187. };
  188. static MenuItem_t SkillItems[] =
  189. {
  190. { ITT_EFUNC, "THOU NEEDETH A WET-NURSE", SCSkill, sk_baby, MENU_NONE },
  191. { ITT_EFUNC, "YELLOWBELLIES-R-US", SCSkill, sk_easy, MENU_NONE },
  192. { ITT_EFUNC, "BRINGEST THEM ONETH", SCSkill, sk_medium, MENU_NONE },
  193. { ITT_EFUNC, "THOU ART A SMITE-MEISTER", SCSkill, sk_hard, MENU_NONE },
  194. { ITT_EFUNC, "BLACK PLAGUE POSSESSES THEE",
  195. SCSkill, sk_nightmare, MENU_NONE }
  196. };
  197. static Menu_t SkillMenu =
  198. {
  199. 38, 30,
  200. DrawSkillMenu,
  201. 5, SkillItems,
  202. 2,
  203. MENU_EPISODE
  204. };
  205. static MenuItem_t OptionsItems[] =
  206. {
  207. { ITT_EFUNC, "END GAME", SCEndGame, 0, MENU_NONE },
  208. { ITT_EFUNC, "MESSAGES : ", SCMessages, 0, MENU_NONE },
  209. { ITT_LRFUNC, "MOUSE SENSITIVITY", SCMouseSensi, 0, MENU_NONE },
  210. { ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
  211. { ITT_SETMENU, "MORE...", NULL, 0, MENU_OPTIONS2 }
  212. };
  213. static Menu_t OptionsMenu =
  214. {
  215. 88, 30,
  216. DrawOptionsMenu,
  217. 5, OptionsItems,
  218. 0,
  219. MENU_MAIN
  220. };
  221. static MenuItem_t Options2Items[] =
  222. {
  223. { ITT_LRFUNC, "SCREEN SIZE", SCScreenSize, 0, MENU_NONE },
  224. { ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
  225. { ITT_LRFUNC, "SFX VOLUME", SCSfxVolume, 0, MENU_NONE },
  226. { ITT_EMPTY, NULL, NULL, 0, MENU_NONE },
  227. { ITT_LRFUNC, "MUSIC VOLUME", SCMusicVolume, 0, MENU_NONE },
  228. { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }
  229. };
  230. static Menu_t Options2Menu =
  231. {
  232. 90, 20,
  233. DrawOptions2Menu,
  234. 6, Options2Items,
  235. 0,
  236. MENU_OPTIONS
  237. };
  238. static Menu_t *Menus[] =
  239. {
  240. &MainMenu,
  241. &EpisodeMenu,
  242. &SkillMenu,
  243. &OptionsMenu,
  244. &Options2Menu,
  245. &FilesMenu,
  246. &LoadMenu,
  247. &SaveMenu
  248. };
  249. //---------------------------------------------------------------------------
  250. //
  251. // PROC MN_Init
  252. //
  253. //---------------------------------------------------------------------------
  254. void MN_Init(void)
  255. {
  256. InitFonts();
  257. MenuActive = false;
  258. messageson = true;
  259. SkullBaseLump = W_GetNumForName("M_SKL00");
  260. if(ExtendedWAD)
  261. { // Add episodes 4 and 5 to the menu
  262. EpisodeMenu.itemCount = 5;
  263. EpisodeMenu.y -= ITEM_HEIGHT;
  264. }
  265. }
  266. //---------------------------------------------------------------------------
  267. //
  268. // PROC InitFonts
  269. //
  270. //---------------------------------------------------------------------------
  271. static void InitFonts(void)
  272. {
  273. FontABaseLump = W_GetNumForName("FONTA_S")+1;
  274. FontBBaseLump = W_GetNumForName("FONTB_S")+1;
  275. }
  276. //---------------------------------------------------------------------------
  277. //
  278. // PROC MN_DrTextA
  279. //
  280. // Draw text using font A.
  281. //
  282. //---------------------------------------------------------------------------
  283. void MN_DrTextA(char *text, int x, int y)
  284. {
  285. char c;
  286. patch_t *p;
  287. while((c = *text++) != 0)
  288. {
  289. if(c < 33)
  290. {
  291. x += 5;
  292. }
  293. else
  294. {
  295. p = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE);
  296. V_DrawPatch(x, y, p);
  297. x += p->width-1;
  298. }
  299. }
  300. }
  301. //---------------------------------------------------------------------------
  302. //
  303. // FUNC MN_TextAWidth
  304. //
  305. // Returns the pixel width of a string using font A.
  306. //
  307. //---------------------------------------------------------------------------
  308. int MN_TextAWidth(char *text)
  309. {
  310. char c;
  311. int width;
  312. patch_t *p;
  313. width = 0;
  314. while((c = *text++) != 0)
  315. {
  316. if(c < 33)
  317. {
  318. width += 5;
  319. }
  320. else
  321. {
  322. p = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE);
  323. width += p->width-1;
  324. }
  325. }
  326. return(width);
  327. }
  328. //---------------------------------------------------------------------------
  329. //
  330. // PROC MN_DrTextB
  331. //
  332. // Draw text using font B.
  333. //
  334. //---------------------------------------------------------------------------
  335. void MN_DrTextB(char *text, int x, int y)
  336. {
  337. char c;
  338. patch_t *p;
  339. while((c = *text++) != 0)
  340. {
  341. if(c < 33)
  342. {
  343. x += 8;
  344. }
  345. else
  346. {
  347. p = W_CacheLumpNum(FontBBaseLump+c-33, PU_CACHE);
  348. V_DrawPatch(x, y, p);
  349. x += p->width-1;
  350. }
  351. }
  352. }
  353. //---------------------------------------------------------------------------
  354. //
  355. // FUNC MN_TextBWidth
  356. //
  357. // Returns the pixel width of a string using font B.
  358. //
  359. //---------------------------------------------------------------------------
  360. int MN_TextBWidth(char *text)
  361. {
  362. char c;
  363. int width;
  364. patch_t *p;
  365. width = 0;
  366. while((c = *text++) != 0)
  367. {
  368. if(c < 33)
  369. {
  370. width += 5;
  371. }
  372. else
  373. {
  374. p = W_CacheLumpNum(FontBBaseLump+c-33, PU_CACHE);
  375. width += p->width-1;
  376. }
  377. }
  378. return(width);
  379. }
  380. //---------------------------------------------------------------------------
  381. //
  382. // PROC MN_Ticker
  383. //
  384. //---------------------------------------------------------------------------
  385. void MN_Ticker(void)
  386. {
  387. if(MenuActive == false)
  388. {
  389. return;
  390. }
  391. MenuTime++;
  392. }
  393. //---------------------------------------------------------------------------
  394. //
  395. // PROC MN_Drawer
  396. //
  397. //---------------------------------------------------------------------------
  398. char *QuitEndMsg[] =
  399. {
  400. "ARE YOU SURE YOU WANT TO QUIT?",
  401. "ARE YOU SURE YOU WANT TO END THE GAME?",
  402. "DO YOU WANT TO QUICKSAVE THE GAME NAMED",
  403. "DO YOU WANT TO QUICKLOAD THE GAME NAMED"
  404. };
  405. void MN_Drawer(void)
  406. {
  407. int i;
  408. int x;
  409. int y;
  410. MenuItem_t *item;
  411. char *selName;
  412. if(MenuActive == false)
  413. {
  414. if(askforquit)
  415. {
  416. MN_DrTextA(QuitEndMsg[typeofask-1], 160-
  417. MN_TextAWidth(QuitEndMsg[typeofask-1])/2, 80);
  418. if(typeofask == 3)
  419. {
  420. MN_DrTextA(SlotText[quicksave-1], 160-
  421. MN_TextAWidth(SlotText[quicksave-1])/2, 90);
  422. MN_DrTextA("?", 160+
  423. MN_TextAWidth(SlotText[quicksave-1])/2, 90);
  424. }
  425. if(typeofask == 4)
  426. {
  427. MN_DrTextA(SlotText[quickload-1], 160-
  428. MN_TextAWidth(SlotText[quickload-1])/2, 90);
  429. MN_DrTextA("?", 160+
  430. MN_TextAWidth(SlotText[quickload-1])/2, 90);
  431. }
  432. UpdateState |= I_FULLSCRN;
  433. }
  434. return;
  435. }
  436. else
  437. {
  438. UpdateState |= I_FULLSCRN;
  439. if(InfoType)
  440. {
  441. MN_DrawInfo();
  442. return;
  443. }
  444. if(screenblocks < 10)
  445. {
  446. BorderNeedRefresh = true;
  447. }
  448. if(CurrentMenu->drawFunc != NULL)
  449. {
  450. CurrentMenu->drawFunc();
  451. }
  452. x = CurrentMenu->x;
  453. y = CurrentMenu->y;
  454. item = CurrentMenu->items;
  455. for(i = 0; i < CurrentMenu->itemCount; i++)
  456. {
  457. if(item->type != ITT_EMPTY && item->text)
  458. {
  459. MN_DrTextB(item->text, x, y);
  460. }
  461. y += ITEM_HEIGHT;
  462. item++;
  463. }
  464. y = CurrentMenu->y+(CurrentItPos*ITEM_HEIGHT)+SELECTOR_YOFFSET;
  465. selName = MenuTime&16 ? "M_SLCTR1" : "M_SLCTR2";
  466. V_DrawPatch(x+SELECTOR_XOFFSET, y,
  467. W_CacheLumpName(selName, PU_CACHE));
  468. }
  469. }
  470. //---------------------------------------------------------------------------
  471. //
  472. // PROC DrawMainMenu
  473. //
  474. //---------------------------------------------------------------------------
  475. static void DrawMainMenu(void)
  476. {
  477. int frame;
  478. frame = (MenuTime/3)%18;
  479. V_DrawPatch(88, 0, W_CacheLumpName("M_HTIC", PU_CACHE));
  480. V_DrawPatch(40, 10, W_CacheLumpNum(SkullBaseLump+(17-frame),
  481. PU_CACHE));
  482. V_DrawPatch(232, 10, W_CacheLumpNum(SkullBaseLump+frame, PU_CACHE));
  483. }
  484. //---------------------------------------------------------------------------
  485. //
  486. // PROC DrawEpisodeMenu
  487. //
  488. //---------------------------------------------------------------------------
  489. static void DrawEpisodeMenu(void)
  490. {
  491. }
  492. //---------------------------------------------------------------------------
  493. //
  494. // PROC DrawSkillMenu
  495. //
  496. //---------------------------------------------------------------------------
  497. static void DrawSkillMenu(void)
  498. {
  499. }
  500. //---------------------------------------------------------------------------
  501. //
  502. // PROC DrawFilesMenu
  503. //
  504. //---------------------------------------------------------------------------
  505. static void DrawFilesMenu(void)
  506. {
  507. // clear out the quicksave/quickload stuff
  508. quicksave = 0;
  509. quickload = 0;
  510. players[consoleplayer].message = NULL;
  511. players[consoleplayer].messageTics = 1;
  512. }
  513. //---------------------------------------------------------------------------
  514. //
  515. // PROC DrawLoadMenu
  516. //
  517. //---------------------------------------------------------------------------
  518. static void DrawLoadMenu(void)
  519. {
  520. MN_DrTextB("LOAD GAME", 160-MN_TextBWidth("LOAD GAME")/2, 10);
  521. if(!slottextloaded)
  522. {
  523. MN_LoadSlotText();
  524. }
  525. DrawFileSlots(&LoadMenu);
  526. }
  527. //---------------------------------------------------------------------------
  528. //
  529. // PROC DrawSaveMenu
  530. //
  531. //---------------------------------------------------------------------------
  532. static void DrawSaveMenu(void)
  533. {
  534. MN_DrTextB("SAVE GAME", 160-MN_TextBWidth("SAVE GAME")/2, 10);
  535. if(!slottextloaded)
  536. {
  537. MN_LoadSlotText();
  538. }
  539. DrawFileSlots(&SaveMenu);
  540. }
  541. //===========================================================================
  542. //
  543. // MN_LoadSlotText
  544. //
  545. // Loads in the text message for each slot
  546. //===========================================================================
  547. void MN_LoadSlotText(void)
  548. {
  549. FILE *fp;
  550. int count;
  551. int i;
  552. char name[256];
  553. for (i = 0; i < 6; i++)
  554. {
  555. if(cdrom)
  556. {
  557. sprintf(name, SAVEGAMENAMECD"%d.hsg", i);
  558. }
  559. else
  560. {
  561. sprintf(name, SAVEGAMENAME"%d.hsg", i);
  562. }
  563. fp = fopen(name, "rb+");
  564. if (!fp)
  565. {
  566. SlotText[i][0] = 0; // empty the string
  567. SlotStatus[i] = 0;
  568. continue;
  569. }
  570. count = fread(&SlotText[i], SLOTTEXTLEN, 1, fp);
  571. fclose(fp);
  572. SlotStatus[i] = 1;
  573. }
  574. slottextloaded = true;
  575. }
  576. //---------------------------------------------------------------------------
  577. //
  578. // PROC DrawFileSlots
  579. //
  580. //---------------------------------------------------------------------------
  581. static void DrawFileSlots(Menu_t *menu)
  582. {
  583. int i;
  584. int x;
  585. int y;
  586. x = menu->x;
  587. y = menu->y;
  588. for(i = 0; i < 6; i++)
  589. {
  590. V_DrawPatch(x, y, W_CacheLumpName("M_FSLOT", PU_CACHE));
  591. if(SlotStatus[i])
  592. {
  593. MN_DrTextA(SlotText[i], x+5, y+5);
  594. }
  595. y += ITEM_HEIGHT;
  596. }
  597. }
  598. //---------------------------------------------------------------------------
  599. //
  600. // PROC DrawOptionsMenu
  601. //
  602. //---------------------------------------------------------------------------
  603. static void DrawOptionsMenu(void)
  604. {
  605. if(messageson)
  606. {
  607. MN_DrTextB("ON", 196, 50);
  608. }
  609. else
  610. {
  611. MN_DrTextB("OFF", 196, 50);
  612. }
  613. DrawSlider(&OptionsMenu, 3, 10, mouseSensitivity);
  614. }
  615. //---------------------------------------------------------------------------
  616. //
  617. // PROC DrawOptions2Menu
  618. //
  619. //---------------------------------------------------------------------------
  620. static void DrawOptions2Menu(void)
  621. {
  622. DrawSlider(&Options2Menu, 1, 9, screenblocks-3);
  623. DrawSlider(&Options2Menu, 3, 16, snd_MaxVolume);
  624. DrawSlider(&Options2Menu, 5, 16, snd_MusicVolume);
  625. }
  626. //---------------------------------------------------------------------------
  627. //
  628. // PROC SCNetCheck
  629. //
  630. //---------------------------------------------------------------------------
  631. static boolean SCNetCheck(int option)
  632. {
  633. if(!netgame)
  634. { // okay to go into the menu
  635. return true;
  636. }
  637. switch(option)
  638. {
  639. case 1:
  640. P_SetMessage(&players[consoleplayer],
  641. "YOU CAN'T START A NEW GAME IN NETPLAY!", true);
  642. break;
  643. case 2:
  644. P_SetMessage(&players[consoleplayer],
  645. "YOU CAN'T LOAD A GAME IN NETPLAY!", true);
  646. break;
  647. default:
  648. break;
  649. }
  650. MenuActive = false;
  651. return false;
  652. }
  653. //---------------------------------------------------------------------------
  654. //
  655. // PROC SCQuitGame
  656. //
  657. //---------------------------------------------------------------------------
  658. static boolean SCQuitGame(int option)
  659. {
  660. MenuActive = false;
  661. askforquit = true;
  662. typeofask = 1; //quit game
  663. if(!netgame && !demoplayback)
  664. {
  665. paused = true;
  666. }
  667. return true;
  668. }
  669. //---------------------------------------------------------------------------
  670. //
  671. // PROC SCEndGame
  672. //
  673. //---------------------------------------------------------------------------
  674. static boolean SCEndGame(int option)
  675. {
  676. if(demoplayback || netgame)
  677. {
  678. return false;
  679. }
  680. MenuActive = false;
  681. askforquit = true;
  682. typeofask = 2; //endgame
  683. if(!netgame && !demoplayback)
  684. {
  685. paused = true;
  686. }
  687. return true;
  688. }
  689. //---------------------------------------------------------------------------
  690. //
  691. // PROC SCMessages
  692. //
  693. //---------------------------------------------------------------------------
  694. static boolean SCMessages(int option)
  695. {
  696. messageson ^= 1;
  697. if(messageson)
  698. {
  699. P_SetMessage(&players[consoleplayer], "MESSAGES ON", true);
  700. }
  701. else
  702. {
  703. P_SetMessage(&players[consoleplayer], "MESSAGES OFF", true);
  704. }
  705. S_StartSound(NULL, sfx_chat);
  706. return true;
  707. }
  708. //---------------------------------------------------------------------------
  709. //
  710. // PROC SCLoadGame
  711. //
  712. //---------------------------------------------------------------------------
  713. static boolean SCLoadGame(int option)
  714. {
  715. char name[256];
  716. if(!SlotStatus[option])
  717. { // slot's empty...don't try and load
  718. return false;
  719. }
  720. if(cdrom)
  721. {
  722. sprintf(name, SAVEGAMENAMECD"%d.hsg", option);
  723. }
  724. else
  725. {
  726. sprintf(name, SAVEGAMENAME"%d.hsg", option);
  727. }
  728. G_LoadGame(name);
  729. MN_DeactivateMenu();
  730. BorderNeedRefresh = true;
  731. if(quickload == -1)
  732. {
  733. quickload = option+1;
  734. players[consoleplayer].message = NULL;
  735. players[consoleplayer].messageTics = 1;
  736. }
  737. return true;
  738. }
  739. //---------------------------------------------------------------------------
  740. //
  741. // PROC SCSaveGame
  742. //
  743. //---------------------------------------------------------------------------
  744. static boolean SCSaveGame(int option)
  745. {
  746. char *ptr;
  747. if(!FileMenuKeySteal)
  748. {
  749. FileMenuKeySteal = true;
  750. strcpy(oldSlotText, SlotText[option]);
  751. ptr = SlotText[option];
  752. while(*ptr)
  753. {
  754. ptr++;
  755. }
  756. *ptr = '[';
  757. *(ptr+1) = 0;
  758. SlotStatus[option]++;
  759. currentSlot = option;
  760. slotptr = ptr-SlotText[option];
  761. return false;
  762. }
  763. else
  764. {
  765. G_SaveGame(option, SlotText[option]);
  766. FileMenuKeySteal = false;
  767. MN_DeactivateMenu();
  768. }
  769. BorderNeedRefresh = true;
  770. if(quicksave == -1)
  771. {
  772. quicksave = option+1;
  773. players[consoleplayer].message = NULL;
  774. players[consoleplayer].messageTics = 1;
  775. }
  776. return true;
  777. }
  778. //---------------------------------------------------------------------------
  779. //
  780. // PROC SCEpisode
  781. //
  782. //---------------------------------------------------------------------------
  783. static boolean SCEpisode(int option)
  784. {
  785. if(shareware && option > 1)
  786. {
  787. P_SetMessage(&players[consoleplayer],
  788. "ONLY AVAILABLE IN THE REGISTERED VERSION", true);
  789. }
  790. else
  791. {
  792. MenuEpisode = option;
  793. SetMenu(MENU_SKILL);
  794. }
  795. return true;
  796. }
  797. //---------------------------------------------------------------------------
  798. //
  799. // PROC SCSkill
  800. //
  801. //---------------------------------------------------------------------------
  802. static boolean SCSkill(int option)
  803. {
  804. G_DeferedInitNew(option, MenuEpisode, 1);
  805. MN_DeactivateMenu();
  806. return true;
  807. }
  808. //---------------------------------------------------------------------------
  809. //
  810. // PROC SCMouseSensi
  811. //
  812. //---------------------------------------------------------------------------
  813. static boolean SCMouseSensi(int option)
  814. {
  815. if(option == RIGHT_DIR)
  816. {
  817. if(mouseSensitivity < 9)
  818. {
  819. mouseSensitivity++;
  820. }
  821. }
  822. else if(mouseSensitivity)
  823. {
  824. mouseSensitivity--;
  825. }
  826. return true;
  827. }
  828. //---------------------------------------------------------------------------
  829. //
  830. // PROC SCSfxVolume
  831. //
  832. //---------------------------------------------------------------------------
  833. static boolean SCSfxVolume(int option)
  834. {
  835. if(option == RIGHT_DIR)
  836. {
  837. if(snd_MaxVolume < 15)
  838. {
  839. snd_MaxVolume++;
  840. }
  841. }
  842. else if(snd_MaxVolume)
  843. {
  844. snd_MaxVolume--;
  845. }
  846. S_SetMaxVolume(false); // don't recalc the sound curve, yet
  847. soundchanged = true; // we'll set it when we leave the menu
  848. return true;
  849. }
  850. //---------------------------------------------------------------------------
  851. //
  852. // PROC SCMusicVolume
  853. //
  854. //---------------------------------------------------------------------------
  855. static boolean SCMusicVolume(int option)
  856. {
  857. if(option == RIGHT_DIR)
  858. {
  859. if(snd_MusicVolume < 15)
  860. {
  861. snd_MusicVolume++;
  862. }
  863. }
  864. else if(snd_MusicVolume)
  865. {
  866. snd_MusicVolume--;
  867. }
  868. S_SetMusicVolume();
  869. return true;
  870. }
  871. //---------------------------------------------------------------------------
  872. //
  873. // PROC SCScreenSize
  874. //
  875. //---------------------------------------------------------------------------
  876. static boolean SCScreenSize(int option)
  877. {
  878. if(option == RIGHT_DIR)
  879. {
  880. if(screenblocks < 11)
  881. {
  882. screenblocks++;
  883. }
  884. }
  885. else if(screenblocks > 3)
  886. {
  887. screenblocks--;
  888. }
  889. R_SetViewSize(screenblocks, detailLevel);
  890. return true;
  891. }
  892. //---------------------------------------------------------------------------
  893. //
  894. // PROC SCInfo
  895. //
  896. //---------------------------------------------------------------------------
  897. static boolean SCInfo(int option)
  898. {
  899. InfoType = 1;
  900. S_StartSound(NULL, sfx_dorcls);
  901. if(!netgame && !demoplayback)
  902. {
  903. paused = true;
  904. }
  905. return true;
  906. }
  907. //---------------------------------------------------------------------------
  908. //
  909. // FUNC MN_Responder
  910. //
  911. //---------------------------------------------------------------------------
  912. boolean MN_Responder(event_t *event)
  913. {
  914. int key;
  915. int i;
  916. MenuItem_t *item;
  917. extern boolean automapactive;
  918. static boolean shiftdown;
  919. extern void D_StartTitle(void);
  920. extern void G_CheckDemoStatus(void);
  921. char *textBuffer;
  922. if(event->data1 == KEY_RSHIFT)
  923. {
  924. shiftdown = (event->type == ev_keydown);
  925. }
  926. if(event->type != ev_keydown)
  927. {
  928. return(false);
  929. }
  930. key = event->data1;
  931. if(InfoType)
  932. {
  933. if(shareware)
  934. {
  935. InfoType = (InfoType+1)%5;
  936. }
  937. else
  938. {
  939. InfoType = (InfoType+1)%4;
  940. }
  941. if(key == KEY_ESCAPE)
  942. {
  943. InfoType = 0;
  944. }
  945. if(!InfoType)
  946. {
  947. paused = false;
  948. MN_DeactivateMenu();
  949. SB_state = -1; //refresh the statbar
  950. BorderNeedRefresh = true;
  951. }
  952. S_StartSound(NULL, sfx_dorcls);
  953. return(true); //make the info screen eat the keypress
  954. }
  955. if(ravpic && key == KEY_F1)
  956. {
  957. G_ScreenShot();
  958. return(true);
  959. }
  960. if(askforquit)
  961. {
  962. switch(key)
  963. {
  964. case 'y':
  965. if(askforquit)
  966. {
  967. switch(typeofask)
  968. {
  969. case 1:
  970. G_CheckDemoStatus();
  971. I_Quit();
  972. break;
  973. case 2:
  974. players[consoleplayer].messageTics = 0;
  975. //set the msg to be cleared
  976. players[consoleplayer].message = NULL;
  977. typeofask = 0;
  978. askforquit = false;
  979. paused = false;
  980. I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
  981. D_StartTitle(); // go to intro/demo mode.
  982. break;
  983. case 3:
  984. P_SetMessage(&players[consoleplayer], "QUICKSAVING....", false);
  985. FileMenuKeySteal = true;
  986. SCSaveGame(quicksave-1);
  987. askforquit = false;
  988. typeofask = 0;
  989. BorderNeedRefresh = true;
  990. return true;
  991. case 4:
  992. P_SetMessage(&players[consoleplayer], "QUICKLOADING....", false);
  993. SCLoadGame(quickload-1);
  994. askforquit = false;
  995. typeofask = 0;
  996. BorderNeedRefresh = true;
  997. return true;
  998. default:
  999. return true; // eat the 'y' keypress
  1000. }
  1001. }
  1002. return false;
  1003. case 'n':
  1004. case KEY_ESCAPE:
  1005. if(askforquit)
  1006. {
  1007. players[consoleplayer].messageTics = 1; //set the msg to be cleared
  1008. askforquit = false;
  1009. typeofask = 0;
  1010. paused = false;
  1011. UpdateState |= I_FULLSCRN;
  1012. BorderNeedRefresh = true;
  1013. return true;
  1014. }
  1015. return false;
  1016. }
  1017. return false; // don't let the keys filter thru
  1018. }
  1019. if(MenuActive == false && !chatmodeon)
  1020. {
  1021. switch(key)
  1022. {
  1023. case KEY_MINUS:
  1024. if(automapactive)
  1025. { // Don't screen size in automap
  1026. return(false);
  1027. }
  1028. SCScreenSize(LEFT_DIR);
  1029. S_StartSound(NULL, sfx_keyup);
  1030. BorderNeedRefresh = true;
  1031. UpdateState |= I_FULLSCRN;
  1032. return(true);
  1033. case KEY_EQUALS:
  1034. if(automapactive)
  1035. { // Don't screen size in automap
  1036. return(false);
  1037. }
  1038. SCScreenSize(RIGHT_DIR);
  1039. S_StartSound(NULL, sfx_keyup);
  1040. BorderNeedRefresh = true;
  1041. UpdateState |= I_FULLSCRN;
  1042. return(true);
  1043. #ifndef __NeXT__
  1044. case KEY_F1: // help screen
  1045. SCInfo(0); // start up info screens
  1046. MenuActive = true;
  1047. return(true);
  1048. case KEY_F2: // save game
  1049. if(gamestate == GS_LEVEL && !demoplayback)
  1050. {
  1051. MenuActive = true;
  1052. FileMenuKeySteal = false;
  1053. MenuTime = 0;
  1054. CurrentMenu = &SaveMenu;
  1055. CurrentItPos = CurrentMenu->oldItPos;
  1056. if(!netgame && !demoplayback)
  1057. {
  1058. paused = true;
  1059. }
  1060. S_StartSound(NULL, sfx_dorcls);
  1061. slottextloaded = false; //reload the slot text, when needed
  1062. }
  1063. return true;
  1064. case KEY_F3: // load game
  1065. if(SCNetCheck(2))
  1066. {
  1067. MenuActive = true;
  1068. FileMenuKeySteal = false;
  1069. MenuTime = 0;
  1070. CurrentMenu = &LoadMenu;
  1071. CurrentItPos = CurrentMenu->oldItPos;
  1072. if(!netgame && !demoplayback)
  1073. {
  1074. paused = true;
  1075. }
  1076. S_StartSound(NULL, sfx_dorcls);
  1077. slottextloaded = false; //reload the slot text, when needed
  1078. }
  1079. return true;
  1080. case KEY_F4: // volume
  1081. MenuActive = true;
  1082. FileMenuKeySteal = false;
  1083. MenuTime = 0;
  1084. CurrentMenu = &Options2Menu;
  1085. CurrentItPos = CurrentMenu->oldItPos;
  1086. if(!netgame && !demoplayback)
  1087. {
  1088. paused = true;
  1089. }
  1090. S_StartSound(NULL, sfx_dorcls);
  1091. slottextloaded = false; //reload the slot text, when needed
  1092. return true;
  1093. case KEY_F5: // F5 isn't used in Heretic. (detail level)
  1094. return true;
  1095. case KEY_F6: // quicksave
  1096. if(gamestate == GS_LEVEL && !demoplayback)
  1097. {
  1098. if(!quicksave || quicksave == -1)
  1099. {
  1100. MenuActive = true;
  1101. FileMenuKeySteal = false;
  1102. MenuTime = 0;
  1103. CurrentMenu = &SaveMenu;
  1104. CurrentItPos = CurrentMenu->oldItPos;
  1105. if(!netgame && !demoplayback)
  1106. {
  1107. paused = true;
  1108. }
  1109. S_StartSound(NULL, sfx_dorcls);
  1110. slottextloaded = false; //reload the slot text, when needed
  1111. quicksave = -1;
  1112. P_SetMessage(&players[consoleplayer],
  1113. "CHOOSE A QUICKSAVE SLOT", true);
  1114. }
  1115. else
  1116. {
  1117. askforquit = true;
  1118. typeofask = 3;
  1119. if(!netgame && !demoplayback)
  1120. {
  1121. paused = true;
  1122. }
  1123. S_StartSound(NULL, sfx_chat);
  1124. }
  1125. }
  1126. return true;
  1127. case KEY_F7: // endgame
  1128. if(gamestate == GS_LEVEL && !demoplayback)
  1129. {
  1130. S_StartSound(NULL, sfx_chat);
  1131. SCEndGame(0);
  1132. }
  1133. return true;
  1134. case KEY_F8: // toggle messages
  1135. SCMessages(0);
  1136. return true;
  1137. case KEY_F9: // quickload
  1138. if(!quickload || quickload == -1)
  1139. {
  1140. MenuActive = true;
  1141. FileMenuKeySteal = false;
  1142. MenuTime = 0;
  1143. CurrentMenu = &LoadMenu;
  1144. CurrentItPos = CurrentMenu->oldItPos;
  1145. if(!netgame && !demoplayback)
  1146. {
  1147. paused = true;
  1148. }
  1149. S_StartSound(NULL, sfx_dorcls);
  1150. slottextloaded = false; //reload the slot text, when needed
  1151. quickload = -1;
  1152. P_SetMessage(&players[consoleplayer],
  1153. "CHOOSE A QUICKLOAD SLOT", true);
  1154. }
  1155. else
  1156. {
  1157. askforquit = true;
  1158. if(!netgame && !demoplayback)
  1159. {
  1160. paused = true;
  1161. }
  1162. typeofask = 4;
  1163. S_StartSound(NULL, sfx_chat);
  1164. }
  1165. return true;
  1166. case KEY_F10: // quit
  1167. if(gamestate == GS_LEVEL)
  1168. {
  1169. SCQuitGame(0);
  1170. S_StartSound(NULL, sfx_chat);
  1171. }
  1172. return true;
  1173. case KEY_F11: // F11 - gamma mode correction
  1174. usegamma++;
  1175. if(usegamma > 4)
  1176. {
  1177. usegamma = 0;
  1178. }
  1179. I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE));
  1180. return true;
  1181. #endif
  1182. }
  1183. }
  1184. if(MenuActive == false)
  1185. {
  1186. if(key == KEY_ESCAPE || gamestate == GS_DEMOSCREEN || demoplayback)
  1187. {
  1188. MN_ActivateMenu();
  1189. return(true);
  1190. }
  1191. return(false);
  1192. }
  1193. if(!FileMenuKeySteal)
  1194. {
  1195. item = &CurrentMenu->items[CurrentItPos];
  1196. switch(key)
  1197. {
  1198. case KEY_DOWNARROW:
  1199. do
  1200. {
  1201. if(CurrentItPos+1 > CurrentMenu->itemCount-1)
  1202. {
  1203. CurrentItPos = 0;
  1204. }
  1205. else
  1206. {
  1207. CurrentItPos++;
  1208. }
  1209. } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
  1210. S_StartSound(NULL, sfx_switch);
  1211. return(true);
  1212. break;
  1213. case KEY_UPARROW:
  1214. do
  1215. {
  1216. if(CurrentItPos == 0)
  1217. {
  1218. CurrentItPos = CurrentMenu->itemCount-1;
  1219. }
  1220. else
  1221. {
  1222. CurrentItPos--;
  1223. }
  1224. } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
  1225. S_StartSound(NULL, sfx_switch);
  1226. return(true);
  1227. break;
  1228. case KEY_LEFTARROW:
  1229. if(item->type == ITT_LRFUNC && item->func != NULL)
  1230. {
  1231. item->func(LEFT_DIR);
  1232. S_StartSound(NULL, sfx_keyup);
  1233. }
  1234. return(true);
  1235. break;
  1236. case KEY_RIGHTARROW:
  1237. if(item->type == ITT_LRFUNC && item->func != NULL)
  1238. {
  1239. item->func(RIGHT_DIR);
  1240. S_StartSound(NULL, sfx_keyup);
  1241. }
  1242. return(true);
  1243. break;
  1244. case KEY_ENTER:
  1245. if(item->type == ITT_SETMENU)
  1246. {
  1247. SetMenu(item->menu);
  1248. }
  1249. else if(item->func != NULL)
  1250. {
  1251. CurrentMenu->oldItPos = CurrentItPos;
  1252. if(item->type == ITT_LRFUNC)
  1253. {
  1254. item->func(RIGHT_DIR);
  1255. }
  1256. else if(item->type == ITT_EFUNC)
  1257. {
  1258. if(item->func(item->option))
  1259. {
  1260. if(item->menu != MENU_NONE)
  1261. {
  1262. SetMenu(item->menu);
  1263. }
  1264. }
  1265. }
  1266. }
  1267. S_StartSound(NULL, sfx_dorcls);
  1268. return(true);
  1269. break;
  1270. case KEY_ESCAPE:
  1271. MN_DeactivateMenu();
  1272. return(true);
  1273. case KEY_BACKSPACE:
  1274. S_StartSound(NULL, sfx_switch);
  1275. if(CurrentMenu->prevMenu == MENU_NONE)
  1276. {
  1277. MN_DeactivateMenu();
  1278. }
  1279. else
  1280. {
  1281. SetMenu(CurrentMenu->prevMenu);
  1282. }
  1283. return(true);
  1284. default:
  1285. for(i = 0; i < CurrentMenu->itemCount; i++)
  1286. {
  1287. if(CurrentMenu->items[i].text)
  1288. {
  1289. if(toupper(key)
  1290. == toupper(CurrentMenu->items[i].text[0]))
  1291. {
  1292. CurrentItPos = i;
  1293. return(true);
  1294. }
  1295. }
  1296. }
  1297. break;
  1298. }
  1299. return(false);
  1300. }
  1301. else
  1302. { // Editing file names
  1303. textBuffer = &SlotText[currentSlot][slotptr];
  1304. if(key == KEY_BACKSPACE)
  1305. {
  1306. if(slotptr)
  1307. {
  1308. *textBuffer-- = 0;
  1309. *textBuffer = ASCII_CURSOR;
  1310. slotptr--;
  1311. }
  1312. return(true);
  1313. }
  1314. if(key == KEY_ESCAPE)
  1315. {
  1316. memset(SlotText[currentSlot], 0, SLOTTEXTLEN+2);
  1317. strcpy(SlotText[currentSlot], oldSlotText);
  1318. SlotStatus[currentSlot]--;
  1319. MN_DeactivateMenu();
  1320. return(true);
  1321. }
  1322. if(key == KEY_ENTER)
  1323. {
  1324. SlotText[currentSlot][slotptr] = 0; // clear the cursor
  1325. item = &CurrentMenu->items[CurrentItPos];
  1326. CurrentMenu->oldItPos = CurrentItPos;
  1327. if(item->type == ITT_EFUNC)
  1328. {
  1329. item->func(item->option);
  1330. if(item->menu != MENU_NONE)
  1331. {
  1332. SetMenu(item->menu);
  1333. }
  1334. }
  1335. return(true);
  1336. }
  1337. if(slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE)
  1338. {
  1339. if((key >= 'a' && key <= 'z'))
  1340. {
  1341. *textBuffer++ = key-32;
  1342. *textBuffer = ASCII_CURSOR;
  1343. slotptr++;
  1344. return(true);
  1345. }
  1346. if(((key >= '0' && key <= '9') || key == ' '
  1347. || key == ',' || key == '.' || key == '-')
  1348. && !shiftdown)
  1349. {
  1350. *textBuffer++ = key;
  1351. *textBuffer = ASCII_CURSOR;
  1352. slotptr++;
  1353. return(true);
  1354. }
  1355. if(shiftdown && key == '1')
  1356. {
  1357. *textBuffer++ = '!';
  1358. *textBuffer = ASCII_CURSOR;
  1359. slotptr++;
  1360. return(true);
  1361. }
  1362. }
  1363. return(true);
  1364. }
  1365. return(false);
  1366. }
  1367. //---------------------------------------------------------------------------
  1368. //
  1369. // PROC MN_ActivateMenu
  1370. //
  1371. //---------------------------------------------------------------------------
  1372. void MN_ActivateMenu(void)
  1373. {
  1374. if(MenuActive)
  1375. {
  1376. return;
  1377. }
  1378. if(paused)
  1379. {
  1380. S_ResumeSound();
  1381. }
  1382. MenuActive = true;
  1383. FileMenuKeySteal = false;
  1384. MenuTime = 0;
  1385. CurrentMenu = &MainMenu;
  1386. CurrentItPos = CurrentMenu->oldItPos;
  1387. if(!netgame && !demoplayback)
  1388. {
  1389. paused = true;
  1390. }
  1391. S_StartSound(NULL, sfx_dorcls);
  1392. slottextloaded = false; //reload the slot text, when needed
  1393. }
  1394. //---------------------------------------------------------------------------
  1395. //
  1396. // PROC MN_DeactivateMenu
  1397. //
  1398. //---------------------------------------------------------------------------
  1399. void MN_DeactivateMenu(void)
  1400. {
  1401. CurrentMenu->oldItPos = CurrentItPos;
  1402. MenuActive = false;
  1403. if(!netgame)
  1404. {
  1405. paused = false;
  1406. }
  1407. S_StartSound(NULL, sfx_dorcls);
  1408. if(soundchanged)
  1409. {
  1410. S_SetMaxVolume(true); //recalc the sound curve
  1411. soundchanged = false;
  1412. }
  1413. players[consoleplayer].message = NULL;
  1414. players[consoleplayer].messageTics = 1;
  1415. }
  1416. //---------------------------------------------------------------------------
  1417. //
  1418. // PROC MN_DrawInfo
  1419. //
  1420. //---------------------------------------------------------------------------
  1421. void MN_DrawInfo(void)
  1422. {
  1423. I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
  1424. memcpy(screen, (byte *)W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType,
  1425. PU_CACHE), SCREENWIDTH*SCREENHEIGHT);
  1426. // V_DrawPatch(0, 0, W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType,
  1427. // PU_CACHE));
  1428. }
  1429. //---------------------------------------------------------------------------
  1430. //
  1431. // PROC SetMenu
  1432. //
  1433. //---------------------------------------------------------------------------
  1434. static void SetMenu(MenuType_t menu)
  1435. {
  1436. CurrentMenu->oldItPos = CurrentItPos;
  1437. CurrentMenu = Menus[menu];
  1438. CurrentItPos = CurrentMenu->oldItPos;
  1439. }
  1440. //---------------------------------------------------------------------------
  1441. //
  1442. // PROC DrawSlider
  1443. //
  1444. //---------------------------------------------------------------------------
  1445. static void DrawSlider(Menu_t *menu, int item, int width, int slot)
  1446. {
  1447. int x;
  1448. int y;
  1449. int x2;
  1450. int count;
  1451. x = menu->x+24;
  1452. y = menu->y+2+(item*ITEM_HEIGHT);
  1453. V_DrawPatch(x-32, y, W_CacheLumpName("M_SLDLT", PU_CACHE));
  1454. for(x2 = x, count = width; count--; x2 += 8)
  1455. {
  1456. V_DrawPatch(x2, y, W_CacheLumpName(count&1 ? "M_SLDMD1"
  1457. : "M_SLDMD2", PU_CACHE));
  1458. }
  1459. V_DrawPatch(x2, y, W_CacheLumpName("M_SLDRT", PU_CACHE));
  1460. V_DrawPatch(x+4+slot*8, y+7, W_CacheLumpName("M_SLDKB", PU_CACHE));
  1461. }