menu.c 104 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017
  1. /*
  2. Copyright (C) 1997-2001 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 <ctype.h>
  16. #ifdef _WIN32
  17. #include <io.h>
  18. #endif
  19. #include "client.h"
  20. #include "../client/qmenu.h"
  21. static int m_main_cursor;
  22. #define NUM_CURSOR_FRAMES 15
  23. static char *menu_in_sound = "misc/menu1.wav";
  24. static char *menu_move_sound = "misc/menu2.wav";
  25. static char *menu_out_sound = "misc/menu3.wav";
  26. void M_Menu_Main_f (void);
  27. void M_Menu_Game_f (void);
  28. void M_Menu_LoadGame_f (void);
  29. void M_Menu_SaveGame_f (void);
  30. void M_Menu_PlayerConfig_f (void);
  31. void M_Menu_DownloadOptions_f (void);
  32. void M_Menu_Credits_f( void );
  33. void M_Menu_Multiplayer_f( void );
  34. void M_Menu_JoinServer_f (void);
  35. void M_Menu_AddressBook_f( void );
  36. void M_Menu_StartServer_f (void);
  37. void M_Menu_DMOptions_f (void);
  38. void M_Menu_Video_f (void);
  39. void M_Menu_Options_f (void);
  40. void M_Menu_Keys_f (void);
  41. void M_Menu_Quit_f (void);
  42. void M_Menu_Credits( void );
  43. qboolean m_entersound; // play after drawing a frame, so caching
  44. // won't disrupt the sound
  45. void (*m_drawfunc) (void);
  46. const char *(*m_keyfunc) (int key);
  47. //=============================================================================
  48. /* Support Routines */
  49. #define MAX_MENU_DEPTH 8
  50. typedef struct
  51. {
  52. void (*draw) (void);
  53. const char *(*key) (int k);
  54. } menulayer_t;
  55. menulayer_t m_layers[MAX_MENU_DEPTH];
  56. int m_menudepth;
  57. static void M_Banner( char *name )
  58. {
  59. int w, h;
  60. re.DrawGetPicSize (&w, &h, name );
  61. re.DrawPic( viddef.width / 2 - w / 2, viddef.height / 2 - 110, name );
  62. }
  63. void M_PushMenu ( void (*draw) (void), const char *(*key) (int k) )
  64. {
  65. int i;
  66. if (Cvar_VariableValue ("maxclients") == 1
  67. && Com_ServerState ())
  68. Cvar_Set ("paused", "1");
  69. // if this menu is already present, drop back to that level
  70. // to avoid stacking menus by hotkeys
  71. for (i=0 ; i<m_menudepth ; i++)
  72. if (m_layers[i].draw == draw &&
  73. m_layers[i].key == key)
  74. {
  75. m_menudepth = i;
  76. }
  77. if (i == m_menudepth)
  78. {
  79. if (m_menudepth >= MAX_MENU_DEPTH)
  80. Com_Error (ERR_FATAL, "M_PushMenu: MAX_MENU_DEPTH");
  81. m_layers[m_menudepth].draw = m_drawfunc;
  82. m_layers[m_menudepth].key = m_keyfunc;
  83. m_menudepth++;
  84. }
  85. m_drawfunc = draw;
  86. m_keyfunc = key;
  87. m_entersound = true;
  88. cls.key_dest = key_menu;
  89. }
  90. void M_ForceMenuOff (void)
  91. {
  92. m_drawfunc = 0;
  93. m_keyfunc = 0;
  94. cls.key_dest = key_game;
  95. m_menudepth = 0;
  96. Key_ClearStates ();
  97. Cvar_Set ("paused", "0");
  98. }
  99. void M_PopMenu (void)
  100. {
  101. S_StartLocalSound( menu_out_sound );
  102. if (m_menudepth < 1)
  103. Com_Error (ERR_FATAL, "M_PopMenu: depth < 1");
  104. m_menudepth--;
  105. m_drawfunc = m_layers[m_menudepth].draw;
  106. m_keyfunc = m_layers[m_menudepth].key;
  107. if (!m_menudepth)
  108. M_ForceMenuOff ();
  109. }
  110. const char *Default_MenuKey( menuframework_s *m, int key )
  111. {
  112. const char *sound = NULL;
  113. menucommon_s *item;
  114. if ( m )
  115. {
  116. if ( ( item = Menu_ItemAtCursor( m ) ) != 0 )
  117. {
  118. if ( item->type == MTYPE_FIELD )
  119. {
  120. if ( Field_Key( ( menufield_s * ) item, key ) )
  121. return NULL;
  122. }
  123. }
  124. }
  125. switch ( key )
  126. {
  127. case K_ESCAPE:
  128. M_PopMenu();
  129. return menu_out_sound;
  130. case K_KP_UPARROW:
  131. case K_UPARROW:
  132. if ( m )
  133. {
  134. m->cursor--;
  135. Menu_AdjustCursor( m, -1 );
  136. sound = menu_move_sound;
  137. }
  138. break;
  139. case K_TAB:
  140. if ( m )
  141. {
  142. m->cursor++;
  143. Menu_AdjustCursor( m, 1 );
  144. sound = menu_move_sound;
  145. }
  146. break;
  147. case K_KP_DOWNARROW:
  148. case K_DOWNARROW:
  149. if ( m )
  150. {
  151. m->cursor++;
  152. Menu_AdjustCursor( m, 1 );
  153. sound = menu_move_sound;
  154. }
  155. break;
  156. case K_KP_LEFTARROW:
  157. case K_LEFTARROW:
  158. if ( m )
  159. {
  160. Menu_SlideItem( m, -1 );
  161. sound = menu_move_sound;
  162. }
  163. break;
  164. case K_KP_RIGHTARROW:
  165. case K_RIGHTARROW:
  166. if ( m )
  167. {
  168. Menu_SlideItem( m, 1 );
  169. sound = menu_move_sound;
  170. }
  171. break;
  172. case K_MOUSE1:
  173. case K_MOUSE2:
  174. case K_MOUSE3:
  175. case K_JOY1:
  176. case K_JOY2:
  177. case K_JOY3:
  178. case K_JOY4:
  179. case K_AUX1:
  180. case K_AUX2:
  181. case K_AUX3:
  182. case K_AUX4:
  183. case K_AUX5:
  184. case K_AUX6:
  185. case K_AUX7:
  186. case K_AUX8:
  187. case K_AUX9:
  188. case K_AUX10:
  189. case K_AUX11:
  190. case K_AUX12:
  191. case K_AUX13:
  192. case K_AUX14:
  193. case K_AUX15:
  194. case K_AUX16:
  195. case K_AUX17:
  196. case K_AUX18:
  197. case K_AUX19:
  198. case K_AUX20:
  199. case K_AUX21:
  200. case K_AUX22:
  201. case K_AUX23:
  202. case K_AUX24:
  203. case K_AUX25:
  204. case K_AUX26:
  205. case K_AUX27:
  206. case K_AUX28:
  207. case K_AUX29:
  208. case K_AUX30:
  209. case K_AUX31:
  210. case K_AUX32:
  211. case K_KP_ENTER:
  212. case K_ENTER:
  213. if ( m )
  214. Menu_SelectItem( m );
  215. sound = menu_move_sound;
  216. break;
  217. }
  218. return sound;
  219. }
  220. //=============================================================================
  221. /*
  222. ================
  223. M_DrawCharacter
  224. Draws one solid graphics character
  225. cx and cy are in 320*240 coordinates, and will be centered on
  226. higher res screens.
  227. ================
  228. */
  229. void M_DrawCharacter (int cx, int cy, int num)
  230. {
  231. re.DrawChar ( cx + ((viddef.width - 320)>>1), cy + ((viddef.height - 240)>>1), num);
  232. }
  233. void M_Print (int cx, int cy, char *str)
  234. {
  235. while (*str)
  236. {
  237. M_DrawCharacter (cx, cy, (*str)+128);
  238. str++;
  239. cx += 8;
  240. }
  241. }
  242. void M_PrintWhite (int cx, int cy, char *str)
  243. {
  244. while (*str)
  245. {
  246. M_DrawCharacter (cx, cy, *str);
  247. str++;
  248. cx += 8;
  249. }
  250. }
  251. void M_DrawPic (int x, int y, char *pic)
  252. {
  253. re.DrawPic (x + ((viddef.width - 320)>>1), y + ((viddef.height - 240)>>1), pic);
  254. }
  255. /*
  256. =============
  257. M_DrawCursor
  258. Draws an animating cursor with the point at
  259. x,y. The pic will extend to the left of x,
  260. and both above and below y.
  261. =============
  262. */
  263. void M_DrawCursor( int x, int y, int f )
  264. {
  265. char cursorname[80];
  266. static qboolean cached;
  267. if ( !cached )
  268. {
  269. int i;
  270. for ( i = 0; i < NUM_CURSOR_FRAMES; i++ )
  271. {
  272. Com_sprintf( cursorname, sizeof( cursorname ), "m_cursor%d", i );
  273. re.RegisterPic( cursorname );
  274. }
  275. cached = true;
  276. }
  277. Com_sprintf( cursorname, sizeof(cursorname), "m_cursor%d", f );
  278. re.DrawPic( x, y, cursorname );
  279. }
  280. void M_DrawTextBox (int x, int y, int width, int lines)
  281. {
  282. int cx, cy;
  283. int n;
  284. // draw left side
  285. cx = x;
  286. cy = y;
  287. M_DrawCharacter (cx, cy, 1);
  288. for (n = 0; n < lines; n++)
  289. {
  290. cy += 8;
  291. M_DrawCharacter (cx, cy, 4);
  292. }
  293. M_DrawCharacter (cx, cy+8, 7);
  294. // draw middle
  295. cx += 8;
  296. while (width > 0)
  297. {
  298. cy = y;
  299. M_DrawCharacter (cx, cy, 2);
  300. for (n = 0; n < lines; n++)
  301. {
  302. cy += 8;
  303. M_DrawCharacter (cx, cy, 5);
  304. }
  305. M_DrawCharacter (cx, cy+8, 8);
  306. width -= 1;
  307. cx += 8;
  308. }
  309. // draw right side
  310. cy = y;
  311. M_DrawCharacter (cx, cy, 3);
  312. for (n = 0; n < lines; n++)
  313. {
  314. cy += 8;
  315. M_DrawCharacter (cx, cy, 6);
  316. }
  317. M_DrawCharacter (cx, cy+8, 9);
  318. }
  319. /*
  320. =======================================================================
  321. MAIN MENU
  322. =======================================================================
  323. */
  324. #define MAIN_ITEMS 5
  325. void M_Main_Draw (void)
  326. {
  327. int i;
  328. int w, h;
  329. int ystart;
  330. int xoffset;
  331. int widest = -1;
  332. int totalheight = 0;
  333. char litname[80];
  334. char *names[] =
  335. {
  336. "m_main_game",
  337. "m_main_multiplayer",
  338. "m_main_options",
  339. "m_main_video",
  340. "m_main_quit",
  341. 0
  342. };
  343. for ( i = 0; names[i] != 0; i++ )
  344. {
  345. re.DrawGetPicSize( &w, &h, names[i] );
  346. if ( w > widest )
  347. widest = w;
  348. totalheight += ( h + 12 );
  349. }
  350. ystart = ( viddef.height / 2 - 110 );
  351. xoffset = ( viddef.width - widest + 70 ) / 2;
  352. for ( i = 0; names[i] != 0; i++ )
  353. {
  354. if ( i != m_main_cursor )
  355. re.DrawPic( xoffset, ystart + i * 40 + 13, names[i] );
  356. }
  357. strcpy( litname, names[m_main_cursor] );
  358. strcat( litname, "_sel" );
  359. re.DrawPic( xoffset, ystart + m_main_cursor * 40 + 13, litname );
  360. M_DrawCursor( xoffset - 25, ystart + m_main_cursor * 40 + 11, (int)(cls.realtime / 100)%NUM_CURSOR_FRAMES );
  361. re.DrawGetPicSize( &w, &h, "m_main_plaque" );
  362. re.DrawPic( xoffset - 30 - w, ystart, "m_main_plaque" );
  363. re.DrawPic( xoffset - 30 - w, ystart + h + 5, "m_main_logo" );
  364. }
  365. const char *M_Main_Key (int key)
  366. {
  367. const char *sound = menu_move_sound;
  368. switch (key)
  369. {
  370. case K_ESCAPE:
  371. M_PopMenu ();
  372. break;
  373. case K_KP_DOWNARROW:
  374. case K_DOWNARROW:
  375. if (++m_main_cursor >= MAIN_ITEMS)
  376. m_main_cursor = 0;
  377. return sound;
  378. case K_KP_UPARROW:
  379. case K_UPARROW:
  380. if (--m_main_cursor < 0)
  381. m_main_cursor = MAIN_ITEMS - 1;
  382. return sound;
  383. case K_KP_ENTER:
  384. case K_ENTER:
  385. m_entersound = true;
  386. switch (m_main_cursor)
  387. {
  388. case 0:
  389. M_Menu_Game_f ();
  390. break;
  391. case 1:
  392. M_Menu_Multiplayer_f();
  393. break;
  394. case 2:
  395. M_Menu_Options_f ();
  396. break;
  397. case 3:
  398. M_Menu_Video_f ();
  399. break;
  400. case 4:
  401. M_Menu_Quit_f ();
  402. break;
  403. }
  404. }
  405. return NULL;
  406. }
  407. void M_Menu_Main_f (void)
  408. {
  409. M_PushMenu (M_Main_Draw, M_Main_Key);
  410. }
  411. /*
  412. =======================================================================
  413. MULTIPLAYER MENU
  414. =======================================================================
  415. */
  416. static menuframework_s s_multiplayer_menu;
  417. static menuaction_s s_join_network_server_action;
  418. static menuaction_s s_start_network_server_action;
  419. static menuaction_s s_player_setup_action;
  420. static void Multiplayer_MenuDraw (void)
  421. {
  422. M_Banner( "m_banner_multiplayer" );
  423. Menu_AdjustCursor( &s_multiplayer_menu, 1 );
  424. Menu_Draw( &s_multiplayer_menu );
  425. }
  426. static void PlayerSetupFunc( void *unused )
  427. {
  428. M_Menu_PlayerConfig_f();
  429. }
  430. static void JoinNetworkServerFunc( void *unused )
  431. {
  432. M_Menu_JoinServer_f();
  433. }
  434. static void StartNetworkServerFunc( void *unused )
  435. {
  436. M_Menu_StartServer_f ();
  437. }
  438. void Multiplayer_MenuInit( void )
  439. {
  440. s_multiplayer_menu.x = viddef.width * 0.50 - 64;
  441. s_multiplayer_menu.nitems = 0;
  442. s_join_network_server_action.generic.type = MTYPE_ACTION;
  443. s_join_network_server_action.generic.flags = QMF_LEFT_JUSTIFY;
  444. s_join_network_server_action.generic.x = 0;
  445. s_join_network_server_action.generic.y = 0;
  446. s_join_network_server_action.generic.name = " join network server";
  447. s_join_network_server_action.generic.callback = JoinNetworkServerFunc;
  448. s_start_network_server_action.generic.type = MTYPE_ACTION;
  449. s_start_network_server_action.generic.flags = QMF_LEFT_JUSTIFY;
  450. s_start_network_server_action.generic.x = 0;
  451. s_start_network_server_action.generic.y = 10;
  452. s_start_network_server_action.generic.name = " start network server";
  453. s_start_network_server_action.generic.callback = StartNetworkServerFunc;
  454. s_player_setup_action.generic.type = MTYPE_ACTION;
  455. s_player_setup_action.generic.flags = QMF_LEFT_JUSTIFY;
  456. s_player_setup_action.generic.x = 0;
  457. s_player_setup_action.generic.y = 20;
  458. s_player_setup_action.generic.name = " player setup";
  459. s_player_setup_action.generic.callback = PlayerSetupFunc;
  460. Menu_AddItem( &s_multiplayer_menu, ( void * ) &s_join_network_server_action );
  461. Menu_AddItem( &s_multiplayer_menu, ( void * ) &s_start_network_server_action );
  462. Menu_AddItem( &s_multiplayer_menu, ( void * ) &s_player_setup_action );
  463. Menu_SetStatusBar( &s_multiplayer_menu, NULL );
  464. Menu_Center( &s_multiplayer_menu );
  465. }
  466. const char *Multiplayer_MenuKey( int key )
  467. {
  468. return Default_MenuKey( &s_multiplayer_menu, key );
  469. }
  470. void M_Menu_Multiplayer_f( void )
  471. {
  472. Multiplayer_MenuInit();
  473. M_PushMenu( Multiplayer_MenuDraw, Multiplayer_MenuKey );
  474. }
  475. /*
  476. =======================================================================
  477. KEYS MENU
  478. =======================================================================
  479. */
  480. char *bindnames[][2] =
  481. {
  482. {"+attack", "attack"},
  483. {"weapnext", "next weapon"},
  484. {"+forward", "walk forward"},
  485. {"+back", "backpedal"},
  486. {"+left", "turn left"},
  487. {"+right", "turn right"},
  488. {"+speed", "run"},
  489. {"+moveleft", "step left"},
  490. {"+moveright", "step right"},
  491. {"+strafe", "sidestep"},
  492. {"+lookup", "look up"},
  493. {"+lookdown", "look down"},
  494. {"centerview", "center view"},
  495. {"+mlook", "mouse look"},
  496. {"+klook", "keyboard look"},
  497. {"+moveup", "up / jump"},
  498. {"+movedown", "down / crouch"},
  499. {"inven", "inventory"},
  500. {"invuse", "use item"},
  501. {"invdrop", "drop item"},
  502. {"invprev", "prev item"},
  503. {"invnext", "next item"},
  504. {"cmd help", "help computer" },
  505. { 0, 0 }
  506. };
  507. int keys_cursor;
  508. static int bind_grab;
  509. static menuframework_s s_keys_menu;
  510. static menuaction_s s_keys_attack_action;
  511. static menuaction_s s_keys_change_weapon_action;
  512. static menuaction_s s_keys_walk_forward_action;
  513. static menuaction_s s_keys_backpedal_action;
  514. static menuaction_s s_keys_turn_left_action;
  515. static menuaction_s s_keys_turn_right_action;
  516. static menuaction_s s_keys_run_action;
  517. static menuaction_s s_keys_step_left_action;
  518. static menuaction_s s_keys_step_right_action;
  519. static menuaction_s s_keys_sidestep_action;
  520. static menuaction_s s_keys_look_up_action;
  521. static menuaction_s s_keys_look_down_action;
  522. static menuaction_s s_keys_center_view_action;
  523. static menuaction_s s_keys_mouse_look_action;
  524. static menuaction_s s_keys_keyboard_look_action;
  525. static menuaction_s s_keys_move_up_action;
  526. static menuaction_s s_keys_move_down_action;
  527. static menuaction_s s_keys_inventory_action;
  528. static menuaction_s s_keys_inv_use_action;
  529. static menuaction_s s_keys_inv_drop_action;
  530. static menuaction_s s_keys_inv_prev_action;
  531. static menuaction_s s_keys_inv_next_action;
  532. static menuaction_s s_keys_help_computer_action;
  533. static void M_UnbindCommand (char *command)
  534. {
  535. int j;
  536. int l;
  537. char *b;
  538. l = strlen(command);
  539. for (j=0 ; j<256 ; j++)
  540. {
  541. b = keybindings[j];
  542. if (!b)
  543. continue;
  544. if (!strncmp (b, command, l) )
  545. Key_SetBinding (j, "");
  546. }
  547. }
  548. static void M_FindKeysForCommand (char *command, int *twokeys)
  549. {
  550. int count;
  551. int j;
  552. int l;
  553. char *b;
  554. twokeys[0] = twokeys[1] = -1;
  555. l = strlen(command);
  556. count = 0;
  557. for (j=0 ; j<256 ; j++)
  558. {
  559. b = keybindings[j];
  560. if (!b)
  561. continue;
  562. if (!strncmp (b, command, l) )
  563. {
  564. twokeys[count] = j;
  565. count++;
  566. if (count == 2)
  567. break;
  568. }
  569. }
  570. }
  571. static void KeyCursorDrawFunc( menuframework_s *menu )
  572. {
  573. if ( bind_grab )
  574. re.DrawChar( menu->x, menu->y + menu->cursor * 9, '=' );
  575. else
  576. re.DrawChar( menu->x, menu->y + menu->cursor * 9, 12 + ( ( int ) ( Sys_Milliseconds() / 250 ) & 1 ) );
  577. }
  578. static void DrawKeyBindingFunc( void *self )
  579. {
  580. int keys[2];
  581. menuaction_s *a = ( menuaction_s * ) self;
  582. M_FindKeysForCommand( bindnames[a->generic.localdata[0]][0], keys);
  583. if (keys[0] == -1)
  584. {
  585. Menu_DrawString( a->generic.x + a->generic.parent->x + 16, a->generic.y + a->generic.parent->y, "???" );
  586. }
  587. else
  588. {
  589. int x;
  590. const char *name;
  591. name = Key_KeynumToString (keys[0]);
  592. Menu_DrawString( a->generic.x + a->generic.parent->x + 16, a->generic.y + a->generic.parent->y, name );
  593. x = strlen(name) * 8;
  594. if (keys[1] != -1)
  595. {
  596. Menu_DrawString( a->generic.x + a->generic.parent->x + 24 + x, a->generic.y + a->generic.parent->y, "or" );
  597. Menu_DrawString( a->generic.x + a->generic.parent->x + 48 + x, a->generic.y + a->generic.parent->y, Key_KeynumToString (keys[1]) );
  598. }
  599. }
  600. }
  601. static void KeyBindingFunc( void *self )
  602. {
  603. menuaction_s *a = ( menuaction_s * ) self;
  604. int keys[2];
  605. M_FindKeysForCommand( bindnames[a->generic.localdata[0]][0], keys );
  606. if (keys[1] != -1)
  607. M_UnbindCommand( bindnames[a->generic.localdata[0]][0]);
  608. bind_grab = true;
  609. Menu_SetStatusBar( &s_keys_menu, "press a key or button for this action" );
  610. }
  611. static void Keys_MenuInit( void )
  612. {
  613. int y = 0;
  614. int i = 0;
  615. s_keys_menu.x = viddef.width * 0.50;
  616. s_keys_menu.nitems = 0;
  617. s_keys_menu.cursordraw = KeyCursorDrawFunc;
  618. s_keys_attack_action.generic.type = MTYPE_ACTION;
  619. s_keys_attack_action.generic.flags = QMF_GRAYED;
  620. s_keys_attack_action.generic.x = 0;
  621. s_keys_attack_action.generic.y = y;
  622. s_keys_attack_action.generic.ownerdraw = DrawKeyBindingFunc;
  623. s_keys_attack_action.generic.localdata[0] = i;
  624. s_keys_attack_action.generic.name = bindnames[s_keys_attack_action.generic.localdata[0]][1];
  625. s_keys_change_weapon_action.generic.type = MTYPE_ACTION;
  626. s_keys_change_weapon_action.generic.flags = QMF_GRAYED;
  627. s_keys_change_weapon_action.generic.x = 0;
  628. s_keys_change_weapon_action.generic.y = y += 9;
  629. s_keys_change_weapon_action.generic.ownerdraw = DrawKeyBindingFunc;
  630. s_keys_change_weapon_action.generic.localdata[0] = ++i;
  631. s_keys_change_weapon_action.generic.name = bindnames[s_keys_change_weapon_action.generic.localdata[0]][1];
  632. s_keys_walk_forward_action.generic.type = MTYPE_ACTION;
  633. s_keys_walk_forward_action.generic.flags = QMF_GRAYED;
  634. s_keys_walk_forward_action.generic.x = 0;
  635. s_keys_walk_forward_action.generic.y = y += 9;
  636. s_keys_walk_forward_action.generic.ownerdraw = DrawKeyBindingFunc;
  637. s_keys_walk_forward_action.generic.localdata[0] = ++i;
  638. s_keys_walk_forward_action.generic.name = bindnames[s_keys_walk_forward_action.generic.localdata[0]][1];
  639. s_keys_backpedal_action.generic.type = MTYPE_ACTION;
  640. s_keys_backpedal_action.generic.flags = QMF_GRAYED;
  641. s_keys_backpedal_action.generic.x = 0;
  642. s_keys_backpedal_action.generic.y = y += 9;
  643. s_keys_backpedal_action.generic.ownerdraw = DrawKeyBindingFunc;
  644. s_keys_backpedal_action.generic.localdata[0] = ++i;
  645. s_keys_backpedal_action.generic.name = bindnames[s_keys_backpedal_action.generic.localdata[0]][1];
  646. s_keys_turn_left_action.generic.type = MTYPE_ACTION;
  647. s_keys_turn_left_action.generic.flags = QMF_GRAYED;
  648. s_keys_turn_left_action.generic.x = 0;
  649. s_keys_turn_left_action.generic.y = y += 9;
  650. s_keys_turn_left_action.generic.ownerdraw = DrawKeyBindingFunc;
  651. s_keys_turn_left_action.generic.localdata[0] = ++i;
  652. s_keys_turn_left_action.generic.name = bindnames[s_keys_turn_left_action.generic.localdata[0]][1];
  653. s_keys_turn_right_action.generic.type = MTYPE_ACTION;
  654. s_keys_turn_right_action.generic.flags = QMF_GRAYED;
  655. s_keys_turn_right_action.generic.x = 0;
  656. s_keys_turn_right_action.generic.y = y += 9;
  657. s_keys_turn_right_action.generic.ownerdraw = DrawKeyBindingFunc;
  658. s_keys_turn_right_action.generic.localdata[0] = ++i;
  659. s_keys_turn_right_action.generic.name = bindnames[s_keys_turn_right_action.generic.localdata[0]][1];
  660. s_keys_run_action.generic.type = MTYPE_ACTION;
  661. s_keys_run_action.generic.flags = QMF_GRAYED;
  662. s_keys_run_action.generic.x = 0;
  663. s_keys_run_action.generic.y = y += 9;
  664. s_keys_run_action.generic.ownerdraw = DrawKeyBindingFunc;
  665. s_keys_run_action.generic.localdata[0] = ++i;
  666. s_keys_run_action.generic.name = bindnames[s_keys_run_action.generic.localdata[0]][1];
  667. s_keys_step_left_action.generic.type = MTYPE_ACTION;
  668. s_keys_step_left_action.generic.flags = QMF_GRAYED;
  669. s_keys_step_left_action.generic.x = 0;
  670. s_keys_step_left_action.generic.y = y += 9;
  671. s_keys_step_left_action.generic.ownerdraw = DrawKeyBindingFunc;
  672. s_keys_step_left_action.generic.localdata[0] = ++i;
  673. s_keys_step_left_action.generic.name = bindnames[s_keys_step_left_action.generic.localdata[0]][1];
  674. s_keys_step_right_action.generic.type = MTYPE_ACTION;
  675. s_keys_step_right_action.generic.flags = QMF_GRAYED;
  676. s_keys_step_right_action.generic.x = 0;
  677. s_keys_step_right_action.generic.y = y += 9;
  678. s_keys_step_right_action.generic.ownerdraw = DrawKeyBindingFunc;
  679. s_keys_step_right_action.generic.localdata[0] = ++i;
  680. s_keys_step_right_action.generic.name = bindnames[s_keys_step_right_action.generic.localdata[0]][1];
  681. s_keys_sidestep_action.generic.type = MTYPE_ACTION;
  682. s_keys_sidestep_action.generic.flags = QMF_GRAYED;
  683. s_keys_sidestep_action.generic.x = 0;
  684. s_keys_sidestep_action.generic.y = y += 9;
  685. s_keys_sidestep_action.generic.ownerdraw = DrawKeyBindingFunc;
  686. s_keys_sidestep_action.generic.localdata[0] = ++i;
  687. s_keys_sidestep_action.generic.name = bindnames[s_keys_sidestep_action.generic.localdata[0]][1];
  688. s_keys_look_up_action.generic.type = MTYPE_ACTION;
  689. s_keys_look_up_action.generic.flags = QMF_GRAYED;
  690. s_keys_look_up_action.generic.x = 0;
  691. s_keys_look_up_action.generic.y = y += 9;
  692. s_keys_look_up_action.generic.ownerdraw = DrawKeyBindingFunc;
  693. s_keys_look_up_action.generic.localdata[0] = ++i;
  694. s_keys_look_up_action.generic.name = bindnames[s_keys_look_up_action.generic.localdata[0]][1];
  695. s_keys_look_down_action.generic.type = MTYPE_ACTION;
  696. s_keys_look_down_action.generic.flags = QMF_GRAYED;
  697. s_keys_look_down_action.generic.x = 0;
  698. s_keys_look_down_action.generic.y = y += 9;
  699. s_keys_look_down_action.generic.ownerdraw = DrawKeyBindingFunc;
  700. s_keys_look_down_action.generic.localdata[0] = ++i;
  701. s_keys_look_down_action.generic.name = bindnames[s_keys_look_down_action.generic.localdata[0]][1];
  702. s_keys_center_view_action.generic.type = MTYPE_ACTION;
  703. s_keys_center_view_action.generic.flags = QMF_GRAYED;
  704. s_keys_center_view_action.generic.x = 0;
  705. s_keys_center_view_action.generic.y = y += 9;
  706. s_keys_center_view_action.generic.ownerdraw = DrawKeyBindingFunc;
  707. s_keys_center_view_action.generic.localdata[0] = ++i;
  708. s_keys_center_view_action.generic.name = bindnames[s_keys_center_view_action.generic.localdata[0]][1];
  709. s_keys_mouse_look_action.generic.type = MTYPE_ACTION;
  710. s_keys_mouse_look_action.generic.flags = QMF_GRAYED;
  711. s_keys_mouse_look_action.generic.x = 0;
  712. s_keys_mouse_look_action.generic.y = y += 9;
  713. s_keys_mouse_look_action.generic.ownerdraw = DrawKeyBindingFunc;
  714. s_keys_mouse_look_action.generic.localdata[0] = ++i;
  715. s_keys_mouse_look_action.generic.name = bindnames[s_keys_mouse_look_action.generic.localdata[0]][1];
  716. s_keys_keyboard_look_action.generic.type = MTYPE_ACTION;
  717. s_keys_keyboard_look_action.generic.flags = QMF_GRAYED;
  718. s_keys_keyboard_look_action.generic.x = 0;
  719. s_keys_keyboard_look_action.generic.y = y += 9;
  720. s_keys_keyboard_look_action.generic.ownerdraw = DrawKeyBindingFunc;
  721. s_keys_keyboard_look_action.generic.localdata[0] = ++i;
  722. s_keys_keyboard_look_action.generic.name = bindnames[s_keys_keyboard_look_action.generic.localdata[0]][1];
  723. s_keys_move_up_action.generic.type = MTYPE_ACTION;
  724. s_keys_move_up_action.generic.flags = QMF_GRAYED;
  725. s_keys_move_up_action.generic.x = 0;
  726. s_keys_move_up_action.generic.y = y += 9;
  727. s_keys_move_up_action.generic.ownerdraw = DrawKeyBindingFunc;
  728. s_keys_move_up_action.generic.localdata[0] = ++i;
  729. s_keys_move_up_action.generic.name = bindnames[s_keys_move_up_action.generic.localdata[0]][1];
  730. s_keys_move_down_action.generic.type = MTYPE_ACTION;
  731. s_keys_move_down_action.generic.flags = QMF_GRAYED;
  732. s_keys_move_down_action.generic.x = 0;
  733. s_keys_move_down_action.generic.y = y += 9;
  734. s_keys_move_down_action.generic.ownerdraw = DrawKeyBindingFunc;
  735. s_keys_move_down_action.generic.localdata[0] = ++i;
  736. s_keys_move_down_action.generic.name = bindnames[s_keys_move_down_action.generic.localdata[0]][1];
  737. s_keys_inventory_action.generic.type = MTYPE_ACTION;
  738. s_keys_inventory_action.generic.flags = QMF_GRAYED;
  739. s_keys_inventory_action.generic.x = 0;
  740. s_keys_inventory_action.generic.y = y += 9;
  741. s_keys_inventory_action.generic.ownerdraw = DrawKeyBindingFunc;
  742. s_keys_inventory_action.generic.localdata[0] = ++i;
  743. s_keys_inventory_action.generic.name = bindnames[s_keys_inventory_action.generic.localdata[0]][1];
  744. s_keys_inv_use_action.generic.type = MTYPE_ACTION;
  745. s_keys_inv_use_action.generic.flags = QMF_GRAYED;
  746. s_keys_inv_use_action.generic.x = 0;
  747. s_keys_inv_use_action.generic.y = y += 9;
  748. s_keys_inv_use_action.generic.ownerdraw = DrawKeyBindingFunc;
  749. s_keys_inv_use_action.generic.localdata[0] = ++i;
  750. s_keys_inv_use_action.generic.name = bindnames[s_keys_inv_use_action.generic.localdata[0]][1];
  751. s_keys_inv_drop_action.generic.type = MTYPE_ACTION;
  752. s_keys_inv_drop_action.generic.flags = QMF_GRAYED;
  753. s_keys_inv_drop_action.generic.x = 0;
  754. s_keys_inv_drop_action.generic.y = y += 9;
  755. s_keys_inv_drop_action.generic.ownerdraw = DrawKeyBindingFunc;
  756. s_keys_inv_drop_action.generic.localdata[0] = ++i;
  757. s_keys_inv_drop_action.generic.name = bindnames[s_keys_inv_drop_action.generic.localdata[0]][1];
  758. s_keys_inv_prev_action.generic.type = MTYPE_ACTION;
  759. s_keys_inv_prev_action.generic.flags = QMF_GRAYED;
  760. s_keys_inv_prev_action.generic.x = 0;
  761. s_keys_inv_prev_action.generic.y = y += 9;
  762. s_keys_inv_prev_action.generic.ownerdraw = DrawKeyBindingFunc;
  763. s_keys_inv_prev_action.generic.localdata[0] = ++i;
  764. s_keys_inv_prev_action.generic.name = bindnames[s_keys_inv_prev_action.generic.localdata[0]][1];
  765. s_keys_inv_next_action.generic.type = MTYPE_ACTION;
  766. s_keys_inv_next_action.generic.flags = QMF_GRAYED;
  767. s_keys_inv_next_action.generic.x = 0;
  768. s_keys_inv_next_action.generic.y = y += 9;
  769. s_keys_inv_next_action.generic.ownerdraw = DrawKeyBindingFunc;
  770. s_keys_inv_next_action.generic.localdata[0] = ++i;
  771. s_keys_inv_next_action.generic.name = bindnames[s_keys_inv_next_action.generic.localdata[0]][1];
  772. s_keys_help_computer_action.generic.type = MTYPE_ACTION;
  773. s_keys_help_computer_action.generic.flags = QMF_GRAYED;
  774. s_keys_help_computer_action.generic.x = 0;
  775. s_keys_help_computer_action.generic.y = y += 9;
  776. s_keys_help_computer_action.generic.ownerdraw = DrawKeyBindingFunc;
  777. s_keys_help_computer_action.generic.localdata[0] = ++i;
  778. s_keys_help_computer_action.generic.name = bindnames[s_keys_help_computer_action.generic.localdata[0]][1];
  779. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_attack_action );
  780. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_change_weapon_action );
  781. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_walk_forward_action );
  782. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_backpedal_action );
  783. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_turn_left_action );
  784. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_turn_right_action );
  785. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_run_action );
  786. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_step_left_action );
  787. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_step_right_action );
  788. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_sidestep_action );
  789. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_look_up_action );
  790. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_look_down_action );
  791. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_center_view_action );
  792. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_mouse_look_action );
  793. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_keyboard_look_action );
  794. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_move_up_action );
  795. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_move_down_action );
  796. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_inventory_action );
  797. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_inv_use_action );
  798. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_inv_drop_action );
  799. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_inv_prev_action );
  800. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_inv_next_action );
  801. Menu_AddItem( &s_keys_menu, ( void * ) &s_keys_help_computer_action );
  802. Menu_SetStatusBar( &s_keys_menu, "enter to change, backspace to clear" );
  803. Menu_Center( &s_keys_menu );
  804. }
  805. static void Keys_MenuDraw (void)
  806. {
  807. Menu_AdjustCursor( &s_keys_menu, 1 );
  808. Menu_Draw( &s_keys_menu );
  809. }
  810. static const char *Keys_MenuKey( int key )
  811. {
  812. menuaction_s *item = ( menuaction_s * ) Menu_ItemAtCursor( &s_keys_menu );
  813. if ( bind_grab )
  814. {
  815. if ( key != K_ESCAPE && key != '`' )
  816. {
  817. char cmd[1024];
  818. Com_sprintf (cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString(key), bindnames[item->generic.localdata[0]][0]);
  819. Cbuf_InsertText (cmd);
  820. }
  821. Menu_SetStatusBar( &s_keys_menu, "enter to change, backspace to clear" );
  822. bind_grab = false;
  823. return menu_out_sound;
  824. }
  825. switch ( key )
  826. {
  827. case K_KP_ENTER:
  828. case K_ENTER:
  829. KeyBindingFunc( item );
  830. return menu_in_sound;
  831. case K_BACKSPACE: // delete bindings
  832. case K_DEL: // delete bindings
  833. case K_KP_DEL:
  834. M_UnbindCommand( bindnames[item->generic.localdata[0]][0] );
  835. return menu_out_sound;
  836. default:
  837. return Default_MenuKey( &s_keys_menu, key );
  838. }
  839. }
  840. void M_Menu_Keys_f (void)
  841. {
  842. Keys_MenuInit();
  843. M_PushMenu( Keys_MenuDraw, Keys_MenuKey );
  844. }
  845. /*
  846. =======================================================================
  847. CONTROLS MENU
  848. =======================================================================
  849. */
  850. static cvar_t *win_noalttab;
  851. extern cvar_t *in_joystick;
  852. static menuframework_s s_options_menu;
  853. static menuaction_s s_options_defaults_action;
  854. static menuaction_s s_options_customize_options_action;
  855. static menuslider_s s_options_sensitivity_slider;
  856. static menulist_s s_options_freelook_box;
  857. static menulist_s s_options_noalttab_box;
  858. static menulist_s s_options_alwaysrun_box;
  859. static menulist_s s_options_invertmouse_box;
  860. static menulist_s s_options_lookspring_box;
  861. static menulist_s s_options_lookstrafe_box;
  862. static menulist_s s_options_crosshair_box;
  863. static menuslider_s s_options_sfxvolume_slider;
  864. static menulist_s s_options_joystick_box;
  865. static menulist_s s_options_cdvolume_box;
  866. static menulist_s s_options_quality_list;
  867. static menulist_s s_options_compatibility_list;
  868. static menulist_s s_options_console_action;
  869. static void CrosshairFunc( void *unused )
  870. {
  871. Cvar_SetValue( "crosshair", s_options_crosshair_box.curvalue );
  872. }
  873. static void JoystickFunc( void *unused )
  874. {
  875. Cvar_SetValue( "in_joystick", s_options_joystick_box.curvalue );
  876. }
  877. static void CustomizeControlsFunc( void *unused )
  878. {
  879. M_Menu_Keys_f();
  880. }
  881. static void AlwaysRunFunc( void *unused )
  882. {
  883. Cvar_SetValue( "cl_run", s_options_alwaysrun_box.curvalue );
  884. }
  885. static void FreeLookFunc( void *unused )
  886. {
  887. Cvar_SetValue( "freelook", s_options_freelook_box.curvalue );
  888. }
  889. static void MouseSpeedFunc( void *unused )
  890. {
  891. Cvar_SetValue( "sensitivity", s_options_sensitivity_slider.curvalue / 2.0F );
  892. }
  893. static void NoAltTabFunc( void *unused )
  894. {
  895. Cvar_SetValue( "win_noalttab", s_options_noalttab_box.curvalue );
  896. }
  897. static float ClampCvar( float min, float max, float value )
  898. {
  899. if ( value < min ) return min;
  900. if ( value > max ) return max;
  901. return value;
  902. }
  903. static void ControlsSetMenuItemValues( void )
  904. {
  905. s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10;
  906. s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd");
  907. s_options_quality_list.curvalue = !Cvar_VariableValue( "s_loadas8bit" );
  908. s_options_sensitivity_slider.curvalue = ( sensitivity->value ) * 2;
  909. Cvar_SetValue( "cl_run", ClampCvar( 0, 1, cl_run->value ) );
  910. s_options_alwaysrun_box.curvalue = cl_run->value;
  911. s_options_invertmouse_box.curvalue = m_pitch->value < 0;
  912. Cvar_SetValue( "lookspring", ClampCvar( 0, 1, lookspring->value ) );
  913. s_options_lookspring_box.curvalue = lookspring->value;
  914. Cvar_SetValue( "lookstrafe", ClampCvar( 0, 1, lookstrafe->value ) );
  915. s_options_lookstrafe_box.curvalue = lookstrafe->value;
  916. Cvar_SetValue( "freelook", ClampCvar( 0, 1, freelook->value ) );
  917. s_options_freelook_box.curvalue = freelook->value;
  918. Cvar_SetValue( "crosshair", ClampCvar( 0, 3, crosshair->value ) );
  919. s_options_crosshair_box.curvalue = crosshair->value;
  920. Cvar_SetValue( "in_joystick", ClampCvar( 0, 1, in_joystick->value ) );
  921. s_options_joystick_box.curvalue = in_joystick->value;
  922. s_options_noalttab_box.curvalue = win_noalttab->value;
  923. }
  924. static void ControlsResetDefaultsFunc( void *unused )
  925. {
  926. Cbuf_AddText ("exec default.cfg\n");
  927. Cbuf_Execute();
  928. ControlsSetMenuItemValues();
  929. }
  930. static void InvertMouseFunc( void *unused )
  931. {
  932. if ( s_options_invertmouse_box.curvalue == 0 )
  933. {
  934. Cvar_SetValue( "m_pitch", fabs( m_pitch->value ) );
  935. }
  936. else
  937. {
  938. Cvar_SetValue( "m_pitch", -fabs( m_pitch->value ) );
  939. }
  940. }
  941. static void LookspringFunc( void *unused )
  942. {
  943. Cvar_SetValue( "lookspring", s_options_lookspring_box.curvalue );
  944. }
  945. static void LookstrafeFunc( void *unused )
  946. {
  947. Cvar_SetValue( "lookstrafe", s_options_lookstrafe_box.curvalue );
  948. }
  949. static void UpdateVolumeFunc( void *unused )
  950. {
  951. Cvar_SetValue( "s_volume", s_options_sfxvolume_slider.curvalue / 10 );
  952. }
  953. static void UpdateCDVolumeFunc( void *unused )
  954. {
  955. Cvar_SetValue( "cd_nocd", !s_options_cdvolume_box.curvalue );
  956. }
  957. static void ConsoleFunc( void *unused )
  958. {
  959. /*
  960. ** the proper way to do this is probably to have ToggleConsole_f accept a parameter
  961. */
  962. extern void Key_ClearTyping( void );
  963. if ( cl.attractloop )
  964. {
  965. Cbuf_AddText ("killserver\n");
  966. return;
  967. }
  968. Key_ClearTyping ();
  969. Con_ClearNotify ();
  970. M_ForceMenuOff ();
  971. cls.key_dest = key_console;
  972. }
  973. static void UpdateSoundQualityFunc( void *unused )
  974. {
  975. if ( s_options_quality_list.curvalue )
  976. {
  977. Cvar_SetValue( "s_khz", 22 );
  978. Cvar_SetValue( "s_loadas8bit", false );
  979. }
  980. else
  981. {
  982. Cvar_SetValue( "s_khz", 11 );
  983. Cvar_SetValue( "s_loadas8bit", true );
  984. }
  985. Cvar_SetValue( "s_primary", s_options_compatibility_list.curvalue );
  986. M_DrawTextBox( 8, 120 - 48, 36, 3 );
  987. M_Print( 16 + 16, 120 - 48 + 8, "Restarting the sound system. This" );
  988. M_Print( 16 + 16, 120 - 48 + 16, "could take up to a minute, so" );
  989. M_Print( 16 + 16, 120 - 48 + 24, "please be patient." );
  990. // the text box won't show up unless we do a buffer swap
  991. re.EndFrame();
  992. CL_Snd_Restart_f();
  993. }
  994. void Options_MenuInit( void )
  995. {
  996. static const char *cd_music_items[] =
  997. {
  998. "disabled",
  999. "enabled",
  1000. 0
  1001. };
  1002. static const char *quality_items[] =
  1003. {
  1004. "low", "high", 0
  1005. };
  1006. static const char *compatibility_items[] =
  1007. {
  1008. "max compatibility", "max performance", 0
  1009. };
  1010. static const char *yesno_names[] =
  1011. {
  1012. "no",
  1013. "yes",
  1014. 0
  1015. };
  1016. static const char *crosshair_names[] =
  1017. {
  1018. "none",
  1019. "cross",
  1020. "dot",
  1021. "angle",
  1022. 0
  1023. };
  1024. win_noalttab = Cvar_Get( "win_noalttab", "0", CVAR_ARCHIVE );
  1025. /*
  1026. ** configure controls menu and menu items
  1027. */
  1028. s_options_menu.x = viddef.width / 2;
  1029. s_options_menu.y = viddef.height / 2 - 58;
  1030. s_options_menu.nitems = 0;
  1031. s_options_sfxvolume_slider.generic.type = MTYPE_SLIDER;
  1032. s_options_sfxvolume_slider.generic.x = 0;
  1033. s_options_sfxvolume_slider.generic.y = 0;
  1034. s_options_sfxvolume_slider.generic.name = "effects volume";
  1035. s_options_sfxvolume_slider.generic.callback = UpdateVolumeFunc;
  1036. s_options_sfxvolume_slider.minvalue = 0;
  1037. s_options_sfxvolume_slider.maxvalue = 10;
  1038. s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10;
  1039. s_options_cdvolume_box.generic.type = MTYPE_SPINCONTROL;
  1040. s_options_cdvolume_box.generic.x = 0;
  1041. s_options_cdvolume_box.generic.y = 10;
  1042. s_options_cdvolume_box.generic.name = "CD music";
  1043. s_options_cdvolume_box.generic.callback = UpdateCDVolumeFunc;
  1044. s_options_cdvolume_box.itemnames = cd_music_items;
  1045. s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd");
  1046. s_options_quality_list.generic.type = MTYPE_SPINCONTROL;
  1047. s_options_quality_list.generic.x = 0;
  1048. s_options_quality_list.generic.y = 20;;
  1049. s_options_quality_list.generic.name = "sound quality";
  1050. s_options_quality_list.generic.callback = UpdateSoundQualityFunc;
  1051. s_options_quality_list.itemnames = quality_items;
  1052. s_options_quality_list.curvalue = !Cvar_VariableValue( "s_loadas8bit" );
  1053. s_options_compatibility_list.generic.type = MTYPE_SPINCONTROL;
  1054. s_options_compatibility_list.generic.x = 0;
  1055. s_options_compatibility_list.generic.y = 30;
  1056. s_options_compatibility_list.generic.name = "sound compatibility";
  1057. s_options_compatibility_list.generic.callback = UpdateSoundQualityFunc;
  1058. s_options_compatibility_list.itemnames = compatibility_items;
  1059. s_options_compatibility_list.curvalue = Cvar_VariableValue( "s_primary" );
  1060. s_options_sensitivity_slider.generic.type = MTYPE_SLIDER;
  1061. s_options_sensitivity_slider.generic.x = 0;
  1062. s_options_sensitivity_slider.generic.y = 50;
  1063. s_options_sensitivity_slider.generic.name = "mouse speed";
  1064. s_options_sensitivity_slider.generic.callback = MouseSpeedFunc;
  1065. s_options_sensitivity_slider.minvalue = 2;
  1066. s_options_sensitivity_slider.maxvalue = 22;
  1067. s_options_alwaysrun_box.generic.type = MTYPE_SPINCONTROL;
  1068. s_options_alwaysrun_box.generic.x = 0;
  1069. s_options_alwaysrun_box.generic.y = 60;
  1070. s_options_alwaysrun_box.generic.name = "always run";
  1071. s_options_alwaysrun_box.generic.callback = AlwaysRunFunc;
  1072. s_options_alwaysrun_box.itemnames = yesno_names;
  1073. s_options_invertmouse_box.generic.type = MTYPE_SPINCONTROL;
  1074. s_options_invertmouse_box.generic.x = 0;
  1075. s_options_invertmouse_box.generic.y = 70;
  1076. s_options_invertmouse_box.generic.name = "invert mouse";
  1077. s_options_invertmouse_box.generic.callback = InvertMouseFunc;
  1078. s_options_invertmouse_box.itemnames = yesno_names;
  1079. s_options_lookspring_box.generic.type = MTYPE_SPINCONTROL;
  1080. s_options_lookspring_box.generic.x = 0;
  1081. s_options_lookspring_box.generic.y = 80;
  1082. s_options_lookspring_box.generic.name = "lookspring";
  1083. s_options_lookspring_box.generic.callback = LookspringFunc;
  1084. s_options_lookspring_box.itemnames = yesno_names;
  1085. s_options_lookstrafe_box.generic.type = MTYPE_SPINCONTROL;
  1086. s_options_lookstrafe_box.generic.x = 0;
  1087. s_options_lookstrafe_box.generic.y = 90;
  1088. s_options_lookstrafe_box.generic.name = "lookstrafe";
  1089. s_options_lookstrafe_box.generic.callback = LookstrafeFunc;
  1090. s_options_lookstrafe_box.itemnames = yesno_names;
  1091. s_options_freelook_box.generic.type = MTYPE_SPINCONTROL;
  1092. s_options_freelook_box.generic.x = 0;
  1093. s_options_freelook_box.generic.y = 100;
  1094. s_options_freelook_box.generic.name = "free look";
  1095. s_options_freelook_box.generic.callback = FreeLookFunc;
  1096. s_options_freelook_box.itemnames = yesno_names;
  1097. s_options_crosshair_box.generic.type = MTYPE_SPINCONTROL;
  1098. s_options_crosshair_box.generic.x = 0;
  1099. s_options_crosshair_box.generic.y = 110;
  1100. s_options_crosshair_box.generic.name = "crosshair";
  1101. s_options_crosshair_box.generic.callback = CrosshairFunc;
  1102. s_options_crosshair_box.itemnames = crosshair_names;
  1103. /*
  1104. s_options_noalttab_box.generic.type = MTYPE_SPINCONTROL;
  1105. s_options_noalttab_box.generic.x = 0;
  1106. s_options_noalttab_box.generic.y = 110;
  1107. s_options_noalttab_box.generic.name = "disable alt-tab";
  1108. s_options_noalttab_box.generic.callback = NoAltTabFunc;
  1109. s_options_noalttab_box.itemnames = yesno_names;
  1110. */
  1111. s_options_joystick_box.generic.type = MTYPE_SPINCONTROL;
  1112. s_options_joystick_box.generic.x = 0;
  1113. s_options_joystick_box.generic.y = 120;
  1114. s_options_joystick_box.generic.name = "use joystick";
  1115. s_options_joystick_box.generic.callback = JoystickFunc;
  1116. s_options_joystick_box.itemnames = yesno_names;
  1117. s_options_customize_options_action.generic.type = MTYPE_ACTION;
  1118. s_options_customize_options_action.generic.x = 0;
  1119. s_options_customize_options_action.generic.y = 140;
  1120. s_options_customize_options_action.generic.name = "customize controls";
  1121. s_options_customize_options_action.generic.callback = CustomizeControlsFunc;
  1122. s_options_defaults_action.generic.type = MTYPE_ACTION;
  1123. s_options_defaults_action.generic.x = 0;
  1124. s_options_defaults_action.generic.y = 150;
  1125. s_options_defaults_action.generic.name = "reset defaults";
  1126. s_options_defaults_action.generic.callback = ControlsResetDefaultsFunc;
  1127. s_options_console_action.generic.type = MTYPE_ACTION;
  1128. s_options_console_action.generic.x = 0;
  1129. s_options_console_action.generic.y = 160;
  1130. s_options_console_action.generic.name = "go to console";
  1131. s_options_console_action.generic.callback = ConsoleFunc;
  1132. ControlsSetMenuItemValues();
  1133. Menu_AddItem( &s_options_menu, ( void * ) &s_options_sfxvolume_slider );
  1134. Menu_AddItem( &s_options_menu, ( void * ) &s_options_cdvolume_box );
  1135. Menu_AddItem( &s_options_menu, ( void * ) &s_options_quality_list );
  1136. Menu_AddItem( &s_options_menu, ( void * ) &s_options_compatibility_list );
  1137. Menu_AddItem( &s_options_menu, ( void * ) &s_options_sensitivity_slider );
  1138. Menu_AddItem( &s_options_menu, ( void * ) &s_options_alwaysrun_box );
  1139. Menu_AddItem( &s_options_menu, ( void * ) &s_options_invertmouse_box );
  1140. Menu_AddItem( &s_options_menu, ( void * ) &s_options_lookspring_box );
  1141. Menu_AddItem( &s_options_menu, ( void * ) &s_options_lookstrafe_box );
  1142. Menu_AddItem( &s_options_menu, ( void * ) &s_options_freelook_box );
  1143. Menu_AddItem( &s_options_menu, ( void * ) &s_options_crosshair_box );
  1144. Menu_AddItem( &s_options_menu, ( void * ) &s_options_joystick_box );
  1145. Menu_AddItem( &s_options_menu, ( void * ) &s_options_customize_options_action );
  1146. Menu_AddItem( &s_options_menu, ( void * ) &s_options_defaults_action );
  1147. Menu_AddItem( &s_options_menu, ( void * ) &s_options_console_action );
  1148. }
  1149. void Options_MenuDraw (void)
  1150. {
  1151. M_Banner( "m_banner_options" );
  1152. Menu_AdjustCursor( &s_options_menu, 1 );
  1153. Menu_Draw( &s_options_menu );
  1154. }
  1155. const char *Options_MenuKey( int key )
  1156. {
  1157. return Default_MenuKey( &s_options_menu, key );
  1158. }
  1159. void M_Menu_Options_f (void)
  1160. {
  1161. Options_MenuInit();
  1162. M_PushMenu ( Options_MenuDraw, Options_MenuKey );
  1163. }
  1164. /*
  1165. =======================================================================
  1166. VIDEO MENU
  1167. =======================================================================
  1168. */
  1169. void M_Menu_Video_f (void)
  1170. {
  1171. VID_MenuInit();
  1172. M_PushMenu( VID_MenuDraw, VID_MenuKey );
  1173. }
  1174. /*
  1175. =============================================================================
  1176. END GAME MENU
  1177. =============================================================================
  1178. */
  1179. static int credits_start_time;
  1180. static const char **credits;
  1181. static char *creditsIndex[256];
  1182. static char *creditsBuffer;
  1183. static const char *idcredits[] =
  1184. {
  1185. "+QUAKE II BY ID SOFTWARE",
  1186. "",
  1187. "+PROGRAMMING",
  1188. "John Carmack",
  1189. "John Cash",
  1190. "Brian Hook",
  1191. "",
  1192. "+ART",
  1193. "Adrian Carmack",
  1194. "Kevin Cloud",
  1195. "Paul Steed",
  1196. "",
  1197. "+LEVEL DESIGN",
  1198. "Tim Willits",
  1199. "American McGee",
  1200. "Christian Antkow",
  1201. "Paul Jaquays",
  1202. "Brandon James",
  1203. "",
  1204. "+BIZ",
  1205. "Todd Hollenshead",
  1206. "Barrett (Bear) Alexander",
  1207. "Donna Jackson",
  1208. "",
  1209. "",
  1210. "+SPECIAL THANKS",
  1211. "Ben Donges for beta testing",
  1212. "",
  1213. "",
  1214. "",
  1215. "",
  1216. "",
  1217. "",
  1218. "+ADDITIONAL SUPPORT",
  1219. "",
  1220. "+LINUX PORT AND CTF",
  1221. "Dave \"Zoid\" Kirsch",
  1222. "",
  1223. "+CINEMATIC SEQUENCES",
  1224. "Ending Cinematic by Blur Studio - ",
  1225. "Venice, CA",
  1226. "",
  1227. "Environment models for Introduction",
  1228. "Cinematic by Karl Dolgener",
  1229. "",
  1230. "Assistance with environment design",
  1231. "by Cliff Iwai",
  1232. "",
  1233. "+SOUND EFFECTS AND MUSIC",
  1234. "Sound Design by Soundelux Media Labs.",
  1235. "Music Composed and Produced by",
  1236. "Soundelux Media Labs. Special thanks",
  1237. "to Bill Brown, Tom Ozanich, Brian",
  1238. "Celano, Jeff Eisner, and The Soundelux",
  1239. "Players.",
  1240. "",
  1241. "\"Level Music\" by Sonic Mayhem",
  1242. "www.sonicmayhem.com",
  1243. "",
  1244. "\"Quake II Theme Song\"",
  1245. "(C) 1997 Rob Zombie. All Rights",
  1246. "Reserved.",
  1247. "",
  1248. "Track 10 (\"Climb\") by Jer Sypult",
  1249. "",
  1250. "Voice of computers by",
  1251. "Carly Staehlin-Taylor",
  1252. "",
  1253. "+THANKS TO ACTIVISION",
  1254. "+IN PARTICULAR:",
  1255. "",
  1256. "John Tam",
  1257. "Steve Rosenthal",
  1258. "Marty Stratton",
  1259. "Henk Hartong",
  1260. "",
  1261. "Quake II(tm) (C)1997 Id Software, Inc.",
  1262. "All Rights Reserved. Distributed by",
  1263. "Activision, Inc. under license.",
  1264. "Quake II(tm), the Id Software name,",
  1265. "the \"Q II\"(tm) logo and id(tm)",
  1266. "logo are trademarks of Id Software,",
  1267. "Inc. Activision(R) is a registered",
  1268. "trademark of Activision, Inc. All",
  1269. "other trademarks and trade names are",
  1270. "properties of their respective owners.",
  1271. 0
  1272. };
  1273. static const char *xatcredits[] =
  1274. {
  1275. "+QUAKE II MISSION PACK: THE RECKONING",
  1276. "+BY",
  1277. "+XATRIX ENTERTAINMENT, INC.",
  1278. "",
  1279. "+DESIGN AND DIRECTION",
  1280. "Drew Markham",
  1281. "",
  1282. "+PRODUCED BY",
  1283. "Greg Goodrich",
  1284. "",
  1285. "+PROGRAMMING",
  1286. "Rafael Paiz",
  1287. "",
  1288. "+LEVEL DESIGN / ADDITIONAL GAME DESIGN",
  1289. "Alex Mayberry",
  1290. "",
  1291. "+LEVEL DESIGN",
  1292. "Mal Blackwell",
  1293. "Dan Koppel",
  1294. "",
  1295. "+ART DIRECTION",
  1296. "Michael \"Maxx\" Kaufman",
  1297. "",
  1298. "+COMPUTER GRAPHICS SUPERVISOR AND",
  1299. "+CHARACTER ANIMATION DIRECTION",
  1300. "Barry Dempsey",
  1301. "",
  1302. "+SENIOR ANIMATOR AND MODELER",
  1303. "Jason Hoover",
  1304. "",
  1305. "+CHARACTER ANIMATION AND",
  1306. "+MOTION CAPTURE SPECIALIST",
  1307. "Amit Doron",
  1308. "",
  1309. "+ART",
  1310. "Claire Praderie-Markham",
  1311. "Viktor Antonov",
  1312. "Corky Lehmkuhl",
  1313. "",
  1314. "+INTRODUCTION ANIMATION",
  1315. "Dominique Drozdz",
  1316. "",
  1317. "+ADDITIONAL LEVEL DESIGN",
  1318. "Aaron Barber",
  1319. "Rhett Baldwin",
  1320. "",
  1321. "+3D CHARACTER ANIMATION TOOLS",
  1322. "Gerry Tyra, SA Technology",
  1323. "",
  1324. "+ADDITIONAL EDITOR TOOL PROGRAMMING",
  1325. "Robert Duffy",
  1326. "",
  1327. "+ADDITIONAL PROGRAMMING",
  1328. "Ryan Feltrin",
  1329. "",
  1330. "+PRODUCTION COORDINATOR",
  1331. "Victoria Sylvester",
  1332. "",
  1333. "+SOUND DESIGN",
  1334. "Gary Bradfield",
  1335. "",
  1336. "+MUSIC BY",
  1337. "Sonic Mayhem",
  1338. "",
  1339. "",
  1340. "",
  1341. "+SPECIAL THANKS",
  1342. "+TO",
  1343. "+OUR FRIENDS AT ID SOFTWARE",
  1344. "",
  1345. "John Carmack",
  1346. "John Cash",
  1347. "Brian Hook",
  1348. "Adrian Carmack",
  1349. "Kevin Cloud",
  1350. "Paul Steed",
  1351. "Tim Willits",
  1352. "Christian Antkow",
  1353. "Paul Jaquays",
  1354. "Brandon James",
  1355. "Todd Hollenshead",
  1356. "Barrett (Bear) Alexander",
  1357. "Dave \"Zoid\" Kirsch",
  1358. "Donna Jackson",
  1359. "",
  1360. "",
  1361. "",
  1362. "+THANKS TO ACTIVISION",
  1363. "+IN PARTICULAR:",
  1364. "",
  1365. "Marty Stratton",
  1366. "Henk \"The Original Ripper\" Hartong",
  1367. "Kevin Kraff",
  1368. "Jamey Gottlieb",
  1369. "Chris Hepburn",
  1370. "",
  1371. "+AND THE GAME TESTERS",
  1372. "",
  1373. "Tim Vanlaw",
  1374. "Doug Jacobs",
  1375. "Steven Rosenthal",
  1376. "David Baker",
  1377. "Chris Campbell",
  1378. "Aaron Casillas",
  1379. "Steve Elwell",
  1380. "Derek Johnstone",
  1381. "Igor Krinitskiy",
  1382. "Samantha Lee",
  1383. "Michael Spann",
  1384. "Chris Toft",
  1385. "Juan Valdes",
  1386. "",
  1387. "+THANKS TO INTERGRAPH COMPUTER SYTEMS",
  1388. "+IN PARTICULAR:",
  1389. "",
  1390. "Michael T. Nicolaou",
  1391. "",
  1392. "",
  1393. "Quake II Mission Pack: The Reckoning",
  1394. "(tm) (C)1998 Id Software, Inc. All",
  1395. "Rights Reserved. Developed by Xatrix",
  1396. "Entertainment, Inc. for Id Software,",
  1397. "Inc. Distributed by Activision Inc.",
  1398. "under license. Quake(R) is a",
  1399. "registered trademark of Id Software,",
  1400. "Inc. Quake II Mission Pack: The",
  1401. "Reckoning(tm), Quake II(tm), the Id",
  1402. "Software name, the \"Q II\"(tm) logo",
  1403. "and id(tm) logo are trademarks of Id",
  1404. "Software, Inc. Activision(R) is a",
  1405. "registered trademark of Activision,",
  1406. "Inc. Xatrix(R) is a registered",
  1407. "trademark of Xatrix Entertainment,",
  1408. "Inc. All other trademarks and trade",
  1409. "names are properties of their",
  1410. "respective owners.",
  1411. 0
  1412. };
  1413. static const char *roguecredits[] =
  1414. {
  1415. "+QUAKE II MISSION PACK 2: GROUND ZERO",
  1416. "+BY",
  1417. "+ROGUE ENTERTAINMENT, INC.",
  1418. "",
  1419. "+PRODUCED BY",
  1420. "Jim Molinets",
  1421. "",
  1422. "+PROGRAMMING",
  1423. "Peter Mack",
  1424. "Patrick Magruder",
  1425. "",
  1426. "+LEVEL DESIGN",
  1427. "Jim Molinets",
  1428. "Cameron Lamprecht",
  1429. "Berenger Fish",
  1430. "Robert Selitto",
  1431. "Steve Tietze",
  1432. "Steve Thoms",
  1433. "",
  1434. "+ART DIRECTION",
  1435. "Rich Fleider",
  1436. "",
  1437. "+ART",
  1438. "Rich Fleider",
  1439. "Steve Maines",
  1440. "Won Choi",
  1441. "",
  1442. "+ANIMATION SEQUENCES",
  1443. "Creat Studios",
  1444. "Steve Maines",
  1445. "",
  1446. "+ADDITIONAL LEVEL DESIGN",
  1447. "Rich Fleider",
  1448. "Steve Maines",
  1449. "Peter Mack",
  1450. "",
  1451. "+SOUND",
  1452. "James Grunke",
  1453. "",
  1454. "+GROUND ZERO THEME",
  1455. "+AND",
  1456. "+MUSIC BY",
  1457. "Sonic Mayhem",
  1458. "",
  1459. "+VWEP MODELS",
  1460. "Brent \"Hentai\" Dill",
  1461. "",
  1462. "",
  1463. "",
  1464. "+SPECIAL THANKS",
  1465. "+TO",
  1466. "+OUR FRIENDS AT ID SOFTWARE",
  1467. "",
  1468. "John Carmack",
  1469. "John Cash",
  1470. "Brian Hook",
  1471. "Adrian Carmack",
  1472. "Kevin Cloud",
  1473. "Paul Steed",
  1474. "Tim Willits",
  1475. "Christian Antkow",
  1476. "Paul Jaquays",
  1477. "Brandon James",
  1478. "Todd Hollenshead",
  1479. "Barrett (Bear) Alexander",
  1480. "Katherine Anna Kang",
  1481. "Donna Jackson",
  1482. "Dave \"Zoid\" Kirsch",
  1483. "",
  1484. "",
  1485. "",
  1486. "+THANKS TO ACTIVISION",
  1487. "+IN PARTICULAR:",
  1488. "",
  1489. "Marty Stratton",
  1490. "Henk Hartong",
  1491. "Mitch Lasky",
  1492. "Steve Rosenthal",
  1493. "Steve Elwell",
  1494. "",
  1495. "+AND THE GAME TESTERS",
  1496. "",
  1497. "The Ranger Clan",
  1498. "Dave \"Zoid\" Kirsch",
  1499. "Nihilistic Software",
  1500. "Robert Duffy",
  1501. "",
  1502. "And Countless Others",
  1503. "",
  1504. "",
  1505. "",
  1506. "Quake II Mission Pack 2: Ground Zero",
  1507. "(tm) (C)1998 Id Software, Inc. All",
  1508. "Rights Reserved. Developed by Rogue",
  1509. "Entertainment, Inc. for Id Software,",
  1510. "Inc. Distributed by Activision Inc.",
  1511. "under license. Quake(R) is a",
  1512. "registered trademark of Id Software,",
  1513. "Inc. Quake II Mission Pack 2: Ground",
  1514. "Zero(tm), Quake II(tm), the Id",
  1515. "Software name, the \"Q II\"(tm) logo",
  1516. "and id(tm) logo are trademarks of Id",
  1517. "Software, Inc. Activision(R) is a",
  1518. "registered trademark of Activision,",
  1519. "Inc. Rogue(R) is a registered",
  1520. "trademark of Rogue Entertainment,",
  1521. "Inc. All other trademarks and trade",
  1522. "names are properties of their",
  1523. "respective owners.",
  1524. 0
  1525. };
  1526. void M_Credits_MenuDraw( void )
  1527. {
  1528. int i, y;
  1529. /*
  1530. ** draw the credits
  1531. */
  1532. for ( i = 0, y = viddef.height - ( ( cls.realtime - credits_start_time ) / 40.0F ); credits[i] && y < viddef.height; y += 10, i++ )
  1533. {
  1534. int j, stringoffset = 0;
  1535. int bold = false;
  1536. if ( y <= -8 )
  1537. continue;
  1538. if ( credits[i][0] == '+' )
  1539. {
  1540. bold = true;
  1541. stringoffset = 1;
  1542. }
  1543. else
  1544. {
  1545. bold = false;
  1546. stringoffset = 0;
  1547. }
  1548. for ( j = 0; credits[i][j+stringoffset]; j++ )
  1549. {
  1550. int x;
  1551. x = ( viddef.width - strlen( credits[i] ) * 8 - stringoffset * 8 ) / 2 + ( j + stringoffset ) * 8;
  1552. if ( bold )
  1553. re.DrawChar( x, y, credits[i][j+stringoffset] + 128 );
  1554. else
  1555. re.DrawChar( x, y, credits[i][j+stringoffset] );
  1556. }
  1557. }
  1558. if ( y < 0 )
  1559. credits_start_time = cls.realtime;
  1560. }
  1561. const char *M_Credits_Key( int key )
  1562. {
  1563. switch (key)
  1564. {
  1565. case K_ESCAPE:
  1566. if (creditsBuffer)
  1567. FS_FreeFile (creditsBuffer);
  1568. M_PopMenu ();
  1569. break;
  1570. }
  1571. return menu_out_sound;
  1572. }
  1573. extern int Developer_searchpath (int who);
  1574. void M_Menu_Credits_f( void )
  1575. {
  1576. int n;
  1577. int count;
  1578. char *p;
  1579. int isdeveloper = 0;
  1580. creditsBuffer = NULL;
  1581. count = FS_LoadFile ("credits", &creditsBuffer);
  1582. if (count != -1)
  1583. {
  1584. p = creditsBuffer;
  1585. for (n = 0; n < 255; n++)
  1586. {
  1587. creditsIndex[n] = p;
  1588. while (*p != '\r' && *p != '\n')
  1589. {
  1590. p++;
  1591. if (--count == 0)
  1592. break;
  1593. }
  1594. if (*p == '\r')
  1595. {
  1596. *p++ = 0;
  1597. if (--count == 0)
  1598. break;
  1599. }
  1600. *p++ = 0;
  1601. if (--count == 0)
  1602. break;
  1603. }
  1604. creditsIndex[++n] = 0;
  1605. credits = creditsIndex;
  1606. }
  1607. else
  1608. {
  1609. isdeveloper = Developer_searchpath (1);
  1610. if (isdeveloper == 1) // xatrix
  1611. credits = xatcredits;
  1612. else if (isdeveloper == 2) // ROGUE
  1613. credits = roguecredits;
  1614. else
  1615. {
  1616. credits = idcredits;
  1617. }
  1618. }
  1619. credits_start_time = cls.realtime;
  1620. M_PushMenu( M_Credits_MenuDraw, M_Credits_Key);
  1621. }
  1622. /*
  1623. =============================================================================
  1624. GAME MENU
  1625. =============================================================================
  1626. */
  1627. static int m_game_cursor;
  1628. static menuframework_s s_game_menu;
  1629. static menuaction_s s_easy_game_action;
  1630. static menuaction_s s_medium_game_action;
  1631. static menuaction_s s_hard_game_action;
  1632. static menuaction_s s_load_game_action;
  1633. static menuaction_s s_save_game_action;
  1634. static menuaction_s s_credits_action;
  1635. static menuseparator_s s_blankline;
  1636. static void StartGame( void )
  1637. {
  1638. // disable updates and start the cinematic going
  1639. cl.servercount = -1;
  1640. M_ForceMenuOff ();
  1641. Cvar_SetValue( "deathmatch", 0 );
  1642. Cvar_SetValue( "coop", 0 );
  1643. Cvar_SetValue( "gamerules", 0 ); //PGM
  1644. Cbuf_AddText ("loading ; killserver ; wait ; newgame\n");
  1645. cls.key_dest = key_game;
  1646. }
  1647. static void EasyGameFunc( void *data )
  1648. {
  1649. Cvar_ForceSet( "skill", "0" );
  1650. StartGame();
  1651. }
  1652. static void MediumGameFunc( void *data )
  1653. {
  1654. Cvar_ForceSet( "skill", "1" );
  1655. StartGame();
  1656. }
  1657. static void HardGameFunc( void *data )
  1658. {
  1659. Cvar_ForceSet( "skill", "2" );
  1660. StartGame();
  1661. }
  1662. static void LoadGameFunc( void *unused )
  1663. {
  1664. M_Menu_LoadGame_f ();
  1665. }
  1666. static void SaveGameFunc( void *unused )
  1667. {
  1668. M_Menu_SaveGame_f();
  1669. }
  1670. static void CreditsFunc( void *unused )
  1671. {
  1672. M_Menu_Credits_f();
  1673. }
  1674. void Game_MenuInit( void )
  1675. {
  1676. static const char *difficulty_names[] =
  1677. {
  1678. "easy",
  1679. "medium",
  1680. "hard",
  1681. 0
  1682. };
  1683. s_game_menu.x = viddef.width * 0.50;
  1684. s_game_menu.nitems = 0;
  1685. s_easy_game_action.generic.type = MTYPE_ACTION;
  1686. s_easy_game_action.generic.flags = QMF_LEFT_JUSTIFY;
  1687. s_easy_game_action.generic.x = 0;
  1688. s_easy_game_action.generic.y = 0;
  1689. s_easy_game_action.generic.name = "easy";
  1690. s_easy_game_action.generic.callback = EasyGameFunc;
  1691. s_medium_game_action.generic.type = MTYPE_ACTION;
  1692. s_medium_game_action.generic.flags = QMF_LEFT_JUSTIFY;
  1693. s_medium_game_action.generic.x = 0;
  1694. s_medium_game_action.generic.y = 10;
  1695. s_medium_game_action.generic.name = "medium";
  1696. s_medium_game_action.generic.callback = MediumGameFunc;
  1697. s_hard_game_action.generic.type = MTYPE_ACTION;
  1698. s_hard_game_action.generic.flags = QMF_LEFT_JUSTIFY;
  1699. s_hard_game_action.generic.x = 0;
  1700. s_hard_game_action.generic.y = 20;
  1701. s_hard_game_action.generic.name = "hard";
  1702. s_hard_game_action.generic.callback = HardGameFunc;
  1703. s_blankline.generic.type = MTYPE_SEPARATOR;
  1704. s_load_game_action.generic.type = MTYPE_ACTION;
  1705. s_load_game_action.generic.flags = QMF_LEFT_JUSTIFY;
  1706. s_load_game_action.generic.x = 0;
  1707. s_load_game_action.generic.y = 40;
  1708. s_load_game_action.generic.name = "load game";
  1709. s_load_game_action.generic.callback = LoadGameFunc;
  1710. s_save_game_action.generic.type = MTYPE_ACTION;
  1711. s_save_game_action.generic.flags = QMF_LEFT_JUSTIFY;
  1712. s_save_game_action.generic.x = 0;
  1713. s_save_game_action.generic.y = 50;
  1714. s_save_game_action.generic.name = "save game";
  1715. s_save_game_action.generic.callback = SaveGameFunc;
  1716. s_credits_action.generic.type = MTYPE_ACTION;
  1717. s_credits_action.generic.flags = QMF_LEFT_JUSTIFY;
  1718. s_credits_action.generic.x = 0;
  1719. s_credits_action.generic.y = 60;
  1720. s_credits_action.generic.name = "credits";
  1721. s_credits_action.generic.callback = CreditsFunc;
  1722. Menu_AddItem( &s_game_menu, ( void * ) &s_easy_game_action );
  1723. Menu_AddItem( &s_game_menu, ( void * ) &s_medium_game_action );
  1724. Menu_AddItem( &s_game_menu, ( void * ) &s_hard_game_action );
  1725. Menu_AddItem( &s_game_menu, ( void * ) &s_blankline );
  1726. Menu_AddItem( &s_game_menu, ( void * ) &s_load_game_action );
  1727. Menu_AddItem( &s_game_menu, ( void * ) &s_save_game_action );
  1728. Menu_AddItem( &s_game_menu, ( void * ) &s_blankline );
  1729. Menu_AddItem( &s_game_menu, ( void * ) &s_credits_action );
  1730. Menu_Center( &s_game_menu );
  1731. }
  1732. void Game_MenuDraw( void )
  1733. {
  1734. M_Banner( "m_banner_game" );
  1735. Menu_AdjustCursor( &s_game_menu, 1 );
  1736. Menu_Draw( &s_game_menu );
  1737. }
  1738. const char *Game_MenuKey( int key )
  1739. {
  1740. return Default_MenuKey( &s_game_menu, key );
  1741. }
  1742. void M_Menu_Game_f (void)
  1743. {
  1744. Game_MenuInit();
  1745. M_PushMenu( Game_MenuDraw, Game_MenuKey );
  1746. m_game_cursor = 1;
  1747. }
  1748. /*
  1749. =============================================================================
  1750. LOADGAME MENU
  1751. =============================================================================
  1752. */
  1753. #define MAX_SAVEGAMES 15
  1754. static menuframework_s s_savegame_menu;
  1755. static menuframework_s s_loadgame_menu;
  1756. static menuaction_s s_loadgame_actions[MAX_SAVEGAMES];
  1757. char m_savestrings[MAX_SAVEGAMES][32];
  1758. qboolean m_savevalid[MAX_SAVEGAMES];
  1759. void Create_Savestrings (void)
  1760. {
  1761. int i;
  1762. FILE *f;
  1763. char name[MAX_OSPATH];
  1764. for (i=0 ; i<MAX_SAVEGAMES ; i++)
  1765. {
  1766. Com_sprintf (name, sizeof(name), "%s/save/save%i/server.ssv", FS_Gamedir(), i);
  1767. f = fopen (name, "rb");
  1768. if (!f)
  1769. {
  1770. strcpy (m_savestrings[i], "<EMPTY>");
  1771. m_savevalid[i] = false;
  1772. }
  1773. else
  1774. {
  1775. FS_Read (m_savestrings[i], sizeof(m_savestrings[i]), f);
  1776. fclose (f);
  1777. m_savevalid[i] = true;
  1778. }
  1779. }
  1780. }
  1781. void LoadGameCallback( void *self )
  1782. {
  1783. menuaction_s *a = ( menuaction_s * ) self;
  1784. if ( m_savevalid[ a->generic.localdata[0] ] )
  1785. Cbuf_AddText (va("load save%i\n", a->generic.localdata[0] ) );
  1786. M_ForceMenuOff ();
  1787. }
  1788. void LoadGame_MenuInit( void )
  1789. {
  1790. int i;
  1791. s_loadgame_menu.x = viddef.width / 2 - 120;
  1792. s_loadgame_menu.y = viddef.height / 2 - 58;
  1793. s_loadgame_menu.nitems = 0;
  1794. Create_Savestrings();
  1795. for ( i = 0; i < MAX_SAVEGAMES; i++ )
  1796. {
  1797. s_loadgame_actions[i].generic.name = m_savestrings[i];
  1798. s_loadgame_actions[i].generic.flags = QMF_LEFT_JUSTIFY;
  1799. s_loadgame_actions[i].generic.localdata[0] = i;
  1800. s_loadgame_actions[i].generic.callback = LoadGameCallback;
  1801. s_loadgame_actions[i].generic.x = 0;
  1802. s_loadgame_actions[i].generic.y = ( i ) * 10;
  1803. if (i>0) // separate from autosave
  1804. s_loadgame_actions[i].generic.y += 10;
  1805. s_loadgame_actions[i].generic.type = MTYPE_ACTION;
  1806. Menu_AddItem( &s_loadgame_menu, &s_loadgame_actions[i] );
  1807. }
  1808. }
  1809. void LoadGame_MenuDraw( void )
  1810. {
  1811. M_Banner( "m_banner_load_game" );
  1812. // Menu_AdjustCursor( &s_loadgame_menu, 1 );
  1813. Menu_Draw( &s_loadgame_menu );
  1814. }
  1815. const char *LoadGame_MenuKey( int key )
  1816. {
  1817. if ( key == K_ESCAPE || key == K_ENTER )
  1818. {
  1819. s_savegame_menu.cursor = s_loadgame_menu.cursor - 1;
  1820. if ( s_savegame_menu.cursor < 0 )
  1821. s_savegame_menu.cursor = 0;
  1822. }
  1823. return Default_MenuKey( &s_loadgame_menu, key );
  1824. }
  1825. void M_Menu_LoadGame_f (void)
  1826. {
  1827. LoadGame_MenuInit();
  1828. M_PushMenu( LoadGame_MenuDraw, LoadGame_MenuKey );
  1829. }
  1830. /*
  1831. =============================================================================
  1832. SAVEGAME MENU
  1833. =============================================================================
  1834. */
  1835. static menuframework_s s_savegame_menu;
  1836. static menuaction_s s_savegame_actions[MAX_SAVEGAMES];
  1837. void SaveGameCallback( void *self )
  1838. {
  1839. menuaction_s *a = ( menuaction_s * ) self;
  1840. Cbuf_AddText (va("save save%i\n", a->generic.localdata[0] ));
  1841. M_ForceMenuOff ();
  1842. }
  1843. void SaveGame_MenuDraw( void )
  1844. {
  1845. M_Banner( "m_banner_save_game" );
  1846. Menu_AdjustCursor( &s_savegame_menu, 1 );
  1847. Menu_Draw( &s_savegame_menu );
  1848. }
  1849. void SaveGame_MenuInit( void )
  1850. {
  1851. int i;
  1852. s_savegame_menu.x = viddef.width / 2 - 120;
  1853. s_savegame_menu.y = viddef.height / 2 - 58;
  1854. s_savegame_menu.nitems = 0;
  1855. Create_Savestrings();
  1856. // don't include the autosave slot
  1857. for ( i = 0; i < MAX_SAVEGAMES-1; i++ )
  1858. {
  1859. s_savegame_actions[i].generic.name = m_savestrings[i+1];
  1860. s_savegame_actions[i].generic.localdata[0] = i+1;
  1861. s_savegame_actions[i].generic.flags = QMF_LEFT_JUSTIFY;
  1862. s_savegame_actions[i].generic.callback = SaveGameCallback;
  1863. s_savegame_actions[i].generic.x = 0;
  1864. s_savegame_actions[i].generic.y = ( i ) * 10;
  1865. s_savegame_actions[i].generic.type = MTYPE_ACTION;
  1866. Menu_AddItem( &s_savegame_menu, &s_savegame_actions[i] );
  1867. }
  1868. }
  1869. const char *SaveGame_MenuKey( int key )
  1870. {
  1871. if ( key == K_ENTER || key == K_ESCAPE )
  1872. {
  1873. s_loadgame_menu.cursor = s_savegame_menu.cursor - 1;
  1874. if ( s_loadgame_menu.cursor < 0 )
  1875. s_loadgame_menu.cursor = 0;
  1876. }
  1877. return Default_MenuKey( &s_savegame_menu, key );
  1878. }
  1879. void M_Menu_SaveGame_f (void)
  1880. {
  1881. if (!Com_ServerState())
  1882. return; // not playing a game
  1883. SaveGame_MenuInit();
  1884. M_PushMenu( SaveGame_MenuDraw, SaveGame_MenuKey );
  1885. Create_Savestrings ();
  1886. }
  1887. /*
  1888. =============================================================================
  1889. JOIN SERVER MENU
  1890. =============================================================================
  1891. */
  1892. #define MAX_LOCAL_SERVERS 8
  1893. static menuframework_s s_joinserver_menu;
  1894. static menuseparator_s s_joinserver_server_title;
  1895. static menuaction_s s_joinserver_search_action;
  1896. static menuaction_s s_joinserver_address_book_action;
  1897. static menuaction_s s_joinserver_server_actions[MAX_LOCAL_SERVERS];
  1898. int m_num_servers;
  1899. #define NO_SERVER_STRING "<no server>"
  1900. // user readable information
  1901. static char local_server_names[MAX_LOCAL_SERVERS][80];
  1902. // network address
  1903. static netadr_t local_server_netadr[MAX_LOCAL_SERVERS];
  1904. void M_AddToServerList (netadr_t adr, char *info)
  1905. {
  1906. int i;
  1907. if (m_num_servers == MAX_LOCAL_SERVERS)
  1908. return;
  1909. while ( *info == ' ' )
  1910. info++;
  1911. // ignore if duplicated
  1912. for (i=0 ; i<m_num_servers ; i++)
  1913. if (!strcmp(info, local_server_names[i]))
  1914. return;
  1915. local_server_netadr[m_num_servers] = adr;
  1916. strncpy (local_server_names[m_num_servers], info, sizeof(local_server_names[0])-1);
  1917. m_num_servers++;
  1918. }
  1919. void JoinServerFunc( void *self )
  1920. {
  1921. char buffer[128];
  1922. int index;
  1923. index = ( menuaction_s * ) self - s_joinserver_server_actions;
  1924. if ( Q_stricmp( local_server_names[index], NO_SERVER_STRING ) == 0 )
  1925. return;
  1926. if (index >= m_num_servers)
  1927. return;
  1928. Com_sprintf (buffer, sizeof(buffer), "connect %s\n", NET_AdrToString (local_server_netadr[index]));
  1929. Cbuf_AddText (buffer);
  1930. M_ForceMenuOff ();
  1931. }
  1932. void AddressBookFunc( void *self )
  1933. {
  1934. M_Menu_AddressBook_f();
  1935. }
  1936. void NullCursorDraw( void *self )
  1937. {
  1938. }
  1939. void SearchLocalGames( void )
  1940. {
  1941. int i;
  1942. m_num_servers = 0;
  1943. for (i=0 ; i<MAX_LOCAL_SERVERS ; i++)
  1944. strcpy (local_server_names[i], NO_SERVER_STRING);
  1945. M_DrawTextBox( 8, 120 - 48, 36, 3 );
  1946. M_Print( 16 + 16, 120 - 48 + 8, "Searching for local servers, this" );
  1947. M_Print( 16 + 16, 120 - 48 + 16, "could take up to a minute, so" );
  1948. M_Print( 16 + 16, 120 - 48 + 24, "please be patient." );
  1949. // the text box won't show up unless we do a buffer swap
  1950. re.EndFrame();
  1951. // send out info packets
  1952. CL_PingServers_f();
  1953. }
  1954. void SearchLocalGamesFunc( void *self )
  1955. {
  1956. SearchLocalGames();
  1957. }
  1958. void JoinServer_MenuInit( void )
  1959. {
  1960. int i;
  1961. s_joinserver_menu.x = viddef.width * 0.50 - 120;
  1962. s_joinserver_menu.nitems = 0;
  1963. s_joinserver_address_book_action.generic.type = MTYPE_ACTION;
  1964. s_joinserver_address_book_action.generic.name = "address book";
  1965. s_joinserver_address_book_action.generic.flags = QMF_LEFT_JUSTIFY;
  1966. s_joinserver_address_book_action.generic.x = 0;
  1967. s_joinserver_address_book_action.generic.y = 0;
  1968. s_joinserver_address_book_action.generic.callback = AddressBookFunc;
  1969. s_joinserver_search_action.generic.type = MTYPE_ACTION;
  1970. s_joinserver_search_action.generic.name = "refresh server list";
  1971. s_joinserver_search_action.generic.flags = QMF_LEFT_JUSTIFY;
  1972. s_joinserver_search_action.generic.x = 0;
  1973. s_joinserver_search_action.generic.y = 10;
  1974. s_joinserver_search_action.generic.callback = SearchLocalGamesFunc;
  1975. s_joinserver_search_action.generic.statusbar = "search for servers";
  1976. s_joinserver_server_title.generic.type = MTYPE_SEPARATOR;
  1977. s_joinserver_server_title.generic.name = "connect to...";
  1978. s_joinserver_server_title.generic.x = 80;
  1979. s_joinserver_server_title.generic.y = 30;
  1980. for ( i = 0; i < MAX_LOCAL_SERVERS; i++ )
  1981. {
  1982. s_joinserver_server_actions[i].generic.type = MTYPE_ACTION;
  1983. strcpy (local_server_names[i], NO_SERVER_STRING);
  1984. s_joinserver_server_actions[i].generic.name = local_server_names[i];
  1985. s_joinserver_server_actions[i].generic.flags = QMF_LEFT_JUSTIFY;
  1986. s_joinserver_server_actions[i].generic.x = 0;
  1987. s_joinserver_server_actions[i].generic.y = 40 + i*10;
  1988. s_joinserver_server_actions[i].generic.callback = JoinServerFunc;
  1989. s_joinserver_server_actions[i].generic.statusbar = "press ENTER to connect";
  1990. }
  1991. Menu_AddItem( &s_joinserver_menu, &s_joinserver_address_book_action );
  1992. Menu_AddItem( &s_joinserver_menu, &s_joinserver_server_title );
  1993. Menu_AddItem( &s_joinserver_menu, &s_joinserver_search_action );
  1994. for ( i = 0; i < 8; i++ )
  1995. Menu_AddItem( &s_joinserver_menu, &s_joinserver_server_actions[i] );
  1996. Menu_Center( &s_joinserver_menu );
  1997. SearchLocalGames();
  1998. }
  1999. void JoinServer_MenuDraw(void)
  2000. {
  2001. M_Banner( "m_banner_join_server" );
  2002. Menu_Draw( &s_joinserver_menu );
  2003. }
  2004. const char *JoinServer_MenuKey( int key )
  2005. {
  2006. return Default_MenuKey( &s_joinserver_menu, key );
  2007. }
  2008. void M_Menu_JoinServer_f (void)
  2009. {
  2010. JoinServer_MenuInit();
  2011. M_PushMenu( JoinServer_MenuDraw, JoinServer_MenuKey );
  2012. }
  2013. /*
  2014. =============================================================================
  2015. START SERVER MENU
  2016. =============================================================================
  2017. */
  2018. static menuframework_s s_startserver_menu;
  2019. static char **mapnames;
  2020. static int nummaps;
  2021. static menuaction_s s_startserver_start_action;
  2022. static menuaction_s s_startserver_dmoptions_action;
  2023. static menufield_s s_timelimit_field;
  2024. static menufield_s s_fraglimit_field;
  2025. static menufield_s s_maxclients_field;
  2026. static menufield_s s_hostname_field;
  2027. static menulist_s s_startmap_list;
  2028. static menulist_s s_rules_box;
  2029. void DMOptionsFunc( void *self )
  2030. {
  2031. if (s_rules_box.curvalue == 1)
  2032. return;
  2033. M_Menu_DMOptions_f();
  2034. }
  2035. void RulesChangeFunc ( void *self )
  2036. {
  2037. // DM
  2038. if (s_rules_box.curvalue == 0)
  2039. {
  2040. s_maxclients_field.generic.statusbar = NULL;
  2041. s_startserver_dmoptions_action.generic.statusbar = NULL;
  2042. }
  2043. else if(s_rules_box.curvalue == 1) // coop // PGM
  2044. {
  2045. s_maxclients_field.generic.statusbar = "4 maximum for cooperative";
  2046. if (atoi(s_maxclients_field.buffer) > 4)
  2047. strcpy( s_maxclients_field.buffer, "4" );
  2048. s_startserver_dmoptions_action.generic.statusbar = "N/A for cooperative";
  2049. }
  2050. //=====
  2051. //PGM
  2052. // ROGUE GAMES
  2053. else if(Developer_searchpath(2) == 2)
  2054. {
  2055. if (s_rules_box.curvalue == 2) // tag
  2056. {
  2057. s_maxclients_field.generic.statusbar = NULL;
  2058. s_startserver_dmoptions_action.generic.statusbar = NULL;
  2059. }
  2060. /*
  2061. else if(s_rules_box.curvalue == 3) // deathball
  2062. {
  2063. s_maxclients_field.generic.statusbar = NULL;
  2064. s_startserver_dmoptions_action.generic.statusbar = NULL;
  2065. }
  2066. */
  2067. }
  2068. //PGM
  2069. //=====
  2070. }
  2071. void StartServerActionFunc( void *self )
  2072. {
  2073. char startmap[1024];
  2074. int timelimit;
  2075. int fraglimit;
  2076. int maxclients;
  2077. char *spot;
  2078. strcpy( startmap, strchr( mapnames[s_startmap_list.curvalue], '\n' ) + 1 );
  2079. maxclients = atoi( s_maxclients_field.buffer );
  2080. timelimit = atoi( s_timelimit_field.buffer );
  2081. fraglimit = atoi( s_fraglimit_field.buffer );
  2082. Cvar_SetValue( "maxclients", ClampCvar( 0, maxclients, maxclients ) );
  2083. Cvar_SetValue ("timelimit", ClampCvar( 0, timelimit, timelimit ) );
  2084. Cvar_SetValue ("fraglimit", ClampCvar( 0, fraglimit, fraglimit ) );
  2085. Cvar_Set("hostname", s_hostname_field.buffer );
  2086. // Cvar_SetValue ("deathmatch", !s_rules_box.curvalue );
  2087. // Cvar_SetValue ("coop", s_rules_box.curvalue );
  2088. //PGM
  2089. if((s_rules_box.curvalue < 2) || (Developer_searchpath(2) != 2))
  2090. {
  2091. Cvar_SetValue ("deathmatch", !s_rules_box.curvalue );
  2092. Cvar_SetValue ("coop", s_rules_box.curvalue );
  2093. Cvar_SetValue ("gamerules", 0 );
  2094. }
  2095. else
  2096. {
  2097. Cvar_SetValue ("deathmatch", 1 ); // deathmatch is always true for rogue games, right?
  2098. Cvar_SetValue ("coop", 0 ); // FIXME - this might need to depend on which game we're running
  2099. Cvar_SetValue ("gamerules", s_rules_box.curvalue );
  2100. }
  2101. //PGM
  2102. spot = NULL;
  2103. if (s_rules_box.curvalue == 1) // PGM
  2104. {
  2105. if(Q_stricmp(startmap, "bunk1") == 0)
  2106. spot = "start";
  2107. else if(Q_stricmp(startmap, "mintro") == 0)
  2108. spot = "start";
  2109. else if(Q_stricmp(startmap, "fact1") == 0)
  2110. spot = "start";
  2111. else if(Q_stricmp(startmap, "power1") == 0)
  2112. spot = "pstart";
  2113. else if(Q_stricmp(startmap, "biggun") == 0)
  2114. spot = "bstart";
  2115. else if(Q_stricmp(startmap, "hangar1") == 0)
  2116. spot = "unitstart";
  2117. else if(Q_stricmp(startmap, "city1") == 0)
  2118. spot = "unitstart";
  2119. else if(Q_stricmp(startmap, "boss1") == 0)
  2120. spot = "bosstart";
  2121. }
  2122. if (spot)
  2123. {
  2124. if (Com_ServerState())
  2125. Cbuf_AddText ("disconnect\n");
  2126. Cbuf_AddText (va("gamemap \"*%s$%s\"\n", startmap, spot));
  2127. }
  2128. else
  2129. {
  2130. Cbuf_AddText (va("map %s\n", startmap));
  2131. }
  2132. M_ForceMenuOff ();
  2133. }
  2134. void StartServer_MenuInit( void )
  2135. {
  2136. static const char *dm_coop_names[] =
  2137. {
  2138. "deathmatch",
  2139. "cooperative",
  2140. 0
  2141. };
  2142. //=======
  2143. //PGM
  2144. static const char *dm_coop_names_rogue[] =
  2145. {
  2146. "deathmatch",
  2147. "cooperative",
  2148. "tag",
  2149. // "deathball",
  2150. 0
  2151. };
  2152. //PGM
  2153. //=======
  2154. char *buffer;
  2155. char mapsname[1024];
  2156. char *s;
  2157. int length;
  2158. int i;
  2159. FILE *fp;
  2160. /*
  2161. ** load the list of map names
  2162. */
  2163. Com_sprintf( mapsname, sizeof( mapsname ), "%s/maps.lst", FS_Gamedir() );
  2164. if ( ( fp = fopen( mapsname, "rb" ) ) == 0 )
  2165. {
  2166. if ( ( length = FS_LoadFile( "maps.lst", ( void ** ) &buffer ) ) == -1 )
  2167. Com_Error( ERR_DROP, "couldn't find maps.lst\n" );
  2168. }
  2169. else
  2170. {
  2171. #ifdef _WIN32
  2172. length = filelength( fileno( fp ) );
  2173. #else
  2174. fseek(fp, 0, SEEK_END);
  2175. length = ftell(fp);
  2176. fseek(fp, 0, SEEK_SET);
  2177. #endif
  2178. buffer = malloc( length );
  2179. fread( buffer, length, 1, fp );
  2180. }
  2181. s = buffer;
  2182. i = 0;
  2183. while ( i < length )
  2184. {
  2185. if ( s[i] == '\r' )
  2186. nummaps++;
  2187. i++;
  2188. }
  2189. if ( nummaps == 0 )
  2190. Com_Error( ERR_DROP, "no maps in maps.lst\n" );
  2191. mapnames = malloc( sizeof( char * ) * ( nummaps + 1 ) );
  2192. memset( mapnames, 0, sizeof( char * ) * ( nummaps + 1 ) );
  2193. s = buffer;
  2194. for ( i = 0; i < nummaps; i++ )
  2195. {
  2196. char shortname[MAX_TOKEN_CHARS];
  2197. char longname[MAX_TOKEN_CHARS];
  2198. char scratch[200];
  2199. int j, l;
  2200. strcpy( shortname, COM_Parse( &s ) );
  2201. l = strlen(shortname);
  2202. for (j=0 ; j<l ; j++)
  2203. shortname[j] = toupper(shortname[j]);
  2204. strcpy( longname, COM_Parse( &s ) );
  2205. Com_sprintf( scratch, sizeof( scratch ), "%s\n%s", longname, shortname );
  2206. mapnames[i] = malloc( strlen( scratch ) + 1 );
  2207. strcpy( mapnames[i], scratch );
  2208. }
  2209. mapnames[nummaps] = 0;
  2210. if ( fp != 0 )
  2211. {
  2212. fp = 0;
  2213. free( buffer );
  2214. }
  2215. else
  2216. {
  2217. FS_FreeFile( buffer );
  2218. }
  2219. /*
  2220. ** initialize the menu stuff
  2221. */
  2222. s_startserver_menu.x = viddef.width * 0.50;
  2223. s_startserver_menu.nitems = 0;
  2224. s_startmap_list.generic.type = MTYPE_SPINCONTROL;
  2225. s_startmap_list.generic.x = 0;
  2226. s_startmap_list.generic.y = 0;
  2227. s_startmap_list.generic.name = "initial map";
  2228. s_startmap_list.itemnames = mapnames;
  2229. s_rules_box.generic.type = MTYPE_SPINCONTROL;
  2230. s_rules_box.generic.x = 0;
  2231. s_rules_box.generic.y = 20;
  2232. s_rules_box.generic.name = "rules";
  2233. //PGM - rogue games only available with rogue DLL.
  2234. if(Developer_searchpath(2) == 2)
  2235. s_rules_box.itemnames = dm_coop_names_rogue;
  2236. else
  2237. s_rules_box.itemnames = dm_coop_names;
  2238. //PGM
  2239. if (Cvar_VariableValue("coop"))
  2240. s_rules_box.curvalue = 1;
  2241. else
  2242. s_rules_box.curvalue = 0;
  2243. s_rules_box.generic.callback = RulesChangeFunc;
  2244. s_timelimit_field.generic.type = MTYPE_FIELD;
  2245. s_timelimit_field.generic.name = "time limit";
  2246. s_timelimit_field.generic.flags = QMF_NUMBERSONLY;
  2247. s_timelimit_field.generic.x = 0;
  2248. s_timelimit_field.generic.y = 36;
  2249. s_timelimit_field.generic.statusbar = "0 = no limit";
  2250. s_timelimit_field.length = 3;
  2251. s_timelimit_field.visible_length = 3;
  2252. strcpy( s_timelimit_field.buffer, Cvar_VariableString("timelimit") );
  2253. s_fraglimit_field.generic.type = MTYPE_FIELD;
  2254. s_fraglimit_field.generic.name = "frag limit";
  2255. s_fraglimit_field.generic.flags = QMF_NUMBERSONLY;
  2256. s_fraglimit_field.generic.x = 0;
  2257. s_fraglimit_field.generic.y = 54;
  2258. s_fraglimit_field.generic.statusbar = "0 = no limit";
  2259. s_fraglimit_field.length = 3;
  2260. s_fraglimit_field.visible_length = 3;
  2261. strcpy( s_fraglimit_field.buffer, Cvar_VariableString("fraglimit") );
  2262. /*
  2263. ** maxclients determines the maximum number of players that can join
  2264. ** the game. If maxclients is only "1" then we should default the menu
  2265. ** option to 8 players, otherwise use whatever its current value is.
  2266. ** Clamping will be done when the server is actually started.
  2267. */
  2268. s_maxclients_field.generic.type = MTYPE_FIELD;
  2269. s_maxclients_field.generic.name = "max players";
  2270. s_maxclients_field.generic.flags = QMF_NUMBERSONLY;
  2271. s_maxclients_field.generic.x = 0;
  2272. s_maxclients_field.generic.y = 72;
  2273. s_maxclients_field.generic.statusbar = NULL;
  2274. s_maxclients_field.length = 3;
  2275. s_maxclients_field.visible_length = 3;
  2276. if ( Cvar_VariableValue( "maxclients" ) == 1 )
  2277. strcpy( s_maxclients_field.buffer, "8" );
  2278. else
  2279. strcpy( s_maxclients_field.buffer, Cvar_VariableString("maxclients") );
  2280. s_hostname_field.generic.type = MTYPE_FIELD;
  2281. s_hostname_field.generic.name = "hostname";
  2282. s_hostname_field.generic.flags = 0;
  2283. s_hostname_field.generic.x = 0;
  2284. s_hostname_field.generic.y = 90;
  2285. s_hostname_field.generic.statusbar = NULL;
  2286. s_hostname_field.length = 12;
  2287. s_hostname_field.visible_length = 12;
  2288. strcpy( s_hostname_field.buffer, Cvar_VariableString("hostname") );
  2289. s_startserver_dmoptions_action.generic.type = MTYPE_ACTION;
  2290. s_startserver_dmoptions_action.generic.name = " deathmatch flags";
  2291. s_startserver_dmoptions_action.generic.flags= QMF_LEFT_JUSTIFY;
  2292. s_startserver_dmoptions_action.generic.x = 24;
  2293. s_startserver_dmoptions_action.generic.y = 108;
  2294. s_startserver_dmoptions_action.generic.statusbar = NULL;
  2295. s_startserver_dmoptions_action.generic.callback = DMOptionsFunc;
  2296. s_startserver_start_action.generic.type = MTYPE_ACTION;
  2297. s_startserver_start_action.generic.name = " begin";
  2298. s_startserver_start_action.generic.flags= QMF_LEFT_JUSTIFY;
  2299. s_startserver_start_action.generic.x = 24;
  2300. s_startserver_start_action.generic.y = 128;
  2301. s_startserver_start_action.generic.callback = StartServerActionFunc;
  2302. Menu_AddItem( &s_startserver_menu, &s_startmap_list );
  2303. Menu_AddItem( &s_startserver_menu, &s_rules_box );
  2304. Menu_AddItem( &s_startserver_menu, &s_timelimit_field );
  2305. Menu_AddItem( &s_startserver_menu, &s_fraglimit_field );
  2306. Menu_AddItem( &s_startserver_menu, &s_maxclients_field );
  2307. Menu_AddItem( &s_startserver_menu, &s_hostname_field );
  2308. Menu_AddItem( &s_startserver_menu, &s_startserver_dmoptions_action );
  2309. Menu_AddItem( &s_startserver_menu, &s_startserver_start_action );
  2310. Menu_Center( &s_startserver_menu );
  2311. // call this now to set proper inital state
  2312. RulesChangeFunc ( NULL );
  2313. }
  2314. void StartServer_MenuDraw(void)
  2315. {
  2316. Menu_Draw( &s_startserver_menu );
  2317. }
  2318. const char *StartServer_MenuKey( int key )
  2319. {
  2320. if ( key == K_ESCAPE )
  2321. {
  2322. if ( mapnames )
  2323. {
  2324. int i;
  2325. for ( i = 0; i < nummaps; i++ )
  2326. free( mapnames[i] );
  2327. free( mapnames );
  2328. }
  2329. mapnames = 0;
  2330. nummaps = 0;
  2331. }
  2332. return Default_MenuKey( &s_startserver_menu, key );
  2333. }
  2334. void M_Menu_StartServer_f (void)
  2335. {
  2336. StartServer_MenuInit();
  2337. M_PushMenu( StartServer_MenuDraw, StartServer_MenuKey );
  2338. }
  2339. /*
  2340. =============================================================================
  2341. DMOPTIONS BOOK MENU
  2342. =============================================================================
  2343. */
  2344. static char dmoptions_statusbar[128];
  2345. static menuframework_s s_dmoptions_menu;
  2346. static menulist_s s_friendlyfire_box;
  2347. static menulist_s s_falls_box;
  2348. static menulist_s s_weapons_stay_box;
  2349. static menulist_s s_instant_powerups_box;
  2350. static menulist_s s_powerups_box;
  2351. static menulist_s s_health_box;
  2352. static menulist_s s_spawn_farthest_box;
  2353. static menulist_s s_teamplay_box;
  2354. static menulist_s s_samelevel_box;
  2355. static menulist_s s_force_respawn_box;
  2356. static menulist_s s_armor_box;
  2357. static menulist_s s_allow_exit_box;
  2358. static menulist_s s_infinite_ammo_box;
  2359. static menulist_s s_fixed_fov_box;
  2360. static menulist_s s_quad_drop_box;
  2361. //ROGUE
  2362. static menulist_s s_no_mines_box;
  2363. static menulist_s s_no_nukes_box;
  2364. static menulist_s s_stack_double_box;
  2365. static menulist_s s_no_spheres_box;
  2366. //ROGUE
  2367. static void DMFlagCallback( void *self )
  2368. {
  2369. menulist_s *f = ( menulist_s * ) self;
  2370. int flags;
  2371. int bit = 0;
  2372. flags = Cvar_VariableValue( "dmflags" );
  2373. if ( f == &s_friendlyfire_box )
  2374. {
  2375. if ( f->curvalue )
  2376. flags &= ~DF_NO_FRIENDLY_FIRE;
  2377. else
  2378. flags |= DF_NO_FRIENDLY_FIRE;
  2379. goto setvalue;
  2380. }
  2381. else if ( f == &s_falls_box )
  2382. {
  2383. if ( f->curvalue )
  2384. flags &= ~DF_NO_FALLING;
  2385. else
  2386. flags |= DF_NO_FALLING;
  2387. goto setvalue;
  2388. }
  2389. else if ( f == &s_weapons_stay_box )
  2390. {
  2391. bit = DF_WEAPONS_STAY;
  2392. }
  2393. else if ( f == &s_instant_powerups_box )
  2394. {
  2395. bit = DF_INSTANT_ITEMS;
  2396. }
  2397. else if ( f == &s_allow_exit_box )
  2398. {
  2399. bit = DF_ALLOW_EXIT;
  2400. }
  2401. else if ( f == &s_powerups_box )
  2402. {
  2403. if ( f->curvalue )
  2404. flags &= ~DF_NO_ITEMS;
  2405. else
  2406. flags |= DF_NO_ITEMS;
  2407. goto setvalue;
  2408. }
  2409. else if ( f == &s_health_box )
  2410. {
  2411. if ( f->curvalue )
  2412. flags &= ~DF_NO_HEALTH;
  2413. else
  2414. flags |= DF_NO_HEALTH;
  2415. goto setvalue;
  2416. }
  2417. else if ( f == &s_spawn_farthest_box )
  2418. {
  2419. bit = DF_SPAWN_FARTHEST;
  2420. }
  2421. else if ( f == &s_teamplay_box )
  2422. {
  2423. if ( f->curvalue == 1 )
  2424. {
  2425. flags |= DF_SKINTEAMS;
  2426. flags &= ~DF_MODELTEAMS;
  2427. }
  2428. else if ( f->curvalue == 2 )
  2429. {
  2430. flags |= DF_MODELTEAMS;
  2431. flags &= ~DF_SKINTEAMS;
  2432. }
  2433. else
  2434. {
  2435. flags &= ~( DF_MODELTEAMS | DF_SKINTEAMS );
  2436. }
  2437. goto setvalue;
  2438. }
  2439. else if ( f == &s_samelevel_box )
  2440. {
  2441. bit = DF_SAME_LEVEL;
  2442. }
  2443. else if ( f == &s_force_respawn_box )
  2444. {
  2445. bit = DF_FORCE_RESPAWN;
  2446. }
  2447. else if ( f == &s_armor_box )
  2448. {
  2449. if ( f->curvalue )
  2450. flags &= ~DF_NO_ARMOR;
  2451. else
  2452. flags |= DF_NO_ARMOR;
  2453. goto setvalue;
  2454. }
  2455. else if ( f == &s_infinite_ammo_box )
  2456. {
  2457. bit = DF_INFINITE_AMMO;
  2458. }
  2459. else if ( f == &s_fixed_fov_box )
  2460. {
  2461. bit = DF_FIXED_FOV;
  2462. }
  2463. else if ( f == &s_quad_drop_box )
  2464. {
  2465. bit = DF_QUAD_DROP;
  2466. }
  2467. //=======
  2468. //ROGUE
  2469. else if (Developer_searchpath(2) == 2)
  2470. {
  2471. if ( f == &s_no_mines_box)
  2472. {
  2473. bit = DF_NO_MINES;
  2474. }
  2475. else if ( f == &s_no_nukes_box)
  2476. {
  2477. bit = DF_NO_NUKES;
  2478. }
  2479. else if ( f == &s_stack_double_box)
  2480. {
  2481. bit = DF_NO_STACK_DOUBLE;
  2482. }
  2483. else if ( f == &s_no_spheres_box)
  2484. {
  2485. bit = DF_NO_SPHERES;
  2486. }
  2487. }
  2488. //ROGUE
  2489. //=======
  2490. if ( f )
  2491. {
  2492. if ( f->curvalue == 0 )
  2493. flags &= ~bit;
  2494. else
  2495. flags |= bit;
  2496. }
  2497. setvalue:
  2498. Cvar_SetValue ("dmflags", flags);
  2499. Com_sprintf( dmoptions_statusbar, sizeof( dmoptions_statusbar ), "dmflags = %d", flags );
  2500. }
  2501. void DMOptions_MenuInit( void )
  2502. {
  2503. static const char *yes_no_names[] =
  2504. {
  2505. "no", "yes", 0
  2506. };
  2507. static const char *teamplay_names[] =
  2508. {
  2509. "disabled", "by skin", "by model", 0
  2510. };
  2511. int dmflags = Cvar_VariableValue( "dmflags" );
  2512. int y = 0;
  2513. s_dmoptions_menu.x = viddef.width * 0.50;
  2514. s_dmoptions_menu.nitems = 0;
  2515. s_falls_box.generic.type = MTYPE_SPINCONTROL;
  2516. s_falls_box.generic.x = 0;
  2517. s_falls_box.generic.y = y;
  2518. s_falls_box.generic.name = "falling damage";
  2519. s_falls_box.generic.callback = DMFlagCallback;
  2520. s_falls_box.itemnames = yes_no_names;
  2521. s_falls_box.curvalue = ( dmflags & DF_NO_FALLING ) == 0;
  2522. s_weapons_stay_box.generic.type = MTYPE_SPINCONTROL;
  2523. s_weapons_stay_box.generic.x = 0;
  2524. s_weapons_stay_box.generic.y = y += 10;
  2525. s_weapons_stay_box.generic.name = "weapons stay";
  2526. s_weapons_stay_box.generic.callback = DMFlagCallback;
  2527. s_weapons_stay_box.itemnames = yes_no_names;
  2528. s_weapons_stay_box.curvalue = ( dmflags & DF_WEAPONS_STAY ) != 0;
  2529. s_instant_powerups_box.generic.type = MTYPE_SPINCONTROL;
  2530. s_instant_powerups_box.generic.x = 0;
  2531. s_instant_powerups_box.generic.y = y += 10;
  2532. s_instant_powerups_box.generic.name = "instant powerups";
  2533. s_instant_powerups_box.generic.callback = DMFlagCallback;
  2534. s_instant_powerups_box.itemnames = yes_no_names;
  2535. s_instant_powerups_box.curvalue = ( dmflags & DF_INSTANT_ITEMS ) != 0;
  2536. s_powerups_box.generic.type = MTYPE_SPINCONTROL;
  2537. s_powerups_box.generic.x = 0;
  2538. s_powerups_box.generic.y = y += 10;
  2539. s_powerups_box.generic.name = "allow powerups";
  2540. s_powerups_box.generic.callback = DMFlagCallback;
  2541. s_powerups_box.itemnames = yes_no_names;
  2542. s_powerups_box.curvalue = ( dmflags & DF_NO_ITEMS ) == 0;
  2543. s_health_box.generic.type = MTYPE_SPINCONTROL;
  2544. s_health_box.generic.x = 0;
  2545. s_health_box.generic.y = y += 10;
  2546. s_health_box.generic.callback = DMFlagCallback;
  2547. s_health_box.generic.name = "allow health";
  2548. s_health_box.itemnames = yes_no_names;
  2549. s_health_box.curvalue = ( dmflags & DF_NO_HEALTH ) == 0;
  2550. s_armor_box.generic.type = MTYPE_SPINCONTROL;
  2551. s_armor_box.generic.x = 0;
  2552. s_armor_box.generic.y = y += 10;
  2553. s_armor_box.generic.name = "allow armor";
  2554. s_armor_box.generic.callback = DMFlagCallback;
  2555. s_armor_box.itemnames = yes_no_names;
  2556. s_armor_box.curvalue = ( dmflags & DF_NO_ARMOR ) == 0;
  2557. s_spawn_farthest_box.generic.type = MTYPE_SPINCONTROL;
  2558. s_spawn_farthest_box.generic.x = 0;
  2559. s_spawn_farthest_box.generic.y = y += 10;
  2560. s_spawn_farthest_box.generic.name = "spawn farthest";
  2561. s_spawn_farthest_box.generic.callback = DMFlagCallback;
  2562. s_spawn_farthest_box.itemnames = yes_no_names;
  2563. s_spawn_farthest_box.curvalue = ( dmflags & DF_SPAWN_FARTHEST ) != 0;
  2564. s_samelevel_box.generic.type = MTYPE_SPINCONTROL;
  2565. s_samelevel_box.generic.x = 0;
  2566. s_samelevel_box.generic.y = y += 10;
  2567. s_samelevel_box.generic.name = "same map";
  2568. s_samelevel_box.generic.callback = DMFlagCallback;
  2569. s_samelevel_box.itemnames = yes_no_names;
  2570. s_samelevel_box.curvalue = ( dmflags & DF_SAME_LEVEL ) != 0;
  2571. s_force_respawn_box.generic.type = MTYPE_SPINCONTROL;
  2572. s_force_respawn_box.generic.x = 0;
  2573. s_force_respawn_box.generic.y = y += 10;
  2574. s_force_respawn_box.generic.name = "force respawn";
  2575. s_force_respawn_box.generic.callback = DMFlagCallback;
  2576. s_force_respawn_box.itemnames = yes_no_names;
  2577. s_force_respawn_box.curvalue = ( dmflags & DF_FORCE_RESPAWN ) != 0;
  2578. s_teamplay_box.generic.type = MTYPE_SPINCONTROL;
  2579. s_teamplay_box.generic.x = 0;
  2580. s_teamplay_box.generic.y = y += 10;
  2581. s_teamplay_box.generic.name = "teamplay";
  2582. s_teamplay_box.generic.callback = DMFlagCallback;
  2583. s_teamplay_box.itemnames = teamplay_names;
  2584. s_allow_exit_box.generic.type = MTYPE_SPINCONTROL;
  2585. s_allow_exit_box.generic.x = 0;
  2586. s_allow_exit_box.generic.y = y += 10;
  2587. s_allow_exit_box.generic.name = "allow exit";
  2588. s_allow_exit_box.generic.callback = DMFlagCallback;
  2589. s_allow_exit_box.itemnames = yes_no_names;
  2590. s_allow_exit_box.curvalue = ( dmflags & DF_ALLOW_EXIT ) != 0;
  2591. s_infinite_ammo_box.generic.type = MTYPE_SPINCONTROL;
  2592. s_infinite_ammo_box.generic.x = 0;
  2593. s_infinite_ammo_box.generic.y = y += 10;
  2594. s_infinite_ammo_box.generic.name = "infinite ammo";
  2595. s_infinite_ammo_box.generic.callback = DMFlagCallback;
  2596. s_infinite_ammo_box.itemnames = yes_no_names;
  2597. s_infinite_ammo_box.curvalue = ( dmflags & DF_INFINITE_AMMO ) != 0;
  2598. s_fixed_fov_box.generic.type = MTYPE_SPINCONTROL;
  2599. s_fixed_fov_box.generic.x = 0;
  2600. s_fixed_fov_box.generic.y = y += 10;
  2601. s_fixed_fov_box.generic.name = "fixed FOV";
  2602. s_fixed_fov_box.generic.callback = DMFlagCallback;
  2603. s_fixed_fov_box.itemnames = yes_no_names;
  2604. s_fixed_fov_box.curvalue = ( dmflags & DF_FIXED_FOV ) != 0;
  2605. s_quad_drop_box.generic.type = MTYPE_SPINCONTROL;
  2606. s_quad_drop_box.generic.x = 0;
  2607. s_quad_drop_box.generic.y = y += 10;
  2608. s_quad_drop_box.generic.name = "quad drop";
  2609. s_quad_drop_box.generic.callback = DMFlagCallback;
  2610. s_quad_drop_box.itemnames = yes_no_names;
  2611. s_quad_drop_box.curvalue = ( dmflags & DF_QUAD_DROP ) != 0;
  2612. s_friendlyfire_box.generic.type = MTYPE_SPINCONTROL;
  2613. s_friendlyfire_box.generic.x = 0;
  2614. s_friendlyfire_box.generic.y = y += 10;
  2615. s_friendlyfire_box.generic.name = "friendly fire";
  2616. s_friendlyfire_box.generic.callback = DMFlagCallback;
  2617. s_friendlyfire_box.itemnames = yes_no_names;
  2618. s_friendlyfire_box.curvalue = ( dmflags & DF_NO_FRIENDLY_FIRE ) == 0;
  2619. //============
  2620. //ROGUE
  2621. if(Developer_searchpath(2) == 2)
  2622. {
  2623. s_no_mines_box.generic.type = MTYPE_SPINCONTROL;
  2624. s_no_mines_box.generic.x = 0;
  2625. s_no_mines_box.generic.y = y += 10;
  2626. s_no_mines_box.generic.name = "remove mines";
  2627. s_no_mines_box.generic.callback = DMFlagCallback;
  2628. s_no_mines_box.itemnames = yes_no_names;
  2629. s_no_mines_box.curvalue = ( dmflags & DF_NO_MINES ) != 0;
  2630. s_no_nukes_box.generic.type = MTYPE_SPINCONTROL;
  2631. s_no_nukes_box.generic.x = 0;
  2632. s_no_nukes_box.generic.y = y += 10;
  2633. s_no_nukes_box.generic.name = "remove nukes";
  2634. s_no_nukes_box.generic.callback = DMFlagCallback;
  2635. s_no_nukes_box.itemnames = yes_no_names;
  2636. s_no_nukes_box.curvalue = ( dmflags & DF_NO_NUKES ) != 0;
  2637. s_stack_double_box.generic.type = MTYPE_SPINCONTROL;
  2638. s_stack_double_box.generic.x = 0;
  2639. s_stack_double_box.generic.y = y += 10;
  2640. s_stack_double_box.generic.name = "2x/4x stacking off";
  2641. s_stack_double_box.generic.callback = DMFlagCallback;
  2642. s_stack_double_box.itemnames = yes_no_names;
  2643. s_stack_double_box.curvalue = ( dmflags & DF_NO_STACK_DOUBLE ) != 0;
  2644. s_no_spheres_box.generic.type = MTYPE_SPINCONTROL;
  2645. s_no_spheres_box.generic.x = 0;
  2646. s_no_spheres_box.generic.y = y += 10;
  2647. s_no_spheres_box.generic.name = "remove spheres";
  2648. s_no_spheres_box.generic.callback = DMFlagCallback;
  2649. s_no_spheres_box.itemnames = yes_no_names;
  2650. s_no_spheres_box.curvalue = ( dmflags & DF_NO_SPHERES ) != 0;
  2651. }
  2652. //ROGUE
  2653. //============
  2654. Menu_AddItem( &s_dmoptions_menu, &s_falls_box );
  2655. Menu_AddItem( &s_dmoptions_menu, &s_weapons_stay_box );
  2656. Menu_AddItem( &s_dmoptions_menu, &s_instant_powerups_box );
  2657. Menu_AddItem( &s_dmoptions_menu, &s_powerups_box );
  2658. Menu_AddItem( &s_dmoptions_menu, &s_health_box );
  2659. Menu_AddItem( &s_dmoptions_menu, &s_armor_box );
  2660. Menu_AddItem( &s_dmoptions_menu, &s_spawn_farthest_box );
  2661. Menu_AddItem( &s_dmoptions_menu, &s_samelevel_box );
  2662. Menu_AddItem( &s_dmoptions_menu, &s_force_respawn_box );
  2663. Menu_AddItem( &s_dmoptions_menu, &s_teamplay_box );
  2664. Menu_AddItem( &s_dmoptions_menu, &s_allow_exit_box );
  2665. Menu_AddItem( &s_dmoptions_menu, &s_infinite_ammo_box );
  2666. Menu_AddItem( &s_dmoptions_menu, &s_fixed_fov_box );
  2667. Menu_AddItem( &s_dmoptions_menu, &s_quad_drop_box );
  2668. Menu_AddItem( &s_dmoptions_menu, &s_friendlyfire_box );
  2669. //=======
  2670. //ROGUE
  2671. if(Developer_searchpath(2) == 2)
  2672. {
  2673. Menu_AddItem( &s_dmoptions_menu, &s_no_mines_box );
  2674. Menu_AddItem( &s_dmoptions_menu, &s_no_nukes_box );
  2675. Menu_AddItem( &s_dmoptions_menu, &s_stack_double_box );
  2676. Menu_AddItem( &s_dmoptions_menu, &s_no_spheres_box );
  2677. }
  2678. //ROGUE
  2679. //=======
  2680. Menu_Center( &s_dmoptions_menu );
  2681. // set the original dmflags statusbar
  2682. DMFlagCallback( 0 );
  2683. Menu_SetStatusBar( &s_dmoptions_menu, dmoptions_statusbar );
  2684. }
  2685. void DMOptions_MenuDraw(void)
  2686. {
  2687. Menu_Draw( &s_dmoptions_menu );
  2688. }
  2689. const char *DMOptions_MenuKey( int key )
  2690. {
  2691. return Default_MenuKey( &s_dmoptions_menu, key );
  2692. }
  2693. void M_Menu_DMOptions_f (void)
  2694. {
  2695. DMOptions_MenuInit();
  2696. M_PushMenu( DMOptions_MenuDraw, DMOptions_MenuKey );
  2697. }
  2698. /*
  2699. =============================================================================
  2700. DOWNLOADOPTIONS BOOK MENU
  2701. =============================================================================
  2702. */
  2703. static menuframework_s s_downloadoptions_menu;
  2704. static menuseparator_s s_download_title;
  2705. static menulist_s s_allow_download_box;
  2706. static menulist_s s_allow_download_maps_box;
  2707. static menulist_s s_allow_download_models_box;
  2708. static menulist_s s_allow_download_players_box;
  2709. static menulist_s s_allow_download_sounds_box;
  2710. static void DownloadCallback( void *self )
  2711. {
  2712. menulist_s *f = ( menulist_s * ) self;
  2713. if (f == &s_allow_download_box)
  2714. {
  2715. Cvar_SetValue("allow_download", f->curvalue);
  2716. }
  2717. else if (f == &s_allow_download_maps_box)
  2718. {
  2719. Cvar_SetValue("allow_download_maps", f->curvalue);
  2720. }
  2721. else if (f == &s_allow_download_models_box)
  2722. {
  2723. Cvar_SetValue("allow_download_models", f->curvalue);
  2724. }
  2725. else if (f == &s_allow_download_players_box)
  2726. {
  2727. Cvar_SetValue("allow_download_players", f->curvalue);
  2728. }
  2729. else if (f == &s_allow_download_sounds_box)
  2730. {
  2731. Cvar_SetValue("allow_download_sounds", f->curvalue);
  2732. }
  2733. }
  2734. void DownloadOptions_MenuInit( void )
  2735. {
  2736. static const char *yes_no_names[] =
  2737. {
  2738. "no", "yes", 0
  2739. };
  2740. int y = 0;
  2741. s_downloadoptions_menu.x = viddef.width * 0.50;
  2742. s_downloadoptions_menu.nitems = 0;
  2743. s_download_title.generic.type = MTYPE_SEPARATOR;
  2744. s_download_title.generic.name = "Download Options";
  2745. s_download_title.generic.x = 48;
  2746. s_download_title.generic.y = y;
  2747. s_allow_download_box.generic.type = MTYPE_SPINCONTROL;
  2748. s_allow_download_box.generic.x = 0;
  2749. s_allow_download_box.generic.y = y += 20;
  2750. s_allow_download_box.generic.name = "allow downloading";
  2751. s_allow_download_box.generic.callback = DownloadCallback;
  2752. s_allow_download_box.itemnames = yes_no_names;
  2753. s_allow_download_box.curvalue = (Cvar_VariableValue("allow_download") != 0);
  2754. s_allow_download_maps_box.generic.type = MTYPE_SPINCONTROL;
  2755. s_allow_download_maps_box.generic.x = 0;
  2756. s_allow_download_maps_box.generic.y = y += 20;
  2757. s_allow_download_maps_box.generic.name = "maps";
  2758. s_allow_download_maps_box.generic.callback = DownloadCallback;
  2759. s_allow_download_maps_box.itemnames = yes_no_names;
  2760. s_allow_download_maps_box.curvalue = (Cvar_VariableValue("allow_download_maps") != 0);
  2761. s_allow_download_players_box.generic.type = MTYPE_SPINCONTROL;
  2762. s_allow_download_players_box.generic.x = 0;
  2763. s_allow_download_players_box.generic.y = y += 10;
  2764. s_allow_download_players_box.generic.name = "player models/skins";
  2765. s_allow_download_players_box.generic.callback = DownloadCallback;
  2766. s_allow_download_players_box.itemnames = yes_no_names;
  2767. s_allow_download_players_box.curvalue = (Cvar_VariableValue("allow_download_players") != 0);
  2768. s_allow_download_models_box.generic.type = MTYPE_SPINCONTROL;
  2769. s_allow_download_models_box.generic.x = 0;
  2770. s_allow_download_models_box.generic.y = y += 10;
  2771. s_allow_download_models_box.generic.name = "models";
  2772. s_allow_download_models_box.generic.callback = DownloadCallback;
  2773. s_allow_download_models_box.itemnames = yes_no_names;
  2774. s_allow_download_models_box.curvalue = (Cvar_VariableValue("allow_download_models") != 0);
  2775. s_allow_download_sounds_box.generic.type = MTYPE_SPINCONTROL;
  2776. s_allow_download_sounds_box.generic.x = 0;
  2777. s_allow_download_sounds_box.generic.y = y += 10;
  2778. s_allow_download_sounds_box.generic.name = "sounds";
  2779. s_allow_download_sounds_box.generic.callback = DownloadCallback;
  2780. s_allow_download_sounds_box.itemnames = yes_no_names;
  2781. s_allow_download_sounds_box.curvalue = (Cvar_VariableValue("allow_download_sounds") != 0);
  2782. Menu_AddItem( &s_downloadoptions_menu, &s_download_title );
  2783. Menu_AddItem( &s_downloadoptions_menu, &s_allow_download_box );
  2784. Menu_AddItem( &s_downloadoptions_menu, &s_allow_download_maps_box );
  2785. Menu_AddItem( &s_downloadoptions_menu, &s_allow_download_players_box );
  2786. Menu_AddItem( &s_downloadoptions_menu, &s_allow_download_models_box );
  2787. Menu_AddItem( &s_downloadoptions_menu, &s_allow_download_sounds_box );
  2788. Menu_Center( &s_downloadoptions_menu );
  2789. // skip over title
  2790. if (s_downloadoptions_menu.cursor == 0)
  2791. s_downloadoptions_menu.cursor = 1;
  2792. }
  2793. void DownloadOptions_MenuDraw(void)
  2794. {
  2795. Menu_Draw( &s_downloadoptions_menu );
  2796. }
  2797. const char *DownloadOptions_MenuKey( int key )
  2798. {
  2799. return Default_MenuKey( &s_downloadoptions_menu, key );
  2800. }
  2801. void M_Menu_DownloadOptions_f (void)
  2802. {
  2803. DownloadOptions_MenuInit();
  2804. M_PushMenu( DownloadOptions_MenuDraw, DownloadOptions_MenuKey );
  2805. }
  2806. /*
  2807. =============================================================================
  2808. ADDRESS BOOK MENU
  2809. =============================================================================
  2810. */
  2811. #define NUM_ADDRESSBOOK_ENTRIES 9
  2812. static menuframework_s s_addressbook_menu;
  2813. static menufield_s s_addressbook_fields[NUM_ADDRESSBOOK_ENTRIES];
  2814. void AddressBook_MenuInit( void )
  2815. {
  2816. int i;
  2817. s_addressbook_menu.x = viddef.width / 2 - 142;
  2818. s_addressbook_menu.y = viddef.height / 2 - 58;
  2819. s_addressbook_menu.nitems = 0;
  2820. for ( i = 0; i < NUM_ADDRESSBOOK_ENTRIES; i++ )
  2821. {
  2822. cvar_t *adr;
  2823. char buffer[20];
  2824. Com_sprintf( buffer, sizeof( buffer ), "adr%d", i );
  2825. adr = Cvar_Get( buffer, "", CVAR_ARCHIVE );
  2826. s_addressbook_fields[i].generic.type = MTYPE_FIELD;
  2827. s_addressbook_fields[i].generic.name = 0;
  2828. s_addressbook_fields[i].generic.callback = 0;
  2829. s_addressbook_fields[i].generic.x = 0;
  2830. s_addressbook_fields[i].generic.y = i * 18 + 0;
  2831. s_addressbook_fields[i].generic.localdata[0] = i;
  2832. s_addressbook_fields[i].cursor = 0;
  2833. s_addressbook_fields[i].length = 60;
  2834. s_addressbook_fields[i].visible_length = 30;
  2835. strcpy( s_addressbook_fields[i].buffer, adr->string );
  2836. Menu_AddItem( &s_addressbook_menu, &s_addressbook_fields[i] );
  2837. }
  2838. }
  2839. const char *AddressBook_MenuKey( int key )
  2840. {
  2841. if ( key == K_ESCAPE )
  2842. {
  2843. int index;
  2844. char buffer[20];
  2845. for ( index = 0; index < NUM_ADDRESSBOOK_ENTRIES; index++ )
  2846. {
  2847. Com_sprintf( buffer, sizeof( buffer ), "adr%d", index );
  2848. Cvar_Set( buffer, s_addressbook_fields[index].buffer );
  2849. }
  2850. }
  2851. return Default_MenuKey( &s_addressbook_menu, key );
  2852. }
  2853. void AddressBook_MenuDraw(void)
  2854. {
  2855. M_Banner( "m_banner_addressbook" );
  2856. Menu_Draw( &s_addressbook_menu );
  2857. }
  2858. void M_Menu_AddressBook_f(void)
  2859. {
  2860. AddressBook_MenuInit();
  2861. M_PushMenu( AddressBook_MenuDraw, AddressBook_MenuKey );
  2862. }
  2863. /*
  2864. =============================================================================
  2865. PLAYER CONFIG MENU
  2866. =============================================================================
  2867. */
  2868. static menuframework_s s_player_config_menu;
  2869. static menufield_s s_player_name_field;
  2870. static menulist_s s_player_model_box;
  2871. static menulist_s s_player_skin_box;
  2872. static menulist_s s_player_handedness_box;
  2873. static menulist_s s_player_rate_box;
  2874. static menuseparator_s s_player_skin_title;
  2875. static menuseparator_s s_player_model_title;
  2876. static menuseparator_s s_player_hand_title;
  2877. static menuseparator_s s_player_rate_title;
  2878. static menuaction_s s_player_download_action;
  2879. #define MAX_DISPLAYNAME 16
  2880. #define MAX_PLAYERMODELS 1024
  2881. typedef struct
  2882. {
  2883. int nskins;
  2884. char **skindisplaynames;
  2885. char displayname[MAX_DISPLAYNAME];
  2886. char directory[MAX_QPATH];
  2887. } playermodelinfo_s;
  2888. static playermodelinfo_s s_pmi[MAX_PLAYERMODELS];
  2889. static char *s_pmnames[MAX_PLAYERMODELS];
  2890. static int s_numplayermodels;
  2891. static int rate_tbl[] = { 2500, 3200, 5000, 10000, 25000, 0 };
  2892. static const char *rate_names[] = { "28.8 Modem", "33.6 Modem", "Single ISDN",
  2893. "Dual ISDN/Cable", "T1/LAN", "User defined", 0 };
  2894. void DownloadOptionsFunc( void *self )
  2895. {
  2896. M_Menu_DownloadOptions_f();
  2897. }
  2898. static void HandednessCallback( void *unused )
  2899. {
  2900. Cvar_SetValue( "hand", s_player_handedness_box.curvalue );
  2901. }
  2902. static void RateCallback( void *unused )
  2903. {
  2904. if (s_player_rate_box.curvalue != sizeof(rate_tbl) / sizeof(*rate_tbl) - 1)
  2905. Cvar_SetValue( "rate", rate_tbl[s_player_rate_box.curvalue] );
  2906. }
  2907. static void ModelCallback( void *unused )
  2908. {
  2909. s_player_skin_box.itemnames = s_pmi[s_player_model_box.curvalue].skindisplaynames;
  2910. s_player_skin_box.curvalue = 0;
  2911. }
  2912. static void FreeFileList( char **list, int n )
  2913. {
  2914. int i;
  2915. for ( i = 0; i < n; i++ )
  2916. {
  2917. if ( list[i] )
  2918. {
  2919. free( list[i] );
  2920. list[i] = 0;
  2921. }
  2922. }
  2923. free( list );
  2924. }
  2925. static qboolean IconOfSkinExists( char *skin, char **pcxfiles, int npcxfiles )
  2926. {
  2927. int i;
  2928. char scratch[1024];
  2929. strcpy( scratch, skin );
  2930. *strrchr( scratch, '.' ) = 0;
  2931. strcat( scratch, "_i.pcx" );
  2932. for ( i = 0; i < npcxfiles; i++ )
  2933. {
  2934. if ( strcmp( pcxfiles[i], scratch ) == 0 )
  2935. return true;
  2936. }
  2937. return false;
  2938. }
  2939. static qboolean PlayerConfig_ScanDirectories( void )
  2940. {
  2941. char findname[1024];
  2942. char scratch[1024];
  2943. int ndirs = 0, npms = 0;
  2944. char **dirnames;
  2945. char *path = NULL;
  2946. int i;
  2947. extern char **FS_ListFiles( char *, int *, unsigned, unsigned );
  2948. s_numplayermodels = 0;
  2949. /*
  2950. ** get a list of directories
  2951. */
  2952. do
  2953. {
  2954. path = FS_NextPath( path );
  2955. Com_sprintf( findname, sizeof(findname), "%s/players/*.*", path );
  2956. if ( ( dirnames = FS_ListFiles( findname, &ndirs, SFF_SUBDIR, 0 ) ) != 0 )
  2957. break;
  2958. } while ( path );
  2959. if ( !dirnames )
  2960. return false;
  2961. /*
  2962. ** go through the subdirectories
  2963. */
  2964. npms = ndirs;
  2965. if ( npms > MAX_PLAYERMODELS )
  2966. npms = MAX_PLAYERMODELS;
  2967. for ( i = 0; i < npms; i++ )
  2968. {
  2969. int k, s;
  2970. char *a, *b, *c;
  2971. char **pcxnames;
  2972. char **skinnames;
  2973. int npcxfiles;
  2974. int nskins = 0;
  2975. if ( dirnames[i] == 0 )
  2976. continue;
  2977. // verify the existence of tris.md2
  2978. strcpy( scratch, dirnames[i] );
  2979. strcat( scratch, "/tris.md2" );
  2980. if ( !Sys_FindFirst( scratch, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM ) )
  2981. {
  2982. free( dirnames[i] );
  2983. dirnames[i] = 0;
  2984. Sys_FindClose();
  2985. continue;
  2986. }
  2987. Sys_FindClose();
  2988. // verify the existence of at least one pcx skin
  2989. strcpy( scratch, dirnames[i] );
  2990. strcat( scratch, "/*.pcx" );
  2991. pcxnames = FS_ListFiles( scratch, &npcxfiles, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM );
  2992. if ( !pcxnames )
  2993. {
  2994. free( dirnames[i] );
  2995. dirnames[i] = 0;
  2996. continue;
  2997. }
  2998. // count valid skins, which consist of a skin with a matching "_i" icon
  2999. for ( k = 0; k < npcxfiles-1; k++ )
  3000. {
  3001. if ( !strstr( pcxnames[k], "_i.pcx" ) )
  3002. {
  3003. if ( IconOfSkinExists( pcxnames[k], pcxnames, npcxfiles - 1 ) )
  3004. {
  3005. nskins++;
  3006. }
  3007. }
  3008. }
  3009. if ( !nskins )
  3010. continue;
  3011. skinnames = malloc( sizeof( char * ) * ( nskins + 1 ) );
  3012. memset( skinnames, 0, sizeof( char * ) * ( nskins + 1 ) );
  3013. // copy the valid skins
  3014. for ( s = 0, k = 0; k < npcxfiles-1; k++ )
  3015. {
  3016. char *a, *b, *c;
  3017. if ( !strstr( pcxnames[k], "_i.pcx" ) )
  3018. {
  3019. if ( IconOfSkinExists( pcxnames[k], pcxnames, npcxfiles - 1 ) )
  3020. {
  3021. a = strrchr( pcxnames[k], '/' );
  3022. b = strrchr( pcxnames[k], '\\' );
  3023. if ( a > b )
  3024. c = a;
  3025. else
  3026. c = b;
  3027. strcpy( scratch, c + 1 );
  3028. if ( strrchr( scratch, '.' ) )
  3029. *strrchr( scratch, '.' ) = 0;
  3030. skinnames[s] = strdup( scratch );
  3031. s++;
  3032. }
  3033. }
  3034. }
  3035. // at this point we have a valid player model
  3036. s_pmi[s_numplayermodels].nskins = nskins;
  3037. s_pmi[s_numplayermodels].skindisplaynames = skinnames;
  3038. // make short name for the model
  3039. a = strrchr( dirnames[i], '/' );
  3040. b = strrchr( dirnames[i], '\\' );
  3041. if ( a > b )
  3042. c = a;
  3043. else
  3044. c = b;
  3045. strncpy( s_pmi[s_numplayermodels].displayname, c + 1, MAX_DISPLAYNAME-1 );
  3046. strcpy( s_pmi[s_numplayermodels].directory, c + 1 );
  3047. FreeFileList( pcxnames, npcxfiles );
  3048. s_numplayermodels++;
  3049. }
  3050. if ( dirnames )
  3051. FreeFileList( dirnames, ndirs );
  3052. }
  3053. static int pmicmpfnc( const void *_a, const void *_b )
  3054. {
  3055. const playermodelinfo_s *a = ( const playermodelinfo_s * ) _a;
  3056. const playermodelinfo_s *b = ( const playermodelinfo_s * ) _b;
  3057. /*
  3058. ** sort by male, female, then alphabetical
  3059. */
  3060. if ( strcmp( a->directory, "male" ) == 0 )
  3061. return -1;
  3062. else if ( strcmp( b->directory, "male" ) == 0 )
  3063. return 1;
  3064. if ( strcmp( a->directory, "female" ) == 0 )
  3065. return -1;
  3066. else if ( strcmp( b->directory, "female" ) == 0 )
  3067. return 1;
  3068. return strcmp( a->directory, b->directory );
  3069. }
  3070. qboolean PlayerConfig_MenuInit( void )
  3071. {
  3072. extern cvar_t *name;
  3073. extern cvar_t *team;
  3074. extern cvar_t *skin;
  3075. char currentdirectory[1024];
  3076. char currentskin[1024];
  3077. int i = 0;
  3078. int currentdirectoryindex = 0;
  3079. int currentskinindex = 0;
  3080. cvar_t *hand = Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
  3081. static const char *handedness[] = { "right", "left", "center", 0 };
  3082. PlayerConfig_ScanDirectories();
  3083. if (s_numplayermodels == 0)
  3084. return false;
  3085. if ( hand->value < 0 || hand->value > 2 )
  3086. Cvar_SetValue( "hand", 0 );
  3087. strcpy( currentdirectory, skin->string );
  3088. if ( strchr( currentdirectory, '/' ) )
  3089. {
  3090. strcpy( currentskin, strchr( currentdirectory, '/' ) + 1 );
  3091. *strchr( currentdirectory, '/' ) = 0;
  3092. }
  3093. else if ( strchr( currentdirectory, '\\' ) )
  3094. {
  3095. strcpy( currentskin, strchr( currentdirectory, '\\' ) + 1 );
  3096. *strchr( currentdirectory, '\\' ) = 0;
  3097. }
  3098. else
  3099. {
  3100. strcpy( currentdirectory, "male" );
  3101. strcpy( currentskin, "grunt" );
  3102. }
  3103. qsort( s_pmi, s_numplayermodels, sizeof( s_pmi[0] ), pmicmpfnc );
  3104. memset( s_pmnames, 0, sizeof( s_pmnames ) );
  3105. for ( i = 0; i < s_numplayermodels; i++ )
  3106. {
  3107. s_pmnames[i] = s_pmi[i].displayname;
  3108. if ( Q_stricmp( s_pmi[i].directory, currentdirectory ) == 0 )
  3109. {
  3110. int j;
  3111. currentdirectoryindex = i;
  3112. for ( j = 0; j < s_pmi[i].nskins; j++ )
  3113. {
  3114. if ( Q_stricmp( s_pmi[i].skindisplaynames[j], currentskin ) == 0 )
  3115. {
  3116. currentskinindex = j;
  3117. break;
  3118. }
  3119. }
  3120. }
  3121. }
  3122. s_player_config_menu.x = viddef.width / 2 - 95;
  3123. s_player_config_menu.y = viddef.height / 2 - 97;
  3124. s_player_config_menu.nitems = 0;
  3125. s_player_name_field.generic.type = MTYPE_FIELD;
  3126. s_player_name_field.generic.name = "name";
  3127. s_player_name_field.generic.callback = 0;
  3128. s_player_name_field.generic.x = 0;
  3129. s_player_name_field.generic.y = 0;
  3130. s_player_name_field.length = 20;
  3131. s_player_name_field.visible_length = 20;
  3132. strcpy( s_player_name_field.buffer, name->string );
  3133. s_player_name_field.cursor = strlen( name->string );
  3134. s_player_model_title.generic.type = MTYPE_SEPARATOR;
  3135. s_player_model_title.generic.name = "model";
  3136. s_player_model_title.generic.x = -8;
  3137. s_player_model_title.generic.y = 60;
  3138. s_player_model_box.generic.type = MTYPE_SPINCONTROL;
  3139. s_player_model_box.generic.x = -56;
  3140. s_player_model_box.generic.y = 70;
  3141. s_player_model_box.generic.callback = ModelCallback;
  3142. s_player_model_box.generic.cursor_offset = -48;
  3143. s_player_model_box.curvalue = currentdirectoryindex;
  3144. s_player_model_box.itemnames = s_pmnames;
  3145. s_player_skin_title.generic.type = MTYPE_SEPARATOR;
  3146. s_player_skin_title.generic.name = "skin";
  3147. s_player_skin_title.generic.x = -16;
  3148. s_player_skin_title.generic.y = 84;
  3149. s_player_skin_box.generic.type = MTYPE_SPINCONTROL;
  3150. s_player_skin_box.generic.x = -56;
  3151. s_player_skin_box.generic.y = 94;
  3152. s_player_skin_box.generic.name = 0;
  3153. s_player_skin_box.generic.callback = 0;
  3154. s_player_skin_box.generic.cursor_offset = -48;
  3155. s_player_skin_box.curvalue = currentskinindex;
  3156. s_player_skin_box.itemnames = s_pmi[currentdirectoryindex].skindisplaynames;
  3157. s_player_hand_title.generic.type = MTYPE_SEPARATOR;
  3158. s_player_hand_title.generic.name = "handedness";
  3159. s_player_hand_title.generic.x = 32;
  3160. s_player_hand_title.generic.y = 108;
  3161. s_player_handedness_box.generic.type = MTYPE_SPINCONTROL;
  3162. s_player_handedness_box.generic.x = -56;
  3163. s_player_handedness_box.generic.y = 118;
  3164. s_player_handedness_box.generic.name = 0;
  3165. s_player_handedness_box.generic.cursor_offset = -48;
  3166. s_player_handedness_box.generic.callback = HandednessCallback;
  3167. s_player_handedness_box.curvalue = Cvar_VariableValue( "hand" );
  3168. s_player_handedness_box.itemnames = handedness;
  3169. for (i = 0; i < sizeof(rate_tbl) / sizeof(*rate_tbl) - 1; i++)
  3170. if (Cvar_VariableValue("rate") == rate_tbl[i])
  3171. break;
  3172. s_player_rate_title.generic.type = MTYPE_SEPARATOR;
  3173. s_player_rate_title.generic.name = "connect speed";
  3174. s_player_rate_title.generic.x = 56;
  3175. s_player_rate_title.generic.y = 156;
  3176. s_player_rate_box.generic.type = MTYPE_SPINCONTROL;
  3177. s_player_rate_box.generic.x = -56;
  3178. s_player_rate_box.generic.y = 166;
  3179. s_player_rate_box.generic.name = 0;
  3180. s_player_rate_box.generic.cursor_offset = -48;
  3181. s_player_rate_box.generic.callback = RateCallback;
  3182. s_player_rate_box.curvalue = i;
  3183. s_player_rate_box.itemnames = rate_names;
  3184. s_player_download_action.generic.type = MTYPE_ACTION;
  3185. s_player_download_action.generic.name = "download options";
  3186. s_player_download_action.generic.flags= QMF_LEFT_JUSTIFY;
  3187. s_player_download_action.generic.x = -24;
  3188. s_player_download_action.generic.y = 186;
  3189. s_player_download_action.generic.statusbar = NULL;
  3190. s_player_download_action.generic.callback = DownloadOptionsFunc;
  3191. Menu_AddItem( &s_player_config_menu, &s_player_name_field );
  3192. Menu_AddItem( &s_player_config_menu, &s_player_model_title );
  3193. Menu_AddItem( &s_player_config_menu, &s_player_model_box );
  3194. if ( s_player_skin_box.itemnames )
  3195. {
  3196. Menu_AddItem( &s_player_config_menu, &s_player_skin_title );
  3197. Menu_AddItem( &s_player_config_menu, &s_player_skin_box );
  3198. }
  3199. Menu_AddItem( &s_player_config_menu, &s_player_hand_title );
  3200. Menu_AddItem( &s_player_config_menu, &s_player_handedness_box );
  3201. Menu_AddItem( &s_player_config_menu, &s_player_rate_title );
  3202. Menu_AddItem( &s_player_config_menu, &s_player_rate_box );
  3203. Menu_AddItem( &s_player_config_menu, &s_player_download_action );
  3204. return true;
  3205. }
  3206. void PlayerConfig_MenuDraw( void )
  3207. {
  3208. extern float CalcFov( float fov_x, float w, float h );
  3209. refdef_t refdef;
  3210. char scratch[MAX_QPATH];
  3211. memset( &refdef, 0, sizeof( refdef ) );
  3212. refdef.x = viddef.width / 2;
  3213. refdef.y = viddef.height / 2 - 72;
  3214. refdef.width = 144;
  3215. refdef.height = 168;
  3216. refdef.fov_x = 40;
  3217. refdef.fov_y = CalcFov( refdef.fov_x, refdef.width, refdef.height );
  3218. refdef.time = cls.realtime*0.001;
  3219. if ( s_pmi[s_player_model_box.curvalue].skindisplaynames )
  3220. {
  3221. static int yaw;
  3222. int maxframe = 29;
  3223. entity_t entity;
  3224. memset( &entity, 0, sizeof( entity ) );
  3225. Com_sprintf( scratch, sizeof( scratch ), "players/%s/tris.md2", s_pmi[s_player_model_box.curvalue].directory );
  3226. entity.model = re.RegisterModel( scratch );
  3227. Com_sprintf( scratch, sizeof( scratch ), "players/%s/%s.pcx", s_pmi[s_player_model_box.curvalue].directory, s_pmi[s_player_model_box.curvalue].skindisplaynames[s_player_skin_box.curvalue] );
  3228. entity.skin = re.RegisterSkin( scratch );
  3229. entity.flags = RF_FULLBRIGHT;
  3230. entity.origin[0] = 80;
  3231. entity.origin[1] = 0;
  3232. entity.origin[2] = 0;
  3233. VectorCopy( entity.origin, entity.oldorigin );
  3234. entity.frame = 0;
  3235. entity.oldframe = 0;
  3236. entity.backlerp = 0.0;
  3237. entity.angles[1] = yaw++;
  3238. if ( ++yaw > 360 )
  3239. yaw -= 360;
  3240. refdef.areabits = 0;
  3241. refdef.num_entities = 1;
  3242. refdef.entities = &entity;
  3243. refdef.lightstyles = 0;
  3244. refdef.rdflags = RDF_NOWORLDMODEL;
  3245. Menu_Draw( &s_player_config_menu );
  3246. M_DrawTextBox( ( refdef.x ) * ( 320.0F / viddef.width ) - 8, ( viddef.height / 2 ) * ( 240.0F / viddef.height) - 77, refdef.width / 8, refdef.height / 8 );
  3247. refdef.height += 4;
  3248. re.RenderFrame( &refdef );
  3249. Com_sprintf( scratch, sizeof( scratch ), "/players/%s/%s_i.pcx",
  3250. s_pmi[s_player_model_box.curvalue].directory,
  3251. s_pmi[s_player_model_box.curvalue].skindisplaynames[s_player_skin_box.curvalue] );
  3252. re.DrawPic( s_player_config_menu.x - 40, refdef.y, scratch );
  3253. }
  3254. }
  3255. const char *PlayerConfig_MenuKey (int key)
  3256. {
  3257. int i;
  3258. if ( key == K_ESCAPE )
  3259. {
  3260. char scratch[1024];
  3261. Cvar_Set( "name", s_player_name_field.buffer );
  3262. Com_sprintf( scratch, sizeof( scratch ), "%s/%s",
  3263. s_pmi[s_player_model_box.curvalue].directory,
  3264. s_pmi[s_player_model_box.curvalue].skindisplaynames[s_player_skin_box.curvalue] );
  3265. Cvar_Set( "skin", scratch );
  3266. for ( i = 0; i < s_numplayermodels; i++ )
  3267. {
  3268. int j;
  3269. for ( j = 0; j < s_pmi[i].nskins; j++ )
  3270. {
  3271. if ( s_pmi[i].skindisplaynames[j] )
  3272. free( s_pmi[i].skindisplaynames[j] );
  3273. s_pmi[i].skindisplaynames[j] = 0;
  3274. }
  3275. free( s_pmi[i].skindisplaynames );
  3276. s_pmi[i].skindisplaynames = 0;
  3277. s_pmi[i].nskins = 0;
  3278. }
  3279. }
  3280. return Default_MenuKey( &s_player_config_menu, key );
  3281. }
  3282. void M_Menu_PlayerConfig_f (void)
  3283. {
  3284. if (!PlayerConfig_MenuInit())
  3285. {
  3286. Menu_SetStatusBar( &s_multiplayer_menu, "No valid player models found" );
  3287. return;
  3288. }
  3289. Menu_SetStatusBar( &s_multiplayer_menu, NULL );
  3290. M_PushMenu( PlayerConfig_MenuDraw, PlayerConfig_MenuKey );
  3291. }
  3292. /*
  3293. =======================================================================
  3294. GALLERY MENU
  3295. =======================================================================
  3296. */
  3297. #if 0
  3298. void M_Menu_Gallery_f( void )
  3299. {
  3300. extern void Gallery_MenuDraw( void );
  3301. extern const char *Gallery_MenuKey( int key );
  3302. M_PushMenu( Gallery_MenuDraw, Gallery_MenuKey );
  3303. }
  3304. #endif
  3305. /*
  3306. =======================================================================
  3307. QUIT MENU
  3308. =======================================================================
  3309. */
  3310. const char *M_Quit_Key (int key)
  3311. {
  3312. switch (key)
  3313. {
  3314. case K_ESCAPE:
  3315. case 'n':
  3316. case 'N':
  3317. M_PopMenu ();
  3318. break;
  3319. case 'Y':
  3320. case 'y':
  3321. cls.key_dest = key_console;
  3322. CL_Quit_f ();
  3323. break;
  3324. default:
  3325. break;
  3326. }
  3327. return NULL;
  3328. }
  3329. void M_Quit_Draw (void)
  3330. {
  3331. int w, h;
  3332. re.DrawGetPicSize (&w, &h, "quit");
  3333. re.DrawPic ( (viddef.width-w)/2, (viddef.height-h)/2, "quit");
  3334. }
  3335. void M_Menu_Quit_f (void)
  3336. {
  3337. M_PushMenu (M_Quit_Draw, M_Quit_Key);
  3338. }
  3339. //=============================================================================
  3340. /* Menu Subsystem */
  3341. /*
  3342. =================
  3343. M_Init
  3344. =================
  3345. */
  3346. void M_Init (void)
  3347. {
  3348. Cmd_AddCommand ("menu_main", M_Menu_Main_f);
  3349. Cmd_AddCommand ("menu_game", M_Menu_Game_f);
  3350. Cmd_AddCommand ("menu_loadgame", M_Menu_LoadGame_f);
  3351. Cmd_AddCommand ("menu_savegame", M_Menu_SaveGame_f);
  3352. Cmd_AddCommand ("menu_joinserver", M_Menu_JoinServer_f);
  3353. Cmd_AddCommand ("menu_addressbook", M_Menu_AddressBook_f);
  3354. Cmd_AddCommand ("menu_startserver", M_Menu_StartServer_f);
  3355. Cmd_AddCommand ("menu_dmoptions", M_Menu_DMOptions_f);
  3356. Cmd_AddCommand ("menu_playerconfig", M_Menu_PlayerConfig_f);
  3357. Cmd_AddCommand ("menu_downloadoptions", M_Menu_DownloadOptions_f);
  3358. Cmd_AddCommand ("menu_credits", M_Menu_Credits_f );
  3359. Cmd_AddCommand ("menu_multiplayer", M_Menu_Multiplayer_f );
  3360. Cmd_AddCommand ("menu_video", M_Menu_Video_f);
  3361. Cmd_AddCommand ("menu_options", M_Menu_Options_f);
  3362. Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
  3363. Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
  3364. }
  3365. /*
  3366. =================
  3367. M_Draw
  3368. =================
  3369. */
  3370. void M_Draw (void)
  3371. {
  3372. if (cls.key_dest != key_menu)
  3373. return;
  3374. // repaint everything next frame
  3375. SCR_DirtyScreen ();
  3376. // dim everything behind it down
  3377. if (cl.cinematictime > 0)
  3378. re.DrawFill (0,0,viddef.width, viddef.height, 0);
  3379. else
  3380. re.DrawFadeScreen ();
  3381. m_drawfunc ();
  3382. // delay playing the enter sound until after the
  3383. // menu has been drawn, to avoid delay while
  3384. // caching images
  3385. if (m_entersound)
  3386. {
  3387. S_StartLocalSound( menu_in_sound );
  3388. m_entersound = false;
  3389. }
  3390. }
  3391. /*
  3392. =================
  3393. M_Keydown
  3394. =================
  3395. */
  3396. void M_Keydown (int key)
  3397. {
  3398. const char *s;
  3399. if (m_keyfunc)
  3400. if ( ( s = m_keyfunc( key ) ) != 0 )
  3401. S_StartLocalSound( ( char * ) s );
  3402. }