menu.c 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #include "quakedef.h"
  16. #ifdef _WIN32
  17. #include "winquake.h"
  18. #endif
  19. void (*vid_menudrawfn)(void);
  20. void (*vid_menukeyfn)(int key);
  21. enum {m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, m_net, m_options, m_video, m_keys, m_help, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state;
  22. void M_Menu_Main_f (void);
  23. void M_Menu_SinglePlayer_f (void);
  24. void M_Menu_Load_f (void);
  25. void M_Menu_Save_f (void);
  26. void M_Menu_MultiPlayer_f (void);
  27. void M_Menu_Setup_f (void);
  28. void M_Menu_Net_f (void);
  29. void M_Menu_Options_f (void);
  30. void M_Menu_Keys_f (void);
  31. void M_Menu_Video_f (void);
  32. void M_Menu_Help_f (void);
  33. void M_Menu_Quit_f (void);
  34. void M_Menu_SerialConfig_f (void);
  35. void M_Menu_ModemConfig_f (void);
  36. void M_Menu_LanConfig_f (void);
  37. void M_Menu_GameOptions_f (void);
  38. void M_Menu_Search_f (void);
  39. void M_Menu_ServerList_f (void);
  40. void M_Main_Draw (void);
  41. void M_SinglePlayer_Draw (void);
  42. void M_Load_Draw (void);
  43. void M_Save_Draw (void);
  44. void M_MultiPlayer_Draw (void);
  45. void M_Setup_Draw (void);
  46. void M_Net_Draw (void);
  47. void M_Options_Draw (void);
  48. void M_Keys_Draw (void);
  49. void M_Video_Draw (void);
  50. void M_Help_Draw (void);
  51. void M_Quit_Draw (void);
  52. void M_SerialConfig_Draw (void);
  53. void M_ModemConfig_Draw (void);
  54. void M_LanConfig_Draw (void);
  55. void M_GameOptions_Draw (void);
  56. void M_Search_Draw (void);
  57. void M_ServerList_Draw (void);
  58. void M_Main_Key (int key);
  59. void M_SinglePlayer_Key (int key);
  60. void M_Load_Key (int key);
  61. void M_Save_Key (int key);
  62. void M_MultiPlayer_Key (int key);
  63. void M_Setup_Key (int key);
  64. void M_Net_Key (int key);
  65. void M_Options_Key (int key);
  66. void M_Keys_Key (int key);
  67. void M_Video_Key (int key);
  68. void M_Help_Key (int key);
  69. void M_Quit_Key (int key);
  70. void M_SerialConfig_Key (int key);
  71. void M_ModemConfig_Key (int key);
  72. void M_LanConfig_Key (int key);
  73. void M_GameOptions_Key (int key);
  74. void M_Search_Key (int key);
  75. void M_ServerList_Key (int key);
  76. qboolean m_entersound; // play after drawing a frame, so caching
  77. // won't disrupt the sound
  78. qboolean m_recursiveDraw;
  79. int m_return_state;
  80. qboolean m_return_onerror;
  81. char m_return_reason [32];
  82. #define StartingGame (m_multiplayer_cursor == 1)
  83. #define JoiningGame (m_multiplayer_cursor == 0)
  84. #define SerialConfig (m_net_cursor == 0)
  85. #define DirectConfig (m_net_cursor == 1)
  86. #define IPXConfig (m_net_cursor == 2)
  87. #define TCPIPConfig (m_net_cursor == 3)
  88. void M_ConfigureNetSubsystem(void);
  89. /*
  90. ================
  91. M_DrawCharacter
  92. Draws one solid graphics character
  93. ================
  94. */
  95. void M_DrawCharacter (int cx, int line, int num)
  96. {
  97. Draw_Character ( cx + ((vid.width - 320)>>1), line, num);
  98. }
  99. void M_Print (int cx, int cy, char *str)
  100. {
  101. while (*str)
  102. {
  103. M_DrawCharacter (cx, cy, (*str)+128);
  104. str++;
  105. cx += 8;
  106. }
  107. }
  108. void M_PrintWhite (int cx, int cy, char *str)
  109. {
  110. while (*str)
  111. {
  112. M_DrawCharacter (cx, cy, *str);
  113. str++;
  114. cx += 8;
  115. }
  116. }
  117. void M_DrawTransPic (int x, int y, qpic_t *pic)
  118. {
  119. Draw_TransPic (x + ((vid.width - 320)>>1), y, pic);
  120. }
  121. void M_DrawPic (int x, int y, qpic_t *pic)
  122. {
  123. Draw_Pic (x + ((vid.width - 320)>>1), y, pic);
  124. }
  125. byte identityTable[256];
  126. byte translationTable[256];
  127. void M_BuildTranslationTable(int top, int bottom)
  128. {
  129. int j;
  130. byte *dest, *source;
  131. for (j = 0; j < 256; j++)
  132. identityTable[j] = j;
  133. dest = translationTable;
  134. source = identityTable;
  135. memcpy (dest, source, 256);
  136. if (top < 128) // the artists made some backwards ranges. sigh.
  137. memcpy (dest + TOP_RANGE, source + top, 16);
  138. else
  139. for (j=0 ; j<16 ; j++)
  140. dest[TOP_RANGE+j] = source[top+15-j];
  141. if (bottom < 128)
  142. memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
  143. else
  144. for (j=0 ; j<16 ; j++)
  145. dest[BOTTOM_RANGE+j] = source[bottom+15-j];
  146. }
  147. void M_DrawTransPicTranslate (int x, int y, qpic_t *pic)
  148. {
  149. Draw_TransPicTranslate (x + ((vid.width - 320)>>1), y, pic, translationTable);
  150. }
  151. void M_DrawTextBox (int x, int y, int width, int lines)
  152. {
  153. qpic_t *p;
  154. int cx, cy;
  155. int n;
  156. // draw left side
  157. cx = x;
  158. cy = y;
  159. p = Draw_CachePic ("gfx/box_tl.lmp");
  160. M_DrawTransPic (cx, cy, p);
  161. p = Draw_CachePic ("gfx/box_ml.lmp");
  162. for (n = 0; n < lines; n++)
  163. {
  164. cy += 8;
  165. M_DrawTransPic (cx, cy, p);
  166. }
  167. p = Draw_CachePic ("gfx/box_bl.lmp");
  168. M_DrawTransPic (cx, cy+8, p);
  169. // draw middle
  170. cx += 8;
  171. while (width > 0)
  172. {
  173. cy = y;
  174. p = Draw_CachePic ("gfx/box_tm.lmp");
  175. M_DrawTransPic (cx, cy, p);
  176. p = Draw_CachePic ("gfx/box_mm.lmp");
  177. for (n = 0; n < lines; n++)
  178. {
  179. cy += 8;
  180. if (n == 1)
  181. p = Draw_CachePic ("gfx/box_mm2.lmp");
  182. M_DrawTransPic (cx, cy, p);
  183. }
  184. p = Draw_CachePic ("gfx/box_bm.lmp");
  185. M_DrawTransPic (cx, cy+8, p);
  186. width -= 2;
  187. cx += 16;
  188. }
  189. // draw right side
  190. cy = y;
  191. p = Draw_CachePic ("gfx/box_tr.lmp");
  192. M_DrawTransPic (cx, cy, p);
  193. p = Draw_CachePic ("gfx/box_mr.lmp");
  194. for (n = 0; n < lines; n++)
  195. {
  196. cy += 8;
  197. M_DrawTransPic (cx, cy, p);
  198. }
  199. p = Draw_CachePic ("gfx/box_br.lmp");
  200. M_DrawTransPic (cx, cy+8, p);
  201. }
  202. //=============================================================================
  203. int m_save_demonum;
  204. /*
  205. ================
  206. M_ToggleMenu_f
  207. ================
  208. */
  209. void M_ToggleMenu_f (void)
  210. {
  211. m_entersound = true;
  212. if (key_dest == key_menu)
  213. {
  214. if (m_state != m_main)
  215. {
  216. M_Menu_Main_f ();
  217. return;
  218. }
  219. key_dest = key_game;
  220. m_state = m_none;
  221. return;
  222. }
  223. if (key_dest == key_console)
  224. {
  225. Con_ToggleConsole_f ();
  226. }
  227. else
  228. {
  229. M_Menu_Main_f ();
  230. }
  231. }
  232. //=============================================================================
  233. /* MAIN MENU */
  234. int m_main_cursor;
  235. #define MAIN_ITEMS 5
  236. void M_Menu_Main_f (void)
  237. {
  238. if (key_dest != key_menu)
  239. {
  240. m_save_demonum = cls.demonum;
  241. cls.demonum = -1;
  242. }
  243. key_dest = key_menu;
  244. m_state = m_main;
  245. m_entersound = true;
  246. }
  247. void M_Main_Draw (void)
  248. {
  249. int f;
  250. qpic_t *p;
  251. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  252. p = Draw_CachePic ("gfx/ttl_main.lmp");
  253. M_DrawPic ( (320-p->width)/2, 4, p);
  254. M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mainmenu.lmp") );
  255. f = (int)(host_time * 10)%6;
  256. M_DrawTransPic (54, 32 + m_main_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
  257. }
  258. void M_Main_Key (int key)
  259. {
  260. switch (key)
  261. {
  262. case K_ESCAPE:
  263. key_dest = key_game;
  264. m_state = m_none;
  265. cls.demonum = m_save_demonum;
  266. if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
  267. CL_NextDemo ();
  268. break;
  269. case K_DOWNARROW:
  270. S_LocalSound ("misc/menu1.wav");
  271. if (++m_main_cursor >= MAIN_ITEMS)
  272. m_main_cursor = 0;
  273. break;
  274. case K_UPARROW:
  275. S_LocalSound ("misc/menu1.wav");
  276. if (--m_main_cursor < 0)
  277. m_main_cursor = MAIN_ITEMS - 1;
  278. break;
  279. case K_ENTER:
  280. m_entersound = true;
  281. switch (m_main_cursor)
  282. {
  283. case 0:
  284. M_Menu_SinglePlayer_f ();
  285. break;
  286. case 1:
  287. M_Menu_MultiPlayer_f ();
  288. break;
  289. case 2:
  290. M_Menu_Options_f ();
  291. break;
  292. case 3:
  293. M_Menu_Help_f ();
  294. break;
  295. case 4:
  296. M_Menu_Quit_f ();
  297. break;
  298. }
  299. }
  300. }
  301. //=============================================================================
  302. /* SINGLE PLAYER MENU */
  303. int m_singleplayer_cursor;
  304. #define SINGLEPLAYER_ITEMS 3
  305. void M_Menu_SinglePlayer_f (void)
  306. {
  307. key_dest = key_menu;
  308. m_state = m_singleplayer;
  309. m_entersound = true;
  310. }
  311. void M_SinglePlayer_Draw (void)
  312. {
  313. int f;
  314. qpic_t *p;
  315. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  316. p = Draw_CachePic ("gfx/ttl_sgl.lmp");
  317. M_DrawPic ( (320-p->width)/2, 4, p);
  318. M_DrawTransPic (72, 32, Draw_CachePic ("gfx/sp_menu.lmp") );
  319. f = (int)(host_time * 10)%6;
  320. M_DrawTransPic (54, 32 + m_singleplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
  321. }
  322. void M_SinglePlayer_Key (int key)
  323. {
  324. switch (key)
  325. {
  326. case K_ESCAPE:
  327. M_Menu_Main_f ();
  328. break;
  329. case K_DOWNARROW:
  330. S_LocalSound ("misc/menu1.wav");
  331. if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
  332. m_singleplayer_cursor = 0;
  333. break;
  334. case K_UPARROW:
  335. S_LocalSound ("misc/menu1.wav");
  336. if (--m_singleplayer_cursor < 0)
  337. m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
  338. break;
  339. case K_ENTER:
  340. m_entersound = true;
  341. switch (m_singleplayer_cursor)
  342. {
  343. case 0:
  344. if (sv.active)
  345. if (!SCR_ModalMessage("Are you sure you want to\nstart a new game?\n"))
  346. break;
  347. key_dest = key_game;
  348. if (sv.active)
  349. Cbuf_AddText ("disconnect\n");
  350. Cbuf_AddText ("maxplayers 1\n");
  351. Cbuf_AddText ("map start\n");
  352. break;
  353. case 1:
  354. M_Menu_Load_f ();
  355. break;
  356. case 2:
  357. M_Menu_Save_f ();
  358. break;
  359. }
  360. }
  361. }
  362. //=============================================================================
  363. /* LOAD/SAVE MENU */
  364. int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES
  365. #define MAX_SAVEGAMES 12
  366. char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
  367. int loadable[MAX_SAVEGAMES];
  368. void M_ScanSaves (void)
  369. {
  370. int i, j;
  371. char name[MAX_OSPATH];
  372. FILE *f;
  373. int version;
  374. for (i=0 ; i<MAX_SAVEGAMES ; i++)
  375. {
  376. strcpy (m_filenames[i], "--- UNUSED SLOT ---");
  377. loadable[i] = false;
  378. sprintf (name, "%s/s%i.sav", com_gamedir, i);
  379. f = fopen (name, "r");
  380. if (!f)
  381. continue;
  382. fscanf (f, "%i\n", &version);
  383. fscanf (f, "%79s\n", name);
  384. strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
  385. // change _ back to space
  386. for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
  387. if (m_filenames[i][j] == '_')
  388. m_filenames[i][j] = ' ';
  389. loadable[i] = true;
  390. fclose (f);
  391. }
  392. }
  393. void M_Menu_Load_f (void)
  394. {
  395. m_entersound = true;
  396. m_state = m_load;
  397. key_dest = key_menu;
  398. M_ScanSaves ();
  399. }
  400. void M_Menu_Save_f (void)
  401. {
  402. if (!sv.active)
  403. return;
  404. if (cl.intermission)
  405. return;
  406. if (svs.maxclients != 1)
  407. return;
  408. m_entersound = true;
  409. m_state = m_save;
  410. key_dest = key_menu;
  411. M_ScanSaves ();
  412. }
  413. void M_Load_Draw (void)
  414. {
  415. int i;
  416. qpic_t *p;
  417. p = Draw_CachePic ("gfx/p_load.lmp");
  418. M_DrawPic ( (320-p->width)/2, 4, p);
  419. for (i=0 ; i< MAX_SAVEGAMES; i++)
  420. M_Print (16, 32 + 8*i, m_filenames[i]);
  421. // line cursor
  422. M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
  423. }
  424. void M_Save_Draw (void)
  425. {
  426. int i;
  427. qpic_t *p;
  428. p = Draw_CachePic ("gfx/p_save.lmp");
  429. M_DrawPic ( (320-p->width)/2, 4, p);
  430. for (i=0 ; i<MAX_SAVEGAMES ; i++)
  431. M_Print (16, 32 + 8*i, m_filenames[i]);
  432. // line cursor
  433. M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
  434. }
  435. void M_Load_Key (int k)
  436. {
  437. switch (k)
  438. {
  439. case K_ESCAPE:
  440. M_Menu_SinglePlayer_f ();
  441. break;
  442. case K_ENTER:
  443. S_LocalSound ("misc/menu2.wav");
  444. if (!loadable[load_cursor])
  445. return;
  446. m_state = m_none;
  447. key_dest = key_game;
  448. // Host_Loadgame_f can't bring up the loading plaque because too much
  449. // stack space has been used, so do it now
  450. SCR_BeginLoadingPlaque ();
  451. // issue the load command
  452. Cbuf_AddText (va ("load s%i\n", load_cursor) );
  453. return;
  454. case K_UPARROW:
  455. case K_LEFTARROW:
  456. S_LocalSound ("misc/menu1.wav");
  457. load_cursor--;
  458. if (load_cursor < 0)
  459. load_cursor = MAX_SAVEGAMES-1;
  460. break;
  461. case K_DOWNARROW:
  462. case K_RIGHTARROW:
  463. S_LocalSound ("misc/menu1.wav");
  464. load_cursor++;
  465. if (load_cursor >= MAX_SAVEGAMES)
  466. load_cursor = 0;
  467. break;
  468. }
  469. }
  470. void M_Save_Key (int k)
  471. {
  472. switch (k)
  473. {
  474. case K_ESCAPE:
  475. M_Menu_SinglePlayer_f ();
  476. break;
  477. case K_ENTER:
  478. m_state = m_none;
  479. key_dest = key_game;
  480. Cbuf_AddText (va("save s%i\n", load_cursor));
  481. return;
  482. case K_UPARROW:
  483. case K_LEFTARROW:
  484. S_LocalSound ("misc/menu1.wav");
  485. load_cursor--;
  486. if (load_cursor < 0)
  487. load_cursor = MAX_SAVEGAMES-1;
  488. break;
  489. case K_DOWNARROW:
  490. case K_RIGHTARROW:
  491. S_LocalSound ("misc/menu1.wav");
  492. load_cursor++;
  493. if (load_cursor >= MAX_SAVEGAMES)
  494. load_cursor = 0;
  495. break;
  496. }
  497. }
  498. //=============================================================================
  499. /* MULTIPLAYER MENU */
  500. int m_multiplayer_cursor;
  501. #define MULTIPLAYER_ITEMS 3
  502. void M_Menu_MultiPlayer_f (void)
  503. {
  504. key_dest = key_menu;
  505. m_state = m_multiplayer;
  506. m_entersound = true;
  507. }
  508. void M_MultiPlayer_Draw (void)
  509. {
  510. int f;
  511. qpic_t *p;
  512. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  513. p = Draw_CachePic ("gfx/p_multi.lmp");
  514. M_DrawPic ( (320-p->width)/2, 4, p);
  515. M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mp_menu.lmp") );
  516. f = (int)(host_time * 10)%6;
  517. M_DrawTransPic (54, 32 + m_multiplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
  518. if (serialAvailable || ipxAvailable || tcpipAvailable)
  519. return;
  520. M_PrintWhite ((320/2) - ((27*8)/2), 148, "No Communications Available");
  521. }
  522. void M_MultiPlayer_Key (int key)
  523. {
  524. switch (key)
  525. {
  526. case K_ESCAPE:
  527. M_Menu_Main_f ();
  528. break;
  529. case K_DOWNARROW:
  530. S_LocalSound ("misc/menu1.wav");
  531. if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
  532. m_multiplayer_cursor = 0;
  533. break;
  534. case K_UPARROW:
  535. S_LocalSound ("misc/menu1.wav");
  536. if (--m_multiplayer_cursor < 0)
  537. m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
  538. break;
  539. case K_ENTER:
  540. m_entersound = true;
  541. switch (m_multiplayer_cursor)
  542. {
  543. case 0:
  544. if (serialAvailable || ipxAvailable || tcpipAvailable)
  545. M_Menu_Net_f ();
  546. break;
  547. case 1:
  548. if (serialAvailable || ipxAvailable || tcpipAvailable)
  549. M_Menu_Net_f ();
  550. break;
  551. case 2:
  552. M_Menu_Setup_f ();
  553. break;
  554. }
  555. }
  556. }
  557. //=============================================================================
  558. /* SETUP MENU */
  559. int setup_cursor = 4;
  560. int setup_cursor_table[] = {40, 56, 80, 104, 140};
  561. char setup_hostname[16];
  562. char setup_myname[16];
  563. int setup_oldtop;
  564. int setup_oldbottom;
  565. int setup_top;
  566. int setup_bottom;
  567. #define NUM_SETUP_CMDS 5
  568. void M_Menu_Setup_f (void)
  569. {
  570. key_dest = key_menu;
  571. m_state = m_setup;
  572. m_entersound = true;
  573. Q_strcpy(setup_myname, cl_name.string);
  574. Q_strcpy(setup_hostname, hostname.string);
  575. setup_top = setup_oldtop = ((int)cl_color.value) >> 4;
  576. setup_bottom = setup_oldbottom = ((int)cl_color.value) & 15;
  577. }
  578. void M_Setup_Draw (void)
  579. {
  580. qpic_t *p;
  581. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  582. p = Draw_CachePic ("gfx/p_multi.lmp");
  583. M_DrawPic ( (320-p->width)/2, 4, p);
  584. M_Print (64, 40, "Hostname");
  585. M_DrawTextBox (160, 32, 16, 1);
  586. M_Print (168, 40, setup_hostname);
  587. M_Print (64, 56, "Your name");
  588. M_DrawTextBox (160, 48, 16, 1);
  589. M_Print (168, 56, setup_myname);
  590. M_Print (64, 80, "Shirt color");
  591. M_Print (64, 104, "Pants color");
  592. M_DrawTextBox (64, 140-8, 14, 1);
  593. M_Print (72, 140, "Accept Changes");
  594. p = Draw_CachePic ("gfx/bigbox.lmp");
  595. M_DrawTransPic (160, 64, p);
  596. p = Draw_CachePic ("gfx/menuplyr.lmp");
  597. M_BuildTranslationTable(setup_top*16, setup_bottom*16);
  598. M_DrawTransPicTranslate (172, 72, p);
  599. M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
  600. if (setup_cursor == 0)
  601. M_DrawCharacter (168 + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
  602. if (setup_cursor == 1)
  603. M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
  604. }
  605. void M_Setup_Key (int k)
  606. {
  607. int l;
  608. switch (k)
  609. {
  610. case K_ESCAPE:
  611. M_Menu_MultiPlayer_f ();
  612. break;
  613. case K_UPARROW:
  614. S_LocalSound ("misc/menu1.wav");
  615. setup_cursor--;
  616. if (setup_cursor < 0)
  617. setup_cursor = NUM_SETUP_CMDS-1;
  618. break;
  619. case K_DOWNARROW:
  620. S_LocalSound ("misc/menu1.wav");
  621. setup_cursor++;
  622. if (setup_cursor >= NUM_SETUP_CMDS)
  623. setup_cursor = 0;
  624. break;
  625. case K_LEFTARROW:
  626. if (setup_cursor < 2)
  627. return;
  628. S_LocalSound ("misc/menu3.wav");
  629. if (setup_cursor == 2)
  630. setup_top = setup_top - 1;
  631. if (setup_cursor == 3)
  632. setup_bottom = setup_bottom - 1;
  633. break;
  634. case K_RIGHTARROW:
  635. if (setup_cursor < 2)
  636. return;
  637. forward:
  638. S_LocalSound ("misc/menu3.wav");
  639. if (setup_cursor == 2)
  640. setup_top = setup_top + 1;
  641. if (setup_cursor == 3)
  642. setup_bottom = setup_bottom + 1;
  643. break;
  644. case K_ENTER:
  645. if (setup_cursor == 0 || setup_cursor == 1)
  646. return;
  647. if (setup_cursor == 2 || setup_cursor == 3)
  648. goto forward;
  649. // setup_cursor == 4 (OK)
  650. if (Q_strcmp(cl_name.string, setup_myname) != 0)
  651. Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
  652. if (Q_strcmp(hostname.string, setup_hostname) != 0)
  653. Cvar_Set("hostname", setup_hostname);
  654. if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
  655. Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
  656. m_entersound = true;
  657. M_Menu_MultiPlayer_f ();
  658. break;
  659. case K_BACKSPACE:
  660. if (setup_cursor == 0)
  661. {
  662. if (strlen(setup_hostname))
  663. setup_hostname[strlen(setup_hostname)-1] = 0;
  664. }
  665. if (setup_cursor == 1)
  666. {
  667. if (strlen(setup_myname))
  668. setup_myname[strlen(setup_myname)-1] = 0;
  669. }
  670. break;
  671. default:
  672. if (k < 32 || k > 127)
  673. break;
  674. if (setup_cursor == 0)
  675. {
  676. l = strlen(setup_hostname);
  677. if (l < 15)
  678. {
  679. setup_hostname[l+1] = 0;
  680. setup_hostname[l] = k;
  681. }
  682. }
  683. if (setup_cursor == 1)
  684. {
  685. l = strlen(setup_myname);
  686. if (l < 15)
  687. {
  688. setup_myname[l+1] = 0;
  689. setup_myname[l] = k;
  690. }
  691. }
  692. }
  693. if (setup_top > 13)
  694. setup_top = 0;
  695. if (setup_top < 0)
  696. setup_top = 13;
  697. if (setup_bottom > 13)
  698. setup_bottom = 0;
  699. if (setup_bottom < 0)
  700. setup_bottom = 13;
  701. }
  702. //=============================================================================
  703. /* NET MENU */
  704. int m_net_cursor;
  705. int m_net_items;
  706. int m_net_saveHeight;
  707. char *net_helpMessage [] =
  708. {
  709. /* .........1.........2.... */
  710. " ",
  711. " Two computers connected",
  712. " through two modems. ",
  713. " ",
  714. " ",
  715. " Two computers connected",
  716. " by a null-modem cable. ",
  717. " ",
  718. " Novell network LANs ",
  719. " or Windows 95 DOS-box. ",
  720. " ",
  721. "(LAN=Local Area Network)",
  722. " Commonly used to play ",
  723. " over the Internet, but ",
  724. " also used on a Local ",
  725. " Area Network. "
  726. };
  727. void M_Menu_Net_f (void)
  728. {
  729. key_dest = key_menu;
  730. m_state = m_net;
  731. m_entersound = true;
  732. m_net_items = 4;
  733. if (m_net_cursor >= m_net_items)
  734. m_net_cursor = 0;
  735. m_net_cursor--;
  736. M_Net_Key (K_DOWNARROW);
  737. }
  738. void M_Net_Draw (void)
  739. {
  740. int f;
  741. qpic_t *p;
  742. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  743. p = Draw_CachePic ("gfx/p_multi.lmp");
  744. M_DrawPic ( (320-p->width)/2, 4, p);
  745. f = 32;
  746. if (serialAvailable)
  747. {
  748. p = Draw_CachePic ("gfx/netmen1.lmp");
  749. }
  750. else
  751. {
  752. #ifdef _WIN32
  753. p = NULL;
  754. #else
  755. p = Draw_CachePic ("gfx/dim_modm.lmp");
  756. #endif
  757. }
  758. if (p)
  759. M_DrawTransPic (72, f, p);
  760. f += 19;
  761. if (serialAvailable)
  762. {
  763. p = Draw_CachePic ("gfx/netmen2.lmp");
  764. }
  765. else
  766. {
  767. #ifdef _WIN32
  768. p = NULL;
  769. #else
  770. p = Draw_CachePic ("gfx/dim_drct.lmp");
  771. #endif
  772. }
  773. if (p)
  774. M_DrawTransPic (72, f, p);
  775. f += 19;
  776. if (ipxAvailable)
  777. p = Draw_CachePic ("gfx/netmen3.lmp");
  778. else
  779. p = Draw_CachePic ("gfx/dim_ipx.lmp");
  780. M_DrawTransPic (72, f, p);
  781. f += 19;
  782. if (tcpipAvailable)
  783. p = Draw_CachePic ("gfx/netmen4.lmp");
  784. else
  785. p = Draw_CachePic ("gfx/dim_tcp.lmp");
  786. M_DrawTransPic (72, f, p);
  787. if (m_net_items == 5) // JDC, could just be removed
  788. {
  789. f += 19;
  790. p = Draw_CachePic ("gfx/netmen5.lmp");
  791. M_DrawTransPic (72, f, p);
  792. }
  793. f = (320-26*8)/2;
  794. M_DrawTextBox (f, 134, 24, 4);
  795. f += 8;
  796. M_Print (f, 142, net_helpMessage[m_net_cursor*4+0]);
  797. M_Print (f, 150, net_helpMessage[m_net_cursor*4+1]);
  798. M_Print (f, 158, net_helpMessage[m_net_cursor*4+2]);
  799. M_Print (f, 166, net_helpMessage[m_net_cursor*4+3]);
  800. f = (int)(host_time * 10)%6;
  801. M_DrawTransPic (54, 32 + m_net_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
  802. }
  803. void M_Net_Key (int k)
  804. {
  805. again:
  806. switch (k)
  807. {
  808. case K_ESCAPE:
  809. M_Menu_MultiPlayer_f ();
  810. break;
  811. case K_DOWNARROW:
  812. S_LocalSound ("misc/menu1.wav");
  813. if (++m_net_cursor >= m_net_items)
  814. m_net_cursor = 0;
  815. break;
  816. case K_UPARROW:
  817. S_LocalSound ("misc/menu1.wav");
  818. if (--m_net_cursor < 0)
  819. m_net_cursor = m_net_items - 1;
  820. break;
  821. case K_ENTER:
  822. m_entersound = true;
  823. switch (m_net_cursor)
  824. {
  825. case 0:
  826. M_Menu_SerialConfig_f ();
  827. break;
  828. case 1:
  829. M_Menu_SerialConfig_f ();
  830. break;
  831. case 2:
  832. M_Menu_LanConfig_f ();
  833. break;
  834. case 3:
  835. M_Menu_LanConfig_f ();
  836. break;
  837. case 4:
  838. // multiprotocol
  839. break;
  840. }
  841. }
  842. if (m_net_cursor == 0 && !serialAvailable)
  843. goto again;
  844. if (m_net_cursor == 1 && !serialAvailable)
  845. goto again;
  846. if (m_net_cursor == 2 && !ipxAvailable)
  847. goto again;
  848. if (m_net_cursor == 3 && !tcpipAvailable)
  849. goto again;
  850. }
  851. //=============================================================================
  852. /* OPTIONS MENU */
  853. #ifdef _WIN32
  854. #define OPTIONS_ITEMS 14
  855. #else
  856. #define OPTIONS_ITEMS 13
  857. #endif
  858. #define SLIDER_RANGE 10
  859. int options_cursor;
  860. void M_Menu_Options_f (void)
  861. {
  862. key_dest = key_menu;
  863. m_state = m_options;
  864. m_entersound = true;
  865. #ifdef _WIN32
  866. if ((options_cursor == 13) && (modestate != MS_WINDOWED))
  867. {
  868. options_cursor = 0;
  869. }
  870. #endif
  871. }
  872. void M_AdjustSliders (int dir)
  873. {
  874. S_LocalSound ("misc/menu3.wav");
  875. switch (options_cursor)
  876. {
  877. case 3: // screen size
  878. scr_viewsize.value += dir * 10;
  879. if (scr_viewsize.value < 30)
  880. scr_viewsize.value = 30;
  881. if (scr_viewsize.value > 120)
  882. scr_viewsize.value = 120;
  883. Cvar_SetValue ("viewsize", scr_viewsize.value);
  884. break;
  885. case 4: // gamma
  886. v_gamma.value -= dir * 0.05;
  887. if (v_gamma.value < 0.5)
  888. v_gamma.value = 0.5;
  889. if (v_gamma.value > 1)
  890. v_gamma.value = 1;
  891. Cvar_SetValue ("gamma", v_gamma.value);
  892. break;
  893. case 5: // mouse speed
  894. sensitivity.value += dir * 0.5;
  895. if (sensitivity.value < 1)
  896. sensitivity.value = 1;
  897. if (sensitivity.value > 11)
  898. sensitivity.value = 11;
  899. Cvar_SetValue ("sensitivity", sensitivity.value);
  900. break;
  901. case 6: // music volume
  902. #ifdef _WIN32
  903. bgmvolume.value += dir * 1.0;
  904. #else
  905. bgmvolume.value += dir * 0.1;
  906. #endif
  907. if (bgmvolume.value < 0)
  908. bgmvolume.value = 0;
  909. if (bgmvolume.value > 1)
  910. bgmvolume.value = 1;
  911. Cvar_SetValue ("bgmvolume", bgmvolume.value);
  912. break;
  913. case 7: // sfx volume
  914. volume.value += dir * 0.1;
  915. if (volume.value < 0)
  916. volume.value = 0;
  917. if (volume.value > 1)
  918. volume.value = 1;
  919. Cvar_SetValue ("volume", volume.value);
  920. break;
  921. case 8: // allways run
  922. if (cl_forwardspeed.value > 200)
  923. {
  924. Cvar_SetValue ("cl_forwardspeed", 200);
  925. Cvar_SetValue ("cl_backspeed", 200);
  926. }
  927. else
  928. {
  929. Cvar_SetValue ("cl_forwardspeed", 400);
  930. Cvar_SetValue ("cl_backspeed", 400);
  931. }
  932. break;
  933. case 9: // invert mouse
  934. Cvar_SetValue ("m_pitch", -m_pitch.value);
  935. break;
  936. case 10: // lookspring
  937. Cvar_SetValue ("lookspring", !lookspring.value);
  938. break;
  939. case 11: // lookstrafe
  940. Cvar_SetValue ("lookstrafe", !lookstrafe.value);
  941. break;
  942. #ifdef _WIN32
  943. case 13: // _windowed_mouse
  944. Cvar_SetValue ("_windowed_mouse", !_windowed_mouse.value);
  945. break;
  946. #endif
  947. }
  948. }
  949. void M_DrawSlider (int x, int y, float range)
  950. {
  951. int i;
  952. if (range < 0)
  953. range = 0;
  954. if (range > 1)
  955. range = 1;
  956. M_DrawCharacter (x-8, y, 128);
  957. for (i=0 ; i<SLIDER_RANGE ; i++)
  958. M_DrawCharacter (x + i*8, y, 129);
  959. M_DrawCharacter (x+i*8, y, 130);
  960. M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
  961. }
  962. void M_DrawCheckbox (int x, int y, int on)
  963. {
  964. #if 0
  965. if (on)
  966. M_DrawCharacter (x, y, 131);
  967. else
  968. M_DrawCharacter (x, y, 129);
  969. #endif
  970. if (on)
  971. M_Print (x, y, "on");
  972. else
  973. M_Print (x, y, "off");
  974. }
  975. void M_Options_Draw (void)
  976. {
  977. float r;
  978. qpic_t *p;
  979. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  980. p = Draw_CachePic ("gfx/p_option.lmp");
  981. M_DrawPic ( (320-p->width)/2, 4, p);
  982. M_Print (16, 32, " Customize controls");
  983. M_Print (16, 40, " Go to console");
  984. M_Print (16, 48, " Reset to defaults");
  985. M_Print (16, 56, " Screen size");
  986. r = (scr_viewsize.value - 30) / (120 - 30);
  987. M_DrawSlider (220, 56, r);
  988. M_Print (16, 64, " Brightness");
  989. r = (1.0 - v_gamma.value) / 0.5;
  990. M_DrawSlider (220, 64, r);
  991. M_Print (16, 72, " Mouse Speed");
  992. r = (sensitivity.value - 1)/10;
  993. M_DrawSlider (220, 72, r);
  994. M_Print (16, 80, " CD Music Volume");
  995. r = bgmvolume.value;
  996. M_DrawSlider (220, 80, r);
  997. M_Print (16, 88, " Sound Volume");
  998. r = volume.value;
  999. M_DrawSlider (220, 88, r);
  1000. M_Print (16, 96, " Always Run");
  1001. M_DrawCheckbox (220, 96, cl_forwardspeed.value > 200);
  1002. M_Print (16, 104, " Invert Mouse");
  1003. M_DrawCheckbox (220, 104, m_pitch.value < 0);
  1004. M_Print (16, 112, " Lookspring");
  1005. M_DrawCheckbox (220, 112, lookspring.value);
  1006. M_Print (16, 120, " Lookstrafe");
  1007. M_DrawCheckbox (220, 120, lookstrafe.value);
  1008. if (vid_menudrawfn)
  1009. M_Print (16, 128, " Video Options");
  1010. #ifdef _WIN32
  1011. if (modestate == MS_WINDOWED)
  1012. {
  1013. M_Print (16, 136, " Use Mouse");
  1014. M_DrawCheckbox (220, 136, _windowed_mouse.value);
  1015. }
  1016. #endif
  1017. // cursor
  1018. M_DrawCharacter (200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
  1019. }
  1020. void M_Options_Key (int k)
  1021. {
  1022. switch (k)
  1023. {
  1024. case K_ESCAPE:
  1025. M_Menu_Main_f ();
  1026. break;
  1027. case K_ENTER:
  1028. m_entersound = true;
  1029. switch (options_cursor)
  1030. {
  1031. case 0:
  1032. M_Menu_Keys_f ();
  1033. break;
  1034. case 1:
  1035. m_state = m_none;
  1036. Con_ToggleConsole_f ();
  1037. break;
  1038. case 2:
  1039. Cbuf_AddText ("exec default.cfg\n");
  1040. break;
  1041. case 12:
  1042. M_Menu_Video_f ();
  1043. break;
  1044. default:
  1045. M_AdjustSliders (1);
  1046. break;
  1047. }
  1048. return;
  1049. case K_UPARROW:
  1050. S_LocalSound ("misc/menu1.wav");
  1051. options_cursor--;
  1052. if (options_cursor < 0)
  1053. options_cursor = OPTIONS_ITEMS-1;
  1054. break;
  1055. case K_DOWNARROW:
  1056. S_LocalSound ("misc/menu1.wav");
  1057. options_cursor++;
  1058. if (options_cursor >= OPTIONS_ITEMS)
  1059. options_cursor = 0;
  1060. break;
  1061. case K_LEFTARROW:
  1062. M_AdjustSliders (-1);
  1063. break;
  1064. case K_RIGHTARROW:
  1065. M_AdjustSliders (1);
  1066. break;
  1067. }
  1068. if (options_cursor == 12 && vid_menudrawfn == NULL)
  1069. {
  1070. if (k == K_UPARROW)
  1071. options_cursor = 11;
  1072. else
  1073. options_cursor = 0;
  1074. }
  1075. #ifdef _WIN32
  1076. if ((options_cursor == 13) && (modestate != MS_WINDOWED))
  1077. {
  1078. if (k == K_UPARROW)
  1079. options_cursor = 12;
  1080. else
  1081. options_cursor = 0;
  1082. }
  1083. #endif
  1084. }
  1085. //=============================================================================
  1086. /* KEYS MENU */
  1087. char *bindnames[][2] =
  1088. {
  1089. {"+attack", "attack"},
  1090. {"impulse 10", "change weapon"},
  1091. {"+jump", "jump / swim up"},
  1092. {"+forward", "walk forward"},
  1093. {"+back", "backpedal"},
  1094. {"+left", "turn left"},
  1095. {"+right", "turn right"},
  1096. {"+speed", "run"},
  1097. {"+moveleft", "step left"},
  1098. {"+moveright", "step right"},
  1099. {"+strafe", "sidestep"},
  1100. {"+lookup", "look up"},
  1101. {"+lookdown", "look down"},
  1102. {"centerview", "center view"},
  1103. {"+mlook", "mouse look"},
  1104. {"+klook", "keyboard look"},
  1105. {"+moveup", "swim up"},
  1106. {"+movedown", "swim down"}
  1107. };
  1108. #define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
  1109. int keys_cursor;
  1110. int bind_grab;
  1111. void M_Menu_Keys_f (void)
  1112. {
  1113. key_dest = key_menu;
  1114. m_state = m_keys;
  1115. m_entersound = true;
  1116. }
  1117. void M_FindKeysForCommand (char *command, int *twokeys)
  1118. {
  1119. int count;
  1120. int j;
  1121. int l;
  1122. char *b;
  1123. twokeys[0] = twokeys[1] = -1;
  1124. l = strlen(command);
  1125. count = 0;
  1126. for (j=0 ; j<256 ; j++)
  1127. {
  1128. b = keybindings[j];
  1129. if (!b)
  1130. continue;
  1131. if (!strncmp (b, command, l) )
  1132. {
  1133. twokeys[count] = j;
  1134. count++;
  1135. if (count == 2)
  1136. break;
  1137. }
  1138. }
  1139. }
  1140. void M_UnbindCommand (char *command)
  1141. {
  1142. int j;
  1143. int l;
  1144. char *b;
  1145. l = strlen(command);
  1146. for (j=0 ; j<256 ; j++)
  1147. {
  1148. b = keybindings[j];
  1149. if (!b)
  1150. continue;
  1151. if (!strncmp (b, command, l) )
  1152. Key_SetBinding (j, "");
  1153. }
  1154. }
  1155. void M_Keys_Draw (void)
  1156. {
  1157. int i, l;
  1158. int keys[2];
  1159. char *name;
  1160. int x, y;
  1161. qpic_t *p;
  1162. p = Draw_CachePic ("gfx/ttl_cstm.lmp");
  1163. M_DrawPic ( (320-p->width)/2, 4, p);
  1164. if (bind_grab)
  1165. M_Print (12, 32, "Press a key or button for this action");
  1166. else
  1167. M_Print (18, 32, "Enter to change, backspace to clear");
  1168. // search for known bindings
  1169. for (i=0 ; i<NUMCOMMANDS ; i++)
  1170. {
  1171. y = 48 + 8*i;
  1172. M_Print (16, y, bindnames[i][1]);
  1173. l = strlen (bindnames[i][0]);
  1174. M_FindKeysForCommand (bindnames[i][0], keys);
  1175. if (keys[0] == -1)
  1176. {
  1177. M_Print (140, y, "???");
  1178. }
  1179. else
  1180. {
  1181. name = Key_KeynumToString (keys[0]);
  1182. M_Print (140, y, name);
  1183. x = strlen(name) * 8;
  1184. if (keys[1] != -1)
  1185. {
  1186. M_Print (140 + x + 8, y, "or");
  1187. M_Print (140 + x + 32, y, Key_KeynumToString (keys[1]));
  1188. }
  1189. }
  1190. }
  1191. if (bind_grab)
  1192. M_DrawCharacter (130, 48 + keys_cursor*8, '=');
  1193. else
  1194. M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
  1195. }
  1196. void M_Keys_Key (int k)
  1197. {
  1198. char cmd[80];
  1199. int keys[2];
  1200. if (bind_grab)
  1201. { // defining a key
  1202. S_LocalSound ("misc/menu1.wav");
  1203. if (k == K_ESCAPE)
  1204. {
  1205. bind_grab = false;
  1206. }
  1207. else if (k != '`')
  1208. {
  1209. sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
  1210. Cbuf_InsertText (cmd);
  1211. }
  1212. bind_grab = false;
  1213. return;
  1214. }
  1215. switch (k)
  1216. {
  1217. case K_ESCAPE:
  1218. M_Menu_Options_f ();
  1219. break;
  1220. case K_LEFTARROW:
  1221. case K_UPARROW:
  1222. S_LocalSound ("misc/menu1.wav");
  1223. keys_cursor--;
  1224. if (keys_cursor < 0)
  1225. keys_cursor = NUMCOMMANDS-1;
  1226. break;
  1227. case K_DOWNARROW:
  1228. case K_RIGHTARROW:
  1229. S_LocalSound ("misc/menu1.wav");
  1230. keys_cursor++;
  1231. if (keys_cursor >= NUMCOMMANDS)
  1232. keys_cursor = 0;
  1233. break;
  1234. case K_ENTER: // go into bind mode
  1235. M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
  1236. S_LocalSound ("misc/menu2.wav");
  1237. if (keys[1] != -1)
  1238. M_UnbindCommand (bindnames[keys_cursor][0]);
  1239. bind_grab = true;
  1240. break;
  1241. case K_BACKSPACE: // delete bindings
  1242. case K_DEL: // delete bindings
  1243. S_LocalSound ("misc/menu2.wav");
  1244. M_UnbindCommand (bindnames[keys_cursor][0]);
  1245. break;
  1246. }
  1247. }
  1248. //=============================================================================
  1249. /* VIDEO MENU */
  1250. void M_Menu_Video_f (void)
  1251. {
  1252. key_dest = key_menu;
  1253. m_state = m_video;
  1254. m_entersound = true;
  1255. }
  1256. void M_Video_Draw (void)
  1257. {
  1258. (*vid_menudrawfn) ();
  1259. }
  1260. void M_Video_Key (int key)
  1261. {
  1262. (*vid_menukeyfn) (key);
  1263. }
  1264. //=============================================================================
  1265. /* HELP MENU */
  1266. int help_page;
  1267. #define NUM_HELP_PAGES 6
  1268. void M_Menu_Help_f (void)
  1269. {
  1270. key_dest = key_menu;
  1271. m_state = m_help;
  1272. m_entersound = true;
  1273. help_page = 0;
  1274. }
  1275. void M_Help_Draw (void)
  1276. {
  1277. M_DrawPic (0, 0, Draw_CachePic ( va("gfx/help%i.lmp", help_page)) );
  1278. }
  1279. void M_Help_Key (int key)
  1280. {
  1281. switch (key)
  1282. {
  1283. case K_ESCAPE:
  1284. M_Menu_Main_f ();
  1285. break;
  1286. case K_UPARROW:
  1287. case K_RIGHTARROW:
  1288. m_entersound = true;
  1289. if (++help_page >= NUM_HELP_PAGES)
  1290. help_page = 0;
  1291. break;
  1292. case K_DOWNARROW:
  1293. case K_LEFTARROW:
  1294. m_entersound = true;
  1295. if (--help_page < 0)
  1296. help_page = NUM_HELP_PAGES-1;
  1297. break;
  1298. }
  1299. }
  1300. //=============================================================================
  1301. /* QUIT MENU */
  1302. int msgNumber;
  1303. int m_quit_prevstate;
  1304. qboolean wasInMenus;
  1305. #ifndef _WIN32
  1306. char *quitMessage [] =
  1307. {
  1308. /* .........1.........2.... */
  1309. " Are you gonna quit ",
  1310. " this game just like ",
  1311. " everything else? ",
  1312. " ",
  1313. " Milord, methinks that ",
  1314. " thou art a lowly ",
  1315. " quitter. Is this true? ",
  1316. " ",
  1317. " Do I need to bust your ",
  1318. " face open for trying ",
  1319. " to quit? ",
  1320. " ",
  1321. " Man, I oughta smack you",
  1322. " for trying to quit! ",
  1323. " Press Y to get ",
  1324. " smacked out. ",
  1325. " Press Y to quit like a ",
  1326. " big loser in life. ",
  1327. " Press N to stay proud ",
  1328. " and successful! ",
  1329. " If you press Y to ",
  1330. " quit, I will summon ",
  1331. " Satan all over your ",
  1332. " hard drive! ",
  1333. " Um, Asmodeus dislikes ",
  1334. " his children trying to ",
  1335. " quit. Press Y to return",
  1336. " to your Tinkertoys. ",
  1337. " If you quit now, I'll ",
  1338. " throw a blanket-party ",
  1339. " for you next time! ",
  1340. " "
  1341. };
  1342. #endif
  1343. void M_Menu_Quit_f (void)
  1344. {
  1345. if (m_state == m_quit)
  1346. return;
  1347. wasInMenus = (key_dest == key_menu);
  1348. key_dest = key_menu;
  1349. m_quit_prevstate = m_state;
  1350. m_state = m_quit;
  1351. m_entersound = true;
  1352. msgNumber = rand()&7;
  1353. }
  1354. void M_Quit_Key (int key)
  1355. {
  1356. switch (key)
  1357. {
  1358. case K_ESCAPE:
  1359. case 'n':
  1360. case 'N':
  1361. if (wasInMenus)
  1362. {
  1363. m_state = m_quit_prevstate;
  1364. m_entersound = true;
  1365. }
  1366. else
  1367. {
  1368. key_dest = key_game;
  1369. m_state = m_none;
  1370. }
  1371. break;
  1372. case 'Y':
  1373. case 'y':
  1374. key_dest = key_console;
  1375. Host_Quit_f ();
  1376. break;
  1377. default:
  1378. break;
  1379. }
  1380. }
  1381. void M_Quit_Draw (void)
  1382. {
  1383. if (wasInMenus)
  1384. {
  1385. m_state = m_quit_prevstate;
  1386. m_recursiveDraw = true;
  1387. M_Draw ();
  1388. m_state = m_quit;
  1389. }
  1390. #ifdef _WIN32
  1391. M_DrawTextBox (0, 0, 38, 23);
  1392. M_PrintWhite (16, 12, " Quake version 1.09 by id Software\n\n");
  1393. M_PrintWhite (16, 28, "Programming Art \n");
  1394. M_Print (16, 36, " John Carmack Adrian Carmack\n");
  1395. M_Print (16, 44, " Michael Abrash Kevin Cloud\n");
  1396. M_Print (16, 52, " John Cash Paul Steed\n");
  1397. M_Print (16, 60, " Dave 'Zoid' Kirsch\n");
  1398. M_PrintWhite (16, 68, "Design Biz\n");
  1399. M_Print (16, 76, " John Romero Jay Wilbur\n");
  1400. M_Print (16, 84, " Sandy Petersen Mike Wilson\n");
  1401. M_Print (16, 92, " American McGee Donna Jackson\n");
  1402. M_Print (16, 100, " Tim Willits Todd Hollenshead\n");
  1403. M_PrintWhite (16, 108, "Support Projects\n");
  1404. M_Print (16, 116, " Barrett Alexander Shawn Green\n");
  1405. M_PrintWhite (16, 124, "Sound Effects\n");
  1406. M_Print (16, 132, " Trent Reznor and Nine Inch Nails\n\n");
  1407. M_PrintWhite (16, 140, "Quake is a trademark of Id Software,\n");
  1408. M_PrintWhite (16, 148, "inc., (c)1996 Id Software, inc. All\n");
  1409. M_PrintWhite (16, 156, "rights reserved. NIN logo is a\n");
  1410. M_PrintWhite (16, 164, "registered trademark licensed to\n");
  1411. M_PrintWhite (16, 172, "Nothing Interactive, Inc. All rights\n");
  1412. M_PrintWhite (16, 180, "reserved. Press y to exit\n");
  1413. #else
  1414. M_DrawTextBox (56, 76, 24, 4);
  1415. M_Print (64, 84, quitMessage[msgNumber*4+0]);
  1416. M_Print (64, 92, quitMessage[msgNumber*4+1]);
  1417. M_Print (64, 100, quitMessage[msgNumber*4+2]);
  1418. M_Print (64, 108, quitMessage[msgNumber*4+3]);
  1419. #endif
  1420. }
  1421. //=============================================================================
  1422. /* SERIAL CONFIG MENU */
  1423. int serialConfig_cursor;
  1424. int serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132};
  1425. #define NUM_SERIALCONFIG_CMDS 6
  1426. static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8};
  1427. static int ISA_IRQs[] = {4,3,4,3};
  1428. int serialConfig_baudrate[] = {9600,14400,19200,28800,38400,57600};
  1429. int serialConfig_comport;
  1430. int serialConfig_irq ;
  1431. int serialConfig_baud;
  1432. char serialConfig_phone[16];
  1433. void M_Menu_SerialConfig_f (void)
  1434. {
  1435. int n;
  1436. int port;
  1437. int baudrate;
  1438. qboolean useModem;
  1439. key_dest = key_menu;
  1440. m_state = m_serialconfig;
  1441. m_entersound = true;
  1442. if (JoiningGame && SerialConfig)
  1443. serialConfig_cursor = 4;
  1444. else
  1445. serialConfig_cursor = 5;
  1446. (*GetComPortConfig) (0, &port, &serialConfig_irq, &baudrate, &useModem);
  1447. // map uart's port to COMx
  1448. for (n = 0; n < 4; n++)
  1449. if (ISA_uarts[n] == port)
  1450. break;
  1451. if (n == 4)
  1452. {
  1453. n = 0;
  1454. serialConfig_irq = 4;
  1455. }
  1456. serialConfig_comport = n + 1;
  1457. // map baudrate to index
  1458. for (n = 0; n < 6; n++)
  1459. if (serialConfig_baudrate[n] == baudrate)
  1460. break;
  1461. if (n == 6)
  1462. n = 5;
  1463. serialConfig_baud = n;
  1464. m_return_onerror = false;
  1465. m_return_reason[0] = 0;
  1466. }
  1467. void M_SerialConfig_Draw (void)
  1468. {
  1469. qpic_t *p;
  1470. int basex;
  1471. char *startJoin;
  1472. char *directModem;
  1473. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  1474. p = Draw_CachePic ("gfx/p_multi.lmp");
  1475. basex = (320-p->width)/2;
  1476. M_DrawPic (basex, 4, p);
  1477. if (StartingGame)
  1478. startJoin = "New Game";
  1479. else
  1480. startJoin = "Join Game";
  1481. if (SerialConfig)
  1482. directModem = "Modem";
  1483. else
  1484. directModem = "Direct Connect";
  1485. M_Print (basex, 32, va ("%s - %s", startJoin, directModem));
  1486. basex += 8;
  1487. M_Print (basex, serialConfig_cursor_table[0], "Port");
  1488. M_DrawTextBox (160, 40, 4, 1);
  1489. M_Print (168, serialConfig_cursor_table[0], va("COM%u", serialConfig_comport));
  1490. M_Print (basex, serialConfig_cursor_table[1], "IRQ");
  1491. M_DrawTextBox (160, serialConfig_cursor_table[1]-8, 1, 1);
  1492. M_Print (168, serialConfig_cursor_table[1], va("%u", serialConfig_irq));
  1493. M_Print (basex, serialConfig_cursor_table[2], "Baud");
  1494. M_DrawTextBox (160, serialConfig_cursor_table[2]-8, 5, 1);
  1495. M_Print (168, serialConfig_cursor_table[2], va("%u", serialConfig_baudrate[serialConfig_baud]));
  1496. if (SerialConfig)
  1497. {
  1498. M_Print (basex, serialConfig_cursor_table[3], "Modem Setup...");
  1499. if (JoiningGame)
  1500. {
  1501. M_Print (basex, serialConfig_cursor_table[4], "Phone number");
  1502. M_DrawTextBox (160, serialConfig_cursor_table[4]-8, 16, 1);
  1503. M_Print (168, serialConfig_cursor_table[4], serialConfig_phone);
  1504. }
  1505. }
  1506. if (JoiningGame)
  1507. {
  1508. M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 7, 1);
  1509. M_Print (basex+8, serialConfig_cursor_table[5], "Connect");
  1510. }
  1511. else
  1512. {
  1513. M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 2, 1);
  1514. M_Print (basex+8, serialConfig_cursor_table[5], "OK");
  1515. }
  1516. M_DrawCharacter (basex-8, serialConfig_cursor_table [serialConfig_cursor], 12+((int)(realtime*4)&1));
  1517. if (serialConfig_cursor == 4)
  1518. M_DrawCharacter (168 + 8*strlen(serialConfig_phone), serialConfig_cursor_table [serialConfig_cursor], 10+((int)(realtime*4)&1));
  1519. if (*m_return_reason)
  1520. M_PrintWhite (basex, 148, m_return_reason);
  1521. }
  1522. void M_SerialConfig_Key (int key)
  1523. {
  1524. int l;
  1525. switch (key)
  1526. {
  1527. case K_ESCAPE:
  1528. M_Menu_Net_f ();
  1529. break;
  1530. case K_UPARROW:
  1531. S_LocalSound ("misc/menu1.wav");
  1532. serialConfig_cursor--;
  1533. if (serialConfig_cursor < 0)
  1534. serialConfig_cursor = NUM_SERIALCONFIG_CMDS-1;
  1535. break;
  1536. case K_DOWNARROW:
  1537. S_LocalSound ("misc/menu1.wav");
  1538. serialConfig_cursor++;
  1539. if (serialConfig_cursor >= NUM_SERIALCONFIG_CMDS)
  1540. serialConfig_cursor = 0;
  1541. break;
  1542. case K_LEFTARROW:
  1543. if (serialConfig_cursor > 2)
  1544. break;
  1545. S_LocalSound ("misc/menu3.wav");
  1546. if (serialConfig_cursor == 0)
  1547. {
  1548. serialConfig_comport--;
  1549. if (serialConfig_comport == 0)
  1550. serialConfig_comport = 4;
  1551. serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
  1552. }
  1553. if (serialConfig_cursor == 1)
  1554. {
  1555. serialConfig_irq--;
  1556. if (serialConfig_irq == 6)
  1557. serialConfig_irq = 5;
  1558. if (serialConfig_irq == 1)
  1559. serialConfig_irq = 7;
  1560. }
  1561. if (serialConfig_cursor == 2)
  1562. {
  1563. serialConfig_baud--;
  1564. if (serialConfig_baud < 0)
  1565. serialConfig_baud = 5;
  1566. }
  1567. break;
  1568. case K_RIGHTARROW:
  1569. if (serialConfig_cursor > 2)
  1570. break;
  1571. forward:
  1572. S_LocalSound ("misc/menu3.wav");
  1573. if (serialConfig_cursor == 0)
  1574. {
  1575. serialConfig_comport++;
  1576. if (serialConfig_comport > 4)
  1577. serialConfig_comport = 1;
  1578. serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
  1579. }
  1580. if (serialConfig_cursor == 1)
  1581. {
  1582. serialConfig_irq++;
  1583. if (serialConfig_irq == 6)
  1584. serialConfig_irq = 7;
  1585. if (serialConfig_irq == 8)
  1586. serialConfig_irq = 2;
  1587. }
  1588. if (serialConfig_cursor == 2)
  1589. {
  1590. serialConfig_baud++;
  1591. if (serialConfig_baud > 5)
  1592. serialConfig_baud = 0;
  1593. }
  1594. break;
  1595. case K_ENTER:
  1596. if (serialConfig_cursor < 3)
  1597. goto forward;
  1598. m_entersound = true;
  1599. if (serialConfig_cursor == 3)
  1600. {
  1601. (*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
  1602. M_Menu_ModemConfig_f ();
  1603. break;
  1604. }
  1605. if (serialConfig_cursor == 4)
  1606. {
  1607. serialConfig_cursor = 5;
  1608. break;
  1609. }
  1610. // serialConfig_cursor == 5 (OK/CONNECT)
  1611. (*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
  1612. M_ConfigureNetSubsystem ();
  1613. if (StartingGame)
  1614. {
  1615. M_Menu_GameOptions_f ();
  1616. break;
  1617. }
  1618. m_return_state = m_state;
  1619. m_return_onerror = true;
  1620. key_dest = key_game;
  1621. m_state = m_none;
  1622. if (SerialConfig)
  1623. Cbuf_AddText (va ("connect \"%s\"\n", serialConfig_phone));
  1624. else
  1625. Cbuf_AddText ("connect\n");
  1626. break;
  1627. case K_BACKSPACE:
  1628. if (serialConfig_cursor == 4)
  1629. {
  1630. if (strlen(serialConfig_phone))
  1631. serialConfig_phone[strlen(serialConfig_phone)-1] = 0;
  1632. }
  1633. break;
  1634. default:
  1635. if (key < 32 || key > 127)
  1636. break;
  1637. if (serialConfig_cursor == 4)
  1638. {
  1639. l = strlen(serialConfig_phone);
  1640. if (l < 15)
  1641. {
  1642. serialConfig_phone[l+1] = 0;
  1643. serialConfig_phone[l] = key;
  1644. }
  1645. }
  1646. }
  1647. if (DirectConfig && (serialConfig_cursor == 3 || serialConfig_cursor == 4))
  1648. if (key == K_UPARROW)
  1649. serialConfig_cursor = 2;
  1650. else
  1651. serialConfig_cursor = 5;
  1652. if (SerialConfig && StartingGame && serialConfig_cursor == 4)
  1653. if (key == K_UPARROW)
  1654. serialConfig_cursor = 3;
  1655. else
  1656. serialConfig_cursor = 5;
  1657. }
  1658. //=============================================================================
  1659. /* MODEM CONFIG MENU */
  1660. int modemConfig_cursor;
  1661. int modemConfig_cursor_table [] = {40, 56, 88, 120, 156};
  1662. #define NUM_MODEMCONFIG_CMDS 5
  1663. char modemConfig_dialing;
  1664. char modemConfig_clear [16];
  1665. char modemConfig_init [32];
  1666. char modemConfig_hangup [16];
  1667. void M_Menu_ModemConfig_f (void)
  1668. {
  1669. key_dest = key_menu;
  1670. m_state = m_modemconfig;
  1671. m_entersound = true;
  1672. (*GetModemConfig) (0, &modemConfig_dialing, modemConfig_clear, modemConfig_init, modemConfig_hangup);
  1673. }
  1674. void M_ModemConfig_Draw (void)
  1675. {
  1676. qpic_t *p;
  1677. int basex;
  1678. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  1679. p = Draw_CachePic ("gfx/p_multi.lmp");
  1680. basex = (320-p->width)/2;
  1681. M_DrawPic (basex, 4, p);
  1682. basex += 8;
  1683. if (modemConfig_dialing == 'P')
  1684. M_Print (basex, modemConfig_cursor_table[0], "Pulse Dialing");
  1685. else
  1686. M_Print (basex, modemConfig_cursor_table[0], "Touch Tone Dialing");
  1687. M_Print (basex, modemConfig_cursor_table[1], "Clear");
  1688. M_DrawTextBox (basex, modemConfig_cursor_table[1]+4, 16, 1);
  1689. M_Print (basex+8, modemConfig_cursor_table[1]+12, modemConfig_clear);
  1690. if (modemConfig_cursor == 1)
  1691. M_DrawCharacter (basex+8 + 8*strlen(modemConfig_clear), modemConfig_cursor_table[1]+12, 10+((int)(realtime*4)&1));
  1692. M_Print (basex, modemConfig_cursor_table[2], "Init");
  1693. M_DrawTextBox (basex, modemConfig_cursor_table[2]+4, 30, 1);
  1694. M_Print (basex+8, modemConfig_cursor_table[2]+12, modemConfig_init);
  1695. if (modemConfig_cursor == 2)
  1696. M_DrawCharacter (basex+8 + 8*strlen(modemConfig_init), modemConfig_cursor_table[2]+12, 10+((int)(realtime*4)&1));
  1697. M_Print (basex, modemConfig_cursor_table[3], "Hangup");
  1698. M_DrawTextBox (basex, modemConfig_cursor_table[3]+4, 16, 1);
  1699. M_Print (basex+8, modemConfig_cursor_table[3]+12, modemConfig_hangup);
  1700. if (modemConfig_cursor == 3)
  1701. M_DrawCharacter (basex+8 + 8*strlen(modemConfig_hangup), modemConfig_cursor_table[3]+12, 10+((int)(realtime*4)&1));
  1702. M_DrawTextBox (basex, modemConfig_cursor_table[4]-8, 2, 1);
  1703. M_Print (basex+8, modemConfig_cursor_table[4], "OK");
  1704. M_DrawCharacter (basex-8, modemConfig_cursor_table [modemConfig_cursor], 12+((int)(realtime*4)&1));
  1705. }
  1706. void M_ModemConfig_Key (int key)
  1707. {
  1708. int l;
  1709. switch (key)
  1710. {
  1711. case K_ESCAPE:
  1712. M_Menu_SerialConfig_f ();
  1713. break;
  1714. case K_UPARROW:
  1715. S_LocalSound ("misc/menu1.wav");
  1716. modemConfig_cursor--;
  1717. if (modemConfig_cursor < 0)
  1718. modemConfig_cursor = NUM_MODEMCONFIG_CMDS-1;
  1719. break;
  1720. case K_DOWNARROW:
  1721. S_LocalSound ("misc/menu1.wav");
  1722. modemConfig_cursor++;
  1723. if (modemConfig_cursor >= NUM_MODEMCONFIG_CMDS)
  1724. modemConfig_cursor = 0;
  1725. break;
  1726. case K_LEFTARROW:
  1727. case K_RIGHTARROW:
  1728. if (modemConfig_cursor == 0)
  1729. {
  1730. if (modemConfig_dialing == 'P')
  1731. modemConfig_dialing = 'T';
  1732. else
  1733. modemConfig_dialing = 'P';
  1734. S_LocalSound ("misc/menu1.wav");
  1735. }
  1736. break;
  1737. case K_ENTER:
  1738. if (modemConfig_cursor == 0)
  1739. {
  1740. if (modemConfig_dialing == 'P')
  1741. modemConfig_dialing = 'T';
  1742. else
  1743. modemConfig_dialing = 'P';
  1744. m_entersound = true;
  1745. }
  1746. if (modemConfig_cursor == 4)
  1747. {
  1748. (*SetModemConfig) (0, va ("%c", modemConfig_dialing), modemConfig_clear, modemConfig_init, modemConfig_hangup);
  1749. m_entersound = true;
  1750. M_Menu_SerialConfig_f ();
  1751. }
  1752. break;
  1753. case K_BACKSPACE:
  1754. if (modemConfig_cursor == 1)
  1755. {
  1756. if (strlen(modemConfig_clear))
  1757. modemConfig_clear[strlen(modemConfig_clear)-1] = 0;
  1758. }
  1759. if (modemConfig_cursor == 2)
  1760. {
  1761. if (strlen(modemConfig_init))
  1762. modemConfig_init[strlen(modemConfig_init)-1] = 0;
  1763. }
  1764. if (modemConfig_cursor == 3)
  1765. {
  1766. if (strlen(modemConfig_hangup))
  1767. modemConfig_hangup[strlen(modemConfig_hangup)-1] = 0;
  1768. }
  1769. break;
  1770. default:
  1771. if (key < 32 || key > 127)
  1772. break;
  1773. if (modemConfig_cursor == 1)
  1774. {
  1775. l = strlen(modemConfig_clear);
  1776. if (l < 15)
  1777. {
  1778. modemConfig_clear[l+1] = 0;
  1779. modemConfig_clear[l] = key;
  1780. }
  1781. }
  1782. if (modemConfig_cursor == 2)
  1783. {
  1784. l = strlen(modemConfig_init);
  1785. if (l < 29)
  1786. {
  1787. modemConfig_init[l+1] = 0;
  1788. modemConfig_init[l] = key;
  1789. }
  1790. }
  1791. if (modemConfig_cursor == 3)
  1792. {
  1793. l = strlen(modemConfig_hangup);
  1794. if (l < 15)
  1795. {
  1796. modemConfig_hangup[l+1] = 0;
  1797. modemConfig_hangup[l] = key;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. //=============================================================================
  1803. /* LAN CONFIG MENU */
  1804. int lanConfig_cursor = -1;
  1805. int lanConfig_cursor_table [] = {72, 92, 124};
  1806. #define NUM_LANCONFIG_CMDS 3
  1807. int lanConfig_port;
  1808. char lanConfig_portname[6];
  1809. char lanConfig_joinname[22];
  1810. void M_Menu_LanConfig_f (void)
  1811. {
  1812. key_dest = key_menu;
  1813. m_state = m_lanconfig;
  1814. m_entersound = true;
  1815. if (lanConfig_cursor == -1)
  1816. {
  1817. if (JoiningGame && TCPIPConfig)
  1818. lanConfig_cursor = 2;
  1819. else
  1820. lanConfig_cursor = 1;
  1821. }
  1822. if (StartingGame && lanConfig_cursor == 2)
  1823. lanConfig_cursor = 1;
  1824. lanConfig_port = DEFAULTnet_hostport;
  1825. sprintf(lanConfig_portname, "%u", lanConfig_port);
  1826. m_return_onerror = false;
  1827. m_return_reason[0] = 0;
  1828. }
  1829. void M_LanConfig_Draw (void)
  1830. {
  1831. qpic_t *p;
  1832. int basex;
  1833. char *startJoin;
  1834. char *protocol;
  1835. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  1836. p = Draw_CachePic ("gfx/p_multi.lmp");
  1837. basex = (320-p->width)/2;
  1838. M_DrawPic (basex, 4, p);
  1839. if (StartingGame)
  1840. startJoin = "New Game";
  1841. else
  1842. startJoin = "Join Game";
  1843. if (IPXConfig)
  1844. protocol = "IPX";
  1845. else
  1846. protocol = "TCP/IP";
  1847. M_Print (basex, 32, va ("%s - %s", startJoin, protocol));
  1848. basex += 8;
  1849. M_Print (basex, 52, "Address:");
  1850. if (IPXConfig)
  1851. M_Print (basex+9*8, 52, my_ipx_address);
  1852. else
  1853. M_Print (basex+9*8, 52, my_tcpip_address);
  1854. M_Print (basex, lanConfig_cursor_table[0], "Port");
  1855. M_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
  1856. M_Print (basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
  1857. if (JoiningGame)
  1858. {
  1859. M_Print (basex, lanConfig_cursor_table[1], "Search for local games...");
  1860. M_Print (basex, 108, "Join game at:");
  1861. M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
  1862. M_Print (basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
  1863. }
  1864. else
  1865. {
  1866. M_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
  1867. M_Print (basex+8, lanConfig_cursor_table[1], "OK");
  1868. }
  1869. M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
  1870. if (lanConfig_cursor == 0)
  1871. M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
  1872. if (lanConfig_cursor == 2)
  1873. M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
  1874. if (*m_return_reason)
  1875. M_PrintWhite (basex, 148, m_return_reason);
  1876. }
  1877. void M_LanConfig_Key (int key)
  1878. {
  1879. int l;
  1880. switch (key)
  1881. {
  1882. case K_ESCAPE:
  1883. M_Menu_Net_f ();
  1884. break;
  1885. case K_UPARROW:
  1886. S_LocalSound ("misc/menu1.wav");
  1887. lanConfig_cursor--;
  1888. if (lanConfig_cursor < 0)
  1889. lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
  1890. break;
  1891. case K_DOWNARROW:
  1892. S_LocalSound ("misc/menu1.wav");
  1893. lanConfig_cursor++;
  1894. if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
  1895. lanConfig_cursor = 0;
  1896. break;
  1897. case K_ENTER:
  1898. if (lanConfig_cursor == 0)
  1899. break;
  1900. m_entersound = true;
  1901. M_ConfigureNetSubsystem ();
  1902. if (lanConfig_cursor == 1)
  1903. {
  1904. if (StartingGame)
  1905. {
  1906. M_Menu_GameOptions_f ();
  1907. break;
  1908. }
  1909. M_Menu_Search_f();
  1910. break;
  1911. }
  1912. if (lanConfig_cursor == 2)
  1913. {
  1914. m_return_state = m_state;
  1915. m_return_onerror = true;
  1916. key_dest = key_game;
  1917. m_state = m_none;
  1918. Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
  1919. break;
  1920. }
  1921. break;
  1922. case K_BACKSPACE:
  1923. if (lanConfig_cursor == 0)
  1924. {
  1925. if (strlen(lanConfig_portname))
  1926. lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
  1927. }
  1928. if (lanConfig_cursor == 2)
  1929. {
  1930. if (strlen(lanConfig_joinname))
  1931. lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
  1932. }
  1933. break;
  1934. default:
  1935. if (key < 32 || key > 127)
  1936. break;
  1937. if (lanConfig_cursor == 2)
  1938. {
  1939. l = strlen(lanConfig_joinname);
  1940. if (l < 21)
  1941. {
  1942. lanConfig_joinname[l+1] = 0;
  1943. lanConfig_joinname[l] = key;
  1944. }
  1945. }
  1946. if (key < '0' || key > '9')
  1947. break;
  1948. if (lanConfig_cursor == 0)
  1949. {
  1950. l = strlen(lanConfig_portname);
  1951. if (l < 5)
  1952. {
  1953. lanConfig_portname[l+1] = 0;
  1954. lanConfig_portname[l] = key;
  1955. }
  1956. }
  1957. }
  1958. if (StartingGame && lanConfig_cursor == 2)
  1959. if (key == K_UPARROW)
  1960. lanConfig_cursor = 1;
  1961. else
  1962. lanConfig_cursor = 0;
  1963. l = Q_atoi(lanConfig_portname);
  1964. if (l > 65535)
  1965. l = lanConfig_port;
  1966. else
  1967. lanConfig_port = l;
  1968. sprintf(lanConfig_portname, "%u", lanConfig_port);
  1969. }
  1970. //=============================================================================
  1971. /* GAME OPTIONS MENU */
  1972. typedef struct
  1973. {
  1974. char *name;
  1975. char *description;
  1976. } level_t;
  1977. level_t levels[] =
  1978. {
  1979. {"start", "Entrance"}, // 0
  1980. {"e1m1", "Slipgate Complex"}, // 1
  1981. {"e1m2", "Castle of the Damned"},
  1982. {"e1m3", "The Necropolis"},
  1983. {"e1m4", "The Grisly Grotto"},
  1984. {"e1m5", "Gloom Keep"},
  1985. {"e1m6", "The Door To Chthon"},
  1986. {"e1m7", "The House of Chthon"},
  1987. {"e1m8", "Ziggurat Vertigo"},
  1988. {"e2m1", "The Installation"}, // 9
  1989. {"e2m2", "Ogre Citadel"},
  1990. {"e2m3", "Crypt of Decay"},
  1991. {"e2m4", "The Ebon Fortress"},
  1992. {"e2m5", "The Wizard's Manse"},
  1993. {"e2m6", "The Dismal Oubliette"},
  1994. {"e2m7", "Underearth"},
  1995. {"e3m1", "Termination Central"}, // 16
  1996. {"e3m2", "The Vaults of Zin"},
  1997. {"e3m3", "The Tomb of Terror"},
  1998. {"e3m4", "Satan's Dark Delight"},
  1999. {"e3m5", "Wind Tunnels"},
  2000. {"e3m6", "Chambers of Torment"},
  2001. {"e3m7", "The Haunted Halls"},
  2002. {"e4m1", "The Sewage System"}, // 23
  2003. {"e4m2", "The Tower of Despair"},
  2004. {"e4m3", "The Elder God Shrine"},
  2005. {"e4m4", "The Palace of Hate"},
  2006. {"e4m5", "Hell's Atrium"},
  2007. {"e4m6", "The Pain Maze"},
  2008. {"e4m7", "Azure Agony"},
  2009. {"e4m8", "The Nameless City"},
  2010. {"end", "Shub-Niggurath's Pit"}, // 31
  2011. {"dm1", "Place of Two Deaths"}, // 32
  2012. {"dm2", "Claustrophobopolis"},
  2013. {"dm3", "The Abandoned Base"},
  2014. {"dm4", "The Bad Place"},
  2015. {"dm5", "The Cistern"},
  2016. {"dm6", "The Dark Zone"}
  2017. };
  2018. //MED 01/06/97 added hipnotic levels
  2019. level_t hipnoticlevels[] =
  2020. {
  2021. {"start", "Command HQ"}, // 0
  2022. {"hip1m1", "The Pumping Station"}, // 1
  2023. {"hip1m2", "Storage Facility"},
  2024. {"hip1m3", "The Lost Mine"},
  2025. {"hip1m4", "Research Facility"},
  2026. {"hip1m5", "Military Complex"},
  2027. {"hip2m1", "Ancient Realms"}, // 6
  2028. {"hip2m2", "The Black Cathedral"},
  2029. {"hip2m3", "The Catacombs"},
  2030. {"hip2m4", "The Crypt"},
  2031. {"hip2m5", "Mortum's Keep"},
  2032. {"hip2m6", "The Gremlin's Domain"},
  2033. {"hip3m1", "Tur Torment"}, // 12
  2034. {"hip3m2", "Pandemonium"},
  2035. {"hip3m3", "Limbo"},
  2036. {"hip3m4", "The Gauntlet"},
  2037. {"hipend", "Armagon's Lair"}, // 16
  2038. {"hipdm1", "The Edge of Oblivion"} // 17
  2039. };
  2040. //PGM 01/07/97 added rogue levels
  2041. //PGM 03/02/97 added dmatch level
  2042. level_t roguelevels[] =
  2043. {
  2044. {"start", "Split Decision"},
  2045. {"r1m1", "Deviant's Domain"},
  2046. {"r1m2", "Dread Portal"},
  2047. {"r1m3", "Judgement Call"},
  2048. {"r1m4", "Cave of Death"},
  2049. {"r1m5", "Towers of Wrath"},
  2050. {"r1m6", "Temple of Pain"},
  2051. {"r1m7", "Tomb of the Overlord"},
  2052. {"r2m1", "Tempus Fugit"},
  2053. {"r2m2", "Elemental Fury I"},
  2054. {"r2m3", "Elemental Fury II"},
  2055. {"r2m4", "Curse of Osiris"},
  2056. {"r2m5", "Wizard's Keep"},
  2057. {"r2m6", "Blood Sacrifice"},
  2058. {"r2m7", "Last Bastion"},
  2059. {"r2m8", "Source of Evil"},
  2060. {"ctf1", "Division of Change"}
  2061. };
  2062. typedef struct
  2063. {
  2064. char *description;
  2065. int firstLevel;
  2066. int levels;
  2067. } episode_t;
  2068. episode_t episodes[] =
  2069. {
  2070. {"Welcome to Quake", 0, 1},
  2071. {"Doomed Dimension", 1, 8},
  2072. {"Realm of Black Magic", 9, 7},
  2073. {"Netherworld", 16, 7},
  2074. {"The Elder World", 23, 8},
  2075. {"Final Level", 31, 1},
  2076. {"Deathmatch Arena", 32, 6}
  2077. };
  2078. //MED 01/06/97 added hipnotic episodes
  2079. episode_t hipnoticepisodes[] =
  2080. {
  2081. {"Scourge of Armagon", 0, 1},
  2082. {"Fortress of the Dead", 1, 5},
  2083. {"Dominion of Darkness", 6, 6},
  2084. {"The Rift", 12, 4},
  2085. {"Final Level", 16, 1},
  2086. {"Deathmatch Arena", 17, 1}
  2087. };
  2088. //PGM 01/07/97 added rogue episodes
  2089. //PGM 03/02/97 added dmatch episode
  2090. episode_t rogueepisodes[] =
  2091. {
  2092. {"Introduction", 0, 1},
  2093. {"Hell's Fortress", 1, 7},
  2094. {"Corridors of Time", 8, 8},
  2095. {"Deathmatch Arena", 16, 1}
  2096. };
  2097. int startepisode;
  2098. int startlevel;
  2099. int maxplayers;
  2100. qboolean m_serverInfoMessage = false;
  2101. double m_serverInfoMessageTime;
  2102. void M_Menu_GameOptions_f (void)
  2103. {
  2104. key_dest = key_menu;
  2105. m_state = m_gameoptions;
  2106. m_entersound = true;
  2107. if (maxplayers == 0)
  2108. maxplayers = svs.maxclients;
  2109. if (maxplayers < 2)
  2110. maxplayers = svs.maxclientslimit;
  2111. }
  2112. int gameoptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 112, 120};
  2113. #define NUM_GAMEOPTIONS 9
  2114. int gameoptions_cursor;
  2115. void M_GameOptions_Draw (void)
  2116. {
  2117. qpic_t *p;
  2118. int x;
  2119. M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
  2120. p = Draw_CachePic ("gfx/p_multi.lmp");
  2121. M_DrawPic ( (320-p->width)/2, 4, p);
  2122. M_DrawTextBox (152, 32, 10, 1);
  2123. M_Print (160, 40, "begin game");
  2124. M_Print (0, 56, " Max players");
  2125. M_Print (160, 56, va("%i", maxplayers) );
  2126. M_Print (0, 64, " Game Type");
  2127. if (coop.value)
  2128. M_Print (160, 64, "Cooperative");
  2129. else
  2130. M_Print (160, 64, "Deathmatch");
  2131. M_Print (0, 72, " Teamplay");
  2132. if (rogue)
  2133. {
  2134. char *msg;
  2135. switch((int)teamplay.value)
  2136. {
  2137. case 1: msg = "No Friendly Fire"; break;
  2138. case 2: msg = "Friendly Fire"; break;
  2139. case 3: msg = "Tag"; break;
  2140. case 4: msg = "Capture the Flag"; break;
  2141. case 5: msg = "One Flag CTF"; break;
  2142. case 6: msg = "Three Team CTF"; break;
  2143. default: msg = "Off"; break;
  2144. }
  2145. M_Print (160, 72, msg);
  2146. }
  2147. else
  2148. {
  2149. char *msg;
  2150. switch((int)teamplay.value)
  2151. {
  2152. case 1: msg = "No Friendly Fire"; break;
  2153. case 2: msg = "Friendly Fire"; break;
  2154. default: msg = "Off"; break;
  2155. }
  2156. M_Print (160, 72, msg);
  2157. }
  2158. M_Print (0, 80, " Skill");
  2159. if (skill.value == 0)
  2160. M_Print (160, 80, "Easy difficulty");
  2161. else if (skill.value == 1)
  2162. M_Print (160, 80, "Normal difficulty");
  2163. else if (skill.value == 2)
  2164. M_Print (160, 80, "Hard difficulty");
  2165. else
  2166. M_Print (160, 80, "Nightmare difficulty");
  2167. M_Print (0, 88, " Frag Limit");
  2168. if (fraglimit.value == 0)
  2169. M_Print (160, 88, "none");
  2170. else
  2171. M_Print (160, 88, va("%i frags", (int)fraglimit.value));
  2172. M_Print (0, 96, " Time Limit");
  2173. if (timelimit.value == 0)
  2174. M_Print (160, 96, "none");
  2175. else
  2176. M_Print (160, 96, va("%i minutes", (int)timelimit.value));
  2177. M_Print (0, 112, " Episode");
  2178. //MED 01/06/97 added hipnotic episodes
  2179. if (hipnotic)
  2180. M_Print (160, 112, hipnoticepisodes[startepisode].description);
  2181. //PGM 01/07/97 added rogue episodes
  2182. else if (rogue)
  2183. M_Print (160, 112, rogueepisodes[startepisode].description);
  2184. else
  2185. M_Print (160, 112, episodes[startepisode].description);
  2186. M_Print (0, 120, " Level");
  2187. //MED 01/06/97 added hipnotic episodes
  2188. if (hipnotic)
  2189. {
  2190. M_Print (160, 120, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].description);
  2191. M_Print (160, 128, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name);
  2192. }
  2193. //PGM 01/07/97 added rogue episodes
  2194. else if (rogue)
  2195. {
  2196. M_Print (160, 120, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].description);
  2197. M_Print (160, 128, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name);
  2198. }
  2199. else
  2200. {
  2201. M_Print (160, 120, levels[episodes[startepisode].firstLevel + startlevel].description);
  2202. M_Print (160, 128, levels[episodes[startepisode].firstLevel + startlevel].name);
  2203. }
  2204. // line cursor
  2205. M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
  2206. if (m_serverInfoMessage)
  2207. {
  2208. if ((realtime - m_serverInfoMessageTime) < 5.0)
  2209. {
  2210. x = (320-26*8)/2;
  2211. M_DrawTextBox (x, 138, 24, 4);
  2212. x += 8;
  2213. M_Print (x, 146, " More than 4 players ");
  2214. M_Print (x, 154, " requires using command ");
  2215. M_Print (x, 162, "line parameters; please ");
  2216. M_Print (x, 170, " see techinfo.txt. ");
  2217. }
  2218. else
  2219. {
  2220. m_serverInfoMessage = false;
  2221. }
  2222. }
  2223. }
  2224. void M_NetStart_Change (int dir)
  2225. {
  2226. int count;
  2227. switch (gameoptions_cursor)
  2228. {
  2229. case 1:
  2230. maxplayers += dir;
  2231. if (maxplayers > svs.maxclientslimit)
  2232. {
  2233. maxplayers = svs.maxclientslimit;
  2234. m_serverInfoMessage = true;
  2235. m_serverInfoMessageTime = realtime;
  2236. }
  2237. if (maxplayers < 2)
  2238. maxplayers = 2;
  2239. break;
  2240. case 2:
  2241. Cvar_SetValue ("coop", coop.value ? 0 : 1);
  2242. break;
  2243. case 3:
  2244. if (rogue)
  2245. count = 6;
  2246. else
  2247. count = 2;
  2248. Cvar_SetValue ("teamplay", teamplay.value + dir);
  2249. if (teamplay.value > count)
  2250. Cvar_SetValue ("teamplay", 0);
  2251. else if (teamplay.value < 0)
  2252. Cvar_SetValue ("teamplay", count);
  2253. break;
  2254. case 4:
  2255. Cvar_SetValue ("skill", skill.value + dir);
  2256. if (skill.value > 3)
  2257. Cvar_SetValue ("skill", 0);
  2258. if (skill.value < 0)
  2259. Cvar_SetValue ("skill", 3);
  2260. break;
  2261. case 5:
  2262. Cvar_SetValue ("fraglimit", fraglimit.value + dir*10);
  2263. if (fraglimit.value > 100)
  2264. Cvar_SetValue ("fraglimit", 0);
  2265. if (fraglimit.value < 0)
  2266. Cvar_SetValue ("fraglimit", 100);
  2267. break;
  2268. case 6:
  2269. Cvar_SetValue ("timelimit", timelimit.value + dir*5);
  2270. if (timelimit.value > 60)
  2271. Cvar_SetValue ("timelimit", 0);
  2272. if (timelimit.value < 0)
  2273. Cvar_SetValue ("timelimit", 60);
  2274. break;
  2275. case 7:
  2276. startepisode += dir;
  2277. //MED 01/06/97 added hipnotic count
  2278. if (hipnotic)
  2279. count = 6;
  2280. //PGM 01/07/97 added rogue count
  2281. //PGM 03/02/97 added 1 for dmatch episode
  2282. else if (rogue)
  2283. count = 4;
  2284. else if (registered.value)
  2285. count = 7;
  2286. else
  2287. count = 2;
  2288. if (startepisode < 0)
  2289. startepisode = count - 1;
  2290. if (startepisode >= count)
  2291. startepisode = 0;
  2292. startlevel = 0;
  2293. break;
  2294. case 8:
  2295. startlevel += dir;
  2296. //MED 01/06/97 added hipnotic episodes
  2297. if (hipnotic)
  2298. count = hipnoticepisodes[startepisode].levels;
  2299. //PGM 01/06/97 added hipnotic episodes
  2300. else if (rogue)
  2301. count = rogueepisodes[startepisode].levels;
  2302. else
  2303. count = episodes[startepisode].levels;
  2304. if (startlevel < 0)
  2305. startlevel = count - 1;
  2306. if (startlevel >= count)
  2307. startlevel = 0;
  2308. break;
  2309. }
  2310. }
  2311. void M_GameOptions_Key (int key)
  2312. {
  2313. switch (key)
  2314. {
  2315. case K_ESCAPE:
  2316. M_Menu_Net_f ();
  2317. break;
  2318. case K_UPARROW:
  2319. S_LocalSound ("misc/menu1.wav");
  2320. gameoptions_cursor--;
  2321. if (gameoptions_cursor < 0)
  2322. gameoptions_cursor = NUM_GAMEOPTIONS-1;
  2323. break;
  2324. case K_DOWNARROW:
  2325. S_LocalSound ("misc/menu1.wav");
  2326. gameoptions_cursor++;
  2327. if (gameoptions_cursor >= NUM_GAMEOPTIONS)
  2328. gameoptions_cursor = 0;
  2329. break;
  2330. case K_LEFTARROW:
  2331. if (gameoptions_cursor == 0)
  2332. break;
  2333. S_LocalSound ("misc/menu3.wav");
  2334. M_NetStart_Change (-1);
  2335. break;
  2336. case K_RIGHTARROW:
  2337. if (gameoptions_cursor == 0)
  2338. break;
  2339. S_LocalSound ("misc/menu3.wav");
  2340. M_NetStart_Change (1);
  2341. break;
  2342. case K_ENTER:
  2343. S_LocalSound ("misc/menu2.wav");
  2344. if (gameoptions_cursor == 0)
  2345. {
  2346. if (sv.active)
  2347. Cbuf_AddText ("disconnect\n");
  2348. Cbuf_AddText ("listen 0\n"); // so host_netport will be re-examined
  2349. Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) );
  2350. SCR_BeginLoadingPlaque ();
  2351. if (hipnotic)
  2352. Cbuf_AddText ( va ("map %s\n", hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name) );
  2353. else if (rogue)
  2354. Cbuf_AddText ( va ("map %s\n", roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name) );
  2355. else
  2356. Cbuf_AddText ( va ("map %s\n", levels[episodes[startepisode].firstLevel + startlevel].name) );
  2357. return;
  2358. }
  2359. M_NetStart_Change (1);
  2360. break;
  2361. }
  2362. }
  2363. //=============================================================================
  2364. /* SEARCH MENU */
  2365. qboolean searchComplete = false;
  2366. double searchCompleteTime;
  2367. void M_Menu_Search_f (void)
  2368. {
  2369. key_dest = key_menu;
  2370. m_state = m_search;
  2371. m_entersound = false;
  2372. slistSilent = true;
  2373. slistLocal = false;
  2374. searchComplete = false;
  2375. NET_Slist_f();
  2376. }
  2377. void M_Search_Draw (void)
  2378. {
  2379. qpic_t *p;
  2380. int x;
  2381. p = Draw_CachePic ("gfx/p_multi.lmp");
  2382. M_DrawPic ( (320-p->width)/2, 4, p);
  2383. x = (320/2) - ((12*8)/2) + 4;
  2384. M_DrawTextBox (x-8, 32, 12, 1);
  2385. M_Print (x, 40, "Searching...");
  2386. if(slistInProgress)
  2387. {
  2388. NET_Poll();
  2389. return;
  2390. }
  2391. if (! searchComplete)
  2392. {
  2393. searchComplete = true;
  2394. searchCompleteTime = realtime;
  2395. }
  2396. if (hostCacheCount)
  2397. {
  2398. M_Menu_ServerList_f ();
  2399. return;
  2400. }
  2401. M_PrintWhite ((320/2) - ((22*8)/2), 64, "No Quake servers found");
  2402. if ((realtime - searchCompleteTime) < 3.0)
  2403. return;
  2404. M_Menu_LanConfig_f ();
  2405. }
  2406. void M_Search_Key (int key)
  2407. {
  2408. }
  2409. //=============================================================================
  2410. /* SLIST MENU */
  2411. int slist_cursor;
  2412. qboolean slist_sorted;
  2413. void M_Menu_ServerList_f (void)
  2414. {
  2415. key_dest = key_menu;
  2416. m_state = m_slist;
  2417. m_entersound = true;
  2418. slist_cursor = 0;
  2419. m_return_onerror = false;
  2420. m_return_reason[0] = 0;
  2421. slist_sorted = false;
  2422. }
  2423. void M_ServerList_Draw (void)
  2424. {
  2425. int n;
  2426. char string [64];
  2427. qpic_t *p;
  2428. if (!slist_sorted)
  2429. {
  2430. if (hostCacheCount > 1)
  2431. {
  2432. int i,j;
  2433. hostcache_t temp;
  2434. for (i = 0; i < hostCacheCount; i++)
  2435. for (j = i+1; j < hostCacheCount; j++)
  2436. if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
  2437. {
  2438. Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
  2439. Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
  2440. Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
  2441. }
  2442. }
  2443. slist_sorted = true;
  2444. }
  2445. p = Draw_CachePic ("gfx/p_multi.lmp");
  2446. M_DrawPic ( (320-p->width)/2, 4, p);
  2447. for (n = 0; n < hostCacheCount; n++)
  2448. {
  2449. if (hostcache[n].maxusers)
  2450. sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
  2451. else
  2452. sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
  2453. M_Print (16, 32 + 8*n, string);
  2454. }
  2455. M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1));
  2456. if (*m_return_reason)
  2457. M_PrintWhite (16, 148, m_return_reason);
  2458. }
  2459. void M_ServerList_Key (int k)
  2460. {
  2461. switch (k)
  2462. {
  2463. case K_ESCAPE:
  2464. M_Menu_LanConfig_f ();
  2465. break;
  2466. case K_SPACE:
  2467. M_Menu_Search_f ();
  2468. break;
  2469. case K_UPARROW:
  2470. case K_LEFTARROW:
  2471. S_LocalSound ("misc/menu1.wav");
  2472. slist_cursor--;
  2473. if (slist_cursor < 0)
  2474. slist_cursor = hostCacheCount - 1;
  2475. break;
  2476. case K_DOWNARROW:
  2477. case K_RIGHTARROW:
  2478. S_LocalSound ("misc/menu1.wav");
  2479. slist_cursor++;
  2480. if (slist_cursor >= hostCacheCount)
  2481. slist_cursor = 0;
  2482. break;
  2483. case K_ENTER:
  2484. S_LocalSound ("misc/menu2.wav");
  2485. m_return_state = m_state;
  2486. m_return_onerror = true;
  2487. slist_sorted = false;
  2488. key_dest = key_game;
  2489. m_state = m_none;
  2490. Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
  2491. break;
  2492. default:
  2493. break;
  2494. }
  2495. }
  2496. //=============================================================================
  2497. /* Menu Subsystem */
  2498. void M_Init (void)
  2499. {
  2500. Cmd_AddCommand ("togglemenu", M_ToggleMenu_f);
  2501. Cmd_AddCommand ("menu_main", M_Menu_Main_f);
  2502. Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f);
  2503. Cmd_AddCommand ("menu_load", M_Menu_Load_f);
  2504. Cmd_AddCommand ("menu_save", M_Menu_Save_f);
  2505. Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
  2506. Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
  2507. Cmd_AddCommand ("menu_options", M_Menu_Options_f);
  2508. Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
  2509. Cmd_AddCommand ("menu_video", M_Menu_Video_f);
  2510. Cmd_AddCommand ("help", M_Menu_Help_f);
  2511. Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
  2512. }
  2513. void M_Draw (void)
  2514. {
  2515. if (m_state == m_none || key_dest != key_menu)
  2516. return;
  2517. if (!m_recursiveDraw)
  2518. {
  2519. scr_copyeverything = 1;
  2520. if (scr_con_current)
  2521. {
  2522. Draw_ConsoleBackground (vid.height);
  2523. VID_UnlockBuffer ();
  2524. S_ExtraUpdate ();
  2525. VID_LockBuffer ();
  2526. }
  2527. else
  2528. Draw_FadeScreen ();
  2529. scr_fullupdate = 0;
  2530. }
  2531. else
  2532. {
  2533. m_recursiveDraw = false;
  2534. }
  2535. switch (m_state)
  2536. {
  2537. case m_none:
  2538. break;
  2539. case m_main:
  2540. M_Main_Draw ();
  2541. break;
  2542. case m_singleplayer:
  2543. M_SinglePlayer_Draw ();
  2544. break;
  2545. case m_load:
  2546. M_Load_Draw ();
  2547. break;
  2548. case m_save:
  2549. M_Save_Draw ();
  2550. break;
  2551. case m_multiplayer:
  2552. M_MultiPlayer_Draw ();
  2553. break;
  2554. case m_setup:
  2555. M_Setup_Draw ();
  2556. break;
  2557. case m_net:
  2558. M_Net_Draw ();
  2559. break;
  2560. case m_options:
  2561. M_Options_Draw ();
  2562. break;
  2563. case m_keys:
  2564. M_Keys_Draw ();
  2565. break;
  2566. case m_video:
  2567. M_Video_Draw ();
  2568. break;
  2569. case m_help:
  2570. M_Help_Draw ();
  2571. break;
  2572. case m_quit:
  2573. M_Quit_Draw ();
  2574. break;
  2575. case m_serialconfig:
  2576. M_SerialConfig_Draw ();
  2577. break;
  2578. case m_modemconfig:
  2579. M_ModemConfig_Draw ();
  2580. break;
  2581. case m_lanconfig:
  2582. M_LanConfig_Draw ();
  2583. break;
  2584. case m_gameoptions:
  2585. M_GameOptions_Draw ();
  2586. break;
  2587. case m_search:
  2588. M_Search_Draw ();
  2589. break;
  2590. case m_slist:
  2591. M_ServerList_Draw ();
  2592. break;
  2593. }
  2594. if (m_entersound)
  2595. {
  2596. S_LocalSound ("misc/menu2.wav");
  2597. m_entersound = false;
  2598. }
  2599. VID_UnlockBuffer ();
  2600. S_ExtraUpdate ();
  2601. VID_LockBuffer ();
  2602. }
  2603. void M_Keydown (int key)
  2604. {
  2605. switch (m_state)
  2606. {
  2607. case m_none:
  2608. return;
  2609. case m_main:
  2610. M_Main_Key (key);
  2611. return;
  2612. case m_singleplayer:
  2613. M_SinglePlayer_Key (key);
  2614. return;
  2615. case m_load:
  2616. M_Load_Key (key);
  2617. return;
  2618. case m_save:
  2619. M_Save_Key (key);
  2620. return;
  2621. case m_multiplayer:
  2622. M_MultiPlayer_Key (key);
  2623. return;
  2624. case m_setup:
  2625. M_Setup_Key (key);
  2626. return;
  2627. case m_net:
  2628. M_Net_Key (key);
  2629. return;
  2630. case m_options:
  2631. M_Options_Key (key);
  2632. return;
  2633. case m_keys:
  2634. M_Keys_Key (key);
  2635. return;
  2636. case m_video:
  2637. M_Video_Key (key);
  2638. return;
  2639. case m_help:
  2640. M_Help_Key (key);
  2641. return;
  2642. case m_quit:
  2643. M_Quit_Key (key);
  2644. return;
  2645. case m_serialconfig:
  2646. M_SerialConfig_Key (key);
  2647. return;
  2648. case m_modemconfig:
  2649. M_ModemConfig_Key (key);
  2650. return;
  2651. case m_lanconfig:
  2652. M_LanConfig_Key (key);
  2653. return;
  2654. case m_gameoptions:
  2655. M_GameOptions_Key (key);
  2656. return;
  2657. case m_search:
  2658. M_Search_Key (key);
  2659. break;
  2660. case m_slist:
  2661. M_ServerList_Key (key);
  2662. return;
  2663. }
  2664. }
  2665. void M_ConfigureNetSubsystem(void)
  2666. {
  2667. // enable/disable net systems to match desired config
  2668. Cbuf_AddText ("stopdemo\n");
  2669. if (SerialConfig || DirectConfig)
  2670. {
  2671. Cbuf_AddText ("com1 enable\n");
  2672. }
  2673. if (IPXConfig || TCPIPConfig)
  2674. net_hostport = lanConfig_port;
  2675. }