ui_main.cpp 220 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581
  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. /*
  4. =======================================================================
  5. USER INTERFACE MAIN
  6. =======================================================================
  7. */
  8. // leave this at the top of all UI_xxxx files for PCH reasons...
  9. //
  10. #include "../server/exe_headers.h"
  11. #include "ui_local.h"
  12. #include "menudef.h"
  13. #include "ui_shared.h"
  14. #include "../ghoul2/G2.h"
  15. #include "../game/bg_public.h"
  16. #include "../game/anims.h"
  17. extern stringID_table_t animTable [MAX_ANIMATIONS+1];
  18. #include "../qcommon/stv_version.h"
  19. #ifdef _XBOX
  20. #include <xtl.h>
  21. #define filepathlength 120
  22. #endif
  23. #include "../qcommon/xb_settings.h"
  24. //JLF
  25. int gScrollAccum = 0;
  26. int gScrollDelta = 0;
  27. #define TEXTSCROLLDESCRETESTEP 50
  28. #define SCROLL_SENSITIVITY 2
  29. #define ARROW_SPACE 8
  30. extern qboolean ItemParse_model_g2anim_go( itemDef_t *item, const char *animName );
  31. extern qboolean ItemParse_asset_model_go( itemDef_t *item, const char *name );
  32. extern qboolean ItemParse_model_g2skin_go( itemDef_t *item, const char *skinName );
  33. extern qboolean UI_SaberModelForSaber( const char *saberName, char *saberModel );
  34. extern qboolean UI_SaberSkinForSaber( const char *saberName, char *saberSkin );
  35. extern void UI_SaberAttachToChar( itemDef_t *item );
  36. extern unsigned long SG_SaveGameSize();
  37. // VIRTUAL KEYBOARD DEFINES ETC
  38. //
  39. // Warning: These next values must work out so that there are at least 2 columns and/or
  40. // 2 rows. Otherwise you will not be able to compile because of divide by zero errors.
  41. // Not to mention the ugly keyboard you'd be designing
  42. #define SKB_NUM_LETTERS (36)
  43. #define SKB_NUM_COLS (10) // must be > 1 and < SKB_NUM_LETTERS-1
  44. #define SKB_NUM_ROWS ((SKB_NUM_LETTERS%SKB_NUM_COLS)?(SKB_NUM_LETTERS/SKB_NUM_COLS+1):(SKB_NUM_LETTERS/SKB_NUM_COLS))
  45. #define SKB_TOP (225)
  46. #define SKB_BOT (350)
  47. #define SKB_LEFT (100)
  48. #define SKB_RIGHT (540)
  49. #define SKB_STRING_LENGTH (10)
  50. #define SKB_STRING_TOP (150)
  51. #define SKB_STRING_LEFT (200)
  52. #define SKB_SPACE_H ((SKB_RIGHT-SKB_LEFT)/(SKB_NUM_COLS-1))
  53. #define SKB_SPACE_V ((SKB_BOT-SKB_TOP)/(SKB_NUM_ROWS-1))
  54. #define SKB_ACCEPT_NAME ("skb_accept")
  55. #define SKB_DELETE_NAME ("skb_delete")
  56. #define SKB_KEYBOARD_NAME ("skb_keyboard")
  57. #define SKB_OK_X (390)
  58. #define SKB_OK_Y (400)
  59. #define SKB_BACKSPACE_X (250)
  60. #define SKB_BACKSPACE_Y (400)
  61. char *letters[SKB_NUM_LETTERS] = {
  62. "0", "1", "2", "3",
  63. "4", "5", "6", "7",
  64. "8", "9",
  65. "A", "B", "C", "D",
  66. "E", "F", "G", "H",
  67. "I", "J", "K", "L",
  68. "M", "N", "O", "P",
  69. "Q", "R", "S", "T",
  70. "U", "V", "W", "X",
  71. "Y", "Z", };
  72. typedef struct
  73. {
  74. short activeKey;
  75. short curStringPos;
  76. short curCol;
  77. short curRow;
  78. } softkeyboardDef_t;
  79. softkeyboardDef_t skb;
  80. extern qboolean PC_Script_Parse(const char **out);
  81. #define LISTBUFSIZE 10240
  82. static struct
  83. {
  84. char listBuf[LISTBUFSIZE]; // The list of file names read in
  85. // For scrolling through file names
  86. int currentLine; // Index to currentSaveFileComments[] currently highlighted
  87. int saveFileCnt; // Number of save files read in
  88. int awaitingSave; // Flag to see if user wants to overwrite a game.
  89. char *savegameMap;
  90. int savegameFromFlag;
  91. } s_savegame;
  92. //JLF MPMOVED
  93. #ifdef _XBOX
  94. struct playerProfile_t
  95. {
  96. // For scrolling through file names
  97. int currentLine; // Index to currentSaveFileComments[] currently highlighted
  98. int fileCnt; // Number of save files read in
  99. char *modelName;
  100. };
  101. playerProfile_t s_playerProfile;
  102. void resetProfileFileCount()
  103. {
  104. s_playerProfile.fileCnt = -1;
  105. };
  106. #endif
  107. #ifdef _XBOX
  108. #define MAX_SAVELOADFILES 100
  109. //JLF MPMOVED
  110. #define MAX_PROFILEFILES 8
  111. #else
  112. #define MAX_SAVELOADFILES 100
  113. #endif
  114. #define MAX_SAVELOADNAME 32
  115. //byte screenShotBuf[SG_SCR_WIDTH * SG_SCR_HEIGHT * 4];
  116. typedef struct
  117. {
  118. char *currentSaveFileName; // file name of savegame
  119. char currentSaveFileComments[iSG_COMMENT_SIZE]; // file comment
  120. char currentSaveFileDateTimeString[iSG_COMMENT_SIZE]; // file time and date
  121. time_t currentSaveFileDateTime;
  122. #ifdef _XBOX
  123. char currentSaveFileMap[32]; // map save game is from
  124. #else
  125. char currentSaveFileMap[MAX_TOKEN_CHARS]; // map save game is from
  126. #endif
  127. char corrupt;
  128. char screenshotNotify;
  129. } savedata_t;
  130. static savedata_t s_savedata[MAX_SAVELOADFILES];
  131. //JLF
  132. char g_loadsaveGameName[MAX_SAVELOADNAME];
  133. qboolean g_loadsaveGameNameInitialized = qfalse;
  134. extern unsigned long SG_BlocksLeft();
  135. //JLF used to tell if delete button should be shown
  136. static qboolean ui_ShowDeleteActive =0 ;
  137. void storeSGDataDatetoCvar();
  138. void storeSGDataTimetoCvar();
  139. void storeSGDataDiffLeveltoCvar();
  140. //JLF MPMOVED
  141. #ifdef _XBOX
  142. typedef struct
  143. {
  144. char currentProfileName[iSG_COMMENT_SIZE]; // file name of savegame
  145. char currentProfileComments[iSG_COMMENT_SIZE]; // file comment
  146. char currentProfileDateTimeString[iSG_COMMENT_SIZE]; // file time and date
  147. time_t currentProfileDateTime;
  148. } profileData_t;
  149. static profileData_t s_ProfileData[MAX_PROFILEFILES];
  150. #endif
  151. void UI_SetActiveMenu( const char* menuname,const char *menuID );
  152. void ReadSaveDirectory (void);
  153. //JLF MPMOVED
  154. #ifdef _XBOX
  155. //void ReadSaveDirectoryProfiles(void);
  156. void UI_UpdateSettingsCvars(void);
  157. static void UI_UpdateVolume(const char* action, const char* type, const char* itemName, int width, int value );
  158. static void UI_UpdateMoves(void);
  159. static void UI_UpdateMoveTitles(void);
  160. #endif
  161. void Item_RunScript(itemDef_t *item, const char *s);
  162. qboolean Item_SetFocus(itemDef_t *item, float x, float y);
  163. qboolean Asset_Parse(char **buffer);
  164. menuDef_t *Menus_FindByName(const char *p);
  165. void Menus_HideItems(const char *menuName);
  166. int Text_Height(const char *text, float scale, int iFontIndex );
  167. int Text_Width(const char *text, float scale, int iFontIndex );
  168. void _UI_DrawTopBottom(float x, float y, float w, float h, float size);
  169. void _UI_DrawSides(float x, float y, float w, float h, float size);
  170. void UI_CheckVid1Data(const char *menuTo,const char *warningMenuName);
  171. void UI_GetVideoSetup ( void );
  172. void UI_UpdateVideoSetup ( void );
  173. static void UI_UpdateCharacterCvars ( void );
  174. static void UI_GetCharacterCvars ( void );
  175. static void UI_UpdateSaberCvars ( void );
  176. static void UI_GetSaberCvars ( void );
  177. static void UI_ResetSaberCvars ( void );
  178. static void UI_InitAllocForcePowers ( const char *forceName );
  179. static void UI_AffectForcePowerLevel ( const char *forceName );
  180. static void UI_SetUpForceSelect( void );
  181. static void UI_ShowForceLevelDesc ( const char *forceName );
  182. static void UI_ResetForceLevels ( void );
  183. static void UI_ClearWeapons ( void );
  184. static void UI_GiveWeapon ( const int weaponIndex );
  185. static void UI_EquipWeapon ( const int weaponIndex );
  186. static void UI_LoadMissionSelectMenu( const char *cvarName );
  187. static void UI_AddWeaponSelection ( const int weaponIndex, const int ammoIndex, const int ammoAmount, const char *iconItemName,const char *litIconItemName, const char *hexBackground, const char *soundfile );
  188. static void UI_AddThrowWeaponSelection ( const int weaponIndex, const int ammoIndex, const int ammoAmount, const char *iconItemName,const char *litIconItemName, const char *hexBackground, const char *soundfile );
  189. static void UI_RemoveWeaponSelection ( const int weaponIndex );
  190. static void UI_RemoveThrowWeaponSelection ( void );
  191. static void UI_HighLightWeaponSelection ( const int selectionslot );
  192. static void UI_NormalWeaponSelection ( const int selectionslot );
  193. static void UI_NormalThrowSelection ( void );
  194. static void UI_HighLightThrowSelection( void );
  195. static void UI_ClearInventory ( void );
  196. static void UI_GiveInventory ( const int itemIndex, const int amount );
  197. static void UI_ForcePowerWeaponsButton(qboolean activeFlag);
  198. static void UI_UpdateCharacterSkin( void );
  199. static void UI_UpdateCharacter( qboolean changedModel );
  200. static void UI_UpdateSaberType( void );
  201. static void UI_UpdateSaberHilt( qboolean secondSaber );
  202. //static void UI_UpdateSaberColor( qboolean secondSaber );
  203. static void UI_InitWeaponSelect( void );
  204. static void UI_DisableWeapon( void );
  205. static void UI_WeaponHelpActive( void );
  206. static void UI_UpdateFightingStyle ( void );
  207. static void UI_UpdateFightingStyleChoices ( void );
  208. static void UI_CalcForceStatus(void);
  209. static void UI_DecrementForcePowerLevel( void );
  210. static void UI_DecrementCurrentForcePower ( void );
  211. static void UI_ShutdownForceHelp( void );
  212. static void UI_ForceHelpActive( void );
  213. static void UI_ResetCharacterListBoxes( void );
  214. static void UI_CheckForForceCheat( void );
  215. void UI_LoadMenus(const char *menuFile, qboolean reset);
  216. static void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle, int iFontIndex);
  217. static qboolean UI_OwnerDrawVisible(int flags);
  218. int UI_OwnerDrawWidth(int ownerDraw, float scale);
  219. static void UI_Update(const char *name);
  220. void UI_UpdateCvars( void );
  221. void UI_ResetDefaults( void );
  222. void UI_AdjustSaveGameListBox( int currentLine );
  223. static void UI_FeederSelection(float feederID, int index, itemDef_t *item);
  224. void Menus_CloseByName(const char *p);
  225. static qboolean UI_SoftKeyboard_HandleKey(int flags, float *special, int key);
  226. static qboolean UI_SoftKeyboardDelete_HandleKey(int flags, float *special, int key);
  227. static qboolean UI_SoftKeyboardAccept_HandleKey(int flags, float *special, int key);
  228. static void UI_SoftKeyboardInit();
  229. static void UI_SoftKeyboardDelete();
  230. static void UI_SoftKeyboardAccept();
  231. static void UI_SoftKeyboard_Draw();
  232. static void UI_SoftKeyboardDelete_Draw();
  233. static void UI_SoftKeyboardAccept_Draw();
  234. // Level select screen data
  235. struct levelSelect_t
  236. {
  237. char mapname[MAX_QPATH]; // Map name to use when loading
  238. char displayName[32]; // Text to show in the listbox
  239. int forceLevel; // Level of neutral force powers
  240. };
  241. const levelSelect_t levelSelectData[] = {
  242. { "yavin1b", "@MENUS_YAVIN1B", 0 },
  243. { "yavin2", "@MENUS_YAVIN2", 1 },
  244. { "t1_danger", "@MENUS_T1_DANGER", 1 },
  245. { "t1_fatal", "@MENUS_T1_FATAL", 1 },
  246. { "t1_rail", "@MENUS_T1_RAIL", 1 },
  247. { "t1_sour", "@MENUS_T1_SOUR", 1 },
  248. { "t1_surprise", "@MENUS_T1_SURPRISE", 1 },
  249. { "hoth2", "@MENUS_HOTH2", 1 },
  250. { "hoth3", "@MENUS_HOTH3", 1 },
  251. { "t2_dpred", "@MENUS_T2_DPRED", 2 },
  252. { "t2_rancor", "@MENUS_T2_RANCOR", 2 },
  253. { "t2_rogue", "@MENUS_T2_ROGUE", 2 },
  254. { "t2_trip", "@MENUS_T2_TRIP", 2 },
  255. { "t2_wedge", "@MENUS_T2_WEDGE", 2 },
  256. { "vjun1", "@MENUS_VJUN1", 2 },
  257. { "vjun2", "@MENUS_VJUN2", 2 },
  258. { "vjun3", "@MENUS_VJUN3", 2 },
  259. { "t3_bounty", "@MENUS_T3_BOUNTY", 3 },
  260. { "t3_byss", "@MENUS_T3_BYSS", 3 },
  261. { "t3_hevil", "@MENUS_T3_HEVIL", 3 },
  262. { "t3_rift", "@MENUS_T3_RIFT", 3 },
  263. { "t3_stamp", "@MENUS_T3_STAMP", 3 },
  264. { "taspir1", "@MENUS_TASPIR1", 3 },
  265. { "taspir2", "@MENUS_TASPIR2", 3 },
  266. { "kor1", "@MENUS_KOR1", 3 },
  267. { "kor2", "@MENUS_KOR2", 3 },
  268. };
  269. const int levelSelectSize = sizeof(levelSelectData) / sizeof(levelSelectData[0]);
  270. // Currently selected map in level select cheat screen
  271. int levelSelectChoice = 0;
  272. // Movedata Sounds
  273. typedef enum
  274. {
  275. MDS_NONE = 0,
  276. MDS_FORCE_JUMP,
  277. MDS_ROLL,
  278. MDS_SABER,
  279. MDS_MOVE_SOUNDS_MAX
  280. };
  281. typedef enum
  282. {
  283. MD_ACROBATICS = 0,
  284. MD_SINGLE_FAST,
  285. MD_SINGLE_MEDIUM,
  286. MD_SINGLE_STRONG,
  287. MD_DUAL_SABERS,
  288. MD_SABER_STAFF,
  289. MD_MOVE_TITLE_MAX
  290. };
  291. // Some hard coded badness
  292. // At some point maybe this should be externalized to a .dat file
  293. char *datapadMoveTitleData[MD_MOVE_TITLE_MAX] =
  294. {
  295. "@MENUS_ACROBATICS",
  296. "@MENUS_SINGLE_FAST",
  297. "@MENUS_SINGLE_MEDIUM",
  298. "@MENUS_SINGLE_STRONG",
  299. "@MENUS_DUAL_SABERS",
  300. "@MENUS_SABER_STAFF",
  301. };
  302. char *datapadMoveTitleBaseAnims[MD_MOVE_TITLE_MAX] =
  303. {
  304. "BOTH_RUN1",
  305. "BOTH_SABERFAST_STANCE",
  306. "BOTH_STAND2",
  307. "BOTH_SABERSLOW_STANCE",
  308. "BOTH_SABERDUAL_STANCE",
  309. "BOTH_SABERSTAFF_STANCE",
  310. };
  311. #define MAX_MOVES 16
  312. typedef struct
  313. {
  314. char *title;
  315. char *desc;
  316. char *anim;
  317. short sound;
  318. } datpadmovedata_t;
  319. static datpadmovedata_t datapadMoveData[MD_MOVE_TITLE_MAX][MAX_MOVES] =
  320. {
  321. // Acrobatics
  322. "@MENUS_FORCE_JUMP1", "@MENUS_FORCE_JUMP1_DESC", "BOTH_FORCEJUMP1", MDS_FORCE_JUMP,
  323. "@MENUS_FORCE_FLIP", "@MENUS_FORCE_FLIP_DESC", "BOTH_FLIP_F", MDS_FORCE_JUMP,
  324. "@MENUS_ROLL", "@MENUS_ROLL_DESC", "BOTH_ROLL_F", MDS_ROLL,
  325. "@MENUS_BACKFLIP_OFF_WALL", "@MENUS_BACKFLIP_OFF_WALL_DESC", "BOTH_WALL_FLIP_BACK1", MDS_FORCE_JUMP,
  326. "@MENUS_SIDEFLIP_OFF_WALL", "@MENUS_SIDEFLIP_OFF_WALL_DESC", "BOTH_WALL_FLIP_RIGHT", MDS_FORCE_JUMP,
  327. "@MENUS_WALL_RUN", "@MENUS_WALL_RUN_DESC", "BOTH_WALL_RUN_RIGHT", MDS_FORCE_JUMP,
  328. "@MENUS_LONG_JUMP", "@MENUS_LONG_JUMP_DESC", "BOTH_FORCELONGLEAP_START", MDS_FORCE_JUMP,
  329. "@MENUS_WALL_GRAB_JUMP", "@MENUS_WALL_GRAB_JUMP_DESC", "BOTH_FORCEWALLREBOUND_FORWARD",MDS_FORCE_JUMP,
  330. "@MENUS_RUN_UP_WALL_BACKFLIP", "@MENUS_RUN_UP_WALL_BACKFLIP_DESC", "BOTH_FORCEWALLRUNFLIP_START", MDS_FORCE_JUMP,
  331. "@MENUS_JUMPUP_FROM_KNOCKDOWN", "@MENUS_JUMPUP_FROM_KNOCKDOWN_DESC","BOTH_KNOCKDOWN3", MDS_NONE,
  332. "@MENUS_JUMPKICK_FROM_KNOCKDOWN", "@MENUS_JUMPKICK_FROM_KNOCKDOWN_DESC","BOTH_KNOCKDOWN2", MDS_NONE,
  333. "@MENUS_ROLL_FROM_KNOCKDOWN", "@MENUS_ROLL_FROM_KNOCKDOWN_DESC", "BOTH_KNOCKDOWN1", MDS_NONE,
  334. NULL, NULL, 0, MDS_NONE,
  335. NULL, NULL, 0, MDS_NONE,
  336. NULL, NULL, 0, MDS_NONE,
  337. NULL, NULL, 0, MDS_NONE,
  338. //Single Saber, Fast Style
  339. "@MENUS_STAB_BACK", "@MENUS_STAB_BACK_DESC", "BOTH_A2_STABBACK1", MDS_SABER,
  340. "@MENUS_LUNGE_ATTACK", "@MENUS_LUNGE_ATTACK_DESC", "BOTH_LUNGE2_B__T_", MDS_SABER,
  341. "@MENUS_FORCE_PULL_IMPALE", "@MENUS_FORCE_PULL_IMPALE_DESC", "BOTH_PULL_IMPALE_STAB", MDS_SABER,
  342. "@MENUS_FAST_ATTACK_KATA", "@MENUS_FAST_ATTACK_KATA_DESC", "BOTH_A1_SPECIAL", MDS_SABER,
  343. "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
  344. "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
  345. "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
  346. NULL, NULL, 0, MDS_NONE,
  347. NULL, NULL, 0, MDS_NONE,
  348. NULL, NULL, 0, MDS_NONE,
  349. NULL, NULL, 0, MDS_NONE,
  350. NULL, NULL, 0, MDS_NONE,
  351. NULL, NULL, 0, MDS_NONE,
  352. NULL, NULL, 0, MDS_NONE,
  353. NULL, NULL, 0, MDS_NONE,
  354. NULL, NULL, 0, MDS_NONE,
  355. //Single Saber, Medium Style
  356. "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
  357. "@MENUS_FLIP_ATTACK", "@MENUS_FLIP_ATTACK_DESC", "BOTH_JUMPFLIPSLASHDOWN1", MDS_FORCE_JUMP,
  358. "@MENUS_FORCE_PULL_SLASH", "@MENUS_FORCE_PULL_SLASH_DESC", "BOTH_PULL_IMPALE_SWING", MDS_SABER,
  359. "@MENUS_MEDIUM_ATTACK_KATA", "@MENUS_MEDIUM_ATTACK_KATA_DESC", "BOTH_A2_SPECIAL", MDS_SABER,
  360. "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
  361. "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
  362. "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
  363. NULL, NULL, 0, MDS_NONE,
  364. NULL, NULL, 0, MDS_NONE,
  365. NULL, NULL, 0, MDS_NONE,
  366. NULL, NULL, 0, MDS_NONE,
  367. NULL, NULL, 0, MDS_NONE,
  368. NULL, NULL, 0, MDS_NONE,
  369. NULL, NULL, 0, MDS_NONE,
  370. NULL, NULL, 0, MDS_NONE,
  371. NULL, NULL, 0, MDS_NONE,
  372. //Single Saber, Strong Style
  373. "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
  374. "@MENUS_JUMP_ATTACK", "@MENUS_JUMP_ATTACK_DESC", "BOTH_FORCELEAP2_T__B_", MDS_FORCE_JUMP,
  375. "@MENUS_FORCE_PULL_SLASH", "@MENUS_FORCE_PULL_SLASH_DESC", "BOTH_PULL_IMPALE_SWING", MDS_SABER,
  376. "@MENUS_STRONG_ATTACK_KATA", "@MENUS_STRONG_ATTACK_KATA_DESC", "BOTH_A3_SPECIAL", MDS_SABER,
  377. "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
  378. "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
  379. "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
  380. NULL, NULL, 0, MDS_NONE,
  381. NULL, NULL, 0, MDS_NONE,
  382. NULL, NULL, 0, MDS_NONE,
  383. NULL, NULL, 0, MDS_NONE,
  384. NULL, NULL, 0, MDS_NONE,
  385. NULL, NULL, 0, MDS_NONE,
  386. NULL, NULL, 0, MDS_NONE,
  387. NULL, NULL, 0, MDS_NONE,
  388. NULL, NULL, 0, MDS_NONE,
  389. //Dual Sabers
  390. "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
  391. "@MENUS_FLIP_FORWARD_ATTACK", "@MENUS_FLIP_FORWARD_ATTACK_DESC", "BOTH_JUMPATTACK6", MDS_FORCE_JUMP,
  392. "@MENUS_DUAL_SABERS_TWIRL", "@MENUS_DUAL_SABERS_TWIRL_DESC", "BOTH_SPINATTACK6", MDS_SABER,
  393. "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN_DUAL", MDS_FORCE_JUMP,
  394. "@MENUS_DUAL_SABER_BARRIER", "@MENUS_DUAL_SABER_BARRIER_DESC", "BOTH_A6_SABERPROTECT", MDS_SABER,
  395. "@MENUS_DUAL_STAB_FRONT_BACK", "@MENUS_DUAL_STAB_FRONT_BACK_DESC", "BOTH_A6_FB", MDS_SABER,
  396. "@MENUS_DUAL_STAB_LEFT_RIGHT", "@MENUS_DUAL_STAB_LEFT_RIGHT_DESC", "BOTH_A6_LR", MDS_SABER,
  397. "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
  398. "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB_DESC", "BOTH_ROLL_STAB", MDS_SABER,
  399. NULL, NULL, 0, MDS_NONE,
  400. NULL, NULL, 0, MDS_NONE,
  401. NULL, NULL, 0, MDS_NONE,
  402. NULL, NULL, 0, MDS_NONE,
  403. NULL, NULL, 0, MDS_NONE,
  404. NULL, NULL, 0, MDS_NONE,
  405. NULL, NULL, 0, MDS_NONE,
  406. // Saber Staff
  407. "@MENUS_STAB_BACK", "@MENUS_STAB_BACK_DESC", "BOTH_A2_STABBACK1", MDS_SABER,
  408. "@MENUS_BACK_FLIP_ATTACK", "@MENUS_BACK_FLIP_ATTACK_DESC", "BOTH_JUMPATTACK7", MDS_FORCE_JUMP,
  409. "@MENUS_SABER_STAFF_TWIRL", "@MENUS_SABER_STAFF_TWIRL_DESC", "BOTH_SPINATTACK7", MDS_SABER,
  410. "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN_STAFF", MDS_FORCE_JUMP,
  411. "@MENUS_SPINNING_KATA", "@MENUS_SPINNING_KATA_DESC", "BOTH_A7_SOULCAL", MDS_SABER,
  412. "@MENUS_KICK1", "@MENUS_KICK1_DESC", "BOTH_A7_KICK_F", MDS_FORCE_JUMP,
  413. "@MENUS_JUMP_KICK", "@MENUS_JUMP_KICK_DESC", "BOTH_A7_KICK_F_AIR", MDS_FORCE_JUMP,
  414. "@MENUS_SPLIT_KICK", "@MENUS_SPLIT_KICK_DESC", "BOTH_A7_KICK_RL", MDS_FORCE_JUMP,
  415. "@MENUS_SPIN_KICK", "@MENUS_SPIN_KICK_DESC", "BOTH_A7_KICK_S", MDS_FORCE_JUMP,
  416. "@MENUS_FLIP_KICK", "@MENUS_FLIP_KICK_DESC", "BOTH_A7_KICK_BF", MDS_FORCE_JUMP,
  417. "@MENUS_BUTTERFLY_ATTACK", "@MENUS_BUTTERFLY_ATTACK_DESC", "BOTH_BUTTERFLY_FR1", MDS_SABER,
  418. "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
  419. NULL, NULL, 0, MDS_NONE,
  420. NULL, NULL, 0, MDS_NONE,
  421. NULL, NULL, 0, MDS_NONE,
  422. NULL, NULL, 0, MDS_NONE,
  423. };
  424. static int gamecodetoui[] = {4,2,3,0,5,1,6};
  425. uiInfo_t uiInfo;
  426. static void UI_RegisterCvars( void );
  427. void UI_Load(void);
  428. typedef struct {
  429. vmCvar_t *vmCvar;
  430. char *cvarName;
  431. char *defaultString;
  432. int cvarFlags;
  433. } cvarTable_t;
  434. vmCvar_t ui_menuFiles;
  435. vmCvar_t ui_hudFiles;
  436. vmCvar_t ui_char_anim;
  437. vmCvar_t ui_char_model;
  438. vmCvar_t ui_char_skin_head;
  439. vmCvar_t ui_char_skin_torso;
  440. vmCvar_t ui_char_skin_legs;
  441. vmCvar_t ui_saber_type;
  442. vmCvar_t ui_saber;
  443. vmCvar_t ui_saber2;
  444. vmCvar_t ui_saber_color;
  445. vmCvar_t ui_saber2_color;
  446. vmCvar_t ui_char_color_red;
  447. vmCvar_t ui_char_color_green;
  448. vmCvar_t ui_char_color_blue;
  449. vmCvar_t ui_PrecacheModels;
  450. //JLFCALLOUT MPMOVED
  451. vmCvar_t ui_hideAcallout;
  452. vmCvar_t ui_hideBcallout;
  453. vmCvar_t ui_hideXcallout;
  454. //END JLFCALLOUT
  455. vmCvar_t saveGameCount;
  456. vmCvar_t overwriteAvailable;
  457. vmCvar_t ui_newGameActive;
  458. vmCvar_t noNewSaveGameAvailable;
  459. vmCvar_t ui_BlocksAvailable;
  460. vmCvar_t ui_BlocksNeeded;
  461. vmCvar_t ui_ShowDelete ;
  462. vmCvar_t ui_cancelYScript ;
  463. //controller menu
  464. vmCvar_t ControllerOutNum ;
  465. // Version of startup state machine function used when we came from MP XBE:
  466. void XB_FastStartup( XBStartupState startupState )
  467. {
  468. if( startupState <= STARTUP_LOAD_SETTINGS )
  469. {
  470. bool bSuccess = Settings.Load();
  471. if( !bSuccess )
  472. {
  473. // Odd. If saving was disabled, then Load will appear to work.
  474. UI_xboxErrorPopup( XB_POPUP_CORRUPT_SETTINGS );
  475. return;
  476. }
  477. }
  478. if( startupState <= STARTUP_FINISH )
  479. {
  480. // Restore settings from stored (or default) settings:
  481. Settings.SetAll();
  482. // Save them out, in case user just deleted (and is now restoring) them:
  483. Settings.Save();
  484. // mainMenu has already been opened
  485. }
  486. }
  487. /*
  488. MASTER Startup function for saved games, invite checks, etc...
  489. Modeled after XBL_Login
  490. */
  491. int blocksNeeded = 0; // 40/44 - Blocks free
  492. extern bool Sys_QuickStart( void );
  493. void XB_Startup( XBStartupState startupState )
  494. {
  495. // If we came from MP - use the express version
  496. if( Sys_QuickStart() && Cvar_Get("inSplashMenu", "0", 0)->integer == 0 )
  497. {
  498. XB_FastStartup( startupState );
  499. return;
  500. }
  501. if( startupState <= STARTUP_LOAD_SETTINGS )
  502. {
  503. bool bSuccess = Settings.Load();
  504. if( !bSuccess )
  505. {
  506. if( Settings.Corrupt() )
  507. {
  508. UI_xboxErrorPopup( XB_POPUP_CORRUPT_SETTINGS );
  509. return;
  510. }
  511. // Otherwise, file doesn't exist - continue to space checking below
  512. }
  513. else
  514. {
  515. // Skip checking space for settings
  516. startupState = STARTUP_GAME_SPACE_CHECK;
  517. }
  518. }
  519. if( startupState <= STARTUP_COMBINED_SPACE_CHECK )
  520. {
  521. // Is there enough room for both settings and a savegame?
  522. if ( SG_BlocksLeft() < SG_SaveGameSize() + SETTINGS_NUM_BLOCKS )
  523. {
  524. blocksNeeded = (SG_SaveGameSize() + SETTINGS_NUM_BLOCKS) - SG_BlocksLeft();
  525. UI_xboxErrorPopup( XB_POPUP_DISKFULL_BOTH );
  526. return;
  527. }
  528. // OK. There's enough room for settings - make a file:
  529. Settings.Save();
  530. }
  531. if( startupState <= STARTUP_GAME_SPACE_CHECK )
  532. {
  533. #ifndef XBOX_DEMO // No space checks in demo
  534. // Is there enough room for another savegame?
  535. if( SG_BlocksLeft() < SG_SaveGameSize() )
  536. {
  537. blocksNeeded = SG_SaveGameSize() - SG_BlocksLeft();
  538. UI_xboxErrorPopup( XB_POPUP_DISKFULL );
  539. return;
  540. }
  541. #endif
  542. }
  543. if( startupState <= STARTUP_INVITE_CHECK )
  544. {
  545. // Do we have a pending invitation? This can only return true ONCE!
  546. extern bool Sys_InviteExists();
  547. if( Sys_InviteExists() )
  548. {
  549. UI_xboxErrorPopup( XB_POPUP_CONFIRM_INVITE );
  550. return;
  551. }
  552. }
  553. if( startupState <= STARTUP_FINISH )
  554. {
  555. // Restore settings from stored (or default) settings:
  556. Settings.SetAll();
  557. // All done! Open the menu!
  558. Menus_CloseAll();
  559. Menus_ActivateByName( Cvar_VariableString( "returnMenu" ) );
  560. }
  561. }
  562. static cvarTable_t cvarTable[] =
  563. {
  564. { &ui_menuFiles, "ui_menuFiles", "ui/menus.txt", CVAR_ARCHIVE },
  565. { &ui_hudFiles, "cg_hudFiles", "ui/jahud.txt",CVAR_ARCHIVE},
  566. { &ui_char_anim, "ui_char_anim", "BOTH_WALK1",0},
  567. { &ui_char_model, "ui_char_model", "",0}, //these are filled in by the "g_*" versions on load
  568. { &ui_char_skin_head, "ui_char_skin_head", "",0}, //the "g_*" versions are initialized in UI_Init, ui_atoms.cpp
  569. { &ui_char_skin_torso, "ui_char_skin_torso", "",0},
  570. { &ui_char_skin_legs, "ui_char_skin_legs", "",0},
  571. { &ui_saber_type, "ui_saber_type", "",0},
  572. { &ui_saber, "ui_saber", "",0},
  573. { &ui_saber2, "ui_saber2", "",0},
  574. { &ui_saber_color, "ui_saber_color", "",0},
  575. { &ui_saber2_color, "ui_saber2_color", "",0},
  576. { &ui_char_color_red, "ui_char_color_red", "", 0},
  577. { &ui_char_color_green, "ui_char_color_green", "", 0},
  578. { &ui_char_color_blue, "ui_char_color_blue", "", 0},
  579. { &ui_PrecacheModels, "ui_PrecacheModels", "1", CVAR_ARCHIVE},
  580. //JLFCALLOUT MPMOVED
  581. { &ui_hideAcallout, "ui_hideAcallout", "", 0},
  582. { &ui_hideBcallout, "ui_hideBcallout", "", 0},
  583. { &ui_hideXcallout, "ui_hideXcallout", "", 0},
  584. //END JLFCALLOUT
  585. { &saveGameCount, "saveGameCount", "", 0},
  586. { &overwriteAvailable, "overwriteAvailable", "0", 0},
  587. { &ui_newGameActive, "ui_newGameActive", "", 0},
  588. { &noNewSaveGameAvailable, "noNewSaveGameAvailable", "", 0},
  589. { &ui_BlocksAvailable, "ui_BlocksAvailable", "0", 0},
  590. { &ui_BlocksNeeded, "ui_BlocksNeeded", "0", 0},
  591. { &ui_ShowDelete, "ui_ShowDelete", "0", 0},
  592. { &ui_cancelYScript, "ui_cancelYScript", "0", 0},
  593. { &ControllerOutNum, "ControllerOutNum", "-1", 0},
  594. };
  595. #define FP_UPDATED_NONE -1
  596. #define NOWEAPON -1
  597. static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);
  598. void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, int iMaxPixelWidth, int style, int iFontIndex);
  599. int Key_GetCatcher( void );
  600. #define UI_FPS_FRAMES 4
  601. void _UI_Refresh( int realtime )
  602. {
  603. static int index;
  604. static int previousTimes[UI_FPS_FRAMES];
  605. if ( !( Key_GetCatcher() & KEYCATCH_UI ) )
  606. {
  607. return;
  608. }
  609. extern void SE_CheckForLanguageUpdates(void);
  610. SE_CheckForLanguageUpdates();
  611. if ( Menus_AnyFullScreenVisible() )
  612. {//if not in full screen, don't mess with ghoul2
  613. //rww - ghoul2 needs to know what time it is even if the client/server are not running
  614. //FIXME: this screws up the game when you go back to the game...
  615. G2API_SetTime(realtime, 0);
  616. G2API_SetTime(realtime, 1);
  617. }
  618. uiInfo.uiDC.frameTime = realtime - uiInfo.uiDC.realTime;
  619. uiInfo.uiDC.realTime = realtime;
  620. previousTimes[index % UI_FPS_FRAMES] = uiInfo.uiDC.frameTime;
  621. index++;
  622. if ( index > UI_FPS_FRAMES )
  623. {
  624. int i, total;
  625. // average multiple frames together to smooth changes out a bit
  626. total = 0;
  627. for ( i = 0 ; i < UI_FPS_FRAMES ; i++ )
  628. {
  629. total += previousTimes[i];
  630. }
  631. if ( !total )
  632. {
  633. total = 1;
  634. }
  635. uiInfo.uiDC.FPS = 1000 * UI_FPS_FRAMES / total;
  636. }
  637. UI_UpdateCvars();
  638. if (Menu_Count() > 0)
  639. {
  640. // paint all the menus
  641. Menu_PaintAll();
  642. // refresh server browser list
  643. // UI_DoServerRefresh();
  644. // refresh server status
  645. // UI_BuildServerStatus(qfalse);
  646. // refresh find player list
  647. // UI_BuildFindPlayerList(qfalse);
  648. }
  649. #ifdef _XBOX
  650. // display current map name
  651. if (Cvar_VariableIntegerValue( "cl_maphack" ))
  652. {
  653. float rgba[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
  654. extern cvar_t *cl_mapname;
  655. Text_Paint(130, 100, /* UI_FONT_DEFAULT, */ 0.9f, rgba, cl_mapname->string, 0, ITEM_TEXTSTYLE_NORMAL, 3);
  656. }
  657. #endif
  658. #ifndef _XBOX
  659. // draw cursor
  660. UI_SetColor( NULL );
  661. if (Menu_Count() > 0)
  662. {
  663. if (uiInfo.uiDC.cursorShow == qtrue)
  664. {
  665. UI_DrawHandlePic( uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory, 48, 48, uiInfo.uiDC.Assets.cursor);
  666. }
  667. }
  668. #endif
  669. }
  670. #ifdef _XBOX
  671. static void UI_SetVis(menuDef_t* menu, const char* name, bool activeFlag)
  672. {
  673. itemDef_t* item = Menu_FindItemByName(menu, name);
  674. if (item)
  675. {
  676. // Make it active
  677. if (activeFlag)
  678. {
  679. item->window.flags |= WINDOW_VISIBLE;
  680. }
  681. else
  682. {
  683. item->window.flags &= ~WINDOW_VISIBLE;
  684. }
  685. }
  686. }
  687. #endif
  688. /*
  689. ===============
  690. UI_LoadMods
  691. ===============
  692. */
  693. static void UI_LoadMods() {
  694. int numdirs;
  695. char dirlist[2048];
  696. char *dirptr;
  697. char *descptr;
  698. int i;
  699. int dirlen;
  700. uiInfo.modCount = 0;
  701. numdirs = FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) );
  702. dirptr = dirlist;
  703. for( i = 0; i < numdirs; i++ ) {
  704. dirlen = strlen( dirptr ) + 1;
  705. descptr = dirptr + dirlen;
  706. uiInfo.modList[uiInfo.modCount].modName = String_Alloc(dirptr);
  707. uiInfo.modList[uiInfo.modCount].modDescr = String_Alloc(descptr);
  708. dirptr += dirlen + strlen(descptr) + 1;
  709. uiInfo.modCount++;
  710. if (uiInfo.modCount >= MAX_MODS) {
  711. break;
  712. }
  713. }
  714. }
  715. /*
  716. ================
  717. vmMain
  718. This is the only way control passes into the module.
  719. This must be the very first function compiled into the .qvm file
  720. ================
  721. */
  722. int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 )
  723. {
  724. return 0;
  725. }
  726. /*
  727. ================
  728. Text_PaintChar
  729. ================
  730. */
  731. /*
  732. static void Text_PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader)
  733. {
  734. float w, h;
  735. w = width * scale;
  736. h = height * scale;
  737. ui.R_DrawStretchPic((int)x, (int)y, w, h, s, t, s2, t2, hShader ); //make the coords (int) or else the chars bleed
  738. }
  739. */
  740. /*
  741. ================
  742. Text_Paint
  743. ================
  744. */
  745. // iMaxPixelWidth is 0 here for no limit (but gets converted to -1), else max printable pixel width relative to start pos
  746. //
  747. void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, int iMaxPixelWidth, int style, int iFontIndex)
  748. {
  749. if (iFontIndex == 0)
  750. {
  751. iFontIndex = uiInfo.uiDC.Assets.qhMediumFont;
  752. }
  753. // kludge.. convert JK2 menu styles to SOF2 printstring ctrl codes...
  754. //
  755. int iStyleOR = 0;
  756. switch (style)
  757. {
  758. // case ITEM_TEXTSTYLE_NORMAL: iStyleOR = 0;break; // JK2 normal text
  759. // case ITEM_TEXTSTYLE_BLINK: iStyleOR = STYLE_BLINK;break; // JK2 fast blinking
  760. case ITEM_TEXTSTYLE_PULSE: iStyleOR = STYLE_BLINK;break; // JK2 slow pulsing
  761. case ITEM_TEXTSTYLE_SHADOWED: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
  762. case ITEM_TEXTSTYLE_OUTLINED: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
  763. case ITEM_TEXTSTYLE_OUTLINESHADOWED: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
  764. case ITEM_TEXTSTYLE_SHADOWEDMORE: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
  765. }
  766. ui.R_Font_DrawString( x, // int ox
  767. y, // int oy
  768. text, // const char *text
  769. color, // paletteRGBA_c c
  770. iStyleOR | iFontIndex, // const int iFontHandle
  771. !iMaxPixelWidth?-1:iMaxPixelWidth, // iMaxPixelWidth (-1 = none)
  772. scale // const float scale = 1.0f
  773. );
  774. }
  775. /*
  776. ================
  777. Text_PaintWithCursor
  778. ================
  779. */
  780. // iMaxPixelWidth is 0 here for no-limit
  781. void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int iMaxPixelWidth, int style, int iFontIndex)
  782. {
  783. Text_Paint(x, y, scale, color, text, iMaxPixelWidth, style, iFontIndex);
  784. // now print the cursor as well...
  785. //
  786. char sTemp[1024];
  787. int iCopyCount = min(strlen(text), cursorPos);
  788. iCopyCount = min(iCopyCount,sizeof(sTemp));
  789. // copy text into temp buffer for pixel measure...
  790. //
  791. strncpy(sTemp,text,iCopyCount);
  792. sTemp[iCopyCount] = '\0';
  793. int iNextXpos = ui.R_Font_StrLenPixels(sTemp, iFontIndex, scale );
  794. Text_Paint(x+iNextXpos, y, scale, color, va("%c",cursor), iMaxPixelWidth, style|ITEM_TEXTSTYLE_BLINK, iFontIndex);
  795. }
  796. const char *UI_FeederItemText(float feederID, int index, int column, qhandle_t *handle)
  797. {
  798. *handle = -1;
  799. if (feederID == FEEDER_SAVEGAMES)
  800. {
  801. if (column==0)
  802. {
  803. return s_savedata[index].currentSaveFileName;//currentSaveFileComments;
  804. }
  805. else
  806. {
  807. return s_savedata[index].currentSaveFileDateTimeString;
  808. }
  809. }
  810. //JLF MPMOVED
  811. #ifdef _XBOX
  812. else if (feederID == FEEDER_PROFILES)
  813. {
  814. if (column == 0)
  815. {
  816. return s_ProfileData[index].currentProfileName;
  817. }
  818. }
  819. #endif
  820. else if (feederID == FEEDER_MOVES)
  821. {
  822. return datapadMoveData[uiInfo.movesTitleIndex][index].title;
  823. }
  824. else if (feederID == FEEDER_MOVES_TITLES)
  825. {
  826. return datapadMoveTitleData[index];
  827. }
  828. else if (feederID == FEEDER_PLAYER_SPECIES)
  829. {
  830. return uiInfo.playerSpecies[index].Name;
  831. }
  832. else if (feederID == FEEDER_LANGUAGES)
  833. {
  834. assert( 0 );
  835. return NULL;
  836. // return SE_GetLanguageName( index );
  837. }
  838. else if (feederID == FEEDER_PLAYER_SKIN_HEAD)
  839. {
  840. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount)
  841. {
  842. *handle = ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index]));
  843. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index];
  844. }
  845. }
  846. else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
  847. {
  848. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount)
  849. {
  850. *handle = ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index]));
  851. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index];
  852. }
  853. }
  854. else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
  855. {
  856. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount)
  857. {
  858. *handle = ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index]));
  859. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index];
  860. }
  861. }
  862. else if (feederID == FEEDER_COLORCHOICES)
  863. {
  864. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount)
  865. {
  866. *handle = ui.R_RegisterShaderNoMip( uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorShader[index]);
  867. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorShader[index];
  868. }
  869. }
  870. else if (feederID == FEEDER_MODS)
  871. {
  872. if (index >= 0 && index < uiInfo.modCount)
  873. {
  874. if (uiInfo.modList[index].modDescr && *uiInfo.modList[index].modDescr)
  875. {
  876. return uiInfo.modList[index].modDescr;
  877. }
  878. else
  879. {
  880. return uiInfo.modList[index].modName;
  881. }
  882. }
  883. }
  884. else if (feederID == FEEDER_LEVELSELECT)
  885. {
  886. if (index >= 0 && index < levelSelectSize)
  887. return levelSelectData[index].displayName;
  888. }
  889. return "";
  890. }
  891. qhandle_t UI_FeederItemImage(float feederID, int index)
  892. {
  893. if (feederID == FEEDER_PLAYER_SKIN_HEAD)
  894. {
  895. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount)
  896. {
  897. //return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadIcons[index];
  898. return ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index]));
  899. }
  900. }
  901. else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
  902. {
  903. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount)
  904. {
  905. //return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoIcons[index];
  906. return ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index]));
  907. }
  908. }
  909. else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
  910. {
  911. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount)
  912. {
  913. //return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegIcons[index];
  914. return ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index]));
  915. }
  916. }
  917. else if (feederID == FEEDER_COLORCHOICES)
  918. {
  919. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount)
  920. {
  921. return ui.R_RegisterShaderNoMip( uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorShader[index]);
  922. }
  923. }
  924. /* else if (feederID == FEEDER_ALLMAPS || feederID == FEEDER_MAPS)
  925. {
  926. int actual;
  927. UI_SelectedMap(index, &actual);
  928. index = actual;
  929. if (index >= 0 && index < uiInfo.mapCount)
  930. {
  931. if (uiInfo.mapList[index].levelShot == -1)
  932. {
  933. uiInfo.mapList[index].levelShot = trap_R_RegisterShaderNoMip(uiInfo.mapList[index].imageName);
  934. }
  935. return uiInfo.mapList[index].levelShot;
  936. }
  937. }
  938. */
  939. return 0;
  940. }
  941. void setArrowX(itemDef_t * arrowcontrol, int xloc)
  942. {
  943. arrowcontrol->window.rect.x = xloc;
  944. }
  945. /*
  946. =================
  947. CreateNextSaveName
  948. =================
  949. */
  950. static int CreateNextSaveName(char *fileName)
  951. {
  952. int i;
  953. // Loop through all the save games and look for the first open name
  954. for (i=0;i<MAX_SAVELOADFILES;i++)
  955. {
  956. Com_sprintf( fileName, MAX_SAVELOADNAME, "jedi_%02d", i );
  957. if (!ui.SG_GetSaveGameComment(fileName, NULL, NULL))
  958. {
  959. return qtrue;
  960. }
  961. }
  962. return qfalse;
  963. }
  964. /*
  965. ===============
  966. UI_DeferMenuScript
  967. Return true if the menu script should be deferred for later
  968. ===============
  969. */
  970. static qboolean UI_DeferMenuScript ( const char **args )
  971. {
  972. const char* name;
  973. // Whats the reason for being deferred?
  974. if (!String_Parse(args, &name))
  975. {
  976. return qfalse;
  977. }
  978. if( !Q_stricmp ( name, "always" ) )
  979. {
  980. return qtrue;
  981. }
  982. // Handle the custom cases
  983. if ( !Q_stricmp ( name, "VideoSetup" ) )
  984. {
  985. const char* warningMenuName;
  986. qboolean deferred;
  987. // No warning menu specified
  988. if ( !String_Parse(args, &warningMenuName) )
  989. {
  990. return qfalse;
  991. }
  992. // Defer if the video options were modified
  993. deferred = Cvar_VariableIntegerValue( "ui_r_modified" ) ? qtrue : qfalse;
  994. if ( deferred )
  995. {
  996. // Open the warning menu
  997. Menus_OpenByName(warningMenuName);
  998. }
  999. return deferred;
  1000. }
  1001. //JLF
  1002. #ifdef _XBOX
  1003. /*
  1004. if ( !Q_stricmp ( name, "ProfileSave" ) )
  1005. {
  1006. const char* warningMenuName;
  1007. qboolean deferred;
  1008. // No warning menu specified
  1009. if ( !String_Parse(args, &warningMenuName) )
  1010. {
  1011. return qfalse;
  1012. }
  1013. // Defer if the video options were modified
  1014. deferred = Cvar_VariableIntegerValue( "ui_profileSaveNeeded" ) ? qtrue : qfalse;
  1015. if ( deferred )
  1016. {
  1017. // Open the warning menu
  1018. Menus_OpenByName(warningMenuName);
  1019. }
  1020. return deferred;
  1021. }
  1022. */
  1023. #endif
  1024. return qfalse;
  1025. }
  1026. void ui_DeleteGame()
  1027. {
  1028. if (s_savedata[s_savegame.currentLine].currentSaveFileName) // A line was chosen
  1029. {
  1030. #ifndef FINAL_BUILD
  1031. ui.Printf( va("%s\n","Attempting to delete game"));
  1032. #endif
  1033. strcpy(g_loadsaveGameName,s_savedata[s_savegame.currentLine].currentSaveFileName);
  1034. g_loadsaveGameNameInitialized = qtrue;
  1035. ui.Cmd_ExecuteText( EXEC_NOW, va("wipe file\n"));//%s\n", s_savedata[s_savegame.currentLine].currentSaveFileName));
  1036. if( (s_savegame.currentLine>0) && ((s_savegame.currentLine+1) == s_savegame.saveFileCnt) )
  1037. {
  1038. s_savegame.currentLine--;
  1039. // yeah this is a pretty bad hack
  1040. // adjust cursor position of listbox so correct item is highlighted
  1041. UI_AdjustSaveGameListBox( s_savegame.currentLine );
  1042. }
  1043. // ReadSaveDirectory(); //refresh
  1044. s_savegame.saveFileCnt = -1; //force a refresh at drawtime
  1045. }
  1046. }
  1047. void ui_SaveGame()
  1048. {
  1049. char fileName[MAX_SAVELOADNAME];
  1050. char description[64];
  1051. // Create a new save game
  1052. // if ( !s_savedata[s_savegame.currentLine].currentSaveFileName) // No line was chosen
  1053. {
  1054. //JLF MPNOTUSED
  1055. #ifdef _XBOX
  1056. strcpy(fileName, "JKSG3");
  1057. #else
  1058. CreateNextSaveName(fileName);
  1059. #endif
  1060. }
  1061. // else // Overwrite a current save game? Ask first.
  1062. {
  1063. // s_savegame.yes.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
  1064. // s_savegame.no.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
  1065. // strcpy(fileName,s_savedata[s_savegame.currentLine].currentSaveFileName);
  1066. // s_savegame.awaitingSave = qtrue;
  1067. // s_savegame.deletegame.generic.flags = QMF_GRAYED; // Turn off delete button
  1068. // break;
  1069. }
  1070. // Save description line
  1071. ui.Cvar_VariableStringBuffer("ui_gameDesc",description,sizeof(description));
  1072. ui.SG_StoreSaveGameComment(description);
  1073. ui.Cmd_ExecuteText( EXEC_APPEND, va("save %s\n", fileName));
  1074. // s_savegame.saveFileCnt = -1; //force a refresh the next time around
  1075. }
  1076. void openDashBoardMemory()
  1077. {
  1078. // TCR C4-3 Cleanup Support
  1079. // Launch to the Dash memory area to clean up
  1080. // Reboot to Dash
  1081. LAUNCH_DATA ld;
  1082. memset(&ld, 0, sizeof(ld));
  1083. PLD_LAUNCH_DASHBOARD pDash = (PLD_LAUNCH_DASHBOARD) &ld;
  1084. pDash->dwReason = XLD_LAUNCH_DASHBOARD_MEMORY;
  1085. char * path = NULL;
  1086. pDash->dwContext = 0;
  1087. pDash->dwParameter1 = 'U';
  1088. pDash->dwParameter2 = SG_SaveGameSize() + SETTINGS_NUM_BLOCKS;
  1089. S_Shutdown();
  1090. // Similarly, kill off the streaming thread
  1091. extern void Sys_StreamShutdown(void);
  1092. Sys_StreamShutdown();
  1093. XLaunchNewImage(path, &ld);
  1094. // LD_LAUNCH_DASHBOARD LaunchDash;
  1095. // LaunchDash.dwReason = XLD_LAUNCH_DASHBOARD_MEMORY;
  1096. // LaunchDash.dwContext = 0;
  1097. // LaunchDash.dwParameter1 = DWORD( 'U');
  1098. // LaunchDash.dwParameter2 = SG_SaveGameSize();
  1099. // XLaunchNewImage( NULL, (PLAUNCH_DATA)(&LaunchDash) );
  1100. // We never get here
  1101. }
  1102. #ifdef XBOX_DEMO
  1103. // Bleh.
  1104. int demoForcePowerLevel[NUM_FORCE_POWERS];
  1105. void UI_DemoSetForceLevels( void )
  1106. {
  1107. if( Cvar_VariableIntegerValue( "t1_mission" ) == 0 ) // Sour
  1108. {// NOTE : always set the uiInfo powers
  1109. // level 1 in all core powers
  1110. demoForcePowerLevel[FP_LEVITATION]=1;
  1111. demoForcePowerLevel[FP_SPEED]=1;
  1112. demoForcePowerLevel[FP_PUSH]=1;
  1113. demoForcePowerLevel[FP_PULL]=1;
  1114. demoForcePowerLevel[FP_SEE]=1;
  1115. demoForcePowerLevel[FP_SABER_OFFENSE]=1;
  1116. demoForcePowerLevel[FP_SABER_DEFENSE]=1;
  1117. demoForcePowerLevel[FP_SABERTHROW]=1;
  1118. // plus these extras
  1119. demoForcePowerLevel[FP_HEAL]=1;
  1120. demoForcePowerLevel[FP_TELEPATHY]=1;
  1121. demoForcePowerLevel[FP_GRIP]=1;
  1122. // and set the rest to zero
  1123. demoForcePowerLevel[FP_ABSORB]=0;
  1124. demoForcePowerLevel[FP_PROTECT]=0;
  1125. demoForcePowerLevel[FP_DRAIN]=0;
  1126. demoForcePowerLevel[FP_LIGHTNING]=0;
  1127. demoForcePowerLevel[FP_RAGE]=0;
  1128. }
  1129. else // Rift
  1130. {
  1131. // level 3 in all core powers
  1132. demoForcePowerLevel[FP_LEVITATION]=3;
  1133. demoForcePowerLevel[FP_SPEED]=3;
  1134. demoForcePowerLevel[FP_PUSH]=3;
  1135. demoForcePowerLevel[FP_PULL]=3;
  1136. demoForcePowerLevel[FP_SEE]=3;
  1137. demoForcePowerLevel[FP_SABER_OFFENSE]=3;
  1138. demoForcePowerLevel[FP_SABER_DEFENSE]=3;
  1139. demoForcePowerLevel[FP_SABERTHROW]=3;
  1140. // plus these extras
  1141. demoForcePowerLevel[FP_HEAL]=1;
  1142. demoForcePowerLevel[FP_TELEPATHY]=1;
  1143. demoForcePowerLevel[FP_GRIP]=2;
  1144. demoForcePowerLevel[FP_LIGHTNING]=1;
  1145. demoForcePowerLevel[FP_PROTECT]=1;
  1146. // and set the rest to zero
  1147. demoForcePowerLevel[FP_ABSORB]=0;
  1148. demoForcePowerLevel[FP_DRAIN]=0;
  1149. demoForcePowerLevel[FP_RAGE]=0;
  1150. }
  1151. }
  1152. #endif
  1153. /*
  1154. ===============
  1155. UI_RunMenuScript
  1156. ===============
  1157. */
  1158. static qboolean UI_RunMenuScript ( const char **args )
  1159. {
  1160. const char *name, *name2,*mapName,*menuName,*warningMenuName;
  1161. if (String_Parse(args, &name))
  1162. {
  1163. if (Q_stricmp(name, "resetdefaults") == 0)
  1164. {
  1165. UI_ResetDefaults();
  1166. }
  1167. else if (Q_stricmp(name, "saveControls") == 0)
  1168. {
  1169. Controls_SetConfig(qtrue);
  1170. }
  1171. else if (Q_stricmp(name, "loadControls") == 0)
  1172. {
  1173. Controls_GetConfig();
  1174. }
  1175. else if (Q_stricmp(name, "clearError") == 0)
  1176. {
  1177. Cvar_Set("com_errorMessage", "");
  1178. }
  1179. //possibly make a separate readsavedirectory call that does it immediately
  1180. else if (Q_stricmp(name, "ReadSaveDirectory") == 0)
  1181. {
  1182. s_savegame.saveFileCnt = -1; //force a refresh at drawtime
  1183. }
  1184. else if (Q_stricmp(name, "loadAuto") == 0)
  1185. {
  1186. // Menus_CloseAll();
  1187. UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
  1188. ui.Cmd_ExecuteText( EXEC_APPEND, "wait ; wait ; wait ; wait ; load auto\n"); //load game menu
  1189. }
  1190. else if (Q_stricmp(name, "loadgame") == 0)
  1191. {
  1192. if (s_savedata[s_savegame.currentLine].currentSaveFileName)
  1193. {
  1194. // Menus_CloseAll();
  1195. UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
  1196. // the 'load' call is broken for levelnames that have spaces
  1197. // the global variable 'g_loadGameName' will carry the level name through
  1198. ui.Cmd_ExecuteText( EXEC_APPEND, va("wait ; wait ; wait ; wait ; load level\n"));
  1199. strcpy(g_loadsaveGameName,s_savedata[s_savegame.currentLine].currentSaveFileName);
  1200. g_loadsaveGameNameInitialized = qtrue;
  1201. }
  1202. }
  1203. else if (Q_stricmp(name, "deletegame") == 0)
  1204. {
  1205. ui_DeleteGame();
  1206. }
  1207. else if (Q_stricmp(name, "savegame") == 0)
  1208. {
  1209. ui_SaveGame();
  1210. }
  1211. else if (Q_stricmp(name, "checkforoverwrite") == 0)
  1212. {
  1213. if(s_savegame.saveFileCnt == MAX_SAVELOADFILES && !s_savegame.currentLine) // check to see if there are enough slots
  1214. {
  1215. // No free slots
  1216. Cvar_Set( "ui_overwriting", "3");
  1217. }
  1218. else
  1219. {
  1220. char fileName[MAX_SAVELOADNAME];
  1221. char description[64];
  1222. if (svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
  1223. {
  1224. Cvar_Set( "ui_overwriting", "666");
  1225. }
  1226. else if ( s_savegame.currentLine || (1== Cvar_VariableIntegerValue("noNewSaveGameAvailable")&& s_savegame.saveFileCnt>0))
  1227. {
  1228. // On an existing savegame
  1229. Cvar_Set( "ui_overwriting", "1");
  1230. }
  1231. else if ( SG_BlocksLeft() < SG_SaveGameSize())
  1232. {
  1233. // Insufficient space
  1234. blocksNeeded = SG_SaveGameSize() - SG_BlocksLeft();
  1235. Cvar_Set( "ui_overwriting", "2");
  1236. }
  1237. else
  1238. {
  1239. // Everything ok
  1240. Cvar_Set( "ui_overwriting", "0");
  1241. }
  1242. }
  1243. }
  1244. else if (Q_stricmp(name, "loadgameselect") == 0)
  1245. {
  1246. if ( trap_Cvar_VariableValue("cl_paused")>0 )
  1247. { //popup the confirmation
  1248. UI_xboxErrorPopup( XB_POPUP_LOAD_CONFIRM );
  1249. }
  1250. else
  1251. {
  1252. itemDef_t item;
  1253. item.parent = Menu_GetFocused();
  1254. item.window.flags = 0;
  1255. Item_RunScript(&item, "uiScript loadgame");
  1256. }
  1257. }
  1258. else if (Q_stricmp(name, "LoadMods") == 0)
  1259. {
  1260. UI_LoadMods();
  1261. }
  1262. else if (Q_stricmp(name, "RunMod") == 0)
  1263. {
  1264. if (uiInfo.modList[uiInfo.modIndex].modName)
  1265. {
  1266. Cvar_Set( "fs_game", uiInfo.modList[uiInfo.modIndex].modName);
  1267. extern void FS_Restart( void );
  1268. FS_Restart();
  1269. Cbuf_ExecuteText( EXEC_APPEND, "vid_restart;" );
  1270. }
  1271. }
  1272. else if (Q_stricmp(name, "Quit") == 0)
  1273. {
  1274. Cbuf_ExecuteText( EXEC_NOW, "quit");
  1275. }
  1276. else if (Q_stricmp(name, "Controls") == 0)
  1277. {
  1278. Cvar_Set( "cl_paused", "1" );
  1279. trap_Key_SetCatcher( KEYCATCH_UI );
  1280. Menus_CloseAll();
  1281. Menus_ActivateByName("setup_menu2");
  1282. }
  1283. else if (Q_stricmp(name, "Leave") == 0)
  1284. {
  1285. Cbuf_ExecuteText( EXEC_APPEND, "disconnect\n" );
  1286. trap_Key_SetCatcher( KEYCATCH_UI );
  1287. Menus_CloseAll();
  1288. //Menus_ActivateByName("mainMenu");
  1289. }
  1290. else if (Q_stricmp(name, "getvideosetup") == 0)
  1291. {
  1292. UI_GetVideoSetup ( );
  1293. }
  1294. else if (Q_stricmp(name, "updatevideosetup") == 0)
  1295. {
  1296. UI_UpdateVideoSetup ( );
  1297. }
  1298. else if (Q_stricmp(name, "nextDataPadForcePower") == 0)
  1299. {
  1300. ui.Cmd_ExecuteText( EXEC_NOW, "dpforcenext\n");
  1301. extern void CG_SetDataPadForceText( void );
  1302. CG_SetDataPadForceText();
  1303. }
  1304. else if (Q_stricmp(name, "prevDataPadForcePower") == 0)
  1305. {
  1306. ui.Cmd_ExecuteText( EXEC_NOW, "dpforceprev\n");
  1307. extern void CG_SetDataPadForceText( void );
  1308. CG_SetDataPadForceText();
  1309. }
  1310. else if (Q_stricmp(name, "nextDataPadWeapon") == 0)
  1311. {
  1312. ui.Cmd_ExecuteText( EXEC_NOW, "dpweapnext\n");
  1313. extern void CG_SetDataPadWeaponText( void );
  1314. CG_SetDataPadWeaponText();
  1315. }
  1316. else if (Q_stricmp(name, "prevDataPadWeapon") == 0)
  1317. {
  1318. ui.Cmd_ExecuteText( EXEC_NOW, "dpweapprev\n");
  1319. extern void CG_SetDataPadWeaponText( void );
  1320. CG_SetDataPadWeaponText();
  1321. }
  1322. else if (Q_stricmp(name, "nextDataPadInventory") == 0)
  1323. {
  1324. ui.Cmd_ExecuteText( EXEC_APPEND, "dpinvnext\n");
  1325. }
  1326. else if (Q_stricmp(name, "prevDataPadInventory") == 0)
  1327. {
  1328. ui.Cmd_ExecuteText( EXEC_APPEND, "dpinvprev\n");
  1329. }
  1330. else if (Q_stricmp(name, "checkvid1data") == 0) // Warn user data has changed before leaving screen?
  1331. {
  1332. String_Parse(args, &menuName);
  1333. String_Parse(args, &warningMenuName);
  1334. UI_CheckVid1Data(menuName,warningMenuName);
  1335. }
  1336. else if (Q_stricmp(name, "startgame") == 0)
  1337. {
  1338. Menus_CloseAll();
  1339. if ( Cvar_VariableIntegerValue("com_demo") )
  1340. {
  1341. ui.Cmd_ExecuteText( EXEC_APPEND, "map demo\n");
  1342. }
  1343. else
  1344. {
  1345. ui.Cmd_ExecuteText( EXEC_APPEND, "map yavin1\n");
  1346. }
  1347. }
  1348. else if (Q_stricmp(name, "startmap") == 0)
  1349. {
  1350. Menus_CloseAll();
  1351. String_Parse(args, &mapName);
  1352. ui.Cmd_ExecuteText( EXEC_APPEND, va("maptransition %s\n",mapName));
  1353. }
  1354. else if (Q_stricmp(name, "closeingame") == 0)
  1355. {
  1356. trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );
  1357. trap_Key_ClearStates();
  1358. Cvar_Set( "cl_paused", "0" );
  1359. Menus_CloseAll();
  1360. if (1 == Cvar_VariableIntegerValue("ui_missionfailed"))
  1361. {
  1362. Menus_ActivateByName("missionfailed_menu");
  1363. ui.Key_SetCatcher( KEYCATCH_UI );
  1364. }
  1365. else
  1366. {
  1367. Menus_ActivateByName("mainhud");
  1368. }
  1369. }
  1370. else if (Q_stricmp(name, "closedatapad") == 0)
  1371. {
  1372. trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );
  1373. trap_Key_ClearStates();
  1374. Cvar_Set( "cl_paused", "0" );
  1375. Menus_CloseAll();
  1376. Menus_ActivateByName("mainhud");
  1377. Cvar_Set( "cg_updatedDataPadForcePower1", "0" );
  1378. Cvar_Set( "cg_updatedDataPadForcePower2", "0" );
  1379. Cvar_Set( "cg_updatedDataPadForcePower3", "0" );
  1380. Cvar_Set( "cg_updatedDataPadObjective", "0" );
  1381. }
  1382. else if (Q_stricmp(name, "closesabermenu") == 0)
  1383. {
  1384. // if we're in the saber menu when creating a character, close this down
  1385. if( !Cvar_VariableIntegerValue( "saber_menu" ) )
  1386. {
  1387. Menus_CloseByName( "saberMenu" );
  1388. Menus_OpenByName( "characterMenu" );
  1389. }
  1390. }
  1391. else if (Q_stricmp(name, "clearmouseover") == 0)
  1392. {
  1393. itemDef_t *item;
  1394. menuDef_t *menu = Menu_GetFocused();
  1395. if (menu)
  1396. {
  1397. const char *itemName;
  1398. String_Parse(args, &itemName);
  1399. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, itemName);
  1400. if (item)
  1401. {
  1402. item->window.flags &= ~WINDOW_MOUSEOVER;
  1403. }
  1404. }
  1405. }
  1406. else if (Q_stricmp(name, "setMovesListDefault") == 0)
  1407. {
  1408. uiInfo.movesTitleIndex = 2;
  1409. }
  1410. else if (Q_stricmp(name, "resetMovesDesc") == 0)
  1411. {
  1412. menuDef_t *menu = Menu_GetFocused();
  1413. itemDef_t *item;
  1414. if (menu)
  1415. {
  1416. item = (itemDef_s *) Menu_FindItemByName(menu, "item_desc");
  1417. if (item)
  1418. {
  1419. listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
  1420. if( listPtr )
  1421. {
  1422. listPtr->cursorPos = 0;
  1423. listPtr->startPos = 0;
  1424. }
  1425. item->cursorPos = 0;
  1426. }
  1427. }
  1428. }
  1429. else if (Q_stricmp(name, "resetMovesList") == 0)
  1430. {
  1431. menuDef_t *menu;
  1432. menu = Menus_FindByName("datapadMovesMenu");
  1433. //update saber models
  1434. if (menu)
  1435. {
  1436. itemDef_t *item;
  1437. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  1438. if (item)
  1439. {
  1440. UI_SaberAttachToChar( item );
  1441. }
  1442. }
  1443. Cvar_Set( "ui_move_desc", " " );
  1444. }
  1445. // else if (Q_stricmp(name, "setanisotropicmax") == 0)
  1446. // {
  1447. // r_ext_texture_filter_anisotropic->value;
  1448. // }
  1449. else if (Q_stricmp(name, "setMoveCharacter") == 0)
  1450. {
  1451. itemDef_t *item;
  1452. menuDef_t *menu;
  1453. modelDef_t *modelPtr;
  1454. char skin[MAX_QPATH];
  1455. UI_GetCharacterCvars();
  1456. UI_GetSaberCvars();
  1457. uiInfo.movesTitleIndex = 0;
  1458. menu = Menus_FindByName("datapadMovesMenu");
  1459. if (menu)
  1460. {
  1461. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  1462. if (item)
  1463. {
  1464. modelPtr = (modelDef_t*)item->typeData;
  1465. if (modelPtr)
  1466. {
  1467. uiInfo.movesBaseAnim = datapadMoveTitleBaseAnims[uiInfo.movesTitleIndex];
  1468. ItemParse_model_g2anim_go( item, uiInfo.movesBaseAnim );
  1469. uiInfo.moveAnimTime = 0 ;
  1470. DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
  1471. Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
  1472. Cvar_VariableString ( "g_char_model"),
  1473. Cvar_VariableString ( "g_char_skin_head"),
  1474. Cvar_VariableString ( "g_char_skin_torso"),
  1475. Cvar_VariableString ( "g_char_skin_legs")
  1476. );
  1477. ItemParse_model_g2skin_go( item, skin );
  1478. UI_SaberAttachToChar( item );
  1479. }
  1480. }
  1481. }
  1482. }
  1483. else if (Q_stricmp(name, "glCustom") == 0)
  1484. {
  1485. Cvar_Set("ui_r_glCustom", "4");
  1486. }
  1487. else if (Q_stricmp(name, "character") == 0)
  1488. {
  1489. UI_UpdateCharacter( qfalse );
  1490. }
  1491. else if (Q_stricmp(name, "characterchanged") == 0)
  1492. {
  1493. UI_UpdateCharacter( qtrue );
  1494. }
  1495. else if (Q_stricmp(name, "char_skin") == 0)
  1496. {
  1497. UI_UpdateCharacterSkin();
  1498. }
  1499. else if (Q_stricmp(name, "saber_type") == 0)
  1500. {
  1501. UI_UpdateSaberType();
  1502. }
  1503. else if (Q_stricmp(name, "saber_hilt") == 0)
  1504. {
  1505. UI_UpdateSaberHilt( qfalse );
  1506. }
  1507. else if (Q_stricmp(name, "saber_color") == 0)
  1508. {
  1509. // UI_UpdateSaberColor( qfalse );
  1510. }
  1511. else if (Q_stricmp(name, "saber2_hilt") == 0)
  1512. {
  1513. UI_UpdateSaberHilt( qtrue );
  1514. }
  1515. else if (Q_stricmp(name, "saber2_color") == 0)
  1516. {
  1517. // UI_UpdateSaberColor( qtrue );
  1518. }
  1519. else if (Q_stricmp(name, "updatecharcvars") == 0)
  1520. {
  1521. UI_UpdateCharacterCvars();
  1522. }
  1523. else if (Q_stricmp(name, "getcharcvars") == 0)
  1524. {
  1525. UI_GetCharacterCvars();
  1526. }
  1527. else if (Q_stricmp(name, "updatesabercvars") == 0)
  1528. {
  1529. UI_UpdateSaberCvars();
  1530. }
  1531. else if (Q_stricmp(name, "getsabercvars") == 0)
  1532. {
  1533. UI_GetSaberCvars();
  1534. }
  1535. else if (Q_stricmp(name, "resetsabercvardefaults") == 0)
  1536. {
  1537. // NOTE : ONLY do this if saber menu is set properly (ie. first time we enter this menu)
  1538. if( !Cvar_VariableIntegerValue( "saber_menu" ) )
  1539. {
  1540. UI_ResetSaberCvars();
  1541. }
  1542. }
  1543. else if( Q_stricmp(name, "fixforsabercheat") == 0)
  1544. {
  1545. if(strstr(Cvar_Get("g_saber2"," ", 0)->string, "single"))
  1546. {
  1547. extern bool Cheat_ChangeSaber( void );
  1548. Cheat_ChangeSaber();
  1549. Cheat_ChangeSaber();
  1550. }
  1551. }
  1552. else if (Q_stricmp(name, "updatefightingstylechoices") == 0)
  1553. {
  1554. UI_UpdateFightingStyleChoices();
  1555. }
  1556. else if (Q_stricmp(name, "initallocforcepower") == 0)
  1557. {
  1558. const char *forceName;
  1559. String_Parse(args, &forceName);
  1560. UI_InitAllocForcePowers(forceName);
  1561. }
  1562. else if (Q_stricmp(name, "affectforcepowerlevel") == 0)
  1563. {
  1564. const char *forceName;
  1565. String_Parse(args, &forceName);
  1566. UI_AffectForcePowerLevel(forceName);
  1567. }
  1568. else if (Q_stricmp(name, "decrementcurrentforcepower") == 0)
  1569. {
  1570. UI_DecrementCurrentForcePower();
  1571. }
  1572. else if (Q_stricmp(name, "shutdownforcehelp") == 0)
  1573. {
  1574. UI_ShutdownForceHelp();
  1575. }
  1576. else if (Q_stricmp(name, "forcehelpactive") == 0)
  1577. {
  1578. UI_ForceHelpActive();
  1579. }
  1580. else if (Q_stricmp(name, "showforceleveldesc") == 0)
  1581. {
  1582. const char *forceName;
  1583. String_Parse(args, &forceName);
  1584. UI_ShowForceLevelDesc(forceName);
  1585. }
  1586. else if (Q_stricmp(name, "resetforcelevels") == 0)
  1587. {
  1588. UI_ResetForceLevels();
  1589. }
  1590. else if (Q_stricmp(name, "checkforforcecheat") == 0)
  1591. {
  1592. UI_CheckForForceCheat();
  1593. }
  1594. else if (Q_stricmp(name, "weaponhelpactive") == 0)
  1595. {
  1596. UI_WeaponHelpActive();
  1597. }
  1598. // initialize weapon selection screen
  1599. else if (Q_stricmp(name, "initweaponselect") == 0)
  1600. {
  1601. UI_InitWeaponSelect();
  1602. }
  1603. else if(Q_stricmp(name, "setupForceSelect") == 0)
  1604. {
  1605. UI_SetUpForceSelect();
  1606. }
  1607. else if (Q_stricmp(name, "clearweapons") == 0)
  1608. {
  1609. UI_ClearWeapons();
  1610. }
  1611. else if (Q_stricmp(name, "stopgamesounds") == 0)
  1612. {
  1613. trap_S_StopSounds();
  1614. }
  1615. else if (Q_stricmp(name, "loadmissionselectmenu") == 0)
  1616. {
  1617. const char *cvarName;
  1618. String_Parse(args, &cvarName);
  1619. if (cvarName)
  1620. {
  1621. UI_LoadMissionSelectMenu(cvarName);
  1622. }
  1623. }
  1624. else if (Q_stricmp(name, "calcforcestatus") == 0)
  1625. {
  1626. UI_CalcForceStatus();
  1627. }
  1628. else if (Q_stricmp(name, "giveweapon") == 0)
  1629. {
  1630. const char *weaponIndex;
  1631. String_Parse(args, &weaponIndex);
  1632. UI_GiveWeapon(atoi(weaponIndex));
  1633. }
  1634. else if (Q_stricmp(name, "equipweapon") == 0)
  1635. {
  1636. const char *weaponIndex;
  1637. String_Parse(args, &weaponIndex);
  1638. UI_EquipWeapon(atoi(weaponIndex));
  1639. }
  1640. else if (Q_stricmp(name, "addweaponselection") == 0)
  1641. {
  1642. const char *weaponIndex;
  1643. String_Parse(args, &weaponIndex);
  1644. if (!weaponIndex)
  1645. {
  1646. return qfalse;
  1647. }
  1648. const char *ammoIndex;
  1649. String_Parse(args, &ammoIndex);
  1650. if (!ammoIndex)
  1651. {
  1652. return qfalse;
  1653. }
  1654. const char *ammoAmount;
  1655. String_Parse(args, &ammoAmount);
  1656. if (!ammoAmount)
  1657. {
  1658. return qfalse;
  1659. }
  1660. const char *itemName;
  1661. String_Parse(args, &itemName);
  1662. if (!itemName)
  1663. {
  1664. return qfalse;
  1665. }
  1666. const char *litItemName;
  1667. String_Parse(args, &litItemName);
  1668. if (!litItemName)
  1669. {
  1670. return qfalse;
  1671. }
  1672. const char *backgroundName;
  1673. String_Parse(args, &backgroundName);
  1674. if (!backgroundName)
  1675. {
  1676. return qfalse;
  1677. }
  1678. const char *soundfile = NULL;
  1679. String_Parse(args, &soundfile);
  1680. UI_AddWeaponSelection(atoi(weaponIndex),atoi(ammoIndex),atoi(ammoAmount),itemName,litItemName, backgroundName, soundfile);
  1681. }
  1682. else if (Q_stricmp(name, "addthrowweaponselection") == 0)
  1683. {
  1684. const char *weaponIndex;
  1685. String_Parse(args, &weaponIndex);
  1686. if (!weaponIndex)
  1687. {
  1688. return qfalse;
  1689. }
  1690. const char *ammoIndex;
  1691. String_Parse(args, &ammoIndex);
  1692. if (!ammoIndex)
  1693. {
  1694. return qfalse;
  1695. }
  1696. const char *ammoAmount;
  1697. String_Parse(args, &ammoAmount);
  1698. if (!ammoAmount)
  1699. {
  1700. return qfalse;
  1701. }
  1702. const char *itemName;
  1703. String_Parse(args, &itemName);
  1704. if (!itemName)
  1705. {
  1706. return qfalse;
  1707. }
  1708. const char *litItemName;
  1709. String_Parse(args, &litItemName);
  1710. if (!litItemName)
  1711. {
  1712. return qfalse;
  1713. }
  1714. const char *backgroundName;
  1715. String_Parse(args, &backgroundName);
  1716. if (!backgroundName)
  1717. {
  1718. return qfalse;
  1719. }
  1720. const char *soundfile;
  1721. String_Parse(args, &soundfile);
  1722. UI_AddThrowWeaponSelection(atoi(weaponIndex),atoi(ammoIndex),atoi(ammoAmount),itemName,litItemName,backgroundName, soundfile);
  1723. }
  1724. else if (Q_stricmp(name, "removeweaponselection") == 0)
  1725. {
  1726. const char *weaponIndex;
  1727. String_Parse(args, &weaponIndex);
  1728. if (weaponIndex)
  1729. {
  1730. UI_RemoveWeaponSelection(atoi(weaponIndex));
  1731. }
  1732. }
  1733. else if (Q_stricmp(name, "removethrowweaponselection") == 0)
  1734. {
  1735. UI_RemoveThrowWeaponSelection();
  1736. }
  1737. else if (Q_stricmp(name, "normalthrowselection") == 0)
  1738. {
  1739. UI_NormalThrowSelection();
  1740. }
  1741. else if (Q_stricmp(name, "highlightthrowselection") == 0)
  1742. {
  1743. UI_HighLightThrowSelection();
  1744. }
  1745. else if (Q_stricmp(name, "normalweaponselection") == 0)
  1746. {
  1747. const char *slotIndex;
  1748. String_Parse(args, &slotIndex);
  1749. if (!slotIndex)
  1750. {
  1751. return qfalse;
  1752. }
  1753. UI_NormalWeaponSelection(atoi(slotIndex));
  1754. }
  1755. else if (Q_stricmp(name, "highlightweaponselection") == 0)
  1756. {
  1757. const char *slotIndex;
  1758. String_Parse(args, &slotIndex);
  1759. if (!slotIndex)
  1760. {
  1761. return qfalse;
  1762. }
  1763. UI_HighLightWeaponSelection(atoi(slotIndex));
  1764. }
  1765. else if (Q_stricmp(name, "clearinventory") == 0)
  1766. {
  1767. UI_ClearInventory();
  1768. }
  1769. else if (Q_stricmp(name, "giveinventory") == 0)
  1770. {
  1771. const char *inventoryIndex,*amount;
  1772. String_Parse(args, &inventoryIndex);
  1773. String_Parse(args, &amount);
  1774. UI_GiveInventory(atoi(inventoryIndex),atoi(amount));
  1775. }
  1776. else if (Q_stricmp(name, "updatefightingstyle") == 0)
  1777. {
  1778. UI_UpdateFightingStyle();
  1779. }
  1780. else if (Q_stricmp(name, "update") == 0)
  1781. {
  1782. if (String_Parse(args, &name2))
  1783. {
  1784. UI_Update(name2);
  1785. }
  1786. else
  1787. {
  1788. Com_Printf("update missing cmd\n");
  1789. }
  1790. }
  1791. else if (Q_stricmp(name, "load_quick") == 0)
  1792. {
  1793. ui.Cmd_ExecuteText(EXEC_APPEND,"load quick\n");
  1794. }
  1795. else if (Q_stricmp(name, "load_auto") == 0)
  1796. {
  1797. if ( trap_Cvar_VariableValue("cl_paused")>0 )
  1798. { //popup the confirmation
  1799. UI_xboxErrorPopup( XB_POPUP_LOAD_CONFIRM_CHECKPOINT );
  1800. }
  1801. else
  1802. {
  1803. ui.Cmd_ExecuteText(EXEC_APPEND,"load *respawn\n"); //death menu, might load a saved game instead if they just loaded on this map
  1804. }
  1805. }
  1806. else if (Q_stricmp(name, "load_auto_failed") == 0)
  1807. {
  1808. // Crazy case, we put up the Load Game screen here, then the popup over it.
  1809. Menus_CloseAll();
  1810. Cvar_Set( "returnmenu", "missionfailed_menu" );
  1811. Cvar_Set( "cl_paused", "1" );
  1812. Cvar_Set( "ui_missionfailed", "1" );
  1813. Cvar_Set( "ui_frontEnd", "1" );
  1814. #ifdef XBOX_DEMO
  1815. // For the demo (which should never show the load game screen)
  1816. // we show the pause menu instead:
  1817. Menus_ActivateByName( "ingameMainMenu" );
  1818. #else
  1819. Menus_ActivateByName( "loadMenu" );
  1820. #endif
  1821. UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
  1822. ui.Cmd_ExecuteText(EXEC_APPEND,"wait ; wait ; wait ; wait ; load *respawn\n"); //death menu, might load a saved game instead if they just loaded on this map
  1823. }
  1824. else if (Q_stricmp(name, "decrementforcepowerlevel") == 0)
  1825. {
  1826. UI_DecrementForcePowerLevel();
  1827. }
  1828. else if (Q_stricmp(name, "resetcharacterlistboxes") == 0)
  1829. {
  1830. UI_ResetCharacterListBoxes();
  1831. }
  1832. #ifdef _XBOX
  1833. else if (Q_stricmp(name, "multiplayer") == 0)
  1834. {
  1835. extern void Sys_Reboot( const char *reason, const void *pData );
  1836. Sys_Reboot("multiplayer", NULL);
  1837. }
  1838. //JLF MPMOVED
  1839. #if 0
  1840. else if (Q_stricmp(name, "loadprofile") == 0)
  1841. {
  1842. if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
  1843. {
  1844. Menus_CloseAll();
  1845. ui.Cmd_ExecuteText( EXEC_APPEND, va("loadprofile %s\n", s_ProfileData[s_playerProfile.currentLine].currentProfileName));
  1846. }
  1847. }
  1848. else if (Q_stricmp(name, "saveprofile") == 0)
  1849. {
  1850. //if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
  1851. {
  1852. Menus_CloseAll();
  1853. // ui.Cmd_ExecuteText( EXEC_APPEND, va("saveprofile %s\n", "test"/*s_ProfileData[s_playerProfile.currentLine].currentProfileName*/));
  1854. }
  1855. }
  1856. else if (Q_stricmp(name, "initprofile") == 0)
  1857. {
  1858. //if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
  1859. {
  1860. Menus_CloseAll();
  1861. ui.Cmd_ExecuteText( EXEC_APPEND, va("initprofile \n" ));
  1862. }
  1863. }
  1864. else if (Q_stricmp(name, "deleteprofile") == 0)
  1865. {
  1866. //if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
  1867. {
  1868. Menus_CloseAll();
  1869. ui.Cmd_ExecuteText( EXEC_APPEND, va("deleteprofile %s\n","test" ));
  1870. }
  1871. }
  1872. else if (Q_stricmp(name, "testandsaveprofile") == 0)
  1873. {
  1874. if (Cvar_VariableIntegerValue("ui_profileSaveNeeded"))// && (*s_file_desc_field.field.buffer))
  1875. {
  1876. ui.Cmd_ExecuteText( EXEC_APPEND, va("saveprofile %s\n",s_ProfileData[s_playerProfile.currentLine].currentProfileName ));
  1877. Cvar_Set("ui_profileSaveNeeded","0");
  1878. }
  1879. }
  1880. #endif
  1881. //JLF
  1882. else if (Q_stricmp(name, "processForDiskSpace") == 0)
  1883. {
  1884. // Kick off the crazy sequence!
  1885. XB_Startup( STARTUP_LOAD_SETTINGS );
  1886. }
  1887. else if (Q_stricmp(name, "initListBoxes") == 0)
  1888. {
  1889. ui_ShowDeleteActive = qfalse;
  1890. //find the listboxes for this level
  1891. menuDef_t * menu = Menu_GetFocused(); // Get current menu
  1892. if (menu)
  1893. {
  1894. int i;
  1895. for (i = 0; i < menu->itemCount; i++)
  1896. {
  1897. listBoxDef_t *listPtr;
  1898. //Item_ValidateTypeData(item);
  1899. if (menu->items[i]->type == ITEM_TYPE_LISTBOX)
  1900. {
  1901. listPtr = (listBoxDef_t*)menu->items[i]->typeData;
  1902. if (listPtr)
  1903. {
  1904. listPtr->cursorPos = 0;
  1905. listPtr->startPos = 0;
  1906. menu->items[i]->cursorPos =0;
  1907. if (menu->items[i]->special== FEEDER_SAVEGAMES)
  1908. {
  1909. UI_FeederSelection( FEEDER_SAVEGAMES , 0, NULL );
  1910. }
  1911. }
  1912. }
  1913. }
  1914. }
  1915. }
  1916. else if (Q_stricmp(name, "confirmdelete") == 0)
  1917. {
  1918. // User is already logged on - is trying to back out. Get confirmation
  1919. UI_xboxErrorPopup( XB_POPUP_DELETE_CONFIRM );
  1920. }
  1921. else if (Q_stricmp(name, "xboxErrorResponse") == 0)
  1922. {
  1923. // User closed the Xbox Error Popup in some way. Do TheRightThing(TM)
  1924. UI_xboxPopupResponse();
  1925. }
  1926. else if (Q_stricmp(name, "genericpopup") == 0)
  1927. {
  1928. const char *menuid;
  1929. String_Parse(args, &menuid);
  1930. if(Q_stricmp(menuid, "savecomplete") == 0)
  1931. {
  1932. UI_xboxErrorPopup( XB_POPUP_SAVE_COMPLETE );
  1933. }
  1934. else if(Q_stricmp(menuid, "overwriteconfirm") == 0)
  1935. {
  1936. int confirmType = Cvar_VariableIntegerValue( "ui_overwriting" );
  1937. if( confirmType == 3 )
  1938. {
  1939. UI_xboxErrorPopup( XB_POPUP_TOO_MANY_SAVES );
  1940. }
  1941. else if( confirmType == 1 )
  1942. {
  1943. UI_xboxErrorPopup( XB_POPUP_OVERWRITE_CONFIRM );
  1944. }
  1945. else if( confirmType == 2 )
  1946. {
  1947. UI_xboxErrorPopup( XB_POPUP_DISKFULL_DURING_SAVE );
  1948. }
  1949. else if( confirmType == 666)
  1950. {
  1951. UI_xboxErrorPopup( XB_POPUP_YOU_ARE_DEAD );
  1952. }
  1953. }
  1954. else if(Q_stricmp(menuid, "quitconfirm") == 0)
  1955. {
  1956. UI_xboxErrorPopup( XB_POPUP_QUIT_CONFIRM );
  1957. }
  1958. else if(Q_stricmp(menuid, "saving") == 0)
  1959. {
  1960. UI_xboxErrorPopup( XB_POPUP_SAVING );
  1961. }
  1962. else if(Q_stricmp(menuid, "confirmNewMission1") == 0)
  1963. {
  1964. UI_xboxErrorPopup( XB_POPUP_CONFIRM_NEW_1 );
  1965. }
  1966. else if(Q_stricmp(menuid, "confirmNewMission2") == 0)
  1967. {
  1968. UI_xboxErrorPopup( XB_POPUP_CONFIRM_NEW_2 );
  1969. }
  1970. else if(Q_stricmp(menuid, "confirmNewMission3") == 0)
  1971. {
  1972. UI_xboxErrorPopup( XB_POPUP_CONFIRM_NEW_3 );
  1973. }
  1974. }
  1975. else if (Q_stricmp(name, "setarrow")==0)
  1976. {
  1977. const char *controlName ;
  1978. const char *arrowControlName ;
  1979. const char * controlText;
  1980. int textwidth;
  1981. int startx;
  1982. itemDef_t * item;
  1983. itemDef_t * arrowControl;
  1984. menuDef_t *menu;
  1985. menu = Menu_GetFocused();
  1986. String_Parse(args, &controlName);
  1987. String_Parse(args, &arrowControlName);
  1988. //get the textwidth from control
  1989. if (menu)
  1990. {
  1991. itemDef_t *item;
  1992. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, controlName);
  1993. if (*(item->text) == '@') // string reference
  1994. {
  1995. controlText = SE_GetString( &(item->text[1]) );
  1996. }
  1997. else
  1998. controlText = item->text;
  1999. textwidth = DC->textWidth( controlText, item->textscale, item->font );
  2000. startx = item->window.rect.x;
  2001. arrowControl = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, arrowControlName);
  2002. setArrowX(arrowControl, textwidth + startx+ ARROW_SPACE);
  2003. }
  2004. }
  2005. else if (Q_stricmp(name, "getControls") == 0)
  2006. {
  2007. // Fetches all controls on the basic controls screen into ui cvars:
  2008. // Inverted aim:
  2009. Cvar_SetValue("ui_mousePitch", (Cvar_VariableValue("m_pitch") >= 0) ? 0 : 1);
  2010. // Thumbstick, buttons, triggers are automatic
  2011. }
  2012. else if (Q_stricmp(name, "setControls") == 0)
  2013. {
  2014. // Assigns all changes made on the basic controls screen:
  2015. char token[MAX_QPATH];
  2016. // Update inverted aim:
  2017. Settings.invertAim[0] = Cvar_VariableIntegerValue( "ui_mousePitch" ) ? false : true;
  2018. Cvar_SetValue( "m_pitch", Settings.invertAim[0] ? 0.022f : -0.022f );
  2019. // update thumbsticks in settings file:
  2020. Settings.thumbstickMode[0] = DC->getCVarValue( "ui_thumbStickMode" );
  2021. // update triggers
  2022. DC->getCVarString( "ui_triggerconfig", token, sizeof(token) );
  2023. if( !Q_stricmp(token, "default") )
  2024. {
  2025. Cbuf_ExecuteText( EXEC_NOW, "exec cfg/triggersConfig0.cfg" );
  2026. Settings.triggerMode[0] = 0;
  2027. }
  2028. else if( !Q_stricmp(token, "southpaw") )
  2029. {
  2030. Cbuf_ExecuteText( EXEC_NOW, "exec cfg/triggersConfig1.cfg" );
  2031. Settings.triggerMode[0] = 1;
  2032. }
  2033. // update buttons
  2034. DC->getCVarString( "ui_buttonconfig", token, sizeof(token) );
  2035. if( !Q_stricmp(token, "weaponsbias") )
  2036. {
  2037. Cbuf_ExecuteText( EXEC_NOW, "exec cfg/spbuttonConfig0.cfg" );
  2038. Settings.buttonMode[0] = 0;
  2039. }
  2040. else if( !Q_stricmp(token, "forcebias") )
  2041. {
  2042. Cbuf_ExecuteText( EXEC_NOW, "exec cfg/spbuttonConfig1.cfg" );
  2043. Settings.buttonMode[0] = 1;
  2044. }
  2045. else if( !Q_stricmp(token, "southpaw") )
  2046. {
  2047. Cbuf_ExecuteText( EXEC_NOW, "exec cfg/spbuttonConfig2.cfg" );
  2048. Settings.buttonMode[0] = 2;
  2049. }
  2050. Settings.Save();
  2051. }
  2052. else if (Q_stricmp(name, "getsettingscvars") == 0)
  2053. {
  2054. // Fetches everything on the advanced controls screen:
  2055. Cvar_SetValue( "ui_useRumble", Cvar_VariableIntegerValue( "in_useRumble" ) );
  2056. Cvar_SetValue( "ui_autolevel", Cvar_VariableIntegerValue( "cl_autolevel" ) );
  2057. Cvar_SetValue( "ui_autoswitch", Cvar_VariableIntegerValue( "cg_autoswitch" ) );
  2058. // Horizontal/vertical
  2059. Cvar_SetValue( "ui_sensitivity", Cvar_VariableValue( "sensitivity" ) );
  2060. Cvar_SetValue( "ui_sensitivityY", Cvar_VariableValue( "sensitivityY" ) );
  2061. }
  2062. else if (Q_stricmp(name, "updatesettingscvars") == 0)
  2063. {
  2064. // Rumble
  2065. Settings.rumble[0] = Cvar_VariableIntegerValue( "ui_useRumble" );
  2066. Cvar_SetValue( "in_useRumble", Settings.rumble[0] );
  2067. // Auto-level
  2068. Settings.autolevel[0] = Cvar_VariableIntegerValue( "ui_autolevel" );
  2069. Cvar_SetValue( "cl_autolevel", Settings.autolevel[0] );
  2070. // Weapon switch
  2071. Settings.autoswitch[0] = Cvar_VariableIntegerValue( "ui_autoswitch" );
  2072. Cvar_SetValue( "cg_autoswitch", Settings.autoswitch[0] );
  2073. // Turn/look
  2074. Settings.sensitivityX[0] = Cvar_VariableValue( "ui_sensitivity" );
  2075. Settings.sensitivityY[0] = Cvar_VariableValue( "ui_sensitivityY" );
  2076. Cvar_SetValue( "sensitivity", Settings.sensitivityX[0] );
  2077. Cvar_SetValue( "sensitivityY", Settings.sensitivityY[0] );
  2078. Settings.Save();
  2079. }
  2080. else if (Q_stricmp(name, "softkeyboardinit") == 0)
  2081. {
  2082. UI_SoftKeyboardInit();
  2083. }
  2084. else if (Q_stricmp(name, "updatevolume") == 0)
  2085. {
  2086. // Store all settings from the audio page:
  2087. Settings.effectsVolume = Cvar_VariableValue( "s_effects_volume" );
  2088. Settings.musicVolume = Cvar_VariableValue( "s_music_volume" );
  2089. Settings.voiceVolume = Cvar_VariableValue( "s_voice_volume" );
  2090. Settings.subtitles = Cvar_VariableIntegerValue( "g_subtitles" );
  2091. Settings.brightness = Cvar_VariableValue( "s_brightness_volume" );
  2092. extern void GLimp_SetGamma(float);
  2093. GLimp_SetGamma(Cvar_VariableValue( "s_brightness_volume" ) / 5.0f);
  2094. Settings.Save();
  2095. }
  2096. else if (Q_stricmp(name, "brightnessChanged") == 0)
  2097. {
  2098. extern void GLimp_SetGamma(float);
  2099. GLimp_SetGamma(Cvar_VariableValue( "s_brightness_volume" ) / 5.0f);
  2100. }
  2101. else if(Q_stricmp(name,"updatemoves") == 0)
  2102. {
  2103. menuDef_t *menu;
  2104. menu = Menus_FindByName("datapadMovesMenu");
  2105. //update saber models
  2106. if (menu)
  2107. {
  2108. itemDef_t *item;
  2109. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  2110. if (item)
  2111. {
  2112. UI_SaberAttachToChar( item );
  2113. }
  2114. }
  2115. UI_UpdateMoves();
  2116. }
  2117. else if(Q_stricmp(name,"updatemovetitles") == 0)
  2118. {
  2119. UI_UpdateMoveTitles();
  2120. }
  2121. else if(Q_stricmp(name, "resetscroll") == 0)
  2122. {
  2123. menuDef_t *menu = Menu_GetFocused();
  2124. if(!menu)
  2125. return qfalse;
  2126. for( int i = 0; i < menu->itemCount; ++i )
  2127. {
  2128. if( menu->items[i]->type == ITEM_TYPE_TEXTSCROLL )
  2129. {
  2130. textScrollDef_t *scrollPtr = (textScrollDef_t*)menu->items[i]->typeData;
  2131. scrollPtr->startPos = 0;
  2132. }
  2133. }
  2134. }
  2135. else if(Q_stricmp(name, "levelselect") == 0)
  2136. {
  2137. const char *action;
  2138. String_Parse(args, &action);
  2139. if (!action)
  2140. return qfalse;
  2141. if (Q_stricmp(action, "init") == 0)
  2142. {
  2143. UI_FeederSelection( FEEDER_LEVELSELECT, 0, NULL );
  2144. }
  2145. else if (Q_stricmp(action, "load") == 0)
  2146. {
  2147. int levelSelectCheat = levelSelectData[levelSelectChoice].forceLevel;
  2148. Cvar_Set("levelSelectCheat", va("%d", levelSelectCheat));
  2149. Cbuf_ExecuteText( EXEC_APPEND, va("map %s\n", levelSelectData[levelSelectChoice].mapname) );
  2150. }
  2151. }
  2152. else if(Q_stricmp(name,"simulateuppress") == 0)
  2153. {
  2154. extern itemDef_t *Menu_SetNextCursorItem(menuDef_t *menu);
  2155. menuDef_t *menu = Menu_GetFocused();
  2156. Menu_SetNextCursorItem(menu);
  2157. }
  2158. else if(Q_stricmp(name,"simulatedownpress") == 0)
  2159. {
  2160. extern itemDef_t *Menu_SetPrevCursorItem(menuDef_t *menu);
  2161. menuDef_t *menu = Menu_GetFocused();
  2162. Menu_SetPrevCursorItem(menu);
  2163. }
  2164. else if(Q_stricmp(name,"setMainController") == 0)
  2165. {
  2166. extern char lastControllerUsed;
  2167. extern void IN_SetMainController(int id);
  2168. IN_SetMainController(lastControllerUsed);
  2169. }
  2170. #endif
  2171. #ifdef XBOX_DEMO
  2172. else if(Q_stricmp(name, "initdemoforce") == 0)
  2173. {
  2174. UI_DemoSetForceLevels();
  2175. }
  2176. else if(Q_stricmp(name, "leaveDemo") == 0)
  2177. {
  2178. extern void Sys_Reboot( const char *reason, const void *pData );
  2179. Sys_Reboot( "demo", NULL );
  2180. }
  2181. else if(Q_stricmp(name, "kioskCheck") == 0)
  2182. {
  2183. // Only do this check once
  2184. static bool firstTime = true;
  2185. // If we were started in kiosk mode (this is a filthy way to determine that)
  2186. // then we should start attract mode immediately:
  2187. extern bool demoTimerAlways;
  2188. extern void PlayDemo( void );
  2189. if( firstTime && demoTimerAlways )
  2190. {
  2191. firstTime = false; // Bad fix for an awful recursion bug
  2192. PlayDemo();
  2193. }
  2194. firstTime = false;
  2195. }
  2196. else if(Q_stricmp(name, "clearplayersave") == 0)
  2197. {
  2198. Cvar_Set( "playersave", "" );
  2199. }
  2200. #endif
  2201. else
  2202. {
  2203. Com_Printf("unknown UI script %s\n", name);
  2204. }
  2205. }
  2206. return qtrue;
  2207. }
  2208. /*
  2209. =================
  2210. UI_GetValue
  2211. =================
  2212. */
  2213. static float UI_GetValue(int ownerDraw)
  2214. {
  2215. return 0;
  2216. }
  2217. //Force Warnings
  2218. typedef enum
  2219. {
  2220. FW_VERY_LIGHT = 0,
  2221. FW_SEMI_LIGHT,
  2222. FW_NEUTRAL,
  2223. FW_SEMI_DARK,
  2224. FW_VERY_DARK
  2225. };
  2226. const char *lukeForceStatusSounds[] =
  2227. {
  2228. "sound/chars/luke/misc/MLUK_03.mp3", // Very Light
  2229. "sound/chars/luke/misc/MLUK_04.mp3", // Semi Light
  2230. "sound/chars/luke/misc/MLUK_05.mp3", // Neutral
  2231. "sound/chars/luke/misc/MLUK_01.mp3", // Semi dark
  2232. "sound/chars/luke/misc/MLUK_02.mp3", // Very dark
  2233. };
  2234. const char *kyleForceStatusSounds[] =
  2235. {
  2236. "sound/chars/kyle/misc/MKYK_05.mp3", // Very Light
  2237. "sound/chars/kyle/misc/MKYK_04.mp3", // Semi Light
  2238. "sound/chars/kyle/misc/MKYK_03.mp3", // Neutral
  2239. "sound/chars/kyle/misc/MKYK_01.mp3", // Semi dark
  2240. "sound/chars/kyle/misc/MKYK_02.mp3", // Very dark
  2241. };
  2242. static void UI_CalcForceStatus(void)
  2243. {
  2244. float lightSide,darkSide,total;
  2245. short who, index=FW_VERY_LIGHT;
  2246. qboolean lukeFlag=qtrue;
  2247. float percent;
  2248. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  2249. char value[256];
  2250. if (!cl)
  2251. {
  2252. return;
  2253. }
  2254. playerState_t* pState = cl->gentity->client;
  2255. if (!cl->gentity || !cl->gentity->client)
  2256. {
  2257. return;
  2258. }
  2259. memset(value, 0, sizeof(value));
  2260. lightSide = pState->forcePowerLevel[FP_HEAL] +
  2261. pState->forcePowerLevel[FP_TELEPATHY] +
  2262. pState->forcePowerLevel[FP_PROTECT] +
  2263. pState->forcePowerLevel[FP_ABSORB];
  2264. darkSide = pState->forcePowerLevel[FP_GRIP] +
  2265. pState->forcePowerLevel[FP_LIGHTNING] +
  2266. pState->forcePowerLevel[FP_RAGE] +
  2267. pState->forcePowerLevel[FP_DRAIN];
  2268. total = lightSide + darkSide;
  2269. percent = lightSide / total;
  2270. who = Q_irand( 0, 100 );
  2271. if (percent >= 0.90f) // 90 - 100%
  2272. {
  2273. index = FW_VERY_LIGHT;
  2274. if (who <50)
  2275. {
  2276. strcpy(value,"vlk"); // Very light Kyle
  2277. lukeFlag = qfalse;
  2278. }
  2279. else
  2280. {
  2281. strcpy(value,"vll"); // Very light Luke
  2282. }
  2283. }
  2284. else if (percent > 0.60f )
  2285. {
  2286. index = FW_SEMI_LIGHT;
  2287. if ( who<50 )
  2288. {
  2289. strcpy(value,"slk"); // Semi-light Kyle
  2290. lukeFlag = qfalse;
  2291. }
  2292. else
  2293. {
  2294. strcpy(value,"sll"); // Semi-light light Luke
  2295. }
  2296. }
  2297. else if (percent > 0.40f )
  2298. {
  2299. index = FW_NEUTRAL;
  2300. if ( who<50 )
  2301. {
  2302. strcpy(value,"ntk"); // Neutral Kyle
  2303. lukeFlag = qfalse;
  2304. }
  2305. else
  2306. {
  2307. strcpy(value,"ntl"); // Netural Luke
  2308. }
  2309. }
  2310. else if (percent > 0.10f )
  2311. {
  2312. index = FW_SEMI_DARK;
  2313. if ( who<50 )
  2314. {
  2315. strcpy(value,"sdk"); // Semi-dark Kyle
  2316. lukeFlag = qfalse;
  2317. }
  2318. else
  2319. {
  2320. strcpy(value,"sdl"); // Semi-Dark Luke
  2321. }
  2322. }
  2323. else
  2324. {
  2325. index = FW_VERY_DARK;
  2326. if ( who<50 )
  2327. {
  2328. strcpy(value,"vdk"); // Very dark Kyle
  2329. lukeFlag = qfalse;
  2330. }
  2331. else
  2332. {
  2333. strcpy(value,"vdl"); // Very Dark Luke
  2334. }
  2335. }
  2336. Cvar_Set("ui_forcestatus", value );
  2337. if (lukeFlag)
  2338. {
  2339. DC->startLocalSound(DC->registerSound(lukeForceStatusSounds[index], qfalse), CHAN_VOICE );
  2340. }
  2341. else
  2342. {
  2343. DC->startLocalSound(DC->registerSound(kyleForceStatusSounds[index], qfalse), CHAN_VOICE );
  2344. }
  2345. }
  2346. /*
  2347. =================
  2348. UI_StopCinematic
  2349. =================
  2350. */
  2351. static void UI_StopCinematic(int handle)
  2352. {
  2353. if (handle >= 0)
  2354. {
  2355. trap_CIN_StopCinematic(handle);
  2356. }
  2357. else
  2358. {
  2359. handle = abs(handle);
  2360. if (handle == UI_MAPCINEMATIC)
  2361. {
  2362. // FIXME - BOB do we need this?
  2363. // if (uiInfo.mapList[ui_currentMap.integer].cinematic >= 0)
  2364. // {
  2365. // trap_CIN_StopCinematic(uiInfo.mapList[ui_currentMap.integer].cinematic);
  2366. // uiInfo.mapList[ui_currentMap.integer].cinematic = -1;
  2367. // }
  2368. }
  2369. else if (handle == UI_NETMAPCINEMATIC)
  2370. {
  2371. // FIXME - BOB do we need this?
  2372. // if (uiInfo.serverStatus.currentServerCinematic >= 0)
  2373. // {
  2374. // trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic);
  2375. // uiInfo.serverStatus.currentServerCinematic = -1;
  2376. // }
  2377. }
  2378. else if (handle == UI_CLANCINEMATIC)
  2379. {
  2380. // FIXME - BOB do we need this?
  2381. // int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
  2382. // if (i >= 0 && i < uiInfo.teamCount)
  2383. // {
  2384. // if (uiInfo.teamList[i].cinematic >= 0)
  2385. // {
  2386. // trap_CIN_StopCinematic(uiInfo.teamList[i].cinematic);
  2387. // uiInfo.teamList[i].cinematic = -1;
  2388. // }
  2389. // }
  2390. }
  2391. }
  2392. }
  2393. static void UI_HandleLoadSelection()
  2394. {
  2395. Cvar_Set("ui_SelectionOK", va("%d",(s_savegame.currentLine < s_savegame.saveFileCnt)) );
  2396. if (s_savegame.currentLine >= s_savegame.saveFileCnt)
  2397. return;
  2398. // Cvar_Set("ui_gameDesc", s_savedata[s_savegame.currentLine].currentSaveFileComments ); // set comment
  2399. bool R_UpdateSaveGameImage(const char *filename);
  2400. //create the correctfilename
  2401. unsigned short saveGameName[filepathlength];
  2402. char directoryInfo[filepathlength];
  2403. char psLocalFilename[filepathlength];
  2404. mbstowcs(saveGameName, s_savedata[s_savegame.currentLine].currentSaveFileName, filepathlength);
  2405. if (ERROR_SUCCESS ==XCreateSaveGame("U:\\", saveGameName, OPEN_EXISTING, 0,directoryInfo, filepathlength))
  2406. {
  2407. strcpy (psLocalFilename , directoryInfo);
  2408. strcat (psLocalFilename , "screenshot.xbx");
  2409. if( !R_UpdateSaveGameImage(psLocalFilename) &&
  2410. !s_savedata[s_savegame.currentLine].screenshotNotify )
  2411. {
  2412. s_savedata[s_savegame.currentLine].screenshotNotify = 1;
  2413. UI_xboxErrorPopup( XB_POPUP_CORRUPT_SCREENSHOT );
  2414. }
  2415. }
  2416. else
  2417. R_UpdateSaveGameImage( "z:\\screenshot.xbx" );
  2418. }
  2419. /*
  2420. =================
  2421. UI_FeederCount
  2422. =================
  2423. */
  2424. static int UI_FeederCount(float feederID)
  2425. {
  2426. #ifdef _XBOX
  2427. //JLF MPNOTNEEDED
  2428. static bool firstSaveRequest = true;
  2429. //JLF MPMOVED
  2430. static bool firstProfileListRequest = true;
  2431. #endif
  2432. if (feederID == FEEDER_SAVEGAMES )
  2433. {
  2434. //JLF MPNOTNEEDED
  2435. #ifdef _XBOX
  2436. if (s_savegame.saveFileCnt == -1 || firstSaveRequest)
  2437. {
  2438. firstSaveRequest = false;
  2439. #else
  2440. if (s_savegame.saveFileCnt == -1)
  2441. {
  2442. #endif
  2443. ReadSaveDirectory(); //refresh
  2444. UI_HandleLoadSelection();
  2445. UI_AdjustSaveGameListBox(s_savegame.currentLine);
  2446. }
  2447. return s_savegame.saveFileCnt;
  2448. }
  2449. //JLF MPMOVED
  2450. #ifdef _XBOX
  2451. else if (feederID == FEEDER_PROFILES )
  2452. {
  2453. // if (s_playerProfile.fileCnt == -1 || firstProfileListRequest)
  2454. // {
  2455. firstProfileListRequest = false;
  2456. // ReadSaveDirectoryProfiles(); //refresh
  2457. // UI_HandleLoadSelection();
  2458. // }
  2459. return s_playerProfile.fileCnt;
  2460. }
  2461. #endif
  2462. // count number of moves for the current title
  2463. else if (feederID == FEEDER_MOVES)
  2464. {
  2465. int count=0,i;
  2466. for (i=0;i<MAX_MOVES;i++)
  2467. {
  2468. if (datapadMoveData[uiInfo.movesTitleIndex][i].title)
  2469. {
  2470. count++;
  2471. }
  2472. }
  2473. return count;
  2474. }
  2475. else if (feederID == FEEDER_MOVES_TITLES)
  2476. {
  2477. return (MD_MOVE_TITLE_MAX);
  2478. }
  2479. else if (feederID == FEEDER_MODS)
  2480. {
  2481. return uiInfo.modCount;
  2482. }
  2483. else if (feederID == FEEDER_LANGUAGES)
  2484. {
  2485. assert( 0 );
  2486. // return uiInfo.languageCount;
  2487. }
  2488. else if (feederID == FEEDER_PLAYER_SPECIES)
  2489. {
  2490. return uiInfo.playerSpeciesCount;
  2491. }
  2492. else if (feederID == FEEDER_PLAYER_SKIN_HEAD)
  2493. {
  2494. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount;
  2495. }
  2496. else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
  2497. {
  2498. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount;
  2499. }
  2500. else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
  2501. {
  2502. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount;
  2503. }
  2504. else if (feederID == FEEDER_COLORCHOICES)
  2505. {
  2506. return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount;
  2507. }
  2508. else if (feederID == FEEDER_LEVELSELECT)
  2509. {
  2510. return levelSelectSize;
  2511. }
  2512. return 0;
  2513. }
  2514. /*
  2515. =================
  2516. UI_FeederSelection
  2517. =================
  2518. */
  2519. static void UI_FeederSelection(float feederID, int index, itemDef_t *item)
  2520. {
  2521. static char info[MAX_STRING_CHARS];
  2522. if (feederID == FEEDER_SAVEGAMES)
  2523. {
  2524. s_savegame.currentLine = index;
  2525. if (s_savedata[s_savegame.saveFileCnt].corrupt = true)
  2526. Cvar_SetValue("ui_FileCorrupt", 1);
  2527. else
  2528. Cvar_SetValue("ui_FileCorrupt", 0);
  2529. if (index ==0 && noNewSaveGameAvailable.integer == 0)
  2530. {
  2531. if (!ui_ShowDeleteActive)
  2532. {
  2533. //there is a 'new save game' index that is highlighted
  2534. Cvar_SetValue("ui_ShowDelete",trap_Cvar_VariableValue("ui_showYdel"));
  2535. Cvar_SetValue("ui_showYdel",0);
  2536. ui_ShowDeleteActive = qtrue;
  2537. Cvar_SetValue( "ui_cancelYScript",1);
  2538. }
  2539. }
  2540. else if (ui_ShowDeleteActive)
  2541. {
  2542. Cvar_SetValue("ui_showYdel",trap_Cvar_VariableValue("ui_ShowDelete"));
  2543. ui_ShowDeleteActive = qfalse;
  2544. Cvar_SetValue("ui_cancelYScript",0);
  2545. }
  2546. storeSGDataDatetoCvar();
  2547. storeSGDataTimetoCvar();
  2548. storeSGDataDiffLeveltoCvar();
  2549. UI_HandleLoadSelection();
  2550. }
  2551. else if (feederID == FEEDER_MOVES)
  2552. {
  2553. itemDef_t *item;
  2554. menuDef_t *menu;
  2555. modelDef_t *modelPtr;
  2556. char skin[MAX_QPATH];
  2557. menu = Menus_FindByName("datapadMovesMenu");
  2558. if (menu)
  2559. {
  2560. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  2561. if (item)
  2562. {
  2563. modelPtr = (modelDef_t*)item->typeData;
  2564. if (modelPtr)
  2565. {
  2566. if (datapadMoveData[uiInfo.movesTitleIndex][index].anim)
  2567. {
  2568. ItemParse_model_g2anim_go( item, datapadMoveData[uiInfo.movesTitleIndex][index].anim );
  2569. uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
  2570. uiInfo.moveAnimTime += uiInfo.uiDC.realTime;
  2571. // Play sound for anim
  2572. if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_FORCE_JUMP)
  2573. {
  2574. DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveJumpSound, CHAN_LOCAL );
  2575. }
  2576. else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_ROLL)
  2577. {
  2578. DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveRollSound, CHAN_LOCAL );
  2579. }
  2580. else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_SABER)
  2581. {
  2582. // Randomly choose one sound
  2583. int soundI = Q_irand( 1, 6 );
  2584. sfxHandle_t *soundPtr;
  2585. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound1;
  2586. if (soundI == 2)
  2587. {
  2588. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound2;
  2589. }
  2590. else if (soundI == 3)
  2591. {
  2592. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound3;
  2593. }
  2594. else if (soundI == 4)
  2595. {
  2596. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound4;
  2597. }
  2598. else if (soundI == 5)
  2599. {
  2600. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound5;
  2601. }
  2602. else if (soundI == 6)
  2603. {
  2604. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound6;
  2605. }
  2606. DC->startLocalSound(*soundPtr, CHAN_LOCAL );
  2607. }
  2608. if (datapadMoveData[uiInfo.movesTitleIndex][index].desc)
  2609. {
  2610. Cvar_Set( "ui_move_desc", datapadMoveData[uiInfo.movesTitleIndex][index].desc);
  2611. }
  2612. Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
  2613. Cvar_VariableString ( "g_char_model"),
  2614. Cvar_VariableString ( "g_char_skin_head"),
  2615. Cvar_VariableString ( "g_char_skin_torso"),
  2616. Cvar_VariableString ( "g_char_skin_legs")
  2617. );
  2618. ItemParse_model_g2skin_go( item, skin );
  2619. }
  2620. }
  2621. }
  2622. }
  2623. }
  2624. else if (feederID == FEEDER_MOVES_TITLES)
  2625. {
  2626. itemDef_t *item;
  2627. menuDef_t *menu;
  2628. modelDef_t *modelPtr;
  2629. uiInfo.movesTitleIndex = index;
  2630. uiInfo.movesBaseAnim = datapadMoveTitleBaseAnims[uiInfo.movesTitleIndex];
  2631. menu = Menus_FindByName("datapadMovesMenu");
  2632. if (menu)
  2633. {
  2634. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  2635. if (item)
  2636. {
  2637. modelPtr = (modelDef_t*)item->typeData;
  2638. if (modelPtr)
  2639. {
  2640. ItemParse_model_g2anim_go( item, uiInfo.movesBaseAnim );
  2641. uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
  2642. }
  2643. }
  2644. }
  2645. }
  2646. else if (feederID == FEEDER_MODS)
  2647. {
  2648. uiInfo.modIndex = index;
  2649. }
  2650. else if (feederID == FEEDER_PLAYER_SPECIES)
  2651. {
  2652. uiInfo.playerSpeciesIndex = index;
  2653. }
  2654. else if (feederID == FEEDER_LANGUAGES)
  2655. {
  2656. uiInfo.languageCountIndex = index;
  2657. }
  2658. else if (feederID == FEEDER_PLAYER_SKIN_HEAD)
  2659. {
  2660. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount)
  2661. {
  2662. Cvar_Set("ui_char_skin_head", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index]);
  2663. }
  2664. }
  2665. else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
  2666. {
  2667. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount)
  2668. {
  2669. Cvar_Set("ui_char_skin_torso", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index]);
  2670. }
  2671. }
  2672. else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
  2673. {
  2674. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount)
  2675. {
  2676. Cvar_Set("ui_char_skin_legs", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index]);
  2677. }
  2678. }
  2679. else if (feederID == FEEDER_COLORCHOICES)
  2680. {
  2681. extern void Item_RunScript(itemDef_t *item, const char *s); //from ui_shared;
  2682. if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount)
  2683. {
  2684. Item_RunScript(item, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorActionText[index]);
  2685. }
  2686. }
  2687. else if (feederID == FEEDER_LEVELSELECT)
  2688. {
  2689. if (index >= 0 && index < levelSelectSize)
  2690. levelSelectChoice = index;
  2691. }
  2692. /* else if (feederID == FEEDER_CINEMATICS)
  2693. {
  2694. uiInfo.movieIndex = index;
  2695. if (uiInfo.previewMovie >= 0)
  2696. {
  2697. trap_CIN_StopCinematic(uiInfo.previewMovie);
  2698. }
  2699. uiInfo.previewMovie = -1;
  2700. }
  2701. else if (feederID == FEEDER_DEMOS)
  2702. {
  2703. uiInfo.demoIndex = index;
  2704. }
  2705. */
  2706. }
  2707. void Key_KeynumToStringBuf( int keynum, char *buf, int buflen );
  2708. void Key_GetBindingBuf( int keynum, char *buf, int buflen );
  2709. static qboolean UI_Crosshair_HandleKey(int flags, float *special, int key)
  2710. {
  2711. if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER)
  2712. {
  2713. if (key == A_MOUSE2)
  2714. {
  2715. uiInfo.currentCrosshair--;
  2716. } else {
  2717. uiInfo.currentCrosshair++;
  2718. }
  2719. if (uiInfo.currentCrosshair >= NUM_CROSSHAIRS) {
  2720. uiInfo.currentCrosshair = 0;
  2721. } else if (uiInfo.currentCrosshair < 0) {
  2722. uiInfo.currentCrosshair = NUM_CROSSHAIRS - 1;
  2723. }
  2724. Cvar_Set("cg_drawCrosshair", va("%d", uiInfo.currentCrosshair));
  2725. return qtrue;
  2726. }
  2727. return qfalse;
  2728. }
  2729. static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key)
  2730. {
  2731. switch (ownerDraw)
  2732. {
  2733. case UI_CROSSHAIR:
  2734. UI_Crosshair_HandleKey(flags, special, key);
  2735. break;
  2736. case UI_SOFT_KEYBOARD:
  2737. return UI_SoftKeyboard_HandleKey(flags, special, key);
  2738. break;
  2739. case UI_SOFT_KEYBOARD_DELETE:
  2740. return UI_SoftKeyboardDelete_HandleKey(flags, special, key);
  2741. break;
  2742. case UI_SOFT_KEYBOARD_ACCEPT:
  2743. return UI_SoftKeyboardAccept_HandleKey(flags, special, key);
  2744. break;
  2745. default:
  2746. break;
  2747. }
  2748. return qfalse;
  2749. }
  2750. //unfortunately we cannot rely on any game/cgame module code to do our animation stuff,
  2751. //because the ui can be loaded while the game/cgame are not loaded. So we're going to recreate what we need here.
  2752. // On Xbox, we need all the RAM we can get, and this is huge. So we just borrow the one from level. I hope
  2753. // this doesn't cause some apocalypse. Getting access to level in here is nigh impossible, as we'd have to
  2754. // include g_local.h, and the consequences of that are bad. So: This pointer is initialized in a global constructor
  2755. // in class UIAnimFileSetInitializer in g_main.cpp! Look there! Don't forget!
  2756. //#ifdef _XBOX
  2757. //animFileSet_t *ui_knownAnimFileSets = NULL;
  2758. //#else
  2759. #undef MAX_ANIM_FILES
  2760. #define MAX_ANIM_FILES 4
  2761. typedef struct
  2762. {
  2763. char filename[MAX_QPATH];
  2764. animation_t animations[MAX_ANIMATIONS];
  2765. } animFileSet_t;
  2766. static animFileSet_t ui_knownAnimFileSets[MAX_ANIM_FILES];
  2767. //#endif
  2768. int ui_numKnownAnimFileSets;
  2769. qboolean UI_ParseAnimationFile( const char *af_filename )
  2770. {
  2771. const char *text_p;
  2772. int len;
  2773. int i;
  2774. const char *token;
  2775. float fps;
  2776. int skip;
  2777. char text[80000];
  2778. int animNum;
  2779. animation_t *animations = ui_knownAnimFileSets[ui_numKnownAnimFileSets].animations;
  2780. len = re.GetAnimationCFG(af_filename, text, sizeof(text));
  2781. if ( len <= 0 )
  2782. {
  2783. return qfalse;
  2784. }
  2785. if ( len >= sizeof( text ) - 1 )
  2786. {
  2787. Com_Error( ERR_FATAL, "UI_ParseAnimationFile: File %s too long\n (%d > %d)", af_filename, len, sizeof( text ) - 1);
  2788. return qfalse;
  2789. }
  2790. // parse the text
  2791. text_p = text;
  2792. skip = 0; // quiet the compiler warning
  2793. //FIXME: have some way of playing anims backwards... negative numFrames?
  2794. //initialize anim array so that from 0 to MAX_ANIMATIONS, set default values of 0 1 0 100
  2795. for(i = 0; i < MAX_ANIMATIONS; i++)
  2796. {
  2797. animations[i].firstFrame = 0;
  2798. animations[i].numFrames = 0;
  2799. animations[i].loopFrames = -1;
  2800. animations[i].frameLerp = 100;
  2801. // animations[i].initialLerp = 100;
  2802. }
  2803. // read information for each frame
  2804. while(1)
  2805. {
  2806. token = COM_Parse( &text_p );
  2807. if ( !token || !token[0])
  2808. {
  2809. break;
  2810. }
  2811. animNum = GetIDForString(animTable, token);
  2812. if(animNum == -1)
  2813. {
  2814. //#ifndef FINAL_BUILD
  2815. #ifdef _DEBUG
  2816. if (strcmp(token,"ROOT"))
  2817. {
  2818. Com_Printf(S_COLOR_RED"WARNING: Unknown token %s in %s\n", token, af_filename);
  2819. }
  2820. #endif
  2821. while (token[0])
  2822. {
  2823. token = COM_ParseExt( &text_p, qfalse ); //returns empty string when next token is EOL
  2824. }
  2825. continue;
  2826. }
  2827. token = COM_Parse( &text_p );
  2828. if ( !token )
  2829. {
  2830. break;
  2831. }
  2832. animations[animNum].firstFrame = atoi( token );
  2833. token = COM_Parse( &text_p );
  2834. if ( !token )
  2835. {
  2836. break;
  2837. }
  2838. animations[animNum].numFrames = atoi( token );
  2839. token = COM_Parse( &text_p );
  2840. if ( !token )
  2841. {
  2842. break;
  2843. }
  2844. animations[animNum].loopFrames = atoi( token );
  2845. token = COM_Parse( &text_p );
  2846. if ( !token )
  2847. {
  2848. break;
  2849. }
  2850. fps = atof( token );
  2851. if ( fps == 0 )
  2852. {
  2853. fps = 1;//Don't allow divide by zero error
  2854. }
  2855. if ( fps < 0 )
  2856. {//backwards
  2857. animations[animNum].frameLerp = floor(1000.0f / fps);
  2858. }
  2859. else
  2860. {
  2861. animations[animNum].frameLerp = ceil(1000.0f / fps);
  2862. }
  2863. // animations[animNum].initialLerp = ceil(1000.0f / fabs(fps));
  2864. }
  2865. return qtrue;
  2866. }
  2867. qboolean UI_ParseAnimFileSet( const char *animCFG, int *animFileIndex )
  2868. { //Not going to bother parsing the sound config here.
  2869. char afilename[MAX_QPATH];
  2870. char strippedName[MAX_QPATH];
  2871. int i;
  2872. char *slash;
  2873. Q_strncpyz( strippedName, animCFG, sizeof(strippedName), qtrue);
  2874. slash = strrchr( strippedName, '/' );
  2875. if ( slash )
  2876. {
  2877. // truncate modelName to find just the dir not the extension
  2878. *slash = 0;
  2879. }
  2880. //if this anims file was loaded before, don't parse it again, just point to the correct table of info
  2881. for ( i = 0; i < ui_numKnownAnimFileSets; i++ )
  2882. {
  2883. if ( Q_stricmp(ui_knownAnimFileSets[i].filename, strippedName ) == 0 )
  2884. {
  2885. *animFileIndex = i;
  2886. return qtrue;
  2887. }
  2888. }
  2889. if ( ui_numKnownAnimFileSets == MAX_ANIM_FILES )
  2890. {//TOO MANY!
  2891. for (i = 0; i < MAX_ANIM_FILES; i++)
  2892. {
  2893. Com_Printf("animfile[%d]: %s\n", i, ui_knownAnimFileSets[i].filename);
  2894. }
  2895. Com_Error( ERR_FATAL, "UI_ParseAnimFileSet: %d == MAX_ANIM_FILES == %d", ui_numKnownAnimFileSets, MAX_ANIM_FILES);
  2896. }
  2897. //Okay, time to parse in a new one
  2898. Q_strncpyz( ui_knownAnimFileSets[ui_numKnownAnimFileSets].filename, strippedName, sizeof( ui_knownAnimFileSets[ui_numKnownAnimFileSets].filename ) );
  2899. // Load and parse animations.cfg file
  2900. Com_sprintf( afilename, sizeof( afilename ), "%s/animation.cfg", strippedName );
  2901. if ( !UI_ParseAnimationFile( afilename ) )
  2902. {
  2903. *animFileIndex = -1;
  2904. return qfalse;
  2905. }
  2906. //set index and increment
  2907. *animFileIndex = ui_numKnownAnimFileSets++;
  2908. return qtrue;
  2909. }
  2910. int UI_G2SetAnim(CGhoul2Info *ghlInfo, const char *boneName, int animNum, const qboolean freeze)
  2911. {
  2912. int animIndex,blendTime;
  2913. char *GLAName;
  2914. GLAName = G2API_GetGLAName(ghlInfo);
  2915. if (!GLAName || !GLAName[0])
  2916. {
  2917. return 0;
  2918. }
  2919. UI_ParseAnimFileSet(GLAName, &animIndex);
  2920. if (animIndex != -1)
  2921. {
  2922. animation_t *anim = &ui_knownAnimFileSets[animIndex].animations[animNum];
  2923. if (anim->numFrames <= 0)
  2924. {
  2925. return 0;
  2926. }
  2927. int sFrame = anim->firstFrame;
  2928. int eFrame = anim->firstFrame + anim->numFrames;
  2929. int flags = BONE_ANIM_OVERRIDE;
  2930. int time = uiInfo.uiDC.realTime;
  2931. float animSpeed = (50.0f / anim->frameLerp);
  2932. blendTime = 150;
  2933. // Freeze anim if it's not looping, special hack for datapad moves menu
  2934. if (freeze)
  2935. {
  2936. if (anim->loopFrames == -1)
  2937. {
  2938. flags = BONE_ANIM_OVERRIDE_FREEZE;
  2939. }
  2940. else
  2941. {
  2942. flags = BONE_ANIM_OVERRIDE_LOOP;
  2943. }
  2944. }
  2945. else if (anim->loopFrames != -1)
  2946. {
  2947. flags = BONE_ANIM_OVERRIDE_LOOP;
  2948. }
  2949. flags |= BONE_ANIM_BLEND;
  2950. blendTime = 150;
  2951. G2API_SetBoneAnim(ghlInfo, boneName, sFrame, eFrame, flags, animSpeed, time, -1, blendTime);
  2952. return ((anim->frameLerp * (anim->numFrames-2)));
  2953. }
  2954. return 0;
  2955. }
  2956. static qboolean UI_ParseColorData(char* buf, playerSpeciesInfo_t &species)
  2957. {
  2958. const char *token;
  2959. const char *p;
  2960. p = buf;
  2961. COM_BeginParseSession();
  2962. species.ColorCount = 0;
  2963. while ( p )
  2964. {
  2965. token = COM_ParseExt( &p, qtrue ); //looking for the shader
  2966. if ( token[0] == 0 )
  2967. {
  2968. return species.ColorCount;
  2969. }
  2970. Q_strncpyz( species.ColorShader[species.ColorCount], token, sizeof(species.ColorShader[0]), qtrue );
  2971. token = COM_ParseExt( &p, qtrue ); //looking for action block {
  2972. if ( token[0] != '{' )
  2973. {
  2974. return qfalse;
  2975. }
  2976. assert(!species.ColorActionText[species.ColorCount][0]);
  2977. token = COM_ParseExt( &p, qtrue ); //looking for action commands
  2978. while (token[0] != '}')
  2979. {
  2980. if ( token[0] == 0)
  2981. { //EOF
  2982. return qfalse;
  2983. }
  2984. assert(species.ColorCount < sizeof(species.ColorActionText)/sizeof(species.ColorActionText[0]) );
  2985. Q_strcat(species.ColorActionText[species.ColorCount], sizeof(species.ColorActionText[0]), token);
  2986. Q_strcat(species.ColorActionText[species.ColorCount], sizeof(species.ColorActionText[0]), " ");
  2987. token = COM_ParseExt( &p, qtrue ); //looking for action commands or final }
  2988. }
  2989. species.ColorCount++; //next color please
  2990. }
  2991. return qtrue;//never get here
  2992. }
  2993. /*
  2994. =================
  2995. bIsImageFile
  2996. builds path and scans for valid image extentions
  2997. =================
  2998. */
  2999. static bool bIsImageFile(const char* dirptr, const char* skinname, qboolean building)
  3000. {
  3001. char fpath[MAX_QPATH];
  3002. int f;
  3003. #ifdef _XBOX
  3004. Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.dds", dirptr, skinname);
  3005. #else
  3006. Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.jpg", dirptr, skinname);
  3007. #endif
  3008. ui.FS_FOpenFile(fpath, &f, FS_READ);
  3009. #if !defined(_XBOX) || defined(_DEBUG)
  3010. if (!f)
  3011. { //not there, try png
  3012. Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.png", dirptr, skinname);
  3013. ui.FS_FOpenFile(fpath, &f, FS_READ);
  3014. }
  3015. if (!f)
  3016. { //not there, try tga
  3017. Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.tga", dirptr, skinname);
  3018. ui.FS_FOpenFile(fpath, &f, FS_READ);
  3019. }
  3020. #endif
  3021. if (f)
  3022. {
  3023. ui.FS_FCloseFile(f);
  3024. if ( building ) ui.R_RegisterShaderNoMip(fpath);
  3025. return true;
  3026. }
  3027. return false;
  3028. }
  3029. /*
  3030. =================
  3031. PlayerModel_BuildList
  3032. =================
  3033. */
  3034. static void UI_BuildPlayerModel_List( qboolean inGameLoad )
  3035. {
  3036. int numdirs;
  3037. char dirlist[2048];
  3038. char* dirptr;
  3039. int dirlen;
  3040. int i;
  3041. const int building = Cvar_VariableIntegerValue("com_buildscript");
  3042. uiInfo.playerSpeciesCount = 0;
  3043. uiInfo.playerSpeciesIndex = 0;
  3044. memset(uiInfo.playerSpecies, 0, sizeof (uiInfo.playerSpecies) );
  3045. // iterate directory of all player models
  3046. numdirs = ui.FS_GetFileList("models/players", "/", dirlist, 2048 );
  3047. dirptr = dirlist;
  3048. for (i=0; i<numdirs; i++,dirptr+=dirlen+1)
  3049. {
  3050. char filelist[2048];
  3051. char* fileptr;
  3052. int filelen;
  3053. int f = 0;
  3054. char fpath[2048];
  3055. dirlen = strlen(dirptr);
  3056. if (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\0';
  3057. if (!strcmp(dirptr,".") || !strcmp(dirptr,".."))
  3058. continue;
  3059. Com_sprintf(fpath, 2048, "models/players/%s/PlayerChoice.txt", dirptr);
  3060. filelen = ui.FS_FOpenFile(fpath, &f, FS_READ);
  3061. if (f)
  3062. {
  3063. char buffer[2048];
  3064. ui.FS_Read(&buffer, filelen, f);
  3065. ui.FS_FCloseFile(f);
  3066. buffer[filelen] = 0; //ensure trailing NULL
  3067. //record this species
  3068. Q_strncpyz( uiInfo.playerSpecies[uiInfo.playerSpeciesCount].Name, dirptr, sizeof(uiInfo.playerSpecies[0].Name), qtrue );
  3069. if (!UI_ParseColorData(buffer,uiInfo.playerSpecies[uiInfo.playerSpeciesCount]))
  3070. {
  3071. ui.Printf( "UI_BuildPlayerModel_List: Errors parsing '%s'\n", fpath );
  3072. }
  3073. int j;
  3074. char skinname[64];
  3075. int numfiles;
  3076. int iSkinParts=0;
  3077. numfiles = ui.FS_GetFileList( va("models/players/%s",dirptr), ".skin", filelist, 2048 );
  3078. fileptr = filelist;
  3079. for (j=0; j<numfiles; j++,fileptr+=filelen+1)
  3080. {
  3081. if ( building )
  3082. {
  3083. ui.FS_FOpenFile(va("models/players/%s/%s",dirptr,fileptr), &f, FS_READ);
  3084. if (f) ui.FS_FCloseFile(f);
  3085. ui.FS_FOpenFile(va("models/players/%s/sounds.cfg", dirptr), &f, FS_READ);
  3086. if (f) ui.FS_FCloseFile(f);
  3087. ui.FS_FOpenFile(va("models/players/%s/animevents.cfg", dirptr), &f, FS_READ);
  3088. if (f) ui.FS_FCloseFile(f);
  3089. }
  3090. filelen = strlen(fileptr);
  3091. COM_StripExtension(fileptr,skinname);
  3092. if (bIsImageFile(dirptr, skinname, building))
  3093. { //if it exists
  3094. if (strnicmp(skinname,"head_",5) == 0)
  3095. {
  3096. if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadCount < MAX_PLAYERMODELS)
  3097. {
  3098. Q_strncpyz(uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadNames[uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadCount++], skinname, sizeof(uiInfo.playerSpecies[0].SkinHeadNames[0]), qtrue);
  3099. iSkinParts |= 1<<0;
  3100. }
  3101. } else
  3102. if (strnicmp(skinname,"torso_",6) == 0)
  3103. {
  3104. if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoCount < MAX_PLAYERMODELS)
  3105. {
  3106. Q_strncpyz(uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoNames[uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoCount++], skinname, sizeof(uiInfo.playerSpecies[0].SkinTorsoNames[0]), qtrue);
  3107. iSkinParts |= 1<<1;
  3108. }
  3109. } else
  3110. if (strnicmp(skinname,"lower_",6) == 0)
  3111. {
  3112. if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegCount < MAX_PLAYERMODELS)
  3113. {
  3114. Q_strncpyz(uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegNames[uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegCount++], skinname, sizeof(uiInfo.playerSpecies[0].SkinLegNames[0]), qtrue);
  3115. iSkinParts |= 1<<2;
  3116. }
  3117. }
  3118. }
  3119. }
  3120. if (iSkinParts != 7)
  3121. { //didn't get a skin for each, then skip this model.
  3122. memset(&uiInfo.playerSpecies[uiInfo.playerSpeciesCount], 0, sizeof(uiInfo.playerSpecies[uiInfo.playerSpeciesCount]));//undo the colors
  3123. continue;
  3124. }
  3125. uiInfo.playerSpeciesCount++;
  3126. if (!inGameLoad && ui_PrecacheModels.integer)
  3127. {
  3128. CGhoul2Info_v ghoul2;
  3129. Com_sprintf( fpath, sizeof( fpath ), "models/players/%s/model.glm", dirptr );
  3130. int g2Model = DC->g2_InitGhoul2Model(ghoul2, fpath, 0, 0, 0, 0, 0);
  3131. if (g2Model >= 0)
  3132. {
  3133. DC->g2_RemoveGhoul2Model( ghoul2, 0 );
  3134. }
  3135. }
  3136. if (uiInfo.playerSpeciesCount >= MAX_PLAYERMODELS)
  3137. {
  3138. return;
  3139. }
  3140. }
  3141. }
  3142. }
  3143. /*
  3144. =================
  3145. UI_Init
  3146. =================
  3147. */
  3148. void _UI_Init( qboolean inGameLoad )
  3149. {
  3150. uiInfo.inGameLoad = inGameLoad;
  3151. UI_RegisterCvars();
  3152. UI_InitMemory();
  3153. // cache redundant calulations
  3154. trap_GetGlconfig( &uiInfo.uiDC.glconfig );
  3155. // for 640x480 virtualized screen
  3156. uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0);
  3157. uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0);
  3158. if ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 )
  3159. {
  3160. // wide screen
  3161. uiInfo.uiDC.bias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * (640.0/480.0) ) );
  3162. }
  3163. else
  3164. {
  3165. // no wide screen
  3166. uiInfo.uiDC.bias = 0;
  3167. }
  3168. Init_Display(&uiInfo.uiDC);
  3169. uiInfo.uiDC.drawText = &Text_Paint;
  3170. uiInfo.uiDC.drawHandlePic = &UI_DrawHandlePic;
  3171. uiInfo.uiDC.drawRect = &_UI_DrawRect;
  3172. uiInfo.uiDC.drawSides = &_UI_DrawSides;
  3173. uiInfo.uiDC.drawTextWithCursor = &Text_PaintWithCursor;
  3174. uiInfo.uiDC.executeText = &Cbuf_ExecuteText;
  3175. uiInfo.uiDC.drawTopBottom = &_UI_DrawTopBottom;
  3176. uiInfo.uiDC.feederCount = &UI_FeederCount;
  3177. uiInfo.uiDC.feederSelection = &UI_FeederSelection;
  3178. uiInfo.uiDC.fillRect = &UI_FillRect;
  3179. uiInfo.uiDC.getBindingBuf = &Key_GetBindingBuf;
  3180. uiInfo.uiDC.getCVarString = Cvar_VariableStringBuffer;
  3181. uiInfo.uiDC.getCVarValue = trap_Cvar_VariableValue;
  3182. uiInfo.uiDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;
  3183. uiInfo.uiDC.getValue = &UI_GetValue;
  3184. uiInfo.uiDC.keynumToStringBuf = &Key_KeynumToStringBuf;
  3185. uiInfo.uiDC.modelBounds = &trap_R_ModelBounds;
  3186. uiInfo.uiDC.ownerDrawVisible = &UI_OwnerDrawVisible;
  3187. uiInfo.uiDC.ownerDrawWidth = &UI_OwnerDrawWidth;
  3188. uiInfo.uiDC.ownerDrawItem = &UI_OwnerDraw;
  3189. uiInfo.uiDC.Print = &Com_Printf;
  3190. uiInfo.uiDC.registerSound = &trap_S_RegisterSound;
  3191. uiInfo.uiDC.registerModel = ui.R_RegisterModel;
  3192. uiInfo.uiDC.clearScene = &trap_R_ClearScene;
  3193. uiInfo.uiDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
  3194. uiInfo.uiDC.renderScene = &trap_R_RenderScene;
  3195. uiInfo.uiDC.runScript = &UI_RunMenuScript;
  3196. uiInfo.uiDC.deferScript = &UI_DeferMenuScript;
  3197. uiInfo.uiDC.setBinding = &trap_Key_SetBinding;
  3198. uiInfo.uiDC.setColor = &UI_SetColor;
  3199. uiInfo.uiDC.setCVar = Cvar_Set;
  3200. uiInfo.uiDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;
  3201. uiInfo.uiDC.startLocalSound = &trap_S_StartLocalSound;
  3202. uiInfo.uiDC.stopCinematic = &UI_StopCinematic;
  3203. uiInfo.uiDC.textHeight = &Text_Height;
  3204. uiInfo.uiDC.textWidth = &Text_Width;
  3205. uiInfo.uiDC.feederItemImage = &UI_FeederItemImage;
  3206. uiInfo.uiDC.feederItemText = &UI_FeederItemText;
  3207. #ifdef _IMMERSION
  3208. uiInfo.uiDC.registerForce = &trap_FF_Register;
  3209. uiInfo.uiDC.startForce = &trap_FF_Start;
  3210. #endif // _IMMERSION
  3211. uiInfo.uiDC.ownerDrawHandleKey = &UI_OwnerDrawHandleKey;
  3212. uiInfo.uiDC.registerSkin = re.RegisterSkin;
  3213. #ifndef _XBOX
  3214. uiInfo.uiDC.g2_SetSkin = G2API_SetSkin;
  3215. uiInfo.uiDC.g2_SetBoneAnim = G2API_SetBoneAnim;
  3216. #endif
  3217. uiInfo.uiDC.g2_RemoveGhoul2Model = G2API_RemoveGhoul2Model;
  3218. uiInfo.uiDC.g2_InitGhoul2Model = G2API_InitGhoul2Model;
  3219. uiInfo.uiDC.g2_CleanGhoul2Models = G2API_CleanGhoul2Models;
  3220. uiInfo.uiDC.g2_AddBolt = G2API_AddBolt;
  3221. uiInfo.uiDC.g2_GetBoltMatrix = G2API_GetBoltMatrix;
  3222. uiInfo.uiDC.g2_GiveMeVectorFromMatrix = G2API_GiveMeVectorFromMatrix;
  3223. uiInfo.uiDC.g2hilev_SetAnim = UI_G2SetAnim;
  3224. UI_BuildPlayerModel_List(inGameLoad);
  3225. String_Init();
  3226. char *menuSet = UI_Cvar_VariableString("ui_menuFiles");
  3227. if (menuSet == NULL || menuSet[0] == '\0')
  3228. {
  3229. menuSet = "ui/menus.txt";
  3230. }
  3231. if (inGameLoad)
  3232. {
  3233. UI_LoadMenus("ui/ingame.txt", qtrue);
  3234. }
  3235. else
  3236. {
  3237. UI_LoadMenus(menuSet, qtrue);
  3238. }
  3239. Menus_CloseAll();
  3240. uiInfo.uiDC.whiteShader = ui.R_RegisterShaderNoMip( "white" );
  3241. AssetCache();
  3242. uis.debugMode = qfalse;
  3243. // sets defaults for ui temp cvars
  3244. uiInfo.effectsColor = (int)trap_Cvar_VariableValue("color")-1;
  3245. if (uiInfo.effectsColor < 0)
  3246. {
  3247. uiInfo.effectsColor = 0;
  3248. }
  3249. uiInfo.effectsColor = gamecodetoui[uiInfo.effectsColor];
  3250. uiInfo.currentCrosshair = (int)trap_Cvar_VariableValue("cg_drawCrosshair");
  3251. Cvar_Set("cg_endcredits", "0"); // Reset value
  3252. Cvar_Set("ui_missionfailed","0"); // reset
  3253. uiInfo.forcePowerUpdated = FP_UPDATED_NONE;
  3254. uiInfo.selectedWeapon1 = NOWEAPON;
  3255. uiInfo.selectedWeapon2 = NOWEAPON;
  3256. uiInfo.selectedThrowWeapon = NOWEAPON;
  3257. uiInfo.uiDC.Assets.nullSound = trap_S_RegisterSound("sound/null", qfalse);
  3258. trap_S_RegisterSound("sound/interface/weapon_deselect", qfalse);
  3259. }
  3260. /*
  3261. =================
  3262. UI_RegisterCvars
  3263. =================
  3264. */
  3265. static void UI_RegisterCvars( void )
  3266. {
  3267. int i;
  3268. cvarTable_t *cv;
  3269. for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ )
  3270. {
  3271. Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
  3272. }
  3273. }
  3274. #ifdef _XBOX
  3275. //JLFCALLOUT MPNOTNEEDED->(INCLUDE WORKS)
  3276. qboolean Menu_Parse(char *buffer, menuDef_t *menu);
  3277. char * UI_ParseInclude(const char *menuFile, menuDef_t * menu)
  3278. {
  3279. char * buffer;
  3280. int len;
  3281. // pc_token_t token;
  3282. //Com_DPrintf("Parsing menu file:%s\n", menuFile);
  3283. len = PC_StartParseSession(menuFile,&buffer, true);
  3284. if (len<=0)
  3285. {
  3286. Com_Printf("UI_ParseMenu: Unable to load menu %s\n", menuFile);
  3287. return NULL;
  3288. }
  3289. // PC_EndParseSession(buffer);
  3290. return buffer;
  3291. }
  3292. #endif
  3293. /*
  3294. =================
  3295. UI_ParseMenu
  3296. =================
  3297. */
  3298. void UI_ParseMenu(const char *menuFile)
  3299. {
  3300. char *buffer,*holdBuffer,*token2;
  3301. int len;
  3302. // pc_token_t token;
  3303. //Com_DPrintf("Parsing menu file:%s\n", menuFile);
  3304. len = PC_StartParseSession(menuFile,&buffer);
  3305. holdBuffer = buffer;
  3306. if (len<=0)
  3307. {
  3308. Com_Printf("UI_ParseMenu: Unable to load menu %s\n", menuFile);
  3309. return;
  3310. }
  3311. while ( 1 )
  3312. {
  3313. token2 = PC_ParseExt();
  3314. if (!*token2)
  3315. {
  3316. break;
  3317. }
  3318. /*
  3319. if ( menuCount == MAX_MENUS )
  3320. {
  3321. PC_ParseWarning("Too many menus!");
  3322. break;
  3323. }
  3324. */
  3325. if ( *token2 == '{')
  3326. {
  3327. continue;
  3328. }
  3329. else if ( *token2 == '}' )
  3330. {
  3331. break;
  3332. }
  3333. else if (Q_stricmp(token2, "assetGlobalDef") == 0)
  3334. {
  3335. if (Asset_Parse(&holdBuffer))
  3336. {
  3337. continue;
  3338. }
  3339. else
  3340. {
  3341. break;
  3342. }
  3343. }
  3344. else if (Q_stricmp(token2, "menudef") == 0)
  3345. {
  3346. // start a new menu
  3347. Menu_New(holdBuffer);
  3348. continue;
  3349. }
  3350. PC_ParseWarning(va("Invalid keyword '%s'",token2));
  3351. }
  3352. PC_EndParseSession(buffer);
  3353. }
  3354. /*
  3355. =================
  3356. Load_Menu
  3357. Load current menu file
  3358. =================
  3359. */
  3360. qboolean Load_Menu(const char **holdBuffer)
  3361. {
  3362. const char *token2;
  3363. token2 = COM_ParseExt( holdBuffer, qtrue );
  3364. if (!token2[0])
  3365. {
  3366. return qfalse;
  3367. }
  3368. if (*token2 != '{')
  3369. {
  3370. return qfalse;
  3371. }
  3372. while ( 1 )
  3373. {
  3374. token2 = COM_ParseExt( holdBuffer, qtrue );
  3375. if ((!token2) || (token2 == 0))
  3376. {
  3377. return qfalse;
  3378. }
  3379. if ( *token2 == '}' )
  3380. {
  3381. return qtrue;
  3382. }
  3383. //#ifdef _DEBUG
  3384. // extern void UI_Debug_AddMenuFilePath(const char *);
  3385. // UI_Debug_AddMenuFilePath(token2);
  3386. //#endif
  3387. UI_ParseMenu(token2);
  3388. }
  3389. return qfalse;
  3390. }
  3391. /*
  3392. =================
  3393. UI_LoadMenus
  3394. Load all menus based on the files listed in the data file in menuFile (default "ui/menus.txt")
  3395. =================
  3396. */
  3397. void UI_LoadMenus(const char *menuFile, qboolean reset)
  3398. {
  3399. // pc_token_t token;
  3400. // int handle;
  3401. int start;
  3402. char *buffer;
  3403. const char *holdBuffer;
  3404. int len;
  3405. start = Sys_Milliseconds();
  3406. len = ui.FS_ReadFile(menuFile,(void **) &buffer);
  3407. if (len<1)
  3408. {
  3409. Com_Printf( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) );
  3410. len = ui.FS_ReadFile("ui/menus.txt",(void **) &buffer);
  3411. if (len<1)
  3412. {
  3413. Com_Error( ERR_FATAL, "%s", va("default menu file not found: ui/menus.txt, unable to continue!\n", menuFile ));
  3414. return;
  3415. }
  3416. }
  3417. if (reset)
  3418. {
  3419. Menu_Reset();
  3420. }
  3421. const char *token2;
  3422. holdBuffer = buffer;
  3423. while ( 1 )
  3424. {
  3425. token2 = COM_ParseExt( &holdBuffer, qtrue );
  3426. if (!*token2)
  3427. {
  3428. break;
  3429. }
  3430. if( *token2 == 0 || *token2 == '}') // End of the menus file
  3431. {
  3432. break;
  3433. }
  3434. if (*token2 == '{')
  3435. {
  3436. continue;
  3437. }
  3438. else if (Q_stricmp(token2, "loadmenu") == 0)
  3439. {
  3440. if (Load_Menu(&holdBuffer))
  3441. {
  3442. continue;
  3443. }
  3444. else
  3445. {
  3446. break;
  3447. }
  3448. }
  3449. else
  3450. {
  3451. Com_Printf("Unknown keyword '%s' in menus file %s\n", token2, menuFile);
  3452. }
  3453. }
  3454. //Com_Printf("UI menu load time = %d milli seconds\n", Sys_Milliseconds() - start);
  3455. ui.FS_FreeFile( buffer ); //let go of the buffer
  3456. }
  3457. /*
  3458. =================
  3459. UI_Load
  3460. =================
  3461. */
  3462. void UI_Load(void)
  3463. {
  3464. char *menuSet;
  3465. char lastName[1024];
  3466. menuDef_t *menu = Menu_GetFocused();
  3467. if (menu && menu->window.name)
  3468. {
  3469. strcpy(lastName, menu->window.name);
  3470. }
  3471. else
  3472. {
  3473. lastName[0] = 0;
  3474. }
  3475. if (uiInfo.inGameLoad)
  3476. {
  3477. menuSet= "ui/ingame.txt";
  3478. }
  3479. else
  3480. {
  3481. menuSet= UI_Cvar_VariableString("ui_menuFiles");
  3482. }
  3483. if (menuSet == NULL || menuSet[0] == '\0')
  3484. {
  3485. menuSet = "ui/menus.txt";
  3486. }
  3487. String_Init();
  3488. UI_LoadMenus(menuSet, qtrue);
  3489. Menus_CloseAll();
  3490. Menus_ActivateByName(lastName);
  3491. }
  3492. /*
  3493. =================
  3494. Asset_Parse
  3495. =================
  3496. */
  3497. qboolean Asset_Parse(char **buffer)
  3498. {
  3499. char *token;
  3500. const char *tempStr;
  3501. int pointSize;
  3502. token = PC_ParseExt();
  3503. if (!token)
  3504. {
  3505. return qfalse;
  3506. }
  3507. if (*token != '{')
  3508. {
  3509. return qfalse;
  3510. }
  3511. while ( 1 )
  3512. {
  3513. token = PC_ParseExt();
  3514. if (!token)
  3515. {
  3516. return qfalse;
  3517. }
  3518. if (*token == '}')
  3519. {
  3520. return qtrue;
  3521. }
  3522. // fonts
  3523. if (Q_stricmp(token, "smallFont") == 0) //legacy, really it only matters which order they are registered
  3524. {
  3525. if (PC_ParseString(&tempStr))
  3526. {
  3527. PC_ParseWarning("Bad 1st parameter for keyword 'smallFont'");
  3528. return qfalse;
  3529. }
  3530. UI_RegisterFont(tempStr);
  3531. //not used anymore
  3532. if (PC_ParseInt(&pointSize))
  3533. {
  3534. // PC_ParseWarning("Bad 2nd parameter for keyword 'smallFont'");
  3535. }
  3536. continue;
  3537. }
  3538. if (Q_stricmp(token, "mediumFont") == 0)
  3539. {
  3540. if (PC_ParseString(&tempStr))
  3541. {
  3542. PC_ParseWarning("Bad 1st parameter for keyword 'font'");
  3543. return qfalse;
  3544. }
  3545. uiInfo.uiDC.Assets.qhMediumFont = UI_RegisterFont(tempStr);
  3546. uiInfo.uiDC.Assets.fontRegistered = qtrue;
  3547. //not used
  3548. if (PC_ParseInt(&pointSize))
  3549. {
  3550. // PC_ParseWarning("Bad 2nd parameter for keyword 'font'");
  3551. }
  3552. continue;
  3553. }
  3554. if (Q_stricmp(token, "bigFont") == 0) //legacy
  3555. {
  3556. if (PC_ParseString(&tempStr))
  3557. {
  3558. PC_ParseWarning("Bad 1st parameter for keyword 'bigFont'");
  3559. return qfalse;
  3560. }
  3561. UI_RegisterFont(tempStr);
  3562. if (PC_ParseInt(&pointSize))
  3563. {
  3564. // PC_ParseWarning("Bad 2nd parameter for keyword 'bigFont'");
  3565. }
  3566. continue;
  3567. }
  3568. // gradientbar
  3569. if (Q_stricmp(token, "gradientbar") == 0)
  3570. {
  3571. if (PC_ParseString(&tempStr))
  3572. {
  3573. PC_ParseWarning("Bad 1st parameter for keyword 'gradientbar'");
  3574. return qfalse;
  3575. }
  3576. uiInfo.uiDC.Assets.gradientBar = ui.R_RegisterShaderNoMip(tempStr);
  3577. continue;
  3578. }
  3579. // enterMenuSound
  3580. if (Q_stricmp(token, "menuEnterSound") == 0)
  3581. {
  3582. if (PC_ParseString(&tempStr))
  3583. {
  3584. PC_ParseWarning("Bad 1st parameter for keyword 'menuEnterSound'");
  3585. return qfalse;
  3586. }
  3587. uiInfo.uiDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse );
  3588. continue;
  3589. }
  3590. // exitMenuSound
  3591. if (Q_stricmp(token, "menuExitSound") == 0)
  3592. {
  3593. if (PC_ParseString(&tempStr))
  3594. {
  3595. PC_ParseWarning("Bad 1st parameter for keyword 'menuExitSound'");
  3596. return qfalse;
  3597. }
  3598. uiInfo.uiDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse );
  3599. continue;
  3600. }
  3601. // itemFocusSound
  3602. if (Q_stricmp(token, "itemFocusSound") == 0)
  3603. {
  3604. if (PC_ParseString(&tempStr))
  3605. {
  3606. PC_ParseWarning("Bad 1st parameter for keyword 'itemFocusSound'");
  3607. return qfalse;
  3608. }
  3609. uiInfo.uiDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse );
  3610. continue;
  3611. }
  3612. // menuBuzzSound
  3613. if (Q_stricmp(token, "menuBuzzSound") == 0)
  3614. {
  3615. if (PC_ParseString(&tempStr))
  3616. {
  3617. PC_ParseWarning("Bad 1st parameter for keyword 'menuBuzzSound'");
  3618. return qfalse;
  3619. }
  3620. uiInfo.uiDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse );
  3621. continue;
  3622. }
  3623. // Chose a force power from the ingame force allocation screen (the one where you get to allocate a force power point)
  3624. if (Q_stricmp(token, "forceChosenSound") == 0)
  3625. {
  3626. if (PC_ParseString(&tempStr))
  3627. {
  3628. PC_ParseWarning("Bad 1st parameter for keyword 'forceChosenSound'");
  3629. return qfalse;
  3630. }
  3631. uiInfo.uiDC.Assets.forceChosenSound = trap_S_RegisterSound( tempStr, qfalse );
  3632. continue;
  3633. }
  3634. // Unchose a force power from the ingame force allocation screen (the one where you get to allocate a force power point)
  3635. if (Q_stricmp(token, "forceUnchosenSound") == 0)
  3636. {
  3637. if (PC_ParseString(&tempStr))
  3638. {
  3639. PC_ParseWarning("Bad 1st parameter for keyword 'forceUnchosenSound'");
  3640. return qfalse;
  3641. }
  3642. uiInfo.uiDC.Assets.forceUnchosenSound = trap_S_RegisterSound( tempStr, qfalse );
  3643. continue;
  3644. }
  3645. if (Q_stricmp(token, "datapadmoveRollSound") == 0)
  3646. {
  3647. if (PC_ParseString(&tempStr))
  3648. {
  3649. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveRollSound'");
  3650. return qfalse;
  3651. }
  3652. uiInfo.uiDC.Assets.datapadmoveRollSound = trap_S_RegisterSound( tempStr, qfalse );
  3653. continue;
  3654. }
  3655. if (Q_stricmp(token, "datapadmoveJumpSound") == 0)
  3656. {
  3657. if (PC_ParseString(&tempStr))
  3658. {
  3659. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveRoll'");
  3660. return qfalse;
  3661. }
  3662. uiInfo.uiDC.Assets.datapadmoveJumpSound = trap_S_RegisterSound( tempStr, qfalse );
  3663. continue;
  3664. }
  3665. if (Q_stricmp(token, "datapadmoveSaberSound1") == 0)
  3666. {
  3667. if (PC_ParseString(&tempStr))
  3668. {
  3669. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound1'");
  3670. return qfalse;
  3671. }
  3672. uiInfo.uiDC.Assets.datapadmoveSaberSound1 = trap_S_RegisterSound( tempStr, qfalse );
  3673. continue;
  3674. }
  3675. if (Q_stricmp(token, "datapadmoveSaberSound2") == 0)
  3676. {
  3677. if (PC_ParseString(&tempStr))
  3678. {
  3679. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound2'");
  3680. return qfalse;
  3681. }
  3682. uiInfo.uiDC.Assets.datapadmoveSaberSound2 = trap_S_RegisterSound( tempStr, qfalse );
  3683. continue;
  3684. }
  3685. if (Q_stricmp(token, "datapadmoveSaberSound3") == 0)
  3686. {
  3687. if (PC_ParseString(&tempStr))
  3688. {
  3689. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound3'");
  3690. return qfalse;
  3691. }
  3692. uiInfo.uiDC.Assets.datapadmoveSaberSound3 = trap_S_RegisterSound( tempStr, qfalse );
  3693. continue;
  3694. }
  3695. if (Q_stricmp(token, "datapadmoveSaberSound4") == 0)
  3696. {
  3697. if (PC_ParseString(&tempStr))
  3698. {
  3699. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound4'");
  3700. return qfalse;
  3701. }
  3702. uiInfo.uiDC.Assets.datapadmoveSaberSound4 = trap_S_RegisterSound( tempStr, qfalse );
  3703. continue;
  3704. }
  3705. if (Q_stricmp(token, "datapadmoveSaberSound5") == 0)
  3706. {
  3707. if (PC_ParseString(&tempStr))
  3708. {
  3709. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound5'");
  3710. return qfalse;
  3711. }
  3712. uiInfo.uiDC.Assets.datapadmoveSaberSound5 = trap_S_RegisterSound( tempStr, qfalse );
  3713. continue;
  3714. }
  3715. if (Q_stricmp(token, "datapadmoveSaberSound6") == 0)
  3716. {
  3717. if (PC_ParseString(&tempStr))
  3718. {
  3719. PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound6'");
  3720. return qfalse;
  3721. }
  3722. uiInfo.uiDC.Assets.datapadmoveSaberSound6 = trap_S_RegisterSound( tempStr, qfalse );
  3723. continue;
  3724. }
  3725. #ifdef _IMMERSION
  3726. if (Q_stricmp(token, "menuEnterForce") == 0)
  3727. {
  3728. if (PC_ParseString(&tempStr))
  3729. {
  3730. PC_ParseWarning("Bad 1st parameter for keyword 'menuEnterForce'");
  3731. return qfalse;
  3732. }
  3733. uiInfo.uiDC.Assets.menuEnterForce = trap_FF_Register( tempStr );
  3734. continue;
  3735. }
  3736. if (Q_stricmp(token, "menuExitForce") == 0)
  3737. {
  3738. if (PC_ParseString(&tempStr))
  3739. {
  3740. PC_ParseWarning("Bad 1st parameter for keyword 'menuExitForce'");
  3741. return qfalse;
  3742. }
  3743. uiInfo.uiDC.Assets.menuExitForce = trap_FF_Register( tempStr );
  3744. continue;
  3745. }
  3746. if (Q_stricmp(token, "itemFocusForce") == 0)
  3747. {
  3748. if (PC_ParseString(&tempStr))
  3749. {
  3750. PC_ParseWarning("Bad 1st parameter for keyword 'itemFocusForce'");
  3751. return qfalse;
  3752. }
  3753. uiInfo.uiDC.Assets.itemFocusForce = trap_FF_Register( tempStr );
  3754. continue;
  3755. }
  3756. if (Q_stricmp(token, "menuBuzzForce") == 0)
  3757. {
  3758. if (PC_ParseString(&tempStr))
  3759. {
  3760. PC_ParseWarning("Bad 1st parameter for keyword 'menuBuzzForce'");
  3761. return qfalse;
  3762. }
  3763. uiInfo.uiDC.Assets.menuBuzzForce = trap_FF_Register( tempStr );
  3764. continue;
  3765. }
  3766. #endif // _IMMERSION
  3767. if (Q_stricmp(token, "cursor") == 0)
  3768. {
  3769. if (PC_ParseString(&tempStr))
  3770. {
  3771. PC_ParseWarning("Bad 1st parameter for keyword 'cursor'");
  3772. return qfalse;
  3773. }
  3774. // uiInfo.uiDC.Assets.cursor = ui.R_RegisterShaderNoMip( tempStr);
  3775. continue;
  3776. }
  3777. if (Q_stricmp(token, "fadeClamp") == 0)
  3778. {
  3779. if (PC_ParseFloat(&uiInfo.uiDC.Assets.fadeClamp))
  3780. {
  3781. PC_ParseWarning("Bad 1st parameter for keyword 'fadeClamp'");
  3782. return qfalse;
  3783. }
  3784. continue;
  3785. }
  3786. if (Q_stricmp(token, "fadeCycle") == 0)
  3787. {
  3788. if (PC_ParseInt(&uiInfo.uiDC.Assets.fadeCycle))
  3789. {
  3790. PC_ParseWarning("Bad 1st parameter for keyword 'fadeCycle'");
  3791. return qfalse;
  3792. }
  3793. continue;
  3794. }
  3795. if (Q_stricmp(token, "fadeAmount") == 0)
  3796. {
  3797. if (PC_ParseFloat(&uiInfo.uiDC.Assets.fadeAmount))
  3798. {
  3799. PC_ParseWarning("Bad 1st parameter for keyword 'fadeAmount'");
  3800. return qfalse;
  3801. }
  3802. continue;
  3803. }
  3804. if (Q_stricmp(token, "shadowX") == 0)
  3805. {
  3806. if (PC_ParseFloat(&uiInfo.uiDC.Assets.shadowX))
  3807. {
  3808. PC_ParseWarning("Bad 1st parameter for keyword 'shadowX'");
  3809. return qfalse;
  3810. }
  3811. continue;
  3812. }
  3813. if (Q_stricmp(token, "shadowY") == 0)
  3814. {
  3815. if (PC_ParseFloat(&uiInfo.uiDC.Assets.shadowY))
  3816. {
  3817. PC_ParseWarning("Bad 1st parameter for keyword 'shadowY'");
  3818. return qfalse;
  3819. }
  3820. continue;
  3821. }
  3822. if (Q_stricmp(token, "shadowColor") == 0)
  3823. {
  3824. if (PC_ParseColor(&uiInfo.uiDC.Assets.shadowColor))
  3825. {
  3826. PC_ParseWarning("Bad 1st parameter for keyword 'shadowColor'");
  3827. return qfalse;
  3828. }
  3829. uiInfo.uiDC.Assets.shadowFadeClamp = uiInfo.uiDC.Assets.shadowColor[3];
  3830. continue;
  3831. }
  3832. // precaching various sound files used in the menus
  3833. if (Q_stricmp(token, "precacheSound") == 0)
  3834. {
  3835. if (PC_Script_Parse(&tempStr))
  3836. {
  3837. char *soundFile;
  3838. do
  3839. {
  3840. soundFile = COM_ParseExt(&tempStr, qfalse);
  3841. if (soundFile[0] != 0 && soundFile[0] != ';') {
  3842. if (!trap_S_RegisterSound( soundFile, qfalse ))
  3843. {
  3844. PC_ParseWarning("Can't locate precache sound");
  3845. }
  3846. }
  3847. } while (soundFile[0]);
  3848. }
  3849. continue;
  3850. }
  3851. }
  3852. PC_ParseWarning(va("Invalid keyword '%s'",token));
  3853. return qfalse;
  3854. }
  3855. /*
  3856. =================
  3857. UI_Update
  3858. =================
  3859. */
  3860. static void UI_Update(const char *name)
  3861. {
  3862. int val = trap_Cvar_VariableValue(name);
  3863. if (Q_stricmp(name, "s_khz") == 0)
  3864. {
  3865. ui.Cmd_ExecuteText( EXEC_APPEND, "snd_restart\n" );
  3866. return;
  3867. }
  3868. #ifdef _IMMERSION
  3869. if (Q_stricmp(name, "ff") == 0)
  3870. {
  3871. ui.Cmd_ExecuteText( EXEC_APPEND, "ff_restart\n");
  3872. return;
  3873. }
  3874. #endif // _IMMERSION
  3875. if (Q_stricmp(name, "ui_SetName") == 0)
  3876. {
  3877. Cvar_Set( "name", UI_Cvar_VariableString("ui_Name"));
  3878. }
  3879. else if (Q_stricmp(name, "ui_setRate") == 0)
  3880. {
  3881. float rate = trap_Cvar_VariableValue("rate");
  3882. if (rate >= 5000)
  3883. {
  3884. Cvar_Set("cl_maxpackets", "30");
  3885. Cvar_Set("cl_packetdup", "1");
  3886. }
  3887. else if (rate >= 4000)
  3888. {
  3889. Cvar_Set("cl_maxpackets", "15");
  3890. Cvar_Set("cl_packetdup", "2"); // favor less prediction errors when there's packet loss
  3891. }
  3892. else
  3893. {
  3894. Cvar_Set("cl_maxpackets", "15");
  3895. Cvar_Set("cl_packetdup", "1"); // favor lower bandwidth
  3896. }
  3897. }
  3898. else if (Q_stricmp(name, "ui_GetName") == 0)
  3899. {
  3900. Cvar_Set( "ui_Name", UI_Cvar_VariableString("name"));
  3901. }
  3902. else if (Q_stricmp(name, "ui_r_colorbits") == 0)
  3903. {
  3904. switch (val)
  3905. {
  3906. case 0:
  3907. Cvar_SetValue( "ui_r_depthbits", 0 );
  3908. break;
  3909. case 16:
  3910. Cvar_SetValue( "ui_r_depthbits", 16 );
  3911. break;
  3912. case 32:
  3913. Cvar_SetValue( "ui_r_depthbits", 24 );
  3914. break;
  3915. }
  3916. }
  3917. else if (Q_stricmp(name, "ui_r_lodbias") == 0)
  3918. {
  3919. switch (val)
  3920. {
  3921. case 0:
  3922. Cvar_SetValue( "ui_r_subdivisions", 4 );
  3923. break;
  3924. case 1:
  3925. Cvar_SetValue( "ui_r_subdivisions", 12 );
  3926. break;
  3927. case 2:
  3928. Cvar_SetValue( "ui_r_subdivisions", 20 );
  3929. break;
  3930. }
  3931. }
  3932. else if (Q_stricmp(name, "ui_r_glCustom") == 0)
  3933. {
  3934. switch (val)
  3935. {
  3936. case 0: // high quality
  3937. Cvar_SetValue( "ui_r_fullScreen", 1 );
  3938. Cvar_SetValue( "ui_r_subdivisions", 4 );
  3939. Cvar_SetValue( "ui_r_lodbias", 0 );
  3940. Cvar_SetValue( "ui_r_colorbits", 32 );
  3941. Cvar_SetValue( "ui_r_depthbits", 24 );
  3942. Cvar_SetValue( "ui_r_picmip", 0 );
  3943. Cvar_SetValue( "ui_r_mode", 4 );
  3944. Cvar_SetValue( "ui_r_texturebits", 32 );
  3945. Cvar_SetValue( "ui_r_fastSky", 0 );
  3946. Cvar_SetValue( "ui_r_inGameVideo", 1 );
  3947. //Cvar_SetValue( "ui_cg_shadows", 2 );//stencil
  3948. Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
  3949. break;
  3950. case 1: // normal
  3951. Cvar_SetValue( "ui_r_fullScreen", 1 );
  3952. Cvar_SetValue( "ui_r_subdivisions", 4 );
  3953. Cvar_SetValue( "ui_r_lodbias", 0 );
  3954. Cvar_SetValue( "ui_r_colorbits", 0 );
  3955. Cvar_SetValue( "ui_r_depthbits", 24 );
  3956. Cvar_SetValue( "ui_r_picmip", 1 );
  3957. Cvar_SetValue( "ui_r_mode", 3 );
  3958. Cvar_SetValue( "ui_r_texturebits", 0 );
  3959. Cvar_SetValue( "ui_r_fastSky", 0 );
  3960. Cvar_SetValue( "ui_r_inGameVideo", 1 );
  3961. //Cvar_SetValue( "ui_cg_shadows", 2 );
  3962. Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
  3963. break;
  3964. case 2: // fast
  3965. Cvar_SetValue( "ui_r_fullScreen", 1 );
  3966. Cvar_SetValue( "ui_r_subdivisions", 12 );
  3967. Cvar_SetValue( "ui_r_lodbias", 1 );
  3968. Cvar_SetValue( "ui_r_colorbits", 0 );
  3969. Cvar_SetValue( "ui_r_depthbits", 0 );
  3970. Cvar_SetValue( "ui_r_picmip", 2 );
  3971. Cvar_SetValue( "ui_r_mode", 3 );
  3972. Cvar_SetValue( "ui_r_texturebits", 0 );
  3973. Cvar_SetValue( "ui_r_fastSky", 1 );
  3974. Cvar_SetValue( "ui_r_inGameVideo", 0 );
  3975. //Cvar_SetValue( "ui_cg_shadows", 1 );
  3976. Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_NEAREST" );
  3977. break;
  3978. case 3: // fastest
  3979. Cvar_SetValue( "ui_r_fullScreen", 1 );
  3980. Cvar_SetValue( "ui_r_subdivisions", 20 );
  3981. Cvar_SetValue( "ui_r_lodbias", 2 );
  3982. Cvar_SetValue( "ui_r_colorbits", 16 );
  3983. Cvar_SetValue( "ui_r_depthbits", 16 );
  3984. Cvar_SetValue( "ui_r_mode", 3 );
  3985. Cvar_SetValue( "ui_r_picmip", 3 );
  3986. Cvar_SetValue( "ui_r_texturebits", 16 );
  3987. Cvar_SetValue( "ui_r_fastSky", 1 );
  3988. Cvar_SetValue( "ui_r_inGameVideo", 0 );
  3989. //Cvar_SetValue( "ui_cg_shadows", 0 );
  3990. Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_NEAREST" );
  3991. break;
  3992. }
  3993. }
  3994. else
  3995. {//failure!!
  3996. Com_Printf("unknown UI script UPDATE %s\n", name);
  3997. }
  3998. }
  3999. #define ASSET_SCROLLBAR "gfx/menus/scrollbar.tga"
  4000. #define ASSET_SCROLLBAR_ARROWDOWN "gfx/menus/scrollbar_arrow_dwn_a.tga"
  4001. #define ASSET_SCROLLBAR_ARROWUP "gfx/menus/scrollbar_arrow_up_a.tga"
  4002. #define ASSET_SCROLLBAR_ARROWLEFT "gfx/menus/scrollbar_arrow_left.tga"
  4003. #define ASSET_SCROLLBAR_ARROWRIGHT "gfx/menus/scrollbar_arrow_right.tga"
  4004. #define ASSET_SCROLL_THUMB "gfx/menus/scrollbar_thumb.tga"
  4005. /*
  4006. =================
  4007. AssetCache
  4008. =================
  4009. */
  4010. void AssetCache(void)
  4011. {
  4012. // int n;
  4013. uiInfo.uiDC.Assets.scrollBar = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR );
  4014. uiInfo.uiDC.Assets.scrollBarArrowDown = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
  4015. uiInfo.uiDC.Assets.scrollBarArrowUp = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
  4016. uiInfo.uiDC.Assets.scrollBarArrowLeft = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
  4017. uiInfo.uiDC.Assets.scrollBarArrowRight = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );
  4018. uiInfo.uiDC.Assets.scrollBarThumb = ui.R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
  4019. uiInfo.uiDC.Assets.sliderBar = ui.R_RegisterShaderNoMip( "gfx/menus/newFront/slider" );
  4020. // uiInfo.uiDC.Assets.sliderThumb = ui.R_RegisterShaderNoMip( "menu/new/sliderthumb");
  4021. /*
  4022. for( n = 0; n < NUM_CROSSHAIRS; n++ )
  4023. {
  4024. uiInfo.uiDC.Assets.crosshairShader[n] = ui.R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) );
  4025. }
  4026. */
  4027. }
  4028. /*
  4029. ================
  4030. _UI_DrawSides
  4031. =================
  4032. */
  4033. void _UI_DrawSides(float x, float y, float w, float h, float size)
  4034. {
  4035. size *= uiInfo.uiDC.xscale;
  4036. trap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
  4037. trap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
  4038. }
  4039. /*
  4040. ================
  4041. _UI_DrawTopBottom
  4042. =================
  4043. */
  4044. void _UI_DrawTopBottom(float x, float y, float w, float h, float size)
  4045. {
  4046. size *= uiInfo.uiDC.yscale;
  4047. trap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
  4048. trap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
  4049. }
  4050. /*
  4051. ================
  4052. UI_DrawRect
  4053. Coordinates are 640*480 virtual values
  4054. =================
  4055. */
  4056. void _UI_DrawRect( float x, float y, float width, float height, float size, const float *color )
  4057. {
  4058. trap_R_SetColor( color );
  4059. _UI_DrawTopBottom(x, y, width, height, size);
  4060. _UI_DrawSides(x, y, width, height, size);
  4061. trap_R_SetColor( NULL );
  4062. }
  4063. /*
  4064. =================
  4065. UI_UpdateCvars
  4066. =================
  4067. */
  4068. void UI_UpdateCvars( void )
  4069. {
  4070. int i;
  4071. cvarTable_t *cv;
  4072. for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ )
  4073. {
  4074. Cvar_Update( cv->vmCvar );
  4075. }
  4076. }
  4077. /*
  4078. =================
  4079. UI_DrawEffects
  4080. =================
  4081. */
  4082. static void UI_DrawEffects(rectDef_t *rect, float scale, vec4_t color)
  4083. {
  4084. UI_DrawHandlePic( rect->x, rect->y - 14, 128, 8, 0/*uiInfo.uiDC.Assets.fxBasePic*/ );
  4085. UI_DrawHandlePic( rect->x + uiInfo.effectsColor * 16 + 8, rect->y - 16, 16, 12, 0/*uiInfo.uiDC.Assets.fxPic[uiInfo.effectsColor]*/ );
  4086. }
  4087. /*
  4088. =================
  4089. UI_Version
  4090. =================
  4091. */
  4092. static void UI_Version(rectDef_t *rect, float scale, vec4_t color, int iFontIndex)
  4093. {
  4094. int width;
  4095. width = DC->textWidth(Q3_VERSION, scale, 0);
  4096. DC->drawText(rect->x - width, rect->y, scale, color, Q3_VERSION, 0, ITEM_TEXTSTYLE_SHADOWED, iFontIndex);
  4097. }
  4098. /*
  4099. =================
  4100. UI_DrawKeyBindStatus
  4101. =================
  4102. */
  4103. static void UI_DrawKeyBindStatus(rectDef_t *rect, float scale, vec4_t color, int textStyle, int iFontIndex)
  4104. {
  4105. if (Display_KeyBindPending())
  4106. {
  4107. Text_Paint(rect->x, rect->y, scale, color, SE_GetString("MENUS_WAITINGFORKEY"), 0, textStyle, iFontIndex);
  4108. }
  4109. else
  4110. {
  4111. // Text_Paint(rect->x, rect->y, scale, color, ui.SP_GetStringTextString("MENUS_ENTERTOCHANGE"), 0, textStyle, iFontIndex);
  4112. }
  4113. }
  4114. /*
  4115. =================
  4116. UI_DrawKeyBindStatus
  4117. =================
  4118. */
  4119. static void UI_DrawGLInfo(rectDef_t *rect, float scale, vec4_t color, int textStyle, int iFontIndex)
  4120. {
  4121. #define MAX_LINES 64
  4122. char buff[4096];
  4123. char * eptr = buff;
  4124. const char *lines[MAX_LINES];
  4125. int y, numLines=0, i=0;
  4126. y = rect->y;
  4127. Text_Paint(rect->x, y, scale, color, va("GL_VENDOR: %s",uiInfo.uiDC.glconfig.vendor_string), rect->w, textStyle, iFontIndex);
  4128. y += 15;
  4129. Text_Paint(rect->x, y, scale, color, va("GL_VERSION: %s: %s", uiInfo.uiDC.glconfig.version_string,uiInfo.uiDC.glconfig.renderer_string), rect->w, textStyle, iFontIndex);
  4130. y += 15;
  4131. Text_Paint(rect->x, y, scale, color, "GL_PIXELFORMAT:", rect->w, textStyle, iFontIndex);
  4132. y += 15;
  4133. Text_Paint(rect->x, y, scale, color, va ("Color(%d-bits) Z(%d-bits) stencil(%d-bits)",uiInfo.uiDC.glconfig.colorBits, uiInfo.uiDC.glconfig.depthBits, uiInfo.uiDC.glconfig.stencilBits), rect->w, textStyle, iFontIndex);
  4134. y += 15;
  4135. // build null terminated extension strings
  4136. Q_strncpyz(buff, uiInfo.uiDC.glconfig.extensions_string, sizeof(buff));
  4137. int testy=y-16;
  4138. while ( testy <= rect->y + rect->h && *eptr && (numLines < MAX_LINES) )
  4139. {
  4140. while ( *eptr && *eptr == ' ' )
  4141. *eptr++ = '\0';
  4142. // track start of valid string
  4143. if (*eptr && *eptr != ' ')
  4144. {
  4145. lines[numLines++] = eptr;
  4146. testy+=16;
  4147. }
  4148. while ( *eptr && *eptr != ' ' )
  4149. eptr++;
  4150. }
  4151. numLines--;
  4152. while (i < numLines)
  4153. {
  4154. Text_Paint(rect->x, y, scale, color, lines[i++], rect->w, textStyle, iFontIndex);
  4155. y += 16;
  4156. }
  4157. }
  4158. /*
  4159. =================
  4160. UI_DataPad_Inventory
  4161. =================
  4162. */
  4163. /*
  4164. static void UI_DataPad_Inventory(rectDef_t *rect, float scale, vec4_t color, int iFontIndex)
  4165. {
  4166. Text_Paint(rect->x, rect->y, scale, color, "INVENTORY", 0, 1, iFontIndex);
  4167. }
  4168. */
  4169. /*
  4170. =================
  4171. UI_DataPad_ForcePowers
  4172. =================
  4173. */
  4174. /*
  4175. static void UI_DataPad_ForcePowers(rectDef_t *rect, float scale, vec4_t color, int iFontIndex)
  4176. {
  4177. Text_Paint(rect->x, rect->y, scale, color, "FORCE POWERS", 0, 1, iFontIndex);
  4178. }
  4179. */
  4180. static void UI_DrawCrosshair(rectDef_t *rect, float scale, vec4_t color) {
  4181. trap_R_SetColor( color );
  4182. if (uiInfo.currentCrosshair < 0 || uiInfo.currentCrosshair >= NUM_CROSSHAIRS) {
  4183. uiInfo.currentCrosshair = 0;
  4184. }
  4185. UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.uiDC.Assets.crosshairShader[uiInfo.currentCrosshair]);
  4186. trap_R_SetColor( NULL );
  4187. }
  4188. /*
  4189. =================
  4190. UI_SoftKeyboard
  4191. =================
  4192. */
  4193. static void UI_SoftKeyboardInit()
  4194. {
  4195. char strtmp[] = "";
  4196. DC->setCVar("keyboardinput", strtmp);
  4197. skb.activeKey=0;
  4198. skb.curCol=0;
  4199. skb.curRow=0;
  4200. skb.curStringPos=0;
  4201. }
  4202. static void UI_SoftKeyboardDelete()
  4203. {
  4204. char strtmp[SKB_STRING_LENGTH+1];
  4205. DC->getCVarString("keyboardinput", strtmp, SKB_STRING_LENGTH+1);
  4206. if(skb.curStringPos > 0)
  4207. {
  4208. skb.curStringPos--;
  4209. strtmp[skb.curStringPos] = 0;
  4210. }
  4211. DC->setCVar("keyboardinput", strtmp);
  4212. }
  4213. static void UI_SoftKeyboardAccept()
  4214. {
  4215. menuDef_t *menu = Menu_GetFocused();
  4216. itemDef_t *item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
  4217. if (menu->onAccept)
  4218. {
  4219. Item_RunScript(item, menu->onAccept);
  4220. }
  4221. }
  4222. static qboolean UI_SoftKeyboardDelete_HandleKey(int flags, float *special, int key)
  4223. {
  4224. menuDef_t *menu = Menu_GetFocused();
  4225. itemDef_t *item;
  4226. switch(key)
  4227. {
  4228. case A_CURSOR_UP:
  4229. skb.curRow = SKB_NUM_ROWS - 1;
  4230. if((skb.curRow * SKB_NUM_COLS + skb.curCol) >= SKB_NUM_LETTERS)
  4231. skb.curRow--;
  4232. item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
  4233. Item_SetFocus(item, 0, 0);
  4234. break;
  4235. case A_CURSOR_DOWN:
  4236. skb.curRow = 0;
  4237. item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
  4238. Item_SetFocus(item, 0, 0);
  4239. break;
  4240. case A_CURSOR_LEFT:
  4241. skb.curCol = SKB_NUM_COLS/2;
  4242. item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
  4243. Item_SetFocus(item, 0, 0);
  4244. break;
  4245. case A_CURSOR_RIGHT:
  4246. skb.curCol = SKB_NUM_COLS/2;
  4247. item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
  4248. Item_SetFocus(item, 0, 0);
  4249. break;
  4250. case A_MOUSE1:
  4251. UI_SoftKeyboardDelete();
  4252. break;
  4253. default:
  4254. break;
  4255. }
  4256. skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
  4257. return qtrue;
  4258. }
  4259. static qboolean UI_SoftKeyboardAccept_HandleKey(int flags, float *special, int key)
  4260. {
  4261. menuDef_t *menu = Menu_GetFocused();
  4262. itemDef_t *item;
  4263. switch(key)
  4264. {
  4265. case A_CURSOR_UP:
  4266. skb.curRow = SKB_NUM_ROWS - 1;
  4267. if((skb.curRow * SKB_NUM_COLS + skb.curCol) >= SKB_NUM_LETTERS)
  4268. skb.curRow--;
  4269. item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
  4270. Item_SetFocus(item, 0, 0);
  4271. break;
  4272. case A_CURSOR_DOWN:
  4273. skb.curRow = 0;
  4274. item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
  4275. Item_SetFocus(item, 0, 0);
  4276. break;
  4277. case A_CURSOR_LEFT:
  4278. skb.curCol = SKB_NUM_COLS/2-1;
  4279. item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
  4280. Item_SetFocus(item, 0, 0);
  4281. break;
  4282. case A_CURSOR_RIGHT:
  4283. skb.curCol = SKB_NUM_COLS/2-1;
  4284. item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
  4285. Item_SetFocus(item, 0, 0);
  4286. break;
  4287. case A_MOUSE1:
  4288. UI_SoftKeyboardAccept();
  4289. break;
  4290. default:
  4291. break;
  4292. }
  4293. skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
  4294. return qtrue;
  4295. }
  4296. static qboolean UI_SoftKeyboard_HandleKey(int flags, float *special, int key)
  4297. {
  4298. char strtmp[SKB_STRING_LENGTH+1];
  4299. menuDef_t *menu = Menu_GetFocused();
  4300. itemDef_t *item;
  4301. // If the user pressed A (mouse 1), just add a letter to our string and return
  4302. if(key == A_MOUSE1)
  4303. {
  4304. DC->getCVarString("keyboardinput", strtmp, SKB_STRING_LENGTH+1);
  4305. if(skb.curStringPos < SKB_STRING_LENGTH)
  4306. {
  4307. strtmp[skb.curStringPos] = letters[skb.activeKey][0];
  4308. skb.curStringPos++;
  4309. }
  4310. DC->setCVar("keyboardinput", strtmp);
  4311. return qtrue;
  4312. }
  4313. // Assuming the user pressed the D-pad, adjust the current row and column,
  4314. // and the associated active key position.
  4315. switch(key)
  4316. {
  4317. case A_CURSOR_UP:
  4318. skb.curRow-=1;
  4319. break;
  4320. case A_CURSOR_DOWN:
  4321. skb.curRow+=1;
  4322. break;
  4323. case A_CURSOR_LEFT:
  4324. skb.curCol-=1;
  4325. break;
  4326. case A_CURSOR_RIGHT:
  4327. skb.curCol+=1;
  4328. break;
  4329. default:
  4330. // We didn't handle this keypress.
  4331. return qfalse;
  4332. break;
  4333. }
  4334. skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
  4335. // Now make sure that the new active key is actually on the keyboard
  4336. // This means that the row and columns must be within bounds, and we
  4337. // must be on a letter (not on an empty space)
  4338. if(skb.activeKey < 0 || skb.activeKey >=SKB_NUM_LETTERS || skb.curCol >= SKB_NUM_COLS || skb.curCol < 0)
  4339. {
  4340. switch(key)
  4341. {
  4342. case A_CURSOR_UP:
  4343. // Wrap to bottom of KB
  4344. skb.curRow = SKB_NUM_ROWS - 1;
  4345. if(skb.curCol < SKB_NUM_COLS/2)
  4346. item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
  4347. else
  4348. item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
  4349. Item_SetFocus(item, 0, 0);
  4350. break;
  4351. case A_CURSOR_DOWN:
  4352. // Move to the next item below this
  4353. skb.curRow--;
  4354. if(skb.curCol < SKB_NUM_COLS/2)
  4355. item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
  4356. else
  4357. item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
  4358. Item_SetFocus(item, 0, 0);
  4359. break;
  4360. case A_CURSOR_LEFT:
  4361. // Wrap to the right side of the KB
  4362. if(skb.curRow == SKB_NUM_ROWS-1)
  4363. skb.curCol = SKB_NUM_LETTERS % SKB_NUM_COLS - 1;
  4364. else
  4365. skb.curCol = SKB_NUM_COLS - 1;
  4366. break;
  4367. case A_CURSOR_RIGHT:
  4368. // Wrap to the left side of the KB
  4369. skb.curCol=0;
  4370. break;
  4371. default:
  4372. break;
  4373. }
  4374. skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
  4375. }
  4376. return qtrue;
  4377. }
  4378. vec4_t color_unfocus = {0.7f, 0.7f, 0.8f, 1.0f};
  4379. vec4_t color_focus = {0.78f, 0.471f, 0.161f, 1.0f};
  4380. static void UI_SoftKeyboardAccept_Draw()
  4381. {
  4382. menuDef_t *menu = Menu_GetFocused();
  4383. itemDef_t *item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
  4384. int x = SKB_OK_X;
  4385. int y = SKB_OK_Y;
  4386. x -= DC->textWidth("OK", 1.0f, 2) / 2;
  4387. y -= DC->textHeight("OK", 1.0f, 2) / 2;
  4388. if(item->window.flags & WINDOW_HASFOCUS)
  4389. DC->drawText(x, y, 1.0f, color_focus, "OK", 1000, 0, 2);
  4390. else
  4391. DC->drawText(x, y, 1.0f, color_unfocus, "OK", 1000, 0, 2);
  4392. }
  4393. static void UI_SoftKeyboardDelete_Draw()
  4394. {
  4395. menuDef_t *menu = Menu_GetFocused();
  4396. itemDef_t *item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
  4397. int x = SKB_BACKSPACE_X;
  4398. int y = SKB_BACKSPACE_Y;
  4399. x -= DC->textWidth("Backspace", 1.0f, 2) / 2;
  4400. y -= DC->textHeight("Backspace", 1.0f, 2) / 2;
  4401. if(item->window.flags & WINDOW_HASFOCUS)
  4402. DC->drawText(x, y, 1.0f, color_focus, "Backspace", 1000, 0, 2);
  4403. else
  4404. DC->drawText(x, y, 1.0f, color_unfocus, "Backspace", 1000, 0, 2);
  4405. }
  4406. static void UI_SoftKeyboard_Draw()
  4407. {
  4408. menuDef_t *menu = Menu_GetFocused();
  4409. itemDef_t *item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
  4410. //draw each letter on the screen at the appropriate coordinates
  4411. int x,y;
  4412. float size;
  4413. vec4_t *color;
  4414. for(int cl=0; cl<SKB_NUM_LETTERS; cl++)
  4415. {
  4416. if(skb.activeKey == cl && (item->window.flags & WINDOW_HASFOCUS))
  4417. {
  4418. color = &color_focus;
  4419. size = 3.0f;
  4420. }
  4421. else
  4422. {
  4423. color = &color_unfocus;
  4424. size = 1.0f;
  4425. }
  4426. x = (cl%SKB_NUM_COLS) * SKB_SPACE_H + SKB_LEFT;
  4427. x -= (DC->textWidth(letters[cl], size, 2)) / 2;
  4428. y = (cl/SKB_NUM_COLS) * SKB_SPACE_V + SKB_TOP;
  4429. y -= ((DC->textHeight(letters[cl], size, 2)) / 2) * 1.5;
  4430. DC->drawText(x, y, size, *color, letters[cl], 1000, 0, 2);
  4431. }
  4432. char *strtmp = new char[SKB_STRING_LENGTH];
  4433. DC->getCVarString("keyboardinput", strtmp, SKB_STRING_LENGTH+1);
  4434. DC->drawText(SKB_STRING_LEFT, SKB_STRING_TOP, 1.5f, color_unfocus, strtmp, 1000, 0, 2);
  4435. }
  4436. /*
  4437. =================
  4438. UI_OwnerDraw
  4439. =================
  4440. */
  4441. static void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle, int iFontIndex)
  4442. {
  4443. rectDef_t rect;
  4444. rect.x = x + text_x;
  4445. rect.y = y + text_y;
  4446. rect.w = w;
  4447. rect.h = h;
  4448. switch (ownerDraw)
  4449. {
  4450. case UI_SOFT_KEYBOARD:
  4451. UI_SoftKeyboard_Draw();
  4452. break;
  4453. case UI_SOFT_KEYBOARD_ACCEPT:
  4454. UI_SoftKeyboardAccept_Draw();
  4455. break;
  4456. case UI_SOFT_KEYBOARD_DELETE:
  4457. UI_SoftKeyboardDelete_Draw();
  4458. break;
  4459. case UI_EFFECTS:
  4460. UI_DrawEffects(&rect, scale, color);
  4461. break;
  4462. case UI_VERSION:
  4463. UI_Version(&rect, scale, color, iFontIndex);
  4464. break;
  4465. case UI_DATAPAD_MISSION:
  4466. ui.Draw_DataPad(DP_OBJECTIVES);
  4467. break;
  4468. case UI_DATAPAD_WEAPONS:
  4469. ui.Draw_DataPad(DP_WEAPONS);
  4470. break;
  4471. /*
  4472. case UI_DATAPAD_INVENTORY:
  4473. ui.Draw_DataPad(DP_HUD);
  4474. ui.Draw_DataPad(DP_INVENTORY);
  4475. break;
  4476. */
  4477. case UI_DATAPAD_FORCEPOWERS:
  4478. ui.Draw_DataPad(DP_FORCEPOWERS);
  4479. break;
  4480. case UI_ALLMAPS_SELECTION://saved game thumbnail
  4481. //JLF MAPIMAGE MPNOTUSED
  4482. #ifdef _XBOX
  4483. //create a shader
  4484. UI_DrawHandlePic(x, y, w, h, shader);
  4485. #else
  4486. int levelshot;
  4487. levelshot = ui.R_RegisterShaderNoMip( va( "levelshots/%s", s_savedata[s_savegame.currentLine].currentSaveFileMap ) );
  4488. if (levelshot)
  4489. {
  4490. ui.R_DrawStretchPic( x, y, w, h, 0, 0, 1, 1, levelshot );
  4491. }
  4492. else
  4493. {
  4494. UI_DrawHandlePic(x, y, w, h, uis.menuBackShader);
  4495. }
  4496. #endif
  4497. /*
  4498. ui.R_Font_DrawString( x, // int ox
  4499. y+h, // int oy
  4500. s_savedata[s_savegame.currentLine].currentSaveFileMap, // const char *text
  4501. color, // paletteRGBA_c c
  4502. iFontIndex, // const int iFontHandle
  4503. w,//-1, // iMaxPixelWidth (-1 = none)
  4504. scale // const float scale = 1.0f
  4505. );
  4506. */
  4507. break;
  4508. case UI_PREVIEWCINEMATIC:
  4509. // FIXME BOB - make this work?
  4510. // UI_DrawPreviewCinematic(&rect, scale, color);
  4511. break;
  4512. case UI_CROSSHAIR:
  4513. UI_DrawCrosshair(&rect, scale, color);
  4514. break;
  4515. case UI_GLINFO:
  4516. UI_DrawGLInfo(&rect,scale, color, textStyle, iFontIndex);
  4517. break;
  4518. case UI_KEYBINDSTATUS:
  4519. UI_DrawKeyBindStatus(&rect,scale, color, textStyle, iFontIndex);
  4520. break;
  4521. default:
  4522. break;
  4523. }
  4524. }
  4525. /*
  4526. =================
  4527. UI_OwnerDrawVisible
  4528. =================
  4529. */
  4530. static qboolean UI_OwnerDrawVisible(int flags)
  4531. {
  4532. qboolean vis = qtrue;
  4533. while (flags)
  4534. {
  4535. /* if (flags & UI_SHOW_DEMOAVAILABLE)
  4536. {
  4537. if (!uiInfo.demoAvailable)
  4538. {
  4539. vis = qfalse;
  4540. }
  4541. flags &= ~UI_SHOW_DEMOAVAILABLE;
  4542. }
  4543. else
  4544. */ {
  4545. flags = 0;
  4546. }
  4547. }
  4548. return vis;
  4549. }
  4550. /*
  4551. =================
  4552. Text_Width
  4553. =================
  4554. */
  4555. int Text_Width(const char *text, float scale, int iFontIndex)
  4556. {
  4557. // temp code until Bob retro-fits all menus to have font specifiers...
  4558. //
  4559. if ( iFontIndex == 0 )
  4560. {
  4561. iFontIndex = uiInfo.uiDC.Assets.qhMediumFont;
  4562. }
  4563. return ui.R_Font_StrLenPixels(text, iFontIndex, scale);
  4564. }
  4565. /*
  4566. =================
  4567. UI_OwnerDrawWidth
  4568. =================
  4569. */
  4570. int UI_OwnerDrawWidth(int ownerDraw, float scale)
  4571. {
  4572. // int i, h, value;
  4573. // const char *text;
  4574. const char *s = NULL;
  4575. switch (ownerDraw)
  4576. {
  4577. case UI_KEYBINDSTATUS:
  4578. if (Display_KeyBindPending())
  4579. {
  4580. s = SE_GetString("MENUS_WAITINGFORKEY");
  4581. }
  4582. else
  4583. {
  4584. // s = ui.SP_GetStringTextString("MENUS_ENTERTOCHANGE");
  4585. }
  4586. break;
  4587. // FIXME BOB
  4588. // case UI_SERVERREFRESHDATE:
  4589. // s = UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer));
  4590. // break;
  4591. default:
  4592. break;
  4593. }
  4594. if (s)
  4595. {
  4596. return Text_Width(s, scale, 0);
  4597. }
  4598. return 0;
  4599. }
  4600. /*
  4601. =================
  4602. Text_Height
  4603. =================
  4604. */
  4605. int Text_Height(const char *text, float scale, int iFontIndex)
  4606. {
  4607. // temp until Bob retro-fits all menu files with font specifiers...
  4608. //
  4609. if ( iFontIndex == 0 )
  4610. {
  4611. iFontIndex = uiInfo.uiDC.Assets.qhMediumFont;
  4612. }
  4613. return ui.R_Font_HeightPixels(iFontIndex, scale);
  4614. }
  4615. /*
  4616. =================
  4617. UI_MouseEvent
  4618. =================
  4619. */
  4620. //JLFMOUSE CALLED EACH FRAME IN UI
  4621. void _UI_MouseEvent( int dx, int dy )
  4622. {
  4623. // update mouse screen position
  4624. uiInfo.uiDC.cursorx += dx;
  4625. if (uiInfo.uiDC.cursorx < 0)
  4626. {
  4627. uiInfo.uiDC.cursorx = 0;
  4628. }
  4629. else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH)
  4630. {
  4631. uiInfo.uiDC.cursorx = SCREEN_WIDTH;
  4632. }
  4633. uiInfo.uiDC.cursory += dy;
  4634. if (uiInfo.uiDC.cursory < 0)
  4635. {
  4636. uiInfo.uiDC.cursory = 0;
  4637. }
  4638. else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT)
  4639. {
  4640. uiInfo.uiDC.cursory = SCREEN_HEIGHT;
  4641. }
  4642. if ( dy > SCROLL_SENSITIVITY || dy < -SCROLL_SENSITIVITY)
  4643. gScrollAccum += dy;
  4644. gScrollDelta =0;
  4645. if (gScrollAccum > TEXTSCROLLDESCRETESTEP)
  4646. {
  4647. gScrollDelta =1;
  4648. gScrollAccum =0;
  4649. }
  4650. else if (gScrollAccum <0)
  4651. {
  4652. gScrollDelta = -1;
  4653. gScrollAccum = TEXTSCROLLDESCRETESTEP;
  4654. }
  4655. if (Menu_Count() > 0)
  4656. {
  4657. //menuDef_t *menu = Menu_GetFocused();
  4658. //Menu_HandleMouseMove(menu, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);
  4659. Display_MouseMove(NULL, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);
  4660. }
  4661. }
  4662. /*
  4663. =================
  4664. UI_KeyEvent
  4665. =================
  4666. */
  4667. void _UI_KeyEvent( int key, qboolean down )
  4668. {
  4669. /* extern qboolean SwallowBadNumLockedKPKey( int iKey );
  4670. if (SwallowBadNumLockedKPKey(key)){
  4671. return;
  4672. }
  4673. */
  4674. if (Menu_Count() > 0)
  4675. {
  4676. menuDef_t *menu = Menu_GetFocused();
  4677. if (menu)
  4678. {
  4679. //DemoEnd();
  4680. //JLF MPMOVED
  4681. #ifdef _XBOX
  4682. // extern void G_DemoKeypress();//JLF new
  4683. // G_DemoKeypress(); //JLF new
  4684. extern void UpdateDemoTimer();
  4685. UpdateDemoTimer();
  4686. #endif
  4687. if (key == A_ESCAPE && down && !Menus_AnyFullScreenVisible() && !(menu->window.flags & WINDOW_IGNORE_ESCAPE))
  4688. {
  4689. Menus_CloseAll();
  4690. }
  4691. else
  4692. {
  4693. Menu_HandleKey(menu, key, down );
  4694. }
  4695. }
  4696. else
  4697. {
  4698. trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );
  4699. trap_Key_ClearStates();
  4700. Cvar_Set( "cl_paused", "0" );
  4701. }
  4702. }
  4703. }
  4704. /*
  4705. =================
  4706. UI_Report
  4707. =================
  4708. */
  4709. void UI_Report(void)
  4710. {
  4711. String_Report();
  4712. }
  4713. /*
  4714. =================
  4715. UI_DataPadMenu
  4716. =================
  4717. */
  4718. void UI_DataPadMenu(void)
  4719. {
  4720. int newForcePower,newObjective;
  4721. Menus_CloseByName("mainhud");
  4722. newForcePower = (int)trap_Cvar_VariableValue("cg_updatedDataPadForcePower1");
  4723. newObjective = (int)trap_Cvar_VariableValue("cg_updatedDataPadObjective");
  4724. if (newForcePower)
  4725. {
  4726. Menus_ActivateByName("datapadForcePowersMenu");
  4727. }
  4728. else if (newObjective)
  4729. {
  4730. Menus_ActivateByName("datapadMissionMenu");
  4731. }
  4732. else
  4733. {
  4734. Menus_ActivateByName("datapadMissionMenu");
  4735. }
  4736. ui.Key_SetCatcher( KEYCATCH_UI );
  4737. }
  4738. /*
  4739. =================
  4740. UI_InGameMenu
  4741. =================
  4742. */
  4743. extern void S_StopAllSoundsExceptMusic(void);
  4744. void UI_InGameMenu(const char*menuID)
  4745. {
  4746. // don't allow this if you are dead
  4747. if( menuID && !strcmp(menuID, "noController"))
  4748. {
  4749. // do nothing
  4750. }
  4751. else if ( svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
  4752. {
  4753. ui.Cvar_Set( "cl_paused", "0" );
  4754. return;
  4755. }
  4756. #ifdef _XBOX
  4757. ui.PrecacheScreenshot();
  4758. #endif
  4759. Menus_CloseByName("mainhud");
  4760. if (menuID)
  4761. {
  4762. Menus_ActivateByName(menuID);
  4763. }
  4764. else
  4765. {
  4766. S_StopAllSoundsExceptMusic();
  4767. Menus_ActivateByName("ingameMainMenu");
  4768. }
  4769. ui.Key_SetCatcher( KEYCATCH_UI );
  4770. }
  4771. qboolean _UI_IsFullscreen( void )
  4772. {
  4773. return Menus_AnyFullScreenVisible();
  4774. }
  4775. /*
  4776. =======================================================================
  4777. MAIN MENU
  4778. =======================================================================
  4779. */
  4780. /*
  4781. ===============
  4782. UI_MainMenu
  4783. The main menu only comes up when not in a game,
  4784. so make sure that the attract loop server is down
  4785. and that local cinematics are killed
  4786. ===============
  4787. */
  4788. void UI_MainMenu(void)
  4789. {
  4790. char buf[256];
  4791. ui.Cvar_Set("sv_killserver", "1"); // let the demo server know it should shut down
  4792. ui.Key_SetCatcher( KEYCATCH_UI );
  4793. menuDef_t *m = Menus_ActivateByName("mainMenu");
  4794. if (!m)
  4795. { //wha? try again
  4796. UI_LoadMenus("ui/menus.txt",qfalse);
  4797. }
  4798. ui.Cvar_VariableStringBuffer("com_errorMessage", buf, sizeof(buf));
  4799. if (strlen(buf)) {
  4800. Menus_ActivateByName("error_popmenu");
  4801. }
  4802. }
  4803. /*
  4804. =================
  4805. Menu_Cache
  4806. =================
  4807. */
  4808. void Menu_Cache( void )
  4809. {
  4810. // uis.cursor = ui.R_RegisterShaderNoMip( "menu/new/crosshairb");
  4811. // Common menu graphics
  4812. uis.whiteShader = ui.R_RegisterShader( "white" );
  4813. // uis.menuBackShader = ui.R_RegisterShaderNoMip( "menu/art/unknownmap" );
  4814. }
  4815. /*
  4816. =================
  4817. UI_UpdateVideoSetup
  4818. Copies the temporary user interface version of the video cvars into
  4819. their real counterparts. This is to create a interface which allows
  4820. you to discard your changes if you did something you didnt want
  4821. =================
  4822. */
  4823. void UI_UpdateVideoSetup ( void )
  4824. {
  4825. Cvar_Set ( "r_mode", Cvar_VariableString ( "ui_r_mode" ) );
  4826. Cvar_Set ( "r_fullscreen", Cvar_VariableString ( "ui_r_fullscreen" ) );
  4827. Cvar_Set ( "r_colorbits", Cvar_VariableString ( "ui_r_colorbits" ) );
  4828. Cvar_Set ( "r_lodbias", Cvar_VariableString ( "ui_r_lodbias" ) );
  4829. Cvar_Set ( "r_picmip", Cvar_VariableString ( "ui_r_picmip" ) );
  4830. Cvar_Set ( "r_texturebits", Cvar_VariableString ( "ui_r_texturebits" ) );
  4831. Cvar_Set ( "r_texturemode", Cvar_VariableString ( "ui_r_texturemode" ) );
  4832. Cvar_Set ( "r_detailtextures", Cvar_VariableString ( "ui_r_detailtextures" ) );
  4833. Cvar_Set ( "r_ext_compress_textures", Cvar_VariableString ( "ui_r_ext_compress_textures" ) );
  4834. Cvar_Set ( "r_depthbits", Cvar_VariableString ( "ui_r_depthbits" ) );
  4835. Cvar_Set ( "r_subdivisions", Cvar_VariableString ( "ui_r_subdivisions" ) );
  4836. Cvar_Set ( "r_fastSky", Cvar_VariableString ( "ui_r_fastSky" ) );
  4837. Cvar_Set ( "r_inGameVideo", Cvar_VariableString ( "ui_r_inGameVideo" ) );
  4838. Cvar_Set ( "r_allowExtensions", Cvar_VariableString ( "ui_r_allowExtensions" ) );
  4839. // Cvar_Set ( "cg_shadows", Cvar_VariableString ( "ui_cg_shadows" ) );
  4840. Cvar_Set ( "ui_r_modified", "0" );
  4841. Cbuf_ExecuteText( EXEC_APPEND, "vid_restart;" );
  4842. }
  4843. /*
  4844. =================
  4845. UI_GetVideoSetup
  4846. Retrieves the current actual video settings into the temporary user
  4847. interface versions of the cvars.
  4848. =================
  4849. */
  4850. void UI_GetVideoSetup ( void )
  4851. {
  4852. // Make sure the cvars are registered as read only.
  4853. Cvar_Register ( NULL, "ui_r_glCustom", "4", CVAR_ROM|CVAR_ARCHIVE );
  4854. Cvar_Register ( NULL, "ui_r_mode", "0", CVAR_ROM );
  4855. Cvar_Register ( NULL, "ui_r_fullscreen", "0", CVAR_ROM );
  4856. Cvar_Register ( NULL, "ui_r_colorbits", "0", CVAR_ROM );
  4857. Cvar_Register ( NULL, "ui_r_lodbias", "0", CVAR_ROM );
  4858. Cvar_Register ( NULL, "ui_r_picmip", "0", CVAR_ROM );
  4859. Cvar_Register ( NULL, "ui_r_texturebits", "0", CVAR_ROM );
  4860. Cvar_Register ( NULL, "ui_r_texturemode", "0", CVAR_ROM );
  4861. Cvar_Register ( NULL, "ui_r_detailtextures", "0", CVAR_ROM );
  4862. Cvar_Register ( NULL, "ui_r_ext_compress_textures", "0", CVAR_ROM );
  4863. Cvar_Register ( NULL, "ui_r_depthbits", "0", CVAR_ROM );
  4864. Cvar_Register ( NULL, "ui_r_subdivisions", "0", CVAR_ROM );
  4865. Cvar_Register ( NULL, "ui_r_fastSky", "0", CVAR_ROM );
  4866. Cvar_Register ( NULL, "ui_r_inGameVideo", "0", CVAR_ROM );
  4867. Cvar_Register ( NULL, "ui_r_allowExtensions", "0", CVAR_ROM );
  4868. // Cvar_Register ( NULL, "ui_cg_shadows", "0", CVAR_ROM );
  4869. Cvar_Register ( NULL, "ui_r_modified", "0", CVAR_ROM );
  4870. // Copy over the real video cvars into their temporary counterparts
  4871. Cvar_Set ( "ui_r_mode", Cvar_VariableString ( "r_mode" ) );
  4872. Cvar_Set ( "ui_r_colorbits", Cvar_VariableString ( "r_colorbits" ) );
  4873. Cvar_Set ( "ui_r_fullscreen", Cvar_VariableString ( "r_fullscreen" ) );
  4874. Cvar_Set ( "ui_r_lodbias", Cvar_VariableString ( "r_lodbias" ) );
  4875. Cvar_Set ( "ui_r_picmip", Cvar_VariableString ( "r_picmip" ) );
  4876. Cvar_Set ( "ui_r_texturebits", Cvar_VariableString ( "r_texturebits" ) );
  4877. Cvar_Set ( "ui_r_texturemode", Cvar_VariableString ( "r_texturemode" ) );
  4878. Cvar_Set ( "ui_r_detailtextures", Cvar_VariableString ( "r_detailtextures" ) );
  4879. Cvar_Set ( "ui_r_ext_compress_textures", Cvar_VariableString ( "r_ext_compress_textures" ) );
  4880. Cvar_Set ( "ui_r_depthbits", Cvar_VariableString ( "r_depthbits" ) );
  4881. Cvar_Set ( "ui_r_subdivisions", Cvar_VariableString ( "r_subdivisions" ) );
  4882. Cvar_Set ( "ui_r_fastSky", Cvar_VariableString ( "r_fastSky" ) );
  4883. Cvar_Set ( "ui_r_inGameVideo", Cvar_VariableString ( "r_inGameVideo" ) );
  4884. Cvar_Set ( "ui_r_allowExtensions", Cvar_VariableString ( "r_allowExtensions" ) );
  4885. // Cvar_Set ( "ui_cg_shadows", Cvar_VariableString ( "cg_shadows" ) );
  4886. Cvar_Set ( "ui_r_modified", "0" );
  4887. }
  4888. static void UI_SetSexandSoundForModel(const char* char_model)
  4889. {
  4890. int f,i;
  4891. char soundpath[MAX_QPATH];
  4892. qboolean isFemale = qfalse;
  4893. i = ui.FS_FOpenFile(va("models/players/%s/sounds.cfg", char_model), &f, FS_READ);
  4894. if ( !f )
  4895. {//no? oh bother.
  4896. Cvar_Reset("snd");
  4897. Cvar_Reset("sex");
  4898. return;
  4899. }
  4900. soundpath[0] = 0;
  4901. ui.FS_Read(&soundpath, i, f);
  4902. while (i >= 0 && soundpath[i] != '\n')
  4903. {
  4904. if (soundpath[i] == 'f')
  4905. {
  4906. isFemale = qtrue;
  4907. soundpath[i] = 0;
  4908. }
  4909. i--;
  4910. }
  4911. i = 0;
  4912. while (soundpath[i] && soundpath[i] != '\r' && soundpath[i] != '\n')
  4913. {
  4914. i++;
  4915. }
  4916. soundpath[i] = 0;
  4917. ui.FS_FCloseFile(f);
  4918. Cvar_Set ( "snd", soundpath);
  4919. if (isFemale)
  4920. {
  4921. Cvar_Set ( "sex", "f");
  4922. }
  4923. else
  4924. {
  4925. Cvar_Set ( "sex", "m");
  4926. }
  4927. }
  4928. static void UI_UpdateCharacterCvars ( void )
  4929. {
  4930. const char *char_model = Cvar_VariableString ( "ui_char_model" );
  4931. UI_SetSexandSoundForModel(char_model);
  4932. Cvar_Set ( "g_char_model", char_model );
  4933. Cvar_Set ( "g_char_skin_head", Cvar_VariableString ( "ui_char_skin_head" ) );
  4934. Cvar_Set ( "g_char_skin_torso", Cvar_VariableString ( "ui_char_skin_torso" ) );
  4935. Cvar_Set ( "g_char_skin_legs", Cvar_VariableString ( "ui_char_skin_legs" ) );
  4936. Cvar_Set ( "g_char_color_red", Cvar_VariableString ( "ui_char_color_red" ) );
  4937. Cvar_Set ( "g_char_color_green", Cvar_VariableString ( "ui_char_color_green" ) );
  4938. Cvar_Set ( "g_char_color_blue", Cvar_VariableString ( "ui_char_color_blue" ) );
  4939. }
  4940. static void UI_GetCharacterCvars ( void )
  4941. {
  4942. Cvar_Set ( "ui_char_skin_head", Cvar_VariableString ( "g_char_skin_head" ) );
  4943. Cvar_Set ( "ui_char_skin_torso", Cvar_VariableString ( "g_char_skin_torso" ) );
  4944. Cvar_Set ( "ui_char_skin_legs", Cvar_VariableString ( "g_char_skin_legs" ) );
  4945. Cvar_Set ( "ui_char_color_red", Cvar_VariableString ( "g_char_color_red" ) );
  4946. Cvar_Set ( "ui_char_color_green", Cvar_VariableString ( "g_char_color_green" ) );
  4947. Cvar_Set ( "ui_char_color_blue", Cvar_VariableString ( "g_char_color_blue" ) );
  4948. char* model = Cvar_VariableString ( "g_char_model" );
  4949. Cvar_Set ( "ui_char_model", model );
  4950. for (int i = 0; i < uiInfo.playerSpeciesCount; i++)
  4951. {
  4952. if ( !stricmp(model, uiInfo.playerSpecies[i].Name) )
  4953. {
  4954. uiInfo.playerSpeciesIndex = i;
  4955. }
  4956. }
  4957. }
  4958. static void UI_UpdateSaberCvars ( void )
  4959. {
  4960. Cvar_Set ( "g_saber_type", Cvar_VariableString ( "ui_saber_type" ) );
  4961. Cvar_Set ( "g_saber", Cvar_VariableString ( "ui_saber" ) );
  4962. Cvar_Set ( "g_saber2", Cvar_VariableString ( "ui_saber2" ) );
  4963. Cvar_Set ( "g_saber_color", Cvar_VariableString ( "ui_saber_color" ) );
  4964. Cvar_Set ( "g_saber2_color", Cvar_VariableString ( "ui_saber2_color" ) );
  4965. }
  4966. static void UI_UpdateFightingStyleChoices ( void )
  4967. {
  4968. //
  4969. if (!strcmpi("staff",Cvar_VariableString ( "ui_saber_type" )))
  4970. {
  4971. Cvar_Set ( "ui_fightingstylesallowed", "0" );
  4972. Cvar_Set ( "ui_newfightingstyle", "1" ); // Default, MEDIUM
  4973. }
  4974. else if (!strcmpi("dual",Cvar_VariableString ( "ui_saber_type" )))
  4975. {
  4976. Cvar_Set ( "ui_fightingstylesallowed", "0" );
  4977. Cvar_Set ( "ui_newfightingstyle", "1" ); // Default, MEDIUM
  4978. }
  4979. else
  4980. {
  4981. // Get player state
  4982. client_t *cl = &svs.clients[0]; // 0 because only ever us as a player
  4983. playerState_t *pState;
  4984. if (cl && cl->gentity && cl->gentity->client)
  4985. {
  4986. pState = cl->gentity->client;
  4987. // Knows Fast style?
  4988. if (pState->saberStylesKnown & (1<<SS_FAST))
  4989. {
  4990. // And Medium?
  4991. if (pState->saberStylesKnown & (1<<SS_MEDIUM))
  4992. {
  4993. Cvar_Set ( "ui_fightingstylesallowed", "6" ); // Has FAST and MEDIUM, so can only choose STRONG
  4994. Cvar_Set ( "ui_newfightingstyle", "2" ); // STRONG
  4995. }
  4996. else
  4997. {
  4998. Cvar_Set ( "ui_fightingstylesallowed", "1" ); // Has FAST, so can choose from MEDIUM and STRONG
  4999. Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
  5000. }
  5001. }
  5002. // Knows Medium style?
  5003. else if (pState->saberStylesKnown & (1<<SS_MEDIUM))
  5004. {
  5005. // And Strong?
  5006. if (pState->saberStylesKnown & (1<<SS_STRONG))
  5007. {
  5008. Cvar_Set ( "ui_fightingstylesallowed", "4" ); // Has MEDIUM and STRONG, so can only choose FAST
  5009. Cvar_Set ( "ui_newfightingstyle", "0" ); // FAST
  5010. }
  5011. else
  5012. {
  5013. Cvar_Set ( "ui_fightingstylesallowed", "2" ); // Has MEDIUM, so can choose from FAST and STRONG
  5014. Cvar_Set ( "ui_newfightingstyle", "0" ); // FAST
  5015. }
  5016. }
  5017. // Knows Strong style?
  5018. else if (pState->saberStylesKnown & (1<<SS_STRONG))
  5019. {
  5020. // And Fast
  5021. if (pState->saberStylesKnown & (1<<SS_FAST))
  5022. {
  5023. Cvar_Set ( "ui_fightingstylesallowed", "5" ); // Has STRONG and FAST, so can only take MEDIUM
  5024. Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
  5025. }
  5026. else
  5027. {
  5028. Cvar_Set ( "ui_fightingstylesallowed", "3" ); // Has STRONG, so can choose from FAST and MEDIUM
  5029. Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
  5030. }
  5031. }
  5032. else // They have nothing, which should not happen
  5033. {
  5034. Cvar_Set ( "ui_currentfightingstyle", "1" ); // Default MEDIUM
  5035. Cvar_Set ( "ui_newfightingstyle", "0" ); // FAST??
  5036. Cvar_Set ( "ui_fightingstylesallowed", "0" ); // Default to no new styles allowed
  5037. }
  5038. // Determine current style
  5039. if (pState->saberAnimLevel == SS_FAST)
  5040. {
  5041. Cvar_Set ( "ui_currentfightingstyle", "0" ); // FAST
  5042. }
  5043. else if (pState->saberAnimLevel == SS_STRONG)
  5044. {
  5045. Cvar_Set ( "ui_currentfightingstyle", "2" ); // STRONG
  5046. }
  5047. else
  5048. {
  5049. Cvar_Set ( "ui_currentfightingstyle", "1" ); // default MEDIUM
  5050. }
  5051. }
  5052. else // No client so this must be first time
  5053. {
  5054. Cvar_Set ( "ui_currentfightingstyle", "1" ); // Default to MEDIUM
  5055. Cvar_Set ( "ui_fightingstylesallowed", "0" ); // Default to no new styles allowed
  5056. Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
  5057. }
  5058. }
  5059. }
  5060. #define MAX_POWER_ENUMS 16
  5061. typedef struct {
  5062. char *title;
  5063. short powerEnum;
  5064. } powerEnum_t;
  5065. static powerEnum_t powerEnums[MAX_POWER_ENUMS] =
  5066. {
  5067. "absorb", FP_ABSORB,
  5068. "heal", FP_HEAL,
  5069. "mindtrick", FP_TELEPATHY,
  5070. "protect", FP_PROTECT,
  5071. // Core powers
  5072. "jump", FP_LEVITATION,
  5073. "pull", FP_PULL,
  5074. "push", FP_PUSH,
  5075. "sense", FP_SEE,
  5076. "speed", FP_SPEED,
  5077. "sabdef", FP_SABER_DEFENSE,
  5078. "saboff", FP_SABER_OFFENSE,
  5079. "sabthrow", FP_SABERTHROW,
  5080. // Dark powers
  5081. "drain", FP_DRAIN,
  5082. "grip", FP_GRIP,
  5083. "lightning", FP_LIGHTNING,
  5084. "rage", FP_RAGE
  5085. };
  5086. // Find the index to the Force Power in powerEnum array
  5087. static qboolean UI_GetForcePowerIndex ( const char *forceName, short *forcePowerI )
  5088. {
  5089. int i;
  5090. // Find a match for the forceName passed in
  5091. for (i=0;i<MAX_POWER_ENUMS;i++)
  5092. {
  5093. if ( !Q_stricmp(forceName, powerEnums[i].title ) )
  5094. {
  5095. *forcePowerI = i;
  5096. return(qtrue);
  5097. }
  5098. }
  5099. *forcePowerI = FP_UPDATED_NONE; // Didn't find it
  5100. return(qfalse);
  5101. }
  5102. // Set the fields for the allocation of force powers (Used by Force Power Allocation screen)
  5103. static void UI_InitAllocForcePowers ( const char *forceName )
  5104. {
  5105. menuDef_t *menu;
  5106. itemDef_t *item;
  5107. short forcePowerI=0;
  5108. menu = Menu_GetFocused(); // Get current menu
  5109. if (!menu)
  5110. {
  5111. return;
  5112. }
  5113. if (!UI_GetForcePowerIndex ( forceName, &forcePowerI ))
  5114. {
  5115. return;
  5116. }
  5117. #ifndef XBOX_DEMO
  5118. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5119. if (!cl)
  5120. {
  5121. return;
  5122. }
  5123. playerState_t* pState = cl->gentity->client;
  5124. #endif
  5125. char itemName[128];
  5126. Com_sprintf (itemName, sizeof(itemName), "%s_hexpic", powerEnums[forcePowerI].title);
  5127. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5128. if (item)
  5129. {
  5130. char itemGraphic[128];
  5131. Com_sprintf (itemGraphic, sizeof(itemGraphic), "gfx/menus/hex_pattern_%d",
  5132. #ifdef XBOX_DEMO
  5133. demoForcePowerLevel[powerEnums[forcePowerI].powerEnum]);
  5134. #else
  5135. pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]);
  5136. #endif
  5137. item->window.background = ui.R_RegisterShaderNoMip(itemGraphic);
  5138. // If maxed out on power - don't allow update
  5139. /* if (pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]>=3)
  5140. {
  5141. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[forcePowerI].title);
  5142. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5143. if (item) // This is okay, because core powers don't have a hex button
  5144. {
  5145. item->window.flags &= ~WINDOW_VISIBLE;
  5146. }
  5147. } */
  5148. }
  5149. // Set weapons button to inactive
  5150. if( Q_stricmp(menu->window.name, "ingameForceStatus") != 0 )
  5151. UI_ForcePowerWeaponsButton(qfalse);
  5152. }
  5153. // Flip flop between being able to see the text showing the Force Point has or hasn't been allocated (Used by Force Power Allocation screen)
  5154. static void UI_SetPowerTitleText ( qboolean showAllocated )
  5155. {
  5156. menuDef_t *menu;
  5157. itemDef_t *item;
  5158. menu = Menu_GetFocused(); // Get current menu
  5159. if (!menu)
  5160. {
  5161. return;
  5162. }
  5163. if (showAllocated)
  5164. {
  5165. // Show the text saying the force point has been allocated
  5166. item = (itemDef_s *) Menu_FindItemByName(menu, "allocated_text");
  5167. if (item)
  5168. {
  5169. item->window.flags |= WINDOW_VISIBLE;
  5170. }
  5171. // Hide text saying the force point needs to be allocated
  5172. item = (itemDef_s *) Menu_FindItemByName(menu, "allocate_text");
  5173. if (item)
  5174. {
  5175. item->window.flags &= ~WINDOW_VISIBLE;
  5176. }
  5177. }
  5178. else
  5179. {
  5180. // Hide the text saying the force point has been allocated
  5181. item = (itemDef_s *) Menu_FindItemByName(menu, "allocated_text");
  5182. if (item)
  5183. {
  5184. item->window.flags &= ~WINDOW_VISIBLE;
  5185. }
  5186. // Show text saying the force point needs to be allocated
  5187. item = (itemDef_s *) Menu_FindItemByName(menu, "allocate_text");
  5188. if (item)
  5189. {
  5190. item->window.flags |= WINDOW_VISIBLE;
  5191. }
  5192. }
  5193. }
  5194. //. Find weapons button and make active/inactive (Used by Force Power Allocation screen)
  5195. static void UI_ForcePowerWeaponsButton(qboolean activeFlag)
  5196. {
  5197. menuDef_t *menu;
  5198. menu = Menu_GetFocused(); // Get current menu
  5199. if (!menu)
  5200. {
  5201. return;
  5202. }
  5203. // Find weaponsbutton
  5204. itemDef_t *item;
  5205. item = (itemDef_s *) Menu_FindItemByName(menu, "weaponbutton");
  5206. if (item)
  5207. {
  5208. // Make it active
  5209. if (activeFlag)
  5210. {
  5211. item->window.flags |= WINDOW_VISIBLE;
  5212. Item_SetFocus(item, 0, 0);
  5213. }
  5214. else
  5215. {
  5216. item->window.flags &= ~WINDOW_VISIBLE;
  5217. }
  5218. }
  5219. //UI_SetVis(menu, "tab_Force", !activeFlag);
  5220. if(activeFlag)
  5221. DC->setCVar("ui_hideAcallout", "0");
  5222. else
  5223. DC->setCVar("ui_hideAcallout", "1");
  5224. }
  5225. void UI_SetItemColor(itemDef_t *item,const char *itemname,const char *name,vec4_t color);
  5226. static void UI_SetHexPicLevel( const menuDef_t *menu,const int forcePowerI,const int powerLevel, const qboolean goldFlag )
  5227. {
  5228. char itemName[128];
  5229. itemDef_t *item;
  5230. // Find proper hex picture on menu
  5231. Com_sprintf (itemName, sizeof(itemName), "%s_hexpic", powerEnums[forcePowerI].title);
  5232. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, itemName);
  5233. // Now give it the proper hex graphic
  5234. if (item)
  5235. {
  5236. char itemGraphic[128];
  5237. if (goldFlag)
  5238. {
  5239. Com_sprintf (itemGraphic, sizeof(itemGraphic), "gfx/menus/hex_pattern_%d_gold",powerLevel);
  5240. }
  5241. else
  5242. {
  5243. Com_sprintf (itemGraphic, sizeof(itemGraphic), "gfx/menus/hex_pattern_%d",powerLevel);
  5244. }
  5245. item->window.background = ui.R_RegisterShaderNoMip(itemGraphic);
  5246. /*
  5247. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[forcePowerI].title);
  5248. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *)menu, itemName);
  5249. if (item)
  5250. {
  5251. if (goldFlag)
  5252. {
  5253. // Change description text to tell player they can decrement the force point
  5254. item->descText = "@MENUS_REMOVEFP";
  5255. }
  5256. else
  5257. {
  5258. // Change description text to tell player they can increment the force point
  5259. item->descText = "@MENUS_ADDFP";
  5260. }
  5261. }
  5262. */
  5263. }
  5264. }
  5265. void UI_SetItemVisible(menuDef_t *menu,const char *itemname,qboolean visible);
  5266. // if this is the first time into the force power allocation screen, show the INSTRUCTION screen
  5267. static void UI_ForceHelpActive( void )
  5268. {
  5269. int tier_storyinfo = Cvar_VariableIntegerValue( "tier_storyinfo" );
  5270. // First time, show instructions
  5271. if (tier_storyinfo==1)
  5272. {
  5273. // Menus_OpenByName("ingameForceHelp");
  5274. Menus_ActivateByName("ingameForceHelp");
  5275. }
  5276. }
  5277. // Shut down the help screen in the force power allocation screen
  5278. static void UI_ShutdownForceHelp( void )
  5279. {
  5280. int i;
  5281. char itemName[128];
  5282. menuDef_t *menu;
  5283. itemDef_t *item;
  5284. vec4_t color = { 0.65f, 0.65f, 0.65f, 1.0f};
  5285. menu = Menu_GetFocused(); // Get current menu
  5286. if (!menu)
  5287. {
  5288. return;
  5289. }
  5290. // Not in upgrade mode so turn on all the force buttons, the big forceicon and description text
  5291. if (uiInfo.forcePowerUpdated == FP_UPDATED_NONE)
  5292. {
  5293. // We just decremented a field so turn all buttons back on
  5294. // Make it so all buttons can be clicked
  5295. for (i=0;i<MAX_POWER_ENUMS;i++)
  5296. {
  5297. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
  5298. UI_SetItemVisible(menu,itemName,qtrue);
  5299. }
  5300. UI_SetItemVisible(menu,"force_icon",qtrue);
  5301. UI_SetItemVisible(menu,"force_desc",qtrue);
  5302. UI_SetItemVisible(menu,"leveltext",qtrue);
  5303. // Set focus on the top left button
  5304. item = (itemDef_s *) Menu_FindItemByName(menu, "absorb_fbutton");
  5305. item->window.flags |= WINDOW_HASFOCUS;
  5306. if (item->onFocus)
  5307. {
  5308. Item_RunScript(item, item->onFocus);
  5309. }
  5310. }
  5311. // In upgrade mode so just turn the deallocate button on
  5312. else
  5313. {
  5314. UI_SetItemVisible(menu,"force_icon",qtrue);
  5315. UI_SetItemVisible(menu,"force_desc",qtrue);
  5316. UI_SetItemVisible(menu,"deallocate_fbutton",qtrue);
  5317. item = (itemDef_s *) Menu_FindItemByName(menu, va("%s_fbutton",powerEnums[uiInfo.forcePowerUpdated].title));
  5318. if (item)
  5319. {
  5320. #ifdef _XBOX
  5321. Item_SetFocus(item, 0,0);
  5322. #else
  5323. item->window.flags |= WINDOW_HASFOCUS;
  5324. #endif
  5325. }
  5326. // Get player state
  5327. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5328. if (!cl) // No client, get out
  5329. {
  5330. return;
  5331. }
  5332. playerState_t* pState = cl->gentity->client;
  5333. if (uiInfo.forcePowerUpdated == FP_UPDATED_NONE)
  5334. {
  5335. return;
  5336. }
  5337. // Update level description
  5338. Com_sprintf (
  5339. itemName,
  5340. sizeof(itemName),
  5341. "%s_level%ddesc",
  5342. powerEnums[uiInfo.forcePowerUpdated].title,
  5343. pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]
  5344. );
  5345. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5346. if (item)
  5347. {
  5348. item->window.flags |= WINDOW_VISIBLE;
  5349. }
  5350. }
  5351. // If one was a chosen force power, high light it again.
  5352. if (uiInfo.forcePowerUpdated>FP_UPDATED_NONE)
  5353. {
  5354. char itemhexName[128];
  5355. char itemiconName[128];
  5356. vec4_t color2 = { 1.0f, 1.0f, 1.0f, 1.0f};
  5357. Com_sprintf (itemhexName, sizeof(itemhexName), "%s_hexpic", powerEnums[uiInfo.forcePowerUpdated].title);
  5358. Com_sprintf (itemiconName, sizeof(itemiconName), "%s_iconpic", powerEnums[uiInfo.forcePowerUpdated].title);
  5359. UI_SetItemColor(item,itemhexName,"forecolor",color2);
  5360. UI_SetItemColor(item,itemiconName,"forecolor",color2);
  5361. }
  5362. else
  5363. {
  5364. // Un-grey-out all icons
  5365. UI_SetItemColor(item,"hexpic","forecolor",color);
  5366. UI_SetItemColor(item,"iconpic","forecolor",color);
  5367. }
  5368. }
  5369. // Decrement force power level (Used by Force Power Allocation screen)
  5370. static void UI_DecrementCurrentForcePower ( void )
  5371. {
  5372. menuDef_t *menu;
  5373. itemDef_t *item;
  5374. short i;
  5375. vec4_t color = { 0.65f, 0.65f, 0.65f, 1.0f};
  5376. char itemName[128];
  5377. menu = Menu_GetFocused(); // Get current menu
  5378. if (!menu)
  5379. {
  5380. return;
  5381. }
  5382. #ifndef XBOX_DEMO
  5383. // Get player state
  5384. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5385. if (!cl) // No client, get out
  5386. {
  5387. return;
  5388. }
  5389. playerState_t* pState = cl->gentity->client;
  5390. #endif
  5391. if (uiInfo.forcePowerUpdated == FP_UPDATED_NONE)
  5392. {
  5393. return;
  5394. }
  5395. DC->startLocalSound(uiInfo.uiDC.Assets.forceUnchosenSound, CHAN_AUTO );
  5396. #ifdef XBOX_DEMO
  5397. if (demoForcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]>0)
  5398. {
  5399. demoForcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]--; // Decrement it
  5400. }
  5401. UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,demoForcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum],qfalse );
  5402. #else
  5403. if (pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]>0)
  5404. {
  5405. pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]--; // Decrement it
  5406. // Turn off power if level is 0
  5407. if (pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]<1)
  5408. {
  5409. pState->forcePowersKnown &= ~( 1 << powerEnums[uiInfo.forcePowerUpdated].powerEnum );
  5410. }
  5411. }
  5412. UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum],qfalse );
  5413. #endif
  5414. UI_ShowForceLevelDesc ( powerEnums[uiInfo.forcePowerUpdated].title );
  5415. // We just decremented a field so turn all buttons back on
  5416. // Make it so all buttons can be clicked
  5417. for (i=0;i<MAX_POWER_ENUMS;i++)
  5418. {
  5419. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
  5420. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5421. if (item) // This is okay, because core powers don't have a hex button
  5422. {
  5423. item->window.flags |= WINDOW_VISIBLE;
  5424. }
  5425. }
  5426. // Show point has not been allocated
  5427. UI_SetPowerTitleText( qfalse);
  5428. // Make weapons button active
  5429. UI_ForcePowerWeaponsButton(qfalse);
  5430. // Hide the deallocate button
  5431. item = (itemDef_s *) Menu_FindItemByName(menu, "deallocate_fbutton");
  5432. if (item)
  5433. {
  5434. item->window.flags &= ~WINDOW_VISIBLE; //
  5435. // Un-grey-out all icons
  5436. UI_SetItemColor(item,"hexpic","forecolor",color);
  5437. UI_SetItemColor(item,"iconpic","forecolor",color);
  5438. }
  5439. item = (itemDef_s *) Menu_FindItemByName(menu, va("%s_fbutton",powerEnums[uiInfo.forcePowerUpdated].title));
  5440. if (item)
  5441. {
  5442. #ifdef _XBOX
  5443. Item_SetFocus(item, 0,0);
  5444. #else
  5445. item->window.flags |= WINDOW_HASFOCUS;
  5446. #endif
  5447. }
  5448. uiInfo.forcePowerUpdated = FP_UPDATED_NONE; // It's as if nothing happened.
  5449. }
  5450. void Item_MouseEnter(itemDef_t *item, float x, float y);
  5451. static void UI_SetUpForceSelect( void )
  5452. {
  5453. menuDef_t* menu;
  5454. itemDef_t* item;
  5455. client_t* client;
  5456. playerState_t* player;
  5457. // get a ptr to the force select menu
  5458. menu = Menu_GetFocused();
  5459. if(!menu)
  5460. {
  5461. return;
  5462. }
  5463. #ifdef XBOX_DEMO
  5464. Item_SetFocus(Menu_FindItemByName(menu, "absorb_fbutton"), 0, 0);
  5465. return;
  5466. #else
  5467. // get a ptr to the player
  5468. client = &svs.clients[0];
  5469. if(!client)
  5470. {
  5471. return;
  5472. }
  5473. player = client->gentity->client;
  5474. // look for the first force power in the force powers screen
  5475. // that doesn't have all three points filled
  5476. if(player->forcePowerLevel[FP_ABSORB] < 3)
  5477. {
  5478. item = Menu_FindItemByName(menu, "absorb_fbutton");
  5479. if(item)
  5480. {
  5481. Item_SetFocus(item, 0, 0);
  5482. }
  5483. return;
  5484. }
  5485. if(player->forcePowerLevel[FP_HEAL] < 3)
  5486. {
  5487. item = Menu_FindItemByName(menu, "heal_fbutton");
  5488. if(item)
  5489. {
  5490. Item_SetFocus(item, 0, 0);
  5491. }
  5492. return;
  5493. }
  5494. if(player->forcePowerLevel[FP_TELEPATHY] < 3)
  5495. {
  5496. item = Menu_FindItemByName(menu, "mindtrick_fbutton");
  5497. if(item)
  5498. {
  5499. Item_SetFocus(item, 0, 0);
  5500. }
  5501. return;
  5502. }
  5503. if(player->forcePowerLevel[FP_PROTECT] < 3)
  5504. {
  5505. item = Menu_FindItemByName(menu, "protect_fbutton");
  5506. if(item)
  5507. {
  5508. Item_SetFocus(item, 0, 0);
  5509. }
  5510. return;
  5511. }
  5512. if(player->forcePowerLevel[FP_DRAIN] < 3)
  5513. {
  5514. item = Menu_FindItemByName(menu, "drain_fbutton");
  5515. if(item)
  5516. {
  5517. Item_SetFocus(item, 0, 0);
  5518. }
  5519. return;
  5520. }
  5521. if(player->forcePowerLevel[FP_GRIP] < 3)
  5522. {
  5523. item = Menu_FindItemByName(menu, "grip_fbutton");
  5524. if(item)
  5525. {
  5526. Item_SetFocus(item, 0, 0);
  5527. }
  5528. return;
  5529. }
  5530. if(player->forcePowerLevel[FP_LIGHTNING] < 3)
  5531. {
  5532. item = Menu_FindItemByName(menu, "lightning_fbutton");
  5533. if(item)
  5534. {
  5535. Item_SetFocus(item, 0, 0);
  5536. }
  5537. return;
  5538. }
  5539. if(player->forcePowerLevel[FP_RAGE] < 3)
  5540. {
  5541. item = Menu_FindItemByName(menu, "rage_fbutton");
  5542. if(item)
  5543. {
  5544. Item_SetFocus(item, 0, 0);
  5545. }
  5546. return;
  5547. }
  5548. #endif
  5549. }
  5550. // Try to increment force power level (Used by Force Power Allocation screen)
  5551. static void UI_AffectForcePowerLevel ( const char *forceName )
  5552. {
  5553. short forcePowerI=0,i;
  5554. menuDef_t *menu;
  5555. itemDef_t *item;
  5556. menu = Menu_GetFocused(); // Get current menu
  5557. if (!menu)
  5558. {
  5559. return;
  5560. }
  5561. if (!UI_GetForcePowerIndex ( forceName, &forcePowerI ))
  5562. {
  5563. return;
  5564. }
  5565. #ifndef XBOX_DEMO
  5566. // Get player state
  5567. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5568. if (!cl) // No client, get out
  5569. {
  5570. return;
  5571. }
  5572. playerState_t* pState = cl->gentity->client;
  5573. #endif
  5574. #ifdef XBOX_DEMO
  5575. if (demoForcePowerLevel[powerEnums[forcePowerI].powerEnum]>2)
  5576. { // Too big, can't be incremented
  5577. Cvar_Set("ui_deallocate_button","0");
  5578. item = Menu_FindItemByName(menu, Cvar_VariableString("ui_forceButton"));
  5579. if(!item)
  5580. return;
  5581. item->window.flags &= ~WINDOW_DECORATION;
  5582. return;
  5583. }
  5584. #else
  5585. if (pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]>2)
  5586. { // Too big, can't be incremented
  5587. Cvar_Set("ui_deallocate_button","0");
  5588. item = Menu_FindItemByName(menu, Cvar_VariableString("ui_forceButton"));
  5589. if(!item)
  5590. return;
  5591. item->window.flags &= ~WINDOW_DECORATION;
  5592. return;
  5593. }
  5594. #endif
  5595. Cvar_Set("ui_deallocate_button","1");
  5596. // Increment power level.
  5597. DC->startLocalSound(uiInfo.uiDC.Assets.forceChosenSound, CHAN_AUTO );
  5598. uiInfo.forcePowerUpdated = forcePowerI; // Remember which power was updated
  5599. #ifdef XBOX_DEMO
  5600. demoForcePowerLevel[powerEnums[forcePowerI].powerEnum]++; // Increment it
  5601. UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,demoForcePowerLevel[powerEnums[forcePowerI].powerEnum],qtrue );
  5602. #else
  5603. pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]++; // Increment it
  5604. pState->forcePowersKnown |= ( 1 << powerEnums[forcePowerI].powerEnum );
  5605. UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum],qtrue );
  5606. #endif
  5607. UI_ShowForceLevelDesc ( forceName );
  5608. // A field was updated, so make it so others can't be
  5609. if (uiInfo.forcePowerUpdated>FP_UPDATED_NONE)
  5610. {
  5611. vec4_t color = { 0.25f, 0.25f, 0.25f, 1.0f};
  5612. char itemName[128];
  5613. // Make it so none of the other buttons can be clicked
  5614. for (i=0;i<MAX_POWER_ENUMS;i++)
  5615. {
  5616. if (i==uiInfo.forcePowerUpdated)
  5617. {
  5618. continue;
  5619. }
  5620. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
  5621. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5622. if (item) // This is okay, because core powers don't have a hex button
  5623. {
  5624. item->window.flags &= ~WINDOW_VISIBLE;
  5625. }
  5626. }
  5627. // Show point has been allocated
  5628. UI_SetPowerTitleText ( qtrue );
  5629. // Make weapons button active
  5630. UI_ForcePowerWeaponsButton(qtrue);
  5631. // Make user_info
  5632. Cvar_Set ( "ui_forcepower_inc", va("%d",uiInfo.forcePowerUpdated) );
  5633. // Just grab an item to hand it to the function.
  5634. item = (itemDef_s *) Menu_FindItemByName(menu, "deallocate_fbutton");
  5635. if (item)
  5636. {
  5637. // Show all icons as greyed-out
  5638. UI_SetItemColor(item,"hexpic","forecolor",color);
  5639. UI_SetItemColor(item,"iconpic","forecolor",color);
  5640. #ifdef _XBOX
  5641. Item_SetFocus(item, 0,0);
  5642. #else
  5643. item->window.flags |= WINDOW_HASFOCUS;
  5644. #endif
  5645. }
  5646. }
  5647. }
  5648. static void UI_DecrementForcePowerLevel( void )
  5649. {
  5650. int forcePowerI = Cvar_VariableIntegerValue( "ui_forcepower_inc" );
  5651. // Get player state
  5652. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5653. if (!cl) // No client, get out
  5654. {
  5655. return;
  5656. }
  5657. playerState_t* pState = cl->gentity->client;
  5658. pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]--; // Decrement it
  5659. }
  5660. // Show force level description that matches current player level (Used by Force Power Allocation screen)
  5661. static void UI_ShowForceLevelDesc ( const char *forceName )
  5662. {
  5663. short forcePowerI=0;
  5664. menuDef_t *menu;
  5665. itemDef_t *item;
  5666. menu = Menu_GetFocused(); // Get current menu
  5667. if (!menu)
  5668. {
  5669. return;
  5670. }
  5671. if (!UI_GetForcePowerIndex ( forceName, &forcePowerI ))
  5672. {
  5673. return;
  5674. }
  5675. // Get player state
  5676. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5677. if (!cl) // No client, get out
  5678. {
  5679. return;
  5680. }
  5681. playerState_t* pState = cl->gentity->client;
  5682. char itemName[128];
  5683. // Update level description
  5684. Com_sprintf (
  5685. itemName,
  5686. sizeof(itemName),
  5687. "%s_level%ddesc",
  5688. powerEnums[forcePowerI].title,
  5689. pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]
  5690. );
  5691. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5692. if (item)
  5693. {
  5694. item->window.flags |= WINDOW_VISIBLE;
  5695. }
  5696. }
  5697. // Reset force level powers screen to what it was before player upgraded them (Used by Force Power Allocation screen)
  5698. static void UI_ResetForceLevels ( void )
  5699. {
  5700. // What force ppower had the point added to it?
  5701. if (uiInfo.forcePowerUpdated!=FP_UPDATED_NONE)
  5702. {
  5703. // Get player state
  5704. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5705. if (!cl) // No client, get out
  5706. {
  5707. return;
  5708. }
  5709. playerState_t* pState = cl->gentity->client;
  5710. // Decrement that power
  5711. pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]--;
  5712. menuDef_t *menu;
  5713. itemDef_t *item;
  5714. menu = Menu_GetFocused(); // Get current menu
  5715. if (!menu)
  5716. {
  5717. return;
  5718. }
  5719. int i;
  5720. char itemName[128];
  5721. // Make it so all buttons can be clicked
  5722. for (i=0;i<MAX_POWER_ENUMS;i++)
  5723. {
  5724. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
  5725. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5726. if (item) // This is okay, because core powers don't have a hex button
  5727. {
  5728. item->window.flags |= WINDOW_VISIBLE;
  5729. }
  5730. }
  5731. UI_SetPowerTitleText( qfalse );
  5732. /*
  5733. Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[uiInfo.forcePowerUpdated].title);
  5734. item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
  5735. if (item)
  5736. {
  5737. // Change description text to tell player they can increment the force point
  5738. item->descText = "@MENUS_ADDFP";
  5739. }
  5740. */
  5741. uiInfo.forcePowerUpdated = FP_UPDATED_NONE;
  5742. }
  5743. UI_ForcePowerWeaponsButton(qfalse);
  5744. }
  5745. // If the user has entered the force cheat (and thus has every force power)
  5746. // make sure that they don't get stuck on the force config screen
  5747. static void UI_CheckForForceCheat( void )
  5748. {
  5749. // Get player state
  5750. client_t* cl = &svs.clients[0];
  5751. if (!cl)
  5752. return;
  5753. playerState_t *pState = cl->gentity->client;
  5754. // If there is ANY light/dark power that they don't have at max rank, we don't do anything
  5755. if( (pState->forcePowerLevel[FP_HEAL] < 3) ||
  5756. (pState->forcePowerLevel[FP_TELEPATHY] < 3) ||
  5757. (pState->forcePowerLevel[FP_GRIP] < 3) ||
  5758. (pState->forcePowerLevel[FP_LIGHTNING] < 3) ||
  5759. (pState->forcePowerLevel[FP_RAGE] < 3) ||
  5760. (pState->forcePowerLevel[FP_PROTECT] < 3) ||
  5761. (pState->forcePowerLevel[FP_ABSORB] < 3) ||
  5762. (pState->forcePowerLevel[FP_DRAIN] < 3) )
  5763. return;
  5764. // Twiddling controls was a mess. Instead, just skip this menu and go to weapons:
  5765. Menus_CloseAll();
  5766. Menus_OpenByName( "ingameWpnSelect" );
  5767. }
  5768. // Used by the cheat system to prevent the give all force powers cheat while
  5769. // the config screen is active
  5770. bool UI_ForceConfigUIActive( void )
  5771. {
  5772. menuDef_t *menu = Menu_GetFocused();
  5773. if( menu && (Q_stricmp(menu->window.name, "progress_FConfig") == 0) )
  5774. return true;
  5775. return false;
  5776. }
  5777. // Set the Players known saber style
  5778. static void UI_UpdateFightingStyle ( void )
  5779. {
  5780. playerState_t *pState;
  5781. int fightingStyle,saberStyle;
  5782. fightingStyle = Cvar_VariableIntegerValue( "ui_newfightingstyle" );
  5783. if (fightingStyle == 1)
  5784. {
  5785. saberStyle = SS_MEDIUM;
  5786. }
  5787. else if (fightingStyle == 2)
  5788. {
  5789. saberStyle = SS_STRONG;
  5790. }
  5791. else // 0 is Fast
  5792. {
  5793. saberStyle = SS_FAST;
  5794. }
  5795. // Get player state
  5796. client_t *cl = &svs.clients[0]; // 0 because only ever us as a player
  5797. // No client, get out
  5798. if (cl && cl->gentity && cl->gentity->client)
  5799. {
  5800. pState = cl->gentity->client;
  5801. pState->saberStylesKnown |= (1<<saberStyle);
  5802. }
  5803. else // Must be at the beginning of the game so the client hasn't been created, shove data in a cvar
  5804. {
  5805. Cvar_Set ( "g_fighting_style", va("%d",saberStyle) );
  5806. }
  5807. }
  5808. static void UI_ResetCharacterListBoxes( void )
  5809. {
  5810. itemDef_t *item;
  5811. menuDef_t *menu;
  5812. listBoxDef_t *listPtr;
  5813. menu = Menus_FindByName("characterMenu");
  5814. if (menu)
  5815. {
  5816. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "headlistbox");
  5817. if (item)
  5818. {
  5819. listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
  5820. if( listPtr )
  5821. {
  5822. listPtr->cursorPos = 0;
  5823. }
  5824. item->cursorPos = 0;
  5825. }
  5826. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "torsolistbox");
  5827. if (item)
  5828. {
  5829. listPtr = (listBoxDef_t*)item->typeData;
  5830. if( listPtr )
  5831. {
  5832. listPtr->cursorPos = 0;
  5833. }
  5834. item->cursorPos = 0;
  5835. }
  5836. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "lowerlistbox");
  5837. if (item)
  5838. {
  5839. listPtr = (listBoxDef_t*)item->typeData;
  5840. if( listPtr )
  5841. {
  5842. listPtr->cursorPos = 0;
  5843. }
  5844. item->cursorPos = 0;
  5845. }
  5846. item = (itemDef_t *) Menu_FindItemByName((menuDef_t *) menu, "colorbox");
  5847. if (item)
  5848. {
  5849. listPtr = (listBoxDef_t*)item->typeData;
  5850. if( listPtr )
  5851. {
  5852. listPtr->cursorPos = 0;
  5853. }
  5854. item->cursorPos = 0;
  5855. }
  5856. }
  5857. }
  5858. static void UI_ClearInventory ( void )
  5859. {
  5860. // Get player state
  5861. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5862. if (!cl) // No client, get out
  5863. {
  5864. return;
  5865. }
  5866. if (cl->gentity && cl->gentity->client)
  5867. {
  5868. playerState_t* pState = cl->gentity->client;
  5869. // Clear out inventory for the player
  5870. int i;
  5871. for (i=0;i<MAX_INVENTORY;i++)
  5872. {
  5873. pState->inventory[i] = 0;
  5874. }
  5875. }
  5876. }
  5877. static void UI_GiveInventory ( const int itemIndex, const int amount )
  5878. {
  5879. // Get player state
  5880. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  5881. if (!cl) // No client, get out
  5882. {
  5883. return;
  5884. }
  5885. if (cl->gentity && cl->gentity->client)
  5886. {
  5887. playerState_t* pState = cl->gentity->client;
  5888. if (itemIndex < MAX_INVENTORY)
  5889. {
  5890. pState->inventory[itemIndex]=amount;
  5891. }
  5892. }
  5893. }
  5894. //. Find weapons allocation screen BEGIN button and make active/inactive
  5895. /*
  5896. static void UI_WeaponAllocBeginButton(qboolean activeFlag)
  5897. {
  5898. menuDef_t *menu;
  5899. menu = Menu_GetFocused(); // Get current menu
  5900. if (!menu)
  5901. {
  5902. return;
  5903. }
  5904. int weap = Cvar_VariableIntegerValue( "weapon_menu" );
  5905. // Find begin button
  5906. itemDef_t *item;
  5907. item = Menu_GetMatchingItemByNumber(menu, weap, "beginmission");
  5908. #ifndef _XBOX
  5909. if (item)
  5910. {
  5911. // Make it active
  5912. if (activeFlag)
  5913. {
  5914. item->window.flags &= ~WINDOW_INACTIVE;
  5915. }
  5916. else
  5917. {
  5918. item->window.flags |= WINDOW_INACTIVE;
  5919. }
  5920. }
  5921. #else
  5922. if (item)
  5923. {
  5924. // Make it active
  5925. if (activeFlag)
  5926. {
  5927. item->window.flags |= WINDOW_VISIBLE;
  5928. Item_SetFocus(item, 0, 0);
  5929. }
  5930. else
  5931. {
  5932. item->window.flags &= ~WINDOW_VISIBLE;
  5933. }
  5934. }
  5935. UI_SetVis(menu, "tab_Weapon", !activeFlag);
  5936. UI_SetVis(menu, "tab_WeaponShadow", !activeFlag);
  5937. UI_SetVis(menu, "beginmissionShadow", activeFlag);
  5938. if(activeFlag)
  5939. DC->setCVar("ui_hideAcallout", "0");
  5940. else
  5941. DC->setCVar("ui_hideAcallout", "1");
  5942. #endif
  5943. }
  5944. */
  5945. // If we have both weapons and the throwable weapon, turn on the begin mission button,
  5946. // otherwise, turn it off
  5947. /*
  5948. static void UI_WeaponsSelectionsComplete( void )
  5949. {
  5950. // We need two weapons and one throwable
  5951. if (( uiInfo.selectedWeapon1 != NOWEAPON ) &&
  5952. ( uiInfo.selectedWeapon2 != NOWEAPON ) &&
  5953. ( uiInfo.selectedThrowWeapon != NOWEAPON ))
  5954. {
  5955. UI_WeaponAllocBeginButton(qtrue); // Turn it on
  5956. }
  5957. else
  5958. {
  5959. UI_WeaponAllocBeginButton(qfalse); // Turn it off
  5960. }
  5961. }
  5962. */
  5963. // if this is the first time into the weapon allocation screen, show the INSTRUCTION screen
  5964. static void UI_WeaponHelpActive( void )
  5965. {
  5966. int tier_storyinfo = Cvar_VariableIntegerValue( "tier_storyinfo" );
  5967. menuDef_t *menu;
  5968. menu = Menu_GetFocused(); // Get current menu
  5969. if (!menu)
  5970. {
  5971. return;
  5972. }
  5973. // First time, show instructions
  5974. if (tier_storyinfo==1)
  5975. {
  5976. UI_SetItemVisible(menu,"weapon_button",qfalse);
  5977. UI_SetItemVisible(menu,"inst_stuff",qtrue);
  5978. }
  5979. // just act like normal
  5980. else
  5981. {
  5982. UI_SetItemVisible(menu,"weapon_button",qtrue);
  5983. UI_SetItemVisible(menu,"inst_stuff",qfalse);
  5984. }
  5985. }
  5986. static void UI_InitWeaponSelect( void )
  5987. {
  5988. menuDef_t *menu = Menu_GetFocused();
  5989. if( !menu || !menu->window.name )
  5990. return;
  5991. if (Q_stricmp(menu->window.name, "ingameWpnSelect") == 0)
  5992. {
  5993. // First screen - reset all weapon selections
  5994. uiInfo.selectedWeapon1 = NOWEAPON;
  5995. uiInfo.selectedWeapon2 = NOWEAPON;
  5996. uiInfo.selectedThrowWeapon = NOWEAPON;
  5997. }
  5998. else if(Q_stricmp(menu->window.name, "ingameWpnSelect2") == 0)
  5999. {
  6000. // Second screen. Disable whatever needs to be disabled, re-enable the rest:
  6001. UI_DisableWeapon();
  6002. // Now put focus on the first item that isn't disabled:
  6003. itemDef_t *item;
  6004. if( uiInfo.selectedWeapon1 == WP_BLASTER )
  6005. item = Menu_FindItemByName( menu, "R1_C2_button" );
  6006. else
  6007. item = Menu_FindItemByName( menu, "R1_C1_button" );
  6008. if( !item )
  6009. return;
  6010. Item_SetFocus( item, 0, 0 );
  6011. }
  6012. else if(Q_stricmp(menu->window.name, "ingameWpnSelect3") == 0)
  6013. {
  6014. // Third screen, nothing to do.
  6015. }
  6016. }
  6017. // Called by the second weapon select screen to disable and gray out the
  6018. // weapon that was chosen on the first screen
  6019. static void UI_DisableWeapon( void )
  6020. {
  6021. // Get weapon chosen on first screen - adjust by one, as itemDefs use 1-based index
  6022. int firstWeapon = Cvar_VariableIntegerValue( "weaponSelect" ) + 1;
  6023. assert( firstWeapon >= 1 && firstWeapon <= 8 );
  6024. menuDef_t *menu = Menu_GetFocused();
  6025. if( !menu )
  6026. return;
  6027. itemDef_t *greyItem = Menu_FindItemByName( menu, "selectionSlotFill" );
  6028. if( !greyItem )
  6029. return;
  6030. for( int i = 1; i <= 8; ++i )
  6031. {
  6032. itemDef_t *butItem = Menu_FindItemByName( menu, va("R1_C%d_button", i) );
  6033. if( !butItem )
  6034. continue;
  6035. if( i == firstWeapon )
  6036. {
  6037. // Copy rect so that disabled weapon has a gray background
  6038. greyItem->window.rect = butItem->window.rect;
  6039. greyItem->window.rect.x--;
  6040. greyItem->window.rect.y--;
  6041. greyItem->window.rect.w += 2;
  6042. greyItem->window.rect.h += 2;
  6043. // Disable button for already selected weapon
  6044. butItem->window.flags |= WINDOW_DECORATION;
  6045. }
  6046. else
  6047. {
  6048. // Make sure all other weapons ARE selectable
  6049. butItem->window.flags &= ~WINDOW_DECORATION;
  6050. }
  6051. }
  6052. }
  6053. static void UI_ClearWeapons ( void )
  6054. {
  6055. // Get player state
  6056. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  6057. if (!cl) // No client, get out
  6058. {
  6059. return;
  6060. }
  6061. if (cl->gentity && cl->gentity->client)
  6062. {
  6063. playerState_t* pState = cl->gentity->client;
  6064. // Clear out any weapons for the player
  6065. pState->stats[ STAT_WEAPONS ] = 0;
  6066. pState->weapon = WP_NONE;
  6067. }
  6068. }
  6069. static void UI_GiveWeapon ( const int weaponIndex )
  6070. {
  6071. // Get player state
  6072. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  6073. if (!cl) // No client, get out
  6074. {
  6075. return;
  6076. }
  6077. if (cl->gentity && cl->gentity->client)
  6078. {
  6079. playerState_t* pState = cl->gentity->client;
  6080. if (weaponIndex<WP_NUM_WEAPONS)
  6081. {
  6082. pState->stats[ STAT_WEAPONS ] |= ( 1 << weaponIndex );
  6083. }
  6084. }
  6085. }
  6086. static void UI_EquipWeapon ( const int weaponIndex )
  6087. {
  6088. // Get player state
  6089. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  6090. if (!cl) // No client, get out
  6091. {
  6092. return;
  6093. }
  6094. if (cl->gentity && cl->gentity->client)
  6095. {
  6096. playerState_t* pState = cl->gentity->client;
  6097. if (weaponIndex<WP_NUM_WEAPONS)
  6098. {
  6099. pState->weapon = weaponIndex;
  6100. //force it to change
  6101. //CG_ChangeWeapon( wp );
  6102. }
  6103. }
  6104. }
  6105. static void UI_LoadMissionSelectMenu( const char *cvarName )
  6106. {
  6107. int holdLevel = (int)trap_Cvar_VariableValue(cvarName);
  6108. // Figure out which tier menu to load
  6109. if ((holdLevel > 0) && (holdLevel < 5))
  6110. {
  6111. UI_LoadMenus("ui/tier1.txt",qfalse);
  6112. Menus_CloseByName("ingameMissionSelect1");
  6113. }
  6114. else if ((holdLevel > 6) && (holdLevel < 10))
  6115. {
  6116. UI_LoadMenus("ui/tier2.txt",qfalse);
  6117. Menus_CloseByName("ingameMissionSelect2");
  6118. }
  6119. else if ((holdLevel > 11) && (holdLevel < 15))
  6120. {
  6121. UI_LoadMenus("ui/tier3.txt",qfalse);
  6122. Menus_CloseByName("ingameMissionSelect3");
  6123. }
  6124. }
  6125. #ifdef XBOX_DEMO
  6126. int demoWeapon1;
  6127. int demoWeapon2;
  6128. int demoThrowable;
  6129. #endif
  6130. // Update the player weapons with the chosen weapon
  6131. static void UI_AddWeaponSelection ( const int weaponIndex, const int ammoIndex, const int ammoAmount, const char *iconItemName,const char *litIconItemName, const char *hexBackground, const char *soundfile )
  6132. {
  6133. if( uiInfo.selectedWeapon1 == NOWEAPON )
  6134. {
  6135. uiInfo.selectedWeapon1 = weaponIndex;
  6136. #ifdef XBOX_DEMO
  6137. demoWeapon1 = weaponIndex;
  6138. #endif
  6139. }
  6140. else
  6141. {
  6142. uiInfo.selectedWeapon2 = weaponIndex;
  6143. #ifdef XBOX_DEMO
  6144. demoWeapon2 = weaponIndex;
  6145. #endif
  6146. }
  6147. if( soundfile )
  6148. {
  6149. DC->startLocalSound(DC->registerSound(soundfile, qfalse), CHAN_LOCAL );
  6150. }
  6151. // Get player state
  6152. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  6153. if (!cl) // No client, get out
  6154. {
  6155. return;
  6156. }
  6157. // Add weapon
  6158. if (cl->gentity && cl->gentity->client)
  6159. {
  6160. playerState_t* pState = cl->gentity->client;
  6161. if ((weaponIndex>0) && (weaponIndex<WP_NUM_WEAPONS))
  6162. {
  6163. pState->stats[ STAT_WEAPONS ] |= ( 1 << weaponIndex );
  6164. }
  6165. // Give them ammo too
  6166. if ((ammoIndex>0) && (ammoIndex<AMMO_MAX))
  6167. {
  6168. pState->ammo[ ammoIndex ] = ammoAmount;
  6169. }
  6170. }
  6171. // UI_WeaponsSelectionsComplete(); // Test to see if the mission begin button should turn on or off
  6172. }
  6173. // Update the player weapons with the chosen weapon
  6174. static void UI_RemoveWeaponSelection ( const int weaponSelectionIndex )
  6175. {
  6176. }
  6177. static void UI_NormalWeaponSelection ( const int selectionslot )
  6178. {
  6179. itemDef_s *item;
  6180. menuDef_t *menu;
  6181. menu = Menu_GetFocused(); // Get current menu
  6182. if (!menu)
  6183. {
  6184. return;
  6185. }
  6186. if (selectionslot == 1)
  6187. {
  6188. item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon1_icon" );
  6189. if (item)
  6190. {
  6191. item->window.background = uiInfo.unlitWeapon1Icon;
  6192. }
  6193. }
  6194. if (selectionslot == 2)
  6195. {
  6196. item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon2_icon" );
  6197. if (item)
  6198. {
  6199. item->window.background = uiInfo.unlitWeapon2Icon;
  6200. }
  6201. }
  6202. }
  6203. static void UI_HighLightWeaponSelection ( const int selectionslot )
  6204. {
  6205. itemDef_s *item;
  6206. menuDef_t *menu;
  6207. menu = Menu_GetFocused(); // Get current menu
  6208. if (!menu)
  6209. {
  6210. return;
  6211. }
  6212. if (selectionslot == 1)
  6213. {
  6214. item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon1_icon" );
  6215. if (item)
  6216. {
  6217. item->window.background = uiInfo.litWeapon1Icon;
  6218. }
  6219. }
  6220. if (selectionslot == 2)
  6221. {
  6222. item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon2_icon" );
  6223. if (item)
  6224. {
  6225. item->window.background = uiInfo.litWeapon2Icon;
  6226. }
  6227. }
  6228. }
  6229. // Update the player throwable weapons (okay it's a bad description) with the chosen weapon
  6230. static void UI_AddThrowWeaponSelection ( const int weaponIndex, const int ammoIndex, const int ammoAmount, const char *iconItemName,const char *litIconItemName, const char *hexBackground, const char *soundfile )
  6231. {
  6232. uiInfo.selectedThrowWeapon = weaponIndex;
  6233. #ifdef XBOX_DEMO
  6234. demoThrowable = weaponIndex;
  6235. #endif
  6236. if( soundfile )
  6237. {
  6238. DC->startLocalSound(DC->registerSound(soundfile, qfalse), CHAN_LOCAL );
  6239. }
  6240. // Get player state
  6241. client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
  6242. if (!cl) // No client, get out
  6243. {
  6244. return;
  6245. }
  6246. // Add weapon
  6247. if (cl->gentity && cl->gentity->client)
  6248. {
  6249. playerState_t* pState = cl->gentity->client;
  6250. if ((weaponIndex>0) && (weaponIndex<WP_NUM_WEAPONS))
  6251. {
  6252. pState->stats[ STAT_WEAPONS ] |= ( 1 << weaponIndex );
  6253. }
  6254. // Give them ammo too
  6255. if ((ammoIndex>0) && (ammoIndex<AMMO_MAX))
  6256. {
  6257. pState->ammo[ ammoIndex ] = ammoAmount;
  6258. }
  6259. }
  6260. // UI_WeaponsSelectionsComplete(); // Test to see if the mission begin button should turn on or off
  6261. }
  6262. // Update the player weapons with the chosen throw weapon
  6263. static void UI_RemoveThrowWeaponSelection ( void )
  6264. {
  6265. }
  6266. static void UI_NormalThrowSelection ( void )
  6267. {
  6268. itemDef_s *item;
  6269. menuDef_t *menu;
  6270. menu = Menu_GetFocused(); // Get current menu
  6271. if (!menu)
  6272. {
  6273. return;
  6274. }
  6275. item = (itemDef_s *) Menu_FindItemByName( menu, "chosenthrowweapon_icon" );
  6276. item->window.background = uiInfo.unlitThrowableIcon;
  6277. }
  6278. static void UI_HighLightThrowSelection ( void )
  6279. {
  6280. itemDef_s *item;
  6281. menuDef_t *menu;
  6282. menu = Menu_GetFocused(); // Get current menu
  6283. if (!menu)
  6284. {
  6285. return;
  6286. }
  6287. item = (itemDef_s *) Menu_FindItemByName( menu, "chosenthrowweapon_icon" );
  6288. item->window.background = uiInfo.litThrowableIcon;
  6289. }
  6290. static void UI_GetSaberCvars ( void )
  6291. {
  6292. Cvar_Set ( "ui_saber_type", Cvar_VariableString ( "g_saber_type" ) );
  6293. Cvar_Set ( "ui_saber", Cvar_VariableString ( "g_saber" ) );
  6294. Cvar_Set ( "ui_saber2", Cvar_VariableString ( "g_saber2" ) );
  6295. Cvar_Set ( "ui_saber_color", Cvar_VariableString ( "g_saber_color" ) );
  6296. Cvar_Set ( "ui_saber2_color", Cvar_VariableString ( "g_saber2_color" ) );
  6297. Cvar_Set ( "ui_newfightingstyle", "0");
  6298. }
  6299. static void UI_ResetSaberCvars ( void )
  6300. {
  6301. Cvar_Set ( "g_saber_type", "single" );
  6302. Cvar_Set ( "g_saber", "single_1" );
  6303. Cvar_Set ( "g_saber2", "" );
  6304. Cvar_Set ( "ui_saber_type", "single" );
  6305. Cvar_Set ( "ui_saber", "single_1" );
  6306. Cvar_Set ( "ui_saber2", "" );
  6307. }
  6308. extern qboolean ItemParse_asset_model_go( itemDef_t *item, const char *name );
  6309. extern qboolean ItemParse_model_g2skin_go( itemDef_t *item, const char *skinName );
  6310. static void UI_UpdateCharacterSkin( void )
  6311. {
  6312. menuDef_t *menu;
  6313. itemDef_t *item;
  6314. char skin[MAX_QPATH];
  6315. menu = Menu_GetFocused(); // Get current menu
  6316. if (!menu)
  6317. {
  6318. return;
  6319. }
  6320. item = (itemDef_s *) Menu_FindItemByName(menu, "character");
  6321. if (!item)
  6322. {
  6323. Com_Error( ERR_FATAL, "UI_UpdateCharacterSkin: Could not find item (character) in menu (%s)", menu->window.name);
  6324. }
  6325. Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
  6326. Cvar_VariableString ( "ui_char_model"),
  6327. Cvar_VariableString ( "ui_char_skin_head"),
  6328. Cvar_VariableString ( "ui_char_skin_torso"),
  6329. Cvar_VariableString ( "ui_char_skin_legs")
  6330. );
  6331. ItemParse_model_g2skin_go( item, skin );
  6332. }
  6333. static void UI_UpdateCharacter( qboolean changedModel )
  6334. {
  6335. menuDef_t *menu;
  6336. itemDef_t *item;
  6337. char modelPath[MAX_QPATH];
  6338. menu = Menu_GetFocused(); // Get current menu
  6339. if (!menu)
  6340. {
  6341. return;
  6342. }
  6343. item = (itemDef_s *) Menu_FindItemByName(menu, "character");
  6344. if (!item)
  6345. {
  6346. Com_Error( ERR_FATAL, "UI_UpdateCharacter: Could not find item (character) in menu (%s)", menu->window.name);
  6347. }
  6348. ItemParse_model_g2anim_go( item, ui_char_anim.string );
  6349. Com_sprintf( modelPath, sizeof( modelPath ), "models/players/%s/model.glm", Cvar_VariableString ( "ui_char_model" ) );
  6350. ItemParse_asset_model_go( item, modelPath );
  6351. if ( changedModel )
  6352. {//set all skins to first skin since we don't know you always have all skins
  6353. //FIXME: could try to keep the same spot in each list as you swtich models
  6354. UI_FeederSelection(FEEDER_PLAYER_SKIN_HEAD, 0, item); //fixme, this is not really the right item!!
  6355. UI_FeederSelection(FEEDER_PLAYER_SKIN_TORSO, 0, item);
  6356. UI_FeederSelection(FEEDER_PLAYER_SKIN_LEGS, 0, item);
  6357. UI_FeederSelection(FEEDER_COLORCHOICES, 0, item);
  6358. }
  6359. UI_UpdateCharacterSkin();
  6360. }
  6361. void UI_UpdateSaberType( void )
  6362. {
  6363. char sType[MAX_QPATH];
  6364. DC->getCVarString( "ui_saber_type", sType, sizeof(sType) );
  6365. if ( Q_stricmp( "single", sType ) == 0 ||
  6366. Q_stricmp( "staff", sType ) == 0 )
  6367. {
  6368. DC->setCVar( "ui_saber2", "" );
  6369. }
  6370. }
  6371. static void UI_UpdateSaberHilt( qboolean secondSaber )
  6372. {
  6373. menuDef_t *menu;
  6374. itemDef_t *item;
  6375. char model[MAX_QPATH];
  6376. char modelPath[MAX_QPATH];
  6377. char skinPath[MAX_QPATH];
  6378. menu = Menu_GetFocused(); // Get current menu (either video or ingame video, I would assume)
  6379. if (!menu)
  6380. {
  6381. return;
  6382. }
  6383. char *itemName;
  6384. char *saberCvarName;
  6385. if ( secondSaber )
  6386. {
  6387. itemName = "saber2";
  6388. saberCvarName = "ui_saber2";
  6389. }
  6390. else
  6391. {
  6392. itemName = "saber";
  6393. saberCvarName = "ui_saber";
  6394. }
  6395. item = (itemDef_s *) Menu_FindItemByName(menu, itemName );
  6396. if(!item)
  6397. {
  6398. Com_Error( ERR_FATAL, "UI_UpdateSaberHilt: Could not find item (%s) in menu (%s)", itemName, menu->window.name);
  6399. }
  6400. DC->getCVarString( saberCvarName, model, sizeof(model) );
  6401. //read this from the sabers.cfg
  6402. if ( UI_SaberModelForSaber( model, modelPath ) )
  6403. {//successfully found a model
  6404. ItemParse_asset_model_go( item, modelPath );//set the model
  6405. //get the customSkin, if any
  6406. //COM_StripExtension( modelPath, skinPath );
  6407. //COM_DefaultExtension( skinPath, sizeof( skinPath ), ".skin" );
  6408. if ( UI_SaberSkinForSaber( model, skinPath ) )
  6409. {
  6410. ItemParse_model_g2skin_go( item, skinPath );//apply the skin
  6411. }
  6412. else
  6413. {
  6414. ItemParse_model_g2skin_go( item, NULL );//apply the skin
  6415. }
  6416. }
  6417. }
  6418. /*
  6419. static void UI_UpdateSaberColor( qboolean secondSaber )
  6420. {
  6421. int sabernumber;
  6422. if (secondSaber)
  6423. sabernumber = 2;
  6424. else
  6425. sabernumber = 1;
  6426. ui.Cmd_ExecuteText( EXEC_APPEND, va("sabercolor %i %s\n",sabernumber, Cvar_VariableString("g_saber_color")));
  6427. }
  6428. */
  6429. char GoToMenu[1024];
  6430. /*
  6431. =================
  6432. Menus_SaveGoToMenu
  6433. =================
  6434. */
  6435. void Menus_SaveGoToMenu(const char *menuTo)
  6436. {
  6437. memcpy(GoToMenu, menuTo, sizeof(GoToMenu));
  6438. }
  6439. /*
  6440. =================
  6441. UI_CheckVid1Data
  6442. =================
  6443. */
  6444. void UI_CheckVid1Data(const char *menuTo,const char *warningMenuName)
  6445. {
  6446. menuDef_t *menu;
  6447. itemDef_t *applyChanges;
  6448. menu = Menu_GetFocused(); // Get current menu (either video or ingame video, I would assume)
  6449. if (!menu)
  6450. {
  6451. Com_Printf(S_COLOR_YELLOW"WARNING: No videoMenu was found. Video data could not be checked\n");
  6452. return;
  6453. }
  6454. applyChanges = (itemDef_s *) Menu_FindItemByName(menu, "applyChanges");
  6455. if (!applyChanges)
  6456. {
  6457. // Menus_CloseAll();
  6458. Menus_OpenByName(menuTo);
  6459. return;
  6460. }
  6461. if ((applyChanges->window.flags & WINDOW_VISIBLE)) // Is the APPLY CHANGES button active?
  6462. {
  6463. // Menus_SaveGoToMenu(menuTo); // Save menu you're going to
  6464. // Menus_HideItems(menu->window.name); // HIDE videMenu in case you have to come back
  6465. Menus_OpenByName(warningMenuName); // Give warning
  6466. }
  6467. else
  6468. {
  6469. // Menus_CloseAll();
  6470. // Menus_OpenByName(menuTo);
  6471. }
  6472. }
  6473. /*
  6474. =================
  6475. UI_ResetDefaults
  6476. =================
  6477. */
  6478. void UI_ResetDefaults( void )
  6479. {
  6480. ui.Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n");
  6481. ui.Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n");
  6482. ui.Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
  6483. }
  6484. /*
  6485. =======================
  6486. UI_SortSaveGames
  6487. =======================
  6488. */
  6489. static int UI_SortSaveGames( const void *A, const void *B )
  6490. {
  6491. const int &a = ((savedata_t*)A)->currentSaveFileDateTime;
  6492. const int &b = ((savedata_t*)B)->currentSaveFileDateTime;
  6493. if (a > b)
  6494. {
  6495. return -1;
  6496. }
  6497. else
  6498. {
  6499. return (a < b);
  6500. }
  6501. }
  6502. /*
  6503. =======================
  6504. UI_AdjustSaveGameListBox
  6505. =======================
  6506. */
  6507. // Yeah I could get fired for this... in a world of good and bad, this is bad
  6508. // I wish we passed in the menu item to RunScript(), oh well...
  6509. void UI_AdjustSaveGameListBox( int currentLine )
  6510. {
  6511. menuDef_t *menu;
  6512. itemDef_t *item;
  6513. // could be in either the ingame or shell load menu (I know, I know it's bad)
  6514. menu = Menus_FindByName("loadgameMenu");
  6515. if( !menu )
  6516. {
  6517. menu = Menus_FindByName("ingameloadMenu");
  6518. }
  6519. if (menu)
  6520. {
  6521. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "loadgamelist");
  6522. if (item)
  6523. {
  6524. listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
  6525. if( listPtr )
  6526. {
  6527. listPtr->cursorPos = currentLine;
  6528. }
  6529. item->cursorPos = currentLine;
  6530. }
  6531. }
  6532. }
  6533. void setBlockDisplayCvar()
  6534. {
  6535. unsigned long blocks;
  6536. blocks = SG_BlocksLeft();
  6537. if (blocks > 50000)
  6538. Cvar_Set("ui_BlocksAvailable","50000+");
  6539. else
  6540. Cvar_SetValue("ui_BlocksAvailable",(int)blocks);
  6541. Cvar_SetValue("ui_BlocksNeeded", SG_SaveGameSize());
  6542. }
  6543. void storeSGDataDatetoCvar()
  6544. {
  6545. char timeBuffer[128];
  6546. char * timeBufferPtr;
  6547. char filetime[64],*tokentimeptr;
  6548. strcpy (filetime,s_savedata[s_savegame.currentLine].currentSaveFileDateTimeString);
  6549. if(!filetime[0])
  6550. {
  6551. Cvar_Set("ui_DateString", "");
  6552. return;
  6553. }
  6554. timeBuffer[0] = 0;
  6555. timeBufferPtr = &(timeBuffer[0]);
  6556. //Wed
  6557. tokentimeptr = strtok(filetime," ");
  6558. //Jan
  6559. tokentimeptr = strtok(NULL," ");
  6560. strcpy(timeBufferPtr,tokentimeptr);
  6561. timeBufferPtr+=strlen(tokentimeptr);
  6562. *timeBufferPtr = ' ';
  6563. timeBufferPtr ++;
  6564. //02
  6565. tokentimeptr = strtok(NULL," ");
  6566. strcpy(timeBufferPtr,tokentimeptr);
  6567. timeBufferPtr+=strlen(tokentimeptr);
  6568. *timeBufferPtr = ' ';
  6569. timeBufferPtr ++;
  6570. //02:
  6571. tokentimeptr = strtok(NULL,":");
  6572. //strcpy(timeBufferPtr,tokentimeptr);
  6573. //timeBufferPtr+=strlen(tokentimeptr);
  6574. //*timeBufferPtr = ':';
  6575. //timeBufferPtr ++;
  6576. //03:
  6577. tokentimeptr = strtok(NULL,":");
  6578. //strcpy(timeBufferPtr,tokentimeptr);
  6579. //timeBufferPtr+=strlen(tokentimeptr);
  6580. //*timeBufferPtr = ' ';
  6581. //timeBufferPtr ++;
  6582. //55
  6583. tokentimeptr = strtok(NULL," ");
  6584. //strcpy(timeBufferPtr,tokentimeptr);
  6585. //timeBufferPtr+=strlen(tokentimeptr);
  6586. //*timeBufferPtr = '_';
  6587. //timeBufferPtr ++;
  6588. //1980
  6589. tokentimeptr = strtok(NULL,"\n");
  6590. strcpy(timeBufferPtr,tokentimeptr);
  6591. timeBufferPtr+=strlen(tokentimeptr);
  6592. *timeBufferPtr = 0;
  6593. Cvar_Set("ui_DateString", timeBuffer);
  6594. }
  6595. void storeSGDataTimetoCvar()
  6596. {
  6597. char timeBuffer[128];
  6598. char * timeBufferPtr;
  6599. char filetime[64],*tokentimeptr;
  6600. strcpy (filetime,s_savedata[s_savegame.currentLine].currentSaveFileDateTimeString);
  6601. if(!filetime[0])
  6602. {
  6603. Cvar_Set("ui_TimeString", "");
  6604. return;
  6605. }
  6606. timeBuffer[0] = 0;
  6607. timeBufferPtr = &(timeBuffer[0]);
  6608. //Wed
  6609. tokentimeptr = strtok(filetime," ");
  6610. //Jan
  6611. tokentimeptr = strtok(NULL," ");
  6612. //02
  6613. tokentimeptr = strtok(NULL," ");
  6614. //02:
  6615. tokentimeptr = strtok(NULL,":");
  6616. strcpy(timeBufferPtr,tokentimeptr);
  6617. timeBufferPtr+=strlen(tokentimeptr);
  6618. *timeBufferPtr = ':';
  6619. timeBufferPtr ++;
  6620. //03:
  6621. tokentimeptr = strtok(NULL,":");
  6622. strcpy(timeBufferPtr,tokentimeptr);
  6623. timeBufferPtr+=strlen(tokentimeptr);
  6624. *timeBufferPtr = ':';
  6625. timeBufferPtr ++;
  6626. //55
  6627. tokentimeptr = strtok(NULL," ");
  6628. strcpy(timeBufferPtr,tokentimeptr);
  6629. timeBufferPtr+=strlen(tokentimeptr);
  6630. //*timeBufferPtr = '_';
  6631. //timeBufferPtr ++;
  6632. //1980
  6633. tokentimeptr = strtok(NULL,"\n");
  6634. //strcpy(timeBufferPtr,tokentimeptr);
  6635. //timeBufferPtr+=strlen(tokentimeptr);
  6636. *timeBufferPtr = 0;
  6637. Cvar_Set("ui_TimeString", timeBuffer);
  6638. }
  6639. void storeSGDataDiffLeveltoCvar()
  6640. {
  6641. char * difflevel;
  6642. difflevel = s_savedata[s_savegame.currentLine].currentSaveFileComments;
  6643. if (!difflevel[0])
  6644. {
  6645. Cvar_Set("ui_DiffLevel", "");
  6646. return;
  6647. }
  6648. if ( difflevel[0] == '@')
  6649. Cvar_Set("ui_DiffLevel", SE_GetString(&difflevel[1]));
  6650. else
  6651. Cvar_Set("ui_DiffLevel", "");
  6652. }
  6653. void ui_resetSaveGameList()
  6654. {
  6655. s_savegame.saveFileCnt = -1;
  6656. }
  6657. /*
  6658. =================
  6659. ReadSaveDirectory
  6660. =================
  6661. */
  6662. //for the xbox reading the save directory will consist of
  6663. //iterating through the save game folders
  6664. void ReadSaveDirectory (void)
  6665. {
  6666. char *holdChar;
  6667. char *filetime,*tokentimeptr;
  6668. const char * newgame;
  6669. qboolean newGameActive,newGameAvailable;
  6670. char saveGameName[filepathlength];
  6671. //char timeBuffer[128];
  6672. //char * timeBufferPtr;
  6673. // Clear out save data
  6674. memset(s_savedata,0,sizeof(s_savedata));
  6675. s_savegame.saveFileCnt = 0;
  6676. Cvar_Set("ui_gameDesc", "" ); // Blank out comment
  6677. Cvar_Set("ui_SelectionOK", "0" );
  6678. //memset( screenShotBuf,0,(SG_SCR_WIDTH * SG_SCR_HEIGHT * 4)); //blank out sshot
  6679. // Get everything in saves directory
  6680. // fileCnt = ui.FS_GetFileList("saves", ".sav", s_savegame.listBuf, LISTBUFSIZE );
  6681. Cvar_Set("ui_ResumeOK", "0" );
  6682. holdChar = s_savegame.listBuf;
  6683. XGAME_FIND_DATA SaveGameData;
  6684. HANDLE searchhandle;
  6685. BOOL retval;
  6686. newGameActive = (Cvar_VariableIntegerValue( "ui_newGameActive" )) ? qtrue : qfalse;
  6687. newGameAvailable = qfalse;
  6688. extern unsigned long SG_BlocksLeft();
  6689. if (newGameActive)
  6690. {
  6691. // if (SG_BlocksLeft() < SG_SaveGameSize())
  6692. // {
  6693. // Cvar_SetValue("noNewSaveGameAvailable", 1);
  6694. // newGameAvailable = qfalse;
  6695. // }
  6696. // else
  6697. // {
  6698. Cvar_SetValue("noNewSaveGameAvailable", 0);
  6699. newGameAvailable = qtrue;
  6700. // }
  6701. }
  6702. else
  6703. Cvar_SetValue("noNewSaveGameAvailable", 1);
  6704. if ( newGameAvailable)
  6705. {
  6706. strcpy(s_savedata[s_savegame.saveFileCnt].currentSaveFileComments,"New Game");
  6707. strcpy(s_savedata[s_savegame.saveFileCnt].currentSaveFileMap, "New Game");
  6708. newgame = SE_GetString( "MENUS", "newSaveGame" );
  6709. //JLF debug code
  6710. if ( !newgame)
  6711. newgame = "New Game";
  6712. //END JLF
  6713. strcpy (holdChar, newgame);
  6714. s_savedata[s_savegame.saveFileCnt].currentSaveFileName = holdChar;
  6715. holdChar += strlen(holdChar)+1;
  6716. s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTime = 0;
  6717. s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTimeString[0] = 0;
  6718. s_savegame.saveFileCnt++;
  6719. }
  6720. // Any saves?
  6721. searchhandle = XFindFirstSaveGame( "U:\\", &SaveGameData );
  6722. if ( searchhandle != INVALID_HANDLE_VALUE )
  6723. {
  6724. do
  6725. {
  6726. // At least one; count up the rest
  6727. DWORD dwCount = 1;
  6728. //get the name of the file
  6729. wcstombs(saveGameName, SaveGameData.szSaveGameName, filepathlength);
  6730. // Skip over Settings
  6731. if( Q_stricmp( saveGameName, "Settings" ) == 0 )
  6732. {
  6733. retval = XFindNextSaveGame( searchhandle, &SaveGameData );
  6734. continue;
  6735. }
  6736. strcpy( holdChar, saveGameName);
  6737. // Is this a valid file??? & Get comment of file
  6738. //create full path name
  6739. time_t result;
  6740. result = ui.SG_GetSaveGameComment(saveGameName, s_savedata[s_savegame.saveFileCnt].currentSaveFileComments, s_savedata[s_savegame.saveFileCnt].currentSaveFileMap);
  6741. if (result != 0) // ignore Bad save game
  6742. {
  6743. s_savedata[s_savegame.saveFileCnt].corrupt = false;
  6744. }
  6745. else
  6746. {
  6747. s_savedata[s_savegame.saveFileCnt].corrupt = true;
  6748. }
  6749. {
  6750. s_savedata[s_savegame.saveFileCnt].currentSaveFileName = holdChar;
  6751. s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTime = result;
  6752. holdChar += strlen(holdChar)+1;
  6753. struct tm *localTime;
  6754. localTime = localtime( &result );
  6755. // Wed Jan 02 02:03:55 1980\n\0
  6756. filetime = asctime (localTime);
  6757. strcpy(s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTimeString, filetime );
  6758. s_savegame.saveFileCnt++;
  6759. if (s_savegame.saveFileCnt == MAX_SAVELOADFILES)
  6760. {
  6761. break;
  6762. }
  6763. }
  6764. retval =XFindNextSaveGame( searchhandle, &SaveGameData );
  6765. }while(retval);
  6766. }
  6767. if ( newGameAvailable)
  6768. qsort( &(s_savedata[1]), s_savegame.saveFileCnt-1, sizeof(savedata_t), UI_SortSaveGames );
  6769. else
  6770. qsort( s_savedata, s_savegame.saveFileCnt, sizeof(savedata_t), UI_SortSaveGames );
  6771. Cvar_SetValue("saveGameCount", s_savegame.saveFileCnt);
  6772. if ((s_savegame.saveFileCnt>1 && newGameAvailable) ||
  6773. (s_savegame.saveFileCnt>0 && !newGameAvailable))
  6774. Cvar_SetValue("overwriteAvailable", 1);
  6775. else
  6776. Cvar_SetValue("overwriteAvailable", 0);
  6777. setBlockDisplayCvar();
  6778. if (s_savegame.currentLine == 0)
  6779. {
  6780. if (ui_ShowDeleteActive)
  6781. {
  6782. Cvar_SetValue("ui_showYdel",trap_Cvar_VariableValue("ui_ShowDelete"));
  6783. ui_ShowDeleteActive = qfalse;
  6784. Cvar_SetValue( "ui_cancelYScript",0);
  6785. }
  6786. if ( newGameAvailable)
  6787. {
  6788. //there is a 'new save game' index that is highlighted
  6789. Cvar_SetValue("ui_ShowDelete",trap_Cvar_VariableValue("ui_showYdel"));
  6790. Cvar_SetValue("ui_showYdel",0);
  6791. Cvar_SetValue( "ui_cancelYScript",1);
  6792. ui_ShowDeleteActive =qtrue;
  6793. }
  6794. }
  6795. storeSGDataDatetoCvar();
  6796. storeSGDataTimetoCvar();
  6797. storeSGDataDiffLeveltoCvar();
  6798. }
  6799. #ifdef _XBOX
  6800. void UI_UpdateSettingsCvars( void )
  6801. {
  6802. }
  6803. static void _UI_SetVol(const char* type, float value)
  6804. {
  6805. if(!Q_stricmp(type, "effects") )
  6806. {
  6807. if(value < 0.1f)
  6808. value = 0.0f;
  6809. DC->setCVar("s_effects_volume", va("%f",value) );
  6810. }
  6811. else if(!Q_stricmp(type, "voice") )
  6812. {
  6813. if(value < 0.1f)
  6814. value = 0.0f;
  6815. DC->setCVar("s_voice_volume", va("%f",value) );
  6816. }
  6817. else if(!Q_stricmp(type, "music") )
  6818. {
  6819. if(value < 0.1f)
  6820. value = 0.0f;
  6821. DC->setCVar("s_music_volume", va("%f",value) );
  6822. }
  6823. else if(!Q_stricmp(type, "horizontal") )
  6824. {
  6825. DC->setCVar("sensitivity", va("%f",value*10.0f) );
  6826. }
  6827. else if(!Q_stricmp(type, "vertical") )
  6828. {
  6829. DC->setCVar("sensitivityY", va("%f",value*10.0f) );
  6830. }
  6831. }
  6832. static float _UI_GetVol(const char* type)
  6833. {
  6834. if(!Q_stricmp(type, "effects") )
  6835. {
  6836. return DC->getCVarValue("s_effects_volume");
  6837. }
  6838. else if(!Q_stricmp(type, "voice") )
  6839. {
  6840. return DC->getCVarValue("s_voice_volume");
  6841. }
  6842. else if(!Q_stricmp(type, "music") )
  6843. {
  6844. return DC->getCVarValue("s_music_volume");
  6845. }
  6846. else if(!Q_stricmp(type, "horizontal") )
  6847. {
  6848. return DC->getCVarValue("sensitivity") / 10.0f;
  6849. }
  6850. else if(!Q_stricmp(type, "vertical") )
  6851. {
  6852. return DC->getCVarValue("sensitivityY") / 10.0f;
  6853. }
  6854. return 1.0f;
  6855. }
  6856. static void UI_UpdateVolume(const char* action, const char* type, const char* itemName, int width, int value )
  6857. {
  6858. itemDef_s* mask;
  6859. menuDef_t* menu;
  6860. int amount;
  6861. // get the current menu
  6862. menu = Menu_GetFocused();
  6863. if (!menu)
  6864. {
  6865. return;
  6866. }
  6867. // get the masking item to change
  6868. mask = (itemDef_s*) Menu_FindItemByName(menu, itemName );
  6869. // figure out what to do
  6870. if(!Q_stricmp(action, "set") ) // set the volume level
  6871. {
  6872. amount = value;
  6873. }
  6874. else if(!Q_stricmp(action, "actual") )
  6875. {
  6876. float mult;
  6877. // get the requested volume
  6878. mult = _UI_GetVol(type);
  6879. // set the mask
  6880. mask->window.rect.w = (int)(mult * width);
  6881. return;
  6882. }
  6883. else if(!Q_stricmp(action, "increment") ) // increment the volume level
  6884. {
  6885. amount = mask->window.rect.w + value;
  6886. }
  6887. else if(!Q_stricmp(action, "decrement") ) // decrement the volume level
  6888. {
  6889. amount = mask->window.rect.w - value;
  6890. }
  6891. // make sure we're in bounds
  6892. if(amount <= width && amount >= 0)
  6893. {
  6894. float volume;
  6895. // compute the volume
  6896. volume = (float)amount / (float)width;
  6897. // alter the mask
  6898. mask->window.rect.w = amount;
  6899. // update the volume
  6900. _UI_SetVol(type, volume);
  6901. }
  6902. }
  6903. /*
  6904. ==========
  6905. UI_UpdateMoveTitles()
  6906. ==========
  6907. */
  6908. static void UI_UpdateMoveTitles(void)
  6909. {
  6910. itemDef_t *item;
  6911. menuDef_t *menu;
  6912. modelDef_t *modelPtr;
  6913. uiInfo.movesTitleIndex = (short)DC->getCVarValue("ui_move_title");
  6914. if(uiInfo.movesTitleIndex > 5 || uiInfo.movesTitleIndex < 0)
  6915. uiInfo.movesTitleIndex = 0;
  6916. uiInfo.movesBaseAnim = datapadMoveTitleBaseAnims[uiInfo.movesTitleIndex];
  6917. menu = Menus_FindByName("datapadMovesMenu");
  6918. if (menu)
  6919. {
  6920. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  6921. if (item)
  6922. {
  6923. modelPtr = (modelDef_t*)item->typeData;
  6924. if (modelPtr)
  6925. {
  6926. ItemParse_model_g2anim_go( item, uiInfo.movesBaseAnim );
  6927. uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
  6928. }
  6929. }
  6930. }
  6931. }
  6932. /*
  6933. ==========
  6934. UI_UpdateMoves()
  6935. ==========
  6936. */
  6937. static void UI_UpdateMoves( void )
  6938. {
  6939. itemDef_t *item;
  6940. menuDef_t *menu;
  6941. modelDef_t *modelPtr;
  6942. char skin[MAX_QPATH];
  6943. uiInfo.movesTitleIndex = (short)DC->getCVarValue("ui_move_title");
  6944. if(uiInfo.movesTitleIndex > 5 || uiInfo.movesTitleIndex < 0)
  6945. uiInfo.movesTitleIndex = 0;
  6946. short index = (short)DC->getCVarValue("ui_moves");
  6947. if(index > 15 || index < 0)
  6948. index = 0;
  6949. menu = Menus_FindByName("datapadMovesMenu");
  6950. if (menu)
  6951. {
  6952. item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
  6953. if (item)
  6954. {
  6955. modelPtr = (modelDef_t*)item->typeData;
  6956. if (modelPtr)
  6957. {
  6958. if (datapadMoveData[uiInfo.movesTitleIndex][index].anim)
  6959. {
  6960. ItemParse_model_g2anim_go( item, datapadMoveData[uiInfo.movesTitleIndex][index].anim );
  6961. uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
  6962. uiInfo.moveAnimTime += uiInfo.uiDC.realTime;
  6963. // Play sound for anim
  6964. if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_FORCE_JUMP)
  6965. {
  6966. DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveJumpSound, CHAN_LOCAL );
  6967. }
  6968. else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_ROLL)
  6969. {
  6970. DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveRollSound, CHAN_LOCAL );
  6971. }
  6972. else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_SABER)
  6973. {
  6974. // Randomly choose one sound
  6975. int soundI = Q_irand( 1, 6 );
  6976. sfxHandle_t *soundPtr;
  6977. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound1;
  6978. if (soundI == 2)
  6979. {
  6980. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound2;
  6981. }
  6982. else if (soundI == 3)
  6983. {
  6984. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound3;
  6985. }
  6986. else if (soundI == 4)
  6987. {
  6988. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound4;
  6989. }
  6990. else if (soundI == 5)
  6991. {
  6992. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound5;
  6993. }
  6994. else if (soundI == 6)
  6995. {
  6996. soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound6;
  6997. }
  6998. DC->startLocalSound(*soundPtr, CHAN_LOCAL );
  6999. }
  7000. if (datapadMoveData[uiInfo.movesTitleIndex][index].desc)
  7001. {
  7002. Cvar_Set( "ui_move_desc", datapadMoveData[uiInfo.movesTitleIndex][index].desc);
  7003. }
  7004. Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
  7005. Cvar_VariableString ( "g_char_model"),
  7006. Cvar_VariableString ( "g_char_skin_head"),
  7007. Cvar_VariableString ( "g_char_skin_torso"),
  7008. Cvar_VariableString ( "g_char_skin_legs")
  7009. );
  7010. ItemParse_model_g2skin_go( item, skin );
  7011. }
  7012. }
  7013. }
  7014. }
  7015. }
  7016. #endif
  7017. //JLF error popup
  7018. // What popup is active at the moment?
  7019. static xbErrorPopupType sPopup = XB_POPUP_NONE;
  7020. // Creates the requested popup, then displays it.
  7021. // Establishes context so proper action will be taken on a selection.
  7022. void UI_xboxErrorPopup(xbErrorPopupType popup)
  7023. {
  7024. // Set our context
  7025. //store all these values
  7026. /*
  7027. DC->setCVar("ui_showWbtsel", "0");
  7028. DC->setCVar("ui_showWmove", "0");
  7029. DC->setCVar("ui_showXadv", "0");
  7030. DC->setCVar("ui_showXNew", "0");
  7031. DC->setCVar("ui_showXchk", "0");
  7032. DC->setCVar("ui_showXforce", "0");
  7033. DC->setCVar("ui_showXcstm", "0");
  7034. DC->setCVar("ui_showYref", "0");
  7035. DC->setCVar("ui_showYdel", "0");
  7036. DC->setCVar("ui_showYbtrule", "0");
  7037. DC->setCVar("ui_showYsaber", "0");
  7038. DC->setCVar("ui_showYwpn", "0");
  7039. DC->setCVar("ui_showAcallout", "0");
  7040. DC->setCVar("ui_showBcallout", "0");
  7041. */
  7042. sPopup = popup;
  7043. Cvar_Set( "xb_errMessage", "" );
  7044. Cvar_Set( "xb_PopupTitle", "" );
  7045. // Cvar_Set( "xb_PopupStringX", "" );
  7046. // Set the menu cvars
  7047. switch( popup )
  7048. {
  7049. case XB_POPUP_DELETE_CONFIRM:
  7050. Cvar_Set( "xb_errMessage", "@MENUS_DELETE_SAVE_PROMPT" );
  7051. Cvar_Set( "xb_PopupTitle", "" );
  7052. break;
  7053. case XB_POPUP_DISKFULL:
  7054. Cvar_Set( "xb_errMessage", va( SE_GetString("MENUS_NO_SPACE_PLEASE_FREE"), blocksNeeded ) );
  7055. break;
  7056. case XB_POPUP_DISKFULL_DURING_SAVE:
  7057. Cvar_Set( "xb_errMessage", "@MENUS_NO_SPACE" );
  7058. break;
  7059. case XB_POPUP_YOU_ARE_DEAD:
  7060. Cvar_Set( "xb_errMessage", "@MENUS_SAVE_WHEN_DEAD");
  7061. break;
  7062. case XB_POPUP_SAVE_COMPLETE:
  7063. Cvar_Set( "xb_errMessage", "@MENUS_SAVE_GAME_COMPLETE" );
  7064. Cvar_Set( "xb_PopupTitle", "" );
  7065. break;
  7066. case XB_POPUP_OVERWRITE_CONFIRM:
  7067. Cvar_Set( "xb_errMessage", "@MENUS_OVERWRITE_PROMPT" );
  7068. Cvar_Set( "xb_PopupTitle", "" );
  7069. break;
  7070. case XB_POPUP_LOAD_FAILED:
  7071. {
  7072. Cvar_Set( "xb_errMessage", "@MENUS_DAMAGED_SAVE" );
  7073. }
  7074. break;
  7075. case XB_POPUP_LOAD_CHECKPOINT_FAILED:
  7076. { char messagebuffer[128];
  7077. strcpy (messagebuffer,SE_GetString("MENUS_NO_LOAD_1"));
  7078. strcat (messagebuffer, " ");
  7079. strcat (messagebuffer, SE_GetString("MENUS_CHECKPOINT_LOWER"));
  7080. strcat (messagebuffer, " ");
  7081. strcat (messagebuffer,SE_GetString("MENUS_NO_LOAD_2"));
  7082. Cvar_Set( "xb_errMessage", messagebuffer );
  7083. Cvar_Set( "xb_PopupTitle", "" );
  7084. }
  7085. break;
  7086. case XB_POPUP_QUIT_CONFIRM:
  7087. {
  7088. Cvar_Set( "xb_errMessage", "@MENUS_QUIT_CURRENT_GAME_AND");
  7089. Cvar_Set( "xb_PopupTitle", "@MENUS_QUIT" );
  7090. }
  7091. break;
  7092. case XB_POPUP_SAVING:
  7093. {
  7094. Cvar_Set( "xb_errMessage", "@MENUS_SAVING");
  7095. }
  7096. break;
  7097. case XB_POPUP_LOAD_CONFIRM:
  7098. {
  7099. if ( svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
  7100. {
  7101. // player dead
  7102. Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM2");
  7103. }
  7104. else
  7105. {
  7106. Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM");
  7107. }
  7108. }
  7109. break;
  7110. case XB_POPUP_LOAD_CONFIRM_CHECKPOINT:
  7111. {
  7112. if ( svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
  7113. {
  7114. // player dead
  7115. Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM2");
  7116. }
  7117. else
  7118. {
  7119. Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM");
  7120. }
  7121. break;
  7122. }
  7123. case XB_POPUP_TOO_MANY_SAVES:
  7124. {
  7125. Cvar_Set( "xb_errMessage", "@MENUS_TOO_MANY_SAVES");
  7126. }
  7127. break;
  7128. case XB_POPUP_CONFIRM_INVITE:
  7129. {
  7130. Cvar_Set( "xb_errMessage", "@MENUS_CONFIRM_JOIN" );
  7131. break;
  7132. }
  7133. case XB_POPUP_CORRUPT_SETTINGS:
  7134. {
  7135. Cvar_Set( "xb_errMessage", "@MENUS_CORRUPT_SETTINGS" );
  7136. break;
  7137. }
  7138. case XB_POPUP_DISKFULL_BOTH:
  7139. {
  7140. Cvar_Set( "xb_errMessage", va( SE_GetString("MENUS_NO_SPACE_PLEASE_FREE"), blocksNeeded ) );
  7141. break;
  7142. }
  7143. case XB_POPUP_TESTING_SAVE:
  7144. {
  7145. Cvar_Set( "xb_errMessage", "@MENUS_LOADING_SAVEGAME" );
  7146. break;
  7147. }
  7148. case XB_POPUP_CORRUPT_SCREENSHOT:
  7149. {
  7150. Cvar_Set( "xb_errMessage", "@MENUS_CORRUPT_SCREENSHOT" );
  7151. break;
  7152. }
  7153. case XB_POPUP_CONFIRM_NEW_1:
  7154. case XB_POPUP_CONFIRM_NEW_2:
  7155. case XB_POPUP_CONFIRM_NEW_3:
  7156. {
  7157. Cvar_Set( "xb_errMessage", "@MENUS_CONFIRM_NEW_MISSION" );
  7158. break;
  7159. }
  7160. default:
  7161. Com_Error( ERR_FATAL, "ERROR: Invalid popup type %i\n", popup );
  7162. }
  7163. // Display the menu - but first make sure to close it, in case it's open.
  7164. // Fixes a bug where openMenuCount gets screwed up.
  7165. Menus_CloseByName( "xbox_error_popup" );
  7166. Menus_ActivateByName( "xbox_error_popup" );
  7167. }
  7168. extern unsigned long getGameBlocks(char * filename);
  7169. // Accepts a response to the currently dislpayed popup.
  7170. // Does whatever is necessary based on which popup was visible, and what the response was.
  7171. void UI_xboxPopupResponse( void )
  7172. {
  7173. if( sPopup == XB_POPUP_NONE )
  7174. Com_Error( ERR_FATAL, "ERROR: Got a popup response with no valid context\n" );
  7175. int response = Cvar_VariableIntegerValue( "xb_errResponse" );
  7176. if(response == 2)
  7177. return;
  7178. switch( sPopup )
  7179. {
  7180. case XB_POPUP_DELETE_CONFIRM:
  7181. if( response == 0 ) // A
  7182. {
  7183. Menus_CloseByName( "xbox_error_popup" );
  7184. ui_DeleteGame();
  7185. }
  7186. else if( response == 1 ) // B
  7187. {
  7188. Menus_CloseByName( "xbox_error_popup" );
  7189. }
  7190. break;
  7191. case XB_POPUP_DISKFULL:
  7192. if( response == 0 ) // A continue
  7193. {
  7194. // Continue without saving
  7195. Menus_CloseByName( "xbox_error_popup" );
  7196. XB_Startup( STARTUP_INVITE_CHECK );
  7197. return;
  7198. }
  7199. else if( response == 1 ) // B
  7200. {
  7201. openDashBoardMemory();
  7202. }
  7203. break;
  7204. case XB_POPUP_DISKFULL_DURING_SAVE:
  7205. if( response == 0 ) // A continue
  7206. {
  7207. // Continue (without saving)
  7208. Menus_CloseByName( "xbox_error_popup" );
  7209. }
  7210. else if( response == 1 ) // B
  7211. {
  7212. return;
  7213. }
  7214. break;
  7215. case XB_POPUP_YOU_ARE_DEAD:
  7216. if( response == 0)
  7217. {
  7218. // Continue without saving
  7219. Menus_CloseByName( "xbox_error_popup" );
  7220. }
  7221. else
  7222. {
  7223. return;
  7224. }
  7225. break;
  7226. case XB_POPUP_SAVE_COMPLETE :
  7227. if( response == 0 ) // A continue
  7228. {
  7229. Menus_CloseByName( "xbox_error_popup" );
  7230. }
  7231. else
  7232. {
  7233. return;
  7234. }
  7235. break;
  7236. case XB_POPUP_OVERWRITE_CONFIRM:
  7237. if( response == 0 ) // A
  7238. {
  7239. unsigned long blocks;
  7240. unsigned long gameblocks;
  7241. blocks = SG_BlocksLeft();
  7242. if ( blocks < SG_SaveGameSize())
  7243. {
  7244. //read the blocks out of the game?
  7245. //gameblocks = getGameBlocks(s_savedata[s_savegame.currentLine].currentSaveFileName);
  7246. // if ( blocks + gameblocks >= SG_SaveGameSize())
  7247. {
  7248. itemDef_t item;
  7249. item.parent = Menu_GetFocused();
  7250. item.window.flags = 0; //err, item is fake here, but we want a valid flag before calling runscript
  7251. Item_RunScript( &item, "uiscript genericpopup saving ; delay 1 ; uiScript deletegame ; uiScript savegame ; defer always ; close xbox_error_popup ; uiScript genericpopup savecomplete" );
  7252. return;
  7253. // UI_xboxErrorPopup(XB_POPUP_DISKFULL);
  7254. }
  7255. // else
  7256. // {
  7257. // Menus_CloseByName( "xbox_error_popup" );
  7258. // UI_xboxErrorPopup(XB_POPUP_DISKFULL);
  7259. // return;
  7260. // }
  7261. }
  7262. else
  7263. {
  7264. itemDef_t item;
  7265. item.parent = Menu_GetFocused();
  7266. item.window.flags = 0; //err, item is fake here, but we want a valid flag before calling runscript
  7267. Item_RunScript( &item, "uiscript genericpopup saving ; delay 1 ; uiScript deletegame ; uiScript savegame ; defer always ; close xbox_error_popup ; uiScript genericpopup savecomplete" );
  7268. return;
  7269. //DELETE
  7270. // ui_DeleteGame();
  7271. //SAVE
  7272. // ui_SaveGame();
  7273. // //call to show save success
  7274. }
  7275. // Menus_CloseByName( "xbox_error_popup" );
  7276. }
  7277. else if( response == 1 ) // B
  7278. {
  7279. Menus_CloseByName( "xbox_error_popup" );
  7280. }
  7281. break;
  7282. case XB_POPUP_LOAD_FAILED:
  7283. if( response == 0 ) // A continue
  7284. {
  7285. Menus_CloseByName( "xbox_error_popup" );
  7286. }
  7287. else
  7288. {
  7289. return;
  7290. }
  7291. break;
  7292. case XB_POPUP_LOAD_CHECKPOINT_FAILED:
  7293. if( response == 0 ) // A continue
  7294. {
  7295. if ( cls.state == CA_ACTIVE )
  7296. {
  7297. Menus_CloseAll();
  7298. UI_SetActiveMenu( "ingame",NULL );
  7299. }
  7300. else
  7301. Menus_CloseByName( "xbox_error_popup" );
  7302. }
  7303. else
  7304. {
  7305. return;
  7306. }
  7307. break;
  7308. case XB_POPUP_QUIT_CONFIRM:
  7309. if( response == 0 ) // A continue
  7310. {
  7311. Cbuf_ExecuteText( EXEC_APPEND, "disconnect\n" );
  7312. trap_Key_SetCatcher( KEYCATCH_UI );
  7313. Menus_CloseAll();
  7314. }
  7315. else
  7316. {
  7317. Menus_CloseByName( "xbox_error_popup" );
  7318. }
  7319. break;
  7320. case XB_POPUP_SAVING:
  7321. return;
  7322. case XB_POPUP_LOAD_CONFIRM:
  7323. if( response == 0 ) // A continue
  7324. {
  7325. itemDef_t item;
  7326. item.parent = Menu_GetFocused();
  7327. item.window.flags = 0; //err, item is fake here, but we want a valid flag before calling runscript
  7328. Item_RunScript( &item, "uiscript loadgame" );
  7329. return;
  7330. }
  7331. else
  7332. {
  7333. Menus_CloseByName( "xbox_error_popup" );
  7334. }
  7335. break;
  7336. case XB_POPUP_LOAD_CONFIRM_CHECKPOINT:
  7337. if( response == 0 )
  7338. {
  7339. // Hackery
  7340. Menus_CloseByName( "xbox_error_popup" );
  7341. UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
  7342. ui.Cmd_ExecuteText(EXEC_APPEND,"wait ; wait ; wait ; wait ; load *respawn\n");
  7343. return;
  7344. }
  7345. else
  7346. {
  7347. Menus_CloseByName( "xbox_error_popup" );
  7348. }
  7349. break;
  7350. case XB_POPUP_TOO_MANY_SAVES:
  7351. if(response == 0)
  7352. {
  7353. Menus_CloseByName( "xbox_error_popup" );
  7354. }
  7355. else
  7356. {
  7357. return;
  7358. }
  7359. break;
  7360. case XB_POPUP_CONFIRM_INVITE:
  7361. if( response == 0 ) // A - join game
  7362. {
  7363. // Never returns
  7364. extern void Sys_JoinInvite( void );
  7365. Sys_JoinInvite();
  7366. }
  7367. else
  7368. {
  7369. Menus_CloseByName( "xbox_error_popup" );
  7370. XB_Startup( STARTUP_FINISH );
  7371. return;
  7372. }
  7373. case XB_POPUP_CORRUPT_SETTINGS:
  7374. if( response == 0 ) // A - accept
  7375. {
  7376. Settings.Delete();
  7377. Menus_CloseByName( "xbox_error_popup" );
  7378. XB_Startup( STARTUP_COMBINED_SPACE_CHECK );
  7379. return;
  7380. }
  7381. else
  7382. {
  7383. return;
  7384. }
  7385. case XB_POPUP_DISKFULL_BOTH:
  7386. if( response == 0 )
  7387. {
  7388. // Continue without saving
  7389. Settings.Disable();
  7390. Menus_CloseByName( "xbox_error_popup" );
  7391. XB_Startup( STARTUP_INVITE_CHECK );
  7392. return;
  7393. }
  7394. else
  7395. {
  7396. // Go to dashboard to free up memory
  7397. openDashBoardMemory();
  7398. }
  7399. case XB_POPUP_TESTING_SAVE:
  7400. // No response is valid, this is just informational while the save is read/checked
  7401. return;
  7402. case XB_POPUP_CORRUPT_SCREENSHOT:
  7403. if( response == 0 ) // A - continue
  7404. {
  7405. Menus_CloseByName( "xbox_error_popup" );
  7406. break;
  7407. }
  7408. else
  7409. {
  7410. // Invalid response
  7411. return;
  7412. }
  7413. case XB_POPUP_CONFIRM_NEW_1:
  7414. case XB_POPUP_CONFIRM_NEW_2:
  7415. case XB_POPUP_CONFIRM_NEW_3:
  7416. if( response == 0 ) // A - continue
  7417. {
  7418. Cvar_SetValue( "cl_paused", 1 );
  7419. UI_DecrementForcePowerLevel();
  7420. Menus_CloseAll();
  7421. Menus_OpenByName( va("ingameMissionSelect%d", (sPopup - XB_POPUP_CONFIRM_NEW_1) + 1) );
  7422. }
  7423. else
  7424. {
  7425. Menus_CloseByName( "xbox_error_popup" );
  7426. }
  7427. break;
  7428. default:
  7429. Com_Error( ERR_FATAL, "ERROR: Invalid popup type %i\n", sPopup );
  7430. }
  7431. // If we get here, the user gave a valid response to our popup. Clear the context:
  7432. sPopup = XB_POPUP_NONE;
  7433. }