1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581 |
- // Copyright (C) 1999-2000 Id Software, Inc.
- //
- /*
- =======================================================================
- USER INTERFACE MAIN
- =======================================================================
- */
- // leave this at the top of all UI_xxxx files for PCH reasons...
- //
- #include "../server/exe_headers.h"
- #include "ui_local.h"
- #include "menudef.h"
- #include "ui_shared.h"
- #include "../ghoul2/G2.h"
- #include "../game/bg_public.h"
- #include "../game/anims.h"
- extern stringID_table_t animTable [MAX_ANIMATIONS+1];
- #include "../qcommon/stv_version.h"
- #ifdef _XBOX
- #include <xtl.h>
- #define filepathlength 120
- #endif
- #include "../qcommon/xb_settings.h"
- //JLF
- int gScrollAccum = 0;
- int gScrollDelta = 0;
- #define TEXTSCROLLDESCRETESTEP 50
- #define SCROLL_SENSITIVITY 2
- #define ARROW_SPACE 8
- extern qboolean ItemParse_model_g2anim_go( itemDef_t *item, const char *animName );
- extern qboolean ItemParse_asset_model_go( itemDef_t *item, const char *name );
- extern qboolean ItemParse_model_g2skin_go( itemDef_t *item, const char *skinName );
- extern qboolean UI_SaberModelForSaber( const char *saberName, char *saberModel );
- extern qboolean UI_SaberSkinForSaber( const char *saberName, char *saberSkin );
- extern void UI_SaberAttachToChar( itemDef_t *item );
- extern unsigned long SG_SaveGameSize();
- // VIRTUAL KEYBOARD DEFINES ETC
- //
- // Warning: These next values must work out so that there are at least 2 columns and/or
- // 2 rows. Otherwise you will not be able to compile because of divide by zero errors.
- // Not to mention the ugly keyboard you'd be designing
- #define SKB_NUM_LETTERS (36)
- #define SKB_NUM_COLS (10) // must be > 1 and < SKB_NUM_LETTERS-1
- #define SKB_NUM_ROWS ((SKB_NUM_LETTERS%SKB_NUM_COLS)?(SKB_NUM_LETTERS/SKB_NUM_COLS+1):(SKB_NUM_LETTERS/SKB_NUM_COLS))
- #define SKB_TOP (225)
- #define SKB_BOT (350)
- #define SKB_LEFT (100)
- #define SKB_RIGHT (540)
- #define SKB_STRING_LENGTH (10)
- #define SKB_STRING_TOP (150)
- #define SKB_STRING_LEFT (200)
- #define SKB_SPACE_H ((SKB_RIGHT-SKB_LEFT)/(SKB_NUM_COLS-1))
- #define SKB_SPACE_V ((SKB_BOT-SKB_TOP)/(SKB_NUM_ROWS-1))
- #define SKB_ACCEPT_NAME ("skb_accept")
- #define SKB_DELETE_NAME ("skb_delete")
- #define SKB_KEYBOARD_NAME ("skb_keyboard")
- #define SKB_OK_X (390)
- #define SKB_OK_Y (400)
- #define SKB_BACKSPACE_X (250)
- #define SKB_BACKSPACE_Y (400)
- char *letters[SKB_NUM_LETTERS] = {
- "0", "1", "2", "3",
- "4", "5", "6", "7",
- "8", "9",
- "A", "B", "C", "D",
- "E", "F", "G", "H",
- "I", "J", "K", "L",
- "M", "N", "O", "P",
- "Q", "R", "S", "T",
- "U", "V", "W", "X",
- "Y", "Z", };
- typedef struct
- {
- short activeKey;
- short curStringPos;
- short curCol;
- short curRow;
- } softkeyboardDef_t;
- softkeyboardDef_t skb;
- extern qboolean PC_Script_Parse(const char **out);
- #define LISTBUFSIZE 10240
- static struct
- {
- char listBuf[LISTBUFSIZE]; // The list of file names read in
- // For scrolling through file names
- int currentLine; // Index to currentSaveFileComments[] currently highlighted
- int saveFileCnt; // Number of save files read in
- int awaitingSave; // Flag to see if user wants to overwrite a game.
- char *savegameMap;
- int savegameFromFlag;
- } s_savegame;
- //JLF MPMOVED
- #ifdef _XBOX
- struct playerProfile_t
- {
- // For scrolling through file names
- int currentLine; // Index to currentSaveFileComments[] currently highlighted
- int fileCnt; // Number of save files read in
- char *modelName;
- };
- playerProfile_t s_playerProfile;
- void resetProfileFileCount()
- {
- s_playerProfile.fileCnt = -1;
- };
- #endif
- #ifdef _XBOX
- #define MAX_SAVELOADFILES 100
- //JLF MPMOVED
- #define MAX_PROFILEFILES 8
- #else
- #define MAX_SAVELOADFILES 100
- #endif
- #define MAX_SAVELOADNAME 32
- //byte screenShotBuf[SG_SCR_WIDTH * SG_SCR_HEIGHT * 4];
- typedef struct
- {
- char *currentSaveFileName; // file name of savegame
- char currentSaveFileComments[iSG_COMMENT_SIZE]; // file comment
- char currentSaveFileDateTimeString[iSG_COMMENT_SIZE]; // file time and date
- time_t currentSaveFileDateTime;
- #ifdef _XBOX
- char currentSaveFileMap[32]; // map save game is from
- #else
- char currentSaveFileMap[MAX_TOKEN_CHARS]; // map save game is from
- #endif
- char corrupt;
- char screenshotNotify;
- } savedata_t;
- static savedata_t s_savedata[MAX_SAVELOADFILES];
- //JLF
- char g_loadsaveGameName[MAX_SAVELOADNAME];
- qboolean g_loadsaveGameNameInitialized = qfalse;
- extern unsigned long SG_BlocksLeft();
- //JLF used to tell if delete button should be shown
- static qboolean ui_ShowDeleteActive =0 ;
- void storeSGDataDatetoCvar();
- void storeSGDataTimetoCvar();
- void storeSGDataDiffLeveltoCvar();
- //JLF MPMOVED
- #ifdef _XBOX
- typedef struct
- {
- char currentProfileName[iSG_COMMENT_SIZE]; // file name of savegame
- char currentProfileComments[iSG_COMMENT_SIZE]; // file comment
- char currentProfileDateTimeString[iSG_COMMENT_SIZE]; // file time and date
- time_t currentProfileDateTime;
- } profileData_t;
- static profileData_t s_ProfileData[MAX_PROFILEFILES];
- #endif
- void UI_SetActiveMenu( const char* menuname,const char *menuID );
- void ReadSaveDirectory (void);
- //JLF MPMOVED
- #ifdef _XBOX
- //void ReadSaveDirectoryProfiles(void);
- void UI_UpdateSettingsCvars(void);
- static void UI_UpdateVolume(const char* action, const char* type, const char* itemName, int width, int value );
- static void UI_UpdateMoves(void);
- static void UI_UpdateMoveTitles(void);
- #endif
- void Item_RunScript(itemDef_t *item, const char *s);
- qboolean Item_SetFocus(itemDef_t *item, float x, float y);
- qboolean Asset_Parse(char **buffer);
- menuDef_t *Menus_FindByName(const char *p);
- void Menus_HideItems(const char *menuName);
- int Text_Height(const char *text, float scale, int iFontIndex );
- int Text_Width(const char *text, float scale, int iFontIndex );
- void _UI_DrawTopBottom(float x, float y, float w, float h, float size);
- void _UI_DrawSides(float x, float y, float w, float h, float size);
- void UI_CheckVid1Data(const char *menuTo,const char *warningMenuName);
- void UI_GetVideoSetup ( void );
- void UI_UpdateVideoSetup ( void );
- static void UI_UpdateCharacterCvars ( void );
- static void UI_GetCharacterCvars ( void );
- static void UI_UpdateSaberCvars ( void );
- static void UI_GetSaberCvars ( void );
- static void UI_ResetSaberCvars ( void );
- static void UI_InitAllocForcePowers ( const char *forceName );
- static void UI_AffectForcePowerLevel ( const char *forceName );
- static void UI_SetUpForceSelect( void );
- static void UI_ShowForceLevelDesc ( const char *forceName );
- static void UI_ResetForceLevels ( void );
- static void UI_ClearWeapons ( void );
- static void UI_GiveWeapon ( const int weaponIndex );
- static void UI_EquipWeapon ( const int weaponIndex );
- static void UI_LoadMissionSelectMenu( const char *cvarName );
- 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 );
- 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 );
- static void UI_RemoveWeaponSelection ( const int weaponIndex );
- static void UI_RemoveThrowWeaponSelection ( void );
- static void UI_HighLightWeaponSelection ( const int selectionslot );
- static void UI_NormalWeaponSelection ( const int selectionslot );
- static void UI_NormalThrowSelection ( void );
- static void UI_HighLightThrowSelection( void );
- static void UI_ClearInventory ( void );
- static void UI_GiveInventory ( const int itemIndex, const int amount );
- static void UI_ForcePowerWeaponsButton(qboolean activeFlag);
- static void UI_UpdateCharacterSkin( void );
- static void UI_UpdateCharacter( qboolean changedModel );
- static void UI_UpdateSaberType( void );
- static void UI_UpdateSaberHilt( qboolean secondSaber );
- //static void UI_UpdateSaberColor( qboolean secondSaber );
- static void UI_InitWeaponSelect( void );
- static void UI_DisableWeapon( void );
- static void UI_WeaponHelpActive( void );
- static void UI_UpdateFightingStyle ( void );
- static void UI_UpdateFightingStyleChoices ( void );
- static void UI_CalcForceStatus(void);
- static void UI_DecrementForcePowerLevel( void );
- static void UI_DecrementCurrentForcePower ( void );
- static void UI_ShutdownForceHelp( void );
- static void UI_ForceHelpActive( void );
- static void UI_ResetCharacterListBoxes( void );
- static void UI_CheckForForceCheat( void );
- void UI_LoadMenus(const char *menuFile, qboolean reset);
- 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);
- static qboolean UI_OwnerDrawVisible(int flags);
- int UI_OwnerDrawWidth(int ownerDraw, float scale);
- static void UI_Update(const char *name);
- void UI_UpdateCvars( void );
- void UI_ResetDefaults( void );
- void UI_AdjustSaveGameListBox( int currentLine );
- static void UI_FeederSelection(float feederID, int index, itemDef_t *item);
- void Menus_CloseByName(const char *p);
- static qboolean UI_SoftKeyboard_HandleKey(int flags, float *special, int key);
- static qboolean UI_SoftKeyboardDelete_HandleKey(int flags, float *special, int key);
- static qboolean UI_SoftKeyboardAccept_HandleKey(int flags, float *special, int key);
- static void UI_SoftKeyboardInit();
- static void UI_SoftKeyboardDelete();
- static void UI_SoftKeyboardAccept();
- static void UI_SoftKeyboard_Draw();
- static void UI_SoftKeyboardDelete_Draw();
- static void UI_SoftKeyboardAccept_Draw();
- // Level select screen data
- struct levelSelect_t
- {
- char mapname[MAX_QPATH]; // Map name to use when loading
- char displayName[32]; // Text to show in the listbox
- int forceLevel; // Level of neutral force powers
- };
- const levelSelect_t levelSelectData[] = {
- { "yavin1b", "@MENUS_YAVIN1B", 0 },
- { "yavin2", "@MENUS_YAVIN2", 1 },
- { "t1_danger", "@MENUS_T1_DANGER", 1 },
- { "t1_fatal", "@MENUS_T1_FATAL", 1 },
- { "t1_rail", "@MENUS_T1_RAIL", 1 },
- { "t1_sour", "@MENUS_T1_SOUR", 1 },
- { "t1_surprise", "@MENUS_T1_SURPRISE", 1 },
- { "hoth2", "@MENUS_HOTH2", 1 },
- { "hoth3", "@MENUS_HOTH3", 1 },
- { "t2_dpred", "@MENUS_T2_DPRED", 2 },
- { "t2_rancor", "@MENUS_T2_RANCOR", 2 },
- { "t2_rogue", "@MENUS_T2_ROGUE", 2 },
- { "t2_trip", "@MENUS_T2_TRIP", 2 },
- { "t2_wedge", "@MENUS_T2_WEDGE", 2 },
- { "vjun1", "@MENUS_VJUN1", 2 },
- { "vjun2", "@MENUS_VJUN2", 2 },
- { "vjun3", "@MENUS_VJUN3", 2 },
- { "t3_bounty", "@MENUS_T3_BOUNTY", 3 },
- { "t3_byss", "@MENUS_T3_BYSS", 3 },
- { "t3_hevil", "@MENUS_T3_HEVIL", 3 },
- { "t3_rift", "@MENUS_T3_RIFT", 3 },
- { "t3_stamp", "@MENUS_T3_STAMP", 3 },
- { "taspir1", "@MENUS_TASPIR1", 3 },
- { "taspir2", "@MENUS_TASPIR2", 3 },
- { "kor1", "@MENUS_KOR1", 3 },
- { "kor2", "@MENUS_KOR2", 3 },
- };
- const int levelSelectSize = sizeof(levelSelectData) / sizeof(levelSelectData[0]);
- // Currently selected map in level select cheat screen
- int levelSelectChoice = 0;
- // Movedata Sounds
- typedef enum
- {
- MDS_NONE = 0,
- MDS_FORCE_JUMP,
- MDS_ROLL,
- MDS_SABER,
- MDS_MOVE_SOUNDS_MAX
- };
- typedef enum
- {
- MD_ACROBATICS = 0,
- MD_SINGLE_FAST,
- MD_SINGLE_MEDIUM,
- MD_SINGLE_STRONG,
- MD_DUAL_SABERS,
- MD_SABER_STAFF,
- MD_MOVE_TITLE_MAX
- };
- // Some hard coded badness
- // At some point maybe this should be externalized to a .dat file
- char *datapadMoveTitleData[MD_MOVE_TITLE_MAX] =
- {
- "@MENUS_ACROBATICS",
- "@MENUS_SINGLE_FAST",
- "@MENUS_SINGLE_MEDIUM",
- "@MENUS_SINGLE_STRONG",
- "@MENUS_DUAL_SABERS",
- "@MENUS_SABER_STAFF",
- };
- char *datapadMoveTitleBaseAnims[MD_MOVE_TITLE_MAX] =
- {
- "BOTH_RUN1",
- "BOTH_SABERFAST_STANCE",
- "BOTH_STAND2",
- "BOTH_SABERSLOW_STANCE",
- "BOTH_SABERDUAL_STANCE",
- "BOTH_SABERSTAFF_STANCE",
- };
- #define MAX_MOVES 16
- typedef struct
- {
- char *title;
- char *desc;
- char *anim;
- short sound;
- } datpadmovedata_t;
- static datpadmovedata_t datapadMoveData[MD_MOVE_TITLE_MAX][MAX_MOVES] =
- {
- // Acrobatics
- "@MENUS_FORCE_JUMP1", "@MENUS_FORCE_JUMP1_DESC", "BOTH_FORCEJUMP1", MDS_FORCE_JUMP,
- "@MENUS_FORCE_FLIP", "@MENUS_FORCE_FLIP_DESC", "BOTH_FLIP_F", MDS_FORCE_JUMP,
- "@MENUS_ROLL", "@MENUS_ROLL_DESC", "BOTH_ROLL_F", MDS_ROLL,
- "@MENUS_BACKFLIP_OFF_WALL", "@MENUS_BACKFLIP_OFF_WALL_DESC", "BOTH_WALL_FLIP_BACK1", MDS_FORCE_JUMP,
- "@MENUS_SIDEFLIP_OFF_WALL", "@MENUS_SIDEFLIP_OFF_WALL_DESC", "BOTH_WALL_FLIP_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_WALL_RUN", "@MENUS_WALL_RUN_DESC", "BOTH_WALL_RUN_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_LONG_JUMP", "@MENUS_LONG_JUMP_DESC", "BOTH_FORCELONGLEAP_START", MDS_FORCE_JUMP,
- "@MENUS_WALL_GRAB_JUMP", "@MENUS_WALL_GRAB_JUMP_DESC", "BOTH_FORCEWALLREBOUND_FORWARD",MDS_FORCE_JUMP,
- "@MENUS_RUN_UP_WALL_BACKFLIP", "@MENUS_RUN_UP_WALL_BACKFLIP_DESC", "BOTH_FORCEWALLRUNFLIP_START", MDS_FORCE_JUMP,
- "@MENUS_JUMPUP_FROM_KNOCKDOWN", "@MENUS_JUMPUP_FROM_KNOCKDOWN_DESC","BOTH_KNOCKDOWN3", MDS_NONE,
- "@MENUS_JUMPKICK_FROM_KNOCKDOWN", "@MENUS_JUMPKICK_FROM_KNOCKDOWN_DESC","BOTH_KNOCKDOWN2", MDS_NONE,
- "@MENUS_ROLL_FROM_KNOCKDOWN", "@MENUS_ROLL_FROM_KNOCKDOWN_DESC", "BOTH_KNOCKDOWN1", MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Single Saber, Fast Style
- "@MENUS_STAB_BACK", "@MENUS_STAB_BACK_DESC", "BOTH_A2_STABBACK1", MDS_SABER,
- "@MENUS_LUNGE_ATTACK", "@MENUS_LUNGE_ATTACK_DESC", "BOTH_LUNGE2_B__T_", MDS_SABER,
- "@MENUS_FORCE_PULL_IMPALE", "@MENUS_FORCE_PULL_IMPALE_DESC", "BOTH_PULL_IMPALE_STAB", MDS_SABER,
- "@MENUS_FAST_ATTACK_KATA", "@MENUS_FAST_ATTACK_KATA_DESC", "BOTH_A1_SPECIAL", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Single Saber, Medium Style
- "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
- "@MENUS_FLIP_ATTACK", "@MENUS_FLIP_ATTACK_DESC", "BOTH_JUMPFLIPSLASHDOWN1", MDS_FORCE_JUMP,
- "@MENUS_FORCE_PULL_SLASH", "@MENUS_FORCE_PULL_SLASH_DESC", "BOTH_PULL_IMPALE_SWING", MDS_SABER,
- "@MENUS_MEDIUM_ATTACK_KATA", "@MENUS_MEDIUM_ATTACK_KATA_DESC", "BOTH_A2_SPECIAL", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Single Saber, Strong Style
- "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
- "@MENUS_JUMP_ATTACK", "@MENUS_JUMP_ATTACK_DESC", "BOTH_FORCELEAP2_T__B_", MDS_FORCE_JUMP,
- "@MENUS_FORCE_PULL_SLASH", "@MENUS_FORCE_PULL_SLASH_DESC", "BOTH_PULL_IMPALE_SWING", MDS_SABER,
- "@MENUS_STRONG_ATTACK_KATA", "@MENUS_STRONG_ATTACK_KATA_DESC", "BOTH_A3_SPECIAL", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Dual Sabers
- "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
- "@MENUS_FLIP_FORWARD_ATTACK", "@MENUS_FLIP_FORWARD_ATTACK_DESC", "BOTH_JUMPATTACK6", MDS_FORCE_JUMP,
- "@MENUS_DUAL_SABERS_TWIRL", "@MENUS_DUAL_SABERS_TWIRL_DESC", "BOTH_SPINATTACK6", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN_DUAL", MDS_FORCE_JUMP,
- "@MENUS_DUAL_SABER_BARRIER", "@MENUS_DUAL_SABER_BARRIER_DESC", "BOTH_A6_SABERPROTECT", MDS_SABER,
- "@MENUS_DUAL_STAB_FRONT_BACK", "@MENUS_DUAL_STAB_FRONT_BACK_DESC", "BOTH_A6_FB", MDS_SABER,
- "@MENUS_DUAL_STAB_LEFT_RIGHT", "@MENUS_DUAL_STAB_LEFT_RIGHT_DESC", "BOTH_A6_LR", MDS_SABER,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- // Saber Staff
- "@MENUS_STAB_BACK", "@MENUS_STAB_BACK_DESC", "BOTH_A2_STABBACK1", MDS_SABER,
- "@MENUS_BACK_FLIP_ATTACK", "@MENUS_BACK_FLIP_ATTACK_DESC", "BOTH_JUMPATTACK7", MDS_FORCE_JUMP,
- "@MENUS_SABER_STAFF_TWIRL", "@MENUS_SABER_STAFF_TWIRL_DESC", "BOTH_SPINATTACK7", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN_STAFF", MDS_FORCE_JUMP,
- "@MENUS_SPINNING_KATA", "@MENUS_SPINNING_KATA_DESC", "BOTH_A7_SOULCAL", MDS_SABER,
- "@MENUS_KICK1", "@MENUS_KICK1_DESC", "BOTH_A7_KICK_F", MDS_FORCE_JUMP,
- "@MENUS_JUMP_KICK", "@MENUS_JUMP_KICK_DESC", "BOTH_A7_KICK_F_AIR", MDS_FORCE_JUMP,
- "@MENUS_SPLIT_KICK", "@MENUS_SPLIT_KICK_DESC", "BOTH_A7_KICK_RL", MDS_FORCE_JUMP,
- "@MENUS_SPIN_KICK", "@MENUS_SPIN_KICK_DESC", "BOTH_A7_KICK_S", MDS_FORCE_JUMP,
- "@MENUS_FLIP_KICK", "@MENUS_FLIP_KICK_DESC", "BOTH_A7_KICK_BF", MDS_FORCE_JUMP,
- "@MENUS_BUTTERFLY_ATTACK", "@MENUS_BUTTERFLY_ATTACK_DESC", "BOTH_BUTTERFLY_FR1", MDS_SABER,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- };
- static int gamecodetoui[] = {4,2,3,0,5,1,6};
- uiInfo_t uiInfo;
- static void UI_RegisterCvars( void );
- void UI_Load(void);
- typedef struct {
- vmCvar_t *vmCvar;
- char *cvarName;
- char *defaultString;
- int cvarFlags;
- } cvarTable_t;
- vmCvar_t ui_menuFiles;
- vmCvar_t ui_hudFiles;
- vmCvar_t ui_char_anim;
- vmCvar_t ui_char_model;
- vmCvar_t ui_char_skin_head;
- vmCvar_t ui_char_skin_torso;
- vmCvar_t ui_char_skin_legs;
- vmCvar_t ui_saber_type;
- vmCvar_t ui_saber;
- vmCvar_t ui_saber2;
- vmCvar_t ui_saber_color;
- vmCvar_t ui_saber2_color;
- vmCvar_t ui_char_color_red;
- vmCvar_t ui_char_color_green;
- vmCvar_t ui_char_color_blue;
- vmCvar_t ui_PrecacheModels;
- //JLFCALLOUT MPMOVED
- vmCvar_t ui_hideAcallout;
- vmCvar_t ui_hideBcallout;
- vmCvar_t ui_hideXcallout;
- //END JLFCALLOUT
- vmCvar_t saveGameCount;
- vmCvar_t overwriteAvailable;
- vmCvar_t ui_newGameActive;
- vmCvar_t noNewSaveGameAvailable;
- vmCvar_t ui_BlocksAvailable;
- vmCvar_t ui_BlocksNeeded;
- vmCvar_t ui_ShowDelete ;
- vmCvar_t ui_cancelYScript ;
- //controller menu
- vmCvar_t ControllerOutNum ;
- // Version of startup state machine function used when we came from MP XBE:
- void XB_FastStartup( XBStartupState startupState )
- {
- if( startupState <= STARTUP_LOAD_SETTINGS )
- {
- bool bSuccess = Settings.Load();
- if( !bSuccess )
- {
- // Odd. If saving was disabled, then Load will appear to work.
- UI_xboxErrorPopup( XB_POPUP_CORRUPT_SETTINGS );
- return;
- }
- }
- if( startupState <= STARTUP_FINISH )
- {
- // Restore settings from stored (or default) settings:
- Settings.SetAll();
- // Save them out, in case user just deleted (and is now restoring) them:
- Settings.Save();
- // mainMenu has already been opened
- }
- }
- /*
- MASTER Startup function for saved games, invite checks, etc...
- Modeled after XBL_Login
- */
- int blocksNeeded = 0; // 40/44 - Blocks free
- extern bool Sys_QuickStart( void );
- void XB_Startup( XBStartupState startupState )
- {
- // If we came from MP - use the express version
- if( Sys_QuickStart() && Cvar_Get("inSplashMenu", "0", 0)->integer == 0 )
- {
- XB_FastStartup( startupState );
- return;
- }
- if( startupState <= STARTUP_LOAD_SETTINGS )
- {
- bool bSuccess = Settings.Load();
- if( !bSuccess )
- {
- if( Settings.Corrupt() )
- {
- UI_xboxErrorPopup( XB_POPUP_CORRUPT_SETTINGS );
- return;
- }
- // Otherwise, file doesn't exist - continue to space checking below
- }
- else
- {
- // Skip checking space for settings
- startupState = STARTUP_GAME_SPACE_CHECK;
- }
- }
- if( startupState <= STARTUP_COMBINED_SPACE_CHECK )
- {
- // Is there enough room for both settings and a savegame?
- if ( SG_BlocksLeft() < SG_SaveGameSize() + SETTINGS_NUM_BLOCKS )
- {
- blocksNeeded = (SG_SaveGameSize() + SETTINGS_NUM_BLOCKS) - SG_BlocksLeft();
- UI_xboxErrorPopup( XB_POPUP_DISKFULL_BOTH );
- return;
- }
- // OK. There's enough room for settings - make a file:
- Settings.Save();
- }
- if( startupState <= STARTUP_GAME_SPACE_CHECK )
- {
- #ifndef XBOX_DEMO // No space checks in demo
- // Is there enough room for another savegame?
- if( SG_BlocksLeft() < SG_SaveGameSize() )
- {
- blocksNeeded = SG_SaveGameSize() - SG_BlocksLeft();
- UI_xboxErrorPopup( XB_POPUP_DISKFULL );
- return;
- }
- #endif
- }
- if( startupState <= STARTUP_INVITE_CHECK )
- {
- // Do we have a pending invitation? This can only return true ONCE!
- extern bool Sys_InviteExists();
- if( Sys_InviteExists() )
- {
- UI_xboxErrorPopup( XB_POPUP_CONFIRM_INVITE );
- return;
- }
- }
- if( startupState <= STARTUP_FINISH )
- {
- // Restore settings from stored (or default) settings:
- Settings.SetAll();
- // All done! Open the menu!
- Menus_CloseAll();
- Menus_ActivateByName( Cvar_VariableString( "returnMenu" ) );
- }
- }
- static cvarTable_t cvarTable[] =
- {
- { &ui_menuFiles, "ui_menuFiles", "ui/menus.txt", CVAR_ARCHIVE },
- { &ui_hudFiles, "cg_hudFiles", "ui/jahud.txt",CVAR_ARCHIVE},
- { &ui_char_anim, "ui_char_anim", "BOTH_WALK1",0},
- { &ui_char_model, "ui_char_model", "",0}, //these are filled in by the "g_*" versions on load
- { &ui_char_skin_head, "ui_char_skin_head", "",0}, //the "g_*" versions are initialized in UI_Init, ui_atoms.cpp
- { &ui_char_skin_torso, "ui_char_skin_torso", "",0},
- { &ui_char_skin_legs, "ui_char_skin_legs", "",0},
- { &ui_saber_type, "ui_saber_type", "",0},
- { &ui_saber, "ui_saber", "",0},
- { &ui_saber2, "ui_saber2", "",0},
- { &ui_saber_color, "ui_saber_color", "",0},
- { &ui_saber2_color, "ui_saber2_color", "",0},
- { &ui_char_color_red, "ui_char_color_red", "", 0},
- { &ui_char_color_green, "ui_char_color_green", "", 0},
- { &ui_char_color_blue, "ui_char_color_blue", "", 0},
- { &ui_PrecacheModels, "ui_PrecacheModels", "1", CVAR_ARCHIVE},
- //JLFCALLOUT MPMOVED
- { &ui_hideAcallout, "ui_hideAcallout", "", 0},
- { &ui_hideBcallout, "ui_hideBcallout", "", 0},
- { &ui_hideXcallout, "ui_hideXcallout", "", 0},
-
- //END JLFCALLOUT
- { &saveGameCount, "saveGameCount", "", 0},
- { &overwriteAvailable, "overwriteAvailable", "0", 0},
- { &ui_newGameActive, "ui_newGameActive", "", 0},
- { &noNewSaveGameAvailable, "noNewSaveGameAvailable", "", 0},
- { &ui_BlocksAvailable, "ui_BlocksAvailable", "0", 0},
- { &ui_BlocksNeeded, "ui_BlocksNeeded", "0", 0},
- { &ui_ShowDelete, "ui_ShowDelete", "0", 0},
- { &ui_cancelYScript, "ui_cancelYScript", "0", 0},
- { &ControllerOutNum, "ControllerOutNum", "-1", 0},
-
- };
- #define FP_UPDATED_NONE -1
- #define NOWEAPON -1
- static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);
- void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, int iMaxPixelWidth, int style, int iFontIndex);
- int Key_GetCatcher( void );
- #define UI_FPS_FRAMES 4
- void _UI_Refresh( int realtime )
- {
- static int index;
- static int previousTimes[UI_FPS_FRAMES];
- if ( !( Key_GetCatcher() & KEYCATCH_UI ) )
- {
- return;
- }
- extern void SE_CheckForLanguageUpdates(void);
- SE_CheckForLanguageUpdates();
- if ( Menus_AnyFullScreenVisible() )
- {//if not in full screen, don't mess with ghoul2
- //rww - ghoul2 needs to know what time it is even if the client/server are not running
- //FIXME: this screws up the game when you go back to the game...
- G2API_SetTime(realtime, 0);
- G2API_SetTime(realtime, 1);
- }
- uiInfo.uiDC.frameTime = realtime - uiInfo.uiDC.realTime;
- uiInfo.uiDC.realTime = realtime;
- previousTimes[index % UI_FPS_FRAMES] = uiInfo.uiDC.frameTime;
- index++;
- if ( index > UI_FPS_FRAMES )
- {
- int i, total;
- // average multiple frames together to smooth changes out a bit
- total = 0;
- for ( i = 0 ; i < UI_FPS_FRAMES ; i++ )
- {
- total += previousTimes[i];
- }
- if ( !total )
- {
- total = 1;
- }
- uiInfo.uiDC.FPS = 1000 * UI_FPS_FRAMES / total;
- }
- UI_UpdateCvars();
- if (Menu_Count() > 0)
- {
- // paint all the menus
- Menu_PaintAll();
- // refresh server browser list
- // UI_DoServerRefresh();
- // refresh server status
- // UI_BuildServerStatus(qfalse);
- // refresh find player list
- // UI_BuildFindPlayerList(qfalse);
- }
- #ifdef _XBOX
- // display current map name
- if (Cvar_VariableIntegerValue( "cl_maphack" ))
- {
- float rgba[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
- extern cvar_t *cl_mapname;
- Text_Paint(130, 100, /* UI_FONT_DEFAULT, */ 0.9f, rgba, cl_mapname->string, 0, ITEM_TEXTSTYLE_NORMAL, 3);
- }
- #endif
- #ifndef _XBOX
- // draw cursor
- UI_SetColor( NULL );
- if (Menu_Count() > 0)
- {
- if (uiInfo.uiDC.cursorShow == qtrue)
- {
- UI_DrawHandlePic( uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory, 48, 48, uiInfo.uiDC.Assets.cursor);
- }
- }
- #endif
- }
- #ifdef _XBOX
- static void UI_SetVis(menuDef_t* menu, const char* name, bool activeFlag)
- {
- itemDef_t* item = Menu_FindItemByName(menu, name);
- if (item)
- {
- // Make it active
- if (activeFlag)
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- else
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- }
- }
- #endif
- /*
- ===============
- UI_LoadMods
- ===============
- */
- static void UI_LoadMods() {
- int numdirs;
- char dirlist[2048];
- char *dirptr;
- char *descptr;
- int i;
- int dirlen;
- uiInfo.modCount = 0;
- numdirs = FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) );
- dirptr = dirlist;
- for( i = 0; i < numdirs; i++ ) {
- dirlen = strlen( dirptr ) + 1;
- descptr = dirptr + dirlen;
- uiInfo.modList[uiInfo.modCount].modName = String_Alloc(dirptr);
- uiInfo.modList[uiInfo.modCount].modDescr = String_Alloc(descptr);
- dirptr += dirlen + strlen(descptr) + 1;
- uiInfo.modCount++;
- if (uiInfo.modCount >= MAX_MODS) {
- break;
- }
- }
- }
- /*
- ================
- vmMain
- This is the only way control passes into the module.
- This must be the very first function compiled into the .qvm file
- ================
- */
- 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 )
- {
- return 0;
- }
- /*
- ================
- Text_PaintChar
- ================
- */
- /*
- 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)
- {
- float w, h;
- w = width * scale;
- h = height * scale;
- ui.R_DrawStretchPic((int)x, (int)y, w, h, s, t, s2, t2, hShader ); //make the coords (int) or else the chars bleed
- }
- */
- /*
- ================
- Text_Paint
- ================
- */
- // iMaxPixelWidth is 0 here for no limit (but gets converted to -1), else max printable pixel width relative to start pos
- //
- void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, int iMaxPixelWidth, int style, int iFontIndex)
- {
- if (iFontIndex == 0)
- {
- iFontIndex = uiInfo.uiDC.Assets.qhMediumFont;
- }
- // kludge.. convert JK2 menu styles to SOF2 printstring ctrl codes...
- //
- int iStyleOR = 0;
- switch (style)
- {
- // case ITEM_TEXTSTYLE_NORMAL: iStyleOR = 0;break; // JK2 normal text
- // case ITEM_TEXTSTYLE_BLINK: iStyleOR = STYLE_BLINK;break; // JK2 fast blinking
- case ITEM_TEXTSTYLE_PULSE: iStyleOR = STYLE_BLINK;break; // JK2 slow pulsing
- case ITEM_TEXTSTYLE_SHADOWED: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
- case ITEM_TEXTSTYLE_OUTLINED: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
- case ITEM_TEXTSTYLE_OUTLINESHADOWED: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
- case ITEM_TEXTSTYLE_SHADOWEDMORE: iStyleOR = STYLE_DROPSHADOW;break; // JK2 drop shadow ( need a color for this )
- }
- ui.R_Font_DrawString( x, // int ox
- y, // int oy
- text, // const char *text
- color, // paletteRGBA_c c
- iStyleOR | iFontIndex, // const int iFontHandle
- !iMaxPixelWidth?-1:iMaxPixelWidth, // iMaxPixelWidth (-1 = none)
- scale // const float scale = 1.0f
- );
- }
- /*
- ================
- Text_PaintWithCursor
- ================
- */
- // iMaxPixelWidth is 0 here for no-limit
- 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)
- {
- Text_Paint(x, y, scale, color, text, iMaxPixelWidth, style, iFontIndex);
- // now print the cursor as well...
- //
- char sTemp[1024];
- int iCopyCount = min(strlen(text), cursorPos);
- iCopyCount = min(iCopyCount,sizeof(sTemp));
- // copy text into temp buffer for pixel measure...
- //
- strncpy(sTemp,text,iCopyCount);
- sTemp[iCopyCount] = '\0';
-
- int iNextXpos = ui.R_Font_StrLenPixels(sTemp, iFontIndex, scale );
- Text_Paint(x+iNextXpos, y, scale, color, va("%c",cursor), iMaxPixelWidth, style|ITEM_TEXTSTYLE_BLINK, iFontIndex);
- }
- const char *UI_FeederItemText(float feederID, int index, int column, qhandle_t *handle)
- {
- *handle = -1;
- if (feederID == FEEDER_SAVEGAMES)
- {
- if (column==0)
- {
- return s_savedata[index].currentSaveFileName;//currentSaveFileComments;
- }
- else
- {
- return s_savedata[index].currentSaveFileDateTimeString;
- }
- }
- //JLF MPMOVED
- #ifdef _XBOX
- else if (feederID == FEEDER_PROFILES)
- {
- if (column == 0)
- {
- return s_ProfileData[index].currentProfileName;
- }
- }
- #endif
- else if (feederID == FEEDER_MOVES)
- {
- return datapadMoveData[uiInfo.movesTitleIndex][index].title;
- }
- else if (feederID == FEEDER_MOVES_TITLES)
- {
- return datapadMoveTitleData[index];
- }
- else if (feederID == FEEDER_PLAYER_SPECIES)
- {
- return uiInfo.playerSpecies[index].Name;
- }
- else if (feederID == FEEDER_LANGUAGES)
- {
- assert( 0 );
- return NULL;
- // return SE_GetLanguageName( index );
- }
- else if (feederID == FEEDER_PLAYER_SKIN_HEAD)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount)
- {
- *handle = ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index]));
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index];
- }
- }
- else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount)
- {
- *handle = ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index]));
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index];
- }
- }
- else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount)
- {
- *handle = ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index]));
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index];
- }
- }
- else if (feederID == FEEDER_COLORCHOICES)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount)
- {
- *handle = ui.R_RegisterShaderNoMip( uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorShader[index]);
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorShader[index];
- }
- }
- else if (feederID == FEEDER_MODS)
- {
- if (index >= 0 && index < uiInfo.modCount)
- {
- if (uiInfo.modList[index].modDescr && *uiInfo.modList[index].modDescr)
- {
- return uiInfo.modList[index].modDescr;
- }
- else
- {
- return uiInfo.modList[index].modName;
- }
- }
- }
- else if (feederID == FEEDER_LEVELSELECT)
- {
- if (index >= 0 && index < levelSelectSize)
- return levelSelectData[index].displayName;
- }
- return "";
- }
- qhandle_t UI_FeederItemImage(float feederID, int index)
- {
- if (feederID == FEEDER_PLAYER_SKIN_HEAD)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount)
- {
- //return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadIcons[index];
- return ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index]));
- }
- }
- else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount)
- {
- //return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoIcons[index];
- return ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index]));
- }
- }
- else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount)
- {
- //return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegIcons[index];
- return ui.R_RegisterShaderNoMip(va("models/players/%s/icon_%s.jpg", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].Name, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index]));
- }
- }
- else if (feederID == FEEDER_COLORCHOICES)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount)
- {
- return ui.R_RegisterShaderNoMip( uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorShader[index]);
- }
- }
- /* else if (feederID == FEEDER_ALLMAPS || feederID == FEEDER_MAPS)
- {
- int actual;
- UI_SelectedMap(index, &actual);
- index = actual;
- if (index >= 0 && index < uiInfo.mapCount)
- {
- if (uiInfo.mapList[index].levelShot == -1)
- {
- uiInfo.mapList[index].levelShot = trap_R_RegisterShaderNoMip(uiInfo.mapList[index].imageName);
- }
- return uiInfo.mapList[index].levelShot;
- }
- }
- */
- return 0;
- }
- void setArrowX(itemDef_t * arrowcontrol, int xloc)
- {
-
- arrowcontrol->window.rect.x = xloc;
- }
- /*
- =================
- CreateNextSaveName
- =================
- */
- static int CreateNextSaveName(char *fileName)
- {
- int i;
- // Loop through all the save games and look for the first open name
- for (i=0;i<MAX_SAVELOADFILES;i++)
- {
- Com_sprintf( fileName, MAX_SAVELOADNAME, "jedi_%02d", i );
- if (!ui.SG_GetSaveGameComment(fileName, NULL, NULL))
- {
- return qtrue;
- }
- }
- return qfalse;
- }
- /*
- ===============
- UI_DeferMenuScript
- Return true if the menu script should be deferred for later
- ===============
- */
- static qboolean UI_DeferMenuScript ( const char **args )
- {
- const char* name;
- // Whats the reason for being deferred?
- if (!String_Parse(args, &name))
- {
- return qfalse;
- }
- if( !Q_stricmp ( name, "always" ) )
- {
- return qtrue;
- }
- // Handle the custom cases
- if ( !Q_stricmp ( name, "VideoSetup" ) )
- {
- const char* warningMenuName;
- qboolean deferred;
- // No warning menu specified
- if ( !String_Parse(args, &warningMenuName) )
- {
- return qfalse;
- }
- // Defer if the video options were modified
- deferred = Cvar_VariableIntegerValue( "ui_r_modified" ) ? qtrue : qfalse;
- if ( deferred )
- {
- // Open the warning menu
- Menus_OpenByName(warningMenuName);
- }
- return deferred;
- }
- //JLF
- #ifdef _XBOX
- /*
- if ( !Q_stricmp ( name, "ProfileSave" ) )
- {
- const char* warningMenuName;
- qboolean deferred;
- // No warning menu specified
- if ( !String_Parse(args, &warningMenuName) )
- {
- return qfalse;
- }
- // Defer if the video options were modified
- deferred = Cvar_VariableIntegerValue( "ui_profileSaveNeeded" ) ? qtrue : qfalse;
- if ( deferred )
- {
- // Open the warning menu
- Menus_OpenByName(warningMenuName);
- }
- return deferred;
- }
- */
- #endif
- return qfalse;
- }
- void ui_DeleteGame()
- {
- if (s_savedata[s_savegame.currentLine].currentSaveFileName) // A line was chosen
- {
- #ifndef FINAL_BUILD
- ui.Printf( va("%s\n","Attempting to delete game"));
- #endif
- strcpy(g_loadsaveGameName,s_savedata[s_savegame.currentLine].currentSaveFileName);
- g_loadsaveGameNameInitialized = qtrue;
- ui.Cmd_ExecuteText( EXEC_NOW, va("wipe file\n"));//%s\n", s_savedata[s_savegame.currentLine].currentSaveFileName));
-
-
- if( (s_savegame.currentLine>0) && ((s_savegame.currentLine+1) == s_savegame.saveFileCnt) )
- {
- s_savegame.currentLine--;
- // yeah this is a pretty bad hack
- // adjust cursor position of listbox so correct item is highlighted
- UI_AdjustSaveGameListBox( s_savegame.currentLine );
- }
-
- // ReadSaveDirectory(); //refresh
- s_savegame.saveFileCnt = -1; //force a refresh at drawtime
- }
- }
- void ui_SaveGame()
- {
- char fileName[MAX_SAVELOADNAME];
- char description[64];
- // Create a new save game
- // if ( !s_savedata[s_savegame.currentLine].currentSaveFileName) // No line was chosen
- {
- //JLF MPNOTUSED
- #ifdef _XBOX
- strcpy(fileName, "JKSG3");
- #else
- CreateNextSaveName(fileName);
-
- #endif
- }
- // else // Overwrite a current save game? Ask first.
- {
- // s_savegame.yes.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
- // s_savegame.no.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
- // strcpy(fileName,s_savedata[s_savegame.currentLine].currentSaveFileName);
- // s_savegame.awaitingSave = qtrue;
- // s_savegame.deletegame.generic.flags = QMF_GRAYED; // Turn off delete button
- // break;
- }
- // Save description line
- ui.Cvar_VariableStringBuffer("ui_gameDesc",description,sizeof(description));
- ui.SG_StoreSaveGameComment(description);
- ui.Cmd_ExecuteText( EXEC_APPEND, va("save %s\n", fileName));
- // s_savegame.saveFileCnt = -1; //force a refresh the next time around
- }
- void openDashBoardMemory()
- {
- // TCR C4-3 Cleanup Support
- // Launch to the Dash memory area to clean up
- // Reboot to Dash
- LAUNCH_DATA ld;
- memset(&ld, 0, sizeof(ld));
- PLD_LAUNCH_DASHBOARD pDash = (PLD_LAUNCH_DASHBOARD) &ld;
- pDash->dwReason = XLD_LAUNCH_DASHBOARD_MEMORY;
- char * path = NULL;
- pDash->dwContext = 0;
- pDash->dwParameter1 = 'U';
- pDash->dwParameter2 = SG_SaveGameSize() + SETTINGS_NUM_BLOCKS;
- S_Shutdown();
- // Similarly, kill off the streaming thread
- extern void Sys_StreamShutdown(void);
- Sys_StreamShutdown();
- XLaunchNewImage(path, &ld);
- // LD_LAUNCH_DASHBOARD LaunchDash;
- // LaunchDash.dwReason = XLD_LAUNCH_DASHBOARD_MEMORY;
- // LaunchDash.dwContext = 0;
- // LaunchDash.dwParameter1 = DWORD( 'U');
- // LaunchDash.dwParameter2 = SG_SaveGameSize();
- // XLaunchNewImage( NULL, (PLAUNCH_DATA)(&LaunchDash) );
- // We never get here
- }
- #ifdef XBOX_DEMO
- // Bleh.
- int demoForcePowerLevel[NUM_FORCE_POWERS];
- void UI_DemoSetForceLevels( void )
- {
- if( Cvar_VariableIntegerValue( "t1_mission" ) == 0 ) // Sour
- {// NOTE : always set the uiInfo powers
- // level 1 in all core powers
- demoForcePowerLevel[FP_LEVITATION]=1;
- demoForcePowerLevel[FP_SPEED]=1;
- demoForcePowerLevel[FP_PUSH]=1;
- demoForcePowerLevel[FP_PULL]=1;
- demoForcePowerLevel[FP_SEE]=1;
- demoForcePowerLevel[FP_SABER_OFFENSE]=1;
- demoForcePowerLevel[FP_SABER_DEFENSE]=1;
- demoForcePowerLevel[FP_SABERTHROW]=1;
- // plus these extras
- demoForcePowerLevel[FP_HEAL]=1;
- demoForcePowerLevel[FP_TELEPATHY]=1;
- demoForcePowerLevel[FP_GRIP]=1;
- // and set the rest to zero
- demoForcePowerLevel[FP_ABSORB]=0;
- demoForcePowerLevel[FP_PROTECT]=0;
- demoForcePowerLevel[FP_DRAIN]=0;
- demoForcePowerLevel[FP_LIGHTNING]=0;
- demoForcePowerLevel[FP_RAGE]=0;
- }
- else // Rift
- {
- // level 3 in all core powers
- demoForcePowerLevel[FP_LEVITATION]=3;
- demoForcePowerLevel[FP_SPEED]=3;
- demoForcePowerLevel[FP_PUSH]=3;
- demoForcePowerLevel[FP_PULL]=3;
- demoForcePowerLevel[FP_SEE]=3;
- demoForcePowerLevel[FP_SABER_OFFENSE]=3;
- demoForcePowerLevel[FP_SABER_DEFENSE]=3;
- demoForcePowerLevel[FP_SABERTHROW]=3;
- // plus these extras
- demoForcePowerLevel[FP_HEAL]=1;
- demoForcePowerLevel[FP_TELEPATHY]=1;
- demoForcePowerLevel[FP_GRIP]=2;
- demoForcePowerLevel[FP_LIGHTNING]=1;
- demoForcePowerLevel[FP_PROTECT]=1;
-
- // and set the rest to zero
-
- demoForcePowerLevel[FP_ABSORB]=0;
- demoForcePowerLevel[FP_DRAIN]=0;
- demoForcePowerLevel[FP_RAGE]=0;
- }
- }
- #endif
- /*
- ===============
- UI_RunMenuScript
- ===============
- */
- static qboolean UI_RunMenuScript ( const char **args )
- {
- const char *name, *name2,*mapName,*menuName,*warningMenuName;
- if (String_Parse(args, &name))
- {
- if (Q_stricmp(name, "resetdefaults") == 0)
- {
- UI_ResetDefaults();
- }
- else if (Q_stricmp(name, "saveControls") == 0)
- {
- Controls_SetConfig(qtrue);
- }
- else if (Q_stricmp(name, "loadControls") == 0)
- {
- Controls_GetConfig();
- }
- else if (Q_stricmp(name, "clearError") == 0)
- {
- Cvar_Set("com_errorMessage", "");
- }
- //possibly make a separate readsavedirectory call that does it immediately
- else if (Q_stricmp(name, "ReadSaveDirectory") == 0)
- {
- s_savegame.saveFileCnt = -1; //force a refresh at drawtime
- }
- else if (Q_stricmp(name, "loadAuto") == 0)
- {
- // Menus_CloseAll();
- UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
- ui.Cmd_ExecuteText( EXEC_APPEND, "wait ; wait ; wait ; wait ; load auto\n"); //load game menu
- }
- else if (Q_stricmp(name, "loadgame") == 0)
- {
- if (s_savedata[s_savegame.currentLine].currentSaveFileName)
- {
- // Menus_CloseAll();
- UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
- // the 'load' call is broken for levelnames that have spaces
- // the global variable 'g_loadGameName' will carry the level name through
- ui.Cmd_ExecuteText( EXEC_APPEND, va("wait ; wait ; wait ; wait ; load level\n"));
- strcpy(g_loadsaveGameName,s_savedata[s_savegame.currentLine].currentSaveFileName);
- g_loadsaveGameNameInitialized = qtrue;
- }
- }
- else if (Q_stricmp(name, "deletegame") == 0)
- {
- ui_DeleteGame();
- }
- else if (Q_stricmp(name, "savegame") == 0)
- {
- ui_SaveGame();
- }
- else if (Q_stricmp(name, "checkforoverwrite") == 0)
- {
- if(s_savegame.saveFileCnt == MAX_SAVELOADFILES && !s_savegame.currentLine) // check to see if there are enough slots
- {
- // No free slots
- Cvar_Set( "ui_overwriting", "3");
- }
- else
- {
- char fileName[MAX_SAVELOADNAME];
- char description[64];
- if (svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
- {
- Cvar_Set( "ui_overwriting", "666");
- }
- else if ( s_savegame.currentLine || (1== Cvar_VariableIntegerValue("noNewSaveGameAvailable")&& s_savegame.saveFileCnt>0))
- {
- // On an existing savegame
- Cvar_Set( "ui_overwriting", "1");
- }
- else if ( SG_BlocksLeft() < SG_SaveGameSize())
- {
- // Insufficient space
- blocksNeeded = SG_SaveGameSize() - SG_BlocksLeft();
- Cvar_Set( "ui_overwriting", "2");
- }
- else
- {
- // Everything ok
- Cvar_Set( "ui_overwriting", "0");
- }
- }
- }
- else if (Q_stricmp(name, "loadgameselect") == 0)
- {
- if ( trap_Cvar_VariableValue("cl_paused")>0 )
- { //popup the confirmation
- UI_xboxErrorPopup( XB_POPUP_LOAD_CONFIRM );
- }
- else
- {
- itemDef_t item;
- item.parent = Menu_GetFocused();
- item.window.flags = 0;
- Item_RunScript(&item, "uiScript loadgame");
- }
- }
-
- else if (Q_stricmp(name, "LoadMods") == 0)
- {
- UI_LoadMods();
- }
- else if (Q_stricmp(name, "RunMod") == 0)
- {
- if (uiInfo.modList[uiInfo.modIndex].modName)
- {
- Cvar_Set( "fs_game", uiInfo.modList[uiInfo.modIndex].modName);
- extern void FS_Restart( void );
- FS_Restart();
- Cbuf_ExecuteText( EXEC_APPEND, "vid_restart;" );
- }
- }
- else if (Q_stricmp(name, "Quit") == 0)
- {
- Cbuf_ExecuteText( EXEC_NOW, "quit");
- }
- else if (Q_stricmp(name, "Controls") == 0)
- {
- Cvar_Set( "cl_paused", "1" );
- trap_Key_SetCatcher( KEYCATCH_UI );
- Menus_CloseAll();
- Menus_ActivateByName("setup_menu2");
- }
- else if (Q_stricmp(name, "Leave") == 0)
- {
- Cbuf_ExecuteText( EXEC_APPEND, "disconnect\n" );
- trap_Key_SetCatcher( KEYCATCH_UI );
- Menus_CloseAll();
- //Menus_ActivateByName("mainMenu");
- }
- else if (Q_stricmp(name, "getvideosetup") == 0)
- {
- UI_GetVideoSetup ( );
- }
- else if (Q_stricmp(name, "updatevideosetup") == 0)
- {
- UI_UpdateVideoSetup ( );
- }
- else if (Q_stricmp(name, "nextDataPadForcePower") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_NOW, "dpforcenext\n");
- extern void CG_SetDataPadForceText( void );
- CG_SetDataPadForceText();
- }
- else if (Q_stricmp(name, "prevDataPadForcePower") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_NOW, "dpforceprev\n");
- extern void CG_SetDataPadForceText( void );
- CG_SetDataPadForceText();
- }
- else if (Q_stricmp(name, "nextDataPadWeapon") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_NOW, "dpweapnext\n");
- extern void CG_SetDataPadWeaponText( void );
- CG_SetDataPadWeaponText();
- }
- else if (Q_stricmp(name, "prevDataPadWeapon") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_NOW, "dpweapprev\n");
- extern void CG_SetDataPadWeaponText( void );
- CG_SetDataPadWeaponText();
- }
- else if (Q_stricmp(name, "nextDataPadInventory") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "dpinvnext\n");
- }
- else if (Q_stricmp(name, "prevDataPadInventory") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "dpinvprev\n");
- }
- else if (Q_stricmp(name, "checkvid1data") == 0) // Warn user data has changed before leaving screen?
- {
- String_Parse(args, &menuName);
- String_Parse(args, &warningMenuName);
- UI_CheckVid1Data(menuName,warningMenuName);
- }
- else if (Q_stricmp(name, "startgame") == 0)
- {
- Menus_CloseAll();
- if ( Cvar_VariableIntegerValue("com_demo") )
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "map demo\n");
- }
- else
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "map yavin1\n");
- }
- }
- else if (Q_stricmp(name, "startmap") == 0)
- {
- Menus_CloseAll();
- String_Parse(args, &mapName);
- ui.Cmd_ExecuteText( EXEC_APPEND, va("maptransition %s\n",mapName));
- }
- else if (Q_stricmp(name, "closeingame") == 0)
- {
- trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );
- trap_Key_ClearStates();
- Cvar_Set( "cl_paused", "0" );
- Menus_CloseAll();
- if (1 == Cvar_VariableIntegerValue("ui_missionfailed"))
- {
- Menus_ActivateByName("missionfailed_menu");
- ui.Key_SetCatcher( KEYCATCH_UI );
- }
- else
- {
- Menus_ActivateByName("mainhud");
- }
- }
- else if (Q_stricmp(name, "closedatapad") == 0)
- {
- trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );
- trap_Key_ClearStates();
- Cvar_Set( "cl_paused", "0" );
- Menus_CloseAll();
- Menus_ActivateByName("mainhud");
- Cvar_Set( "cg_updatedDataPadForcePower1", "0" );
- Cvar_Set( "cg_updatedDataPadForcePower2", "0" );
- Cvar_Set( "cg_updatedDataPadForcePower3", "0" );
- Cvar_Set( "cg_updatedDataPadObjective", "0" );
- }
- else if (Q_stricmp(name, "closesabermenu") == 0)
- {
- // if we're in the saber menu when creating a character, close this down
- if( !Cvar_VariableIntegerValue( "saber_menu" ) )
- {
- Menus_CloseByName( "saberMenu" );
- Menus_OpenByName( "characterMenu" );
- }
- }
- else if (Q_stricmp(name, "clearmouseover") == 0)
- {
- itemDef_t *item;
- menuDef_t *menu = Menu_GetFocused();
- if (menu)
- {
- const char *itemName;
- String_Parse(args, &itemName);
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, itemName);
- if (item)
- {
- item->window.flags &= ~WINDOW_MOUSEOVER;
- }
- }
- }
- else if (Q_stricmp(name, "setMovesListDefault") == 0)
- {
- uiInfo.movesTitleIndex = 2;
- }
- else if (Q_stricmp(name, "resetMovesDesc") == 0)
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item;
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName(menu, "item_desc");
- if (item)
- {
- listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
- if( listPtr )
- {
- listPtr->cursorPos = 0;
- listPtr->startPos = 0;
- }
- item->cursorPos = 0;
- }
- }
- }
- else if (Q_stricmp(name, "resetMovesList") == 0)
- {
- menuDef_t *menu;
- menu = Menus_FindByName("datapadMovesMenu");
- //update saber models
- if (menu)
- {
- itemDef_t *item;
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- UI_SaberAttachToChar( item );
- }
- }
- Cvar_Set( "ui_move_desc", " " );
- }
- // else if (Q_stricmp(name, "setanisotropicmax") == 0)
- // {
- // r_ext_texture_filter_anisotropic->value;
- // }
- else if (Q_stricmp(name, "setMoveCharacter") == 0)
- {
- itemDef_t *item;
- menuDef_t *menu;
- modelDef_t *modelPtr;
- char skin[MAX_QPATH];
- UI_GetCharacterCvars();
- UI_GetSaberCvars();
- uiInfo.movesTitleIndex = 0;
- menu = Menus_FindByName("datapadMovesMenu");
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- modelPtr = (modelDef_t*)item->typeData;
- if (modelPtr)
- {
- uiInfo.movesBaseAnim = datapadMoveTitleBaseAnims[uiInfo.movesTitleIndex];
- ItemParse_model_g2anim_go( item, uiInfo.movesBaseAnim );
- uiInfo.moveAnimTime = 0 ;
- DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
- Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
- Cvar_VariableString ( "g_char_model"),
- Cvar_VariableString ( "g_char_skin_head"),
- Cvar_VariableString ( "g_char_skin_torso"),
- Cvar_VariableString ( "g_char_skin_legs")
- );
- ItemParse_model_g2skin_go( item, skin );
- UI_SaberAttachToChar( item );
- }
- }
- }
- }
- else if (Q_stricmp(name, "glCustom") == 0)
- {
- Cvar_Set("ui_r_glCustom", "4");
- }
- else if (Q_stricmp(name, "character") == 0)
- {
- UI_UpdateCharacter( qfalse );
- }
- else if (Q_stricmp(name, "characterchanged") == 0)
- {
- UI_UpdateCharacter( qtrue );
- }
- else if (Q_stricmp(name, "char_skin") == 0)
- {
- UI_UpdateCharacterSkin();
- }
- else if (Q_stricmp(name, "saber_type") == 0)
- {
- UI_UpdateSaberType();
- }
- else if (Q_stricmp(name, "saber_hilt") == 0)
- {
- UI_UpdateSaberHilt( qfalse );
- }
- else if (Q_stricmp(name, "saber_color") == 0)
- {
- // UI_UpdateSaberColor( qfalse );
- }
- else if (Q_stricmp(name, "saber2_hilt") == 0)
- {
- UI_UpdateSaberHilt( qtrue );
- }
- else if (Q_stricmp(name, "saber2_color") == 0)
- {
- // UI_UpdateSaberColor( qtrue );
- }
- else if (Q_stricmp(name, "updatecharcvars") == 0)
- {
- UI_UpdateCharacterCvars();
- }
- else if (Q_stricmp(name, "getcharcvars") == 0)
- {
- UI_GetCharacterCvars();
- }
- else if (Q_stricmp(name, "updatesabercvars") == 0)
- {
- UI_UpdateSaberCvars();
- }
- else if (Q_stricmp(name, "getsabercvars") == 0)
- {
- UI_GetSaberCvars();
- }
- else if (Q_stricmp(name, "resetsabercvardefaults") == 0)
- {
- // NOTE : ONLY do this if saber menu is set properly (ie. first time we enter this menu)
- if( !Cvar_VariableIntegerValue( "saber_menu" ) )
- {
- UI_ResetSaberCvars();
- }
- }
- else if( Q_stricmp(name, "fixforsabercheat") == 0)
- {
- if(strstr(Cvar_Get("g_saber2"," ", 0)->string, "single"))
- {
- extern bool Cheat_ChangeSaber( void );
- Cheat_ChangeSaber();
- Cheat_ChangeSaber();
- }
- }
- else if (Q_stricmp(name, "updatefightingstylechoices") == 0)
- {
- UI_UpdateFightingStyleChoices();
- }
- else if (Q_stricmp(name, "initallocforcepower") == 0)
- {
- const char *forceName;
- String_Parse(args, &forceName);
- UI_InitAllocForcePowers(forceName);
- }
- else if (Q_stricmp(name, "affectforcepowerlevel") == 0)
- {
- const char *forceName;
- String_Parse(args, &forceName);
- UI_AffectForcePowerLevel(forceName);
- }
- else if (Q_stricmp(name, "decrementcurrentforcepower") == 0)
- {
- UI_DecrementCurrentForcePower();
- }
- else if (Q_stricmp(name, "shutdownforcehelp") == 0)
- {
- UI_ShutdownForceHelp();
- }
- else if (Q_stricmp(name, "forcehelpactive") == 0)
- {
- UI_ForceHelpActive();
- }
- else if (Q_stricmp(name, "showforceleveldesc") == 0)
- {
- const char *forceName;
- String_Parse(args, &forceName);
- UI_ShowForceLevelDesc(forceName);
- }
- else if (Q_stricmp(name, "resetforcelevels") == 0)
- {
- UI_ResetForceLevels();
- }
- else if (Q_stricmp(name, "checkforforcecheat") == 0)
- {
- UI_CheckForForceCheat();
- }
- else if (Q_stricmp(name, "weaponhelpactive") == 0)
- {
- UI_WeaponHelpActive();
- }
- // initialize weapon selection screen
- else if (Q_stricmp(name, "initweaponselect") == 0)
- {
- UI_InitWeaponSelect();
- }
- else if(Q_stricmp(name, "setupForceSelect") == 0)
- {
- UI_SetUpForceSelect();
- }
- else if (Q_stricmp(name, "clearweapons") == 0)
- {
- UI_ClearWeapons();
- }
- else if (Q_stricmp(name, "stopgamesounds") == 0)
- {
- trap_S_StopSounds();
- }
- else if (Q_stricmp(name, "loadmissionselectmenu") == 0)
- {
- const char *cvarName;
- String_Parse(args, &cvarName);
- if (cvarName)
- {
- UI_LoadMissionSelectMenu(cvarName);
- }
- }
- else if (Q_stricmp(name, "calcforcestatus") == 0)
- {
- UI_CalcForceStatus();
- }
- else if (Q_stricmp(name, "giveweapon") == 0)
- {
- const char *weaponIndex;
- String_Parse(args, &weaponIndex);
- UI_GiveWeapon(atoi(weaponIndex));
- }
- else if (Q_stricmp(name, "equipweapon") == 0)
- {
- const char *weaponIndex;
- String_Parse(args, &weaponIndex);
- UI_EquipWeapon(atoi(weaponIndex));
- }
- else if (Q_stricmp(name, "addweaponselection") == 0)
- {
- const char *weaponIndex;
- String_Parse(args, &weaponIndex);
- if (!weaponIndex)
- {
- return qfalse;
- }
- const char *ammoIndex;
- String_Parse(args, &ammoIndex);
- if (!ammoIndex)
- {
- return qfalse;
- }
- const char *ammoAmount;
- String_Parse(args, &ammoAmount);
- if (!ammoAmount)
- {
- return qfalse;
- }
- const char *itemName;
- String_Parse(args, &itemName);
- if (!itemName)
- {
- return qfalse;
- }
- const char *litItemName;
- String_Parse(args, &litItemName);
- if (!litItemName)
- {
- return qfalse;
- }
- const char *backgroundName;
- String_Parse(args, &backgroundName);
- if (!backgroundName)
- {
- return qfalse;
- }
- const char *soundfile = NULL;
- String_Parse(args, &soundfile);
-
- UI_AddWeaponSelection(atoi(weaponIndex),atoi(ammoIndex),atoi(ammoAmount),itemName,litItemName, backgroundName, soundfile);
- }
- else if (Q_stricmp(name, "addthrowweaponselection") == 0)
- {
- const char *weaponIndex;
- String_Parse(args, &weaponIndex);
- if (!weaponIndex)
- {
- return qfalse;
- }
- const char *ammoIndex;
- String_Parse(args, &ammoIndex);
- if (!ammoIndex)
- {
- return qfalse;
- }
- const char *ammoAmount;
- String_Parse(args, &ammoAmount);
- if (!ammoAmount)
- {
- return qfalse;
- }
- const char *itemName;
- String_Parse(args, &itemName);
- if (!itemName)
- {
- return qfalse;
- }
- const char *litItemName;
- String_Parse(args, &litItemName);
- if (!litItemName)
- {
- return qfalse;
- }
- const char *backgroundName;
- String_Parse(args, &backgroundName);
- if (!backgroundName)
- {
- return qfalse;
- }
- const char *soundfile;
- String_Parse(args, &soundfile);
- UI_AddThrowWeaponSelection(atoi(weaponIndex),atoi(ammoIndex),atoi(ammoAmount),itemName,litItemName,backgroundName, soundfile);
- }
- else if (Q_stricmp(name, "removeweaponselection") == 0)
- {
- const char *weaponIndex;
- String_Parse(args, &weaponIndex);
- if (weaponIndex)
- {
- UI_RemoveWeaponSelection(atoi(weaponIndex));
- }
- }
- else if (Q_stricmp(name, "removethrowweaponselection") == 0)
- {
- UI_RemoveThrowWeaponSelection();
- }
- else if (Q_stricmp(name, "normalthrowselection") == 0)
- {
- UI_NormalThrowSelection();
- }
- else if (Q_stricmp(name, "highlightthrowselection") == 0)
- {
- UI_HighLightThrowSelection();
- }
- else if (Q_stricmp(name, "normalweaponselection") == 0)
- {
- const char *slotIndex;
- String_Parse(args, &slotIndex);
- if (!slotIndex)
- {
- return qfalse;
- }
- UI_NormalWeaponSelection(atoi(slotIndex));
- }
- else if (Q_stricmp(name, "highlightweaponselection") == 0)
- {
- const char *slotIndex;
- String_Parse(args, &slotIndex);
- if (!slotIndex)
- {
- return qfalse;
- }
- UI_HighLightWeaponSelection(atoi(slotIndex));
- }
- else if (Q_stricmp(name, "clearinventory") == 0)
- {
- UI_ClearInventory();
- }
- else if (Q_stricmp(name, "giveinventory") == 0)
- {
- const char *inventoryIndex,*amount;
- String_Parse(args, &inventoryIndex);
- String_Parse(args, &amount);
- UI_GiveInventory(atoi(inventoryIndex),atoi(amount));
- }
- else if (Q_stricmp(name, "updatefightingstyle") == 0)
- {
- UI_UpdateFightingStyle();
- }
- else if (Q_stricmp(name, "update") == 0)
- {
- if (String_Parse(args, &name2))
- {
- UI_Update(name2);
- }
- else
- {
- Com_Printf("update missing cmd\n");
- }
- }
- else if (Q_stricmp(name, "load_quick") == 0)
- {
- ui.Cmd_ExecuteText(EXEC_APPEND,"load quick\n");
- }
- else if (Q_stricmp(name, "load_auto") == 0)
- {
- if ( trap_Cvar_VariableValue("cl_paused")>0 )
- { //popup the confirmation
- UI_xboxErrorPopup( XB_POPUP_LOAD_CONFIRM_CHECKPOINT );
- }
- else
- {
- ui.Cmd_ExecuteText(EXEC_APPEND,"load *respawn\n"); //death menu, might load a saved game instead if they just loaded on this map
- }
- }
- else if (Q_stricmp(name, "load_auto_failed") == 0)
- {
- // Crazy case, we put up the Load Game screen here, then the popup over it.
- Menus_CloseAll();
- Cvar_Set( "returnmenu", "missionfailed_menu" );
- Cvar_Set( "cl_paused", "1" );
- Cvar_Set( "ui_missionfailed", "1" );
- Cvar_Set( "ui_frontEnd", "1" );
- #ifdef XBOX_DEMO
- // For the demo (which should never show the load game screen)
- // we show the pause menu instead:
- Menus_ActivateByName( "ingameMainMenu" );
- #else
- Menus_ActivateByName( "loadMenu" );
- #endif
- UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
- 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
- }
- else if (Q_stricmp(name, "decrementforcepowerlevel") == 0)
- {
- UI_DecrementForcePowerLevel();
- }
- else if (Q_stricmp(name, "resetcharacterlistboxes") == 0)
- {
- UI_ResetCharacterListBoxes();
- }
- #ifdef _XBOX
- else if (Q_stricmp(name, "multiplayer") == 0)
- {
- extern void Sys_Reboot( const char *reason, const void *pData );
- Sys_Reboot("multiplayer", NULL);
- }
- //JLF MPMOVED
- #if 0
- else if (Q_stricmp(name, "loadprofile") == 0)
- {
- if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
- {
- Menus_CloseAll();
- ui.Cmd_ExecuteText( EXEC_APPEND, va("loadprofile %s\n", s_ProfileData[s_playerProfile.currentLine].currentProfileName));
- }
- }
- else if (Q_stricmp(name, "saveprofile") == 0)
- {
- //if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
- {
- Menus_CloseAll();
- // ui.Cmd_ExecuteText( EXEC_APPEND, va("saveprofile %s\n", "test"/*s_ProfileData[s_playerProfile.currentLine].currentProfileName*/));
- }
- }
- else if (Q_stricmp(name, "initprofile") == 0)
- {
- //if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
- {
- Menus_CloseAll();
- ui.Cmd_ExecuteText( EXEC_APPEND, va("initprofile \n" ));
- }
- }
- else if (Q_stricmp(name, "deleteprofile") == 0)
- {
- //if (s_ProfileData[s_playerProfile.currentLine].currentProfileName)// && (*s_file_desc_field.field.buffer))
- {
- Menus_CloseAll();
- ui.Cmd_ExecuteText( EXEC_APPEND, va("deleteprofile %s\n","test" ));
- }
- }
- else if (Q_stricmp(name, "testandsaveprofile") == 0)
- {
- if (Cvar_VariableIntegerValue("ui_profileSaveNeeded"))// && (*s_file_desc_field.field.buffer))
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, va("saveprofile %s\n",s_ProfileData[s_playerProfile.currentLine].currentProfileName ));
- Cvar_Set("ui_profileSaveNeeded","0");
- }
- }
- #endif
- //JLF
- else if (Q_stricmp(name, "processForDiskSpace") == 0)
- {
- // Kick off the crazy sequence!
- XB_Startup( STARTUP_LOAD_SETTINGS );
- }
- else if (Q_stricmp(name, "initListBoxes") == 0)
- {
- ui_ShowDeleteActive = qfalse;
- //find the listboxes for this level
- menuDef_t * menu = Menu_GetFocused(); // Get current menu
-
- if (menu)
- {
- int i;
-
- for (i = 0; i < menu->itemCount; i++)
- {
- listBoxDef_t *listPtr;
- //Item_ValidateTypeData(item);
- if (menu->items[i]->type == ITEM_TYPE_LISTBOX)
- {
- listPtr = (listBoxDef_t*)menu->items[i]->typeData;
- if (listPtr)
- {
- listPtr->cursorPos = 0;
- listPtr->startPos = 0;
- menu->items[i]->cursorPos =0;
- if (menu->items[i]->special== FEEDER_SAVEGAMES)
- {
- UI_FeederSelection( FEEDER_SAVEGAMES , 0, NULL );
- }
- }
- }
- }
- }
- }
- else if (Q_stricmp(name, "confirmdelete") == 0)
- {
- // User is already logged on - is trying to back out. Get confirmation
- UI_xboxErrorPopup( XB_POPUP_DELETE_CONFIRM );
- }
- else if (Q_stricmp(name, "xboxErrorResponse") == 0)
- {
- // User closed the Xbox Error Popup in some way. Do TheRightThing(TM)
- UI_xboxPopupResponse();
- }
- else if (Q_stricmp(name, "genericpopup") == 0)
- {
- const char *menuid;
- String_Parse(args, &menuid);
- if(Q_stricmp(menuid, "savecomplete") == 0)
- {
- UI_xboxErrorPopup( XB_POPUP_SAVE_COMPLETE );
- }
- else if(Q_stricmp(menuid, "overwriteconfirm") == 0)
- {
- int confirmType = Cvar_VariableIntegerValue( "ui_overwriting" );
- if( confirmType == 3 )
- {
- UI_xboxErrorPopup( XB_POPUP_TOO_MANY_SAVES );
- }
- else if( confirmType == 1 )
- {
- UI_xboxErrorPopup( XB_POPUP_OVERWRITE_CONFIRM );
- }
- else if( confirmType == 2 )
- {
- UI_xboxErrorPopup( XB_POPUP_DISKFULL_DURING_SAVE );
- }
- else if( confirmType == 666)
- {
- UI_xboxErrorPopup( XB_POPUP_YOU_ARE_DEAD );
- }
- }
- else if(Q_stricmp(menuid, "quitconfirm") == 0)
- {
- UI_xboxErrorPopup( XB_POPUP_QUIT_CONFIRM );
- }
- else if(Q_stricmp(menuid, "saving") == 0)
- {
- UI_xboxErrorPopup( XB_POPUP_SAVING );
- }
- else if(Q_stricmp(menuid, "confirmNewMission1") == 0)
- {
- UI_xboxErrorPopup( XB_POPUP_CONFIRM_NEW_1 );
- }
- else if(Q_stricmp(menuid, "confirmNewMission2") == 0)
- {
- UI_xboxErrorPopup( XB_POPUP_CONFIRM_NEW_2 );
- }
- else if(Q_stricmp(menuid, "confirmNewMission3") == 0)
- {
- UI_xboxErrorPopup( XB_POPUP_CONFIRM_NEW_3 );
- }
- }
- else if (Q_stricmp(name, "setarrow")==0)
- {
- const char *controlName ;
- const char *arrowControlName ;
- const char * controlText;
- int textwidth;
- int startx;
- itemDef_t * item;
- itemDef_t * arrowControl;
- menuDef_t *menu;
- menu = Menu_GetFocused();
-
- String_Parse(args, &controlName);
- String_Parse(args, &arrowControlName);
- //get the textwidth from control
- if (menu)
- {
- itemDef_t *item;
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, controlName);
- if (*(item->text) == '@') // string reference
- {
- controlText = SE_GetString( &(item->text[1]) );
- }
- else
- controlText = item->text;
- textwidth = DC->textWidth( controlText, item->textscale, item->font );
- startx = item->window.rect.x;
- arrowControl = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, arrowControlName);
- setArrowX(arrowControl, textwidth + startx+ ARROW_SPACE);
- }
-
- }
- else if (Q_stricmp(name, "getControls") == 0)
- {
- // Fetches all controls on the basic controls screen into ui cvars:
- // Inverted aim:
- Cvar_SetValue("ui_mousePitch", (Cvar_VariableValue("m_pitch") >= 0) ? 0 : 1);
- // Thumbstick, buttons, triggers are automatic
- }
- else if (Q_stricmp(name, "setControls") == 0)
- {
- // Assigns all changes made on the basic controls screen:
- char token[MAX_QPATH];
- // Update inverted aim:
- Settings.invertAim[0] = Cvar_VariableIntegerValue( "ui_mousePitch" ) ? false : true;
- Cvar_SetValue( "m_pitch", Settings.invertAim[0] ? 0.022f : -0.022f );
- // update thumbsticks in settings file:
- Settings.thumbstickMode[0] = DC->getCVarValue( "ui_thumbStickMode" );
-
- // update triggers
- DC->getCVarString( "ui_triggerconfig", token, sizeof(token) );
- if( !Q_stricmp(token, "default") )
- {
- Cbuf_ExecuteText( EXEC_NOW, "exec cfg/triggersConfig0.cfg" );
- Settings.triggerMode[0] = 0;
- }
- else if( !Q_stricmp(token, "southpaw") )
- {
- Cbuf_ExecuteText( EXEC_NOW, "exec cfg/triggersConfig1.cfg" );
- Settings.triggerMode[0] = 1;
- }
- // update buttons
- DC->getCVarString( "ui_buttonconfig", token, sizeof(token) );
- if( !Q_stricmp(token, "weaponsbias") )
- {
- Cbuf_ExecuteText( EXEC_NOW, "exec cfg/spbuttonConfig0.cfg" );
- Settings.buttonMode[0] = 0;
- }
- else if( !Q_stricmp(token, "forcebias") )
- {
- Cbuf_ExecuteText( EXEC_NOW, "exec cfg/spbuttonConfig1.cfg" );
- Settings.buttonMode[0] = 1;
- }
- else if( !Q_stricmp(token, "southpaw") )
- {
- Cbuf_ExecuteText( EXEC_NOW, "exec cfg/spbuttonConfig2.cfg" );
- Settings.buttonMode[0] = 2;
- }
- Settings.Save();
- }
- else if (Q_stricmp(name, "getsettingscvars") == 0)
- {
- // Fetches everything on the advanced controls screen:
- Cvar_SetValue( "ui_useRumble", Cvar_VariableIntegerValue( "in_useRumble" ) );
- Cvar_SetValue( "ui_autolevel", Cvar_VariableIntegerValue( "cl_autolevel" ) );
- Cvar_SetValue( "ui_autoswitch", Cvar_VariableIntegerValue( "cg_autoswitch" ) );
-
- // Horizontal/vertical
- Cvar_SetValue( "ui_sensitivity", Cvar_VariableValue( "sensitivity" ) );
- Cvar_SetValue( "ui_sensitivityY", Cvar_VariableValue( "sensitivityY" ) );
- }
- else if (Q_stricmp(name, "updatesettingscvars") == 0)
- {
- // Rumble
- Settings.rumble[0] = Cvar_VariableIntegerValue( "ui_useRumble" );
- Cvar_SetValue( "in_useRumble", Settings.rumble[0] );
- // Auto-level
- Settings.autolevel[0] = Cvar_VariableIntegerValue( "ui_autolevel" );
- Cvar_SetValue( "cl_autolevel", Settings.autolevel[0] );
- // Weapon switch
- Settings.autoswitch[0] = Cvar_VariableIntegerValue( "ui_autoswitch" );
- Cvar_SetValue( "cg_autoswitch", Settings.autoswitch[0] );
- // Turn/look
- Settings.sensitivityX[0] = Cvar_VariableValue( "ui_sensitivity" );
- Settings.sensitivityY[0] = Cvar_VariableValue( "ui_sensitivityY" );
- Cvar_SetValue( "sensitivity", Settings.sensitivityX[0] );
- Cvar_SetValue( "sensitivityY", Settings.sensitivityY[0] );
- Settings.Save();
- }
- else if (Q_stricmp(name, "softkeyboardinit") == 0)
- {
- UI_SoftKeyboardInit();
- }
- else if (Q_stricmp(name, "updatevolume") == 0)
- {
- // Store all settings from the audio page:
- Settings.effectsVolume = Cvar_VariableValue( "s_effects_volume" );
- Settings.musicVolume = Cvar_VariableValue( "s_music_volume" );
- Settings.voiceVolume = Cvar_VariableValue( "s_voice_volume" );
- Settings.subtitles = Cvar_VariableIntegerValue( "g_subtitles" );
- Settings.brightness = Cvar_VariableValue( "s_brightness_volume" );
- extern void GLimp_SetGamma(float);
- GLimp_SetGamma(Cvar_VariableValue( "s_brightness_volume" ) / 5.0f);
- Settings.Save();
- }
- else if (Q_stricmp(name, "brightnessChanged") == 0)
- {
- extern void GLimp_SetGamma(float);
- GLimp_SetGamma(Cvar_VariableValue( "s_brightness_volume" ) / 5.0f);
- }
- else if(Q_stricmp(name,"updatemoves") == 0)
- {
- menuDef_t *menu;
- menu = Menus_FindByName("datapadMovesMenu");
- //update saber models
- if (menu)
- {
- itemDef_t *item;
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- UI_SaberAttachToChar( item );
- }
- }
- UI_UpdateMoves();
- }
- else if(Q_stricmp(name,"updatemovetitles") == 0)
- {
- UI_UpdateMoveTitles();
- }
- else if(Q_stricmp(name, "resetscroll") == 0)
- {
- menuDef_t *menu = Menu_GetFocused();
- if(!menu)
- return qfalse;
- for( int i = 0; i < menu->itemCount; ++i )
- {
- if( menu->items[i]->type == ITEM_TYPE_TEXTSCROLL )
- {
- textScrollDef_t *scrollPtr = (textScrollDef_t*)menu->items[i]->typeData;
- scrollPtr->startPos = 0;
- }
- }
- }
- else if(Q_stricmp(name, "levelselect") == 0)
- {
- const char *action;
- String_Parse(args, &action);
- if (!action)
- return qfalse;
- if (Q_stricmp(action, "init") == 0)
- {
- UI_FeederSelection( FEEDER_LEVELSELECT, 0, NULL );
- }
- else if (Q_stricmp(action, "load") == 0)
- {
- int levelSelectCheat = levelSelectData[levelSelectChoice].forceLevel;
- Cvar_Set("levelSelectCheat", va("%d", levelSelectCheat));
- Cbuf_ExecuteText( EXEC_APPEND, va("map %s\n", levelSelectData[levelSelectChoice].mapname) );
- }
- }
- else if(Q_stricmp(name,"simulateuppress") == 0)
- {
- extern itemDef_t *Menu_SetNextCursorItem(menuDef_t *menu);
- menuDef_t *menu = Menu_GetFocused();
- Menu_SetNextCursorItem(menu);
- }
- else if(Q_stricmp(name,"simulatedownpress") == 0)
- {
- extern itemDef_t *Menu_SetPrevCursorItem(menuDef_t *menu);
- menuDef_t *menu = Menu_GetFocused();
- Menu_SetPrevCursorItem(menu);
- }
- else if(Q_stricmp(name,"setMainController") == 0)
- {
- extern char lastControllerUsed;
- extern void IN_SetMainController(int id);
- IN_SetMainController(lastControllerUsed);
- }
- #endif
- #ifdef XBOX_DEMO
- else if(Q_stricmp(name, "initdemoforce") == 0)
- {
- UI_DemoSetForceLevels();
- }
- else if(Q_stricmp(name, "leaveDemo") == 0)
- {
- extern void Sys_Reboot( const char *reason, const void *pData );
- Sys_Reboot( "demo", NULL );
- }
- else if(Q_stricmp(name, "kioskCheck") == 0)
- {
- // Only do this check once
- static bool firstTime = true;
- // If we were started in kiosk mode (this is a filthy way to determine that)
- // then we should start attract mode immediately:
- extern bool demoTimerAlways;
- extern void PlayDemo( void );
- if( firstTime && demoTimerAlways )
- {
- firstTime = false; // Bad fix for an awful recursion bug
- PlayDemo();
- }
- firstTime = false;
- }
- else if(Q_stricmp(name, "clearplayersave") == 0)
- {
- Cvar_Set( "playersave", "" );
- }
- #endif
- else
- {
- Com_Printf("unknown UI script %s\n", name);
- }
- }
- return qtrue;
- }
- /*
- =================
- UI_GetValue
- =================
- */
- static float UI_GetValue(int ownerDraw)
- {
- return 0;
- }
- //Force Warnings
- typedef enum
- {
- FW_VERY_LIGHT = 0,
- FW_SEMI_LIGHT,
- FW_NEUTRAL,
- FW_SEMI_DARK,
- FW_VERY_DARK
- };
- const char *lukeForceStatusSounds[] =
- {
- "sound/chars/luke/misc/MLUK_03.mp3", // Very Light
- "sound/chars/luke/misc/MLUK_04.mp3", // Semi Light
- "sound/chars/luke/misc/MLUK_05.mp3", // Neutral
- "sound/chars/luke/misc/MLUK_01.mp3", // Semi dark
- "sound/chars/luke/misc/MLUK_02.mp3", // Very dark
- };
- const char *kyleForceStatusSounds[] =
- {
- "sound/chars/kyle/misc/MKYK_05.mp3", // Very Light
- "sound/chars/kyle/misc/MKYK_04.mp3", // Semi Light
- "sound/chars/kyle/misc/MKYK_03.mp3", // Neutral
- "sound/chars/kyle/misc/MKYK_01.mp3", // Semi dark
- "sound/chars/kyle/misc/MKYK_02.mp3", // Very dark
- };
- static void UI_CalcForceStatus(void)
- {
- float lightSide,darkSide,total;
- short who, index=FW_VERY_LIGHT;
- qboolean lukeFlag=qtrue;
- float percent;
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- char value[256];
- if (!cl)
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- if (!cl->gentity || !cl->gentity->client)
- {
- return;
- }
- memset(value, 0, sizeof(value));
- lightSide = pState->forcePowerLevel[FP_HEAL] +
- pState->forcePowerLevel[FP_TELEPATHY] +
- pState->forcePowerLevel[FP_PROTECT] +
- pState->forcePowerLevel[FP_ABSORB];
-
- darkSide = pState->forcePowerLevel[FP_GRIP] +
- pState->forcePowerLevel[FP_LIGHTNING] +
- pState->forcePowerLevel[FP_RAGE] +
- pState->forcePowerLevel[FP_DRAIN];
-
- total = lightSide + darkSide;
- percent = lightSide / total;
- who = Q_irand( 0, 100 );
- if (percent >= 0.90f) // 90 - 100%
- {
- index = FW_VERY_LIGHT;
- if (who <50)
- {
- strcpy(value,"vlk"); // Very light Kyle
- lukeFlag = qfalse;
- }
- else
- {
- strcpy(value,"vll"); // Very light Luke
- }
- }
- else if (percent > 0.60f )
- {
- index = FW_SEMI_LIGHT;
- if ( who<50 )
- {
- strcpy(value,"slk"); // Semi-light Kyle
- lukeFlag = qfalse;
- }
- else
- {
- strcpy(value,"sll"); // Semi-light light Luke
- }
- }
- else if (percent > 0.40f )
- {
- index = FW_NEUTRAL;
- if ( who<50 )
- {
- strcpy(value,"ntk"); // Neutral Kyle
- lukeFlag = qfalse;
- }
- else
- {
- strcpy(value,"ntl"); // Netural Luke
- }
- }
- else if (percent > 0.10f )
- {
- index = FW_SEMI_DARK;
- if ( who<50 )
- {
- strcpy(value,"sdk"); // Semi-dark Kyle
- lukeFlag = qfalse;
- }
- else
- {
- strcpy(value,"sdl"); // Semi-Dark Luke
- }
- }
- else
- {
- index = FW_VERY_DARK;
- if ( who<50 )
- {
- strcpy(value,"vdk"); // Very dark Kyle
- lukeFlag = qfalse;
- }
- else
- {
- strcpy(value,"vdl"); // Very Dark Luke
- }
- }
- Cvar_Set("ui_forcestatus", value );
- if (lukeFlag)
- {
- DC->startLocalSound(DC->registerSound(lukeForceStatusSounds[index], qfalse), CHAN_VOICE );
- }
- else
- {
- DC->startLocalSound(DC->registerSound(kyleForceStatusSounds[index], qfalse), CHAN_VOICE );
- }
- }
- /*
- =================
- UI_StopCinematic
- =================
- */
- static void UI_StopCinematic(int handle)
- {
- if (handle >= 0)
- {
- trap_CIN_StopCinematic(handle);
- }
- else
- {
- handle = abs(handle);
- if (handle == UI_MAPCINEMATIC)
- {
- // FIXME - BOB do we need this?
- // if (uiInfo.mapList[ui_currentMap.integer].cinematic >= 0)
- // {
- // trap_CIN_StopCinematic(uiInfo.mapList[ui_currentMap.integer].cinematic);
- // uiInfo.mapList[ui_currentMap.integer].cinematic = -1;
- // }
- }
- else if (handle == UI_NETMAPCINEMATIC)
- {
- // FIXME - BOB do we need this?
- // if (uiInfo.serverStatus.currentServerCinematic >= 0)
- // {
- // trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic);
- // uiInfo.serverStatus.currentServerCinematic = -1;
- // }
- }
- else if (handle == UI_CLANCINEMATIC)
- {
- // FIXME - BOB do we need this?
- // int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName"));
- // if (i >= 0 && i < uiInfo.teamCount)
- // {
- // if (uiInfo.teamList[i].cinematic >= 0)
- // {
- // trap_CIN_StopCinematic(uiInfo.teamList[i].cinematic);
- // uiInfo.teamList[i].cinematic = -1;
- // }
- // }
- }
- }
- }
- static void UI_HandleLoadSelection()
- {
- Cvar_Set("ui_SelectionOK", va("%d",(s_savegame.currentLine < s_savegame.saveFileCnt)) );
- if (s_savegame.currentLine >= s_savegame.saveFileCnt)
- return;
- // Cvar_Set("ui_gameDesc", s_savedata[s_savegame.currentLine].currentSaveFileComments ); // set comment
- bool R_UpdateSaveGameImage(const char *filename);
- //create the correctfilename
- unsigned short saveGameName[filepathlength];
- char directoryInfo[filepathlength];
- char psLocalFilename[filepathlength];
- mbstowcs(saveGameName, s_savedata[s_savegame.currentLine].currentSaveFileName, filepathlength);
- if (ERROR_SUCCESS ==XCreateSaveGame("U:\\", saveGameName, OPEN_EXISTING, 0,directoryInfo, filepathlength))
- {
- strcpy (psLocalFilename , directoryInfo);
- strcat (psLocalFilename , "screenshot.xbx");
- if( !R_UpdateSaveGameImage(psLocalFilename) &&
- !s_savedata[s_savegame.currentLine].screenshotNotify )
- {
- s_savedata[s_savegame.currentLine].screenshotNotify = 1;
- UI_xboxErrorPopup( XB_POPUP_CORRUPT_SCREENSHOT );
- }
- }
- else
- R_UpdateSaveGameImage( "z:\\screenshot.xbx" );
- }
- /*
- =================
- UI_FeederCount
- =================
- */
- static int UI_FeederCount(float feederID)
- {
- #ifdef _XBOX
- //JLF MPNOTNEEDED
- static bool firstSaveRequest = true;
- //JLF MPMOVED
- static bool firstProfileListRequest = true;
- #endif
- if (feederID == FEEDER_SAVEGAMES )
- {
- //JLF MPNOTNEEDED
- #ifdef _XBOX
- if (s_savegame.saveFileCnt == -1 || firstSaveRequest)
- {
- firstSaveRequest = false;
- #else
- if (s_savegame.saveFileCnt == -1)
- {
- #endif
- ReadSaveDirectory(); //refresh
- UI_HandleLoadSelection();
- UI_AdjustSaveGameListBox(s_savegame.currentLine);
- }
- return s_savegame.saveFileCnt;
- }
- //JLF MPMOVED
- #ifdef _XBOX
- else if (feederID == FEEDER_PROFILES )
- {
- // if (s_playerProfile.fileCnt == -1 || firstProfileListRequest)
- // {
- firstProfileListRequest = false;
- // ReadSaveDirectoryProfiles(); //refresh
- // UI_HandleLoadSelection();
- // }
- return s_playerProfile.fileCnt;
- }
- #endif
- // count number of moves for the current title
- else if (feederID == FEEDER_MOVES)
- {
- int count=0,i;
- for (i=0;i<MAX_MOVES;i++)
- {
- if (datapadMoveData[uiInfo.movesTitleIndex][i].title)
- {
- count++;
- }
- }
- return count;
- }
- else if (feederID == FEEDER_MOVES_TITLES)
- {
- return (MD_MOVE_TITLE_MAX);
- }
- else if (feederID == FEEDER_MODS)
- {
- return uiInfo.modCount;
- }
- else if (feederID == FEEDER_LANGUAGES)
- {
- assert( 0 );
- // return uiInfo.languageCount;
- }
- else if (feederID == FEEDER_PLAYER_SPECIES)
- {
- return uiInfo.playerSpeciesCount;
- }
- else if (feederID == FEEDER_PLAYER_SKIN_HEAD)
- {
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount;
- }
- else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
- {
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount;
- }
- else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
- {
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount;
- }
- else if (feederID == FEEDER_COLORCHOICES)
- {
- return uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount;
- }
- else if (feederID == FEEDER_LEVELSELECT)
- {
- return levelSelectSize;
- }
- return 0;
- }
- /*
- =================
- UI_FeederSelection
- =================
- */
- static void UI_FeederSelection(float feederID, int index, itemDef_t *item)
- {
- static char info[MAX_STRING_CHARS];
- if (feederID == FEEDER_SAVEGAMES)
- {
- s_savegame.currentLine = index;
- if (s_savedata[s_savegame.saveFileCnt].corrupt = true)
- Cvar_SetValue("ui_FileCorrupt", 1);
- else
- Cvar_SetValue("ui_FileCorrupt", 0);
- if (index ==0 && noNewSaveGameAvailable.integer == 0)
- {
- if (!ui_ShowDeleteActive)
- {
- //there is a 'new save game' index that is highlighted
- Cvar_SetValue("ui_ShowDelete",trap_Cvar_VariableValue("ui_showYdel"));
- Cvar_SetValue("ui_showYdel",0);
- ui_ShowDeleteActive = qtrue;
- Cvar_SetValue( "ui_cancelYScript",1);
-
- }
- }
- else if (ui_ShowDeleteActive)
- {
-
- Cvar_SetValue("ui_showYdel",trap_Cvar_VariableValue("ui_ShowDelete"));
- ui_ShowDeleteActive = qfalse;
- Cvar_SetValue("ui_cancelYScript",0);
- }
- storeSGDataDatetoCvar();
- storeSGDataTimetoCvar();
- storeSGDataDiffLeveltoCvar();
- UI_HandleLoadSelection();
- }
- else if (feederID == FEEDER_MOVES)
- {
- itemDef_t *item;
- menuDef_t *menu;
- modelDef_t *modelPtr;
- char skin[MAX_QPATH];
- menu = Menus_FindByName("datapadMovesMenu");
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- modelPtr = (modelDef_t*)item->typeData;
- if (modelPtr)
- {
- if (datapadMoveData[uiInfo.movesTitleIndex][index].anim)
- {
- ItemParse_model_g2anim_go( item, datapadMoveData[uiInfo.movesTitleIndex][index].anim );
- uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
- uiInfo.moveAnimTime += uiInfo.uiDC.realTime;
- // Play sound for anim
- if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_FORCE_JUMP)
- {
- DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveJumpSound, CHAN_LOCAL );
- }
- else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_ROLL)
- {
- DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveRollSound, CHAN_LOCAL );
- }
- else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_SABER)
- {
- // Randomly choose one sound
- int soundI = Q_irand( 1, 6 );
- sfxHandle_t *soundPtr;
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound1;
- if (soundI == 2)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound2;
- }
- else if (soundI == 3)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound3;
- }
- else if (soundI == 4)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound4;
- }
- else if (soundI == 5)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound5;
- }
- else if (soundI == 6)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound6;
- }
- DC->startLocalSound(*soundPtr, CHAN_LOCAL );
- }
- if (datapadMoveData[uiInfo.movesTitleIndex][index].desc)
- {
- Cvar_Set( "ui_move_desc", datapadMoveData[uiInfo.movesTitleIndex][index].desc);
- }
- Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
- Cvar_VariableString ( "g_char_model"),
- Cvar_VariableString ( "g_char_skin_head"),
- Cvar_VariableString ( "g_char_skin_torso"),
- Cvar_VariableString ( "g_char_skin_legs")
- );
- ItemParse_model_g2skin_go( item, skin );
- }
- }
- }
- }
- }
- else if (feederID == FEEDER_MOVES_TITLES)
- {
- itemDef_t *item;
- menuDef_t *menu;
- modelDef_t *modelPtr;
- uiInfo.movesTitleIndex = index;
- uiInfo.movesBaseAnim = datapadMoveTitleBaseAnims[uiInfo.movesTitleIndex];
- menu = Menus_FindByName("datapadMovesMenu");
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- modelPtr = (modelDef_t*)item->typeData;
- if (modelPtr)
- {
- ItemParse_model_g2anim_go( item, uiInfo.movesBaseAnim );
- uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
- }
- }
- }
- }
- else if (feederID == FEEDER_MODS)
- {
- uiInfo.modIndex = index;
- }
- else if (feederID == FEEDER_PLAYER_SPECIES)
- {
- uiInfo.playerSpeciesIndex = index;
- }
- else if (feederID == FEEDER_LANGUAGES)
- {
- uiInfo.languageCountIndex = index;
- }
- else if (feederID == FEEDER_PLAYER_SKIN_HEAD)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadCount)
- {
- Cvar_Set("ui_char_skin_head", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinHeadNames[index]);
- }
- }
- else if (feederID == FEEDER_PLAYER_SKIN_TORSO)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoCount)
- {
- Cvar_Set("ui_char_skin_torso", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinTorsoNames[index]);
- }
- }
- else if (feederID == FEEDER_PLAYER_SKIN_LEGS)
- {
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegCount)
- {
- Cvar_Set("ui_char_skin_legs", uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].SkinLegNames[index]);
- }
- }
- else if (feederID == FEEDER_COLORCHOICES)
- {
- extern void Item_RunScript(itemDef_t *item, const char *s); //from ui_shared;
- if (index >= 0 && index < uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorCount)
- {
- Item_RunScript(item, uiInfo.playerSpecies[uiInfo.playerSpeciesIndex].ColorActionText[index]);
- }
- }
- else if (feederID == FEEDER_LEVELSELECT)
- {
- if (index >= 0 && index < levelSelectSize)
- levelSelectChoice = index;
- }
- /* else if (feederID == FEEDER_CINEMATICS)
- {
- uiInfo.movieIndex = index;
- if (uiInfo.previewMovie >= 0)
- {
- trap_CIN_StopCinematic(uiInfo.previewMovie);
- }
- uiInfo.previewMovie = -1;
- }
- else if (feederID == FEEDER_DEMOS)
- {
- uiInfo.demoIndex = index;
- }
- */
- }
- void Key_KeynumToStringBuf( int keynum, char *buf, int buflen );
- void Key_GetBindingBuf( int keynum, char *buf, int buflen );
- static qboolean UI_Crosshair_HandleKey(int flags, float *special, int key)
- {
- if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER)
- {
- if (key == A_MOUSE2)
- {
- uiInfo.currentCrosshair--;
- } else {
- uiInfo.currentCrosshair++;
- }
- if (uiInfo.currentCrosshair >= NUM_CROSSHAIRS) {
- uiInfo.currentCrosshair = 0;
- } else if (uiInfo.currentCrosshair < 0) {
- uiInfo.currentCrosshair = NUM_CROSSHAIRS - 1;
- }
- Cvar_Set("cg_drawCrosshair", va("%d", uiInfo.currentCrosshair));
- return qtrue;
- }
- return qfalse;
- }
- static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key)
- {
- switch (ownerDraw)
- {
- case UI_CROSSHAIR:
- UI_Crosshair_HandleKey(flags, special, key);
- break;
- case UI_SOFT_KEYBOARD:
- return UI_SoftKeyboard_HandleKey(flags, special, key);
- break;
- case UI_SOFT_KEYBOARD_DELETE:
- return UI_SoftKeyboardDelete_HandleKey(flags, special, key);
- break;
- case UI_SOFT_KEYBOARD_ACCEPT:
- return UI_SoftKeyboardAccept_HandleKey(flags, special, key);
- break;
- default:
- break;
- }
- return qfalse;
- }
- //unfortunately we cannot rely on any game/cgame module code to do our animation stuff,
- //because the ui can be loaded while the game/cgame are not loaded. So we're going to recreate what we need here.
- // On Xbox, we need all the RAM we can get, and this is huge. So we just borrow the one from level. I hope
- // this doesn't cause some apocalypse. Getting access to level in here is nigh impossible, as we'd have to
- // include g_local.h, and the consequences of that are bad. So: This pointer is initialized in a global constructor
- // in class UIAnimFileSetInitializer in g_main.cpp! Look there! Don't forget!
- //#ifdef _XBOX
- //animFileSet_t *ui_knownAnimFileSets = NULL;
- //#else
- #undef MAX_ANIM_FILES
- #define MAX_ANIM_FILES 4
- typedef struct
- {
- char filename[MAX_QPATH];
- animation_t animations[MAX_ANIMATIONS];
- } animFileSet_t;
- static animFileSet_t ui_knownAnimFileSets[MAX_ANIM_FILES];
- //#endif
- int ui_numKnownAnimFileSets;
- qboolean UI_ParseAnimationFile( const char *af_filename )
- {
- const char *text_p;
- int len;
- int i;
- const char *token;
- float fps;
- int skip;
- char text[80000];
- int animNum;
- animation_t *animations = ui_knownAnimFileSets[ui_numKnownAnimFileSets].animations;
- len = re.GetAnimationCFG(af_filename, text, sizeof(text));
- if ( len <= 0 )
- {
- return qfalse;
- }
- if ( len >= sizeof( text ) - 1 )
- {
- Com_Error( ERR_FATAL, "UI_ParseAnimationFile: File %s too long\n (%d > %d)", af_filename, len, sizeof( text ) - 1);
- return qfalse;
- }
- // parse the text
- text_p = text;
- skip = 0; // quiet the compiler warning
- //FIXME: have some way of playing anims backwards... negative numFrames?
- //initialize anim array so that from 0 to MAX_ANIMATIONS, set default values of 0 1 0 100
- for(i = 0; i < MAX_ANIMATIONS; i++)
- {
- animations[i].firstFrame = 0;
- animations[i].numFrames = 0;
- animations[i].loopFrames = -1;
- animations[i].frameLerp = 100;
- // animations[i].initialLerp = 100;
- }
- // read information for each frame
- while(1)
- {
- token = COM_Parse( &text_p );
- if ( !token || !token[0])
- {
- break;
- }
- animNum = GetIDForString(animTable, token);
- if(animNum == -1)
- {
- //#ifndef FINAL_BUILD
- #ifdef _DEBUG
- if (strcmp(token,"ROOT"))
- {
- Com_Printf(S_COLOR_RED"WARNING: Unknown token %s in %s\n", token, af_filename);
- }
- #endif
- while (token[0])
- {
- token = COM_ParseExt( &text_p, qfalse ); //returns empty string when next token is EOL
- }
- continue;
- }
- token = COM_Parse( &text_p );
- if ( !token )
- {
- break;
- }
- animations[animNum].firstFrame = atoi( token );
- token = COM_Parse( &text_p );
- if ( !token )
- {
- break;
- }
- animations[animNum].numFrames = atoi( token );
- token = COM_Parse( &text_p );
- if ( !token )
- {
- break;
- }
- animations[animNum].loopFrames = atoi( token );
- token = COM_Parse( &text_p );
- if ( !token )
- {
- break;
- }
- fps = atof( token );
- if ( fps == 0 )
- {
- fps = 1;//Don't allow divide by zero error
- }
- if ( fps < 0 )
- {//backwards
- animations[animNum].frameLerp = floor(1000.0f / fps);
- }
- else
- {
- animations[animNum].frameLerp = ceil(1000.0f / fps);
- }
- // animations[animNum].initialLerp = ceil(1000.0f / fabs(fps));
- }
- return qtrue;
- }
- qboolean UI_ParseAnimFileSet( const char *animCFG, int *animFileIndex )
- { //Not going to bother parsing the sound config here.
- char afilename[MAX_QPATH];
- char strippedName[MAX_QPATH];
- int i;
- char *slash;
- Q_strncpyz( strippedName, animCFG, sizeof(strippedName), qtrue);
- slash = strrchr( strippedName, '/' );
- if ( slash )
- {
- // truncate modelName to find just the dir not the extension
- *slash = 0;
- }
- //if this anims file was loaded before, don't parse it again, just point to the correct table of info
- for ( i = 0; i < ui_numKnownAnimFileSets; i++ )
- {
- if ( Q_stricmp(ui_knownAnimFileSets[i].filename, strippedName ) == 0 )
- {
- *animFileIndex = i;
- return qtrue;
- }
- }
- if ( ui_numKnownAnimFileSets == MAX_ANIM_FILES )
- {//TOO MANY!
- for (i = 0; i < MAX_ANIM_FILES; i++)
- {
- Com_Printf("animfile[%d]: %s\n", i, ui_knownAnimFileSets[i].filename);
- }
- Com_Error( ERR_FATAL, "UI_ParseAnimFileSet: %d == MAX_ANIM_FILES == %d", ui_numKnownAnimFileSets, MAX_ANIM_FILES);
- }
- //Okay, time to parse in a new one
- Q_strncpyz( ui_knownAnimFileSets[ui_numKnownAnimFileSets].filename, strippedName, sizeof( ui_knownAnimFileSets[ui_numKnownAnimFileSets].filename ) );
- // Load and parse animations.cfg file
- Com_sprintf( afilename, sizeof( afilename ), "%s/animation.cfg", strippedName );
- if ( !UI_ParseAnimationFile( afilename ) )
- {
- *animFileIndex = -1;
- return qfalse;
- }
- //set index and increment
- *animFileIndex = ui_numKnownAnimFileSets++;
- return qtrue;
- }
- int UI_G2SetAnim(CGhoul2Info *ghlInfo, const char *boneName, int animNum, const qboolean freeze)
- {
- int animIndex,blendTime;
- char *GLAName;
- GLAName = G2API_GetGLAName(ghlInfo);
- if (!GLAName || !GLAName[0])
- {
- return 0;
- }
- UI_ParseAnimFileSet(GLAName, &animIndex);
- if (animIndex != -1)
- {
- animation_t *anim = &ui_knownAnimFileSets[animIndex].animations[animNum];
- if (anim->numFrames <= 0)
- {
- return 0;
- }
- int sFrame = anim->firstFrame;
- int eFrame = anim->firstFrame + anim->numFrames;
- int flags = BONE_ANIM_OVERRIDE;
- int time = uiInfo.uiDC.realTime;
- float animSpeed = (50.0f / anim->frameLerp);
- blendTime = 150;
- // Freeze anim if it's not looping, special hack for datapad moves menu
- if (freeze)
- {
- if (anim->loopFrames == -1)
- {
- flags = BONE_ANIM_OVERRIDE_FREEZE;
- }
- else
- {
- flags = BONE_ANIM_OVERRIDE_LOOP;
- }
- }
- else if (anim->loopFrames != -1)
- {
- flags = BONE_ANIM_OVERRIDE_LOOP;
- }
- flags |= BONE_ANIM_BLEND;
- blendTime = 150;
- G2API_SetBoneAnim(ghlInfo, boneName, sFrame, eFrame, flags, animSpeed, time, -1, blendTime);
- return ((anim->frameLerp * (anim->numFrames-2)));
- }
- return 0;
- }
- static qboolean UI_ParseColorData(char* buf, playerSpeciesInfo_t &species)
- {
- const char *token;
- const char *p;
- p = buf;
- COM_BeginParseSession();
- species.ColorCount = 0;
- while ( p )
- {
- token = COM_ParseExt( &p, qtrue ); //looking for the shader
- if ( token[0] == 0 )
- {
- return species.ColorCount;
- }
- Q_strncpyz( species.ColorShader[species.ColorCount], token, sizeof(species.ColorShader[0]), qtrue );
- token = COM_ParseExt( &p, qtrue ); //looking for action block {
- if ( token[0] != '{' )
- {
- return qfalse;
- }
- assert(!species.ColorActionText[species.ColorCount][0]);
- token = COM_ParseExt( &p, qtrue ); //looking for action commands
- while (token[0] != '}')
- {
- if ( token[0] == 0)
- { //EOF
- return qfalse;
- }
- assert(species.ColorCount < sizeof(species.ColorActionText)/sizeof(species.ColorActionText[0]) );
- Q_strcat(species.ColorActionText[species.ColorCount], sizeof(species.ColorActionText[0]), token);
- Q_strcat(species.ColorActionText[species.ColorCount], sizeof(species.ColorActionText[0]), " ");
- token = COM_ParseExt( &p, qtrue ); //looking for action commands or final }
- }
- species.ColorCount++; //next color please
- }
- return qtrue;//never get here
- }
- /*
- =================
- bIsImageFile
- builds path and scans for valid image extentions
- =================
- */
- static bool bIsImageFile(const char* dirptr, const char* skinname, qboolean building)
- {
- char fpath[MAX_QPATH];
- int f;
- #ifdef _XBOX
- Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.dds", dirptr, skinname);
- #else
- Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.jpg", dirptr, skinname);
- #endif
- ui.FS_FOpenFile(fpath, &f, FS_READ);
- #if !defined(_XBOX) || defined(_DEBUG)
- if (!f)
- { //not there, try png
- Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.png", dirptr, skinname);
- ui.FS_FOpenFile(fpath, &f, FS_READ);
- }
- if (!f)
- { //not there, try tga
- Com_sprintf(fpath, MAX_QPATH, "models/players/%s/icon_%s.tga", dirptr, skinname);
- ui.FS_FOpenFile(fpath, &f, FS_READ);
- }
- #endif
- if (f)
- {
- ui.FS_FCloseFile(f);
- if ( building ) ui.R_RegisterShaderNoMip(fpath);
- return true;
- }
- return false;
- }
- /*
- =================
- PlayerModel_BuildList
- =================
- */
- static void UI_BuildPlayerModel_List( qboolean inGameLoad )
- {
- int numdirs;
- char dirlist[2048];
- char* dirptr;
- int dirlen;
- int i;
- const int building = Cvar_VariableIntegerValue("com_buildscript");
- uiInfo.playerSpeciesCount = 0;
- uiInfo.playerSpeciesIndex = 0;
- memset(uiInfo.playerSpecies, 0, sizeof (uiInfo.playerSpecies) );
- // iterate directory of all player models
- numdirs = ui.FS_GetFileList("models/players", "/", dirlist, 2048 );
- dirptr = dirlist;
- for (i=0; i<numdirs; i++,dirptr+=dirlen+1)
- {
- char filelist[2048];
- char* fileptr;
- int filelen;
- int f = 0;
- char fpath[2048];
- dirlen = strlen(dirptr);
-
- if (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\0';
- if (!strcmp(dirptr,".") || !strcmp(dirptr,".."))
- continue;
-
- Com_sprintf(fpath, 2048, "models/players/%s/PlayerChoice.txt", dirptr);
- filelen = ui.FS_FOpenFile(fpath, &f, FS_READ);
- if (f)
- {
- char buffer[2048];
- ui.FS_Read(&buffer, filelen, f);
- ui.FS_FCloseFile(f);
- buffer[filelen] = 0; //ensure trailing NULL
-
- //record this species
- Q_strncpyz( uiInfo.playerSpecies[uiInfo.playerSpeciesCount].Name, dirptr, sizeof(uiInfo.playerSpecies[0].Name), qtrue );
- if (!UI_ParseColorData(buffer,uiInfo.playerSpecies[uiInfo.playerSpeciesCount]))
- {
- ui.Printf( "UI_BuildPlayerModel_List: Errors parsing '%s'\n", fpath );
- }
- int j;
- char skinname[64];
- int numfiles;
- int iSkinParts=0;
- numfiles = ui.FS_GetFileList( va("models/players/%s",dirptr), ".skin", filelist, 2048 );
- fileptr = filelist;
- for (j=0; j<numfiles; j++,fileptr+=filelen+1)
- {
- if ( building )
- {
- ui.FS_FOpenFile(va("models/players/%s/%s",dirptr,fileptr), &f, FS_READ);
- if (f) ui.FS_FCloseFile(f);
- ui.FS_FOpenFile(va("models/players/%s/sounds.cfg", dirptr), &f, FS_READ);
- if (f) ui.FS_FCloseFile(f);
- ui.FS_FOpenFile(va("models/players/%s/animevents.cfg", dirptr), &f, FS_READ);
- if (f) ui.FS_FCloseFile(f);
- }
- filelen = strlen(fileptr);
- COM_StripExtension(fileptr,skinname);
- if (bIsImageFile(dirptr, skinname, building))
- { //if it exists
- if (strnicmp(skinname,"head_",5) == 0)
- {
- if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadCount < MAX_PLAYERMODELS)
- {
- Q_strncpyz(uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadNames[uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadCount++], skinname, sizeof(uiInfo.playerSpecies[0].SkinHeadNames[0]), qtrue);
- iSkinParts |= 1<<0;
- }
- } else
- if (strnicmp(skinname,"torso_",6) == 0)
- {
- if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoCount < MAX_PLAYERMODELS)
- {
- Q_strncpyz(uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoNames[uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoCount++], skinname, sizeof(uiInfo.playerSpecies[0].SkinTorsoNames[0]), qtrue);
- iSkinParts |= 1<<1;
- }
- } else
- if (strnicmp(skinname,"lower_",6) == 0)
- {
- if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegCount < MAX_PLAYERMODELS)
- {
- Q_strncpyz(uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegNames[uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegCount++], skinname, sizeof(uiInfo.playerSpecies[0].SkinLegNames[0]), qtrue);
- iSkinParts |= 1<<2;
- }
- }
-
- }
- }
- if (iSkinParts != 7)
- { //didn't get a skin for each, then skip this model.
- memset(&uiInfo.playerSpecies[uiInfo.playerSpeciesCount], 0, sizeof(uiInfo.playerSpecies[uiInfo.playerSpeciesCount]));//undo the colors
- continue;
- }
- uiInfo.playerSpeciesCount++;
- if (!inGameLoad && ui_PrecacheModels.integer)
- {
- CGhoul2Info_v ghoul2;
- Com_sprintf( fpath, sizeof( fpath ), "models/players/%s/model.glm", dirptr );
- int g2Model = DC->g2_InitGhoul2Model(ghoul2, fpath, 0, 0, 0, 0, 0);
- if (g2Model >= 0)
- {
- DC->g2_RemoveGhoul2Model( ghoul2, 0 );
- }
- }
- if (uiInfo.playerSpeciesCount >= MAX_PLAYERMODELS)
- {
- return;
- }
- }
- }
- }
- /*
- =================
- UI_Init
- =================
- */
- void _UI_Init( qboolean inGameLoad )
- {
- uiInfo.inGameLoad = inGameLoad;
- UI_RegisterCvars();
- UI_InitMemory();
- // cache redundant calulations
- trap_GetGlconfig( &uiInfo.uiDC.glconfig );
- // for 640x480 virtualized screen
- uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0);
- uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0);
- if ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 )
- {
- // wide screen
- uiInfo.uiDC.bias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * (640.0/480.0) ) );
- }
- else
- {
- // no wide screen
- uiInfo.uiDC.bias = 0;
- }
- Init_Display(&uiInfo.uiDC);
- uiInfo.uiDC.drawText = &Text_Paint;
- uiInfo.uiDC.drawHandlePic = &UI_DrawHandlePic;
- uiInfo.uiDC.drawRect = &_UI_DrawRect;
- uiInfo.uiDC.drawSides = &_UI_DrawSides;
- uiInfo.uiDC.drawTextWithCursor = &Text_PaintWithCursor;
- uiInfo.uiDC.executeText = &Cbuf_ExecuteText;
- uiInfo.uiDC.drawTopBottom = &_UI_DrawTopBottom;
- uiInfo.uiDC.feederCount = &UI_FeederCount;
- uiInfo.uiDC.feederSelection = &UI_FeederSelection;
- uiInfo.uiDC.fillRect = &UI_FillRect;
- uiInfo.uiDC.getBindingBuf = &Key_GetBindingBuf;
- uiInfo.uiDC.getCVarString = Cvar_VariableStringBuffer;
- uiInfo.uiDC.getCVarValue = trap_Cvar_VariableValue;
- uiInfo.uiDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;
- uiInfo.uiDC.getValue = &UI_GetValue;
- uiInfo.uiDC.keynumToStringBuf = &Key_KeynumToStringBuf;
- uiInfo.uiDC.modelBounds = &trap_R_ModelBounds;
- uiInfo.uiDC.ownerDrawVisible = &UI_OwnerDrawVisible;
- uiInfo.uiDC.ownerDrawWidth = &UI_OwnerDrawWidth;
- uiInfo.uiDC.ownerDrawItem = &UI_OwnerDraw;
- uiInfo.uiDC.Print = &Com_Printf;
- uiInfo.uiDC.registerSound = &trap_S_RegisterSound;
- uiInfo.uiDC.registerModel = ui.R_RegisterModel;
- uiInfo.uiDC.clearScene = &trap_R_ClearScene;
- uiInfo.uiDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
- uiInfo.uiDC.renderScene = &trap_R_RenderScene;
- uiInfo.uiDC.runScript = &UI_RunMenuScript;
- uiInfo.uiDC.deferScript = &UI_DeferMenuScript;
- uiInfo.uiDC.setBinding = &trap_Key_SetBinding;
- uiInfo.uiDC.setColor = &UI_SetColor;
- uiInfo.uiDC.setCVar = Cvar_Set;
- uiInfo.uiDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;
- uiInfo.uiDC.startLocalSound = &trap_S_StartLocalSound;
- uiInfo.uiDC.stopCinematic = &UI_StopCinematic;
- uiInfo.uiDC.textHeight = &Text_Height;
- uiInfo.uiDC.textWidth = &Text_Width;
- uiInfo.uiDC.feederItemImage = &UI_FeederItemImage;
- uiInfo.uiDC.feederItemText = &UI_FeederItemText;
- #ifdef _IMMERSION
- uiInfo.uiDC.registerForce = &trap_FF_Register;
- uiInfo.uiDC.startForce = &trap_FF_Start;
- #endif // _IMMERSION
- uiInfo.uiDC.ownerDrawHandleKey = &UI_OwnerDrawHandleKey;
- uiInfo.uiDC.registerSkin = re.RegisterSkin;
- #ifndef _XBOX
- uiInfo.uiDC.g2_SetSkin = G2API_SetSkin;
- uiInfo.uiDC.g2_SetBoneAnim = G2API_SetBoneAnim;
- #endif
- uiInfo.uiDC.g2_RemoveGhoul2Model = G2API_RemoveGhoul2Model;
- uiInfo.uiDC.g2_InitGhoul2Model = G2API_InitGhoul2Model;
- uiInfo.uiDC.g2_CleanGhoul2Models = G2API_CleanGhoul2Models;
- uiInfo.uiDC.g2_AddBolt = G2API_AddBolt;
- uiInfo.uiDC.g2_GetBoltMatrix = G2API_GetBoltMatrix;
- uiInfo.uiDC.g2_GiveMeVectorFromMatrix = G2API_GiveMeVectorFromMatrix;
- uiInfo.uiDC.g2hilev_SetAnim = UI_G2SetAnim;
- UI_BuildPlayerModel_List(inGameLoad);
- String_Init();
- char *menuSet = UI_Cvar_VariableString("ui_menuFiles");
- if (menuSet == NULL || menuSet[0] == '\0')
- {
- menuSet = "ui/menus.txt";
- }
- if (inGameLoad)
- {
- UI_LoadMenus("ui/ingame.txt", qtrue);
- }
- else
- {
- UI_LoadMenus(menuSet, qtrue);
- }
- Menus_CloseAll();
- uiInfo.uiDC.whiteShader = ui.R_RegisterShaderNoMip( "white" );
- AssetCache();
- uis.debugMode = qfalse;
-
- // sets defaults for ui temp cvars
- uiInfo.effectsColor = (int)trap_Cvar_VariableValue("color")-1;
- if (uiInfo.effectsColor < 0)
- {
- uiInfo.effectsColor = 0;
- }
- uiInfo.effectsColor = gamecodetoui[uiInfo.effectsColor];
- uiInfo.currentCrosshair = (int)trap_Cvar_VariableValue("cg_drawCrosshair");
- Cvar_Set("cg_endcredits", "0"); // Reset value
- Cvar_Set("ui_missionfailed","0"); // reset
- uiInfo.forcePowerUpdated = FP_UPDATED_NONE;
- uiInfo.selectedWeapon1 = NOWEAPON;
- uiInfo.selectedWeapon2 = NOWEAPON;
- uiInfo.selectedThrowWeapon = NOWEAPON;
- uiInfo.uiDC.Assets.nullSound = trap_S_RegisterSound("sound/null", qfalse);
- trap_S_RegisterSound("sound/interface/weapon_deselect", qfalse);
- }
- /*
- =================
- UI_RegisterCvars
- =================
- */
- static void UI_RegisterCvars( void )
- {
- int i;
- cvarTable_t *cv;
- for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ )
- {
- Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
- }
- }
- #ifdef _XBOX
- //JLFCALLOUT MPNOTNEEDED->(INCLUDE WORKS)
- qboolean Menu_Parse(char *buffer, menuDef_t *menu);
- char * UI_ParseInclude(const char *menuFile, menuDef_t * menu)
- {
- char * buffer;
- int len;
- // pc_token_t token;
- //Com_DPrintf("Parsing menu file:%s\n", menuFile);
- len = PC_StartParseSession(menuFile,&buffer, true);
- if (len<=0)
- {
- Com_Printf("UI_ParseMenu: Unable to load menu %s\n", menuFile);
- return NULL;
- }
- // PC_EndParseSession(buffer);
- return buffer;
- }
- #endif
- /*
- =================
- UI_ParseMenu
- =================
- */
- void UI_ParseMenu(const char *menuFile)
- {
- char *buffer,*holdBuffer,*token2;
- int len;
- // pc_token_t token;
- //Com_DPrintf("Parsing menu file:%s\n", menuFile);
- len = PC_StartParseSession(menuFile,&buffer);
- holdBuffer = buffer;
- if (len<=0)
- {
- Com_Printf("UI_ParseMenu: Unable to load menu %s\n", menuFile);
- return;
- }
- while ( 1 )
- {
- token2 = PC_ParseExt();
- if (!*token2)
- {
- break;
- }
- /*
- if ( menuCount == MAX_MENUS )
- {
- PC_ParseWarning("Too many menus!");
- break;
- }
- */
- if ( *token2 == '{')
- {
- continue;
- }
- else if ( *token2 == '}' )
- {
- break;
- }
- else if (Q_stricmp(token2, "assetGlobalDef") == 0)
- {
- if (Asset_Parse(&holdBuffer))
- {
- continue;
- }
- else
- {
- break;
- }
- }
- else if (Q_stricmp(token2, "menudef") == 0)
- {
- // start a new menu
- Menu_New(holdBuffer);
- continue;
- }
- PC_ParseWarning(va("Invalid keyword '%s'",token2));
- }
- PC_EndParseSession(buffer);
-
- }
- /*
- =================
- Load_Menu
- Load current menu file
- =================
- */
- qboolean Load_Menu(const char **holdBuffer)
- {
- const char *token2;
- token2 = COM_ParseExt( holdBuffer, qtrue );
- if (!token2[0])
- {
- return qfalse;
- }
- if (*token2 != '{')
- {
- return qfalse;
- }
- while ( 1 )
- {
- token2 = COM_ParseExt( holdBuffer, qtrue );
- if ((!token2) || (token2 == 0))
- {
- return qfalse;
- }
-
- if ( *token2 == '}' )
- {
- return qtrue;
- }
- //#ifdef _DEBUG
- // extern void UI_Debug_AddMenuFilePath(const char *);
- // UI_Debug_AddMenuFilePath(token2);
- //#endif
- UI_ParseMenu(token2);
- }
- return qfalse;
- }
- /*
- =================
- UI_LoadMenus
- Load all menus based on the files listed in the data file in menuFile (default "ui/menus.txt")
- =================
- */
- void UI_LoadMenus(const char *menuFile, qboolean reset)
- {
- // pc_token_t token;
- // int handle;
- int start;
- char *buffer;
- const char *holdBuffer;
- int len;
- start = Sys_Milliseconds();
- len = ui.FS_ReadFile(menuFile,(void **) &buffer);
- if (len<1)
- {
- Com_Printf( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) );
- len = ui.FS_ReadFile("ui/menus.txt",(void **) &buffer);
- if (len<1)
- {
- Com_Error( ERR_FATAL, "%s", va("default menu file not found: ui/menus.txt, unable to continue!\n", menuFile ));
- return;
- }
- }
- if (reset)
- {
- Menu_Reset();
- }
- const char *token2;
- holdBuffer = buffer;
- while ( 1 )
- {
- token2 = COM_ParseExt( &holdBuffer, qtrue );
- if (!*token2)
- {
- break;
- }
- if( *token2 == 0 || *token2 == '}') // End of the menus file
- {
- break;
- }
- if (*token2 == '{')
- {
- continue;
- }
- else if (Q_stricmp(token2, "loadmenu") == 0)
- {
- if (Load_Menu(&holdBuffer))
- {
- continue;
- }
- else
- {
- break;
- }
- }
- else
- {
- Com_Printf("Unknown keyword '%s' in menus file %s\n", token2, menuFile);
- }
- }
- //Com_Printf("UI menu load time = %d milli seconds\n", Sys_Milliseconds() - start);
- ui.FS_FreeFile( buffer ); //let go of the buffer
- }
- /*
- =================
- UI_Load
- =================
- */
- void UI_Load(void)
- {
- char *menuSet;
- char lastName[1024];
- menuDef_t *menu = Menu_GetFocused();
- if (menu && menu->window.name)
- {
- strcpy(lastName, menu->window.name);
- }
- else
- {
- lastName[0] = 0;
- }
- if (uiInfo.inGameLoad)
- {
- menuSet= "ui/ingame.txt";
- }
- else
- {
- menuSet= UI_Cvar_VariableString("ui_menuFiles");
- }
- if (menuSet == NULL || menuSet[0] == '\0')
- {
- menuSet = "ui/menus.txt";
- }
- String_Init();
- UI_LoadMenus(menuSet, qtrue);
- Menus_CloseAll();
- Menus_ActivateByName(lastName);
- }
- /*
- =================
- Asset_Parse
- =================
- */
- qboolean Asset_Parse(char **buffer)
- {
- char *token;
- const char *tempStr;
- int pointSize;
- token = PC_ParseExt();
- if (!token)
- {
- return qfalse;
- }
- if (*token != '{')
- {
- return qfalse;
- }
-
- while ( 1 )
- {
- token = PC_ParseExt();
- if (!token)
- {
- return qfalse;
- }
- if (*token == '}')
- {
- return qtrue;
- }
- // fonts
- if (Q_stricmp(token, "smallFont") == 0) //legacy, really it only matters which order they are registered
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'smallFont'");
- return qfalse;
- }
- UI_RegisterFont(tempStr);
- //not used anymore
- if (PC_ParseInt(&pointSize))
- {
- // PC_ParseWarning("Bad 2nd parameter for keyword 'smallFont'");
- }
- continue;
- }
- if (Q_stricmp(token, "mediumFont") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'font'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.qhMediumFont = UI_RegisterFont(tempStr);
- uiInfo.uiDC.Assets.fontRegistered = qtrue;
- //not used
- if (PC_ParseInt(&pointSize))
- {
- // PC_ParseWarning("Bad 2nd parameter for keyword 'font'");
- }
- continue;
- }
- if (Q_stricmp(token, "bigFont") == 0) //legacy
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'bigFont'");
- return qfalse;
- }
- UI_RegisterFont(tempStr);
- if (PC_ParseInt(&pointSize))
- {
- // PC_ParseWarning("Bad 2nd parameter for keyword 'bigFont'");
- }
- continue;
- }
- // gradientbar
- if (Q_stricmp(token, "gradientbar") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'gradientbar'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.gradientBar = ui.R_RegisterShaderNoMip(tempStr);
- continue;
- }
- // enterMenuSound
- if (Q_stricmp(token, "menuEnterSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'menuEnterSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- // exitMenuSound
- if (Q_stricmp(token, "menuExitSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'menuExitSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- // itemFocusSound
- if (Q_stricmp(token, "itemFocusSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'itemFocusSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- // menuBuzzSound
- if (Q_stricmp(token, "menuBuzzSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'menuBuzzSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- // Chose a force power from the ingame force allocation screen (the one where you get to allocate a force power point)
- if (Q_stricmp(token, "forceChosenSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'forceChosenSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.forceChosenSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- // Unchose a force power from the ingame force allocation screen (the one where you get to allocate a force power point)
- if (Q_stricmp(token, "forceUnchosenSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'forceUnchosenSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.forceUnchosenSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveRollSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveRollSound'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveRollSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveJumpSound") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveRoll'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveJumpSound = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveSaberSound1") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound1'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveSaberSound1 = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveSaberSound2") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound2'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveSaberSound2 = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveSaberSound3") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound3'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveSaberSound3 = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveSaberSound4") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound4'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveSaberSound4 = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveSaberSound5") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound5'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveSaberSound5 = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- if (Q_stricmp(token, "datapadmoveSaberSound6") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'datapadmoveSaberSound6'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.datapadmoveSaberSound6 = trap_S_RegisterSound( tempStr, qfalse );
- continue;
- }
- #ifdef _IMMERSION
- if (Q_stricmp(token, "menuEnterForce") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'menuEnterForce'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuEnterForce = trap_FF_Register( tempStr );
- continue;
- }
- if (Q_stricmp(token, "menuExitForce") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'menuExitForce'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuExitForce = trap_FF_Register( tempStr );
- continue;
- }
- if (Q_stricmp(token, "itemFocusForce") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'itemFocusForce'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.itemFocusForce = trap_FF_Register( tempStr );
- continue;
- }
- if (Q_stricmp(token, "menuBuzzForce") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'menuBuzzForce'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuBuzzForce = trap_FF_Register( tempStr );
- continue;
- }
- #endif // _IMMERSION
- if (Q_stricmp(token, "cursor") == 0)
- {
- if (PC_ParseString(&tempStr))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'cursor'");
- return qfalse;
- }
- // uiInfo.uiDC.Assets.cursor = ui.R_RegisterShaderNoMip( tempStr);
- continue;
- }
- if (Q_stricmp(token, "fadeClamp") == 0)
- {
- if (PC_ParseFloat(&uiInfo.uiDC.Assets.fadeClamp))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'fadeClamp'");
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token, "fadeCycle") == 0)
- {
- if (PC_ParseInt(&uiInfo.uiDC.Assets.fadeCycle))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'fadeCycle'");
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token, "fadeAmount") == 0)
- {
- if (PC_ParseFloat(&uiInfo.uiDC.Assets.fadeAmount))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'fadeAmount'");
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token, "shadowX") == 0)
- {
- if (PC_ParseFloat(&uiInfo.uiDC.Assets.shadowX))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'shadowX'");
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token, "shadowY") == 0)
- {
- if (PC_ParseFloat(&uiInfo.uiDC.Assets.shadowY))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'shadowY'");
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token, "shadowColor") == 0)
- {
- if (PC_ParseColor(&uiInfo.uiDC.Assets.shadowColor))
- {
- PC_ParseWarning("Bad 1st parameter for keyword 'shadowColor'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.shadowFadeClamp = uiInfo.uiDC.Assets.shadowColor[3];
- continue;
- }
- // precaching various sound files used in the menus
- if (Q_stricmp(token, "precacheSound") == 0)
- {
- if (PC_Script_Parse(&tempStr))
- {
- char *soundFile;
- do
- {
- soundFile = COM_ParseExt(&tempStr, qfalse);
- if (soundFile[0] != 0 && soundFile[0] != ';') {
- if (!trap_S_RegisterSound( soundFile, qfalse ))
- {
- PC_ParseWarning("Can't locate precache sound");
- }
- }
- } while (soundFile[0]);
- }
- continue;
- }
- }
- PC_ParseWarning(va("Invalid keyword '%s'",token));
- return qfalse;
- }
- /*
- =================
- UI_Update
- =================
- */
- static void UI_Update(const char *name)
- {
- int val = trap_Cvar_VariableValue(name);
- if (Q_stricmp(name, "s_khz") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "snd_restart\n" );
- return;
- }
- #ifdef _IMMERSION
- if (Q_stricmp(name, "ff") == 0)
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "ff_restart\n");
- return;
- }
- #endif // _IMMERSION
- if (Q_stricmp(name, "ui_SetName") == 0)
- {
- Cvar_Set( "name", UI_Cvar_VariableString("ui_Name"));
- }
- else if (Q_stricmp(name, "ui_setRate") == 0)
- {
- float rate = trap_Cvar_VariableValue("rate");
- if (rate >= 5000)
- {
- Cvar_Set("cl_maxpackets", "30");
- Cvar_Set("cl_packetdup", "1");
- }
- else if (rate >= 4000)
- {
- Cvar_Set("cl_maxpackets", "15");
- Cvar_Set("cl_packetdup", "2"); // favor less prediction errors when there's packet loss
- }
- else
- {
- Cvar_Set("cl_maxpackets", "15");
- Cvar_Set("cl_packetdup", "1"); // favor lower bandwidth
- }
- }
- else if (Q_stricmp(name, "ui_GetName") == 0)
- {
- Cvar_Set( "ui_Name", UI_Cvar_VariableString("name"));
- }
- else if (Q_stricmp(name, "ui_r_colorbits") == 0)
- {
- switch (val)
- {
- case 0:
- Cvar_SetValue( "ui_r_depthbits", 0 );
- break;
- case 16:
- Cvar_SetValue( "ui_r_depthbits", 16 );
- break;
- case 32:
- Cvar_SetValue( "ui_r_depthbits", 24 );
- break;
- }
- }
- else if (Q_stricmp(name, "ui_r_lodbias") == 0)
- {
- switch (val)
- {
- case 0:
- Cvar_SetValue( "ui_r_subdivisions", 4 );
- break;
- case 1:
- Cvar_SetValue( "ui_r_subdivisions", 12 );
- break;
- case 2:
- Cvar_SetValue( "ui_r_subdivisions", 20 );
- break;
- }
- }
- else if (Q_stricmp(name, "ui_r_glCustom") == 0)
- {
- switch (val)
- {
- case 0: // high quality
- Cvar_SetValue( "ui_r_fullScreen", 1 );
- Cvar_SetValue( "ui_r_subdivisions", 4 );
- Cvar_SetValue( "ui_r_lodbias", 0 );
- Cvar_SetValue( "ui_r_colorbits", 32 );
- Cvar_SetValue( "ui_r_depthbits", 24 );
- Cvar_SetValue( "ui_r_picmip", 0 );
- Cvar_SetValue( "ui_r_mode", 4 );
- Cvar_SetValue( "ui_r_texturebits", 32 );
- Cvar_SetValue( "ui_r_fastSky", 0 );
- Cvar_SetValue( "ui_r_inGameVideo", 1 );
- //Cvar_SetValue( "ui_cg_shadows", 2 );//stencil
- Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
- break;
- case 1: // normal
- Cvar_SetValue( "ui_r_fullScreen", 1 );
- Cvar_SetValue( "ui_r_subdivisions", 4 );
- Cvar_SetValue( "ui_r_lodbias", 0 );
- Cvar_SetValue( "ui_r_colorbits", 0 );
- Cvar_SetValue( "ui_r_depthbits", 24 );
- Cvar_SetValue( "ui_r_picmip", 1 );
- Cvar_SetValue( "ui_r_mode", 3 );
- Cvar_SetValue( "ui_r_texturebits", 0 );
- Cvar_SetValue( "ui_r_fastSky", 0 );
- Cvar_SetValue( "ui_r_inGameVideo", 1 );
- //Cvar_SetValue( "ui_cg_shadows", 2 );
- Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
- break;
- case 2: // fast
- Cvar_SetValue( "ui_r_fullScreen", 1 );
- Cvar_SetValue( "ui_r_subdivisions", 12 );
- Cvar_SetValue( "ui_r_lodbias", 1 );
- Cvar_SetValue( "ui_r_colorbits", 0 );
- Cvar_SetValue( "ui_r_depthbits", 0 );
- Cvar_SetValue( "ui_r_picmip", 2 );
- Cvar_SetValue( "ui_r_mode", 3 );
- Cvar_SetValue( "ui_r_texturebits", 0 );
- Cvar_SetValue( "ui_r_fastSky", 1 );
- Cvar_SetValue( "ui_r_inGameVideo", 0 );
- //Cvar_SetValue( "ui_cg_shadows", 1 );
- Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_NEAREST" );
- break;
- case 3: // fastest
- Cvar_SetValue( "ui_r_fullScreen", 1 );
- Cvar_SetValue( "ui_r_subdivisions", 20 );
- Cvar_SetValue( "ui_r_lodbias", 2 );
- Cvar_SetValue( "ui_r_colorbits", 16 );
- Cvar_SetValue( "ui_r_depthbits", 16 );
- Cvar_SetValue( "ui_r_mode", 3 );
- Cvar_SetValue( "ui_r_picmip", 3 );
- Cvar_SetValue( "ui_r_texturebits", 16 );
- Cvar_SetValue( "ui_r_fastSky", 1 );
- Cvar_SetValue( "ui_r_inGameVideo", 0 );
- //Cvar_SetValue( "ui_cg_shadows", 0 );
- Cvar_Set( "ui_r_texturemode", "GL_LINEAR_MIPMAP_NEAREST" );
- break;
- }
- }
- else
- {//failure!!
- Com_Printf("unknown UI script UPDATE %s\n", name);
- }
- }
- #define ASSET_SCROLLBAR "gfx/menus/scrollbar.tga"
- #define ASSET_SCROLLBAR_ARROWDOWN "gfx/menus/scrollbar_arrow_dwn_a.tga"
- #define ASSET_SCROLLBAR_ARROWUP "gfx/menus/scrollbar_arrow_up_a.tga"
- #define ASSET_SCROLLBAR_ARROWLEFT "gfx/menus/scrollbar_arrow_left.tga"
- #define ASSET_SCROLLBAR_ARROWRIGHT "gfx/menus/scrollbar_arrow_right.tga"
- #define ASSET_SCROLL_THUMB "gfx/menus/scrollbar_thumb.tga"
- /*
- =================
- AssetCache
- =================
- */
- void AssetCache(void)
- {
- // int n;
- uiInfo.uiDC.Assets.scrollBar = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR );
- uiInfo.uiDC.Assets.scrollBarArrowDown = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
- uiInfo.uiDC.Assets.scrollBarArrowUp = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
- uiInfo.uiDC.Assets.scrollBarArrowLeft = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
- uiInfo.uiDC.Assets.scrollBarArrowRight = ui.R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );
- uiInfo.uiDC.Assets.scrollBarThumb = ui.R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
- uiInfo.uiDC.Assets.sliderBar = ui.R_RegisterShaderNoMip( "gfx/menus/newFront/slider" );
- // uiInfo.uiDC.Assets.sliderThumb = ui.R_RegisterShaderNoMip( "menu/new/sliderthumb");
-
- /*
- for( n = 0; n < NUM_CROSSHAIRS; n++ )
- {
- uiInfo.uiDC.Assets.crosshairShader[n] = ui.R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) );
- }
- */
- }
- /*
- ================
- _UI_DrawSides
- =================
- */
- void _UI_DrawSides(float x, float y, float w, float h, float size)
- {
- size *= uiInfo.uiDC.xscale;
- trap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- trap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- }
- /*
- ================
- _UI_DrawTopBottom
- =================
- */
- void _UI_DrawTopBottom(float x, float y, float w, float h, float size)
- {
- size *= uiInfo.uiDC.yscale;
- trap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- trap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- }
- /*
- ================
- UI_DrawRect
- Coordinates are 640*480 virtual values
- =================
- */
- void _UI_DrawRect( float x, float y, float width, float height, float size, const float *color )
- {
- trap_R_SetColor( color );
- _UI_DrawTopBottom(x, y, width, height, size);
- _UI_DrawSides(x, y, width, height, size);
- trap_R_SetColor( NULL );
- }
- /*
- =================
- UI_UpdateCvars
- =================
- */
- void UI_UpdateCvars( void )
- {
- int i;
- cvarTable_t *cv;
- for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ )
- {
- Cvar_Update( cv->vmCvar );
- }
- }
- /*
- =================
- UI_DrawEffects
- =================
- */
- static void UI_DrawEffects(rectDef_t *rect, float scale, vec4_t color)
- {
- UI_DrawHandlePic( rect->x, rect->y - 14, 128, 8, 0/*uiInfo.uiDC.Assets.fxBasePic*/ );
- UI_DrawHandlePic( rect->x + uiInfo.effectsColor * 16 + 8, rect->y - 16, 16, 12, 0/*uiInfo.uiDC.Assets.fxPic[uiInfo.effectsColor]*/ );
- }
- /*
- =================
- UI_Version
- =================
- */
- static void UI_Version(rectDef_t *rect, float scale, vec4_t color, int iFontIndex)
- {
- int width;
-
- width = DC->textWidth(Q3_VERSION, scale, 0);
- DC->drawText(rect->x - width, rect->y, scale, color, Q3_VERSION, 0, ITEM_TEXTSTYLE_SHADOWED, iFontIndex);
- }
- /*
- =================
- UI_DrawKeyBindStatus
- =================
- */
- static void UI_DrawKeyBindStatus(rectDef_t *rect, float scale, vec4_t color, int textStyle, int iFontIndex)
- {
- if (Display_KeyBindPending())
- {
- Text_Paint(rect->x, rect->y, scale, color, SE_GetString("MENUS_WAITINGFORKEY"), 0, textStyle, iFontIndex);
- }
- else
- {
- // Text_Paint(rect->x, rect->y, scale, color, ui.SP_GetStringTextString("MENUS_ENTERTOCHANGE"), 0, textStyle, iFontIndex);
- }
- }
- /*
- =================
- UI_DrawKeyBindStatus
- =================
- */
- static void UI_DrawGLInfo(rectDef_t *rect, float scale, vec4_t color, int textStyle, int iFontIndex)
- {
- #define MAX_LINES 64
- char buff[4096];
- char * eptr = buff;
- const char *lines[MAX_LINES];
- int y, numLines=0, i=0;
- y = rect->y;
- Text_Paint(rect->x, y, scale, color, va("GL_VENDOR: %s",uiInfo.uiDC.glconfig.vendor_string), rect->w, textStyle, iFontIndex);
- y += 15;
- 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);
- y += 15;
- Text_Paint(rect->x, y, scale, color, "GL_PIXELFORMAT:", rect->w, textStyle, iFontIndex);
- y += 15;
- 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);
- y += 15;
- // build null terminated extension strings
- Q_strncpyz(buff, uiInfo.uiDC.glconfig.extensions_string, sizeof(buff));
- int testy=y-16;
- while ( testy <= rect->y + rect->h && *eptr && (numLines < MAX_LINES) )
- {
- while ( *eptr && *eptr == ' ' )
- *eptr++ = '\0';
- // track start of valid string
- if (*eptr && *eptr != ' ')
- {
- lines[numLines++] = eptr;
- testy+=16;
- }
- while ( *eptr && *eptr != ' ' )
- eptr++;
- }
- numLines--;
- while (i < numLines)
- {
- Text_Paint(rect->x, y, scale, color, lines[i++], rect->w, textStyle, iFontIndex);
- y += 16;
- }
- }
- /*
- =================
- UI_DataPad_Inventory
- =================
- */
- /*
- static void UI_DataPad_Inventory(rectDef_t *rect, float scale, vec4_t color, int iFontIndex)
- {
- Text_Paint(rect->x, rect->y, scale, color, "INVENTORY", 0, 1, iFontIndex);
- }
- */
- /*
- =================
- UI_DataPad_ForcePowers
- =================
- */
- /*
- static void UI_DataPad_ForcePowers(rectDef_t *rect, float scale, vec4_t color, int iFontIndex)
- {
- Text_Paint(rect->x, rect->y, scale, color, "FORCE POWERS", 0, 1, iFontIndex);
- }
- */
- static void UI_DrawCrosshair(rectDef_t *rect, float scale, vec4_t color) {
- trap_R_SetColor( color );
- if (uiInfo.currentCrosshair < 0 || uiInfo.currentCrosshair >= NUM_CROSSHAIRS) {
- uiInfo.currentCrosshair = 0;
- }
- UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.uiDC.Assets.crosshairShader[uiInfo.currentCrosshair]);
- trap_R_SetColor( NULL );
- }
- /*
- =================
- UI_SoftKeyboard
- =================
- */
- static void UI_SoftKeyboardInit()
- {
- char strtmp[] = "";
- DC->setCVar("keyboardinput", strtmp);
- skb.activeKey=0;
- skb.curCol=0;
- skb.curRow=0;
- skb.curStringPos=0;
- }
- static void UI_SoftKeyboardDelete()
- {
- char strtmp[SKB_STRING_LENGTH+1];
- DC->getCVarString("keyboardinput", strtmp, SKB_STRING_LENGTH+1);
- if(skb.curStringPos > 0)
- {
- skb.curStringPos--;
- strtmp[skb.curStringPos] = 0;
- }
- DC->setCVar("keyboardinput", strtmp);
- }
- static void UI_SoftKeyboardAccept()
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
- if (menu->onAccept)
- {
- Item_RunScript(item, menu->onAccept);
- }
- }
- static qboolean UI_SoftKeyboardDelete_HandleKey(int flags, float *special, int key)
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item;
- switch(key)
- {
- case A_CURSOR_UP:
- skb.curRow = SKB_NUM_ROWS - 1;
- if((skb.curRow * SKB_NUM_COLS + skb.curCol) >= SKB_NUM_LETTERS)
- skb.curRow--;
- item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_DOWN:
- skb.curRow = 0;
- item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_LEFT:
- skb.curCol = SKB_NUM_COLS/2;
- item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_RIGHT:
- skb.curCol = SKB_NUM_COLS/2;
- item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_MOUSE1:
- UI_SoftKeyboardDelete();
- break;
- default:
- break;
- }
- skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
- return qtrue;
- }
- static qboolean UI_SoftKeyboardAccept_HandleKey(int flags, float *special, int key)
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item;
- switch(key)
- {
- case A_CURSOR_UP:
- skb.curRow = SKB_NUM_ROWS - 1;
- if((skb.curRow * SKB_NUM_COLS + skb.curCol) >= SKB_NUM_LETTERS)
- skb.curRow--;
- item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_DOWN:
- skb.curRow = 0;
- item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_LEFT:
- skb.curCol = SKB_NUM_COLS/2-1;
- item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_RIGHT:
- skb.curCol = SKB_NUM_COLS/2-1;
- item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_MOUSE1:
- UI_SoftKeyboardAccept();
- break;
- default:
- break;
- }
- skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
- return qtrue;
- }
- static qboolean UI_SoftKeyboard_HandleKey(int flags, float *special, int key)
- {
- char strtmp[SKB_STRING_LENGTH+1];
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item;
- // If the user pressed A (mouse 1), just add a letter to our string and return
- if(key == A_MOUSE1)
- {
- DC->getCVarString("keyboardinput", strtmp, SKB_STRING_LENGTH+1);
- if(skb.curStringPos < SKB_STRING_LENGTH)
- {
- strtmp[skb.curStringPos] = letters[skb.activeKey][0];
- skb.curStringPos++;
- }
- DC->setCVar("keyboardinput", strtmp);
- return qtrue;
- }
- // Assuming the user pressed the D-pad, adjust the current row and column,
- // and the associated active key position.
- switch(key)
- {
- case A_CURSOR_UP:
- skb.curRow-=1;
- break;
- case A_CURSOR_DOWN:
- skb.curRow+=1;
- break;
- case A_CURSOR_LEFT:
- skb.curCol-=1;
- break;
- case A_CURSOR_RIGHT:
- skb.curCol+=1;
- break;
- default:
- // We didn't handle this keypress.
- return qfalse;
- break;
- }
- skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
- // Now make sure that the new active key is actually on the keyboard
- // This means that the row and columns must be within bounds, and we
- // must be on a letter (not on an empty space)
- if(skb.activeKey < 0 || skb.activeKey >=SKB_NUM_LETTERS || skb.curCol >= SKB_NUM_COLS || skb.curCol < 0)
- {
- switch(key)
- {
- case A_CURSOR_UP:
- // Wrap to bottom of KB
- skb.curRow = SKB_NUM_ROWS - 1;
- if(skb.curCol < SKB_NUM_COLS/2)
- item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
- else
- item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_DOWN:
- // Move to the next item below this
- skb.curRow--;
- if(skb.curCol < SKB_NUM_COLS/2)
- item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
- else
- item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
- Item_SetFocus(item, 0, 0);
- break;
- case A_CURSOR_LEFT:
- // Wrap to the right side of the KB
- if(skb.curRow == SKB_NUM_ROWS-1)
- skb.curCol = SKB_NUM_LETTERS % SKB_NUM_COLS - 1;
- else
- skb.curCol = SKB_NUM_COLS - 1;
- break;
- case A_CURSOR_RIGHT:
- // Wrap to the left side of the KB
- skb.curCol=0;
- break;
- default:
- break;
- }
- skb.activeKey = skb.curRow * SKB_NUM_COLS + skb.curCol;
- }
- return qtrue;
- }
- vec4_t color_unfocus = {0.7f, 0.7f, 0.8f, 1.0f};
- vec4_t color_focus = {0.78f, 0.471f, 0.161f, 1.0f};
- static void UI_SoftKeyboardAccept_Draw()
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item = Menu_FindItemByName(menu, SKB_ACCEPT_NAME);
- int x = SKB_OK_X;
- int y = SKB_OK_Y;
- x -= DC->textWidth("OK", 1.0f, 2) / 2;
- y -= DC->textHeight("OK", 1.0f, 2) / 2;
- if(item->window.flags & WINDOW_HASFOCUS)
- DC->drawText(x, y, 1.0f, color_focus, "OK", 1000, 0, 2);
- else
- DC->drawText(x, y, 1.0f, color_unfocus, "OK", 1000, 0, 2);
- }
- static void UI_SoftKeyboardDelete_Draw()
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item = Menu_FindItemByName(menu, SKB_DELETE_NAME);
- int x = SKB_BACKSPACE_X;
- int y = SKB_BACKSPACE_Y;
- x -= DC->textWidth("Backspace", 1.0f, 2) / 2;
- y -= DC->textHeight("Backspace", 1.0f, 2) / 2;
- if(item->window.flags & WINDOW_HASFOCUS)
- DC->drawText(x, y, 1.0f, color_focus, "Backspace", 1000, 0, 2);
- else
- DC->drawText(x, y, 1.0f, color_unfocus, "Backspace", 1000, 0, 2);
- }
- static void UI_SoftKeyboard_Draw()
- {
- menuDef_t *menu = Menu_GetFocused();
- itemDef_t *item = Menu_FindItemByName(menu, SKB_KEYBOARD_NAME);
- //draw each letter on the screen at the appropriate coordinates
- int x,y;
- float size;
- vec4_t *color;
- for(int cl=0; cl<SKB_NUM_LETTERS; cl++)
- {
- if(skb.activeKey == cl && (item->window.flags & WINDOW_HASFOCUS))
- {
- color = &color_focus;
- size = 3.0f;
- }
- else
- {
- color = &color_unfocus;
- size = 1.0f;
- }
- x = (cl%SKB_NUM_COLS) * SKB_SPACE_H + SKB_LEFT;
- x -= (DC->textWidth(letters[cl], size, 2)) / 2;
- y = (cl/SKB_NUM_COLS) * SKB_SPACE_V + SKB_TOP;
- y -= ((DC->textHeight(letters[cl], size, 2)) / 2) * 1.5;
- DC->drawText(x, y, size, *color, letters[cl], 1000, 0, 2);
- }
- char *strtmp = new char[SKB_STRING_LENGTH];
- DC->getCVarString("keyboardinput", strtmp, SKB_STRING_LENGTH+1);
- DC->drawText(SKB_STRING_LEFT, SKB_STRING_TOP, 1.5f, color_unfocus, strtmp, 1000, 0, 2);
- }
- /*
- =================
- UI_OwnerDraw
- =================
- */
- 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)
- {
- rectDef_t rect;
- rect.x = x + text_x;
- rect.y = y + text_y;
- rect.w = w;
- rect.h = h;
- switch (ownerDraw)
- {
- case UI_SOFT_KEYBOARD:
- UI_SoftKeyboard_Draw();
- break;
- case UI_SOFT_KEYBOARD_ACCEPT:
- UI_SoftKeyboardAccept_Draw();
- break;
- case UI_SOFT_KEYBOARD_DELETE:
- UI_SoftKeyboardDelete_Draw();
- break;
- case UI_EFFECTS:
- UI_DrawEffects(&rect, scale, color);
- break;
- case UI_VERSION:
- UI_Version(&rect, scale, color, iFontIndex);
- break;
- case UI_DATAPAD_MISSION:
- ui.Draw_DataPad(DP_OBJECTIVES);
- break;
- case UI_DATAPAD_WEAPONS:
- ui.Draw_DataPad(DP_WEAPONS);
- break;
- /*
- case UI_DATAPAD_INVENTORY:
- ui.Draw_DataPad(DP_HUD);
- ui.Draw_DataPad(DP_INVENTORY);
- break;
- */
- case UI_DATAPAD_FORCEPOWERS:
- ui.Draw_DataPad(DP_FORCEPOWERS);
- break;
- case UI_ALLMAPS_SELECTION://saved game thumbnail
- //JLF MAPIMAGE MPNOTUSED
- #ifdef _XBOX
- //create a shader
- UI_DrawHandlePic(x, y, w, h, shader);
-
- #else
- int levelshot;
- levelshot = ui.R_RegisterShaderNoMip( va( "levelshots/%s", s_savedata[s_savegame.currentLine].currentSaveFileMap ) );
- if (levelshot)
- {
- ui.R_DrawStretchPic( x, y, w, h, 0, 0, 1, 1, levelshot );
- }
- else
- {
- UI_DrawHandlePic(x, y, w, h, uis.menuBackShader);
- }
- #endif
- /*
- ui.R_Font_DrawString( x, // int ox
- y+h, // int oy
- s_savedata[s_savegame.currentLine].currentSaveFileMap, // const char *text
- color, // paletteRGBA_c c
- iFontIndex, // const int iFontHandle
- w,//-1, // iMaxPixelWidth (-1 = none)
- scale // const float scale = 1.0f
- );
- */
- break;
- case UI_PREVIEWCINEMATIC:
- // FIXME BOB - make this work?
- // UI_DrawPreviewCinematic(&rect, scale, color);
- break;
- case UI_CROSSHAIR:
- UI_DrawCrosshair(&rect, scale, color);
- break;
- case UI_GLINFO:
- UI_DrawGLInfo(&rect,scale, color, textStyle, iFontIndex);
- break;
- case UI_KEYBINDSTATUS:
- UI_DrawKeyBindStatus(&rect,scale, color, textStyle, iFontIndex);
- break;
- default:
- break;
- }
- }
- /*
- =================
- UI_OwnerDrawVisible
- =================
- */
- static qboolean UI_OwnerDrawVisible(int flags)
- {
- qboolean vis = qtrue;
- while (flags)
- {
- /* if (flags & UI_SHOW_DEMOAVAILABLE)
- {
- if (!uiInfo.demoAvailable)
- {
- vis = qfalse;
- }
- flags &= ~UI_SHOW_DEMOAVAILABLE;
- }
- else
- */ {
- flags = 0;
- }
- }
- return vis;
- }
- /*
- =================
- Text_Width
- =================
- */
- int Text_Width(const char *text, float scale, int iFontIndex)
- {
- // temp code until Bob retro-fits all menus to have font specifiers...
- //
- if ( iFontIndex == 0 )
- {
- iFontIndex = uiInfo.uiDC.Assets.qhMediumFont;
- }
- return ui.R_Font_StrLenPixels(text, iFontIndex, scale);
- }
- /*
- =================
- UI_OwnerDrawWidth
- =================
- */
- int UI_OwnerDrawWidth(int ownerDraw, float scale)
- {
- // int i, h, value;
- // const char *text;
- const char *s = NULL;
- switch (ownerDraw)
- {
- case UI_KEYBINDSTATUS:
- if (Display_KeyBindPending())
- {
- s = SE_GetString("MENUS_WAITINGFORKEY");
- }
- else
- {
- // s = ui.SP_GetStringTextString("MENUS_ENTERTOCHANGE");
- }
- break;
-
- // FIXME BOB
- // case UI_SERVERREFRESHDATE:
- // s = UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer));
- // break;
- default:
- break;
- }
- if (s)
- {
- return Text_Width(s, scale, 0);
- }
- return 0;
- }
- /*
- =================
- Text_Height
- =================
- */
- int Text_Height(const char *text, float scale, int iFontIndex)
- {
- // temp until Bob retro-fits all menu files with font specifiers...
- //
- if ( iFontIndex == 0 )
- {
- iFontIndex = uiInfo.uiDC.Assets.qhMediumFont;
- }
- return ui.R_Font_HeightPixels(iFontIndex, scale);
- }
- /*
- =================
- UI_MouseEvent
- =================
- */
- //JLFMOUSE CALLED EACH FRAME IN UI
- void _UI_MouseEvent( int dx, int dy )
- {
- // update mouse screen position
- uiInfo.uiDC.cursorx += dx;
- if (uiInfo.uiDC.cursorx < 0)
- {
- uiInfo.uiDC.cursorx = 0;
- }
- else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH)
- {
- uiInfo.uiDC.cursorx = SCREEN_WIDTH;
- }
- uiInfo.uiDC.cursory += dy;
- if (uiInfo.uiDC.cursory < 0)
- {
- uiInfo.uiDC.cursory = 0;
- }
- else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT)
- {
- uiInfo.uiDC.cursory = SCREEN_HEIGHT;
- }
- if ( dy > SCROLL_SENSITIVITY || dy < -SCROLL_SENSITIVITY)
- gScrollAccum += dy;
- gScrollDelta =0;
- if (gScrollAccum > TEXTSCROLLDESCRETESTEP)
- {
- gScrollDelta =1;
- gScrollAccum =0;
- }
- else if (gScrollAccum <0)
- {
- gScrollDelta = -1;
- gScrollAccum = TEXTSCROLLDESCRETESTEP;
- }
-
- if (Menu_Count() > 0)
- {
- //menuDef_t *menu = Menu_GetFocused();
- //Menu_HandleMouseMove(menu, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);
- Display_MouseMove(NULL, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);
- }
- }
- /*
- =================
- UI_KeyEvent
- =================
- */
- void _UI_KeyEvent( int key, qboolean down )
- {
- /* extern qboolean SwallowBadNumLockedKPKey( int iKey );
- if (SwallowBadNumLockedKPKey(key)){
- return;
- }
- */
- if (Menu_Count() > 0)
- {
- menuDef_t *menu = Menu_GetFocused();
- if (menu)
- {
- //DemoEnd();
- //JLF MPMOVED
- #ifdef _XBOX
- // extern void G_DemoKeypress();//JLF new
- // G_DemoKeypress(); //JLF new
- extern void UpdateDemoTimer();
- UpdateDemoTimer();
- #endif
- if (key == A_ESCAPE && down && !Menus_AnyFullScreenVisible() && !(menu->window.flags & WINDOW_IGNORE_ESCAPE))
- {
- Menus_CloseAll();
- }
- else
- {
- Menu_HandleKey(menu, key, down );
- }
- }
- else
- {
- trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );
- trap_Key_ClearStates();
- Cvar_Set( "cl_paused", "0" );
- }
- }
- }
- /*
- =================
- UI_Report
- =================
- */
- void UI_Report(void)
- {
- String_Report();
- }
- /*
- =================
- UI_DataPadMenu
- =================
- */
- void UI_DataPadMenu(void)
- {
- int newForcePower,newObjective;
- Menus_CloseByName("mainhud");
- newForcePower = (int)trap_Cvar_VariableValue("cg_updatedDataPadForcePower1");
- newObjective = (int)trap_Cvar_VariableValue("cg_updatedDataPadObjective");
- if (newForcePower)
- {
- Menus_ActivateByName("datapadForcePowersMenu");
- }
- else if (newObjective)
- {
- Menus_ActivateByName("datapadMissionMenu");
- }
- else
- {
- Menus_ActivateByName("datapadMissionMenu");
- }
- ui.Key_SetCatcher( KEYCATCH_UI );
- }
- /*
- =================
- UI_InGameMenu
- =================
- */
- extern void S_StopAllSoundsExceptMusic(void);
- void UI_InGameMenu(const char*menuID)
- {
- // don't allow this if you are dead
- if( menuID && !strcmp(menuID, "noController"))
- {
- // do nothing
- }
- else if ( svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
- {
- ui.Cvar_Set( "cl_paused", "0" );
- return;
- }
- #ifdef _XBOX
- ui.PrecacheScreenshot();
- #endif
- Menus_CloseByName("mainhud");
- if (menuID)
- {
- Menus_ActivateByName(menuID);
- }
- else
- {
- S_StopAllSoundsExceptMusic();
- Menus_ActivateByName("ingameMainMenu");
- }
- ui.Key_SetCatcher( KEYCATCH_UI );
- }
- qboolean _UI_IsFullscreen( void )
- {
- return Menus_AnyFullScreenVisible();
- }
- /*
- =======================================================================
- MAIN MENU
- =======================================================================
- */
- /*
- ===============
- UI_MainMenu
- The main menu only comes up when not in a game,
- so make sure that the attract loop server is down
- and that local cinematics are killed
- ===============
- */
- void UI_MainMenu(void)
- {
- char buf[256];
- ui.Cvar_Set("sv_killserver", "1"); // let the demo server know it should shut down
- ui.Key_SetCatcher( KEYCATCH_UI );
- menuDef_t *m = Menus_ActivateByName("mainMenu");
- if (!m)
- { //wha? try again
- UI_LoadMenus("ui/menus.txt",qfalse);
- }
- ui.Cvar_VariableStringBuffer("com_errorMessage", buf, sizeof(buf));
- if (strlen(buf)) {
- Menus_ActivateByName("error_popmenu");
- }
- }
- /*
- =================
- Menu_Cache
- =================
- */
- void Menu_Cache( void )
- {
- // uis.cursor = ui.R_RegisterShaderNoMip( "menu/new/crosshairb");
- // Common menu graphics
- uis.whiteShader = ui.R_RegisterShader( "white" );
- // uis.menuBackShader = ui.R_RegisterShaderNoMip( "menu/art/unknownmap" );
- }
- /*
- =================
- UI_UpdateVideoSetup
- Copies the temporary user interface version of the video cvars into
- their real counterparts. This is to create a interface which allows
- you to discard your changes if you did something you didnt want
- =================
- */
- void UI_UpdateVideoSetup ( void )
- {
- Cvar_Set ( "r_mode", Cvar_VariableString ( "ui_r_mode" ) );
- Cvar_Set ( "r_fullscreen", Cvar_VariableString ( "ui_r_fullscreen" ) );
- Cvar_Set ( "r_colorbits", Cvar_VariableString ( "ui_r_colorbits" ) );
- Cvar_Set ( "r_lodbias", Cvar_VariableString ( "ui_r_lodbias" ) );
- Cvar_Set ( "r_picmip", Cvar_VariableString ( "ui_r_picmip" ) );
- Cvar_Set ( "r_texturebits", Cvar_VariableString ( "ui_r_texturebits" ) );
- Cvar_Set ( "r_texturemode", Cvar_VariableString ( "ui_r_texturemode" ) );
- Cvar_Set ( "r_detailtextures", Cvar_VariableString ( "ui_r_detailtextures" ) );
- Cvar_Set ( "r_ext_compress_textures", Cvar_VariableString ( "ui_r_ext_compress_textures" ) );
- Cvar_Set ( "r_depthbits", Cvar_VariableString ( "ui_r_depthbits" ) );
- Cvar_Set ( "r_subdivisions", Cvar_VariableString ( "ui_r_subdivisions" ) );
- Cvar_Set ( "r_fastSky", Cvar_VariableString ( "ui_r_fastSky" ) );
- Cvar_Set ( "r_inGameVideo", Cvar_VariableString ( "ui_r_inGameVideo" ) );
- Cvar_Set ( "r_allowExtensions", Cvar_VariableString ( "ui_r_allowExtensions" ) );
- // Cvar_Set ( "cg_shadows", Cvar_VariableString ( "ui_cg_shadows" ) );
- Cvar_Set ( "ui_r_modified", "0" );
- Cbuf_ExecuteText( EXEC_APPEND, "vid_restart;" );
- }
- /*
- =================
- UI_GetVideoSetup
- Retrieves the current actual video settings into the temporary user
- interface versions of the cvars.
- =================
- */
- void UI_GetVideoSetup ( void )
- {
- // Make sure the cvars are registered as read only.
- Cvar_Register ( NULL, "ui_r_glCustom", "4", CVAR_ROM|CVAR_ARCHIVE );
- Cvar_Register ( NULL, "ui_r_mode", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_fullscreen", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_colorbits", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_lodbias", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_picmip", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_texturebits", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_texturemode", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_detailtextures", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_ext_compress_textures", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_depthbits", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_subdivisions", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_fastSky", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_inGameVideo", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_allowExtensions", "0", CVAR_ROM );
- // Cvar_Register ( NULL, "ui_cg_shadows", "0", CVAR_ROM );
- Cvar_Register ( NULL, "ui_r_modified", "0", CVAR_ROM );
-
- // Copy over the real video cvars into their temporary counterparts
- Cvar_Set ( "ui_r_mode", Cvar_VariableString ( "r_mode" ) );
- Cvar_Set ( "ui_r_colorbits", Cvar_VariableString ( "r_colorbits" ) );
- Cvar_Set ( "ui_r_fullscreen", Cvar_VariableString ( "r_fullscreen" ) );
- Cvar_Set ( "ui_r_lodbias", Cvar_VariableString ( "r_lodbias" ) );
- Cvar_Set ( "ui_r_picmip", Cvar_VariableString ( "r_picmip" ) );
- Cvar_Set ( "ui_r_texturebits", Cvar_VariableString ( "r_texturebits" ) );
- Cvar_Set ( "ui_r_texturemode", Cvar_VariableString ( "r_texturemode" ) );
- Cvar_Set ( "ui_r_detailtextures", Cvar_VariableString ( "r_detailtextures" ) );
- Cvar_Set ( "ui_r_ext_compress_textures", Cvar_VariableString ( "r_ext_compress_textures" ) );
- Cvar_Set ( "ui_r_depthbits", Cvar_VariableString ( "r_depthbits" ) );
- Cvar_Set ( "ui_r_subdivisions", Cvar_VariableString ( "r_subdivisions" ) );
- Cvar_Set ( "ui_r_fastSky", Cvar_VariableString ( "r_fastSky" ) );
- Cvar_Set ( "ui_r_inGameVideo", Cvar_VariableString ( "r_inGameVideo" ) );
- Cvar_Set ( "ui_r_allowExtensions", Cvar_VariableString ( "r_allowExtensions" ) );
- // Cvar_Set ( "ui_cg_shadows", Cvar_VariableString ( "cg_shadows" ) );
- Cvar_Set ( "ui_r_modified", "0" );
- }
- static void UI_SetSexandSoundForModel(const char* char_model)
- {
- int f,i;
- char soundpath[MAX_QPATH];
- qboolean isFemale = qfalse;
- i = ui.FS_FOpenFile(va("models/players/%s/sounds.cfg", char_model), &f, FS_READ);
- if ( !f )
- {//no? oh bother.
- Cvar_Reset("snd");
- Cvar_Reset("sex");
- return;
- }
- soundpath[0] = 0;
- ui.FS_Read(&soundpath, i, f);
- while (i >= 0 && soundpath[i] != '\n')
- {
- if (soundpath[i] == 'f')
- {
- isFemale = qtrue;
- soundpath[i] = 0;
- }
- i--;
- }
- i = 0;
- while (soundpath[i] && soundpath[i] != '\r' && soundpath[i] != '\n')
- {
- i++;
- }
- soundpath[i] = 0;
- ui.FS_FCloseFile(f);
- Cvar_Set ( "snd", soundpath);
- if (isFemale)
- {
- Cvar_Set ( "sex", "f");
- }
- else
- {
- Cvar_Set ( "sex", "m");
- }
- }
- static void UI_UpdateCharacterCvars ( void )
- {
- const char *char_model = Cvar_VariableString ( "ui_char_model" );
- UI_SetSexandSoundForModel(char_model);
- Cvar_Set ( "g_char_model", char_model );
- Cvar_Set ( "g_char_skin_head", Cvar_VariableString ( "ui_char_skin_head" ) );
- Cvar_Set ( "g_char_skin_torso", Cvar_VariableString ( "ui_char_skin_torso" ) );
- Cvar_Set ( "g_char_skin_legs", Cvar_VariableString ( "ui_char_skin_legs" ) );
- Cvar_Set ( "g_char_color_red", Cvar_VariableString ( "ui_char_color_red" ) );
- Cvar_Set ( "g_char_color_green", Cvar_VariableString ( "ui_char_color_green" ) );
- Cvar_Set ( "g_char_color_blue", Cvar_VariableString ( "ui_char_color_blue" ) );
- }
- static void UI_GetCharacterCvars ( void )
- {
- Cvar_Set ( "ui_char_skin_head", Cvar_VariableString ( "g_char_skin_head" ) );
- Cvar_Set ( "ui_char_skin_torso", Cvar_VariableString ( "g_char_skin_torso" ) );
- Cvar_Set ( "ui_char_skin_legs", Cvar_VariableString ( "g_char_skin_legs" ) );
- Cvar_Set ( "ui_char_color_red", Cvar_VariableString ( "g_char_color_red" ) );
- Cvar_Set ( "ui_char_color_green", Cvar_VariableString ( "g_char_color_green" ) );
- Cvar_Set ( "ui_char_color_blue", Cvar_VariableString ( "g_char_color_blue" ) );
- char* model = Cvar_VariableString ( "g_char_model" );
- Cvar_Set ( "ui_char_model", model );
- for (int i = 0; i < uiInfo.playerSpeciesCount; i++)
- {
- if ( !stricmp(model, uiInfo.playerSpecies[i].Name) )
- {
- uiInfo.playerSpeciesIndex = i;
- }
- }
- }
- static void UI_UpdateSaberCvars ( void )
- {
- Cvar_Set ( "g_saber_type", Cvar_VariableString ( "ui_saber_type" ) );
- Cvar_Set ( "g_saber", Cvar_VariableString ( "ui_saber" ) );
- Cvar_Set ( "g_saber2", Cvar_VariableString ( "ui_saber2" ) );
- Cvar_Set ( "g_saber_color", Cvar_VariableString ( "ui_saber_color" ) );
- Cvar_Set ( "g_saber2_color", Cvar_VariableString ( "ui_saber2_color" ) );
- }
- static void UI_UpdateFightingStyleChoices ( void )
- {
- //
- if (!strcmpi("staff",Cvar_VariableString ( "ui_saber_type" )))
- {
- Cvar_Set ( "ui_fightingstylesallowed", "0" );
- Cvar_Set ( "ui_newfightingstyle", "1" ); // Default, MEDIUM
- }
- else if (!strcmpi("dual",Cvar_VariableString ( "ui_saber_type" )))
- {
- Cvar_Set ( "ui_fightingstylesallowed", "0" );
- Cvar_Set ( "ui_newfightingstyle", "1" ); // Default, MEDIUM
- }
- else
- {
- // Get player state
- client_t *cl = &svs.clients[0]; // 0 because only ever us as a player
- playerState_t *pState;
- if (cl && cl->gentity && cl->gentity->client)
- {
- pState = cl->gentity->client;
- // Knows Fast style?
- if (pState->saberStylesKnown & (1<<SS_FAST))
- {
- // And Medium?
- if (pState->saberStylesKnown & (1<<SS_MEDIUM))
- {
- Cvar_Set ( "ui_fightingstylesallowed", "6" ); // Has FAST and MEDIUM, so can only choose STRONG
- Cvar_Set ( "ui_newfightingstyle", "2" ); // STRONG
- }
- else
- {
- Cvar_Set ( "ui_fightingstylesallowed", "1" ); // Has FAST, so can choose from MEDIUM and STRONG
- Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
- }
- }
- // Knows Medium style?
- else if (pState->saberStylesKnown & (1<<SS_MEDIUM))
- {
- // And Strong?
- if (pState->saberStylesKnown & (1<<SS_STRONG))
- {
- Cvar_Set ( "ui_fightingstylesallowed", "4" ); // Has MEDIUM and STRONG, so can only choose FAST
- Cvar_Set ( "ui_newfightingstyle", "0" ); // FAST
- }
- else
- {
- Cvar_Set ( "ui_fightingstylesallowed", "2" ); // Has MEDIUM, so can choose from FAST and STRONG
- Cvar_Set ( "ui_newfightingstyle", "0" ); // FAST
- }
- }
- // Knows Strong style?
- else if (pState->saberStylesKnown & (1<<SS_STRONG))
- {
- // And Fast
- if (pState->saberStylesKnown & (1<<SS_FAST))
- {
- Cvar_Set ( "ui_fightingstylesallowed", "5" ); // Has STRONG and FAST, so can only take MEDIUM
- Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
- }
- else
- {
- Cvar_Set ( "ui_fightingstylesallowed", "3" ); // Has STRONG, so can choose from FAST and MEDIUM
- Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
- }
- }
- else // They have nothing, which should not happen
- {
- Cvar_Set ( "ui_currentfightingstyle", "1" ); // Default MEDIUM
- Cvar_Set ( "ui_newfightingstyle", "0" ); // FAST??
- Cvar_Set ( "ui_fightingstylesallowed", "0" ); // Default to no new styles allowed
- }
- // Determine current style
- if (pState->saberAnimLevel == SS_FAST)
- {
- Cvar_Set ( "ui_currentfightingstyle", "0" ); // FAST
- }
- else if (pState->saberAnimLevel == SS_STRONG)
- {
- Cvar_Set ( "ui_currentfightingstyle", "2" ); // STRONG
- }
- else
- {
- Cvar_Set ( "ui_currentfightingstyle", "1" ); // default MEDIUM
- }
- }
- else // No client so this must be first time
- {
- Cvar_Set ( "ui_currentfightingstyle", "1" ); // Default to MEDIUM
- Cvar_Set ( "ui_fightingstylesallowed", "0" ); // Default to no new styles allowed
- Cvar_Set ( "ui_newfightingstyle", "1" ); // MEDIUM
- }
- }
- }
- #define MAX_POWER_ENUMS 16
- typedef struct {
- char *title;
- short powerEnum;
- } powerEnum_t;
- static powerEnum_t powerEnums[MAX_POWER_ENUMS] =
- {
- "absorb", FP_ABSORB,
- "heal", FP_HEAL,
- "mindtrick", FP_TELEPATHY,
- "protect", FP_PROTECT,
- // Core powers
- "jump", FP_LEVITATION,
- "pull", FP_PULL,
- "push", FP_PUSH,
- "sense", FP_SEE,
- "speed", FP_SPEED,
- "sabdef", FP_SABER_DEFENSE,
- "saboff", FP_SABER_OFFENSE,
- "sabthrow", FP_SABERTHROW,
- // Dark powers
- "drain", FP_DRAIN,
- "grip", FP_GRIP,
- "lightning", FP_LIGHTNING,
- "rage", FP_RAGE
- };
- // Find the index to the Force Power in powerEnum array
- static qboolean UI_GetForcePowerIndex ( const char *forceName, short *forcePowerI )
- {
- int i;
- // Find a match for the forceName passed in
- for (i=0;i<MAX_POWER_ENUMS;i++)
- {
- if ( !Q_stricmp(forceName, powerEnums[i].title ) )
- {
- *forcePowerI = i;
- return(qtrue);
- }
- }
- *forcePowerI = FP_UPDATED_NONE; // Didn't find it
- return(qfalse);
- }
- // Set the fields for the allocation of force powers (Used by Force Power Allocation screen)
- static void UI_InitAllocForcePowers ( const char *forceName )
- {
- menuDef_t *menu;
- itemDef_t *item;
- short forcePowerI=0;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- if (!UI_GetForcePowerIndex ( forceName, &forcePowerI ))
- {
- return;
- }
- #ifndef XBOX_DEMO
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl)
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- #endif
- char itemName[128];
- Com_sprintf (itemName, sizeof(itemName), "%s_hexpic", powerEnums[forcePowerI].title);
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
-
- if (item)
- {
- char itemGraphic[128];
- Com_sprintf (itemGraphic, sizeof(itemGraphic), "gfx/menus/hex_pattern_%d",
- #ifdef XBOX_DEMO
- demoForcePowerLevel[powerEnums[forcePowerI].powerEnum]);
- #else
- pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]);
- #endif
- item->window.background = ui.R_RegisterShaderNoMip(itemGraphic);
- // If maxed out on power - don't allow update
- /* if (pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]>=3)
- {
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[forcePowerI].title);
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item) // This is okay, because core powers don't have a hex button
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- } */
- }
- // Set weapons button to inactive
- if( Q_stricmp(menu->window.name, "ingameForceStatus") != 0 )
- UI_ForcePowerWeaponsButton(qfalse);
- }
- // 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)
- static void UI_SetPowerTitleText ( qboolean showAllocated )
- {
- menuDef_t *menu;
- itemDef_t *item;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- if (showAllocated)
- {
- // Show the text saying the force point has been allocated
- item = (itemDef_s *) Menu_FindItemByName(menu, "allocated_text");
- if (item)
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- // Hide text saying the force point needs to be allocated
- item = (itemDef_s *) Menu_FindItemByName(menu, "allocate_text");
- if (item)
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- }
- else
- {
- // Hide the text saying the force point has been allocated
- item = (itemDef_s *) Menu_FindItemByName(menu, "allocated_text");
- if (item)
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- // Show text saying the force point needs to be allocated
- item = (itemDef_s *) Menu_FindItemByName(menu, "allocate_text");
- if (item)
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- }
- }
- //. Find weapons button and make active/inactive (Used by Force Power Allocation screen)
- static void UI_ForcePowerWeaponsButton(qboolean activeFlag)
- {
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- // Find weaponsbutton
- itemDef_t *item;
- item = (itemDef_s *) Menu_FindItemByName(menu, "weaponbutton");
- if (item)
- {
- // Make it active
- if (activeFlag)
- {
- item->window.flags |= WINDOW_VISIBLE;
- Item_SetFocus(item, 0, 0);
- }
- else
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- }
- //UI_SetVis(menu, "tab_Force", !activeFlag);
- if(activeFlag)
- DC->setCVar("ui_hideAcallout", "0");
- else
- DC->setCVar("ui_hideAcallout", "1");
- }
- void UI_SetItemColor(itemDef_t *item,const char *itemname,const char *name,vec4_t color);
- static void UI_SetHexPicLevel( const menuDef_t *menu,const int forcePowerI,const int powerLevel, const qboolean goldFlag )
- {
- char itemName[128];
- itemDef_t *item;
- // Find proper hex picture on menu
- Com_sprintf (itemName, sizeof(itemName), "%s_hexpic", powerEnums[forcePowerI].title);
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, itemName);
-
- // Now give it the proper hex graphic
- if (item)
- {
- char itemGraphic[128];
- if (goldFlag)
- {
- Com_sprintf (itemGraphic, sizeof(itemGraphic), "gfx/menus/hex_pattern_%d_gold",powerLevel);
- }
- else
- {
- Com_sprintf (itemGraphic, sizeof(itemGraphic), "gfx/menus/hex_pattern_%d",powerLevel);
- }
- item->window.background = ui.R_RegisterShaderNoMip(itemGraphic);
- /*
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[forcePowerI].title);
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *)menu, itemName);
- if (item)
- {
- if (goldFlag)
- {
- // Change description text to tell player they can decrement the force point
- item->descText = "@MENUS_REMOVEFP";
- }
- else
- {
- // Change description text to tell player they can increment the force point
- item->descText = "@MENUS_ADDFP";
- }
- }
- */
- }
- }
- void UI_SetItemVisible(menuDef_t *menu,const char *itemname,qboolean visible);
- // if this is the first time into the force power allocation screen, show the INSTRUCTION screen
- static void UI_ForceHelpActive( void )
- {
- int tier_storyinfo = Cvar_VariableIntegerValue( "tier_storyinfo" );
- // First time, show instructions
- if (tier_storyinfo==1)
- {
- // Menus_OpenByName("ingameForceHelp");
- Menus_ActivateByName("ingameForceHelp");
- }
- }
- // Shut down the help screen in the force power allocation screen
- static void UI_ShutdownForceHelp( void )
- {
- int i;
- char itemName[128];
- menuDef_t *menu;
- itemDef_t *item;
- vec4_t color = { 0.65f, 0.65f, 0.65f, 1.0f};
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- // Not in upgrade mode so turn on all the force buttons, the big forceicon and description text
- if (uiInfo.forcePowerUpdated == FP_UPDATED_NONE)
- {
- // We just decremented a field so turn all buttons back on
- // Make it so all buttons can be clicked
- for (i=0;i<MAX_POWER_ENUMS;i++)
- {
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
- UI_SetItemVisible(menu,itemName,qtrue);
- }
- UI_SetItemVisible(menu,"force_icon",qtrue);
- UI_SetItemVisible(menu,"force_desc",qtrue);
- UI_SetItemVisible(menu,"leveltext",qtrue);
- // Set focus on the top left button
- item = (itemDef_s *) Menu_FindItemByName(menu, "absorb_fbutton");
- item->window.flags |= WINDOW_HASFOCUS;
- if (item->onFocus)
- {
- Item_RunScript(item, item->onFocus);
- }
- }
- // In upgrade mode so just turn the deallocate button on
- else
- {
- UI_SetItemVisible(menu,"force_icon",qtrue);
- UI_SetItemVisible(menu,"force_desc",qtrue);
- UI_SetItemVisible(menu,"deallocate_fbutton",qtrue);
- item = (itemDef_s *) Menu_FindItemByName(menu, va("%s_fbutton",powerEnums[uiInfo.forcePowerUpdated].title));
- if (item)
- {
- #ifdef _XBOX
- Item_SetFocus(item, 0,0);
- #else
- item->window.flags |= WINDOW_HASFOCUS;
- #endif
- }
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- if (uiInfo.forcePowerUpdated == FP_UPDATED_NONE)
- {
- return;
- }
- // Update level description
- Com_sprintf (
- itemName,
- sizeof(itemName),
- "%s_level%ddesc",
- powerEnums[uiInfo.forcePowerUpdated].title,
- pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]
- );
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item)
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- }
- // If one was a chosen force power, high light it again.
- if (uiInfo.forcePowerUpdated>FP_UPDATED_NONE)
- {
- char itemhexName[128];
- char itemiconName[128];
- vec4_t color2 = { 1.0f, 1.0f, 1.0f, 1.0f};
- Com_sprintf (itemhexName, sizeof(itemhexName), "%s_hexpic", powerEnums[uiInfo.forcePowerUpdated].title);
- Com_sprintf (itemiconName, sizeof(itemiconName), "%s_iconpic", powerEnums[uiInfo.forcePowerUpdated].title);
-
- UI_SetItemColor(item,itemhexName,"forecolor",color2);
- UI_SetItemColor(item,itemiconName,"forecolor",color2);
- }
- else
- {
- // Un-grey-out all icons
- UI_SetItemColor(item,"hexpic","forecolor",color);
- UI_SetItemColor(item,"iconpic","forecolor",color);
- }
- }
- // Decrement force power level (Used by Force Power Allocation screen)
- static void UI_DecrementCurrentForcePower ( void )
- {
- menuDef_t *menu;
- itemDef_t *item;
- short i;
- vec4_t color = { 0.65f, 0.65f, 0.65f, 1.0f};
- char itemName[128];
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- #ifndef XBOX_DEMO
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- #endif
- if (uiInfo.forcePowerUpdated == FP_UPDATED_NONE)
- {
- return;
- }
- DC->startLocalSound(uiInfo.uiDC.Assets.forceUnchosenSound, CHAN_AUTO );
- #ifdef XBOX_DEMO
- if (demoForcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]>0)
- {
- demoForcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]--; // Decrement it
- }
- UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,demoForcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum],qfalse );
- #else
- if (pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]>0)
- {
- pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]--; // Decrement it
- // Turn off power if level is 0
- if (pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]<1)
- {
- pState->forcePowersKnown &= ~( 1 << powerEnums[uiInfo.forcePowerUpdated].powerEnum );
- }
- }
- UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum],qfalse );
- #endif
- UI_ShowForceLevelDesc ( powerEnums[uiInfo.forcePowerUpdated].title );
- // We just decremented a field so turn all buttons back on
- // Make it so all buttons can be clicked
- for (i=0;i<MAX_POWER_ENUMS;i++)
- {
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item) // This is okay, because core powers don't have a hex button
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- }
- // Show point has not been allocated
- UI_SetPowerTitleText( qfalse);
- // Make weapons button active
- UI_ForcePowerWeaponsButton(qfalse);
- // Hide the deallocate button
- item = (itemDef_s *) Menu_FindItemByName(menu, "deallocate_fbutton");
- if (item)
- {
- item->window.flags &= ~WINDOW_VISIBLE; //
- // Un-grey-out all icons
- UI_SetItemColor(item,"hexpic","forecolor",color);
- UI_SetItemColor(item,"iconpic","forecolor",color);
- }
- item = (itemDef_s *) Menu_FindItemByName(menu, va("%s_fbutton",powerEnums[uiInfo.forcePowerUpdated].title));
- if (item)
- {
- #ifdef _XBOX
- Item_SetFocus(item, 0,0);
- #else
- item->window.flags |= WINDOW_HASFOCUS;
- #endif
- }
- uiInfo.forcePowerUpdated = FP_UPDATED_NONE; // It's as if nothing happened.
- }
- void Item_MouseEnter(itemDef_t *item, float x, float y);
- static void UI_SetUpForceSelect( void )
- {
- menuDef_t* menu;
- itemDef_t* item;
- client_t* client;
- playerState_t* player;
- // get a ptr to the force select menu
- menu = Menu_GetFocused();
- if(!menu)
- {
- return;
- }
- #ifdef XBOX_DEMO
- Item_SetFocus(Menu_FindItemByName(menu, "absorb_fbutton"), 0, 0);
- return;
- #else
- // get a ptr to the player
- client = &svs.clients[0];
- if(!client)
- {
- return;
- }
- player = client->gentity->client;
- // look for the first force power in the force powers screen
- // that doesn't have all three points filled
- if(player->forcePowerLevel[FP_ABSORB] < 3)
- {
- item = Menu_FindItemByName(menu, "absorb_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_HEAL] < 3)
- {
- item = Menu_FindItemByName(menu, "heal_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_TELEPATHY] < 3)
- {
- item = Menu_FindItemByName(menu, "mindtrick_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_PROTECT] < 3)
- {
- item = Menu_FindItemByName(menu, "protect_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_DRAIN] < 3)
- {
- item = Menu_FindItemByName(menu, "drain_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_GRIP] < 3)
- {
- item = Menu_FindItemByName(menu, "grip_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_LIGHTNING] < 3)
- {
- item = Menu_FindItemByName(menu, "lightning_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- if(player->forcePowerLevel[FP_RAGE] < 3)
- {
- item = Menu_FindItemByName(menu, "rage_fbutton");
- if(item)
- {
- Item_SetFocus(item, 0, 0);
- }
- return;
- }
- #endif
- }
- // Try to increment force power level (Used by Force Power Allocation screen)
- static void UI_AffectForcePowerLevel ( const char *forceName )
- {
- short forcePowerI=0,i;
- menuDef_t *menu;
- itemDef_t *item;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- if (!UI_GetForcePowerIndex ( forceName, &forcePowerI ))
- {
- return;
- }
- #ifndef XBOX_DEMO
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- #endif
- #ifdef XBOX_DEMO
- if (demoForcePowerLevel[powerEnums[forcePowerI].powerEnum]>2)
- { // Too big, can't be incremented
- Cvar_Set("ui_deallocate_button","0");
- item = Menu_FindItemByName(menu, Cvar_VariableString("ui_forceButton"));
-
- if(!item)
- return;
- item->window.flags &= ~WINDOW_DECORATION;
- return;
- }
- #else
- if (pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]>2)
- { // Too big, can't be incremented
- Cvar_Set("ui_deallocate_button","0");
- item = Menu_FindItemByName(menu, Cvar_VariableString("ui_forceButton"));
-
- if(!item)
- return;
- item->window.flags &= ~WINDOW_DECORATION;
- return;
- }
- #endif
- Cvar_Set("ui_deallocate_button","1");
- // Increment power level.
- DC->startLocalSound(uiInfo.uiDC.Assets.forceChosenSound, CHAN_AUTO );
- uiInfo.forcePowerUpdated = forcePowerI; // Remember which power was updated
- #ifdef XBOX_DEMO
- demoForcePowerLevel[powerEnums[forcePowerI].powerEnum]++; // Increment it
- UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,demoForcePowerLevel[powerEnums[forcePowerI].powerEnum],qtrue );
- #else
- pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]++; // Increment it
- pState->forcePowersKnown |= ( 1 << powerEnums[forcePowerI].powerEnum );
- UI_SetHexPicLevel( menu,uiInfo.forcePowerUpdated,pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum],qtrue );
- #endif
- UI_ShowForceLevelDesc ( forceName );
- // A field was updated, so make it so others can't be
- if (uiInfo.forcePowerUpdated>FP_UPDATED_NONE)
- {
- vec4_t color = { 0.25f, 0.25f, 0.25f, 1.0f};
- char itemName[128];
- // Make it so none of the other buttons can be clicked
- for (i=0;i<MAX_POWER_ENUMS;i++)
- {
- if (i==uiInfo.forcePowerUpdated)
- {
- continue;
- }
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item) // This is okay, because core powers don't have a hex button
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- }
- // Show point has been allocated
- UI_SetPowerTitleText ( qtrue );
- // Make weapons button active
- UI_ForcePowerWeaponsButton(qtrue);
- // Make user_info
- Cvar_Set ( "ui_forcepower_inc", va("%d",uiInfo.forcePowerUpdated) );
- // Just grab an item to hand it to the function.
- item = (itemDef_s *) Menu_FindItemByName(menu, "deallocate_fbutton");
- if (item)
- {
- // Show all icons as greyed-out
- UI_SetItemColor(item,"hexpic","forecolor",color);
- UI_SetItemColor(item,"iconpic","forecolor",color);
- #ifdef _XBOX
- Item_SetFocus(item, 0,0);
- #else
- item->window.flags |= WINDOW_HASFOCUS;
- #endif
- }
- }
- }
- static void UI_DecrementForcePowerLevel( void )
- {
- int forcePowerI = Cvar_VariableIntegerValue( "ui_forcepower_inc" );
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]--; // Decrement it
- }
- // Show force level description that matches current player level (Used by Force Power Allocation screen)
- static void UI_ShowForceLevelDesc ( const char *forceName )
- {
- short forcePowerI=0;
- menuDef_t *menu;
- itemDef_t *item;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
-
- if (!UI_GetForcePowerIndex ( forceName, &forcePowerI ))
- {
- return;
- }
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- char itemName[128];
- // Update level description
- Com_sprintf (
- itemName,
- sizeof(itemName),
- "%s_level%ddesc",
- powerEnums[forcePowerI].title,
- pState->forcePowerLevel[powerEnums[forcePowerI].powerEnum]
- );
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item)
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- }
- // Reset force level powers screen to what it was before player upgraded them (Used by Force Power Allocation screen)
- static void UI_ResetForceLevels ( void )
- {
- // What force ppower had the point added to it?
- if (uiInfo.forcePowerUpdated!=FP_UPDATED_NONE)
- {
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- playerState_t* pState = cl->gentity->client;
- // Decrement that power
- pState->forcePowerLevel[powerEnums[uiInfo.forcePowerUpdated].powerEnum]--;
- menuDef_t *menu;
- itemDef_t *item;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- int i;
- char itemName[128];
- // Make it so all buttons can be clicked
- for (i=0;i<MAX_POWER_ENUMS;i++)
- {
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[i].title);
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item) // This is okay, because core powers don't have a hex button
- {
- item->window.flags |= WINDOW_VISIBLE;
- }
- }
- UI_SetPowerTitleText( qfalse );
- /*
- Com_sprintf (itemName, sizeof(itemName), "%s_fbutton", powerEnums[uiInfo.forcePowerUpdated].title);
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName);
- if (item)
- {
- // Change description text to tell player they can increment the force point
- item->descText = "@MENUS_ADDFP";
- }
- */
- uiInfo.forcePowerUpdated = FP_UPDATED_NONE;
- }
- UI_ForcePowerWeaponsButton(qfalse);
- }
- // If the user has entered the force cheat (and thus has every force power)
- // make sure that they don't get stuck on the force config screen
- static void UI_CheckForForceCheat( void )
- {
- // Get player state
- client_t* cl = &svs.clients[0];
- if (!cl)
- return;
- playerState_t *pState = cl->gentity->client;
- // If there is ANY light/dark power that they don't have at max rank, we don't do anything
- if( (pState->forcePowerLevel[FP_HEAL] < 3) ||
- (pState->forcePowerLevel[FP_TELEPATHY] < 3) ||
- (pState->forcePowerLevel[FP_GRIP] < 3) ||
- (pState->forcePowerLevel[FP_LIGHTNING] < 3) ||
- (pState->forcePowerLevel[FP_RAGE] < 3) ||
- (pState->forcePowerLevel[FP_PROTECT] < 3) ||
- (pState->forcePowerLevel[FP_ABSORB] < 3) ||
- (pState->forcePowerLevel[FP_DRAIN] < 3) )
- return;
- // Twiddling controls was a mess. Instead, just skip this menu and go to weapons:
- Menus_CloseAll();
- Menus_OpenByName( "ingameWpnSelect" );
- }
- // Used by the cheat system to prevent the give all force powers cheat while
- // the config screen is active
- bool UI_ForceConfigUIActive( void )
- {
- menuDef_t *menu = Menu_GetFocused();
- if( menu && (Q_stricmp(menu->window.name, "progress_FConfig") == 0) )
- return true;
- return false;
- }
- // Set the Players known saber style
- static void UI_UpdateFightingStyle ( void )
- {
- playerState_t *pState;
- int fightingStyle,saberStyle;
- fightingStyle = Cvar_VariableIntegerValue( "ui_newfightingstyle" );
- if (fightingStyle == 1)
- {
- saberStyle = SS_MEDIUM;
- }
- else if (fightingStyle == 2)
- {
- saberStyle = SS_STRONG;
- }
- else // 0 is Fast
- {
- saberStyle = SS_FAST;
- }
- // Get player state
- client_t *cl = &svs.clients[0]; // 0 because only ever us as a player
- // No client, get out
- if (cl && cl->gentity && cl->gentity->client)
- {
- pState = cl->gentity->client;
- pState->saberStylesKnown |= (1<<saberStyle);
- }
- else // Must be at the beginning of the game so the client hasn't been created, shove data in a cvar
- {
- Cvar_Set ( "g_fighting_style", va("%d",saberStyle) );
- }
- }
- static void UI_ResetCharacterListBoxes( void )
- {
- itemDef_t *item;
- menuDef_t *menu;
- listBoxDef_t *listPtr;
- menu = Menus_FindByName("characterMenu");
-
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "headlistbox");
- if (item)
- {
- listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
- if( listPtr )
- {
- listPtr->cursorPos = 0;
- }
- item->cursorPos = 0;
- }
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "torsolistbox");
- if (item)
- {
- listPtr = (listBoxDef_t*)item->typeData;
- if( listPtr )
- {
- listPtr->cursorPos = 0;
- }
- item->cursorPos = 0;
- }
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "lowerlistbox");
- if (item)
- {
- listPtr = (listBoxDef_t*)item->typeData;
- if( listPtr )
- {
- listPtr->cursorPos = 0;
- }
- item->cursorPos = 0;
- }
- item = (itemDef_t *) Menu_FindItemByName((menuDef_t *) menu, "colorbox");
- if (item)
- {
- listPtr = (listBoxDef_t*)item->typeData;
- if( listPtr )
- {
- listPtr->cursorPos = 0;
- }
- item->cursorPos = 0;
- }
- }
- }
- static void UI_ClearInventory ( void )
- {
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- // Clear out inventory for the player
- int i;
- for (i=0;i<MAX_INVENTORY;i++)
- {
- pState->inventory[i] = 0;
- }
- }
- }
- static void UI_GiveInventory ( const int itemIndex, const int amount )
- {
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- if (itemIndex < MAX_INVENTORY)
- {
- pState->inventory[itemIndex]=amount;
- }
- }
- }
- //. Find weapons allocation screen BEGIN button and make active/inactive
- /*
- static void UI_WeaponAllocBeginButton(qboolean activeFlag)
- {
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- int weap = Cvar_VariableIntegerValue( "weapon_menu" );
-
- // Find begin button
- itemDef_t *item;
- item = Menu_GetMatchingItemByNumber(menu, weap, "beginmission");
- #ifndef _XBOX
- if (item)
- {
- // Make it active
- if (activeFlag)
- {
- item->window.flags &= ~WINDOW_INACTIVE;
- }
- else
- {
- item->window.flags |= WINDOW_INACTIVE;
- }
- }
- #else
- if (item)
- {
- // Make it active
- if (activeFlag)
- {
- item->window.flags |= WINDOW_VISIBLE;
- Item_SetFocus(item, 0, 0);
- }
- else
- {
- item->window.flags &= ~WINDOW_VISIBLE;
- }
- }
- UI_SetVis(menu, "tab_Weapon", !activeFlag);
- UI_SetVis(menu, "tab_WeaponShadow", !activeFlag);
- UI_SetVis(menu, "beginmissionShadow", activeFlag);
- if(activeFlag)
- DC->setCVar("ui_hideAcallout", "0");
- else
- DC->setCVar("ui_hideAcallout", "1");
- #endif
- }
- */
- // If we have both weapons and the throwable weapon, turn on the begin mission button,
- // otherwise, turn it off
- /*
- static void UI_WeaponsSelectionsComplete( void )
- {
- // We need two weapons and one throwable
- if (( uiInfo.selectedWeapon1 != NOWEAPON ) &&
- ( uiInfo.selectedWeapon2 != NOWEAPON ) &&
- ( uiInfo.selectedThrowWeapon != NOWEAPON ))
- {
- UI_WeaponAllocBeginButton(qtrue); // Turn it on
- }
- else
- {
- UI_WeaponAllocBeginButton(qfalse); // Turn it off
- }
- }
- */
- // if this is the first time into the weapon allocation screen, show the INSTRUCTION screen
- static void UI_WeaponHelpActive( void )
- {
- int tier_storyinfo = Cvar_VariableIntegerValue( "tier_storyinfo" );
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- // First time, show instructions
- if (tier_storyinfo==1)
- {
- UI_SetItemVisible(menu,"weapon_button",qfalse);
- UI_SetItemVisible(menu,"inst_stuff",qtrue);
- }
- // just act like normal
- else
- {
- UI_SetItemVisible(menu,"weapon_button",qtrue);
- UI_SetItemVisible(menu,"inst_stuff",qfalse);
- }
- }
- static void UI_InitWeaponSelect( void )
- {
- menuDef_t *menu = Menu_GetFocused();
- if( !menu || !menu->window.name )
- return;
- if (Q_stricmp(menu->window.name, "ingameWpnSelect") == 0)
- {
- // First screen - reset all weapon selections
- uiInfo.selectedWeapon1 = NOWEAPON;
- uiInfo.selectedWeapon2 = NOWEAPON;
- uiInfo.selectedThrowWeapon = NOWEAPON;
- }
- else if(Q_stricmp(menu->window.name, "ingameWpnSelect2") == 0)
- {
- // Second screen. Disable whatever needs to be disabled, re-enable the rest:
- UI_DisableWeapon();
- // Now put focus on the first item that isn't disabled:
- itemDef_t *item;
- if( uiInfo.selectedWeapon1 == WP_BLASTER )
- item = Menu_FindItemByName( menu, "R1_C2_button" );
- else
- item = Menu_FindItemByName( menu, "R1_C1_button" );
- if( !item )
- return;
- Item_SetFocus( item, 0, 0 );
- }
- else if(Q_stricmp(menu->window.name, "ingameWpnSelect3") == 0)
- {
- // Third screen, nothing to do.
- }
- }
- // Called by the second weapon select screen to disable and gray out the
- // weapon that was chosen on the first screen
- static void UI_DisableWeapon( void )
- {
- // Get weapon chosen on first screen - adjust by one, as itemDefs use 1-based index
- int firstWeapon = Cvar_VariableIntegerValue( "weaponSelect" ) + 1;
- assert( firstWeapon >= 1 && firstWeapon <= 8 );
- menuDef_t *menu = Menu_GetFocused();
- if( !menu )
- return;
- itemDef_t *greyItem = Menu_FindItemByName( menu, "selectionSlotFill" );
- if( !greyItem )
- return;
- for( int i = 1; i <= 8; ++i )
- {
- itemDef_t *butItem = Menu_FindItemByName( menu, va("R1_C%d_button", i) );
- if( !butItem )
- continue;
- if( i == firstWeapon )
- {
- // Copy rect so that disabled weapon has a gray background
- greyItem->window.rect = butItem->window.rect;
- greyItem->window.rect.x--;
- greyItem->window.rect.y--;
- greyItem->window.rect.w += 2;
- greyItem->window.rect.h += 2;
- // Disable button for already selected weapon
- butItem->window.flags |= WINDOW_DECORATION;
- }
- else
- {
- // Make sure all other weapons ARE selectable
- butItem->window.flags &= ~WINDOW_DECORATION;
- }
- }
- }
- static void UI_ClearWeapons ( void )
- {
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- // Clear out any weapons for the player
- pState->stats[ STAT_WEAPONS ] = 0;
- pState->weapon = WP_NONE;
-
- }
- }
- static void UI_GiveWeapon ( const int weaponIndex )
- {
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- if (weaponIndex<WP_NUM_WEAPONS)
- {
- pState->stats[ STAT_WEAPONS ] |= ( 1 << weaponIndex );
- }
- }
- }
- static void UI_EquipWeapon ( const int weaponIndex )
- {
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- if (weaponIndex<WP_NUM_WEAPONS)
- {
- pState->weapon = weaponIndex;
- //force it to change
- //CG_ChangeWeapon( wp );
- }
- }
- }
- static void UI_LoadMissionSelectMenu( const char *cvarName )
- {
- int holdLevel = (int)trap_Cvar_VariableValue(cvarName);
- // Figure out which tier menu to load
- if ((holdLevel > 0) && (holdLevel < 5))
- {
- UI_LoadMenus("ui/tier1.txt",qfalse);
- Menus_CloseByName("ingameMissionSelect1");
- }
- else if ((holdLevel > 6) && (holdLevel < 10))
- {
- UI_LoadMenus("ui/tier2.txt",qfalse);
- Menus_CloseByName("ingameMissionSelect2");
- }
- else if ((holdLevel > 11) && (holdLevel < 15))
- {
- UI_LoadMenus("ui/tier3.txt",qfalse);
- Menus_CloseByName("ingameMissionSelect3");
- }
- }
- #ifdef XBOX_DEMO
- int demoWeapon1;
- int demoWeapon2;
- int demoThrowable;
- #endif
- // Update the player weapons with the chosen weapon
- 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 )
- {
- if( uiInfo.selectedWeapon1 == NOWEAPON )
- {
- uiInfo.selectedWeapon1 = weaponIndex;
- #ifdef XBOX_DEMO
- demoWeapon1 = weaponIndex;
- #endif
- }
- else
- {
- uiInfo.selectedWeapon2 = weaponIndex;
- #ifdef XBOX_DEMO
- demoWeapon2 = weaponIndex;
- #endif
- }
- if( soundfile )
- {
- DC->startLocalSound(DC->registerSound(soundfile, qfalse), CHAN_LOCAL );
- }
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- // Add weapon
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- if ((weaponIndex>0) && (weaponIndex<WP_NUM_WEAPONS))
- {
- pState->stats[ STAT_WEAPONS ] |= ( 1 << weaponIndex );
- }
- // Give them ammo too
- if ((ammoIndex>0) && (ammoIndex<AMMO_MAX))
- {
- pState->ammo[ ammoIndex ] = ammoAmount;
- }
- }
- // UI_WeaponsSelectionsComplete(); // Test to see if the mission begin button should turn on or off
- }
- // Update the player weapons with the chosen weapon
- static void UI_RemoveWeaponSelection ( const int weaponSelectionIndex )
- {
- }
- static void UI_NormalWeaponSelection ( const int selectionslot )
- {
- itemDef_s *item;
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- if (selectionslot == 1)
- {
- item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon1_icon" );
- if (item)
- {
- item->window.background = uiInfo.unlitWeapon1Icon;
- }
- }
- if (selectionslot == 2)
- {
- item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon2_icon" );
- if (item)
- {
- item->window.background = uiInfo.unlitWeapon2Icon;
- }
- }
- }
- static void UI_HighLightWeaponSelection ( const int selectionslot )
- {
- itemDef_s *item;
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- if (selectionslot == 1)
- {
- item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon1_icon" );
- if (item)
- {
- item->window.background = uiInfo.litWeapon1Icon;
- }
- }
- if (selectionslot == 2)
- {
- item = (itemDef_s *) Menu_FindItemByName( menu, "chosenweapon2_icon" );
- if (item)
- {
- item->window.background = uiInfo.litWeapon2Icon;
- }
- }
- }
- // Update the player throwable weapons (okay it's a bad description) with the chosen weapon
- 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 )
- {
- uiInfo.selectedThrowWeapon = weaponIndex;
- #ifdef XBOX_DEMO
- demoThrowable = weaponIndex;
- #endif
- if( soundfile )
- {
- DC->startLocalSound(DC->registerSound(soundfile, qfalse), CHAN_LOCAL );
- }
- // Get player state
- client_t* cl = &svs.clients[0]; // 0 because only ever us as a player
- if (!cl) // No client, get out
- {
- return;
- }
- // Add weapon
- if (cl->gentity && cl->gentity->client)
- {
- playerState_t* pState = cl->gentity->client;
- if ((weaponIndex>0) && (weaponIndex<WP_NUM_WEAPONS))
- {
- pState->stats[ STAT_WEAPONS ] |= ( 1 << weaponIndex );
- }
- // Give them ammo too
- if ((ammoIndex>0) && (ammoIndex<AMMO_MAX))
- {
- pState->ammo[ ammoIndex ] = ammoAmount;
- }
- }
- // UI_WeaponsSelectionsComplete(); // Test to see if the mission begin button should turn on or off
- }
- // Update the player weapons with the chosen throw weapon
- static void UI_RemoveThrowWeaponSelection ( void )
- {
- }
- static void UI_NormalThrowSelection ( void )
- {
- itemDef_s *item;
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- item = (itemDef_s *) Menu_FindItemByName( menu, "chosenthrowweapon_icon" );
- item->window.background = uiInfo.unlitThrowableIcon;
- }
- static void UI_HighLightThrowSelection ( void )
- {
- itemDef_s *item;
- menuDef_t *menu;
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- item = (itemDef_s *) Menu_FindItemByName( menu, "chosenthrowweapon_icon" );
- item->window.background = uiInfo.litThrowableIcon;
- }
- static void UI_GetSaberCvars ( void )
- {
- Cvar_Set ( "ui_saber_type", Cvar_VariableString ( "g_saber_type" ) );
- Cvar_Set ( "ui_saber", Cvar_VariableString ( "g_saber" ) );
- Cvar_Set ( "ui_saber2", Cvar_VariableString ( "g_saber2" ) );
- Cvar_Set ( "ui_saber_color", Cvar_VariableString ( "g_saber_color" ) );
- Cvar_Set ( "ui_saber2_color", Cvar_VariableString ( "g_saber2_color" ) );
- Cvar_Set ( "ui_newfightingstyle", "0");
- }
- static void UI_ResetSaberCvars ( void )
- {
- Cvar_Set ( "g_saber_type", "single" );
- Cvar_Set ( "g_saber", "single_1" );
- Cvar_Set ( "g_saber2", "" );
- Cvar_Set ( "ui_saber_type", "single" );
- Cvar_Set ( "ui_saber", "single_1" );
- Cvar_Set ( "ui_saber2", "" );
- }
- extern qboolean ItemParse_asset_model_go( itemDef_t *item, const char *name );
- extern qboolean ItemParse_model_g2skin_go( itemDef_t *item, const char *skinName );
- static void UI_UpdateCharacterSkin( void )
- {
- menuDef_t *menu;
- itemDef_t *item;
- char skin[MAX_QPATH];
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- item = (itemDef_s *) Menu_FindItemByName(menu, "character");
- if (!item)
- {
- Com_Error( ERR_FATAL, "UI_UpdateCharacterSkin: Could not find item (character) in menu (%s)", menu->window.name);
- }
- Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
- Cvar_VariableString ( "ui_char_model"),
- Cvar_VariableString ( "ui_char_skin_head"),
- Cvar_VariableString ( "ui_char_skin_torso"),
- Cvar_VariableString ( "ui_char_skin_legs")
- );
- ItemParse_model_g2skin_go( item, skin );
- }
- static void UI_UpdateCharacter( qboolean changedModel )
- {
- menuDef_t *menu;
- itemDef_t *item;
- char modelPath[MAX_QPATH];
- menu = Menu_GetFocused(); // Get current menu
- if (!menu)
- {
- return;
- }
- item = (itemDef_s *) Menu_FindItemByName(menu, "character");
- if (!item)
- {
- Com_Error( ERR_FATAL, "UI_UpdateCharacter: Could not find item (character) in menu (%s)", menu->window.name);
- }
- ItemParse_model_g2anim_go( item, ui_char_anim.string );
- Com_sprintf( modelPath, sizeof( modelPath ), "models/players/%s/model.glm", Cvar_VariableString ( "ui_char_model" ) );
- ItemParse_asset_model_go( item, modelPath );
- if ( changedModel )
- {//set all skins to first skin since we don't know you always have all skins
- //FIXME: could try to keep the same spot in each list as you swtich models
- UI_FeederSelection(FEEDER_PLAYER_SKIN_HEAD, 0, item); //fixme, this is not really the right item!!
- UI_FeederSelection(FEEDER_PLAYER_SKIN_TORSO, 0, item);
- UI_FeederSelection(FEEDER_PLAYER_SKIN_LEGS, 0, item);
- UI_FeederSelection(FEEDER_COLORCHOICES, 0, item);
- }
- UI_UpdateCharacterSkin();
- }
- void UI_UpdateSaberType( void )
- {
- char sType[MAX_QPATH];
- DC->getCVarString( "ui_saber_type", sType, sizeof(sType) );
- if ( Q_stricmp( "single", sType ) == 0 ||
- Q_stricmp( "staff", sType ) == 0 )
- {
- DC->setCVar( "ui_saber2", "" );
- }
- }
- static void UI_UpdateSaberHilt( qboolean secondSaber )
- {
- menuDef_t *menu;
- itemDef_t *item;
- char model[MAX_QPATH];
- char modelPath[MAX_QPATH];
- char skinPath[MAX_QPATH];
- menu = Menu_GetFocused(); // Get current menu (either video or ingame video, I would assume)
- if (!menu)
- {
- return;
- }
- char *itemName;
- char *saberCvarName;
- if ( secondSaber )
- {
- itemName = "saber2";
- saberCvarName = "ui_saber2";
- }
- else
- {
- itemName = "saber";
- saberCvarName = "ui_saber";
- }
- item = (itemDef_s *) Menu_FindItemByName(menu, itemName );
- if(!item)
- {
- Com_Error( ERR_FATAL, "UI_UpdateSaberHilt: Could not find item (%s) in menu (%s)", itemName, menu->window.name);
- }
- DC->getCVarString( saberCvarName, model, sizeof(model) );
- //read this from the sabers.cfg
- if ( UI_SaberModelForSaber( model, modelPath ) )
- {//successfully found a model
- ItemParse_asset_model_go( item, modelPath );//set the model
- //get the customSkin, if any
- //COM_StripExtension( modelPath, skinPath );
- //COM_DefaultExtension( skinPath, sizeof( skinPath ), ".skin" );
- if ( UI_SaberSkinForSaber( model, skinPath ) )
- {
- ItemParse_model_g2skin_go( item, skinPath );//apply the skin
- }
- else
- {
- ItemParse_model_g2skin_go( item, NULL );//apply the skin
- }
- }
- }
- /*
- static void UI_UpdateSaberColor( qboolean secondSaber )
- {
- int sabernumber;
- if (secondSaber)
- sabernumber = 2;
- else
- sabernumber = 1;
- ui.Cmd_ExecuteText( EXEC_APPEND, va("sabercolor %i %s\n",sabernumber, Cvar_VariableString("g_saber_color")));
- }
- */
- char GoToMenu[1024];
- /*
- =================
- Menus_SaveGoToMenu
- =================
- */
- void Menus_SaveGoToMenu(const char *menuTo)
- {
- memcpy(GoToMenu, menuTo, sizeof(GoToMenu));
- }
- /*
- =================
- UI_CheckVid1Data
- =================
- */
- void UI_CheckVid1Data(const char *menuTo,const char *warningMenuName)
- {
- menuDef_t *menu;
- itemDef_t *applyChanges;
- menu = Menu_GetFocused(); // Get current menu (either video or ingame video, I would assume)
- if (!menu)
- {
- Com_Printf(S_COLOR_YELLOW"WARNING: No videoMenu was found. Video data could not be checked\n");
- return;
- }
- applyChanges = (itemDef_s *) Menu_FindItemByName(menu, "applyChanges");
- if (!applyChanges)
- {
- // Menus_CloseAll();
- Menus_OpenByName(menuTo);
- return;
- }
- if ((applyChanges->window.flags & WINDOW_VISIBLE)) // Is the APPLY CHANGES button active?
- {
- // Menus_SaveGoToMenu(menuTo); // Save menu you're going to
- // Menus_HideItems(menu->window.name); // HIDE videMenu in case you have to come back
- Menus_OpenByName(warningMenuName); // Give warning
- }
- else
- {
- // Menus_CloseAll();
- // Menus_OpenByName(menuTo);
- }
- }
- /*
- =================
- UI_ResetDefaults
- =================
- */
- void UI_ResetDefaults( void )
- {
- ui.Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n");
- ui.Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n");
- ui.Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
- }
- /*
- =======================
- UI_SortSaveGames
- =======================
- */
- static int UI_SortSaveGames( const void *A, const void *B )
- {
- const int &a = ((savedata_t*)A)->currentSaveFileDateTime;
- const int &b = ((savedata_t*)B)->currentSaveFileDateTime;
- if (a > b)
- {
- return -1;
- }
- else
- {
- return (a < b);
- }
- }
- /*
- =======================
- UI_AdjustSaveGameListBox
- =======================
- */
- // Yeah I could get fired for this... in a world of good and bad, this is bad
- // I wish we passed in the menu item to RunScript(), oh well...
- void UI_AdjustSaveGameListBox( int currentLine )
- {
- menuDef_t *menu;
- itemDef_t *item;
- // could be in either the ingame or shell load menu (I know, I know it's bad)
- menu = Menus_FindByName("loadgameMenu");
- if( !menu )
- {
- menu = Menus_FindByName("ingameloadMenu");
- }
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "loadgamelist");
- if (item)
- {
- listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;
- if( listPtr )
- {
- listPtr->cursorPos = currentLine;
- }
-
- item->cursorPos = currentLine;
- }
- }
-
- }
- void setBlockDisplayCvar()
- {
- unsigned long blocks;
- blocks = SG_BlocksLeft();
- if (blocks > 50000)
- Cvar_Set("ui_BlocksAvailable","50000+");
- else
- Cvar_SetValue("ui_BlocksAvailable",(int)blocks);
-
- Cvar_SetValue("ui_BlocksNeeded", SG_SaveGameSize());
- }
-
- void storeSGDataDatetoCvar()
- {
- char timeBuffer[128];
- char * timeBufferPtr;
- char filetime[64],*tokentimeptr;
-
- strcpy (filetime,s_savedata[s_savegame.currentLine].currentSaveFileDateTimeString);
- if(!filetime[0])
- {
- Cvar_Set("ui_DateString", "");
- return;
- }
- timeBuffer[0] = 0;
- timeBufferPtr = &(timeBuffer[0]);
- //Wed
- tokentimeptr = strtok(filetime," ");
- //Jan
- tokentimeptr = strtok(NULL," ");
- strcpy(timeBufferPtr,tokentimeptr);
- timeBufferPtr+=strlen(tokentimeptr);
- *timeBufferPtr = ' ';
- timeBufferPtr ++;
- //02
- tokentimeptr = strtok(NULL," ");
- strcpy(timeBufferPtr,tokentimeptr);
- timeBufferPtr+=strlen(tokentimeptr);
- *timeBufferPtr = ' ';
- timeBufferPtr ++;
- //02:
- tokentimeptr = strtok(NULL,":");
- //strcpy(timeBufferPtr,tokentimeptr);
- //timeBufferPtr+=strlen(tokentimeptr);
- //*timeBufferPtr = ':';
- //timeBufferPtr ++;
-
- //03:
- tokentimeptr = strtok(NULL,":");
- //strcpy(timeBufferPtr,tokentimeptr);
- //timeBufferPtr+=strlen(tokentimeptr);
- //*timeBufferPtr = ' ';
- //timeBufferPtr ++;
- //55
- tokentimeptr = strtok(NULL," ");
- //strcpy(timeBufferPtr,tokentimeptr);
- //timeBufferPtr+=strlen(tokentimeptr);
- //*timeBufferPtr = '_';
- //timeBufferPtr ++;
- //1980
- tokentimeptr = strtok(NULL,"\n");
- strcpy(timeBufferPtr,tokentimeptr);
- timeBufferPtr+=strlen(tokentimeptr);
- *timeBufferPtr = 0;
- Cvar_Set("ui_DateString", timeBuffer);
-
- }
- void storeSGDataTimetoCvar()
- {
- char timeBuffer[128];
- char * timeBufferPtr;
- char filetime[64],*tokentimeptr;
-
- strcpy (filetime,s_savedata[s_savegame.currentLine].currentSaveFileDateTimeString);
- if(!filetime[0])
- {
- Cvar_Set("ui_TimeString", "");
- return;
- }
- timeBuffer[0] = 0;
- timeBufferPtr = &(timeBuffer[0]);
- //Wed
- tokentimeptr = strtok(filetime," ");
- //Jan
- tokentimeptr = strtok(NULL," ");
-
- //02
- tokentimeptr = strtok(NULL," ");
-
- //02:
- tokentimeptr = strtok(NULL,":");
- strcpy(timeBufferPtr,tokentimeptr);
- timeBufferPtr+=strlen(tokentimeptr);
- *timeBufferPtr = ':';
- timeBufferPtr ++;
-
- //03:
- tokentimeptr = strtok(NULL,":");
- strcpy(timeBufferPtr,tokentimeptr);
- timeBufferPtr+=strlen(tokentimeptr);
- *timeBufferPtr = ':';
- timeBufferPtr ++;
- //55
- tokentimeptr = strtok(NULL," ");
- strcpy(timeBufferPtr,tokentimeptr);
- timeBufferPtr+=strlen(tokentimeptr);
- //*timeBufferPtr = '_';
- //timeBufferPtr ++;
- //1980
- tokentimeptr = strtok(NULL,"\n");
- //strcpy(timeBufferPtr,tokentimeptr);
- //timeBufferPtr+=strlen(tokentimeptr);
- *timeBufferPtr = 0;
- Cvar_Set("ui_TimeString", timeBuffer);
-
-
-
- }
- void storeSGDataDiffLeveltoCvar()
- {
- char * difflevel;
- difflevel = s_savedata[s_savegame.currentLine].currentSaveFileComments;
- if (!difflevel[0])
- {
- Cvar_Set("ui_DiffLevel", "");
- return;
- }
- if ( difflevel[0] == '@')
- Cvar_Set("ui_DiffLevel", SE_GetString(&difflevel[1]));
- else
- Cvar_Set("ui_DiffLevel", "");
-
- }
- void ui_resetSaveGameList()
- {
- s_savegame.saveFileCnt = -1;
- }
- /*
- =================
- ReadSaveDirectory
- =================
- */
- //for the xbox reading the save directory will consist of
- //iterating through the save game folders
- void ReadSaveDirectory (void)
- {
- char *holdChar;
- char *filetime,*tokentimeptr;
- const char * newgame;
- qboolean newGameActive,newGameAvailable;
- char saveGameName[filepathlength];
- //char timeBuffer[128];
- //char * timeBufferPtr;
-
- // Clear out save data
- memset(s_savedata,0,sizeof(s_savedata));
- s_savegame.saveFileCnt = 0;
- Cvar_Set("ui_gameDesc", "" ); // Blank out comment
- Cvar_Set("ui_SelectionOK", "0" );
- //memset( screenShotBuf,0,(SG_SCR_WIDTH * SG_SCR_HEIGHT * 4)); //blank out sshot
- // Get everything in saves directory
- // fileCnt = ui.FS_GetFileList("saves", ".sav", s_savegame.listBuf, LISTBUFSIZE );
- Cvar_Set("ui_ResumeOK", "0" );
- holdChar = s_savegame.listBuf;
- XGAME_FIND_DATA SaveGameData;
- HANDLE searchhandle;
- BOOL retval;
- newGameActive = (Cvar_VariableIntegerValue( "ui_newGameActive" )) ? qtrue : qfalse;
- newGameAvailable = qfalse;
- extern unsigned long SG_BlocksLeft();
- if (newGameActive)
- {
- // if (SG_BlocksLeft() < SG_SaveGameSize())
- // {
- // Cvar_SetValue("noNewSaveGameAvailable", 1);
- // newGameAvailable = qfalse;
- // }
- // else
- // {
- Cvar_SetValue("noNewSaveGameAvailable", 0);
- newGameAvailable = qtrue;
- // }
- }
- else
- Cvar_SetValue("noNewSaveGameAvailable", 1);
- if ( newGameAvailable)
- {
- strcpy(s_savedata[s_savegame.saveFileCnt].currentSaveFileComments,"New Game");
- strcpy(s_savedata[s_savegame.saveFileCnt].currentSaveFileMap, "New Game");
- newgame = SE_GetString( "MENUS", "newSaveGame" );
- //JLF debug code
- if ( !newgame)
- newgame = "New Game";
- //END JLF
- strcpy (holdChar, newgame);
- s_savedata[s_savegame.saveFileCnt].currentSaveFileName = holdChar;
- holdChar += strlen(holdChar)+1;
- s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTime = 0;
- s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTimeString[0] = 0;
- s_savegame.saveFileCnt++;
- }
- // Any saves?
- searchhandle = XFindFirstSaveGame( "U:\\", &SaveGameData );
- if ( searchhandle != INVALID_HANDLE_VALUE )
- {
- do
- {
- // At least one; count up the rest
- DWORD dwCount = 1;
- //get the name of the file
-
- wcstombs(saveGameName, SaveGameData.szSaveGameName, filepathlength);
- // Skip over Settings
- if( Q_stricmp( saveGameName, "Settings" ) == 0 )
- {
- retval = XFindNextSaveGame( searchhandle, &SaveGameData );
- continue;
- }
- strcpy( holdChar, saveGameName);
-
- // Is this a valid file??? & Get comment of file
- //create full path name
- time_t result;
- result = ui.SG_GetSaveGameComment(saveGameName, s_savedata[s_savegame.saveFileCnt].currentSaveFileComments, s_savedata[s_savegame.saveFileCnt].currentSaveFileMap);
- if (result != 0) // ignore Bad save game
- {
- s_savedata[s_savegame.saveFileCnt].corrupt = false;
- }
- else
- {
- s_savedata[s_savegame.saveFileCnt].corrupt = true;
- }
- {
- s_savedata[s_savegame.saveFileCnt].currentSaveFileName = holdChar;
- s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTime = result;
- holdChar += strlen(holdChar)+1;
-
- struct tm *localTime;
- localTime = localtime( &result );
- // Wed Jan 02 02:03:55 1980\n\0
- filetime = asctime (localTime);
-
-
-
- strcpy(s_savedata[s_savegame.saveFileCnt].currentSaveFileDateTimeString, filetime );
- s_savegame.saveFileCnt++;
- if (s_savegame.saveFileCnt == MAX_SAVELOADFILES)
- {
- break;
- }
- }
-
- retval =XFindNextSaveGame( searchhandle, &SaveGameData );
- }while(retval);
- }
- if ( newGameAvailable)
- qsort( &(s_savedata[1]), s_savegame.saveFileCnt-1, sizeof(savedata_t), UI_SortSaveGames );
- else
- qsort( s_savedata, s_savegame.saveFileCnt, sizeof(savedata_t), UI_SortSaveGames );
- Cvar_SetValue("saveGameCount", s_savegame.saveFileCnt);
-
- if ((s_savegame.saveFileCnt>1 && newGameAvailable) ||
- (s_savegame.saveFileCnt>0 && !newGameAvailable))
- Cvar_SetValue("overwriteAvailable", 1);
- else
- Cvar_SetValue("overwriteAvailable", 0);
- setBlockDisplayCvar();
- if (s_savegame.currentLine == 0)
- {
- if (ui_ShowDeleteActive)
- {
- Cvar_SetValue("ui_showYdel",trap_Cvar_VariableValue("ui_ShowDelete"));
- ui_ShowDeleteActive = qfalse;
- Cvar_SetValue( "ui_cancelYScript",0);
- }
- if ( newGameAvailable)
- {
- //there is a 'new save game' index that is highlighted
- Cvar_SetValue("ui_ShowDelete",trap_Cvar_VariableValue("ui_showYdel"));
- Cvar_SetValue("ui_showYdel",0);
- Cvar_SetValue( "ui_cancelYScript",1);
- ui_ShowDeleteActive =qtrue;
- }
- }
- storeSGDataDatetoCvar();
- storeSGDataTimetoCvar();
- storeSGDataDiffLeveltoCvar();
- }
- #ifdef _XBOX
- void UI_UpdateSettingsCvars( void )
- {
- }
- static void _UI_SetVol(const char* type, float value)
- {
- if(!Q_stricmp(type, "effects") )
- {
- if(value < 0.1f)
- value = 0.0f;
- DC->setCVar("s_effects_volume", va("%f",value) );
- }
- else if(!Q_stricmp(type, "voice") )
- {
- if(value < 0.1f)
- value = 0.0f;
- DC->setCVar("s_voice_volume", va("%f",value) );
- }
- else if(!Q_stricmp(type, "music") )
- {
- if(value < 0.1f)
- value = 0.0f;
- DC->setCVar("s_music_volume", va("%f",value) );
- }
- else if(!Q_stricmp(type, "horizontal") )
- {
- DC->setCVar("sensitivity", va("%f",value*10.0f) );
- }
- else if(!Q_stricmp(type, "vertical") )
- {
- DC->setCVar("sensitivityY", va("%f",value*10.0f) );
- }
- }
- static float _UI_GetVol(const char* type)
- {
- if(!Q_stricmp(type, "effects") )
- {
- return DC->getCVarValue("s_effects_volume");
- }
- else if(!Q_stricmp(type, "voice") )
- {
- return DC->getCVarValue("s_voice_volume");
- }
- else if(!Q_stricmp(type, "music") )
- {
- return DC->getCVarValue("s_music_volume");
- }
- else if(!Q_stricmp(type, "horizontal") )
- {
- return DC->getCVarValue("sensitivity") / 10.0f;
- }
- else if(!Q_stricmp(type, "vertical") )
- {
- return DC->getCVarValue("sensitivityY") / 10.0f;
- }
- return 1.0f;
- }
- static void UI_UpdateVolume(const char* action, const char* type, const char* itemName, int width, int value )
- {
- itemDef_s* mask;
- menuDef_t* menu;
- int amount;
- // get the current menu
- menu = Menu_GetFocused();
- if (!menu)
- {
- return;
- }
- // get the masking item to change
- mask = (itemDef_s*) Menu_FindItemByName(menu, itemName );
- // figure out what to do
- if(!Q_stricmp(action, "set") ) // set the volume level
- {
- amount = value;
- }
- else if(!Q_stricmp(action, "actual") )
- {
- float mult;
- // get the requested volume
- mult = _UI_GetVol(type);
- // set the mask
- mask->window.rect.w = (int)(mult * width);
-
- return;
- }
- else if(!Q_stricmp(action, "increment") ) // increment the volume level
- {
- amount = mask->window.rect.w + value;
- }
- else if(!Q_stricmp(action, "decrement") ) // decrement the volume level
- {
- amount = mask->window.rect.w - value;
- }
- // make sure we're in bounds
- if(amount <= width && amount >= 0)
- {
- float volume;
- // compute the volume
- volume = (float)amount / (float)width;
- // alter the mask
- mask->window.rect.w = amount;
- // update the volume
- _UI_SetVol(type, volume);
- }
- }
- /*
- ==========
- UI_UpdateMoveTitles()
- ==========
- */
- static void UI_UpdateMoveTitles(void)
- {
- itemDef_t *item;
- menuDef_t *menu;
- modelDef_t *modelPtr;
- uiInfo.movesTitleIndex = (short)DC->getCVarValue("ui_move_title");
- if(uiInfo.movesTitleIndex > 5 || uiInfo.movesTitleIndex < 0)
- uiInfo.movesTitleIndex = 0;
- uiInfo.movesBaseAnim = datapadMoveTitleBaseAnims[uiInfo.movesTitleIndex];
- menu = Menus_FindByName("datapadMovesMenu");
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- modelPtr = (modelDef_t*)item->typeData;
- if (modelPtr)
- {
- ItemParse_model_g2anim_go( item, uiInfo.movesBaseAnim );
- uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
- }
- }
- }
- }
- /*
- ==========
- UI_UpdateMoves()
- ==========
- */
- static void UI_UpdateMoves( void )
- {
- itemDef_t *item;
- menuDef_t *menu;
- modelDef_t *modelPtr;
- char skin[MAX_QPATH];
- uiInfo.movesTitleIndex = (short)DC->getCVarValue("ui_move_title");
- if(uiInfo.movesTitleIndex > 5 || uiInfo.movesTitleIndex < 0)
- uiInfo.movesTitleIndex = 0;
- short index = (short)DC->getCVarValue("ui_moves");
- if(index > 15 || index < 0)
- index = 0;
- menu = Menus_FindByName("datapadMovesMenu");
- if (menu)
- {
- item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, "character");
- if (item)
- {
- modelPtr = (modelDef_t*)item->typeData;
- if (modelPtr)
- {
- if (datapadMoveData[uiInfo.movesTitleIndex][index].anim)
- {
- ItemParse_model_g2anim_go( item, datapadMoveData[uiInfo.movesTitleIndex][index].anim );
- uiInfo.moveAnimTime = DC->g2hilev_SetAnim(&item->ghoul2[0], "model_root", modelPtr->g2anim, qtrue);
- uiInfo.moveAnimTime += uiInfo.uiDC.realTime;
- // Play sound for anim
- if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_FORCE_JUMP)
- {
- DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveJumpSound, CHAN_LOCAL );
- }
- else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_ROLL)
- {
- DC->startLocalSound(uiInfo.uiDC.Assets.datapadmoveRollSound, CHAN_LOCAL );
- }
- else if (datapadMoveData[uiInfo.movesTitleIndex][index].sound == MDS_SABER)
- {
- // Randomly choose one sound
- int soundI = Q_irand( 1, 6 );
- sfxHandle_t *soundPtr;
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound1;
- if (soundI == 2)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound2;
- }
- else if (soundI == 3)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound3;
- }
- else if (soundI == 4)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound4;
- }
- else if (soundI == 5)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound5;
- }
- else if (soundI == 6)
- {
- soundPtr = &uiInfo.uiDC.Assets.datapadmoveSaberSound6;
- }
- DC->startLocalSound(*soundPtr, CHAN_LOCAL );
- }
- if (datapadMoveData[uiInfo.movesTitleIndex][index].desc)
- {
- Cvar_Set( "ui_move_desc", datapadMoveData[uiInfo.movesTitleIndex][index].desc);
- }
- Com_sprintf( skin, sizeof( skin ), "models/players/%s/|%s|%s|%s",
- Cvar_VariableString ( "g_char_model"),
- Cvar_VariableString ( "g_char_skin_head"),
- Cvar_VariableString ( "g_char_skin_torso"),
- Cvar_VariableString ( "g_char_skin_legs")
- );
- ItemParse_model_g2skin_go( item, skin );
- }
- }
- }
- }
- }
- #endif
- //JLF error popup
- // What popup is active at the moment?
- static xbErrorPopupType sPopup = XB_POPUP_NONE;
- // Creates the requested popup, then displays it.
- // Establishes context so proper action will be taken on a selection.
- void UI_xboxErrorPopup(xbErrorPopupType popup)
- {
- // Set our context
- //store all these values
- /*
- DC->setCVar("ui_showWbtsel", "0");
- DC->setCVar("ui_showWmove", "0");
- DC->setCVar("ui_showXadv", "0");
- DC->setCVar("ui_showXNew", "0");
- DC->setCVar("ui_showXchk", "0");
- DC->setCVar("ui_showXforce", "0");
- DC->setCVar("ui_showXcstm", "0");
- DC->setCVar("ui_showYref", "0");
- DC->setCVar("ui_showYdel", "0");
- DC->setCVar("ui_showYbtrule", "0");
- DC->setCVar("ui_showYsaber", "0");
- DC->setCVar("ui_showYwpn", "0");
- DC->setCVar("ui_showAcallout", "0");
- DC->setCVar("ui_showBcallout", "0");
-
- */
- sPopup = popup;
- Cvar_Set( "xb_errMessage", "" );
- Cvar_Set( "xb_PopupTitle", "" );
- // Cvar_Set( "xb_PopupStringX", "" );
- // Set the menu cvars
- switch( popup )
- {
- case XB_POPUP_DELETE_CONFIRM:
- Cvar_Set( "xb_errMessage", "@MENUS_DELETE_SAVE_PROMPT" );
- Cvar_Set( "xb_PopupTitle", "" );
- break;
-
- case XB_POPUP_DISKFULL:
- Cvar_Set( "xb_errMessage", va( SE_GetString("MENUS_NO_SPACE_PLEASE_FREE"), blocksNeeded ) );
- break;
- case XB_POPUP_DISKFULL_DURING_SAVE:
- Cvar_Set( "xb_errMessage", "@MENUS_NO_SPACE" );
- break;
- case XB_POPUP_YOU_ARE_DEAD:
- Cvar_Set( "xb_errMessage", "@MENUS_SAVE_WHEN_DEAD");
- break;
- case XB_POPUP_SAVE_COMPLETE:
- Cvar_Set( "xb_errMessage", "@MENUS_SAVE_GAME_COMPLETE" );
- Cvar_Set( "xb_PopupTitle", "" );
- break;
- case XB_POPUP_OVERWRITE_CONFIRM:
- Cvar_Set( "xb_errMessage", "@MENUS_OVERWRITE_PROMPT" );
- Cvar_Set( "xb_PopupTitle", "" );
- break;
- case XB_POPUP_LOAD_FAILED:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_DAMAGED_SAVE" );
- }
- break;
- case XB_POPUP_LOAD_CHECKPOINT_FAILED:
- { char messagebuffer[128];
-
- strcpy (messagebuffer,SE_GetString("MENUS_NO_LOAD_1"));
- strcat (messagebuffer, " ");
- strcat (messagebuffer, SE_GetString("MENUS_CHECKPOINT_LOWER"));
- strcat (messagebuffer, " ");
- strcat (messagebuffer,SE_GetString("MENUS_NO_LOAD_2"));
- Cvar_Set( "xb_errMessage", messagebuffer );
- Cvar_Set( "xb_PopupTitle", "" );
- }
- break;
- case XB_POPUP_QUIT_CONFIRM:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_QUIT_CURRENT_GAME_AND");
- Cvar_Set( "xb_PopupTitle", "@MENUS_QUIT" );
- }
- break;
- case XB_POPUP_SAVING:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_SAVING");
- }
- break;
- case XB_POPUP_LOAD_CONFIRM:
- {
- if ( svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
- {
- // player dead
- Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM2");
- }
- else
- {
- Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM");
- }
- }
- break;
- case XB_POPUP_LOAD_CONFIRM_CHECKPOINT:
- {
- if ( svs.clients[0].frames[svs.clients[0].netchan.outgoingSequence & PACKET_MASK].ps.stats[STAT_HEALTH] <= 0)
- {
- // player dead
- Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM2");
- }
- else
- {
- Cvar_Set( "xb_errMessage", "@MENUS_LOAD_CONFIRM");
- }
- break;
- }
- case XB_POPUP_TOO_MANY_SAVES:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_TOO_MANY_SAVES");
- }
- break;
- case XB_POPUP_CONFIRM_INVITE:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_CONFIRM_JOIN" );
- break;
- }
- case XB_POPUP_CORRUPT_SETTINGS:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_CORRUPT_SETTINGS" );
- break;
- }
- case XB_POPUP_DISKFULL_BOTH:
- {
- Cvar_Set( "xb_errMessage", va( SE_GetString("MENUS_NO_SPACE_PLEASE_FREE"), blocksNeeded ) );
- break;
- }
- case XB_POPUP_TESTING_SAVE:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_LOADING_SAVEGAME" );
- break;
- }
- case XB_POPUP_CORRUPT_SCREENSHOT:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_CORRUPT_SCREENSHOT" );
- break;
- }
- case XB_POPUP_CONFIRM_NEW_1:
- case XB_POPUP_CONFIRM_NEW_2:
- case XB_POPUP_CONFIRM_NEW_3:
- {
- Cvar_Set( "xb_errMessage", "@MENUS_CONFIRM_NEW_MISSION" );
- break;
- }
- default:
- Com_Error( ERR_FATAL, "ERROR: Invalid popup type %i\n", popup );
- }
- // Display the menu - but first make sure to close it, in case it's open.
- // Fixes a bug where openMenuCount gets screwed up.
- Menus_CloseByName( "xbox_error_popup" );
- Menus_ActivateByName( "xbox_error_popup" );
- }
- extern unsigned long getGameBlocks(char * filename);
- // Accepts a response to the currently dislpayed popup.
- // Does whatever is necessary based on which popup was visible, and what the response was.
- void UI_xboxPopupResponse( void )
- {
- if( sPopup == XB_POPUP_NONE )
- Com_Error( ERR_FATAL, "ERROR: Got a popup response with no valid context\n" );
- int response = Cvar_VariableIntegerValue( "xb_errResponse" );
- if(response == 2)
- return;
- switch( sPopup )
- {
- case XB_POPUP_DELETE_CONFIRM:
- if( response == 0 ) // A
- {
- Menus_CloseByName( "xbox_error_popup" );
- ui_DeleteGame();
- }
- else if( response == 1 ) // B
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- break;
- case XB_POPUP_DISKFULL:
- if( response == 0 ) // A continue
- {
- // Continue without saving
- Menus_CloseByName( "xbox_error_popup" );
- XB_Startup( STARTUP_INVITE_CHECK );
- return;
- }
- else if( response == 1 ) // B
- {
- openDashBoardMemory();
- }
- break;
- case XB_POPUP_DISKFULL_DURING_SAVE:
- if( response == 0 ) // A continue
- {
- // Continue (without saving)
- Menus_CloseByName( "xbox_error_popup" );
- }
- else if( response == 1 ) // B
- {
- return;
- }
- break;
- case XB_POPUP_YOU_ARE_DEAD:
- if( response == 0)
- {
- // Continue without saving
- Menus_CloseByName( "xbox_error_popup" );
- }
- else
- {
- return;
- }
- break;
- case XB_POPUP_SAVE_COMPLETE :
- if( response == 0 ) // A continue
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- else
- {
- return;
- }
- break;
- case XB_POPUP_OVERWRITE_CONFIRM:
- if( response == 0 ) // A
- {
- unsigned long blocks;
- unsigned long gameblocks;
- blocks = SG_BlocksLeft();
- if ( blocks < SG_SaveGameSize())
- {
- //read the blocks out of the game?
- //gameblocks = getGameBlocks(s_savedata[s_savegame.currentLine].currentSaveFileName);
- // if ( blocks + gameblocks >= SG_SaveGameSize())
- {
- itemDef_t item;
- item.parent = Menu_GetFocused();
- item.window.flags = 0; //err, item is fake here, but we want a valid flag before calling runscript
- Item_RunScript( &item, "uiscript genericpopup saving ; delay 1 ; uiScript deletegame ; uiScript savegame ; defer always ; close xbox_error_popup ; uiScript genericpopup savecomplete" );
- return;
- // UI_xboxErrorPopup(XB_POPUP_DISKFULL);
- }
- // else
- // {
- // Menus_CloseByName( "xbox_error_popup" );
- // UI_xboxErrorPopup(XB_POPUP_DISKFULL);
- // return;
- // }
- }
- else
- {
- itemDef_t item;
- item.parent = Menu_GetFocused();
- item.window.flags = 0; //err, item is fake here, but we want a valid flag before calling runscript
- Item_RunScript( &item, "uiscript genericpopup saving ; delay 1 ; uiScript deletegame ; uiScript savegame ; defer always ; close xbox_error_popup ; uiScript genericpopup savecomplete" );
- return;
- //DELETE
- // ui_DeleteGame();
- //SAVE
- // ui_SaveGame();
- // //call to show save success
- }
- // Menus_CloseByName( "xbox_error_popup" );
-
- }
- else if( response == 1 ) // B
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- break;
-
- case XB_POPUP_LOAD_FAILED:
- if( response == 0 ) // A continue
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- else
- {
- return;
- }
- break;
- case XB_POPUP_LOAD_CHECKPOINT_FAILED:
- if( response == 0 ) // A continue
- {
-
- if ( cls.state == CA_ACTIVE )
- {
- Menus_CloseAll();
- UI_SetActiveMenu( "ingame",NULL );
- }
- else
- Menus_CloseByName( "xbox_error_popup" );
-
- }
- else
- {
- return;
- }
- break;
- case XB_POPUP_QUIT_CONFIRM:
- if( response == 0 ) // A continue
- {
- Cbuf_ExecuteText( EXEC_APPEND, "disconnect\n" );
- trap_Key_SetCatcher( KEYCATCH_UI );
- Menus_CloseAll();
- }
- else
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- break;
- case XB_POPUP_SAVING:
- return;
- case XB_POPUP_LOAD_CONFIRM:
- if( response == 0 ) // A continue
- {
- itemDef_t item;
- item.parent = Menu_GetFocused();
- item.window.flags = 0; //err, item is fake here, but we want a valid flag before calling runscript
- Item_RunScript( &item, "uiscript loadgame" );
- return;
- }
- else
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- break;
- case XB_POPUP_LOAD_CONFIRM_CHECKPOINT:
- if( response == 0 )
- {
- // Hackery
- Menus_CloseByName( "xbox_error_popup" );
- UI_xboxErrorPopup( XB_POPUP_TESTING_SAVE );
- ui.Cmd_ExecuteText(EXEC_APPEND,"wait ; wait ; wait ; wait ; load *respawn\n");
- return;
- }
- else
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- break;
- case XB_POPUP_TOO_MANY_SAVES:
- if(response == 0)
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- else
- {
- return;
- }
- break;
- case XB_POPUP_CONFIRM_INVITE:
- if( response == 0 ) // A - join game
- {
- // Never returns
- extern void Sys_JoinInvite( void );
- Sys_JoinInvite();
- }
- else
- {
- Menus_CloseByName( "xbox_error_popup" );
- XB_Startup( STARTUP_FINISH );
- return;
- }
-
- case XB_POPUP_CORRUPT_SETTINGS:
- if( response == 0 ) // A - accept
- {
- Settings.Delete();
- Menus_CloseByName( "xbox_error_popup" );
- XB_Startup( STARTUP_COMBINED_SPACE_CHECK );
- return;
- }
- else
- {
- return;
- }
- case XB_POPUP_DISKFULL_BOTH:
- if( response == 0 )
- {
- // Continue without saving
- Settings.Disable();
- Menus_CloseByName( "xbox_error_popup" );
- XB_Startup( STARTUP_INVITE_CHECK );
- return;
- }
- else
- {
- // Go to dashboard to free up memory
- openDashBoardMemory();
- }
- case XB_POPUP_TESTING_SAVE:
- // No response is valid, this is just informational while the save is read/checked
- return;
- case XB_POPUP_CORRUPT_SCREENSHOT:
- if( response == 0 ) // A - continue
- {
- Menus_CloseByName( "xbox_error_popup" );
- break;
- }
- else
- {
- // Invalid response
- return;
- }
- case XB_POPUP_CONFIRM_NEW_1:
- case XB_POPUP_CONFIRM_NEW_2:
- case XB_POPUP_CONFIRM_NEW_3:
- if( response == 0 ) // A - continue
- {
- Cvar_SetValue( "cl_paused", 1 );
- UI_DecrementForcePowerLevel();
- Menus_CloseAll();
- Menus_OpenByName( va("ingameMissionSelect%d", (sPopup - XB_POPUP_CONFIRM_NEW_1) + 1) );
- }
- else
- {
- Menus_CloseByName( "xbox_error_popup" );
- }
- break;
- default:
- Com_Error( ERR_FATAL, "ERROR: Invalid popup type %i\n", sPopup );
- }
- // If we get here, the user gave a valid response to our popup. Clear the context:
- sPopup = XB_POPUP_NONE;
- }
|