Interface Items.c 215 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348
  1. #ifdef PRECOMPILEDHEADERS
  2. #include "Tactical All.h"
  3. #include "language defines.h"
  4. #else
  5. #include <stdio.h>
  6. #include <stdarg.h>
  7. #include <time.h>
  8. #include "sgp.h"
  9. #include "gameloop.h"
  10. #include "himage.h"
  11. #include "vobject.h"
  12. #include "sysutil.h"
  13. #include "overhead.h"
  14. #include "mousesystem.h"
  15. #include "Button System.h"
  16. #include "interface.h"
  17. #include "vsurface.h"
  18. #include "wcheck.h"
  19. #include "input.h"
  20. #include "Handle UI.h"
  21. #include "renderworld.h"
  22. #include "sys globals.h"
  23. #include "cursors.h"
  24. #include "radar screen.h"
  25. #include "worldman.h"
  26. #include "Font Control.h"
  27. #include "render dirty.h"
  28. #include "utilities.h"
  29. #include "Sound Control.h"
  30. #include "Interface Panels.h"
  31. #include "Animation Control.h"
  32. #include "Soldier Control.h"
  33. #include "pathai.h"
  34. #include "weapons.h"
  35. #include "lighting.h"
  36. #include "faces.h"
  37. #include "mapscreen.h"
  38. #include "message.h"
  39. #include "text.h"
  40. #include "Interface Items.h"
  41. #include "Font Control.h"
  42. #include "Cursor Control.h"
  43. #include "interface cursors.h"
  44. #include "interface utils.h"
  45. #include "interface items.h"
  46. #include "wordwrap.h"
  47. #include "interface control.h"
  48. #include "vobject_blitters.h"
  49. #include "world items.h"
  50. #include "points.h"
  51. #include "physics.h"
  52. #include "finances.h"
  53. #include "ui cursors.h"
  54. #include "handle ui.h"
  55. #include "ShopKeeper Interface.h"
  56. #include "dialogue control.h"
  57. #include "english.h"
  58. #include "keys.h"
  59. #include "Strategicmap.h"
  60. #include "Arms Dealer Init.h"
  61. #include "soldier macros.h"
  62. #include "game clock.h"
  63. #include "squads.h"
  64. #include "LaptopSave.h"
  65. #include "MessageBoxScreen.h"
  66. #include "Language Defines.h"
  67. #include "GameSettings.h"
  68. #endif
  69. #define ITEMDESC_FONT BLOCKFONT2
  70. #define ITEMDESC_FONTSHADOW1 MILITARY_SHADOW
  71. #define ITEMDESC_FONTSHADOW2 32
  72. #define ITEMDESC_FONTSHADOW3 34
  73. #define ITEMDESC_FONTFORE1 33
  74. #define ITEMDESC_FONTFORE2 32
  75. #define ITEMDESC_FONTAPFORE 218
  76. #define ITEMDESC_FONTHPFORE 24
  77. #define ITEMDESC_FONTBSFORE 125
  78. #define ITEMDESC_FONTHEFORE 75
  79. #define ITEMDESC_FONTHEAPFORE 76
  80. #define ITEMDESC_AMMO_FORE 209
  81. #define ITEMDESC_FONTHIGHLIGHT FONT_MCOLOR_WHITE
  82. #define STATUS_BAR_SHADOW FROMRGB( 140, 136, 119 )
  83. #define STATUS_BAR FROMRGB( 201, 172, 133 )
  84. #define DESC_STATUS_BAR_SHADOW STATUS_BAR_SHADOW
  85. #define DESC_STATUS_BAR STATUS_BAR
  86. #define MIN_LOB_RANGE 4
  87. #define INV_BAR_DX 5
  88. #define INV_BAR_DY 21
  89. #define RENDER_ITEM_NOSTATUS 20
  90. #define RENDER_ITEM_ATTACHMENT1 200
  91. #define ITEM_STATS_WIDTH 26
  92. #define ITEM_STATS_HEIGHT 8
  93. #define ITEMDESC_START_X 214
  94. #define ITEMDESC_START_Y 1 + INV_INTERFACE_START_Y
  95. #define ITEMDESC_HEIGHT 133
  96. #define ITEMDESC_WIDTH 320
  97. #define MAP_ITEMDESC_HEIGHT 268
  98. #define MAP_ITEMDESC_WIDTH 272
  99. #define ITEMDESC_NAME_X (16 + gsInvDescX)
  100. #define ITEMDESC_NAME_Y (67 + gsInvDescY)
  101. #define ITEMDESC_CALIBER_X (162 + gsInvDescX)
  102. #define ITEMDESC_CALIBER_Y (67 + gsInvDescY)
  103. #define ITEMDESC_CALIBER_WIDTH 142
  104. #define MAP_ITEMDESC_CALIBER_X (105 + gsInvDescX)
  105. #define MAP_ITEMDESC_CALIBER_Y (66 + gsInvDescY)
  106. #define MAP_ITEMDESC_CALIBER_WIDTH 149
  107. #define ITEMDESC_ITEM_X (8 + gsInvDescX)
  108. #define ITEMDESC_ITEM_Y (11 + gsInvDescY)
  109. #define CAMO_REGION_HEIGHT 75
  110. #define CAMO_REGION_WIDTH 75
  111. #define BULLET_SING_X (222 + gsInvDescX)
  112. #define BULLET_SING_Y (49 + gsInvDescY)
  113. #define BULLET_BURST_X (263 + gsInvDescX)
  114. #define BULLET_BURST_Y (49 + gsInvDescY)
  115. #define BULLET_WIDTH 3
  116. #define BULLET_GAP 5
  117. #define MAP_BULLET_SING_X (77 + gsInvDescX)
  118. #define MAP_BULLET_SING_Y (135 + gsInvDescY)
  119. #define MAP_BULLET_BURST_X (117 + gsInvDescX)
  120. #define MAP_BULLET_BURST_Y (135 + gsInvDescY)
  121. #define MAP_ITEMDESC_NAME_X (7 + gsInvDescX)
  122. #define MAP_ITEMDESC_NAME_Y (65 + gsInvDescY)
  123. #define MAP_ITEMDESC_ITEM_X (25 + gsInvDescX)
  124. #define MAP_ITEMDESC_ITEM_Y (6 + gsInvDescY)
  125. #define ITEMDESC_DESC_START_X (11 + gsInvDescX)
  126. #define ITEMDESC_DESC_START_Y (80 + gsInvDescY)
  127. #define ITEMDESC_PROS_START_X ( 11 + gsInvDescX )
  128. #define ITEMDESC_PROS_START_Y (110 + gsInvDescY)
  129. #define ITEMDESC_CONS_START_X ( 11 + gsInvDescX )
  130. #define ITEMDESC_CONS_START_Y (120 + gsInvDescY)
  131. #define ITEMDESC_ITEM_STATUS_X ( 6 + gsInvDescX )
  132. #define ITEMDESC_ITEM_STATUS_Y ( 60 + gsInvDescY )
  133. #define DOTDOTDOT L"..."
  134. #define COMMA_AND_SPACE L", "
  135. #define ITEM_PROS_AND_CONS( usItem ) ( ( Item[ usItem ].usItemClass & IC_GUN) )
  136. #define MAP_ITEMDESC_DESC_START_X ( 23 + gsInvDescX )
  137. #define MAP_ITEMDESC_DESC_START_Y (170 + gsInvDescY)
  138. #define MAP_ITEMDESC_PROS_START_X ( 23 + gsInvDescX )
  139. #define MAP_ITEMDESC_PROS_START_Y (230 + gsInvDescY)
  140. #define MAP_ITEMDESC_CONS_START_X ( 23 + gsInvDescX )
  141. #define MAP_ITEMDESC_CONS_START_Y (240 + gsInvDescY)
  142. #define MAP_ITEMDESC_ITEM_STATUS_X ( 18 + gsInvDescX )
  143. #define MAP_ITEMDESC_ITEM_STATUS_Y ( 53 + gsInvDescY )
  144. #define ITEMDESC_ITEM_STATUS_WIDTH 2
  145. #define ITEMDESC_ITEM_STATUS_HEIGHT 50
  146. #define ITEMDESC_ITEM_STATUS_HEIGHT_MAP 40
  147. #define ITEMDESC_DESC_WIDTH 301
  148. #define MAP_ITEMDESC_DESC_WIDTH 220
  149. #define ITEMDESC_ITEM_WIDTH 117
  150. #define ITEMDESC_ITEM_HEIGHT 54
  151. #define ITEMDESC_AMMO_X ( 10 + gsInvDescX )
  152. #define ITEMDESC_AMMO_Y ( 50 + gsInvDescY )
  153. #define MAP_ITEMDESC_AMMO_X ( 28 + gsInvDescX )
  154. #define MAP_ITEMDESC_AMMO_Y ( 45 + gsInvDescY )
  155. #define ITEMDESC_AMMO_TEXT_X 3
  156. #define ITEMDESC_AMMO_TEXT_Y 1
  157. #define ITEMDESC_AMMO_TEXT_WIDTH 31
  158. #define WORD_WRAP_INV_WIDTH 58
  159. #define ITEM_BAR_WIDTH 2
  160. #define ITEM_BAR_HEIGHT 20
  161. #define ITEM_FONT TINYFONT1
  162. #define EXCEPTIONAL_DAMAGE 30
  163. #define EXCEPTIONAL_WEIGHT 20
  164. #define EXCEPTIONAL_RANGE 300
  165. #define EXCEPTIONAL_MAGAZINE 30
  166. #define EXCEPTIONAL_AP_COST 7
  167. #define EXCEPTIONAL_BURST_SIZE 5
  168. #define EXCEPTIONAL_RELIABILITY 2
  169. #define EXCEPTIONAL_REPAIR_EASE 2
  170. #define BAD_DAMAGE 23
  171. #define BAD_WEIGHT 45
  172. #define BAD_RANGE 150
  173. #define BAD_MAGAZINE 10
  174. #define BAD_AP_COST 11
  175. #define BAD_RELIABILITY -2
  176. #define BAD_REPAIR_EASE -2
  177. #define KEYRING_X 487
  178. #define KEYRING_Y 445
  179. #define MAP_KEYRING_X 217
  180. #define MAP_KEYRING_Y 271
  181. #define KEYRING_WIDTH 517 - 487
  182. #define KEYRING_HEIGHT 469 - 445
  183. #define TACTICAL_INVENTORY_KEYRING_GRAPHIC_OFFSET_X 215
  184. //enum used for the money buttons
  185. enum
  186. {
  187. M_1000,
  188. M_100,
  189. M_10,
  190. M_DONE,
  191. };
  192. // AN ARRAY OF MOUSE REGIONS, ONE FOR EACH OBJECT POSITION ON BUDDY
  193. MOUSE_REGION gInvRegions[ NUM_INV_SLOTS ];
  194. extern MOUSE_REGION gMPanelRegion;
  195. extern BOOLEAN fMapInventoryItem;
  196. extern BOOLEAN gfAddingMoneyToMercFromPlayersAccount;
  197. extern SOLDIERTYPE *gpSMCurrentMerc;
  198. extern UINT8 gubSelectSMPanelToMerc;
  199. extern MOUSE_REGION gSM_SELMERCMoneyRegion;
  200. extern UINT32 guiMapInvSecondHandBlockout;
  201. MOUSE_REGION gInvDesc;
  202. OBJECTTYPE *gpItemPointer = NULL;
  203. OBJECTTYPE gItemPointer;
  204. BOOLEAN gfItemPointerDifferentThanDefault = FALSE;
  205. SOLDIERTYPE *gpItemPointerSoldier;
  206. INT8 gbItemPointerSrcSlot;
  207. UINT16 gusItemPointer = 255;
  208. UINT16 usItemSnapCursor;
  209. UINT32 guiNewlyPlacedItemTimer = 0;
  210. BOOLEAN gfBadThrowItemCTGH;
  211. BOOLEAN gfDontChargeAPsToPickup = FALSE;
  212. BOOLEAN gbItemPointerLocateGood = FALSE;
  213. // ITEM DESCRIPTION BOX STUFF
  214. UINT32 guiItemDescBox;
  215. UINT32 guiMapItemDescBox;
  216. UINT32 guiItemGraphic;
  217. UINT32 guiMoneyGraphicsForDescBox;
  218. UINT32 guiBullet;
  219. BOOLEAN gfInItemDescBox = FALSE;
  220. UINT32 guiCurrentItemDescriptionScreen=0;
  221. OBJECTTYPE *gpItemDescObject = NULL;
  222. BOOLEAN gfItemDescObjectIsAttachment = FALSE;
  223. UINT16 gzItemName[ SIZE_ITEM_NAME ];
  224. UINT16 gzItemDesc[ SIZE_ITEM_INFO ];
  225. UINT16 gzItemPros[ SIZE_ITEM_PROS ];
  226. UINT16 gzItemCons[ SIZE_ITEM_CONS ];
  227. UINT16 gzFullItemPros[ SIZE_ITEM_PROS ];
  228. UINT16 gzFullItemCons[ SIZE_ITEM_PROS ];
  229. UINT16 gzFullItemTemp[ SIZE_ITEM_PROS ]; // necessary, unfortunately
  230. void ItemDescCallback( MOUSE_REGION * pRegion, INT32 iReason );
  231. INT16 gsInvDescX;
  232. INT16 gsInvDescY;
  233. UINT8 gubItemDescStatusIndex;
  234. INT32 giItemDescAmmoButtonImages;
  235. INT32 giItemDescAmmoButton;
  236. BOOLEAN gfItemAmmoDown = FALSE;
  237. SOLDIERTYPE *gpItemDescSoldier;
  238. BOOLEAN fItemDescDelete = FALSE;
  239. MOUSE_REGION gItemDescAttachmentRegions[4];
  240. MOUSE_REGION gProsAndConsRegions[2];
  241. void BtnMoneyButtonCallback(GUI_BUTTON *btn,INT32 reason);
  242. UINT32 guiMoneyButtonBtn[MAX_ATTACHMENTS];
  243. INT32 guiMoneyButtonImage;
  244. INT32 guiMoneyDoneButtonImage;
  245. UINT16 gusOriginalAttachItem[ MAX_ATTACHMENTS ];
  246. UINT8 gbOriginalAttachStatus[ MAX_ATTACHMENTS ];
  247. SOLDIERTYPE * gpAttachSoldier;
  248. extern BOOLEAN gfSMDisableForItems;
  249. typedef struct
  250. {
  251. UINT16 x;
  252. UINT16 y;
  253. } MoneyLoc;
  254. MoneyLoc gMoneyButtonLoc = { 343, 351 };
  255. MoneyLoc gMoneyButtonOffsets[] = { 0,0, 34,0, 0,32, 34,32, 8,22 };
  256. MoneyLoc gMapMoneyButtonLoc = { 174, 115 };
  257. // show the description
  258. extern BOOLEAN fShowDescriptionFlag;
  259. extern BOOLEAN fShowInventoryFlag;
  260. void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason );
  261. void ItemDescAmmoCallback(GUI_BUTTON *btn,INT32 reason);
  262. // number of keys on keyring, temp for now
  263. #define NUMBER_KEYS_ON_KEYRING 28
  264. #define KEY_RING_ROW_WIDTH 7
  265. #define MAP_KEY_RING_ROW_WIDTH 4
  266. // ITEM STACK POPUP STUFF
  267. BOOLEAN gfInItemStackPopup = FALSE;
  268. UINT32 guiItemPopupBoxes;
  269. OBJECTTYPE *gpItemPopupObject;
  270. INT16 gsItemPopupWidth;
  271. INT16 gsItemPopupHeight;
  272. INT16 gsItemPopupX;
  273. INT16 gsItemPopupY;
  274. MOUSE_REGION gItemPopupRegions[8];
  275. MOUSE_REGION gKeyRingRegions[ NUMBER_KEYS_ON_KEYRING ];
  276. BOOLEAN gfInKeyRingPopup = FALSE;
  277. UINT8 gubNumItemPopups = 0;
  278. MOUSE_REGION gItemPopupRegion;
  279. INT16 gsItemPopupInvX;
  280. INT16 gsItemPopupInvY;
  281. INT16 gsItemPopupInvWidth;
  282. INT16 gsItemPopupInvHeight;
  283. INT16 gsKeyRingPopupInvX;
  284. INT16 gsKeyRingPopupInvY;
  285. INT16 gsKeyRingPopupInvWidth;
  286. INT16 gsKeyRingPopupInvHeight;
  287. SOLDIERTYPE *gpItemPopupSoldier;
  288. extern BOOLEAN fMapScreenBottomDirty;
  289. // inventory description done button for mapscreen
  290. INT32 giMapInvDescButtonImage;
  291. INT32 giMapInvDescButton = -1;
  292. // the done descrition button callback
  293. void ItemDescDoneButtonCallback( GUI_BUTTON *btn, INT32 reason );
  294. extern BOOLEAN fMapInventoryItem;
  295. BOOLEAN gfItemPopupRegionCallbackEndFix = FALSE;
  296. extern void InternalMAPBeginItemPointer( SOLDIERTYPE *pSoldier );
  297. void ItemPopupRegionCallback( MOUSE_REGION * pRegion, INT32 iReason );
  298. void ItemPopupFullRegionCallback( MOUSE_REGION * pRegion, INT32 iReason );
  299. BOOLEAN ReloadItemDesc( );
  300. extern void HelpTextDoneCallback( void );
  301. void RemoveMoney();
  302. BOOLEAN CompatibleItemForApplyingOnMerc( OBJECTTYPE *pTestObject );
  303. extern BOOLEAN MAPInternalInitItemDescriptionBox( OBJECTTYPE *pObject, UINT8 ubStatusIndex, SOLDIERTYPE *pSoldier );
  304. extern void StartSKIDescriptionBox( void );
  305. void UpdateItemHatches();
  306. UINT8 ubRGBItemCyclePlacedItemColors[] =
  307. {
  308. 25, 25, 25,
  309. 50, 50, 50,
  310. 75, 75, 75,
  311. 100, 100, 100,
  312. 125, 125, 125,
  313. 150, 150, 150,
  314. 175, 175, 175,
  315. 200, 200, 200,
  316. 225, 225, 225,
  317. 250, 250, 250,
  318. 250, 250, 250,
  319. 225, 225, 225,
  320. 200, 200, 200,
  321. 175, 175, 175,
  322. 150, 150, 150,
  323. 125, 125, 125,
  324. 100, 100, 100,
  325. 75, 75, 75,
  326. 50, 50, 50,
  327. 25, 25, 25
  328. };
  329. typedef struct
  330. {
  331. INT16 sX;
  332. INT16 sY;
  333. INT16 sValDx;
  334. } INV_DESC_STATS;
  335. typedef struct
  336. {
  337. INT16 sX;
  338. INT16 sY;
  339. INT16 sHeight;
  340. INT16 sWidth;
  341. INT16 sBarDx;
  342. INT16 sBarDy;
  343. } INV_ATTACHXY;
  344. #define NUM_INV_HELPTEXT_ENTRIES 1
  345. typedef struct
  346. {
  347. INT32 iXPosition[NUM_INV_HELPTEXT_ENTRIES];
  348. INT32 iYPosition[NUM_INV_HELPTEXT_ENTRIES];
  349. INT32 iWidth[NUM_INV_HELPTEXT_ENTRIES];
  350. STR16 sString1[NUM_INV_HELPTEXT_ENTRIES];
  351. STR16 sString2[NUM_INV_HELPTEXT_ENTRIES];
  352. } INV_HELPTEXT;
  353. INV_DESC_STATS gWeaponStats[] =
  354. {
  355. 202, 25, 83,
  356. 202, 15, 83,
  357. 202, 15, 83,
  358. 265, 40, 20,
  359. 202, 40, 32,
  360. 202, 50, 32,
  361. 265, 50, 20,
  362. 234, 50, 0,
  363. 290, 50, 0,
  364. };
  365. // displayed AFTER the mass/weight/"Kg" line
  366. INV_DESC_STATS gMoneyStats[] =
  367. {
  368. 202, 14, 78,
  369. 212, 25, 78,
  370. 202, 40, 78,
  371. 212, 51, 78,
  372. };
  373. // displayed AFTER the mass/weight/"Kg" line
  374. INV_DESC_STATS gMapMoneyStats[] =
  375. {
  376. 51, 97, 45,
  377. 61, 107, 75,
  378. 51, 125, 45,
  379. 61, 135, 70,
  380. };
  381. INV_DESC_STATS gMapWeaponStats[] =
  382. {
  383. 72 - 20, 20+80+8, 80,
  384. 72 - 20, 20+80-2, 80,
  385. 72 - 20, 20+80-2, 80,
  386. 72+65 - 20, 40+80+4, 21,
  387. 72 - 20, 40+80+4, 30,
  388. 72 - 20, 53+80+2, 30,
  389. 72+65 - 20, 53+80+2, 25,
  390. 86, 53+80+2, 0,
  391. 145, 53+80+2, 0,
  392. };
  393. INV_ATTACHXY gItemDescAttachmentsXY[] =
  394. {
  395. 129, 12, SM_INV_SLOT_HEIGHT, SM_INV_SLOT_WIDTH, INV_BAR_DX-1, INV_BAR_DY+1,
  396. 163, 12, SM_INV_SLOT_HEIGHT, SM_INV_SLOT_WIDTH, INV_BAR_DX-1, INV_BAR_DY+1,
  397. 129, 39, SM_INV_SLOT_HEIGHT, SM_INV_SLOT_WIDTH, INV_BAR_DX-1, INV_BAR_DY+1,
  398. 163, 39, SM_INV_SLOT_HEIGHT, SM_INV_SLOT_WIDTH, INV_BAR_DX-1, INV_BAR_DY+1
  399. };
  400. INV_ATTACHXY gMapItemDescAttachmentsXY[] =
  401. {
  402. 173, 10, SM_INV_SLOT_HEIGHT, 26, INV_BAR_DX + 2, INV_BAR_DY,
  403. 211, 10, SM_INV_SLOT_HEIGHT, 26, INV_BAR_DX + 2, INV_BAR_DY,
  404. 173, 36, SM_INV_SLOT_HEIGHT, 26, INV_BAR_DX + 2, INV_BAR_DY,
  405. 211, 36, SM_INV_SLOT_HEIGHT, 26, INV_BAR_DX + 2, INV_BAR_DY
  406. };
  407. SGPRect gItemDescProsConsRects[] =
  408. {// NB the left value is calculated based on the width of the 'pros' and 'cons' labels
  409. 0, 111, 313, 118,
  410. 0, 119, 313, 126
  411. };
  412. SGPRect gMapItemDescProsConsRects[] =
  413. {
  414. 0, 231, 313, 238,
  415. 0, 239, 313, 246,
  416. };
  417. INV_HELPTEXT gItemDescHelpText =
  418. {
  419. { 69 }, // x locations
  420. { 12 }, // y locations
  421. { 170 }, // widths
  422. { Message[STR_ATTACHMENT_HELP] },
  423. { Message[STR_ATTACHMENT_INVALID_HELP] },
  424. };
  425. BOOLEAN gfItemDescHelpTextOffset = FALSE;
  426. // ARRAY FOR INV PANEL INTERFACE ITEM POSITIONS (sX,sY get set via InitInvSlotInterface() )
  427. INV_REGIONS gSMInvData[] =
  428. {
  429. FALSE, INV_BAR_DX, INV_BAR_DY, HEAD_INV_SLOT_WIDTH, HEAD_INV_SLOT_HEIGHT, 0, 0, // HELMETPOS
  430. FALSE, INV_BAR_DX, INV_BAR_DY, VEST_INV_SLOT_WIDTH, VEST_INV_SLOT_HEIGHT, 0, 0, // VESTPOS
  431. FALSE, INV_BAR_DX, INV_BAR_DY, LEGS_INV_SLOT_WIDTH, LEGS_INV_SLOT_HEIGHT, 0, 0, // LEGPOS,
  432. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // HEAD1POS
  433. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // HEAD2POS
  434. TRUE, INV_BAR_DX, INV_BAR_DY, BIG_INV_SLOT_WIDTH, BIG_INV_SLOT_HEIGHT, 0, 0, // HANDPOS,
  435. TRUE, INV_BAR_DX, INV_BAR_DY, BIG_INV_SLOT_WIDTH, BIG_INV_SLOT_HEIGHT, 0, 0, // SECONDHANDPOS
  436. TRUE, INV_BAR_DX, INV_BAR_DY, BIG_INV_SLOT_WIDTH, BIG_INV_SLOT_HEIGHT, 0, 0, // BIGPOCK1
  437. TRUE, INV_BAR_DX, INV_BAR_DY, BIG_INV_SLOT_WIDTH, BIG_INV_SLOT_HEIGHT, 0, 0, // BIGPOCK2
  438. TRUE, INV_BAR_DX, INV_BAR_DY, BIG_INV_SLOT_WIDTH, BIG_INV_SLOT_HEIGHT, 0, 0, // BIGPOCK3
  439. TRUE, INV_BAR_DX, INV_BAR_DY, BIG_INV_SLOT_WIDTH, BIG_INV_SLOT_HEIGHT, 0, 0, // BIGPOCK4
  440. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK1
  441. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK2
  442. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK3
  443. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK4
  444. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK5
  445. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK6
  446. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0, // SMALLPOCK7
  447. FALSE, INV_BAR_DX, INV_BAR_DY, SM_INV_SLOT_WIDTH, SM_INV_SLOT_HEIGHT, 0, 0 // SMALLPOCK8
  448. };
  449. typedef struct
  450. {
  451. UINT32 uiTotalAmount;
  452. UINT32 uiMoneyRemaining;
  453. UINT32 uiMoneyRemoving;
  454. } REMOVE_MONEY;
  455. REMOVE_MONEY gRemoveMoney;
  456. MOUSE_REGION gSMInvRegion[ NUM_INV_SLOTS ];
  457. MOUSE_REGION gKeyRingPanel;
  458. MOUSE_REGION gSMInvCamoRegion;
  459. INT8 gbCompatibleAmmo[ NUM_INV_SLOTS ];
  460. INT8 gbInvalidPlacementSlot[ NUM_INV_SLOTS ];
  461. UINT16 us16BPPItemCyclePlacedItemColors[ 20 ];
  462. UINT32 guiBodyInvVO[ 4 ][ 2 ];
  463. UINT32 guiGoldKeyVO;
  464. INT8 gbCompatibleApplyItem = FALSE;
  465. BOOLEAN AttemptToAddSubstring( STR16 zDest, STR16 zTemp, UINT32 * puiStringLength, UINT32 uiPixLimit )
  466. {
  467. UINT32 uiRequiredStringLength, uiTempStringLength;
  468. uiTempStringLength = StringPixLength( zTemp, ITEMDESC_FONT );
  469. uiRequiredStringLength = *puiStringLength + uiTempStringLength;
  470. if (zDest[0] != 0)
  471. {
  472. uiRequiredStringLength += StringPixLength( COMMA_AND_SPACE, ITEMDESC_FONT );
  473. }
  474. if (uiRequiredStringLength < uiPixLimit)
  475. {
  476. if (zDest[0] != 0)
  477. {
  478. wcscat( zDest, COMMA_AND_SPACE );
  479. }
  480. wcscat( zDest, zTemp );
  481. *puiStringLength = uiRequiredStringLength;
  482. return( TRUE );
  483. }
  484. else
  485. {
  486. wcscat( zDest, DOTDOTDOT );
  487. return( FALSE );
  488. }
  489. }
  490. void GenerateProsString( UINT16 * zItemPros, OBJECTTYPE * pObject, UINT32 uiPixLimit )
  491. {
  492. UINT32 uiStringLength = 0;
  493. UINT16 * zTemp;
  494. UINT16 usItem = pObject->usItem;
  495. UINT8 ubWeight;
  496. zItemPros[0] = 0;
  497. ubWeight = Item[ usItem ].ubWeight;
  498. if (Item[ usItem ].usItemClass == IC_GUN)
  499. {
  500. ubWeight += Item[ pObject->usGunAmmoItem ].ubWeight;
  501. }
  502. if (Item[usItem].ubWeight <= EXCEPTIONAL_WEIGHT)
  503. {
  504. zTemp = Message[STR_LIGHT];
  505. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  506. {
  507. return;
  508. }
  509. }
  510. if (Item[usItem].ubPerPocket >= 1) // fits in a small pocket
  511. {
  512. zTemp = Message[STR_SMALL];
  513. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  514. {
  515. return;
  516. }
  517. }
  518. if ( GunRange( pObject ) >= EXCEPTIONAL_RANGE )
  519. {
  520. zTemp = Message[STR_LONG_RANGE];
  521. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  522. {
  523. return;
  524. }
  525. }
  526. if (Weapon[usItem].ubImpact >= EXCEPTIONAL_DAMAGE)
  527. {
  528. zTemp = Message[STR_HIGH_DAMAGE];
  529. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  530. {
  531. return;
  532. }
  533. }
  534. if (BaseAPsToShootOrStab( DEFAULT_APS, DEFAULT_AIMSKILL, gpItemDescObject ) <= EXCEPTIONAL_AP_COST)
  535. {
  536. zTemp = Message[STR_QUICK_FIRING];
  537. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  538. {
  539. return;
  540. }
  541. }
  542. if (Weapon[usItem].ubShotsPerBurst >= EXCEPTIONAL_BURST_SIZE || usItem == G11)
  543. {
  544. zTemp = Message[STR_FAST_BURST];
  545. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  546. {
  547. return;
  548. }
  549. }
  550. if (Weapon[usItem].ubMagSize > EXCEPTIONAL_MAGAZINE)
  551. {
  552. zTemp = Message[STR_LARGE_AMMO_CAPACITY];
  553. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  554. {
  555. return;
  556. }
  557. }
  558. if ( Item[usItem].bReliability >= EXCEPTIONAL_RELIABILITY )
  559. {
  560. zTemp = Message[STR_RELIABLE];
  561. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  562. {
  563. return;
  564. }
  565. }
  566. if ( Item[usItem].bRepairEase >= EXCEPTIONAL_REPAIR_EASE )
  567. {
  568. zTemp = Message[STR_EASY_TO_REPAIR];
  569. if ( ! AttemptToAddSubstring( zItemPros, zTemp, &uiStringLength, uiPixLimit ) )
  570. {
  571. return;
  572. }
  573. }
  574. if ( zItemPros[0] == 0 )
  575. {
  576. // empty string, so display "None"
  577. if ( ! AttemptToAddSubstring( zItemPros, Message[ STR_NONE ], &uiStringLength, uiPixLimit ) )
  578. {
  579. return;
  580. }
  581. }
  582. }
  583. void GenerateConsString( UINT16 * zItemCons, OBJECTTYPE * pObject, UINT32 uiPixLimit )
  584. {
  585. UINT32 uiStringLength = 0;
  586. UINT16 * zTemp;
  587. UINT8 ubWeight;
  588. UINT16 usItem = pObject->usItem;
  589. zItemCons[0] = 0;
  590. // calculate the weight of the item plus ammunition but not including any attachments
  591. ubWeight = Item[ usItem ].ubWeight;
  592. if (Item[ usItem ].usItemClass == IC_GUN)
  593. {
  594. ubWeight += Item[ pObject->usGunAmmoItem ].ubWeight;
  595. }
  596. if (ubWeight >= BAD_WEIGHT)
  597. {
  598. zTemp = Message[STR_HEAVY];
  599. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  600. {
  601. return;
  602. }
  603. }
  604. if ( GunRange( pObject ) <= BAD_RANGE)
  605. {
  606. zTemp = Message[STR_SHORT_RANGE];
  607. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  608. {
  609. return;
  610. }
  611. }
  612. if (Weapon[usItem].ubImpact <= BAD_DAMAGE)
  613. {
  614. zTemp = Message[STR_LOW_DAMAGE];
  615. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  616. {
  617. return;
  618. }
  619. }
  620. if (BaseAPsToShootOrStab( DEFAULT_APS, DEFAULT_AIMSKILL, gpItemDescObject ) >= BAD_AP_COST)
  621. {
  622. zTemp = Message[STR_SLOW_FIRING];
  623. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  624. {
  625. return;
  626. }
  627. }
  628. if (Weapon[usItem].ubShotsPerBurst == 0)
  629. {
  630. zTemp = Message[STR_NO_BURST];
  631. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  632. {
  633. return;
  634. }
  635. }
  636. if (Weapon[usItem].ubMagSize < BAD_MAGAZINE)
  637. {
  638. zTemp = Message[STR_SMALL_AMMO_CAPACITY];
  639. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  640. {
  641. return;
  642. }
  643. }
  644. if ( Item[usItem].bReliability <= BAD_RELIABILITY )
  645. {
  646. zTemp = Message[STR_UNRELIABLE];
  647. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  648. {
  649. return;
  650. }
  651. }
  652. if ( Item[usItem].bRepairEase <= BAD_REPAIR_EASE )
  653. {
  654. zTemp = Message[STR_HARD_TO_REPAIR];
  655. if ( ! AttemptToAddSubstring( zItemCons, zTemp, &uiStringLength, uiPixLimit ) )
  656. {
  657. return;
  658. }
  659. }
  660. if ( zItemCons[0] == 0 )
  661. {
  662. // empty string, so display "None"
  663. if ( ! AttemptToAddSubstring( zItemCons, Message[ STR_NONE ], &uiStringLength, uiPixLimit ) )
  664. {
  665. return;
  666. }
  667. }
  668. }
  669. BOOLEAN InitInvSlotInterface( INV_REGION_DESC *pRegionDesc , INV_REGION_DESC *pCamoRegion, MOUSE_CALLBACK INVMoveCallback, MOUSE_CALLBACK INVClickCallback, MOUSE_CALLBACK INVMoveCammoCallback, MOUSE_CALLBACK INVClickCammoCallback, BOOLEAN fSetHighestPrioity )
  670. {
  671. INT32 cnt;
  672. VOBJECT_DESC VObjectDesc;
  673. // Load all four body type images
  674. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  675. FilenameForBPP("INTERFACE\\inventory_figure_large_male.sti", VObjectDesc.ImageFile);
  676. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 1 ][ 0 ] ) ) );
  677. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  678. FilenameForBPP("INTERFACE\\inventory_figure_large_male_H.sti", VObjectDesc.ImageFile);
  679. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 1 ][ 1 ] ) ) );
  680. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  681. FilenameForBPP("INTERFACE\\inventory_normal_male.sti", VObjectDesc.ImageFile);
  682. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 0 ][ 0 ] ) ) );
  683. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  684. FilenameForBPP("INTERFACE\\inventory_normal_male_H.sti", VObjectDesc.ImageFile);
  685. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 0 ][ 1 ] ) ) );
  686. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  687. FilenameForBPP("INTERFACE\\inventory_normal_male.sti", VObjectDesc.ImageFile);
  688. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 2 ][ 0 ] ) ) );
  689. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  690. FilenameForBPP("INTERFACE\\inventory_normal_male.sti", VObjectDesc.ImageFile);
  691. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 2 ][ 1 ] ) ) );
  692. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  693. FilenameForBPP("INTERFACE\\inventory_figure_female.sti", VObjectDesc.ImageFile);
  694. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 3 ][ 0 ] ) ) );
  695. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  696. FilenameForBPP("INTERFACE\\inventory_figure_female_H.sti", VObjectDesc.ImageFile);
  697. CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 3 ][ 1 ] ) ) );
  698. // add gold key graphic
  699. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  700. FilenameForBPP("INTERFACE\\gold_key_button.sti", VObjectDesc.ImageFile);
  701. CHECKF( AddVideoObject( &VObjectDesc, &guiGoldKeyVO ) );
  702. // Add cammo region
  703. MSYS_DefineRegion( &gSMInvCamoRegion, pCamoRegion->sX, pCamoRegion->sY, (INT16)(pCamoRegion->sX + CAMO_REGION_WIDTH ), (INT16)(pCamoRegion->sY + CAMO_REGION_HEIGHT ), MSYS_PRIORITY_HIGH,
  704. MSYS_NO_CURSOR, INVMoveCammoCallback, INVClickCammoCallback );
  705. // Add region
  706. MSYS_AddRegion( &gSMInvCamoRegion );
  707. // Add regions for inventory slots
  708. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  709. {
  710. // set inventory pocket coordinates from the table passed in
  711. gSMInvData[ cnt ].sX = pRegionDesc[ cnt ].sX;
  712. gSMInvData[ cnt ].sY = pRegionDesc[ cnt ].sY;
  713. MSYS_DefineRegion( &gSMInvRegion[ cnt ], gSMInvData[ cnt ].sX, gSMInvData[ cnt ].sY, (INT16)(gSMInvData[ cnt ].sX + gSMInvData[ cnt ].sWidth), (INT16)(gSMInvData[ cnt ].sY + gSMInvData[ cnt ].sHeight), ( INT8 )( fSetHighestPrioity ? MSYS_PRIORITY_HIGHEST : MSYS_PRIORITY_HIGH ),
  714. MSYS_NO_CURSOR, INVMoveCallback, INVClickCallback );
  715. // Add region
  716. MSYS_AddRegion( &gSMInvRegion[ cnt ] );
  717. MSYS_SetRegionUserData( &gSMInvRegion[ cnt ], 0, cnt );
  718. }
  719. memset( gbCompatibleAmmo, 0, sizeof( gbCompatibleAmmo ) );
  720. return( TRUE );
  721. }
  722. void InitKeyRingInterface( MOUSE_CALLBACK KeyRingClickCallback )
  723. {
  724. MSYS_DefineRegion( &gKeyRingPanel, KEYRING_X, KEYRING_Y, KEYRING_X + KEYRING_WIDTH, KEYRING_X + KEYRING_HEIGHT, MSYS_PRIORITY_HIGH,
  725. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, KeyRingClickCallback );
  726. SetRegionFastHelpText( &(gKeyRingPanel), TacticalStr[ KEYRING_HELP_TEXT ] );
  727. }
  728. void InitMapKeyRingInterface( MOUSE_CALLBACK KeyRingClickCallback )
  729. {
  730. MSYS_DefineRegion( &gKeyRingPanel, MAP_KEYRING_X, MAP_KEYRING_Y, MAP_KEYRING_X + KEYRING_WIDTH, MAP_KEYRING_Y + KEYRING_HEIGHT, MSYS_PRIORITY_HIGH,
  731. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, KeyRingClickCallback );
  732. SetRegionFastHelpText( &(gKeyRingPanel), TacticalStr[ KEYRING_HELP_TEXT ] );
  733. }
  734. void EnableKeyRing( BOOLEAN fEnable )
  735. {
  736. if ( fEnable )
  737. {
  738. MSYS_EnableRegion( &gKeyRingPanel );
  739. }
  740. else
  741. {
  742. MSYS_DisableRegion( &gKeyRingPanel );
  743. }
  744. }
  745. void ShutdownKeyRingInterface( void )
  746. {
  747. MSYS_RemoveRegion( &gKeyRingPanel );
  748. return;
  749. }
  750. void DisableInvRegions( BOOLEAN fDisable )
  751. {
  752. INT32 cnt;
  753. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  754. {
  755. if ( fDisable )
  756. {
  757. MSYS_DisableRegion( &gSMInvRegion[ cnt ] );
  758. }
  759. else
  760. {
  761. MSYS_EnableRegion( &gSMInvRegion[ cnt ] );
  762. }
  763. }
  764. if ( fDisable )
  765. {
  766. MSYS_DisableRegion( &gSMInvCamoRegion );
  767. MSYS_DisableRegion( &gSM_SELMERCMoneyRegion );
  768. EnableKeyRing( FALSE );
  769. }
  770. else
  771. {
  772. MSYS_EnableRegion( &gSMInvCamoRegion );
  773. MSYS_EnableRegion( &gSM_SELMERCMoneyRegion );
  774. EnableKeyRing( TRUE );
  775. }
  776. }
  777. void ShutdownInvSlotInterface( )
  778. {
  779. UINT32 cnt;
  780. // Remove all body type panels
  781. DeleteVideoObjectFromIndex( guiBodyInvVO[ 0 ][ 0 ] );
  782. DeleteVideoObjectFromIndex( guiBodyInvVO[ 2 ][ 0 ] );
  783. DeleteVideoObjectFromIndex( guiBodyInvVO[ 1 ][ 0 ] );
  784. DeleteVideoObjectFromIndex( guiBodyInvVO[ 3 ][ 0 ] );
  785. DeleteVideoObjectFromIndex( guiBodyInvVO[ 0 ][ 1 ] );
  786. DeleteVideoObjectFromIndex( guiBodyInvVO[ 2 ][ 1 ] );
  787. DeleteVideoObjectFromIndex( guiBodyInvVO[ 1 ][ 1 ] );
  788. DeleteVideoObjectFromIndex( guiBodyInvVO[ 3 ][ 1 ] );
  789. DeleteVideoObjectFromIndex( guiGoldKeyVO );
  790. // Remove regions
  791. // Add regions for inventory slots
  792. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  793. {
  794. // Remove region
  795. MSYS_RemoveRegion( &gSMInvRegion[ cnt ] );
  796. }
  797. // Remove cammo
  798. MSYS_RemoveRegion( &gSMInvCamoRegion );
  799. }
  800. void RenderInvBodyPanel( SOLDIERTYPE *pSoldier, INT16 sX, INT16 sY )
  801. {
  802. // Blit body inv, based on body type
  803. INT8 bSubImageIndex = gbCompatibleApplyItem;
  804. BltVideoObjectFromIndex( guiSAVEBUFFER, guiBodyInvVO[ pSoldier->ubBodyType ][ bSubImageIndex ], 0, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL );
  805. }
  806. void HandleRenderInvSlots( SOLDIERTYPE *pSoldier, UINT8 fDirtyLevel )
  807. {
  808. INT32 cnt;
  809. static INT16 pStr[ 150 ];
  810. if ( InItemDescriptionBox( ) || InItemStackPopup( ) || InKeyRingPopup( ) )
  811. {
  812. }
  813. else
  814. {
  815. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  816. {
  817. if ( fDirtyLevel == DIRTYLEVEL2 )
  818. {
  819. GetHelpTextForItem( pStr, &( pSoldier->inv[ cnt ] ), pSoldier );
  820. SetRegionFastHelpText( &(gSMInvRegion[ cnt ]), pStr );
  821. }
  822. INVRenderINVPanelItem( pSoldier, (INT16)cnt, fDirtyLevel );
  823. }
  824. if ( KeyExistsInKeyRing( pSoldier, ANYKEY, NULL ) )
  825. {
  826. // blit gold key here?
  827. if ( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  828. {
  829. BltVideoObjectFromIndex( guiSAVEBUFFER, guiGoldKeyVO, 0, 496, 446, VO_BLT_SRCTRANSPARENCY, NULL );
  830. RestoreExternBackgroundRect( 496, 446, 29, 23 );
  831. }
  832. else
  833. {
  834. BltVideoObjectFromIndex( guiSAVEBUFFER, guiGoldKeyVO, 0, 217, 271, VO_BLT_SRCTRANSPARENCY, NULL );
  835. RestoreExternBackgroundRect( 217, 271, 29, 23 );
  836. }
  837. }
  838. }
  839. }
  840. void INVRenderINVPanelItem( SOLDIERTYPE *pSoldier, INT16 sPocket, UINT8 fDirtyLevel )
  841. {
  842. INT16 sX, sY;
  843. INT16 sBarX, sBarY;
  844. OBJECTTYPE *pObject;
  845. BOOLEAN fOutline = FALSE;
  846. INT16 sOutlineColor = 0;
  847. UINT8 fRenderDirtyLevel;
  848. BOOLEAN fHatchItOut = FALSE;
  849. //Assign the screen
  850. guiCurrentItemDescriptionScreen = guiCurrentScreen;
  851. pObject = &(pSoldier->inv[ sPocket ]);
  852. sX = gSMInvData[ sPocket ].sX;
  853. sY = gSMInvData[ sPocket ].sY;
  854. if ( fDirtyLevel == DIRTYLEVEL2 )
  855. {
  856. // CHECK FOR COMPATIBILITY WITH MAGAZINES
  857. /* OLD VERSION OF GUN/AMMO MATCH HIGHLIGHTING
  858. UINT32 uiDestPitchBYTES;
  859. UINT8 *pDestBuf;
  860. UINT16 usLineColor;
  861. if ( ( Item [ pSoldier->inv[ HANDPOS ].usItem ].usItemClass & IC_GUN ) && ( Item[ pObject->usItem ].usItemClass & IC_AMMO ) )
  862. {
  863. // CHECK
  864. if (Weapon[pSoldier->inv[ HANDPOS ].usItem].ubCalibre == Magazine[Item[pObject->usItem].ubClassIndex].ubCalibre )
  865. {
  866. // IT's an OK calibre ammo, do something!
  867. // Render Item with specific color
  868. //fOutline = TRUE;
  869. //sOutlineColor = Get16BPPColor( FROMRGB( 96, 104, 128 ) );
  870. //sOutlineColor = Get16BPPColor( FROMRGB( 20, 20, 120 ) );
  871. // Draw rectangle!
  872. pDestBuf = LockVideoSurface( guiSAVEBUFFER, &uiDestPitchBYTES );
  873. SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480 );
  874. //usLineColor = Get16BPPColor( FROMRGB( 255, 255, 0 ) );
  875. usLineColor = Get16BPPColor( FROMRGB( 230, 215, 196 ) );
  876. RectangleDraw( TRUE, (sX+1), (sY+1), (sX + gSMInvData[ sPocket ].sWidth - 2 ),( sY + gSMInvData[ sPocket ].sHeight - 2 ), usLineColor, pDestBuf );
  877. SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480 );
  878. UnLockVideoSurface( guiSAVEBUFFER );
  879. }
  880. }
  881. */
  882. if ( gbCompatibleAmmo[ sPocket ] )
  883. {
  884. fOutline = TRUE;
  885. sOutlineColor = Get16BPPColor( FROMRGB( 255, 255, 255 ) );
  886. }
  887. // IF it's the second hand and this hand cannot contain anything, remove the second hand position graphic
  888. if (sPocket == SECONDHANDPOS && Item[pSoldier->inv[HANDPOS].usItem].fFlags & ITEM_TWO_HANDED)
  889. {
  890. // if( guiCurrentScreen != MAP_SCREEN )
  891. if( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  892. {
  893. BltVideoObjectFromIndex( guiSAVEBUFFER, guiSecItemHiddenVO, 0, 217, 448, VO_BLT_SRCTRANSPARENCY, NULL );
  894. RestoreExternBackgroundRect( 217, 448, 72, 28 );
  895. }
  896. else
  897. {
  898. BltVideoObjectFromIndex( guiSAVEBUFFER, guiMapInvSecondHandBlockout, 0, 14, 218, VO_BLT_SRCTRANSPARENCY, NULL );
  899. RestoreExternBackgroundRect( 14, 218, 102, 24 );
  900. }
  901. }
  902. }
  903. // If we have a new item and we are in the right panel...
  904. if ( pSoldier->bNewItemCount[ sPocket ] > 0 && gsCurInterfacePanel == SM_PANEL && fInterfacePanelDirty != DIRTYLEVEL2 )
  905. {
  906. fRenderDirtyLevel = DIRTYLEVEL0;
  907. //fRenderDirtyLevel = fDirtyLevel;
  908. }
  909. else
  910. {
  911. fRenderDirtyLevel = fDirtyLevel;
  912. }
  913. //Now render as normal
  914. //INVRenderItem( guiSAVEBUFFER, pObject, (INT16)(sX + gSMInvData[ sPocket ].sSubX), (INT16)(sY + gSMInvData[ sPocket ].sSubY), gSMInvData[ sPocket ].sWidth, gSMInvData[ sPocket ].sHeight, fDirtyLevel, &(gfSM_HandInvDispText[ sPocket ] ) );
  915. INVRenderItem( guiSAVEBUFFER, pSoldier, pObject, sX, sY, gSMInvData[ sPocket ].sWidth, gSMInvData[ sPocket ].sHeight, fRenderDirtyLevel, NULL, 0, fOutline, sOutlineColor );
  916. if ( gbInvalidPlacementSlot[ sPocket ] )
  917. {
  918. if ( sPocket != SECONDHANDPOS )
  919. {
  920. // If we are in inv panel and our guy is not = cursor guy...
  921. if ( !gfSMDisableForItems )
  922. {
  923. fHatchItOut = TRUE;
  924. }
  925. }
  926. }
  927. //if we are in the shop keeper interface
  928. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  929. {
  930. if( ShouldSoldierDisplayHatchOnItem( pSoldier->ubProfile, sPocket ) && !gbInvalidPlacementSlot[ sPocket ] )
  931. {
  932. fHatchItOut = TRUE;
  933. }
  934. }
  935. if ( fHatchItOut )
  936. {
  937. UINT32 uiWhichBuffer = ( guiCurrentItemDescriptionScreen == MAP_SCREEN ) ? guiSAVEBUFFER : guiRENDERBUFFER;
  938. DrawHatchOnInventory( uiWhichBuffer, sX, sY, (UINT16)(gSMInvData[ sPocket ].sWidth-1), (UINT16)(gSMInvData[ sPocket ].sHeight-1) );
  939. }
  940. // if there's an item in there
  941. if ( pObject->usItem != NOTHING )
  942. {
  943. // Add item status bar
  944. sBarX = sX - gSMInvData[ sPocket ].sBarDx;
  945. sBarY = sY + gSMInvData[ sPocket ].sBarDy;
  946. DrawItemUIBarEx( pObject, 0, sBarX, sBarY, ITEM_BAR_WIDTH, ITEM_BAR_HEIGHT, Get16BPPColor( STATUS_BAR ), Get16BPPColor( STATUS_BAR_SHADOW ), TRUE , guiSAVEBUFFER);
  947. }
  948. }
  949. BOOLEAN CompatibleAmmoForGun( OBJECTTYPE *pTryObject, OBJECTTYPE *pTestObject )
  950. {
  951. if ( ( Item[ pTryObject->usItem ].usItemClass & IC_AMMO ) )
  952. {
  953. // CHECK
  954. if (Weapon[ pTestObject->usItem ].ubCalibre == Magazine[Item[pTryObject->usItem].ubClassIndex].ubCalibre )
  955. {
  956. return( TRUE );
  957. }
  958. }
  959. return( FALSE );
  960. }
  961. BOOLEAN CompatibleGunForAmmo( OBJECTTYPE *pTryObject, OBJECTTYPE *pTestObject )
  962. {
  963. if ( ( Item[ pTryObject->usItem ].usItemClass & IC_GUN ) )
  964. {
  965. // CHECK
  966. if (Weapon[ pTryObject->usItem ].ubCalibre == Magazine[Item[pTestObject->usItem].ubClassIndex].ubCalibre )
  967. {
  968. return( TRUE );
  969. }
  970. }
  971. return( FALSE );
  972. }
  973. BOOLEAN CompatibleItemForApplyingOnMerc( OBJECTTYPE *pTestObject )
  974. {
  975. UINT16 usItem = pTestObject->usItem;
  976. // ATE: If in mapscreen, return false always....
  977. if( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  978. {
  979. return( FALSE );
  980. }
  981. // ATE: Would be nice to have flag here to check for these types....
  982. if ( usItem == CAMOUFLAGEKIT || usItem == ADRENALINE_BOOSTER || usItem == REGEN_BOOSTER ||
  983. usItem == SYRINGE_3 || usItem == SYRINGE_4 || usItem == SYRINGE_5 ||
  984. usItem == ALCOHOL || usItem == WINE || usItem == BEER || usItem == CANTEEN || usItem == JAR_ELIXIR )
  985. {
  986. return( TRUE );
  987. }
  988. else
  989. {
  990. return( FALSE );
  991. }
  992. }
  993. BOOLEAN SoldierContainsAnyCompatibleStuff( SOLDIERTYPE *pSoldier, OBJECTTYPE *pTestObject )
  994. {
  995. INT32 cnt;
  996. OBJECTTYPE *pObject;
  997. if( ( Item [ pTestObject->usItem ].usItemClass & IC_GUN ) )
  998. {
  999. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1000. {
  1001. pObject = &(pSoldier->inv[ cnt ]);
  1002. if ( CompatibleAmmoForGun( pObject, pTestObject ) )
  1003. {
  1004. return( TRUE );
  1005. }
  1006. }
  1007. }
  1008. if( ( Item [ pTestObject->usItem ].usItemClass & IC_AMMO ) )
  1009. {
  1010. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1011. {
  1012. pObject = &(pSoldier->inv[ cnt ]);
  1013. if ( CompatibleGunForAmmo( pObject, pTestObject ) )
  1014. {
  1015. return( TRUE );
  1016. }
  1017. }
  1018. }
  1019. // ATE: Put attachment checking here.....
  1020. return( FALSE );
  1021. }
  1022. void HandleAnyMercInSquadHasCompatibleStuff( UINT8 ubSquad, OBJECTTYPE *pObject, BOOLEAN fReset )
  1023. {
  1024. INT32 iCounter = 0;
  1025. if ( ubSquad == NUMBER_OF_SQUADS )
  1026. {
  1027. return;
  1028. }
  1029. for( iCounter = 0; iCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; iCounter++ )
  1030. {
  1031. if( Squad[ iCurrentTacticalSquad ][ iCounter ] != NULL )
  1032. {
  1033. if ( !fReset )
  1034. {
  1035. if ( SoldierContainsAnyCompatibleStuff( Squad[ iCurrentTacticalSquad ][ iCounter ], pObject ) )
  1036. {
  1037. // Get face and set value....
  1038. gFacesData[ Squad[ iCurrentTacticalSquad ][ iCounter ]->iFaceIndex ].fCompatibleItems = TRUE;
  1039. }
  1040. }
  1041. else
  1042. {
  1043. gFacesData[ Squad[ iCurrentTacticalSquad ][ iCounter ]->iFaceIndex ].fCompatibleItems = FALSE;
  1044. }
  1045. }
  1046. }
  1047. }
  1048. BOOLEAN HandleCompatibleAmmoUIForMapScreen( SOLDIERTYPE *pSoldier, INT32 bInvPos, BOOLEAN fOn, BOOLEAN fFromMerc )
  1049. {
  1050. BOOLEAN fFound = FALSE;
  1051. INT32 cnt;
  1052. OBJECTTYPE *pObject, *pTestObject ;
  1053. BOOLEAN fFoundAttachment = FALSE;
  1054. if( fFromMerc == FALSE )
  1055. {
  1056. pTestObject = &( pInventoryPoolList[ bInvPos ].o );
  1057. }
  1058. else
  1059. {
  1060. if ( bInvPos == NO_SLOT )
  1061. {
  1062. pTestObject = NULL;
  1063. }
  1064. else
  1065. {
  1066. pTestObject = &(pSoldier->inv[ bInvPos ]);
  1067. }
  1068. }
  1069. // ATE: If pTest object is NULL, test only for existence of syringes, etc...
  1070. if ( pTestObject == NULL )
  1071. {
  1072. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1073. {
  1074. pObject = &(pSoldier->inv[ cnt ]);
  1075. if ( CompatibleItemForApplyingOnMerc( pObject ) )
  1076. {
  1077. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1078. {
  1079. fFound = TRUE;
  1080. }
  1081. // IT's an OK calibere ammo, do something!
  1082. // Render Item with specific color
  1083. gbCompatibleAmmo[ cnt ] = fOn;
  1084. }
  1085. }
  1086. if ( gpItemPointer != NULL )
  1087. {
  1088. if ( CompatibleItemForApplyingOnMerc( gpItemPointer ) )
  1089. {
  1090. // OK, Light up portrait as well.....
  1091. if ( fOn )
  1092. {
  1093. gbCompatibleApplyItem = TRUE;
  1094. }
  1095. else
  1096. {
  1097. gbCompatibleApplyItem = FALSE;
  1098. }
  1099. fFound = TRUE;
  1100. }
  1101. }
  1102. if ( fFound )
  1103. {
  1104. fInterfacePanelDirty = DIRTYLEVEL2;
  1105. //HandleRenderInvSlots( pSoldier, DIRTYLEVEL2 );
  1106. }
  1107. return( fFound );
  1108. }
  1109. if ( (! Item[ pTestObject->usItem ].fFlags & ITEM_HIDDEN_ADDON) )
  1110. {
  1111. // First test attachments, which almost any type of item can have....
  1112. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1113. {
  1114. pObject = &(pSoldier->inv[ cnt ]);
  1115. if ( Item[ pObject->usItem ].fFlags & ITEM_HIDDEN_ADDON )
  1116. {
  1117. // don't consider for UI purposes
  1118. continue;
  1119. }
  1120. if ( ValidAttachment( pObject->usItem, pTestObject->usItem ) ||
  1121. ValidAttachment( pTestObject->usItem, pObject->usItem ) ||
  1122. ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
  1123. ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
  1124. {
  1125. fFoundAttachment = TRUE;
  1126. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1127. {
  1128. fFound = TRUE;
  1129. }
  1130. // IT's an OK calibere ammo, do something!
  1131. // Render Item with specific color
  1132. gbCompatibleAmmo[ cnt ] = fOn;
  1133. }
  1134. }
  1135. }
  1136. if ( ( Item [ pTestObject->usItem ].usItemClass & IC_GUN ) )
  1137. {
  1138. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1139. {
  1140. pObject = &(pSoldier->inv[ cnt ]);
  1141. if ( CompatibleAmmoForGun( pObject, pTestObject ) )
  1142. {
  1143. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1144. {
  1145. fFound = TRUE;
  1146. }
  1147. // IT's an OK calibere ammo, do something!
  1148. // Render Item with specific color
  1149. gbCompatibleAmmo[ cnt ] = fOn;
  1150. }
  1151. }
  1152. }
  1153. else if( ( Item [ pTestObject->usItem ].usItemClass & IC_AMMO ) )
  1154. {
  1155. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1156. {
  1157. pObject = &(pSoldier->inv[ cnt ]);
  1158. if ( CompatibleGunForAmmo( pObject, pTestObject ) )
  1159. {
  1160. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1161. {
  1162. fFound = TRUE;
  1163. }
  1164. // IT's an OK calibere ammo, do something!
  1165. // Render Item with specific color
  1166. gbCompatibleAmmo[ cnt ] = fOn;
  1167. }
  1168. }
  1169. }
  1170. return( fFound );
  1171. }
  1172. BOOLEAN HandleCompatibleAmmoUIForMapInventory( SOLDIERTYPE *pSoldier, INT32 bInvPos, INT32 iStartSlotNumber, BOOLEAN fOn, BOOLEAN fFromMerc )
  1173. {
  1174. // CJC: ATE, needs fixing here!
  1175. BOOLEAN fFound = FALSE;
  1176. INT32 cnt;
  1177. OBJECTTYPE *pObject, *pTestObject ;
  1178. BOOLEAN fFoundAttachment = FALSE;
  1179. if( fFromMerc == FALSE )
  1180. {
  1181. pTestObject = &( pInventoryPoolList[ iStartSlotNumber + bInvPos ].o);
  1182. }
  1183. else
  1184. {
  1185. if ( bInvPos == NO_SLOT )
  1186. {
  1187. pTestObject = NULL;
  1188. }
  1189. else
  1190. {
  1191. pTestObject = &(pSoldier->inv[ bInvPos ]);
  1192. }
  1193. }
  1194. // First test attachments, which almost any type of item can have....
  1195. for ( cnt = 0; cnt < MAP_INVENTORY_POOL_SLOT_COUNT; cnt++ )
  1196. {
  1197. pObject = &( pInventoryPoolList[ iStartSlotNumber + cnt ].o );
  1198. if ( Item[ pObject->usItem ].fFlags & ITEM_HIDDEN_ADDON )
  1199. {
  1200. // don't consider for UI purposes
  1201. continue;
  1202. }
  1203. if ( ValidAttachment( pObject->usItem, pTestObject->usItem ) ||
  1204. ValidAttachment( pTestObject->usItem, pObject->usItem ) ||
  1205. ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
  1206. ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
  1207. {
  1208. fFoundAttachment = TRUE;
  1209. if ( fOn != fMapInventoryItemCompatable[ cnt ] )
  1210. {
  1211. fFound = TRUE;
  1212. }
  1213. // IT's an OK calibere ammo, do something!
  1214. // Render Item with specific color
  1215. fMapInventoryItemCompatable[ cnt ] = fOn;
  1216. }
  1217. }
  1218. if( ( Item [ pTestObject->usItem ].usItemClass & IC_GUN ) )
  1219. {
  1220. for ( cnt = 0; cnt < MAP_INVENTORY_POOL_SLOT_COUNT; cnt++ )
  1221. {
  1222. pObject = &( pInventoryPoolList[ iStartSlotNumber + cnt ].o );
  1223. if ( CompatibleAmmoForGun( pObject, pTestObject ) )
  1224. {
  1225. if ( fOn != fMapInventoryItemCompatable[ cnt ] )
  1226. {
  1227. fFound = TRUE;
  1228. }
  1229. // IT's an OK calibere ammo, do something!
  1230. // Render Item with specific color
  1231. fMapInventoryItemCompatable[ cnt ] = fOn;
  1232. }
  1233. }
  1234. }
  1235. else if( ( Item [ pTestObject->usItem ].usItemClass & IC_AMMO ) )
  1236. {
  1237. for ( cnt = 0; cnt < MAP_INVENTORY_POOL_SLOT_COUNT; cnt++ )
  1238. {
  1239. pObject = &( pInventoryPoolList[ iStartSlotNumber + cnt ].o );
  1240. if ( CompatibleGunForAmmo( pObject, pTestObject ) )
  1241. {
  1242. if ( fOn != fMapInventoryItemCompatable[ cnt ] )
  1243. {
  1244. fFound = TRUE;
  1245. }
  1246. // IT's an OK calibere ammo, do something!
  1247. // Render Item with specific color
  1248. fMapInventoryItemCompatable[ cnt ] = fOn;
  1249. }
  1250. }
  1251. }
  1252. return( fFound );
  1253. }
  1254. BOOLEAN InternalHandleCompatibleAmmoUI( SOLDIERTYPE *pSoldier, OBJECTTYPE *pTestObject, BOOLEAN fOn )
  1255. {
  1256. BOOLEAN fFound = FALSE;
  1257. INT32 cnt;
  1258. OBJECTTYPE *pObject;
  1259. BOOLEAN fFoundAttachment = FALSE;
  1260. // ATE: If pTest object is NULL, test only for existence of syringes, etc...
  1261. if ( pTestObject == NULL )
  1262. {
  1263. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1264. {
  1265. pObject = &(pSoldier->inv[ cnt ]);
  1266. if ( CompatibleItemForApplyingOnMerc( pObject ) )
  1267. {
  1268. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1269. {
  1270. fFound = TRUE;
  1271. }
  1272. // IT's an OK calibere ammo, do something!
  1273. // Render Item with specific color
  1274. gbCompatibleAmmo[ cnt ] = fOn;
  1275. }
  1276. }
  1277. if ( gpItemPointer != NULL )
  1278. {
  1279. if ( CompatibleItemForApplyingOnMerc( gpItemPointer ) )
  1280. {
  1281. // OK, Light up portrait as well.....
  1282. if ( fOn )
  1283. {
  1284. gbCompatibleApplyItem = TRUE;
  1285. }
  1286. else
  1287. {
  1288. gbCompatibleApplyItem = FALSE;
  1289. }
  1290. fFound = TRUE;
  1291. }
  1292. }
  1293. if ( fFound )
  1294. {
  1295. fInterfacePanelDirty = DIRTYLEVEL2;
  1296. //HandleRenderInvSlots( pSoldier, DIRTYLEVEL2 );
  1297. }
  1298. return( fFound );
  1299. }
  1300. // First test attachments, which almost any type of item can have....
  1301. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1302. {
  1303. pObject = &(pSoldier->inv[ cnt ]);
  1304. if ( Item[ pObject->usItem ].fFlags & ITEM_HIDDEN_ADDON )
  1305. {
  1306. // don't consider for UI purposes
  1307. continue;
  1308. }
  1309. if ( ValidAttachment( pObject->usItem, pTestObject->usItem ) ||
  1310. ValidAttachment( pTestObject->usItem, pObject->usItem ) ||
  1311. ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
  1312. ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
  1313. {
  1314. fFoundAttachment = TRUE;
  1315. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1316. {
  1317. fFound = TRUE;
  1318. }
  1319. // IT's an OK calibere ammo, do something!
  1320. // Render Item with specific color
  1321. gbCompatibleAmmo[ cnt ] = fOn;
  1322. }
  1323. }
  1324. //if ( !fFoundAttachment )
  1325. //{
  1326. if( ( Item [ pTestObject->usItem ].usItemClass & IC_GUN ) )
  1327. {
  1328. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1329. {
  1330. pObject = &(pSoldier->inv[ cnt ]);
  1331. if ( CompatibleAmmoForGun( pObject, pTestObject ) )
  1332. {
  1333. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1334. {
  1335. fFound = TRUE;
  1336. }
  1337. // IT's an OK calibere ammo, do something!
  1338. // Render Item with specific color
  1339. gbCompatibleAmmo[ cnt ] = fOn;
  1340. }
  1341. }
  1342. }
  1343. else if( ( Item [ pTestObject->usItem ].usItemClass & IC_AMMO ) )
  1344. {
  1345. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1346. {
  1347. pObject = &(pSoldier->inv[ cnt ]);
  1348. if ( CompatibleGunForAmmo( pObject, pTestObject ) )
  1349. {
  1350. if ( fOn != gbCompatibleAmmo[ cnt ] )
  1351. {
  1352. fFound = TRUE;
  1353. }
  1354. // IT's an OK calibere ammo, do something!
  1355. // Render Item with specific color
  1356. gbCompatibleAmmo[ cnt ] = fOn;
  1357. }
  1358. }
  1359. }
  1360. else if ( CompatibleItemForApplyingOnMerc( pTestObject ) )
  1361. {
  1362. //If we are currently NOT in the Shopkeeper interface
  1363. if( !( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) )
  1364. {
  1365. fFound = TRUE;
  1366. gbCompatibleApplyItem = fOn;
  1367. }
  1368. }
  1369. //}
  1370. if ( !fFound )
  1371. {
  1372. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1373. {
  1374. if ( gbCompatibleAmmo[ cnt ] )
  1375. {
  1376. fFound = TRUE;
  1377. gbCompatibleAmmo[ cnt ] = FALSE;
  1378. }
  1379. if ( gbCompatibleApplyItem )
  1380. {
  1381. fFound = TRUE;
  1382. gbCompatibleApplyItem = FALSE;
  1383. }
  1384. }
  1385. }
  1386. if ( fFound )
  1387. {
  1388. fInterfacePanelDirty = DIRTYLEVEL2;
  1389. //HandleRenderInvSlots( pSoldier, DIRTYLEVEL2 );
  1390. }
  1391. return( fFound );
  1392. }
  1393. void ResetCompatibleItemArray( )
  1394. {
  1395. INT32 cnt = 0;
  1396. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1397. {
  1398. if ( gbCompatibleAmmo[ cnt ] )
  1399. {
  1400. gbCompatibleAmmo[ cnt ] = FALSE;
  1401. }
  1402. }
  1403. }
  1404. BOOLEAN HandleCompatibleAmmoUI( SOLDIERTYPE *pSoldier, INT8 bInvPos, BOOLEAN fOn )
  1405. {
  1406. INT32 cnt;
  1407. OBJECTTYPE *pTestObject;
  1408. BOOLEAN fFound = FALSE;
  1409. //if we are in the shopkeeper interface
  1410. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  1411. {
  1412. // if the inventory position is -1, this is a flag from the Shopkeeper interface screen
  1413. //indicating that we are to use a different object to do the search
  1414. if( bInvPos == -1 )
  1415. {
  1416. if( fOn )
  1417. {
  1418. if( gpHighLightedItemObject )
  1419. {
  1420. pTestObject = gpHighLightedItemObject;
  1421. // gubSkiDirtyLevel = SKI_DIRTY_LEVEL2;
  1422. }
  1423. else
  1424. return( FALSE );
  1425. }
  1426. else
  1427. {
  1428. gpHighLightedItemObject = NULL;
  1429. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1430. {
  1431. if ( gbCompatibleAmmo[ cnt ] )
  1432. {
  1433. fFound = TRUE;
  1434. gbCompatibleAmmo[ cnt ] = FALSE;
  1435. }
  1436. }
  1437. gubSkiDirtyLevel = SKI_DIRTY_LEVEL1;
  1438. return( TRUE );
  1439. }
  1440. }
  1441. else
  1442. {
  1443. if( fOn )
  1444. {
  1445. pTestObject = &(pSoldier->inv[ bInvPos ]);
  1446. gpHighLightedItemObject = pTestObject;
  1447. }
  1448. else
  1449. {
  1450. pTestObject = &(pSoldier->inv[ bInvPos ]);
  1451. gpHighLightedItemObject = NULL;
  1452. gubSkiDirtyLevel = SKI_DIRTY_LEVEL1;
  1453. }
  1454. }
  1455. }
  1456. else
  1457. {
  1458. // if( fOn )
  1459. if ( bInvPos == NO_SLOT )
  1460. {
  1461. pTestObject = NULL;
  1462. }
  1463. else
  1464. {
  1465. pTestObject = &(pSoldier->inv[ bInvPos ]);
  1466. }
  1467. }
  1468. return( InternalHandleCompatibleAmmoUI( pSoldier, pTestObject, fOn ) );
  1469. }
  1470. void GetSlotInvXY( UINT8 ubPos, INT16 *psX, INT16 *psY )
  1471. {
  1472. *psX = gSMInvData[ ubPos ].sX;
  1473. *psY = gSMInvData[ ubPos ].sY;
  1474. }
  1475. void GetSlotInvHeightWidth( UINT8 ubPos, INT16 *psWidth, INT16 *psHeight )
  1476. {
  1477. *psWidth = gSMInvData[ ubPos ].sWidth;
  1478. *psHeight = gSMInvData[ ubPos ].sHeight;
  1479. }
  1480. void HandleNewlyAddedItems( SOLDIERTYPE *pSoldier, BOOLEAN *fDirtyLevel )
  1481. {
  1482. UINT32 cnt;
  1483. INT16 sX, sY;
  1484. OBJECTTYPE *pObject;
  1485. // If item description up.... stop
  1486. if ( gfInItemDescBox )
  1487. {
  1488. return;
  1489. }
  1490. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1491. {
  1492. if ( pSoldier->bNewItemCount[ cnt ] == -2 )
  1493. {
  1494. // Stop
  1495. *fDirtyLevel = DIRTYLEVEL2;
  1496. pSoldier->bNewItemCount[ cnt ] = 0;
  1497. }
  1498. if ( pSoldier->bNewItemCount[ cnt ] > 0 )
  1499. {
  1500. sX = gSMInvData[ cnt ].sX;
  1501. sY = gSMInvData[ cnt ].sY;
  1502. pObject = &(pSoldier->inv[ cnt ]);
  1503. if ( pObject->usItem == NOTHING )
  1504. {
  1505. gbNewItem[ cnt ] = 0;
  1506. continue;
  1507. }
  1508. INVRenderItem( guiSAVEBUFFER, pSoldier, pObject, sX, sY, gSMInvData[ cnt ].sWidth, gSMInvData[ cnt ].sHeight, DIRTYLEVEL2, NULL, 0, TRUE, us16BPPItemCyclePlacedItemColors[ pSoldier->bNewItemCycleCount[ cnt ] ] );
  1509. }
  1510. }
  1511. }
  1512. void CheckForAnyNewlyAddedItems( SOLDIERTYPE *pSoldier )
  1513. {
  1514. UINT32 cnt;
  1515. // OK, l0ok for any new...
  1516. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1517. {
  1518. if ( pSoldier->bNewItemCount[ cnt ] == -1 )
  1519. {
  1520. pSoldier->bNewItemCount[ cnt ] = NEW_ITEM_CYCLES - 1;
  1521. }
  1522. }
  1523. }
  1524. void DegradeNewlyAddedItems( )
  1525. {
  1526. UINT32 uiTime;
  1527. UINT32 cnt, cnt2;
  1528. SOLDIERTYPE *pSoldier;
  1529. // If time done
  1530. uiTime = GetJA2Clock();
  1531. if ( ( uiTime - guiNewlyPlacedItemTimer ) > 100 )
  1532. {
  1533. guiNewlyPlacedItemTimer = uiTime;
  1534. for ( cnt2 = 0; cnt2 < NUM_TEAM_SLOTS; cnt2++ )
  1535. {
  1536. // GET SOLDIER
  1537. if ( gTeamPanel[ cnt2 ].fOccupied )
  1538. {
  1539. pSoldier = MercPtrs[ gTeamPanel[ cnt2 ].ubID ];
  1540. for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ )
  1541. {
  1542. if ( pSoldier->bNewItemCount[ cnt ] > 0 )
  1543. {
  1544. // Decrement all the time!
  1545. pSoldier->bNewItemCycleCount[ cnt ]--;
  1546. if ( pSoldier->bNewItemCycleCount[ cnt ] == 0 )
  1547. {
  1548. // OK, cycle down....
  1549. pSoldier->bNewItemCount[ cnt ]--;
  1550. if ( pSoldier->bNewItemCount[ cnt ] == 0 )
  1551. {
  1552. // Stop...
  1553. pSoldier->bNewItemCount[ cnt ] = -2;
  1554. }
  1555. else
  1556. {
  1557. // Reset!
  1558. pSoldier->bNewItemCycleCount[ cnt ] = NEW_ITEM_CYCLE_COUNT;
  1559. continue;
  1560. }
  1561. }
  1562. }
  1563. }
  1564. }
  1565. }
  1566. }
  1567. }
  1568. void InitItemInterface( )
  1569. {
  1570. UINT32 cnt, cnt2;
  1571. for ( cnt = 0, cnt2 = 0; cnt2 < 20; cnt+=3, cnt2++ )
  1572. {
  1573. us16BPPItemCyclePlacedItemColors[ cnt2 ] = Get16BPPColor( FROMRGB( ubRGBItemCyclePlacedItemColors[ cnt ], ubRGBItemCyclePlacedItemColors[ cnt + 1 ], ubRGBItemCyclePlacedItemColors[ cnt + 2] ) );
  1574. }
  1575. }
  1576. void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObject, INT16 sX, INT16 sY, INT16 sWidth, INT16 sHeight, UINT8 fDirtyLevel, UINT8 *pubHighlightCounter, UINT8 ubStatusIndex, BOOLEAN fOutline, INT16 sOutlineColor )
  1577. {
  1578. UINT16 uiStringLength;
  1579. INVTYPE *pItem;
  1580. ETRLEObject *pTrav;
  1581. UINT32 usHeight, usWidth;
  1582. INT16 sCenX, sCenY, sNewY, sNewX;
  1583. HVOBJECT hVObject;
  1584. BOOLEAN fLineSplit = FALSE;
  1585. INT16 sFontX2, sFontY2;
  1586. INT16 sFontX, sFontY;
  1587. static INT16 pStr[ 100 ], pStr2[ 100 ];
  1588. if ( pObject->usItem == NOTHING )
  1589. {
  1590. return;
  1591. }
  1592. if ( ubStatusIndex < RENDER_ITEM_ATTACHMENT1 )
  1593. {
  1594. pItem = &Item[ pObject->usItem ];
  1595. }
  1596. else
  1597. {
  1598. pItem = &Item[ pObject->usAttachItem[ ubStatusIndex - RENDER_ITEM_ATTACHMENT1 ] ];
  1599. }
  1600. if ( fDirtyLevel == DIRTYLEVEL2 )
  1601. {
  1602. // TAKE A LOOK AT THE VIDEO OBJECT SIZE ( ONE OF TWO SIZES ) AND CENTER!
  1603. GetVideoObject( &hVObject, GetInterfaceGraphicForItem( pItem ) );
  1604. pTrav = &(hVObject->pETRLEObject[ pItem->ubGraphicNum ] );
  1605. usHeight = (UINT32)pTrav->usHeight;
  1606. usWidth = (UINT32)pTrav->usWidth;
  1607. // CENTER IN SLOT!
  1608. // CANCEL OFFSETS!
  1609. sCenX = sX + ( abs( sWidth - usWidth ) / 2 ) - pTrav->sOffsetX;
  1610. sCenY = sY + ( abs( sHeight - usHeight ) / 2 ) - pTrav->sOffsetY;
  1611. // Shadow area
  1612. BltVideoObjectOutlineShadowFromIndex( uiBuffer, GetInterfaceGraphicForItem( pItem ), pItem->ubGraphicNum, sCenX - 2, sCenY + 2 );
  1613. BltVideoObjectOutlineFromIndex( uiBuffer, GetInterfaceGraphicForItem( pItem ), pItem->ubGraphicNum, sCenX, sCenY, sOutlineColor, fOutline );
  1614. if ( uiBuffer == FRAME_BUFFER )
  1615. {
  1616. InvalidateRegion( sX, sY, (INT16)(sX + sWidth), (INT16)(sY + sHeight ) );
  1617. }
  1618. else
  1619. {
  1620. RestoreExternBackgroundRect( sX, sY, sWidth, sHeight );
  1621. }
  1622. }
  1623. SetFont( ITEM_FONT );
  1624. if ( fDirtyLevel != DIRTYLEVEL0 )
  1625. {
  1626. if ( ubStatusIndex < RENDER_ITEM_ATTACHMENT1 )
  1627. {
  1628. SetFontBackground( FONT_MCOLOR_BLACK );
  1629. SetFontForeground( FONT_MCOLOR_DKGRAY );
  1630. // FIRST DISPLAY FREE ROUNDS REMIANING
  1631. if ( pItem->usItemClass == IC_GUN && pObject->usItem != ROCKET_LAUNCHER )
  1632. {
  1633. sNewY = sY + sHeight - 10;
  1634. sNewX = sX + 1;
  1635. switch (pObject->ubGunAmmoType)
  1636. {
  1637. case AMMO_AP:
  1638. case AMMO_SUPER_AP:
  1639. SetFontForeground( ITEMDESC_FONTAPFORE );
  1640. break;
  1641. case AMMO_HP:
  1642. SetFontForeground( ITEMDESC_FONTHPFORE );
  1643. break;
  1644. case AMMO_BUCKSHOT:
  1645. SetFontForeground( ITEMDESC_FONTBSFORE );
  1646. break;
  1647. case AMMO_HE:
  1648. SetFontForeground( ITEMDESC_FONTHEFORE );
  1649. break;
  1650. case AMMO_HEAT:
  1651. SetFontForeground( ITEMDESC_FONTHEAPFORE );
  1652. break;
  1653. default:
  1654. SetFontForeground( FONT_MCOLOR_DKGRAY );
  1655. break;
  1656. }
  1657. swprintf( pStr, L"%d", pObject->ubGunShotsLeft );
  1658. if ( uiBuffer == guiSAVEBUFFER )
  1659. {
  1660. RestoreExternBackgroundRect( sNewX, sNewY, 20, 15 );
  1661. }
  1662. mprintf( sNewX, sNewY, pStr );
  1663. gprintfinvalidate( sNewX, sNewY, pStr );
  1664. SetFontForeground( FONT_MCOLOR_DKGRAY );
  1665. // Display 'JAMMED' if we are jammed
  1666. if ( pObject->bGunAmmoStatus < 0 )
  1667. {
  1668. SetFontForeground( FONT_MCOLOR_RED );
  1669. if ( sWidth >= ( BIG_INV_SLOT_WIDTH - 10 ) )
  1670. {
  1671. swprintf( pStr, TacticalStr[ JAMMED_ITEM_STR ] );
  1672. }
  1673. else
  1674. {
  1675. swprintf( pStr, TacticalStr[ SHORT_JAMMED_GUN ] );
  1676. }
  1677. VarFindFontCenterCoordinates( sX, sY, sWidth, sHeight , ITEM_FONT, &sNewX, &sNewY, pStr );
  1678. mprintf( sNewX, sNewY, pStr );
  1679. gprintfinvalidate( sNewX, sNewY, pStr );
  1680. }
  1681. }
  1682. else
  1683. {
  1684. if ( ubStatusIndex != RENDER_ITEM_NOSTATUS )
  1685. {
  1686. // Now display # of items
  1687. if ( pObject->ubNumberOfObjects > 1 )
  1688. {
  1689. SetFontForeground( FONT_GRAY4 );
  1690. sNewY = sY + sHeight - 10;
  1691. swprintf( pStr, L"%d", pObject->ubNumberOfObjects );
  1692. // Get length of string
  1693. uiStringLength=StringPixLength(pStr, ITEM_FONT );
  1694. sNewX = sX + sWidth - uiStringLength - 4;
  1695. if ( uiBuffer == guiSAVEBUFFER )
  1696. {
  1697. RestoreExternBackgroundRect( sNewX, sNewY, 15, 15 );
  1698. }
  1699. mprintf( sNewX, sNewY, pStr );
  1700. gprintfinvalidate( sNewX, sNewY, pStr );
  1701. }
  1702. }
  1703. }
  1704. if ( ItemHasAttachments( pObject ) )
  1705. {
  1706. if ( FindAttachment( pObject, UNDER_GLAUNCHER ) == NO_SLOT )
  1707. {
  1708. SetFontForeground( FONT_GREEN );
  1709. }
  1710. else
  1711. {
  1712. SetFontForeground( FONT_YELLOW );
  1713. }
  1714. sNewY = sY;
  1715. swprintf( pStr, L"*" );
  1716. // Get length of string
  1717. uiStringLength=StringPixLength(pStr, ITEM_FONT );
  1718. sNewX = sX + sWidth - uiStringLength - 4;
  1719. if ( uiBuffer == guiSAVEBUFFER )
  1720. {
  1721. RestoreExternBackgroundRect( sNewX, sNewY, 15, 15 );
  1722. }
  1723. mprintf( sNewX, sNewY, pStr );
  1724. gprintfinvalidate( sNewX, sNewY, pStr );
  1725. }
  1726. if ( pSoldier && pObject == &(pSoldier->inv[HANDPOS] ) && ( Item[ pSoldier->inv[ HANDPOS ].usItem ].usItemClass == IC_GUN ) && pSoldier->bWeaponMode != WM_NORMAL )
  1727. {
  1728. SetFontForeground( FONT_DKRED );
  1729. sNewY = sY + 13; // rather arbitrary
  1730. if ( pSoldier->bWeaponMode == WM_BURST )
  1731. {
  1732. swprintf( pStr, L"*" );
  1733. }
  1734. else
  1735. {
  1736. swprintf( pStr, L"+" );
  1737. }
  1738. // Get length of string
  1739. uiStringLength=StringPixLength(pStr, ITEM_FONT );
  1740. sNewX = sX + sWidth - uiStringLength - 4;
  1741. if ( uiBuffer == guiSAVEBUFFER )
  1742. {
  1743. RestoreExternBackgroundRect( sNewX, sNewY, 15, 15 );
  1744. }
  1745. mprintf( sNewX, sNewY, pStr );
  1746. gprintfinvalidate( sNewX, sNewY, pStr );
  1747. }
  1748. }
  1749. }
  1750. if ( pubHighlightCounter != NULL )
  1751. {
  1752. SetFontBackground( FONT_MCOLOR_BLACK );
  1753. SetFontForeground( FONT_MCOLOR_LTGRAY );
  1754. // DO HIGHLIGHT
  1755. if ( *pubHighlightCounter )
  1756. {
  1757. // Set string
  1758. if ( ubStatusIndex < RENDER_ITEM_ATTACHMENT1 )
  1759. {
  1760. swprintf( pStr, L"%s", ShortItemNames[ pObject->usItem ] );
  1761. }
  1762. else
  1763. {
  1764. swprintf( pStr, L"%s", ShortItemNames[ pObject->usAttachItem[ ubStatusIndex - RENDER_ITEM_ATTACHMENT1 ] ] );
  1765. }
  1766. fLineSplit = WrapString( pStr, pStr2, WORD_WRAP_INV_WIDTH, ITEM_FONT );
  1767. VarFindFontCenterCoordinates( sX, sY, sWidth, sHeight , ITEM_FONT, &sFontX, &sFontY, pStr );
  1768. sFontY = sY + 1;
  1769. gprintfinvalidate( sFontX, sFontY, pStr );
  1770. if ( fLineSplit )
  1771. {
  1772. VarFindFontCenterCoordinates( sX, sY, sWidth, sHeight , ITEM_FONT, &sFontX2, &sFontY2, pStr2 );
  1773. sFontY2 = sY + 13;
  1774. gprintfinvalidate( sFontX2, sFontY2, pStr2 );
  1775. }
  1776. }
  1777. if ( *pubHighlightCounter == 2 )
  1778. {
  1779. mprintf( sFontX, sFontY, pStr );
  1780. if ( fLineSplit )
  1781. {
  1782. mprintf( sFontX2, sFontY2, pStr2 );
  1783. }
  1784. }
  1785. else if ( *pubHighlightCounter == 1 )
  1786. {
  1787. *pubHighlightCounter = 0;
  1788. gprintfRestore( sFontX, sFontY, pStr );
  1789. if ( fLineSplit )
  1790. {
  1791. gprintfRestore( sFontX2, sFontY2, pStr2 );
  1792. }
  1793. }
  1794. }
  1795. }
  1796. BOOLEAN InItemDescriptionBox( )
  1797. {
  1798. return( gfInItemDescBox );
  1799. }
  1800. void CycleItemDescriptionItem( )
  1801. {
  1802. INT16 usOldItem;
  1803. // Delete old box...
  1804. DeleteItemDescriptionBox( );
  1805. // Make new item....
  1806. usOldItem = gpItemDescSoldier->inv[ HANDPOS ].usItem;
  1807. if ( _KeyDown( SHIFT ) )
  1808. {
  1809. usOldItem--;
  1810. if ( usOldItem < 0 )
  1811. {
  1812. usOldItem = MAXITEMS-1;
  1813. }
  1814. }
  1815. else
  1816. {
  1817. usOldItem++;
  1818. if ( usOldItem > MAXITEMS )
  1819. {
  1820. usOldItem = 0;
  1821. }
  1822. }
  1823. CreateItem( (UINT16)usOldItem, 100, &( gpItemDescSoldier->inv[ HANDPOS ] ) );
  1824. InternalInitItemDescriptionBox( &( gpItemDescSoldier->inv[ HANDPOS ] ), 214, (INT16)(INV_INTERFACE_START_Y + 1 ), gubItemDescStatusIndex, gpItemDescSoldier );
  1825. }
  1826. BOOLEAN InitItemDescriptionBox( SOLDIERTYPE *pSoldier, UINT8 ubPosition, INT16 sX, INT16 sY, UINT8 ubStatusIndex )
  1827. {
  1828. OBJECTTYPE *pObject;
  1829. //DEF:
  1830. //if we are in the shopkeeper screen, and we are to use the
  1831. if( guiCurrentScreen == SHOPKEEPER_SCREEN && ubPosition == 255 )
  1832. {
  1833. pObject = pShopKeeperItemDescObject;
  1834. }
  1835. //else use item from the hand position
  1836. else
  1837. {
  1838. pObject = &(pSoldier->inv[ ubPosition ] );
  1839. }
  1840. return( InternalInitItemDescriptionBox( pObject, sX, sY, ubStatusIndex, pSoldier ) );
  1841. }
  1842. BOOLEAN InitKeyItemDescriptionBox( SOLDIERTYPE *pSoldier, UINT8 ubPosition, INT16 sX, INT16 sY, UINT8 ubStatusIndex )
  1843. {
  1844. OBJECTTYPE *pObject;
  1845. AllocateObject( &pObject );
  1846. CreateKeyObject( pObject, pSoldier->pKeyRing[ ubPosition ].ubNumber ,pSoldier->pKeyRing[ ubPosition ].ubKeyID );
  1847. return( InternalInitItemDescriptionBox( pObject, sX, sY, ubStatusIndex, pSoldier ) );
  1848. }
  1849. BOOLEAN InternalInitItemDescriptionBox( OBJECTTYPE *pObject, INT16 sX, INT16 sY, UINT8 ubStatusIndex, SOLDIERTYPE *pSoldier )
  1850. {
  1851. VOBJECT_DESC VObjectDesc;
  1852. UINT8 ubString[48];
  1853. INT32 cnt;
  1854. INT16 pStr[10];
  1855. UINT16 usX, usY;
  1856. INT16 sForeColour;
  1857. INT16 sProsConsIndent;
  1858. //Set the current screen
  1859. guiCurrentItemDescriptionScreen = guiCurrentScreen;
  1860. // Set X, Y
  1861. gsInvDescX = sX;
  1862. gsInvDescY = sY;
  1863. gpItemDescObject = pObject;
  1864. gubItemDescStatusIndex = ubStatusIndex;
  1865. gpItemDescSoldier = pSoldier;
  1866. fItemDescDelete = FALSE;
  1867. // Build a mouse region here that is over any others.....
  1868. if (guiCurrentItemDescriptionScreen == MAP_SCREEN )
  1869. {
  1870. //return( FALSE );
  1871. MSYS_DefineRegion( &gInvDesc, (UINT16)gsInvDescX, (UINT16)gsInvDescY ,(UINT16)(gsInvDescX + MAP_ITEMDESC_WIDTH), (UINT16)(gsInvDescY + MAP_ITEMDESC_HEIGHT), MSYS_PRIORITY_HIGHEST - 2,
  1872. CURSOR_NORMAL, MSYS_NO_CALLBACK, ItemDescCallback );
  1873. MSYS_AddRegion( &gInvDesc);
  1874. giMapInvDescButtonImage= LoadButtonImage( "INTERFACE\\itemdescdonebutton.sti" ,-1,0,-1,1,-1 );
  1875. // create button
  1876. giMapInvDescButton= QuickCreateButton( giMapInvDescButtonImage, (UINT16)( gsInvDescX + 204 ), (UINT16)( gsInvDescY + 107 ),
  1877. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  1878. ( GUI_CALLBACK )BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)ItemDescDoneButtonCallback );
  1879. fShowDescriptionFlag = TRUE;
  1880. }
  1881. else
  1882. {
  1883. MSYS_DefineRegion( &gInvDesc, (UINT16)gsInvDescX, (UINT16)gsInvDescY ,(UINT16)(gsInvDescX + ITEMDESC_WIDTH), (UINT16)(gsInvDescY + ITEMDESC_HEIGHT), MSYS_PRIORITY_HIGHEST,
  1884. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemDescCallback );
  1885. MSYS_AddRegion( &gInvDesc);
  1886. }
  1887. // Add region
  1888. if ( (Item[ pObject->usItem ].usItemClass & IC_GUN) && pObject->usItem != ROCKET_LAUNCHER )
  1889. {
  1890. // Add button
  1891. // if( guiCurrentScreen != MAP_SCREEN )
  1892. //if( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  1893. swprintf( pStr, L"%d/%d", gpItemDescObject->ubGunShotsLeft, Weapon[ gpItemDescObject->usItem ].ubMagSize );
  1894. FilenameForBPP("INTERFACE\\infobox.sti", ubString);
  1895. sForeColour = ITEMDESC_AMMO_FORE;
  1896. switch( pObject->ubGunAmmoType )
  1897. {
  1898. case AMMO_AP:
  1899. case AMMO_SUPER_AP:
  1900. //sForeColour = ITEMDESC_FONTAPFORE;
  1901. giItemDescAmmoButtonImages = LoadButtonImage(ubString,8,5,-1,7,-1 );
  1902. break;
  1903. case AMMO_HP:
  1904. //sForeColour = ITEMDESC_FONTHPFORE;
  1905. giItemDescAmmoButtonImages = LoadButtonImage(ubString,12,9,-1,11,-1 );
  1906. break;
  1907. default:
  1908. //sForeColour = FONT_MCOLOR_WHITE;
  1909. giItemDescAmmoButtonImages = LoadButtonImage(ubString,4,1,-1,3,-1 );
  1910. break;
  1911. }
  1912. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  1913. {
  1914. // in mapscreen, move over a bit
  1915. giItemDescAmmoButton = CreateIconAndTextButton( giItemDescAmmoButtonImages, pStr, TINYFONT1,
  1916. sForeColour, FONT_MCOLOR_BLACK,
  1917. sForeColour, FONT_MCOLOR_BLACK,
  1918. TEXT_CJUSTIFIED,
  1919. (INT16)(ITEMDESC_AMMO_X + 18), (INT16)(ITEMDESC_AMMO_Y - 5), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST,
  1920. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemDescAmmoCallback );
  1921. }
  1922. else
  1923. {
  1924. // not in mapscreen
  1925. giItemDescAmmoButton = CreateIconAndTextButton( giItemDescAmmoButtonImages, pStr, TINYFONT1,
  1926. sForeColour, FONT_MCOLOR_BLACK,
  1927. sForeColour, FONT_MCOLOR_BLACK,
  1928. TEXT_CJUSTIFIED,
  1929. (INT16)(ITEMDESC_AMMO_X), (INT16)(ITEMDESC_AMMO_Y), BUTTON_TOGGLE ,MSYS_PRIORITY_HIGHEST,
  1930. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemDescAmmoCallback );
  1931. //if we are being called from the
  1932. }
  1933. //if we are being init from the shop keeper screen and this is a dealer item we are getting info from
  1934. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE && pShopKeeperItemDescObject != NULL )
  1935. {
  1936. //disable the eject button
  1937. SpecifyDisabledButtonStyle( giItemDescAmmoButton, DISABLED_STYLE_HATCHED );
  1938. DisableButton( giItemDescAmmoButton );
  1939. SetButtonFastHelpText( giItemDescAmmoButton, L"\0" );
  1940. }
  1941. else
  1942. SetButtonFastHelpText( giItemDescAmmoButton, Message[ STR_EJECT_AMMO ] );
  1943. FindFontCenterCoordinates( (INT16)ITEMDESC_AMMO_TEXT_X, (INT16)ITEMDESC_AMMO_TEXT_Y, ITEMDESC_AMMO_TEXT_WIDTH, GetFontHeight( TINYFONT1 ), pStr, TINYFONT1, &usX, &usY);
  1944. SpecifyButtonTextOffsets( giItemDescAmmoButton, (UINT8) usX, (UINT8) usY, TRUE );
  1945. gfItemAmmoDown = FALSE;
  1946. }
  1947. if ( ITEM_PROS_AND_CONS( gpItemDescObject->usItem ) )
  1948. {
  1949. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  1950. {
  1951. sProsConsIndent = __max( StringPixLength( gzProsLabel, ITEMDESC_FONT ), StringPixLength( gzConsLabel, ITEMDESC_FONT ) ) + 10;
  1952. for ( cnt = 0; cnt < 2; cnt++ )
  1953. {
  1954. // Add region for pros/cons help text
  1955. MSYS_DefineRegion( &gProsAndConsRegions[ cnt ],
  1956. (INT16)(ITEMDESC_PROS_START_X + sProsConsIndent),
  1957. (INT16)(gsInvDescY + gMapItemDescProsConsRects[ cnt ].iTop),
  1958. (INT16)(gsInvDescX + gMapItemDescProsConsRects[ cnt ].iRight),
  1959. (INT16)(gsInvDescY + gMapItemDescProsConsRects[ cnt ].iBottom),
  1960. MSYS_PRIORITY_HIGHEST, MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemDescCallback );
  1961. MSYS_AddRegion( &gProsAndConsRegions[cnt]);
  1962. if (cnt == 0)
  1963. {
  1964. wcscpy( gzFullItemPros, gzProsLabel );
  1965. wcscat( gzFullItemPros, L" " );
  1966. // use temp variable to prevent an initial comma from being displayed
  1967. GenerateProsString( gzFullItemTemp, gpItemDescObject, 1000 );
  1968. wcscat( gzFullItemPros, gzFullItemTemp );
  1969. SetRegionFastHelpText( &(gProsAndConsRegions[ cnt ]), gzFullItemPros );
  1970. }
  1971. else
  1972. {
  1973. wcscpy( gzFullItemCons, gzConsLabel );
  1974. wcscat( gzFullItemCons, L" " );
  1975. // use temp variable to prevent an initial comma from being displayed
  1976. GenerateConsString( gzFullItemTemp, gpItemDescObject, 1000 );
  1977. wcscat( gzFullItemCons, gzFullItemTemp );
  1978. SetRegionFastHelpText( &(gProsAndConsRegions[ cnt ]), gzFullItemCons );
  1979. }
  1980. SetRegionHelpEndCallback( &(gProsAndConsRegions[ cnt ]), HelpTextDoneCallback );
  1981. }
  1982. }
  1983. else
  1984. {
  1985. sProsConsIndent = __max( StringPixLength( gzProsLabel, ITEMDESC_FONT ), StringPixLength( gzConsLabel, ITEMDESC_FONT ) ) + 10;
  1986. for ( cnt = 0; cnt < 2; cnt++ )
  1987. {
  1988. // Add region for pros/cons help text
  1989. MSYS_DefineRegion( &gProsAndConsRegions[ cnt ],
  1990. (INT16)(ITEMDESC_PROS_START_X + sProsConsIndent),
  1991. (INT16)(gsInvDescY + gItemDescProsConsRects[ cnt ].iTop),
  1992. (INT16)(gsInvDescX + gItemDescProsConsRects[ cnt ].iRight),
  1993. (INT16)(gsInvDescY + gItemDescProsConsRects[ cnt ].iBottom),
  1994. MSYS_PRIORITY_HIGHEST, MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemDescCallback );
  1995. MSYS_AddRegion( &gProsAndConsRegions[cnt]);
  1996. if (cnt == 0)
  1997. {
  1998. wcscpy( gzFullItemPros, gzProsLabel );
  1999. wcscat( gzFullItemPros, L" " );
  2000. // use temp variable to prevent an initial comma from being displayed
  2001. GenerateProsString( gzFullItemTemp, gpItemDescObject, 1000 );
  2002. wcscat( gzFullItemPros, gzFullItemTemp );
  2003. SetRegionFastHelpText( &(gProsAndConsRegions[ cnt ]), gzFullItemPros );
  2004. }
  2005. else
  2006. {
  2007. wcscpy( gzFullItemCons, gzConsLabel );
  2008. wcscat( gzFullItemCons, L" " );
  2009. // use temp variable to prevent an initial comma from being displayed
  2010. GenerateConsString( gzFullItemTemp, gpItemDescObject, 1000 );
  2011. wcscat( gzFullItemCons, gzFullItemTemp );
  2012. SetRegionFastHelpText( &(gProsAndConsRegions[ cnt ]), gzFullItemCons );
  2013. }
  2014. SetRegionHelpEndCallback( &(gProsAndConsRegions[ cnt ]), HelpTextDoneCallback );
  2015. }
  2016. }
  2017. }
  2018. // Load graphic
  2019. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  2020. strcpy( VObjectDesc.ImageFile, "INTERFACE\\infobox.sti" );
  2021. CHECKF( AddVideoObject( &VObjectDesc, &guiItemDescBox) );
  2022. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  2023. strcpy( VObjectDesc.ImageFile, "INTERFACE\\iteminfoc.STI" );
  2024. CHECKF( AddVideoObject( &VObjectDesc, &guiMapItemDescBox) );
  2025. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  2026. strcpy( VObjectDesc.ImageFile, "INTERFACE\\bullet.STI" );
  2027. CHECKF( AddVideoObject( &VObjectDesc, &guiBullet) );
  2028. if ( gpItemDescObject->usItem != MONEY )
  2029. {
  2030. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  2031. {
  2032. // Build a mouse region here that is over any others.....
  2033. // if (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  2034. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  2035. MSYS_DefineRegion( &gItemDescAttachmentRegions[cnt], (INT16)(gsInvDescX + gMapItemDescAttachmentsXY[cnt].sX), (INT16)(gsInvDescY + gMapItemDescAttachmentsXY[cnt].sY), (INT16)(gsInvDescX + gMapItemDescAttachmentsXY[cnt].sX + gMapItemDescAttachmentsXY[cnt].sWidth), (INT16)(gsInvDescY + gMapItemDescAttachmentsXY[cnt].sY + gMapItemDescAttachmentsXY[cnt].sHeight), MSYS_PRIORITY_HIGHEST,
  2036. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemDescAttachmentsCallback );
  2037. else
  2038. MSYS_DefineRegion( &gItemDescAttachmentRegions[cnt], (INT16)(gsInvDescX + gItemDescAttachmentsXY[cnt].sX), (INT16)(gsInvDescY + gItemDescAttachmentsXY[cnt].sY), (INT16)(gsInvDescX + gItemDescAttachmentsXY[cnt].sX + gItemDescAttachmentsXY[cnt].sBarDx + gItemDescAttachmentsXY[cnt].sWidth), (INT16)(gsInvDescY + gItemDescAttachmentsXY[cnt].sY + gItemDescAttachmentsXY[cnt].sHeight), MSYS_PRIORITY_HIGHEST,
  2039. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemDescAttachmentsCallback );
  2040. // Add region
  2041. MSYS_AddRegion( &gItemDescAttachmentRegions[cnt]);
  2042. MSYS_SetRegionUserData( &gItemDescAttachmentRegions[cnt], 0, cnt );
  2043. if ( gpItemDescObject->usAttachItem[ cnt ] != NOTHING )
  2044. {
  2045. SetRegionFastHelpText( &(gItemDescAttachmentRegions[ cnt ]), ItemNames[ gpItemDescObject->usAttachItem[ cnt ] ] );
  2046. SetRegionHelpEndCallback( &(gItemDescAttachmentRegions[ cnt ]), HelpTextDoneCallback );
  2047. }
  2048. else
  2049. {
  2050. SetRegionFastHelpText( &(gItemDescAttachmentRegions[ cnt ]), Message[ STR_ATTACHMENTS ] );
  2051. SetRegionHelpEndCallback( &(gItemDescAttachmentRegions[ cnt ]), HelpTextDoneCallback );
  2052. }
  2053. }
  2054. }
  2055. else
  2056. {
  2057. memset( &gRemoveMoney, 0, sizeof( REMOVE_MONEY ) );
  2058. gRemoveMoney.uiTotalAmount = gpItemDescObject->uiMoneyAmount;
  2059. gRemoveMoney.uiMoneyRemaining = gpItemDescObject->uiMoneyAmount;
  2060. gRemoveMoney.uiMoneyRemoving = 0;
  2061. // Load graphic
  2062. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  2063. strcpy( VObjectDesc.ImageFile, "INTERFACE\\info_bil.sti" );
  2064. CHECKF( AddVideoObject( &VObjectDesc, &guiMoneyGraphicsForDescBox) );
  2065. //Create buttons for the money
  2066. // if (guiCurrentScreen == MAP_SCREEN )
  2067. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  2068. {
  2069. guiMoneyButtonImage = LoadButtonImage("INTERFACE\\Info_bil.sti", -1,1,-1,2,-1 );
  2070. for(cnt=0; cnt<MAX_ATTACHMENTS-1; cnt++)
  2071. {
  2072. guiMoneyButtonBtn[cnt] = CreateIconAndTextButton( guiMoneyButtonImage, gzMoneyAmounts[cnt], BLOCKFONT2,
  2073. 5, DEFAULT_SHADOW,
  2074. 5, DEFAULT_SHADOW,
  2075. TEXT_CJUSTIFIED,
  2076. (UINT16)(gMapMoneyButtonLoc.x + gMoneyButtonOffsets[cnt].x), (UINT16)(gMapMoneyButtonLoc.y + gMoneyButtonOffsets[cnt].y), BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  2077. DEFAULT_MOVE_CALLBACK, BtnMoneyButtonCallback );
  2078. MSYS_SetBtnUserData( guiMoneyButtonBtn[cnt], 0, cnt);
  2079. if( cnt == M_1000 && gRemoveMoney.uiTotalAmount < 1000 )
  2080. DisableButton( guiMoneyButtonBtn[cnt] );
  2081. else if( cnt == M_100 && gRemoveMoney.uiTotalAmount < 100 )
  2082. DisableButton( guiMoneyButtonBtn[cnt] );
  2083. else if( cnt == M_10 && gRemoveMoney.uiTotalAmount < 10 )
  2084. DisableButton( guiMoneyButtonBtn[cnt] );
  2085. }
  2086. //Create the Done button
  2087. guiMoneyDoneButtonImage = UseLoadedButtonImage( guiMoneyButtonImage, -1,3,-1,4,-1 );
  2088. guiMoneyButtonBtn[cnt] = CreateIconAndTextButton( guiMoneyDoneButtonImage, gzMoneyAmounts[cnt], BLOCKFONT2,
  2089. 5, DEFAULT_SHADOW,
  2090. 5, DEFAULT_SHADOW,
  2091. TEXT_CJUSTIFIED,
  2092. (UINT16)(gMapMoneyButtonLoc.x + gMoneyButtonOffsets[cnt].x), (UINT16)(gMapMoneyButtonLoc.y + gMoneyButtonOffsets[cnt].y), BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  2093. DEFAULT_MOVE_CALLBACK, BtnMoneyButtonCallback );
  2094. MSYS_SetBtnUserData( guiMoneyButtonBtn[cnt], 0, cnt);
  2095. }
  2096. else
  2097. {
  2098. guiMoneyButtonImage = LoadButtonImage("INTERFACE\\Info_bil.sti", -1,1,-1,2,-1 );
  2099. for(cnt=0; cnt<MAX_ATTACHMENTS-1; cnt++)
  2100. {
  2101. guiMoneyButtonBtn[cnt] = CreateIconAndTextButton( guiMoneyButtonImage, gzMoneyAmounts[cnt], BLOCKFONT2,
  2102. 5, DEFAULT_SHADOW,
  2103. 5, DEFAULT_SHADOW,
  2104. TEXT_CJUSTIFIED,
  2105. (UINT16)(gMoneyButtonLoc.x + gMoneyButtonOffsets[cnt].x), (UINT16)(gMoneyButtonLoc.y + gMoneyButtonOffsets[cnt].y), BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  2106. DEFAULT_MOVE_CALLBACK, BtnMoneyButtonCallback );
  2107. MSYS_SetBtnUserData( guiMoneyButtonBtn[cnt], 0, cnt);
  2108. if( cnt == M_1000 && gRemoveMoney.uiTotalAmount < 1000 )
  2109. DisableButton( guiMoneyButtonBtn[cnt] );
  2110. else if( cnt == M_100 && gRemoveMoney.uiTotalAmount < 100 )
  2111. DisableButton( guiMoneyButtonBtn[cnt] );
  2112. else if( cnt == M_10 && gRemoveMoney.uiTotalAmount < 10 )
  2113. DisableButton( guiMoneyButtonBtn[cnt] );
  2114. }
  2115. //Create the Done button
  2116. guiMoneyDoneButtonImage = UseLoadedButtonImage( guiMoneyButtonImage, -1,3,6,4,5 );
  2117. guiMoneyButtonBtn[cnt] = CreateIconAndTextButton( guiMoneyDoneButtonImage, gzMoneyAmounts[cnt], BLOCKFONT2,
  2118. 5, DEFAULT_SHADOW,
  2119. 5, DEFAULT_SHADOW,
  2120. TEXT_CJUSTIFIED,
  2121. (UINT16)(gMoneyButtonLoc.x + gMoneyButtonOffsets[cnt].x), (UINT16)(gMoneyButtonLoc.y + gMoneyButtonOffsets[cnt].y), BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  2122. DEFAULT_MOVE_CALLBACK, BtnMoneyButtonCallback );
  2123. MSYS_SetBtnUserData( guiMoneyButtonBtn[cnt], 0, cnt);
  2124. }
  2125. }
  2126. fInterfacePanelDirty = DIRTYLEVEL2;
  2127. gfInItemDescBox = TRUE;
  2128. CHECKF( ReloadItemDesc( ) );
  2129. if ( gpItemPointer )
  2130. {
  2131. gpAttachSoldier = gpItemPointerSoldier;
  2132. }
  2133. else
  2134. {
  2135. gpAttachSoldier = pSoldier;
  2136. }
  2137. // store attachments that item originally had
  2138. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  2139. {
  2140. gusOriginalAttachItem[ cnt ] = pObject->usAttachItem[ cnt ];
  2141. gbOriginalAttachStatus[ cnt ] = pObject->bAttachStatus[ cnt ];
  2142. }
  2143. if ( (gpItemPointer != NULL) && (gfItemDescHelpTextOffset == FALSE) && (CheckFact( FACT_ATTACHED_ITEM_BEFORE, 0 ) == FALSE) )
  2144. {
  2145. // set up help text for attachments
  2146. for ( cnt = 0; cnt < NUM_INV_HELPTEXT_ENTRIES; cnt++ )
  2147. {
  2148. gItemDescHelpText.iXPosition[ cnt ] += gsInvDescX;
  2149. gItemDescHelpText.iYPosition[ cnt ] += gsInvDescY;
  2150. }
  2151. if ( !(Item[ pObject->usItem ].fFlags & ITEM_HIDDEN_ADDON) && ( ValidAttachment( gpItemPointer->usItem, pObject->usItem ) || ValidLaunchable( gpItemPointer->usItem, pObject->usItem ) || ValidMerge( gpItemPointer->usItem, pObject->usItem ) ) )
  2152. {
  2153. SetUpFastHelpListRegions(
  2154. gItemDescHelpText.iXPosition,
  2155. gItemDescHelpText.iYPosition,
  2156. gItemDescHelpText.iWidth,
  2157. gItemDescHelpText.sString1,
  2158. NUM_INV_HELPTEXT_ENTRIES );
  2159. }
  2160. else
  2161. {
  2162. SetUpFastHelpListRegions(
  2163. gItemDescHelpText.iXPosition,
  2164. gItemDescHelpText.iYPosition,
  2165. gItemDescHelpText.iWidth,
  2166. gItemDescHelpText.sString2,
  2167. NUM_INV_HELPTEXT_ENTRIES );
  2168. }
  2169. StartShowingInterfaceFastHelpText();
  2170. SetFactTrue( FACT_ATTACHED_ITEM_BEFORE );
  2171. gfItemDescHelpTextOffset = TRUE;
  2172. }
  2173. return( TRUE );
  2174. }
  2175. BOOLEAN ReloadItemDesc( )
  2176. {
  2177. if ( !LoadTileGraphicForItem( &(Item[ gpItemDescObject->usItem ]), &guiItemGraphic ) )
  2178. {
  2179. return( FALSE );
  2180. }
  2181. //
  2182. // Load name, desc
  2183. //
  2184. //if the player is extracting money from the players account, use a different item name and description
  2185. if( gfAddingMoneyToMercFromPlayersAccount && gpItemDescObject->usItem == MONEY )
  2186. {
  2187. if ( !LoadItemInfo( MONEY_FOR_PLAYERS_ACCOUNT, gzItemName, gzItemDesc ) )
  2188. {
  2189. return( FALSE );
  2190. }
  2191. }
  2192. else
  2193. {
  2194. if ( !LoadItemInfo( gpItemDescObject->usItem, gzItemName, gzItemDesc ) )
  2195. {
  2196. return( FALSE );
  2197. }
  2198. }
  2199. /*
  2200. if (Item[ gpItemDescObject->usItem ].usItemClass & IC_WEAPON)
  2201. {
  2202. // load item pros and cons
  2203. if ( !LoadItemProsAndCons( gpItemDescObject->usItem, gzItemPros, gzItemCons ) )
  2204. {
  2205. return( FALSE );
  2206. }
  2207. }
  2208. else
  2209. {
  2210. wcscpy( gzItemPros, L"" );
  2211. wcscpy( gzItemCons, L"" );
  2212. }
  2213. */
  2214. return( TRUE );
  2215. }
  2216. void ItemDescAmmoCallback(GUI_BUTTON *btn,INT32 reason)
  2217. {
  2218. static BOOLEAN fRightDown = FALSE;
  2219. INT16 pStr[10];
  2220. /* region gets disabled in SKI for shopkeeper boxes. It now works normally for merc's inventory boxes!
  2221. //if we are currently in the shopkeeper interface, return;
  2222. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  2223. {
  2224. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  2225. return;
  2226. }
  2227. */
  2228. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  2229. {
  2230. fRightDown = TRUE;
  2231. gfItemAmmoDown = TRUE;
  2232. btn->uiFlags |= BUTTON_CLICKED_ON;
  2233. }
  2234. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP && fRightDown )
  2235. {
  2236. fRightDown = FALSE;
  2237. gfItemAmmoDown = FALSE;
  2238. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  2239. {
  2240. if ( gpItemPointer == NULL && EmptyWeaponMagazine( gpItemDescObject, &gItemPointer ) )
  2241. {
  2242. // OK, END the description box
  2243. //fItemDescDelete = TRUE;
  2244. fInterfacePanelDirty = DIRTYLEVEL2;
  2245. gpItemPointer = &gItemPointer;
  2246. gpItemPointerSoldier = gpItemDescSoldier;
  2247. swprintf( pStr, L"0" );
  2248. SpecifyButtonText( giItemDescAmmoButton, pStr );
  2249. // Set mouse
  2250. guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) );
  2251. gusExternVoSubIndex = Item[ gpItemPointer->usItem ].ubGraphicNum;
  2252. MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR );
  2253. MSYS_SetCurrentCursor( EXTERN_CURSOR );
  2254. fMapInventoryItem=TRUE;
  2255. fTeamPanelDirty=TRUE;
  2256. }
  2257. }
  2258. else
  2259. {
  2260. // Set pointer to item
  2261. if ( gpItemPointer == NULL && EmptyWeaponMagazine( gpItemDescObject, &gItemPointer ) )
  2262. {
  2263. gpItemPointer = &gItemPointer;
  2264. gpItemPointerSoldier = gpItemDescSoldier;
  2265. // if in SKI, load item into SKI's item pointer
  2266. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  2267. {
  2268. // pick up bullets from weapon into cursor (don't try to sell)
  2269. BeginSkiItemPointer( PLAYERS_INVENTORY, -1, FALSE );
  2270. }
  2271. // OK, END the description box
  2272. //fItemDescDelete = TRUE;
  2273. fInterfacePanelDirty = DIRTYLEVEL2;
  2274. swprintf( pStr, L"0" );
  2275. SpecifyButtonText( giItemDescAmmoButton, pStr );
  2276. fItemDescDelete = TRUE;
  2277. }
  2278. }
  2279. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  2280. }
  2281. }
  2282. void DoAttachment( void )
  2283. {
  2284. if ( AttachObject( gpItemDescSoldier, gpItemDescObject, gpItemPointer ) )
  2285. {
  2286. if (gpItemPointer->usItem == NOTHING)
  2287. {
  2288. // attachment attached, merge item consumed, etc
  2289. if ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  2290. {
  2291. MAPEndItemPointer( );
  2292. }
  2293. else
  2294. {
  2295. // End Item pickup
  2296. gpItemPointer = NULL;
  2297. EnableSMPanelButtons( TRUE , TRUE );
  2298. MSYS_ChangeRegionCursor( &gSMPanelRegion , CURSOR_NORMAL );
  2299. SetCurrentCursorFromDatabase( CURSOR_NORMAL );
  2300. //if we are currently in the shopkeeper interface
  2301. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  2302. {
  2303. //Clear out the moving cursor
  2304. memset( &gMoveingItem, 0, sizeof( INVENTORY_IN_SLOT ) );
  2305. //change the curosr back to the normal one
  2306. SetSkiCursor( CURSOR_NORMAL );
  2307. }
  2308. }
  2309. }
  2310. if ( gpItemDescObject->usItem == NOTHING )
  2311. {
  2312. // close desc panel panel
  2313. DeleteItemDescriptionBox();
  2314. }
  2315. //Dirty interface
  2316. fInterfacePanelDirty = DIRTYLEVEL2;
  2317. ReloadItemDesc( );
  2318. }
  2319. // re-evaluate repairs
  2320. gfReEvaluateEveryonesNothingToDo = TRUE;
  2321. }
  2322. void PermanantAttachmentMessageBoxCallBack( UINT8 ubExitValue )
  2323. {
  2324. if ( ubExitValue == MSG_BOX_RETURN_YES )
  2325. {
  2326. DoAttachment();
  2327. }
  2328. // else do nothing
  2329. }
  2330. void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason )
  2331. {
  2332. UINT32 uiItemPos;
  2333. static BOOLEAN fRightDown = FALSE;
  2334. if ( gfItemDescObjectIsAttachment )
  2335. {
  2336. // screen out completely
  2337. return;
  2338. }
  2339. uiItemPos = MSYS_GetRegionUserData( pRegion, 0 );
  2340. if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  2341. {
  2342. // if the item being described belongs to a shopkeeper, ignore attempts to pick it up / replace it
  2343. if( ( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) && ( pShopKeeperItemDescObject != NULL ) )
  2344. {
  2345. return;
  2346. }
  2347. // Try to place attachment if something is in our hand
  2348. // require as many APs as to reload
  2349. if ( gpItemPointer != NULL )
  2350. {
  2351. // nb pointer could be NULL because of inventory manipulation in mapscreen from sector inv
  2352. if ( !gpItemPointerSoldier || EnoughPoints( gpItemPointerSoldier, AP_RELOAD_GUN, 0, TRUE ) )
  2353. {
  2354. if ( (Item[ gpItemPointer->usItem ].fFlags & ITEM_INSEPARABLE) && ValidAttachment( gpItemPointer->usItem, gpItemDescObject->usItem ) )
  2355. {
  2356. DoScreenIndependantMessageBox( Message[ STR_PERMANENT_ATTACHMENT ], ( UINT8 )MSG_BOX_FLAG_YESNO, PermanantAttachmentMessageBoxCallBack );
  2357. return;
  2358. }
  2359. DoAttachment();
  2360. }
  2361. }
  2362. else
  2363. {
  2364. // ATE: Make sure we have enough AP's to drop it if we pick it up!
  2365. if ( EnoughPoints( gpItemDescSoldier, ( AP_RELOAD_GUN + AP_PICKUP_ITEM ), 0, TRUE ) )
  2366. {
  2367. // Get attachment if there is one
  2368. // The follwing function will handle if no attachment is here
  2369. if ( RemoveAttachment( gpItemDescObject, (UINT8)uiItemPos, &gItemPointer ) )
  2370. {
  2371. gpItemPointer = &gItemPointer;
  2372. gpItemPointerSoldier = gpItemDescSoldier;
  2373. // if( guiCurrentScreen == MAP_SCREEN )
  2374. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  2375. {
  2376. // Set mouse
  2377. guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) );
  2378. gusExternVoSubIndex = Item[ gpItemPointer->usItem ].ubGraphicNum;
  2379. MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR );
  2380. MSYS_SetCurrentCursor( EXTERN_CURSOR );
  2381. fMapInventoryItem=TRUE;
  2382. fTeamPanelDirty=TRUE;
  2383. }
  2384. //if we are currently in the shopkeeper interface
  2385. else if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  2386. {
  2387. // pick up attachment from item into cursor (don't try to sell)
  2388. BeginSkiItemPointer( PLAYERS_INVENTORY, -1, FALSE );
  2389. }
  2390. //Dirty interface
  2391. fInterfacePanelDirty = DIRTYLEVEL2;
  2392. // re-evaluate repairs
  2393. gfReEvaluateEveryonesNothingToDo = TRUE;
  2394. UpdateItemHatches();
  2395. }
  2396. }
  2397. }
  2398. }
  2399. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_DWN )
  2400. {
  2401. fRightDown = TRUE;
  2402. }
  2403. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP && fRightDown )
  2404. {
  2405. static OBJECTTYPE Object2;
  2406. fRightDown = FALSE;
  2407. if ( gpItemDescObject->usAttachItem[ uiItemPos ] != NOTHING )
  2408. {
  2409. BOOLEAN fShopkeeperItem = FALSE;
  2410. // remember if this is a shopkeeper's item we're viewing ( pShopKeeperItemDescObject will get nuked on deletion )
  2411. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE && pShopKeeperItemDescObject != NULL )
  2412. {
  2413. fShopkeeperItem = TRUE;
  2414. }
  2415. DeleteItemDescriptionBox( );
  2416. if ( CreateItem( gpItemDescObject->usAttachItem[ uiItemPos ], gpItemDescObject->bAttachStatus[ uiItemPos ], &Object2 ) )
  2417. {
  2418. gfItemDescObjectIsAttachment = TRUE;
  2419. InternalInitItemDescriptionBox( &Object2, gsInvDescX, gsInvDescY, 0, gpItemDescSoldier );
  2420. if ( fShopkeeperItem )
  2421. {
  2422. pShopKeeperItemDescObject = &Object2;
  2423. StartSKIDescriptionBox( );
  2424. }
  2425. }
  2426. }
  2427. }
  2428. }
  2429. void RenderItemDescriptionBox( )
  2430. {
  2431. ETRLEObject *pTrav;
  2432. UINT32 usHeight, usWidth;
  2433. INT16 sCenX, sCenY, sStrX;
  2434. HVOBJECT hVObject;
  2435. CHAR16 sTempString[ 128 ];
  2436. UINT16 uiStringLength, uiRightLength;
  2437. static INT16 pStr[ 100 ];
  2438. INT32 cnt;
  2439. FLOAT fWeight;
  2440. UINT16 usX, usY;
  2441. UINT8 ubAttackAPs;
  2442. BOOLEAN fHatchOutAttachments = gfItemDescObjectIsAttachment; // if examining attachment, always hatch out attachment slots
  2443. INT16 sProsConsIndent;
  2444. if( ( guiCurrentItemDescriptionScreen == MAP_SCREEN ) &&(gfInItemDescBox ) )
  2445. {
  2446. // TAKE A LOOK AT THE VIDEO OBJECT SIZE ( ONE OF TWO SIZES ) AND CENTER!
  2447. GetVideoObject( &hVObject, guiItemGraphic );
  2448. pTrav = &(hVObject->pETRLEObject[ 0 ] );
  2449. usHeight = (UINT32)pTrav->usHeight;
  2450. usWidth = (UINT32)pTrav->usWidth;
  2451. // CENTER IN SLOT!
  2452. // REMOVE OFFSETS!
  2453. sCenX = MAP_ITEMDESC_ITEM_X + ( abs( ITEMDESC_ITEM_WIDTH - usWidth ) / 2 ) - pTrav->sOffsetX;
  2454. sCenY = MAP_ITEMDESC_ITEM_Y + ( abs( ITEMDESC_ITEM_HEIGHT - usHeight ) / 2 )- pTrav->sOffsetY;
  2455. BltVideoObjectFromIndex( guiSAVEBUFFER, guiMapItemDescBox, 0, gsInvDescX, gsInvDescY, VO_BLT_SRCTRANSPARENCY, NULL );
  2456. //Display the money 'seperating' border
  2457. if ( gpItemDescObject->usItem == MONEY )
  2458. {
  2459. //Render the money Boxes
  2460. BltVideoObjectFromIndex( guiSAVEBUFFER, guiMoneyGraphicsForDescBox, 0, (UINT16)(gMapMoneyButtonLoc.x + gMoneyButtonOffsets[0].x), (UINT16)(gMapMoneyButtonLoc.y + gMoneyButtonOffsets[0].y), VO_BLT_SRCTRANSPARENCY, NULL );
  2461. }
  2462. // Display item
  2463. BltVideoObjectOutlineShadowFromIndex( guiSAVEBUFFER, guiItemGraphic, 0, sCenX - 2, sCenY + 2 );
  2464. BltVideoObjectFromIndex( guiSAVEBUFFER, guiItemGraphic, 0, sCenX, sCenY, VO_BLT_SRCTRANSPARENCY, NULL );
  2465. // Display ststus
  2466. DrawItemUIBarEx( gpItemDescObject, gubItemDescStatusIndex, (INT16)MAP_ITEMDESC_ITEM_STATUS_X, (INT16)MAP_ITEMDESC_ITEM_STATUS_Y, ITEMDESC_ITEM_STATUS_WIDTH, ITEMDESC_ITEM_STATUS_HEIGHT_MAP, Get16BPPColor( DESC_STATUS_BAR ), Get16BPPColor( DESC_STATUS_BAR_SHADOW ), TRUE, guiSAVEBUFFER );
  2467. if (gpItemPointer)
  2468. {
  2469. if ( ( Item[ gpItemPointer->usItem ].fFlags & ITEM_HIDDEN_ADDON ) ||
  2470. ( !ValidItemAttachment( gpItemDescObject, gpItemPointer->usItem, FALSE ) &&
  2471. !ValidMerge( gpItemPointer->usItem, gpItemDescObject->usItem ) && !ValidLaunchable( gpItemPointer->usItem, gpItemDescObject->usItem ) ) )
  2472. {
  2473. // hatch out the attachment panels
  2474. fHatchOutAttachments = TRUE;
  2475. }
  2476. }
  2477. // Display attachments
  2478. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  2479. {
  2480. if ( gpItemDescObject->usAttachItem[ cnt ] != NOTHING )
  2481. {
  2482. // if (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  2483. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  2484. {
  2485. sCenX = (INT16)( gsInvDescX + gMapItemDescAttachmentsXY[cnt].sX + 5 );
  2486. sCenY = (INT16)( gsInvDescY + gMapItemDescAttachmentsXY[cnt].sY - 1 );
  2487. INVRenderItem( guiSAVEBUFFER, NULL, gpItemDescObject, sCenX, sCenY, gMapItemDescAttachmentsXY[cnt].sWidth, gMapItemDescAttachmentsXY[cnt].sHeight, DIRTYLEVEL2, NULL, (UINT8)(RENDER_ITEM_ATTACHMENT1 + cnt), FALSE, 0 );
  2488. sCenX = sCenX - gMapItemDescAttachmentsXY[cnt].sBarDx;
  2489. sCenY = sCenY + gMapItemDescAttachmentsXY[cnt].sBarDy;
  2490. DrawItemUIBarEx( gpItemDescObject, (UINT8)(DRAW_ITEM_STATUS_ATTACHMENT1 + cnt), sCenX, sCenY, ITEM_BAR_WIDTH, ITEM_BAR_HEIGHT, Get16BPPColor( STATUS_BAR ), Get16BPPColor( STATUS_BAR_SHADOW ), TRUE , guiSAVEBUFFER );
  2491. }
  2492. else
  2493. {
  2494. sCenX = (INT16)( gsInvDescX + gMapItemDescAttachmentsXY[cnt].sX + 5 );
  2495. sCenY = (INT16)( gsInvDescY + gMapItemDescAttachmentsXY[cnt].sY - 1 );
  2496. INVRenderItem( guiSAVEBUFFER, NULL, gpItemDescObject, sCenX, sCenY, gMapItemDescAttachmentsXY[cnt].sWidth, gMapItemDescAttachmentsXY[cnt].sHeight, DIRTYLEVEL2, NULL, (UINT8)(RENDER_ITEM_ATTACHMENT1 + cnt), FALSE, 0 );
  2497. sCenX = sCenX - gItemDescAttachmentsXY[cnt].sBarDx;
  2498. sCenY = sCenY + gItemDescAttachmentsXY[cnt].sBarDy;
  2499. DrawItemUIBarEx( gpItemDescObject, (UINT8)(DRAW_ITEM_STATUS_ATTACHMENT1 + cnt), sCenX, sCenY, ITEM_BAR_WIDTH, ITEM_BAR_HEIGHT, Get16BPPColor( STATUS_BAR ), Get16BPPColor( STATUS_BAR_SHADOW ), TRUE , guiSAVEBUFFER );
  2500. }
  2501. }
  2502. if (fHatchOutAttachments )
  2503. {
  2504. DrawHatchOnInventory( guiSAVEBUFFER, (INT16) (gsInvDescX + gMapItemDescAttachmentsXY[ cnt ].sX), (INT16) (gsInvDescY + gMapItemDescAttachmentsXY[ cnt ].sY - 2), (INT16)(gMapItemDescAttachmentsXY[ cnt ].sWidth + gMapItemDescAttachmentsXY[ cnt ].sBarDx), (INT16) (gMapItemDescAttachmentsXY[ cnt ].sHeight + 2) );
  2505. }
  2506. }
  2507. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_GUN )
  2508. {
  2509. // display bullets for ROF
  2510. BltVideoObjectFromIndex( guiSAVEBUFFER, guiBullet, 0, MAP_BULLET_SING_X, MAP_BULLET_SING_Y, VO_BLT_SRCTRANSPARENCY, NULL );
  2511. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst > 0)
  2512. {
  2513. for ( cnt = 0; cnt < Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst; cnt++ )
  2514. {
  2515. BltVideoObjectFromIndex( guiSAVEBUFFER, guiBullet, 0, MAP_BULLET_BURST_X + cnt * (BULLET_WIDTH + 1), MAP_BULLET_BURST_Y, VO_BLT_SRCTRANSPARENCY, NULL );
  2516. }
  2517. }
  2518. }
  2519. RestoreExternBackgroundRect( gsInvDescX, gsInvDescY, MAP_ITEMDESC_WIDTH, MAP_ITEMDESC_HEIGHT );
  2520. // Render font desc
  2521. SetFont( ITEMDESC_FONT );
  2522. SetFontBackground( FONT_MCOLOR_BLACK );
  2523. SetFontForeground( FONT_FCOLOR_WHITE );
  2524. SetFontShadow( ITEMDESC_FONTSHADOW3 );
  2525. // Render name
  2526. #ifdef JA2TESTVERSION
  2527. mprintf( MAP_ITEMDESC_NAME_X, MAP_ITEMDESC_NAME_Y, L"%s (%d)", gzItemName, gpItemDescObject->usItem );
  2528. #else
  2529. mprintf( MAP_ITEMDESC_NAME_X, MAP_ITEMDESC_NAME_Y, L"%s", gzItemName );
  2530. #endif
  2531. SetFontForeground( FONT_BLACK );
  2532. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  2533. DisplayWrappedString( (INT16)MAP_ITEMDESC_DESC_START_X, (INT16)MAP_ITEMDESC_DESC_START_Y, MAP_ITEMDESC_DESC_WIDTH, 2, ITEMDESC_FONT, FONT_BLACK, gzItemDesc, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2534. if ( ITEM_PROS_AND_CONS( gpItemDescObject->usItem ) )
  2535. {
  2536. if ( (gpItemDescObject->usItem == ROCKET_RIFLE || gpItemDescObject->usItem == AUTO_ROCKET_RIFLE) && gpItemDescObject->ubImprintID < NO_PROFILE )
  2537. {
  2538. // add name noting imprint
  2539. swprintf( pStr, L"%s %s (%s)", AmmoCaliber[ Weapon[ gpItemDescObject->usItem ].ubCalibre ], WeaponType[ Weapon[ gpItemDescObject->usItem ].ubWeaponType ], gMercProfiles[ gpItemDescObject->ubImprintID ].zNickname );
  2540. }
  2541. else
  2542. {
  2543. swprintf( pStr, L"%s %s", AmmoCaliber[ Weapon[ gpItemDescObject->usItem ].ubCalibre ], WeaponType[ Weapon[ gpItemDescObject->usItem ].ubWeaponType ] );
  2544. }
  2545. FindFontRightCoordinates( (INT16) MAP_ITEMDESC_CALIBER_X, (INT16) MAP_ITEMDESC_CALIBER_Y, MAP_ITEMDESC_CALIBER_WIDTH, ITEM_STATS_HEIGHT, pStr, ITEMDESC_FONT, &usX, &usY);
  2546. mprintf( usX, usY, pStr );
  2547. SetFontForeground( FONT_MCOLOR_DKWHITE2 );
  2548. SetFontShadow( ITEMDESC_FONTSHADOW3 );
  2549. mprintf( (INT16)MAP_ITEMDESC_PROS_START_X, (INT16)MAP_ITEMDESC_PROS_START_Y, gzProsLabel );
  2550. sProsConsIndent = __max( StringPixLength( gzProsLabel, ITEMDESC_FONT ), StringPixLength( gzConsLabel, ITEMDESC_FONT ) ) + 10;
  2551. GenerateProsString( gzItemPros, gpItemDescObject, MAP_ITEMDESC_DESC_WIDTH - sProsConsIndent - StringPixLength( DOTDOTDOT, ITEMDESC_FONT ) );
  2552. if (gzItemPros[0] != 0)
  2553. {
  2554. SetFontForeground( FONT_BLACK );
  2555. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  2556. DisplayWrappedString( (INT16)(MAP_ITEMDESC_PROS_START_X + sProsConsIndent), (INT16)MAP_ITEMDESC_PROS_START_Y, (INT16)(ITEMDESC_DESC_WIDTH - sProsConsIndent), 2, ITEMDESC_FONT, FONT_BLACK, gzItemPros, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
  2557. }
  2558. SetFontForeground( FONT_MCOLOR_DKWHITE2 );
  2559. SetFontShadow( ITEMDESC_FONTSHADOW3 );
  2560. mprintf( (INT16)MAP_ITEMDESC_CONS_START_X, (INT16)MAP_ITEMDESC_CONS_START_Y, gzConsLabel );
  2561. GenerateConsString( gzItemCons, gpItemDescObject, MAP_ITEMDESC_DESC_WIDTH - sProsConsIndent - StringPixLength( DOTDOTDOT, ITEMDESC_FONT ) );
  2562. if (gzItemCons[0] != 0)
  2563. {
  2564. SetFontForeground( FONT_BLACK );
  2565. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  2566. DisplayWrappedString( (INT16)(MAP_ITEMDESC_CONS_START_X + sProsConsIndent), (INT16)MAP_ITEMDESC_CONS_START_Y, (INT16)(ITEMDESC_DESC_WIDTH - sProsConsIndent), 2, ITEMDESC_FONT, FONT_BLACK, gzItemCons, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2567. }
  2568. }
  2569. /*
  2570. DisplayWrappedString( (INT16)MAP_ITEMDESC_PROS_START_X, (INT16)MAP_ITEMDESC_PROS_START_Y, MAP_ITEMDESC_DESC_WIDTH, 2, ITEMDESC_FONT, FONT_BLACK, gzProsLabel, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2571. if (gzItemPros[0] != 0)
  2572. {
  2573. DisplayWrappedString( (INT16)MAP_ITEMDESC_PROS_START_X, (INT16)MAP_ITEMDESC_PROS_START_Y, MAP_ITEMDESC_DESC_WIDTH, 2, ITEMDESC_FONT, FONT_BLACK, gzItemPros, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2574. }
  2575. DisplayWrappedString( (INT16)MAP_ITEMDESC_CONS_START_X, (INT16)MAP_ITEMDESC_CONS_START_Y, MAP_ITEMDESC_DESC_WIDTH, 2, ITEMDESC_FONT, FONT_BLACK, gzConsLabel, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2576. if (gzItemCons[0] != 0)
  2577. {
  2578. DisplayWrappedString( (INT16)MAP_ITEMDESC_CONS_START_X, (INT16)MAP_ITEMDESC_CONS_START_Y, MAP_ITEMDESC_DESC_WIDTH, 2, ITEMDESC_FONT, FONT_BLACK, gzItemCons, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2579. }
  2580. */
  2581. // Get length of string
  2582. uiRightLength=35;
  2583. fWeight = (float)(CalculateObjectWeight( gpItemDescObject )) / 10;
  2584. if ( !gGameSettings.fOptions[ TOPTION_USE_METRIC_SYSTEM ] ) // metric units not enabled
  2585. {
  2586. fWeight = fWeight * 2.2f;
  2587. }
  2588. // Add weight of attachments here !
  2589. if ( fWeight < 0.1 )
  2590. {
  2591. fWeight = 0.1f;
  2592. }
  2593. // Render, stat name
  2594. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_WEAPON )
  2595. {
  2596. SetFont( BLOCKFONT2 );
  2597. SetFontForeground( 6 );
  2598. SetFontShadow( DEFAULT_SHADOW );
  2599. //LABELS
  2600. swprintf( sTempString, gWeaponStatsDesc[ 0 ], GetWeightUnitString() );
  2601. mprintf( gMapWeaponStats[ 0 ].sX + gsInvDescX, gMapWeaponStats[ 0 ].sY + gsInvDescY, L"%s", sTempString );
  2602. //mprintf( gMapWeaponStats[ 2 ].sX + gsInvDescX, gMapWeaponStats[ 2 ].sY + gsInvDescY, L"%s", gMapWeaponStats[ 2 ].zDesc );
  2603. if ( Item[ gpItemDescObject->usItem ].usItemClass & (IC_GUN | IC_LAUNCHER ) )
  2604. {
  2605. mprintf( gMapWeaponStats[ 3 ].sX + gsInvDescX, gMapWeaponStats[ 3 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 3 ] );
  2606. }
  2607. if ( !(Item[ gpItemDescObject->usItem ].usItemClass & IC_LAUNCHER) && gpItemDescObject->usItem != ROCKET_LAUNCHER )
  2608. {
  2609. mprintf( gMapWeaponStats[ 4 ].sX + gsInvDescX, gMapWeaponStats[ 4 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 4 ] );
  2610. }
  2611. mprintf( gMapWeaponStats[ 5 ].sX + gsInvDescX, gMapWeaponStats[ 5 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 5 ] );
  2612. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_GUN )
  2613. {
  2614. // equals sign
  2615. mprintf( gMapWeaponStats[ 7 ].sX + gsInvDescX, gMapWeaponStats[ 7 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 7 ] );
  2616. }
  2617. mprintf( gMapWeaponStats[ 1 ].sX + gsInvDescX, gMapWeaponStats[ 1 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 1 ] );
  2618. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst > 0)
  2619. {
  2620. mprintf( gMapWeaponStats[ 8 ].sX + gsInvDescX, gMapWeaponStats[ 8 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 8 ] );
  2621. }
  2622. SetFontForeground( 5 );
  2623. //Status
  2624. // This is gross, but to get the % to work out right...
  2625. swprintf( pStr, L"%2d%%", gpItemDescObject->bStatus[ gubItemDescStatusIndex ] );
  2626. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 1 ].sX + gsInvDescX + gMapWeaponStats[ 1 ].sValDx + 6), (INT16)(gMapWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2627. wcscat( pStr, L"%%" );
  2628. mprintf( usX, usY, pStr );
  2629. // Values
  2630. if (fWeight <= (EXCEPTIONAL_WEIGHT / 10))
  2631. {
  2632. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  2633. }
  2634. else
  2635. {
  2636. SetFontForeground( 5 );
  2637. }
  2638. //Weight
  2639. swprintf( pStr, L"%1.1f", fWeight );
  2640. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 0 ].sX + gsInvDescX + gMapWeaponStats[ 0 ].sValDx+6), (INT16)(gMapWeaponStats[ 0 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2641. mprintf( usX, usY, pStr );
  2642. if ( Item[ gpItemDescObject->usItem ].usItemClass & (IC_GUN | IC_LAUNCHER) )
  2643. {
  2644. if ( GunRange( gpItemDescObject ) >= EXCEPTIONAL_RANGE)
  2645. {
  2646. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  2647. }
  2648. else
  2649. {
  2650. SetFontForeground( 5 );
  2651. }
  2652. //Range
  2653. swprintf( pStr, L"%2d", ( GunRange( gpItemDescObject ) ) / 10 );
  2654. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 3 ].sX + gsInvDescX + gMapWeaponStats[ 3 ].sValDx), (INT16)(gMapWeaponStats[ 3 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2655. mprintf( usX, usY, pStr );
  2656. }
  2657. if ( !(Item[ gpItemDescObject->usItem ].usItemClass & IC_LAUNCHER) && gpItemDescObject->usItem != ROCKET_LAUNCHER )
  2658. {
  2659. if (Weapon[ gpItemDescObject->usItem ].ubImpact >= EXCEPTIONAL_DAMAGE)
  2660. {
  2661. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  2662. }
  2663. else
  2664. {
  2665. SetFontForeground( 5 );
  2666. }
  2667. //Damage
  2668. swprintf( pStr, L"%2d", Weapon[ gpItemDescObject->usItem ].ubImpact );
  2669. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 4 ].sX + gsInvDescX + gMapWeaponStats[ 4 ].sValDx), (INT16)(gMapWeaponStats[ 4 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2670. mprintf( usX, usY, pStr );
  2671. }
  2672. ubAttackAPs = BaseAPsToShootOrStab( DEFAULT_APS, DEFAULT_AIMSKILL, gpItemDescObject );
  2673. if (ubAttackAPs <= EXCEPTIONAL_AP_COST)
  2674. {
  2675. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  2676. }
  2677. else
  2678. {
  2679. SetFontForeground( 5 );
  2680. }
  2681. //Ap's
  2682. swprintf( pStr, L"%2d", ubAttackAPs );
  2683. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 5 ].sX + gsInvDescX + gMapWeaponStats[ 5 ].sValDx), (INT16)(gMapWeaponStats[ 5 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2684. mprintf( usX, usY, pStr );
  2685. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst > 0)
  2686. {
  2687. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst >= EXCEPTIONAL_BURST_SIZE || gpItemDescObject->usItem == G11)
  2688. {
  2689. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  2690. }
  2691. else
  2692. {
  2693. SetFontForeground( 5 );
  2694. }
  2695. swprintf( pStr, L"%2d", ubAttackAPs + CalcAPsToBurst( DEFAULT_APS, gpItemDescObject ) );
  2696. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 6 ].sX + gsInvDescX + gMapWeaponStats[ 6 ].sValDx), (INT16)(gMapWeaponStats[ 6 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2697. mprintf( usX, usY, pStr );
  2698. }
  2699. }
  2700. else if ( gpItemDescObject->usItem == MONEY )
  2701. {
  2702. SetFontForeground( FONT_FCOLOR_WHITE );
  2703. SetFontShadow( DEFAULT_SHADOW );
  2704. //
  2705. // Display the total amount of money
  2706. //
  2707. // if the player is taking money from their account
  2708. if( gfAddingMoneyToMercFromPlayersAccount )
  2709. swprintf( pStr, L"%ld", LaptopSaveInfo.iCurrentBalance );
  2710. else
  2711. swprintf( pStr, L"%ld", gRemoveMoney.uiTotalAmount );
  2712. InsertCommasForDollarFigure( pStr );
  2713. InsertDollarSignInToString( pStr );
  2714. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2715. sStrX = MAP_ITEMDESC_NAME_X + ( 245 - uiStringLength );
  2716. mprintf( sStrX, MAP_ITEMDESC_NAME_Y, pStr );
  2717. SetFont( BLOCKFONT2 );
  2718. SetFontForeground( 6 );
  2719. SetFontShadow( DEFAULT_SHADOW );
  2720. //Display the 'Removing'
  2721. mprintf( gMapMoneyStats[ 0 ].sX + gsInvDescX, gMapMoneyStats[ 0 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_AMOUNT ] );
  2722. //Display the 'REmaining'
  2723. mprintf( gMapMoneyStats[ 2 ].sX + gsInvDescX, gMapMoneyStats[ 2 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_AMOUNT_2_SPLIT ] );
  2724. //Display the 'Amt removing'
  2725. mprintf( gMapMoneyStats[ 1 ].sX + gsInvDescX, gMapMoneyStats[ 1 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_REMAINING ] );
  2726. //Display the 'REmaining amount'
  2727. mprintf( gMapMoneyStats[ 3 ].sX + gsInvDescX, gMapMoneyStats[ 3 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_TO_SPLIT ] );
  2728. SetFontForeground( 5 );
  2729. //Display the 'Seperate text'
  2730. mprintf( (UINT16)(gMapMoneyButtonLoc.x + gMoneyButtonOffsets[cnt].x), (UINT16)(gMapMoneyButtonLoc.y + gMoneyButtonOffsets[cnt].y ), gzMoneyAmounts[4] );
  2731. // The Money Remaining
  2732. swprintf( pStr, L"%ld", gRemoveMoney.uiMoneyRemaining );
  2733. InsertCommasForDollarFigure( pStr );
  2734. InsertDollarSignInToString( pStr );
  2735. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2736. sStrX = gMapMoneyStats[ 1 ].sX + gsInvDescX + gMapMoneyStats[ 1 ].sValDx + ( uiRightLength - uiStringLength );
  2737. mprintf( sStrX, gMapMoneyStats[ 1 ].sY + gsInvDescY, pStr );
  2738. // The money removing
  2739. SetFontForeground( 5 );
  2740. swprintf( pStr, L"%ld", gRemoveMoney.uiMoneyRemoving );
  2741. InsertCommasForDollarFigure( pStr );
  2742. InsertDollarSignInToString( pStr );
  2743. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2744. sStrX = gMapMoneyStats[ 3 ].sX + gsInvDescX + gMapMoneyStats[ 3 ].sValDx + ( uiRightLength - uiStringLength );
  2745. mprintf( sStrX, gMapMoneyStats[ 3 ].sY + gsInvDescY, pStr );
  2746. // print label for amount
  2747. // SetFontForeground( ITEMDESC_FONTFORE1 );
  2748. // mprintf( gMapMoneyStats[ 1 ].sX + gsInvDescX, gMapMoneyStats[ 1 ].sY + gsInvDescY, L"%s", gMapMoneyStats[ 1 ].zDesc );
  2749. }
  2750. else if ( Item[ gpItemDescObject->usItem ].usItemClass == IC_MONEY )
  2751. {
  2752. SetFontForeground( FONT_FCOLOR_WHITE );
  2753. SetFontShadow( DEFAULT_SHADOW );
  2754. swprintf( pStr, L"%ld", gpItemDescObject->uiMoneyAmount );
  2755. InsertCommasForDollarFigure( pStr );
  2756. InsertDollarSignInToString( pStr );
  2757. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2758. sStrX = MAP_ITEMDESC_NAME_X + ( 245 - uiStringLength );
  2759. mprintf( sStrX, MAP_ITEMDESC_NAME_Y, pStr );
  2760. }
  2761. else
  2762. {
  2763. //Labels
  2764. SetFont( BLOCKFONT2 );
  2765. SetFontForeground( 6 );
  2766. SetFontShadow( DEFAULT_SHADOW );
  2767. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_AMMO )
  2768. {
  2769. mprintf( gMapWeaponStats[ 2 ].sX + gsInvDescX, gMapWeaponStats[ 2 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 2 ] );
  2770. }
  2771. else
  2772. {
  2773. mprintf( gMapWeaponStats[ 1 ].sX + gsInvDescX, gMapWeaponStats[ 1 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 1 ] );
  2774. }
  2775. swprintf( sTempString, gWeaponStatsDesc[ 0 ], GetWeightUnitString() );
  2776. mprintf( gMapWeaponStats[ 0 ].sX + gsInvDescX, gMapWeaponStats[ 0 ].sY + gsInvDescY, sTempString );
  2777. // Values
  2778. SetFontForeground( 5 );
  2779. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_AMMO )
  2780. {
  2781. // Ammo
  2782. swprintf( pStr, L"%d/%d", gpItemDescObject->ubShotsLeft[0], Magazine[ Item[ gpItemDescObject->usItem ].ubClassIndex ].ubMagSize );
  2783. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2784. // sStrX = gMapWeaponStats[ 0 ].sX + gsInvDescX + gMapWeaponStats[ 0 ].sValDx + ( uiRightLength - uiStringLength );
  2785. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 2 ].sX + gsInvDescX + gMapWeaponStats[ 2 ].sValDx+6), (INT16)(gMapWeaponStats[ 2 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &sStrX, &usY);
  2786. mprintf( sStrX, gMapWeaponStats[ 2 ].sY + gsInvDescY, pStr );
  2787. }
  2788. else
  2789. {
  2790. //Status
  2791. swprintf( pStr, L"%2d%%", gpItemDescObject->bStatus[ gubItemDescStatusIndex ] );
  2792. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2793. // sStrX = gMapWeaponStats[ 1 ].sX + gsInvDescX + gMapWeaponStats[ 1 ].sValDx + ( uiRightLength - uiStringLength );
  2794. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 1 ].sX + gsInvDescX + gMapWeaponStats[ 1 ].sValDx + 6), (INT16)(gMapWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &sStrX, &usY);
  2795. wcscat( pStr, L"%%" );
  2796. mprintf( sStrX, gMapWeaponStats[ 1 ].sY + gsInvDescY, pStr );
  2797. }
  2798. //Weight
  2799. swprintf( pStr, L"%1.1f", fWeight );
  2800. uiStringLength=StringPixLength(pStr, ITEMDESC_FONT );
  2801. // sStrX = gMapWeaponStats[ 0 ].sX + gsInvDescX + gMapWeaponStats[ 0 ].sValDx + ( uiRightLength - uiStringLength );
  2802. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 0 ].sX + gsInvDescX + gMapWeaponStats[ 0 ].sValDx+6), (INT16)(gMapWeaponStats[ 0 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &sStrX, &usY);
  2803. mprintf( sStrX, gMapWeaponStats[ 0 ].sY + gsInvDescY, pStr );
  2804. if ( ( InKeyRingPopup() == TRUE ) || ( Item[ gpItemDescObject->usItem ].usItemClass & IC_KEY ) )
  2805. {
  2806. SetFontForeground( 6 );
  2807. // build description for keys .. the sector found
  2808. swprintf( pStr, L"%s", sKeyDescriptionStrings[ 0 ] );
  2809. mprintf( gMapWeaponStats[ 4 ].sX + gsInvDescX, gMapWeaponStats[ 4 ].sY + gsInvDescY, pStr );
  2810. swprintf( pStr, L"%s", sKeyDescriptionStrings[ 1 ] );
  2811. mprintf( gMapWeaponStats[ 4 ].sX + gsInvDescX, gMapWeaponStats[ 4 ].sY + gsInvDescY + GetFontHeight( BLOCKFONT ) + 2 , pStr );
  2812. SetFontForeground( 5 );
  2813. GetShortSectorString( ( INT16 ) SECTORX( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), ( INT16 ) SECTORY( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), sTempString );
  2814. swprintf( pStr, L"%s", sTempString );
  2815. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gMapWeaponStats[ 4 ].sY + gsInvDescY ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2816. mprintf( usX, usY, pStr );
  2817. swprintf( pStr, L"%d", KeyTable[ gpItemDescObject->ubKeyID ].usDateFound );
  2818. FindFontRightCoordinates( (INT16)(gMapWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gMapWeaponStats[ 4 ].sY + gsInvDescY + GetFontHeight( BLOCKFONT ) + 2 ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2819. mprintf( usX, usY, pStr );
  2820. }
  2821. }
  2822. SetFontShadow( DEFAULT_SHADOW );
  2823. }
  2824. else if ( gfInItemDescBox )
  2825. {
  2826. // TAKE A LOOK AT THE VIDEO OBJECT SIZE ( ONE OF TWO SIZES ) AND CENTER!
  2827. GetVideoObject( &hVObject, guiItemGraphic );
  2828. pTrav = &(hVObject->pETRLEObject[ 0 ] );
  2829. usHeight = (UINT32)pTrav->usHeight;
  2830. usWidth = (UINT32)pTrav->usWidth;
  2831. // CENTER IN SLOT!
  2832. sCenX = ITEMDESC_ITEM_X + ( abs( ITEMDESC_ITEM_WIDTH - usWidth ) / 2 ) - pTrav->sOffsetX;
  2833. sCenY = ITEMDESC_ITEM_Y + ( abs( ITEMDESC_ITEM_HEIGHT - usHeight ) / 2 ) - pTrav->sOffsetY;
  2834. BltVideoObjectFromIndex( guiSAVEBUFFER, guiItemDescBox, 0, gsInvDescX, gsInvDescY, VO_BLT_SRCTRANSPARENCY, NULL );
  2835. if ( gpItemDescObject->usItem == MONEY )
  2836. {
  2837. //Render the money Boxes
  2838. BltVideoObjectFromIndex( guiSAVEBUFFER, guiMoneyGraphicsForDescBox, 0, (UINT16)(gsInvDescX+gItemDescAttachmentsXY[0].sX-1), (UINT16)(gsInvDescY+gItemDescAttachmentsXY[0].sY-2), VO_BLT_SRCTRANSPARENCY, NULL );
  2839. }
  2840. // Display item
  2841. BltVideoObjectOutlineShadowFromIndex( guiSAVEBUFFER, guiItemGraphic, 0, sCenX - 2, sCenY + 2 );
  2842. BltVideoObjectFromIndex( guiSAVEBUFFER, guiItemGraphic, 0, sCenX, sCenY, VO_BLT_SRCTRANSPARENCY, NULL );
  2843. // Display status
  2844. DrawItemUIBarEx( gpItemDescObject, gubItemDescStatusIndex, (INT16)ITEMDESC_ITEM_STATUS_X, (INT16)ITEMDESC_ITEM_STATUS_Y, ITEMDESC_ITEM_STATUS_WIDTH, ITEMDESC_ITEM_STATUS_HEIGHT, Get16BPPColor( DESC_STATUS_BAR ), Get16BPPColor( DESC_STATUS_BAR_SHADOW ), TRUE, guiSAVEBUFFER );
  2845. if (gpItemPointer)
  2846. {
  2847. if ( ( Item[ gpItemPointer->usItem ].fFlags & ITEM_HIDDEN_ADDON ) ||
  2848. ( !ValidItemAttachment( gpItemDescObject, gpItemPointer->usItem, FALSE ) &&
  2849. !ValidMerge( gpItemPointer->usItem, gpItemDescObject->usItem ) && !ValidLaunchable( gpItemPointer->usItem, gpItemDescObject->usItem ) ) )
  2850. {
  2851. // hatch out the attachment panels
  2852. fHatchOutAttachments = TRUE;
  2853. }
  2854. }
  2855. // Display attachments
  2856. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  2857. {
  2858. if ( gpItemDescObject->usAttachItem[ cnt ] != NOTHING )
  2859. {
  2860. sCenX = (INT16)( gsInvDescX + gItemDescAttachmentsXY[cnt].sX + 5 );
  2861. sCenY = (INT16)( gsInvDescY + gItemDescAttachmentsXY[cnt].sY - 1 );
  2862. INVRenderItem( guiSAVEBUFFER, NULL, gpItemDescObject, sCenX, sCenY, gItemDescAttachmentsXY[cnt].sWidth, gItemDescAttachmentsXY[cnt].sHeight, DIRTYLEVEL2, NULL, (UINT8)(RENDER_ITEM_ATTACHMENT1 + cnt), FALSE, 0 );
  2863. sCenX = sCenX - gItemDescAttachmentsXY[cnt].sBarDx;
  2864. sCenY = sCenY + gItemDescAttachmentsXY[cnt].sBarDy;
  2865. DrawItemUIBarEx( gpItemDescObject, (UINT8)(DRAW_ITEM_STATUS_ATTACHMENT1 + cnt), sCenX, sCenY, ITEM_BAR_WIDTH, ITEM_BAR_HEIGHT, Get16BPPColor( STATUS_BAR ), Get16BPPColor( STATUS_BAR_SHADOW ), TRUE , guiSAVEBUFFER );
  2866. SetRegionFastHelpText( &(gItemDescAttachmentRegions[ cnt ]), ItemNames[ gpItemDescObject->usAttachItem[ cnt ] ] );
  2867. SetRegionHelpEndCallback( &(gItemDescAttachmentRegions[ cnt ]), HelpTextDoneCallback );
  2868. }
  2869. else
  2870. {
  2871. SetRegionFastHelpText( &(gItemDescAttachmentRegions[ cnt ]), Message[ STR_ATTACHMENTS ] );
  2872. SetRegionHelpEndCallback( &(gItemDescAttachmentRegions[ cnt ]), HelpTextDoneCallback );
  2873. }
  2874. if (fHatchOutAttachments)
  2875. {
  2876. //UINT32 uiWhichBuffer = ( guiCurrentItemDescriptionScreen == MAP_SCREEN ) ? guiSAVEBUFFER : guiRENDERBUFFER;
  2877. DrawHatchOnInventory( guiSAVEBUFFER, (INT16) (gsInvDescX + gItemDescAttachmentsXY[ cnt ].sX), (INT16) (gsInvDescY + gItemDescAttachmentsXY[ cnt ].sY - 2), (INT16)(gItemDescAttachmentsXY[ cnt ].sWidth + gItemDescAttachmentsXY[ cnt ].sBarDx), (INT16) (gItemDescAttachmentsXY[ cnt ].sHeight + 2) );
  2878. }
  2879. }
  2880. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_GUN )
  2881. {
  2882. // display bullets for ROF
  2883. BltVideoObjectFromIndex( guiSAVEBUFFER, guiBullet, 0, BULLET_SING_X, BULLET_SING_Y, VO_BLT_SRCTRANSPARENCY, NULL );
  2884. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst > 0)
  2885. {
  2886. for ( cnt = 0; cnt < Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst; cnt++ )
  2887. {
  2888. BltVideoObjectFromIndex( guiSAVEBUFFER, guiBullet, 0, BULLET_BURST_X + cnt * (BULLET_WIDTH + 1), BULLET_BURST_Y, VO_BLT_SRCTRANSPARENCY, NULL );
  2889. }
  2890. }
  2891. }
  2892. RestoreExternBackgroundRect( gsInvDescX, gsInvDescY, ITEMDESC_WIDTH, ITEMDESC_HEIGHT );
  2893. // Render font desc
  2894. SetFont( ITEMDESC_FONT );
  2895. SetFontBackground( FONT_MCOLOR_BLACK );
  2896. SetFontForeground( FONT_FCOLOR_WHITE );
  2897. SetFontShadow( ITEMDESC_FONTSHADOW3 );
  2898. // Render name
  2899. // SET CLIPPING RECT FOR FONTS
  2900. #ifdef JA2TESTVERSION
  2901. mprintf( ITEMDESC_NAME_X, ITEMDESC_NAME_Y, L"%s (%d)", gzItemName, gpItemDescObject->usItem );
  2902. #else
  2903. mprintf( ITEMDESC_NAME_X, ITEMDESC_NAME_Y, L"%s", gzItemName );
  2904. #endif
  2905. // Render caliber and description
  2906. SetFontForeground( FONT_BLACK );
  2907. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  2908. DisplayWrappedString( (INT16)ITEMDESC_DESC_START_X, (INT16)ITEMDESC_DESC_START_Y, ITEMDESC_DESC_WIDTH, 2, ITEMDESC_FONT, FONT_BLACK, gzItemDesc, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2909. if ( ITEM_PROS_AND_CONS( gpItemDescObject->usItem ) )
  2910. {
  2911. if ( (gpItemDescObject->usItem == ROCKET_RIFLE || gpItemDescObject->usItem == AUTO_ROCKET_RIFLE) && gpItemDescObject->ubImprintID < NO_PROFILE )
  2912. {
  2913. // add name noting imprint
  2914. swprintf( pStr, L"%s %s (%s)", AmmoCaliber[ Weapon[ gpItemDescObject->usItem ].ubCalibre ], WeaponType[ Weapon[ gpItemDescObject->usItem ].ubWeaponType ], gMercProfiles[ gpItemDescObject->ubImprintID ].zNickname );
  2915. }
  2916. else
  2917. {
  2918. swprintf( pStr, L"%s %s", AmmoCaliber[ Weapon[ gpItemDescObject->usItem ].ubCalibre ], WeaponType[ Weapon[ gpItemDescObject->usItem ].ubWeaponType ] );
  2919. }
  2920. FindFontRightCoordinates( (INT16) ITEMDESC_CALIBER_X, (INT16) ITEMDESC_CALIBER_Y, ITEMDESC_CALIBER_WIDTH, ITEM_STATS_HEIGHT, pStr, ITEMDESC_FONT, &usX, &usY);
  2921. mprintf( usX, usY, pStr );
  2922. SetFontForeground( FONT_MCOLOR_DKWHITE2 );
  2923. SetFontShadow( ITEMDESC_FONTSHADOW3 );
  2924. mprintf( (INT16)ITEMDESC_PROS_START_X, (INT16)ITEMDESC_PROS_START_Y, gzProsLabel );
  2925. sProsConsIndent = __max( StringPixLength( gzProsLabel, ITEMDESC_FONT ), StringPixLength( gzConsLabel, ITEMDESC_FONT ) ) + 10;
  2926. gzItemPros[0] = 0;
  2927. GenerateProsString( gzItemPros, gpItemDescObject, ITEMDESC_DESC_WIDTH - sProsConsIndent - StringPixLength( DOTDOTDOT, ITEMDESC_FONT ) );
  2928. if (gzItemPros[0] != 0)
  2929. {
  2930. SetFontForeground( FONT_BLACK );
  2931. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  2932. DisplayWrappedString( (INT16)(ITEMDESC_PROS_START_X + sProsConsIndent), (INT16)ITEMDESC_PROS_START_Y, (INT16)(ITEMDESC_DESC_WIDTH - sProsConsIndent), 2, ITEMDESC_FONT, FONT_BLACK, gzItemPros, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED );
  2933. }
  2934. SetFontForeground( FONT_MCOLOR_DKWHITE2 );
  2935. SetFontShadow( ITEMDESC_FONTSHADOW3 );
  2936. mprintf( (INT16)ITEMDESC_CONS_START_X, (INT16)ITEMDESC_CONS_START_Y, gzConsLabel );
  2937. GenerateConsString( gzItemCons, gpItemDescObject, ITEMDESC_DESC_WIDTH - sProsConsIndent - StringPixLength( DOTDOTDOT, ITEMDESC_FONT ) );
  2938. if (gzItemCons[0] != 0)
  2939. {
  2940. SetFontForeground( FONT_BLACK );
  2941. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  2942. DisplayWrappedString( (INT16)(ITEMDESC_CONS_START_X + sProsConsIndent), (INT16)ITEMDESC_CONS_START_Y, (INT16)(ITEMDESC_DESC_WIDTH - sProsConsIndent), 2, ITEMDESC_FONT, FONT_BLACK, gzItemCons, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
  2943. }
  2944. }
  2945. // Get length of string
  2946. uiRightLength=35;
  2947. // Calculate total weight of item and attachments
  2948. fWeight = (float)(CalculateObjectWeight( gpItemDescObject )) / 10;
  2949. if ( !gGameSettings.fOptions[ TOPTION_USE_METRIC_SYSTEM ] )
  2950. {
  2951. fWeight = fWeight * 2.2f;
  2952. }
  2953. if ( fWeight < 0.1 )
  2954. {
  2955. fWeight = (float)0.1;
  2956. }
  2957. // Render, stat name
  2958. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_WEAPON )
  2959. {
  2960. SetFont( BLOCKFONT2 );
  2961. SetFontForeground( 6 );
  2962. SetFontShadow( DEFAULT_SHADOW );
  2963. //LABELS
  2964. swprintf( sTempString, gWeaponStatsDesc[ 0 ], GetWeightUnitString() );
  2965. mprintf( gWeaponStats[ 0 ].sX + gsInvDescX, gWeaponStats[ 0 ].sY + gsInvDescY, sTempString );
  2966. // mprintf( gWeaponStats[ 1 ].sX + gsInvDescX, gWeaponStats[ 1 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 1 ].zDesc );
  2967. // mprintf( gWeaponStats[ 2 ].sX + gsInvDescX, gWeaponStats[ 2 ].sY + gsInvDescY, L"%s", gWeaponStats[ 2 ].zDesc );
  2968. if ( Item[ gpItemDescObject->usItem ].usItemClass & (IC_GUN | IC_LAUNCHER ) )
  2969. {
  2970. mprintf( gWeaponStats[ 3 ].sX + gsInvDescX, gWeaponStats[ 3 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 3 ] );
  2971. }
  2972. if ( !(Item[ gpItemDescObject->usItem ].usItemClass & IC_LAUNCHER) && gpItemDescObject->usItem != ROCKET_LAUNCHER )
  2973. {
  2974. mprintf( gWeaponStats[ 4 ].sX + gsInvDescX, gWeaponStats[ 4 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 4 ] );
  2975. }
  2976. mprintf( gWeaponStats[ 5 ].sX + gsInvDescX, gWeaponStats[ 5 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 5 ] );
  2977. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_GUN )
  2978. {
  2979. mprintf( gWeaponStats[ 7 ].sX + gsInvDescX, gWeaponStats[ 7 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 7 ] );
  2980. }
  2981. mprintf( gWeaponStats[ 1 ].sX + gsInvDescX, gWeaponStats[ 1 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 1 ] );
  2982. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst > 0)
  2983. {
  2984. mprintf( gWeaponStats[ 8 ].sX + gsInvDescX, gWeaponStats[ 8 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 8 ] );
  2985. }
  2986. // Values
  2987. if (fWeight <= (EXCEPTIONAL_WEIGHT / 10))
  2988. {
  2989. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  2990. }
  2991. else
  2992. {
  2993. SetFontForeground( 5 );
  2994. }
  2995. //Status
  2996. swprintf( pStr, L"%2d%%", gpItemDescObject->bGunStatus );
  2997. FindFontRightCoordinates( (INT16)(gWeaponStats[ 1 ].sX + gsInvDescX + gWeaponStats[ 1 ].sValDx), (INT16)(gWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  2998. wcscat( pStr, L"%%" );
  2999. mprintf( usX, usY, pStr );
  3000. //Wieght
  3001. swprintf( pStr, L"%1.1f", fWeight );
  3002. FindFontRightCoordinates( (INT16)(gWeaponStats[ 0 ].sX + gsInvDescX + gWeaponStats[ 0 ].sValDx), (INT16)(gWeaponStats[ 0 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3003. mprintf( usX, usY, pStr );
  3004. if ( Item[ gpItemDescObject->usItem ].usItemClass & (IC_GUN | IC_LAUNCHER) )
  3005. {
  3006. if ( GunRange( gpItemDescObject ) >= EXCEPTIONAL_RANGE)
  3007. {
  3008. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  3009. }
  3010. else
  3011. {
  3012. SetFontForeground( 5 );
  3013. }
  3014. swprintf( pStr, L"%2d", ( GunRange( gpItemDescObject ) ) / 10 );
  3015. FindFontRightCoordinates( (INT16)(gWeaponStats[ 3 ].sX + gsInvDescX + gWeaponStats[ 3 ].sValDx), (INT16)(gWeaponStats[ 3 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3016. mprintf( usX, usY, pStr );
  3017. }
  3018. if ( !(Item[ gpItemDescObject->usItem ].usItemClass & IC_LAUNCHER) && gpItemDescObject->usItem != ROCKET_LAUNCHER )
  3019. {
  3020. if (Weapon[ gpItemDescObject->usItem ].ubImpact >= EXCEPTIONAL_DAMAGE)
  3021. {
  3022. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  3023. }
  3024. else
  3025. {
  3026. SetFontForeground( 5 );
  3027. }
  3028. swprintf( pStr, L"%2d", Weapon[ gpItemDescObject->usItem ].ubImpact );
  3029. FindFontRightCoordinates( (INT16)(gWeaponStats[ 4 ].sX + gsInvDescX + gWeaponStats[ 4 ].sValDx), (INT16)(gWeaponStats[ 4 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3030. mprintf( usX, usY, pStr );
  3031. }
  3032. ubAttackAPs = BaseAPsToShootOrStab( DEFAULT_APS, DEFAULT_AIMSKILL, gpItemDescObject );
  3033. if (ubAttackAPs <= EXCEPTIONAL_AP_COST)
  3034. {
  3035. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  3036. }
  3037. else
  3038. {
  3039. SetFontForeground( 5 );
  3040. }
  3041. swprintf( pStr, L"%2d", ubAttackAPs );
  3042. FindFontRightCoordinates( (INT16)(gWeaponStats[ 5 ].sX + gsInvDescX + gWeaponStats[ 5 ].sValDx), (INT16)(gWeaponStats[ 5 ].sY + gsInvDescY ), ITEM_STATS_WIDTH, ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3043. mprintf( usX, usY, pStr );
  3044. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst > 0)
  3045. {
  3046. if (Weapon[ gpItemDescObject->usItem ].ubShotsPerBurst >= EXCEPTIONAL_BURST_SIZE || gpItemDescObject->usItem == G11)
  3047. {
  3048. SetFontForeground( ITEMDESC_FONTHIGHLIGHT );
  3049. }
  3050. else
  3051. {
  3052. SetFontForeground( 5 );
  3053. }
  3054. swprintf( pStr, L"%2d", ubAttackAPs + CalcAPsToBurst( DEFAULT_APS, gpItemDescObject ) );
  3055. FindFontRightCoordinates( (INT16)(gWeaponStats[ 6 ].sX + gsInvDescX + gWeaponStats[ 6 ].sValDx), (INT16)(gWeaponStats[ 6 ].sY + gsInvDescY ), ITEM_STATS_WIDTH, ITEM_STATS_HEIGHT, pStr, BLOCKFONT2, &usX, &usY );
  3056. mprintf( usX, usY, pStr );
  3057. }
  3058. }
  3059. else if ( gpItemDescObject->usItem == MONEY )
  3060. {
  3061. //Labels
  3062. SetFont( BLOCKFONT2 );
  3063. SetFontShadow( DEFAULT_SHADOW );
  3064. SetFontForeground( 6 );
  3065. //Display the 'Seperate text'
  3066. //if the player is removing money from the players account
  3067. if( gfAddingMoneyToMercFromPlayersAccount )
  3068. mprintf( (UINT16)(gMoneyButtonLoc.x + gMoneyButtonOffsets[4].x), (UINT16)(gMoneyButtonLoc.y + gMoneyButtonOffsets[4].y), gzMoneyAmounts[5] );
  3069. else
  3070. mprintf( (UINT16)(gMoneyButtonLoc.x + gMoneyButtonOffsets[4].x), (UINT16)(gMoneyButtonLoc.y + gMoneyButtonOffsets[4].y), gzMoneyAmounts[4] );
  3071. // if the player is taking money from their account
  3072. if( gfAddingMoneyToMercFromPlayersAccount )
  3073. {
  3074. //Display the 'Removing'
  3075. mprintf( gMoneyStats[ 0 ].sX + gsInvDescX, gMoneyStats[ 0 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_PLAYERS ] );
  3076. //Display the 'REmaining'
  3077. mprintf( gMoneyStats[ 2 ].sX + gsInvDescX, gMoneyStats[ 2 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_AMOUNT_2_WITHDRAW ] );
  3078. }
  3079. else
  3080. {
  3081. //Display the 'Removing'
  3082. mprintf( gMoneyStats[ 0 ].sX + gsInvDescX, gMoneyStats[ 0 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ 0 ] );
  3083. //Display the 'REmaining'
  3084. mprintf( gMoneyStats[ 2 ].sX + gsInvDescX, gMoneyStats[ 2 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ 2 ] );
  3085. }
  3086. // Total Amount
  3087. SetFontForeground( FONT_WHITE );
  3088. swprintf( pStr, L"%d", gRemoveMoney.uiTotalAmount );
  3089. InsertCommasForDollarFigure( pStr );
  3090. InsertDollarSignInToString( pStr );
  3091. FindFontRightCoordinates( (INT16)(ITEMDESC_NAME_X), (INT16)(ITEMDESC_NAME_Y ), 295,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3092. mprintf( usX, usY, pStr );
  3093. SetFontForeground( 6 );
  3094. // if the player is taking money from their account
  3095. if( gfAddingMoneyToMercFromPlayersAccount )
  3096. {
  3097. //Display the 'Amt removing'
  3098. mprintf( gMoneyStats[ 1 ].sX + gsInvDescX, gMoneyStats[ 1 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_BALANCE ] );
  3099. //Display the 'REmaining amount'
  3100. mprintf( gMoneyStats[ 3 ].sX + gsInvDescX, gMoneyStats[ 3 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ MONEY_DESC_TO_WITHDRAW ] );
  3101. }
  3102. else
  3103. {
  3104. //Display the 'Amt removing'
  3105. mprintf( gMoneyStats[ 1 ].sX + gsInvDescX, gMoneyStats[ 1 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ 1 ] );
  3106. //Display the 'REmaining amount'
  3107. mprintf( gMoneyStats[ 3 ].sX + gsInvDescX, gMoneyStats[ 3 ].sY + gsInvDescY, L"%s", gMoneyStatsDesc[ 3 ] );
  3108. }
  3109. // Values
  3110. SetFontForeground( 5 );
  3111. //Display the total amount of money remaining
  3112. swprintf( pStr, L"%ld", gRemoveMoney.uiMoneyRemaining );
  3113. InsertCommasForDollarFigure( pStr );
  3114. InsertDollarSignInToString( pStr );
  3115. FindFontRightCoordinates( (INT16)(gMoneyStats[ 1 ].sX + gsInvDescX + gMoneyStats[ 1 ].sValDx), (INT16)(gMoneyStats[ 1 ].sY + gsInvDescY ), (UINT16)(ITEM_STATS_WIDTH-3),ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3116. mprintf( usX, usY, pStr );
  3117. //Display the total amount of money removing
  3118. swprintf( pStr, L"%ld", gRemoveMoney.uiMoneyRemoving );
  3119. InsertCommasForDollarFigure( pStr );
  3120. InsertDollarSignInToString( pStr );
  3121. FindFontRightCoordinates( (INT16)(gMoneyStats[ 3 ].sX + gsInvDescX + gMoneyStats[ 3 ].sValDx), (INT16)(gMoneyStats[ 3 ].sY + gsInvDescY), (UINT16)(ITEM_STATS_WIDTH-3) ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3122. mprintf( usX, usY, pStr );
  3123. }
  3124. else if ( Item[ gpItemDescObject->usItem ].usItemClass == IC_MONEY )
  3125. {
  3126. SetFontForeground( FONT_FCOLOR_WHITE );
  3127. SetFontShadow( DEFAULT_SHADOW );
  3128. swprintf( pStr, L"%ld", gpItemDescObject->uiMoneyAmount );
  3129. InsertCommasForDollarFigure( pStr );
  3130. InsertDollarSignInToString( pStr );
  3131. FindFontRightCoordinates( (INT16)(ITEMDESC_NAME_X), (INT16)(ITEMDESC_NAME_Y ), 295,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3132. mprintf( usX, usY, pStr );
  3133. }
  3134. else
  3135. {
  3136. //Labels
  3137. SetFont( BLOCKFONT2 );
  3138. SetFontForeground( 6 );
  3139. SetFontShadow( DEFAULT_SHADOW );
  3140. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_AMMO )
  3141. {
  3142. //Status
  3143. mprintf( gWeaponStats[ 2 ].sX + gsInvDescX, gWeaponStats[ 2 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 2 ] );
  3144. }
  3145. else
  3146. {
  3147. mprintf( gWeaponStats[ 1 ].sX + gsInvDescX, gWeaponStats[ 1 ].sY + gsInvDescY, L"%s", gWeaponStatsDesc[ 1 ] );
  3148. }
  3149. //Weight
  3150. swprintf( sTempString, gWeaponStatsDesc[ 0 ], GetWeightUnitString() );
  3151. mprintf( gWeaponStats[ 0 ].sX + gsInvDescX, gWeaponStats[ 0 ].sY + gsInvDescY, sTempString );
  3152. // Values
  3153. SetFontForeground( 5 );
  3154. if ( Item[ gpItemDescObject->usItem ].usItemClass & IC_AMMO )
  3155. {
  3156. // Ammo - print amount
  3157. //Status
  3158. swprintf( pStr, L"%d/%d", gpItemDescObject->ubShotsLeft[0], Magazine[ Item[ gpItemDescObject->usItem ].ubClassIndex ].ubMagSize );
  3159. FindFontRightCoordinates( (INT16)(gWeaponStats[ 2 ].sX + gsInvDescX + gWeaponStats[ 2 ].sValDx), (INT16)(gWeaponStats[ 2 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3160. mprintf( usX, usY, pStr );
  3161. }
  3162. else
  3163. {
  3164. //Status
  3165. swprintf( pStr, L"%2d%%", gpItemDescObject->bStatus[ gubItemDescStatusIndex ] );
  3166. FindFontRightCoordinates( (INT16)(gWeaponStats[ 1 ].sX + gsInvDescX + gWeaponStats[ 1 ].sValDx), (INT16)(gWeaponStats[ 1 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3167. wcscat( pStr, L"%%" );
  3168. mprintf( usX, usY, pStr );
  3169. }
  3170. if( ( InKeyRingPopup() == TRUE ) || ( Item[ gpItemDescObject->usItem ].usItemClass & IC_KEY ) )
  3171. {
  3172. SetFontForeground( 6 );
  3173. // build description for keys .. the sector found
  3174. swprintf( pStr, L"%s", sKeyDescriptionStrings[ 0 ] );
  3175. mprintf( gWeaponStats[ 4 ].sX + gsInvDescX, gWeaponStats[ 4 ].sY + gsInvDescY, pStr );
  3176. swprintf( pStr, L"%s", sKeyDescriptionStrings[ 1 ] );
  3177. mprintf( gWeaponStats[ 4 ].sX + gsInvDescX, gWeaponStats[ 4 ].sY + gsInvDescY + GetFontHeight( BLOCKFONT ) + 2 , pStr );
  3178. SetFontForeground( 5 );
  3179. GetShortSectorString( ( INT16 ) SECTORX( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), ( INT16 ) SECTORY( KeyTable[ gpItemDescObject->ubKeyID ].usSectorFound ), sTempString );
  3180. swprintf( pStr, L"%s", sTempString );
  3181. FindFontRightCoordinates( (INT16)(gWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gWeaponStats[ 4 ].sY + gsInvDescY ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3182. mprintf( usX, usY, pStr );
  3183. swprintf( pStr, L"%d", KeyTable[ gpItemDescObject->ubKeyID ].usDateFound );
  3184. FindFontRightCoordinates( (INT16)(gWeaponStats[ 4 ].sX + gsInvDescX ), (INT16)(gWeaponStats[ 4 ].sY + gsInvDescY + GetFontHeight( BLOCKFONT ) + 2 ), 110 ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3185. mprintf( usX, usY, pStr );
  3186. }
  3187. //Weight
  3188. swprintf( pStr, L"%1.1f", fWeight );
  3189. FindFontRightCoordinates( (INT16)(gWeaponStats[ 0 ].sX + gsInvDescX + gWeaponStats[ 0 ].sValDx), (INT16)(gWeaponStats[ 0 ].sY + gsInvDescY ), ITEM_STATS_WIDTH ,ITEM_STATS_HEIGHT ,pStr, BLOCKFONT2, &usX, &usY);
  3190. mprintf( usX, usY, pStr );
  3191. }
  3192. SetFontShadow( DEFAULT_SHADOW );
  3193. }
  3194. }
  3195. void HandleItemDescriptionBox( BOOLEAN *pfDirty )
  3196. {
  3197. if ( fItemDescDelete )
  3198. {
  3199. DeleteItemDescriptionBox( );
  3200. fItemDescDelete = FALSE;
  3201. *pfDirty = DIRTYLEVEL2;
  3202. }
  3203. }
  3204. void DeleteItemDescriptionBox( )
  3205. {
  3206. INT32 cnt, cnt2;
  3207. BOOLEAN fFound, fAllFound;
  3208. if( gfInItemDescBox == FALSE )
  3209. {
  3210. return;
  3211. }
  3212. // DEF:
  3213. //Used in the shopkeeper interface
  3214. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  3215. {
  3216. DeleteShopKeeperItemDescBox();
  3217. }
  3218. // check for any AP costs
  3219. if ( ( gTacticalStatus.uiFlags & TURNBASED ) && ( gTacticalStatus.uiFlags & INCOMBAT ) )
  3220. {
  3221. if (gpAttachSoldier)
  3222. {
  3223. // check for change in attachments, starting with removed attachments
  3224. fAllFound = TRUE;
  3225. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  3226. {
  3227. if ( gusOriginalAttachItem[ cnt ] != NOTHING )
  3228. {
  3229. fFound = FALSE;
  3230. for ( cnt2 = 0; cnt2 < MAX_ATTACHMENTS; cnt2++ )
  3231. {
  3232. if ( (gusOriginalAttachItem[ cnt ] == gpItemDescObject->usAttachItem[ cnt2 ]) && (gpItemDescObject->bAttachStatus[ cnt2 ] == gbOriginalAttachStatus[ cnt ]) )
  3233. {
  3234. fFound = TRUE;
  3235. }
  3236. }
  3237. if (!fFound)
  3238. {
  3239. // charge APs
  3240. fAllFound = FALSE;
  3241. break;
  3242. }
  3243. }
  3244. }
  3245. if (fAllFound)
  3246. {
  3247. // nothing was removed; search for attachment added
  3248. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  3249. {
  3250. if ( gpItemDescObject->usAttachItem[ cnt ] != NOTHING )
  3251. {
  3252. fFound = FALSE;
  3253. for ( cnt2 = 0; cnt2 < MAX_ATTACHMENTS; cnt2++ )
  3254. {
  3255. if ( (gpItemDescObject->usAttachItem[ cnt ] == gusOriginalAttachItem[ cnt2 ]) && (gbOriginalAttachStatus[ cnt2 ] == gpItemDescObject->bAttachStatus[ cnt ]) )
  3256. {
  3257. fFound = TRUE;
  3258. }
  3259. }
  3260. if (!fFound)
  3261. {
  3262. // charge APs
  3263. fAllFound = FALSE;
  3264. break;
  3265. }
  3266. }
  3267. }
  3268. }
  3269. if (!fAllFound)
  3270. {
  3271. DeductPoints( gpAttachSoldier, AP_RELOAD_GUN, 0 );
  3272. }
  3273. }
  3274. }
  3275. //Remove
  3276. DeleteVideoObjectFromIndex( guiItemDescBox );
  3277. DeleteVideoObjectFromIndex( guiMapItemDescBox );
  3278. DeleteVideoObjectFromIndex( guiBullet );
  3279. // Delete item graphic
  3280. DeleteVideoObjectFromIndex( guiItemGraphic );
  3281. gfInItemDescBox = FALSE;
  3282. // if( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  3283. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  3284. {
  3285. UnloadButtonImage( giMapInvDescButtonImage );
  3286. RemoveButton( giMapInvDescButton );
  3287. }
  3288. // Remove region
  3289. MSYS_RemoveRegion( &gInvDesc);
  3290. if( gpItemDescObject->usItem != MONEY )
  3291. {
  3292. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  3293. {
  3294. MSYS_RemoveRegion( &gItemDescAttachmentRegions[cnt]);
  3295. }
  3296. }
  3297. else
  3298. {
  3299. UnloadButtonImage( guiMoneyButtonImage );
  3300. UnloadButtonImage( guiMoneyDoneButtonImage );
  3301. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  3302. {
  3303. RemoveButton( guiMoneyButtonBtn[cnt] );
  3304. }
  3305. }
  3306. if ( ITEM_PROS_AND_CONS( gpItemDescObject->usItem ) )
  3307. {
  3308. MSYS_RemoveRegion( &gProsAndConsRegions[0] );
  3309. MSYS_RemoveRegion( &gProsAndConsRegions[1] );
  3310. }
  3311. if(( ( Item[ gpItemDescObject->usItem ].usItemClass & IC_GUN ) && gpItemDescObject->usItem != ROCKET_LAUNCHER ) )
  3312. {
  3313. // Remove button
  3314. UnloadButtonImage( giItemDescAmmoButtonImages );
  3315. RemoveButton( giItemDescAmmoButton );
  3316. }
  3317. // if(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  3318. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  3319. {
  3320. fCharacterInfoPanelDirty=TRUE;
  3321. fMapPanelDirty = TRUE;
  3322. fTeamPanelDirty = TRUE;
  3323. fMapScreenBottomDirty = TRUE;
  3324. }
  3325. if( InKeyRingPopup() == TRUE )
  3326. {
  3327. DeleteKeyObject(gpItemDescObject);
  3328. gpItemDescObject = NULL;
  3329. fShowDescriptionFlag = FALSE;
  3330. fInterfacePanelDirty = DIRTYLEVEL2;
  3331. return;
  3332. }
  3333. fShowDescriptionFlag = FALSE;
  3334. fInterfacePanelDirty = DIRTYLEVEL2;
  3335. if( gpItemDescObject->usItem == MONEY )
  3336. {
  3337. //if there is no money remaining
  3338. if( gRemoveMoney.uiMoneyRemaining == 0 && !gfAddingMoneyToMercFromPlayersAccount )
  3339. {
  3340. //get rid of the money in the slot
  3341. memset( gpItemDescObject, 0, sizeof( OBJECTTYPE ) );
  3342. gpItemDescObject = NULL;
  3343. }
  3344. }
  3345. if( gfAddingMoneyToMercFromPlayersAccount )
  3346. gfAddingMoneyToMercFromPlayersAccount = FALSE;
  3347. gfItemDescObjectIsAttachment = FALSE;
  3348. }
  3349. void InternalBeginItemPointer( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, INT8 bHandPos )
  3350. {
  3351. // BOOLEAN fOk;
  3352. // If not null return
  3353. if ( gpItemPointer != NULL )
  3354. {
  3355. return;
  3356. }
  3357. // Copy into cursor...
  3358. memcpy( &gItemPointer, pObject, sizeof( OBJECTTYPE ) );
  3359. // Dirty interface
  3360. fInterfacePanelDirty = DIRTYLEVEL2;
  3361. gpItemPointer = &gItemPointer;
  3362. gpItemPointerSoldier = pSoldier;
  3363. gbItemPointerSrcSlot = bHandPos;
  3364. gbItemPointerLocateGood = TRUE;
  3365. CheckForDisabledForGiveItem( );
  3366. EnableSMPanelButtons( FALSE, TRUE );
  3367. gfItemPointerDifferentThanDefault = FALSE;
  3368. // re-evaluate repairs
  3369. gfReEvaluateEveryonesNothingToDo = TRUE;
  3370. }
  3371. void BeginItemPointer( SOLDIERTYPE *pSoldier, UINT8 ubHandPos )
  3372. {
  3373. BOOLEAN fOk;
  3374. OBJECTTYPE pObject;
  3375. memset( &pObject, 0, sizeof( OBJECTTYPE ) );
  3376. if (_KeyDown( SHIFT ))
  3377. {
  3378. // Remove all from soldier's slot
  3379. fOk = RemoveObjectFromSlot( pSoldier, ubHandPos, &pObject );
  3380. }
  3381. else
  3382. {
  3383. GetObjFrom( &(pSoldier->inv[ubHandPos]), 0, &pObject );
  3384. fOk = (pObject.ubNumberOfObjects == 1);
  3385. }
  3386. if (fOk)
  3387. {
  3388. InternalBeginItemPointer( pSoldier, &pObject, ubHandPos );
  3389. }
  3390. }
  3391. void BeginKeyRingItemPointer( SOLDIERTYPE *pSoldier, UINT8 ubKeyRingPosition )
  3392. {
  3393. BOOLEAN fOk;
  3394. // If not null return
  3395. if ( gpItemPointer != NULL )
  3396. {
  3397. return;
  3398. }
  3399. if (_KeyDown( SHIFT ))
  3400. {
  3401. // Remove all from soldier's slot
  3402. fOk = RemoveKeysFromSlot( pSoldier, ubKeyRingPosition, pSoldier->pKeyRing[ ubKeyRingPosition ].ubNumber, &gItemPointer );
  3403. }
  3404. else
  3405. {
  3406. RemoveKeyFromSlot( pSoldier, ubKeyRingPosition, &gItemPointer );
  3407. fOk = (gItemPointer.ubNumberOfObjects == 1);
  3408. }
  3409. if (fOk)
  3410. {
  3411. // ATE: Look if we are a BLOODIED KNIFE, and change if so, making guy scream...
  3412. // Dirty interface
  3413. fInterfacePanelDirty = DIRTYLEVEL2;
  3414. gpItemPointer = &gItemPointer;
  3415. gpItemPointerSoldier = pSoldier;
  3416. gbItemPointerSrcSlot = ubKeyRingPosition;
  3417. if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  3418. {
  3419. guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) );
  3420. gusExternVoSubIndex = Item[ gpItemPointer->usItem ].ubGraphicNum;
  3421. fMapInventoryItem=TRUE;
  3422. MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR );
  3423. MSYS_SetCurrentCursor( EXTERN_CURSOR );
  3424. }
  3425. }
  3426. else
  3427. {
  3428. //Debug mesg
  3429. }
  3430. gfItemPointerDifferentThanDefault = FALSE;
  3431. }
  3432. void EndItemPointer( )
  3433. {
  3434. if ( gpItemPointer != NULL )
  3435. {
  3436. gpItemPointer = NULL;
  3437. gbItemPointerSrcSlot = NO_SLOT;
  3438. MSYS_ChangeRegionCursor( &gSMPanelRegion , CURSOR_NORMAL );
  3439. MSYS_SetCurrentCursor( CURSOR_NORMAL );
  3440. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  3441. {
  3442. memset( &gMoveingItem, 0, sizeof( INVENTORY_IN_SLOT ) );
  3443. SetSkiCursor( CURSOR_NORMAL );
  3444. }
  3445. else
  3446. {
  3447. EnableSMPanelButtons( TRUE , TRUE );
  3448. }
  3449. gbItemPointerLocateGood = FALSE;
  3450. // re-evaluate repairs
  3451. gfReEvaluateEveryonesNothingToDo = TRUE;
  3452. }
  3453. }
  3454. void DrawItemFreeCursor( )
  3455. {
  3456. //OBJECTTYPE *gpItemPointer;
  3457. //UINT16 usItemSnapCursor;
  3458. // Get usIndex and then graphic for item
  3459. guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) );
  3460. gusExternVoSubIndex = Item[ gpItemPointer->usItem ].ubGraphicNum;
  3461. MSYS_ChangeRegionCursor( &gSMPanelRegion , EXTERN_CURSOR );
  3462. MSYS_SetCurrentCursor( EXTERN_CURSOR );
  3463. }
  3464. void HideItemTileCursor( )
  3465. {
  3466. // RemoveTopmost( gusCurMousePos, gusItemPointer );
  3467. }
  3468. BOOLEAN SoldierCanSeeCatchComing( SOLDIERTYPE *pSoldier, INT16 sSrcGridNo )
  3469. {
  3470. return( TRUE );
  3471. /*-
  3472. INT32 cnt;
  3473. INT8 bDirection, bTargetDirection;
  3474. bTargetDirection = (INT8)GetDirectionToGridNoFromGridNo( pSoldier->sGridNo, sSrcGridNo );
  3475. // Look 3 directions Clockwise from what we are facing....
  3476. bDirection = pSoldier->bDirection;
  3477. for ( cnt = 0; cnt < 3; cnt++ )
  3478. {
  3479. if ( bDirection == bTargetDirection )
  3480. {
  3481. return( TRUE );
  3482. }
  3483. bDirection = gOneCDirection[ bDirection ];
  3484. }
  3485. // Look 3 directions CounterClockwise from what we are facing....
  3486. bDirection = pSoldier->bDirection;
  3487. for ( cnt = 0; cnt < 3; cnt++ )
  3488. {
  3489. if ( bDirection == bTargetDirection )
  3490. {
  3491. return( TRUE );
  3492. }
  3493. bDirection = gOneCCDirection[ bDirection ];
  3494. }
  3495. // If here, nothing good can happen!
  3496. return( FALSE );
  3497. -*/
  3498. }
  3499. void DrawItemTileCursor( )
  3500. {
  3501. UINT16 usMapPos;
  3502. UINT16 usIndex;
  3503. UINT8 ubSoldierID;
  3504. INT16 sAPCost;
  3505. BOOLEAN fRecalc;
  3506. UINT32 uiCursorFlags;
  3507. INT16 sFinalGridNo;
  3508. UINT32 uiCursorId = CURSOR_ITEM_GOOD_THROW;
  3509. SOLDIERTYPE *pSoldier;
  3510. BOOLEAN fGiveItem = FALSE;
  3511. INT16 sActionGridNo;
  3512. UINT8 ubDirection;
  3513. static UINT32 uiOldCursorId = 0;
  3514. static UINT16 usOldMousePos = 0;
  3515. INT16 sEndZ = 0;
  3516. INT16 sDist;
  3517. INT8 bLevel;
  3518. if (GetMouseMapPos( &usMapPos) )
  3519. {
  3520. if ( gfUIFullTargetFound )
  3521. {
  3522. // Force mouse position to guy...
  3523. usMapPos = MercPtrs[ gusUIFullTargetID ]->sGridNo;
  3524. }
  3525. gusCurMousePos = usMapPos;
  3526. if( gusCurMousePos != usOldMousePos )
  3527. {
  3528. gfItemPointerDifferentThanDefault = FALSE;
  3529. }
  3530. // Save old one..
  3531. usOldMousePos = gusCurMousePos;
  3532. // Default to turning adjacent area gridno off....
  3533. gfUIHandleShowMoveGrid = FALSE;
  3534. // If we are over a talkable guy, set flag
  3535. if ( IsValidTalkableNPCFromMouse( &ubSoldierID, TRUE, FALSE, TRUE ) )
  3536. {
  3537. fGiveItem = TRUE;
  3538. }
  3539. // OK, if different than default, change....
  3540. if ( gfItemPointerDifferentThanDefault )
  3541. {
  3542. fGiveItem = !fGiveItem;
  3543. }
  3544. // Get recalc and cursor flags
  3545. fRecalc = GetMouseRecalcAndShowAPFlags( &uiCursorFlags, NULL );
  3546. // OK, if we begin to move, reset the cursor...
  3547. if ( uiCursorFlags & MOUSE_MOVING )
  3548. {
  3549. EndPhysicsTrajectoryUI( );
  3550. }
  3551. // Get Pyth spaces away.....
  3552. sDist = PythSpacesAway( gpItemPointerSoldier->sGridNo, gusCurMousePos );
  3553. // If we are here and we are not selected, select!
  3554. // ATE Design discussion propably needed here...
  3555. if ( gpItemPointerSoldier->ubID != gusSelectedSoldier )
  3556. {
  3557. SelectSoldier( gpItemPointerSoldier->ubID, FALSE, FALSE );
  3558. }
  3559. // ATE: if good for locate, locate to selected soldier....
  3560. if ( gbItemPointerLocateGood )
  3561. {
  3562. gbItemPointerLocateGood = FALSE;
  3563. LocateSoldier( gusSelectedSoldier, FALSE );
  3564. }
  3565. if ( !fGiveItem )
  3566. {
  3567. if ( UIHandleOnMerc( FALSE ) && usMapPos != gpItemPointerSoldier->sGridNo )
  3568. {
  3569. // We are on a guy.. check if they can catch or not....
  3570. if ( gfUIFullTargetFound )
  3571. {
  3572. // Get soldier
  3573. pSoldier = MercPtrs[ gusUIFullTargetID ];
  3574. // Are they on our team?
  3575. // ATE: Can't be an EPC
  3576. if ( pSoldier->bTeam == gbPlayerNum && !AM_AN_EPC( pSoldier ) && !( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) )
  3577. {
  3578. if ( sDist <= PASSING_ITEM_DISTANCE_OKLIFE )
  3579. {
  3580. // OK, on a valid pass
  3581. gfUIMouseOnValidCatcher = 4;
  3582. gubUIValidCatcherID = (UINT8)gusUIFullTargetID;
  3583. }
  3584. else
  3585. {
  3586. // Can they see the throw?
  3587. if ( SoldierCanSeeCatchComing( pSoldier, gpItemPointerSoldier->sGridNo ) )
  3588. {
  3589. // OK, set global that this buddy can see catch...
  3590. gfUIMouseOnValidCatcher = TRUE;
  3591. gubUIValidCatcherID = (UINT8)gusUIFullTargetID;
  3592. }
  3593. }
  3594. }
  3595. }
  3596. }
  3597. // We're going to toss it!
  3598. if ( gTacticalStatus.uiFlags & INCOMBAT )
  3599. {
  3600. gfUIDisplayActionPoints = TRUE;
  3601. gUIDisplayActionPointsOffX = 15;
  3602. gUIDisplayActionPointsOffY = 15;
  3603. }
  3604. // If we are tossing...
  3605. if ( sDist <= 1 && gfUIMouseOnValidCatcher == 0 || gfUIMouseOnValidCatcher == 4 )
  3606. {
  3607. gsCurrentActionPoints = AP_PICKUP_ITEM;
  3608. }
  3609. else
  3610. {
  3611. gsCurrentActionPoints = AP_TOSS_ITEM;
  3612. }
  3613. }
  3614. else
  3615. {
  3616. if ( gfUIFullTargetFound )
  3617. {
  3618. UIHandleOnMerc( FALSE );
  3619. // OK, set global that this buddy can see catch...
  3620. gfUIMouseOnValidCatcher = 2;
  3621. gubUIValidCatcherID = (UINT8)gusUIFullTargetID;
  3622. // If this is a robot, change to say 'reload'
  3623. if ( MercPtrs[ gusUIFullTargetID ]->uiStatusFlags & SOLDIER_ROBOT )
  3624. {
  3625. gfUIMouseOnValidCatcher = 3;
  3626. }
  3627. if ( !( uiCursorFlags & MOUSE_MOVING ) )
  3628. {
  3629. // Find adjacent gridno...
  3630. sActionGridNo = FindAdjacentGridEx( gpItemPointerSoldier, gusCurMousePos, &ubDirection, NULL, FALSE, FALSE );
  3631. if ( sActionGridNo == -1 )
  3632. {
  3633. sActionGridNo = gusCurMousePos;
  3634. }
  3635. // Display location...
  3636. gsUIHandleShowMoveGridLocation = sActionGridNo;
  3637. gfUIHandleShowMoveGrid = TRUE;
  3638. // Get AP cost
  3639. if ( MercPtrs[ gusUIFullTargetID ]->uiStatusFlags & SOLDIER_ROBOT )
  3640. {
  3641. sAPCost = GetAPsToReloadRobot( gpItemPointerSoldier, MercPtrs[ gusUIFullTargetID ] );
  3642. }
  3643. else
  3644. {
  3645. sAPCost = GetAPsToGiveItem( gpItemPointerSoldier, sActionGridNo );
  3646. }
  3647. gsCurrentActionPoints = sAPCost;
  3648. }
  3649. // Set value
  3650. if ( gTacticalStatus.uiFlags & INCOMBAT )
  3651. {
  3652. gfUIDisplayActionPoints = TRUE;
  3653. gUIDisplayActionPointsOffX = 15;
  3654. gUIDisplayActionPointsOffY = 15;
  3655. }
  3656. }
  3657. }
  3658. if ( fGiveItem )
  3659. {
  3660. uiCursorId = CURSOR_ITEM_GIVE;
  3661. }
  3662. else
  3663. {
  3664. // How afar away are we?
  3665. if ( sDist <= 1 && gfUIMouseOnValidCatcher == 0 )
  3666. {
  3667. // OK, we want to drop.....
  3668. // Write the word 'drop' on cursor...
  3669. wcscpy( gzIntTileLocation, pMessageStrings[ MSG_DROP ] );
  3670. gfUIIntTileLocation = TRUE;
  3671. }
  3672. else
  3673. {
  3674. if ( usMapPos == gpItemPointerSoldier->sGridNo )
  3675. {
  3676. EndPhysicsTrajectoryUI( );
  3677. }
  3678. else if ( gfUIMouseOnValidCatcher == 4 )
  3679. {
  3680. // ATE: Don't do if we are passing....
  3681. }
  3682. else
  3683. // ( sDist > PASSING_ITEM_DISTANCE_OKLIFE )
  3684. {
  3685. // Write the word 'drop' on cursor...
  3686. if ( gfUIMouseOnValidCatcher == 0 )
  3687. {
  3688. wcscpy( gzIntTileLocation, pMessageStrings[ MSG_THROW ] );
  3689. gfUIIntTileLocation = TRUE;
  3690. }
  3691. gfUIHandlePhysicsTrajectory = TRUE;
  3692. if ( fRecalc && usMapPos != gpItemPointerSoldier->sGridNo )
  3693. {
  3694. if ( gfUIMouseOnValidCatcher )
  3695. {
  3696. switch( gAnimControl[ MercPtrs[ gubUIValidCatcherID ]->usAnimState ].ubHeight )
  3697. {
  3698. case ANIM_STAND:
  3699. sEndZ = 150;
  3700. break;
  3701. case ANIM_CROUCH:
  3702. sEndZ = 80;
  3703. break;
  3704. case ANIM_PRONE:
  3705. sEndZ = 10;
  3706. break;
  3707. }
  3708. if ( MercPtrs[ gubUIValidCatcherID ]->bLevel > 0 )
  3709. {
  3710. sEndZ = 0;
  3711. }
  3712. }
  3713. // Calculate chance to throw here.....
  3714. if ( !CalculateLaunchItemChanceToGetThrough( gpItemPointerSoldier, gpItemPointer, usMapPos, (INT8)gsInterfaceLevel, (INT16)( ( gsInterfaceLevel * 256 ) + sEndZ ), &sFinalGridNo, FALSE, &bLevel, TRUE ) )
  3715. {
  3716. gfBadThrowItemCTGH = TRUE;
  3717. }
  3718. else
  3719. {
  3720. gfBadThrowItemCTGH = FALSE;
  3721. }
  3722. BeginPhysicsTrajectoryUI( sFinalGridNo, bLevel, gfBadThrowItemCTGH );
  3723. }
  3724. }
  3725. if ( gfBadThrowItemCTGH )
  3726. {
  3727. uiCursorId = CURSOR_ITEM_BAD_THROW;
  3728. }
  3729. }
  3730. }
  3731. //Erase any cursor in viewport
  3732. //MSYS_ChangeRegionCursor( &gViewportRegion , VIDEO_NO_CURSOR );
  3733. // Get tile graphic fro item
  3734. usIndex = GetTileGraphicForItem( &(Item[ gpItemPointer->usItem ]) );
  3735. // ONly load if different....
  3736. if ( usIndex != gusItemPointer || uiOldCursorId != uiCursorId )
  3737. {
  3738. // OK, Tile database gives me subregion and video object to use...
  3739. SetExternVOData( uiCursorId, gTileDatabase[ usIndex ].hTileSurface, gTileDatabase[ usIndex ].usRegionIndex );
  3740. gusItemPointer = usIndex;
  3741. uiOldCursorId = uiCursorId;
  3742. }
  3743. MSYS_ChangeRegionCursor( &gViewportRegion , (UINT16)uiCursorId );
  3744. }
  3745. }
  3746. BOOLEAN IsValidAmmoToReloadRobot( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject )
  3747. {
  3748. if ( !CompatibleAmmoForGun( pObject, &( pSoldier->inv[ HANDPOS ] ) ) )
  3749. {
  3750. // Build string...
  3751. ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ ROBOT_NEEDS_GIVEN_CALIBER_STR ], AmmoCaliber[ Weapon[ pSoldier->inv[ HANDPOS ].usItem ].ubCalibre ] );
  3752. return( FALSE );
  3753. }
  3754. return( TRUE );
  3755. }
  3756. BOOLEAN HandleItemPointerClick( UINT16 usMapPos )
  3757. {
  3758. // Determine what to do
  3759. UINT8 ubDirection;
  3760. UINT8 ubSoldierID;
  3761. UINT16 usItem;
  3762. INT16 sAPCost;
  3763. SOLDIERTYPE *pSoldier=NULL;
  3764. UINT8 ubThrowActionCode=0;
  3765. UINT32 uiThrowActionData=0;
  3766. INT16 sEndZ = 0;
  3767. BOOLEAN fGiveItem = FALSE;
  3768. OBJECTTYPE TempObject;
  3769. INT16 sGridNo;
  3770. INT16 sDist;
  3771. INT16 sDistVisible;
  3772. if ( SelectedGuyInBusyAnimation( ) )
  3773. {
  3774. return( FALSE );
  3775. }
  3776. if ( giUIMessageOverlay != -1 )
  3777. {
  3778. EndUIMessage( );
  3779. return( FALSE );
  3780. }
  3781. // Don't allow if our soldier is a # of things...
  3782. if ( AM_AN_EPC( gpItemPointerSoldier ) || gpItemPointerSoldier->bLife < OKLIFE || gpItemPointerSoldier->bOverTerrainType == DEEP_WATER )
  3783. {
  3784. return( FALSE );
  3785. }
  3786. // This implies we have no path....
  3787. if ( gsCurrentActionPoints == 0 )
  3788. {
  3789. ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ NO_PATH ] );
  3790. return( FALSE );
  3791. }
  3792. if ( gfUIFullTargetFound )
  3793. {
  3794. // Force mouse position to guy...
  3795. usMapPos = MercPtrs[ gusUIFullTargetID ]->sGridNo;
  3796. if ( gAnimControl[ MercPtrs[ gusUIFullTargetID ]->usAnimState ].uiFlags & ANIM_MOVING )
  3797. {
  3798. return( FALSE );
  3799. }
  3800. }
  3801. // Check if we have APs....
  3802. if ( !EnoughPoints( gpItemPointerSoldier, gsCurrentActionPoints, 0, TRUE ) )
  3803. {
  3804. if ( gfDontChargeAPsToPickup && gsCurrentActionPoints == AP_PICKUP_ITEM )
  3805. {
  3806. }
  3807. else
  3808. {
  3809. return( FALSE );
  3810. }
  3811. }
  3812. // SEE IF WE ARE OVER A TALKABLE GUY!
  3813. if ( IsValidTalkableNPCFromMouse( &ubSoldierID, TRUE, FALSE, TRUE ) )
  3814. {
  3815. fGiveItem = TRUE;
  3816. }
  3817. // OK, if different than default, change....
  3818. if ( gfItemPointerDifferentThanDefault )
  3819. {
  3820. fGiveItem = !fGiveItem;
  3821. }
  3822. // Get Pyth spaces away.....
  3823. sDist = PythSpacesAway( gpItemPointerSoldier->sGridNo, gusCurMousePos );
  3824. if ( fGiveItem )
  3825. {
  3826. usItem = gpItemPointer->usItem;
  3827. // If the target is a robot,
  3828. if ( MercPtrs[ ubSoldierID ]->uiStatusFlags & SOLDIER_ROBOT )
  3829. {
  3830. // Charge APs to reload robot!
  3831. sAPCost = GetAPsToReloadRobot( gpItemPointerSoldier, MercPtrs[ ubSoldierID ] );
  3832. }
  3833. else
  3834. {
  3835. // Calculate action point costs!
  3836. sAPCost = GetAPsToGiveItem( gpItemPointerSoldier, usMapPos );
  3837. }
  3838. // Place it back in our hands!
  3839. memcpy( &TempObject, gpItemPointer, sizeof( OBJECTTYPE ) );
  3840. if ( gbItemPointerSrcSlot != NO_SLOT )
  3841. {
  3842. PlaceObject( gpItemPointerSoldier, gbItemPointerSrcSlot, gpItemPointer );
  3843. fInterfacePanelDirty = DIRTYLEVEL2;
  3844. }
  3845. /*
  3846. //if the user just clicked on an arms dealer
  3847. if( IsMercADealer( MercPtrs[ ubSoldierID ]->ubProfile ) )
  3848. {
  3849. if ( EnoughPoints( gpItemPointerSoldier, sAPCost, 0, TRUE ) )
  3850. {
  3851. //Enter the shopkeeper interface
  3852. EnterShopKeeperInterfaceScreen( MercPtrs[ ubSoldierID ]->ubProfile );
  3853. EndItemPointer( );
  3854. }
  3855. return( TRUE );
  3856. }
  3857. */
  3858. if ( EnoughPoints( gpItemPointerSoldier, sAPCost, 0, TRUE ) )
  3859. {
  3860. // If we are a robot, check if this is proper item to reload!
  3861. if ( MercPtrs[ ubSoldierID ]->uiStatusFlags & SOLDIER_ROBOT )
  3862. {
  3863. // Check if we can reload robot....
  3864. if ( IsValidAmmoToReloadRobot( MercPtrs[ ubSoldierID ], &TempObject ) )
  3865. {
  3866. INT16 sActionGridNo;
  3867. UINT8 ubDirection;
  3868. INT16 sAdjustedGridNo;
  3869. // Walk up to him and reload!
  3870. // See if we can get there to stab
  3871. sActionGridNo = FindAdjacentGridEx( gpItemPointerSoldier, MercPtrs[ ubSoldierID ]->sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE );
  3872. if ( sActionGridNo != -1 && gbItemPointerSrcSlot != NO_SLOT )
  3873. {
  3874. // Make a temp object for ammo...
  3875. gpItemPointerSoldier->pTempObject = MemAlloc( sizeof( OBJECTTYPE ) );
  3876. memcpy( gpItemPointerSoldier->pTempObject, &TempObject, sizeof( OBJECTTYPE ) );
  3877. // Remove from soldier's inv...
  3878. RemoveObjs( &( gpItemPointerSoldier->inv[ gbItemPointerSrcSlot ] ), 1 );
  3879. gpItemPointerSoldier->sPendingActionData2 = sAdjustedGridNo;
  3880. gpItemPointerSoldier->uiPendingActionData1 = gbItemPointerSrcSlot;
  3881. gpItemPointerSoldier->bPendingActionData3 = ubDirection;
  3882. gpItemPointerSoldier->ubPendingActionAnimCount = 0;
  3883. // CHECK IF WE ARE AT THIS GRIDNO NOW
  3884. if ( gpItemPointerSoldier->sGridNo != sActionGridNo )
  3885. {
  3886. // SEND PENDING ACTION
  3887. gpItemPointerSoldier->ubPendingAction = MERC_RELOADROBOT;
  3888. // WALK UP TO DEST FIRST
  3889. EVENT_InternalGetNewSoldierPath( gpItemPointerSoldier, sActionGridNo, gpItemPointerSoldier->usUIMovementMode, FALSE, FALSE );
  3890. }
  3891. else
  3892. {
  3893. EVENT_SoldierBeginReloadRobot( gpItemPointerSoldier, sAdjustedGridNo, ubDirection, gbItemPointerSrcSlot );
  3894. }
  3895. // OK, set UI
  3896. SetUIBusy( gpItemPointerSoldier->ubID );
  3897. }
  3898. }
  3899. gfDontChargeAPsToPickup = FALSE;
  3900. EndItemPointer( );
  3901. }
  3902. else
  3903. {
  3904. //if (gbItemPointerSrcSlot != NO_SLOT )
  3905. {
  3906. // Give guy this item.....
  3907. SoldierGiveItem( gpItemPointerSoldier, MercPtrs[ ubSoldierID ], &TempObject, gbItemPointerSrcSlot );
  3908. gfDontChargeAPsToPickup = FALSE;
  3909. EndItemPointer( );
  3910. // If we are giving it to somebody not on our team....
  3911. if ( MercPtrs[ ubSoldierID ]->ubProfile < FIRST_RPC || RPC_RECRUITED( MercPtrs[ ubSoldierID ] ) )
  3912. {
  3913. }
  3914. else
  3915. {
  3916. SetEngagedInConvFromPCAction( gpItemPointerSoldier );
  3917. }
  3918. }
  3919. }
  3920. }
  3921. return( TRUE );
  3922. }
  3923. // CHECK IF WE ARE NOT ON THE SAME GRIDNO
  3924. if ( sDist <= 1 && !( gfUIFullTargetFound && gusUIFullTargetID != gpItemPointerSoldier->ubID ) )
  3925. {
  3926. // Check some things here....
  3927. // 1 ) are we at the exact gridno that we stand on?
  3928. if ( usMapPos == gpItemPointerSoldier->sGridNo )
  3929. {
  3930. // Drop
  3931. if ( !gfDontChargeAPsToPickup )
  3932. {
  3933. // Deduct points
  3934. DeductPoints( gpItemPointerSoldier, AP_PICKUP_ITEM, 0 );
  3935. }
  3936. SoldierDropItem( gpItemPointerSoldier, gpItemPointer );
  3937. }
  3938. else
  3939. {
  3940. // Try to drop in an adjacent area....
  3941. // 1 ) is this not a good OK destination
  3942. // this will sound strange, but this is OK......
  3943. if ( !NewOKDestination( gpItemPointerSoldier, usMapPos, FALSE, gpItemPointerSoldier->bLevel ) || FindBestPath( gpItemPointerSoldier, usMapPos, gpItemPointerSoldier->bLevel, WALKING, NO_COPYROUTE, 0 ) == 1 )
  3944. {
  3945. // Drop
  3946. if ( !gfDontChargeAPsToPickup )
  3947. {
  3948. // Deduct points
  3949. DeductPoints( gpItemPointerSoldier, AP_PICKUP_ITEM, 0 );
  3950. }
  3951. // Play animation....
  3952. // Don't show animation of dropping item, if we are not standing
  3953. switch ( gAnimControl[ gpItemPointerSoldier->usAnimState ].ubHeight )
  3954. {
  3955. case ANIM_STAND:
  3956. gpItemPointerSoldier->pTempObject = MemAlloc( sizeof( OBJECTTYPE ) );
  3957. if (gpItemPointerSoldier->pTempObject != NULL)
  3958. {
  3959. memcpy( gpItemPointerSoldier->pTempObject, gpItemPointer, sizeof( OBJECTTYPE ) );
  3960. gpItemPointerSoldier->sPendingActionData2 = usMapPos;
  3961. // Turn towards.....gridno
  3962. EVENT_SetSoldierDesiredDirection( gpItemPointerSoldier, (INT8)GetDirectionFromGridNo( usMapPos, gpItemPointerSoldier ) );
  3963. EVENT_InitNewSoldierAnim( gpItemPointerSoldier, DROP_ADJACENT_OBJECT, 0 , FALSE );
  3964. }
  3965. break;
  3966. case ANIM_CROUCH:
  3967. case ANIM_PRONE:
  3968. AddItemToPool( usMapPos, gpItemPointer, 1, gpItemPointerSoldier->bLevel, 0 , -1 );
  3969. NotifySoldiersToLookforItems( );
  3970. break;
  3971. }
  3972. }
  3973. else
  3974. {
  3975. // Drop in place...
  3976. if ( !gfDontChargeAPsToPickup )
  3977. {
  3978. // Deduct points
  3979. DeductPoints( gpItemPointerSoldier, AP_PICKUP_ITEM, 0 );
  3980. }
  3981. SoldierDropItem( gpItemPointerSoldier, gpItemPointer );
  3982. }
  3983. }
  3984. }
  3985. else
  3986. {
  3987. sGridNo = usMapPos;
  3988. if ( sDist <= PASSING_ITEM_DISTANCE_OKLIFE && gfUIFullTargetFound && MercPtrs[ gusUIFullTargetID ]->bTeam == gbPlayerNum && !AM_AN_EPC( MercPtrs[ gusUIFullTargetID ] ) && !( MercPtrs[ gusUIFullTargetID ]->uiStatusFlags & SOLDIER_VEHICLE ) )
  3989. {
  3990. // OK, do the transfer...
  3991. {
  3992. pSoldier = MercPtrs[ gusUIFullTargetID ];
  3993. {
  3994. // Change to inventory....
  3995. //gfSwitchPanel = TRUE;
  3996. //gbNewPanel = SM_PANEL;
  3997. //gubNewPanelParam = (UINT8)pSoldier->ubID;
  3998. if ( !EnoughPoints( pSoldier, 3, 0, TRUE ) ||
  3999. !EnoughPoints( gpItemPointerSoldier, 3, 0, TRUE ) )
  4000. {
  4001. return( FALSE );
  4002. }
  4003. sDistVisible = DistanceVisible( pSoldier, DIRECTION_IRRELEVANT, DIRECTION_IRRELEVANT, gpItemPointerSoldier->sGridNo, gpItemPointerSoldier->bLevel );
  4004. // Check LOS....
  4005. if ( !SoldierTo3DLocationLineOfSightTest( pSoldier, gpItemPointerSoldier->sGridNo, gpItemPointerSoldier->bLevel, 3, (UINT8) sDistVisible, TRUE ) )
  4006. {
  4007. return( FALSE );
  4008. }
  4009. // Charge AP values...
  4010. DeductPoints( pSoldier, 3, 0 );
  4011. DeductPoints( gpItemPointerSoldier, 3, 0 );
  4012. usItem = gpItemPointer->usItem;
  4013. // try to auto place object....
  4014. if ( AutoPlaceObject( pSoldier, gpItemPointer, TRUE ) )
  4015. {
  4016. ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_ITEM_PASSED_TO_MERC ], ShortItemNames[ usItem ], pSoldier->name );
  4017. // Check if it's the same now!
  4018. if ( gpItemPointer->ubNumberOfObjects == 0 )
  4019. {
  4020. EndItemPointer( );
  4021. }
  4022. // OK, make guys turn towards each other and do animation...
  4023. {
  4024. UINT8 ubFacingDirection;
  4025. // Get direction to face.....
  4026. ubFacingDirection = (UINT8)GetDirectionFromGridNo( gpItemPointerSoldier->sGridNo, pSoldier );
  4027. // Stop merc first....
  4028. EVENT_StopMerc( pSoldier, pSoldier->sGridNo, pSoldier->bDirection );
  4029. // If we are standing only...
  4030. if ( gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_STAND && !MercInWater( pSoldier ) )
  4031. {
  4032. // Turn to face, then do animation....
  4033. EVENT_SetSoldierDesiredDirection( pSoldier, ubFacingDirection );
  4034. pSoldier->fTurningUntilDone = TRUE;
  4035. pSoldier->usPendingAnimation = PASS_OBJECT;
  4036. }
  4037. if ( gAnimControl[ gpItemPointerSoldier->usAnimState ].ubEndHeight == ANIM_STAND && !MercInWater( gpItemPointerSoldier ) )
  4038. {
  4039. EVENT_SetSoldierDesiredDirection( gpItemPointerSoldier, gOppositeDirection[ ubFacingDirection ] );
  4040. gpItemPointerSoldier->fTurningUntilDone = TRUE;
  4041. gpItemPointerSoldier->usPendingAnimation = PASS_OBJECT;
  4042. }
  4043. }
  4044. return( TRUE );
  4045. }
  4046. else
  4047. {
  4048. ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_NO_ROOM_TO_PASS_ITEM ], ShortItemNames[ usItem ], pSoldier->name );
  4049. return( FALSE );
  4050. }
  4051. }
  4052. }
  4053. }
  4054. else
  4055. {
  4056. // CHECK FOR VALID CTGH
  4057. if ( gfBadThrowItemCTGH )
  4058. {
  4059. ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ CANNOT_THROW_TO_DEST_STR ] );
  4060. return( FALSE );
  4061. }
  4062. // Deduct points
  4063. //DeductPoints( gpItemPointerSoldier, AP_TOSS_ITEM, 0 );
  4064. gpItemPointerSoldier->fDontChargeTurningAPs = TRUE;
  4065. // Will be dome later....
  4066. ubThrowActionCode = NO_THROW_ACTION;
  4067. // OK, CHECK FOR VALID THROW/CATCH
  4068. // IF OVER OUR GUY...
  4069. if ( gfUIFullTargetFound )
  4070. {
  4071. pSoldier = MercPtrs[ gusUIFullTargetID ];
  4072. if ( pSoldier->bTeam == gbPlayerNum && pSoldier->bLife >= OKLIFE && !AM_AN_EPC( pSoldier ) && !( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) )
  4073. {
  4074. // OK, on our team,
  4075. // How's our direction?
  4076. if ( SoldierCanSeeCatchComing( pSoldier, gpItemPointerSoldier->sGridNo ) )
  4077. {
  4078. // Setup as being the catch target
  4079. ubThrowActionCode = THROW_TARGET_MERC_CATCH;
  4080. uiThrowActionData = pSoldier->ubID;
  4081. sGridNo = pSoldier->sGridNo;
  4082. switch( gAnimControl[ pSoldier->usAnimState ].ubHeight )
  4083. {
  4084. case ANIM_STAND:
  4085. sEndZ = 150;
  4086. break;
  4087. case ANIM_CROUCH:
  4088. sEndZ = 80;
  4089. break;
  4090. case ANIM_PRONE:
  4091. sEndZ = 10;
  4092. break;
  4093. }
  4094. if ( pSoldier->bLevel > 0 )
  4095. {
  4096. sEndZ = 0;
  4097. }
  4098. // Get direction
  4099. ubDirection = (UINT8)GetDirectionFromGridNo( gpItemPointerSoldier->sGridNo, pSoldier );
  4100. // ATE: Goto stationary...
  4101. SoldierGotoStationaryStance( pSoldier );
  4102. // Set direction to turn...
  4103. EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection );
  4104. }
  4105. }
  4106. }
  4107. // CHANGE DIRECTION AT LEAST
  4108. ubDirection = (UINT8)GetDirectionFromGridNo( sGridNo, gpItemPointerSoldier );
  4109. EVENT_SetSoldierDesiredDirection( gpItemPointerSoldier, ubDirection );
  4110. gpItemPointerSoldier->fTurningUntilDone = TRUE;
  4111. // Increment attacker count...
  4112. gTacticalStatus.ubAttackBusyCount++;
  4113. DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("INcremtning ABC: Throw item to %d", gTacticalStatus.ubAttackBusyCount) );
  4114. // Given our gridno, throw grenate!
  4115. CalculateLaunchItemParamsForThrow( gpItemPointerSoldier, sGridNo, gpItemPointerSoldier->bLevel, (INT16)( ( gsInterfaceLevel * 256 ) + sEndZ ), gpItemPointer, 0, ubThrowActionCode, uiThrowActionData );
  4116. // OK, goto throw animation
  4117. HandleSoldierThrowItem( gpItemPointerSoldier, usMapPos );
  4118. }
  4119. }
  4120. gfDontChargeAPsToPickup = FALSE;
  4121. EndItemPointer( );
  4122. return( TRUE );
  4123. }
  4124. BOOLEAN ItemCursorInLobRange( UINT16 usMapPos )
  4125. {
  4126. // Draw item depending on distance from buddy
  4127. if ( GetRangeFromGridNoDiff( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE )
  4128. {
  4129. return( FALSE );
  4130. }
  4131. else
  4132. {
  4133. return( TRUE );
  4134. }
  4135. }
  4136. BOOLEAN InItemStackPopup( )
  4137. {
  4138. return( gfInItemStackPopup );
  4139. }
  4140. BOOLEAN InKeyRingPopup( )
  4141. {
  4142. return( gfInKeyRingPopup );
  4143. }
  4144. BOOLEAN InitItemStackPopup( SOLDIERTYPE *pSoldier, UINT8 ubPosition, INT16 sInvX, INT16 sInvY, INT16 sInvWidth, INT16 sInvHeight )
  4145. {
  4146. VOBJECT_DESC VObjectDesc;
  4147. INT16 sX, sY, sCenX, sCenY;
  4148. SGPRect aRect;
  4149. UINT8 ubLimit;
  4150. ETRLEObject *pTrav;
  4151. HVOBJECT hVObject;
  4152. INT32 cnt;
  4153. UINT16 usPopupWidth;
  4154. INT16 sItemSlotWidth, sItemSlotHeight;
  4155. // Set some globals
  4156. gsItemPopupInvX = sInvX;
  4157. gsItemPopupInvY = sInvY;
  4158. gsItemPopupInvWidth = sInvWidth;
  4159. gsItemPopupInvHeight = sInvHeight;
  4160. gpItemPopupSoldier = pSoldier;
  4161. // Determine # of items
  4162. gpItemPopupObject = &(pSoldier->inv[ ubPosition ] );
  4163. ubLimit = ItemSlotLimit( gpItemPopupObject->usItem, ubPosition );
  4164. // Return false if #objects not >1
  4165. if ( ubLimit <1 )
  4166. {
  4167. return( FALSE );
  4168. }
  4169. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  4170. {
  4171. if ( ubLimit > 6 )
  4172. {
  4173. ubLimit = 6;
  4174. }
  4175. }
  4176. // Load graphics
  4177. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  4178. strcpy( VObjectDesc.ImageFile, "INTERFACE\\extra_inventory.STI" );
  4179. CHECKF( AddVideoObject( &VObjectDesc, &guiItemPopupBoxes) );
  4180. // Get size
  4181. GetVideoObject( &hVObject, guiItemPopupBoxes );
  4182. pTrav = &(hVObject->pETRLEObject[ 0 ] );
  4183. usPopupWidth = pTrav->usWidth;
  4184. // Determine position, height and width of mouse region, area
  4185. GetSlotInvXY( ubPosition, &sX, &sY );
  4186. GetSlotInvHeightWidth( ubPosition, &sItemSlotWidth, &sItemSlotHeight );
  4187. // Get Width, Height
  4188. gsItemPopupWidth = ubLimit * usPopupWidth;
  4189. gsItemPopupHeight = pTrav->usHeight;
  4190. gubNumItemPopups = ubLimit;
  4191. // Calculate X,Y, first center
  4192. sCenX = sX - ( ( gsItemPopupWidth / 2 ) + ( sItemSlotWidth / 2 ) );
  4193. sCenY = sY;
  4194. // Limit it to window for item desc
  4195. if ( sCenX < gsItemPopupInvX )
  4196. {
  4197. sCenX = gsItemPopupInvX;
  4198. }
  4199. if ( ( sCenX + gsItemPopupWidth ) > ( gsItemPopupInvX + gsItemPopupInvWidth ) )
  4200. {
  4201. sCenX = gsItemPopupInvX;
  4202. }
  4203. // Cap it at 0....
  4204. if ( sCenX < 0 )
  4205. {
  4206. sCenX = 0;
  4207. }
  4208. // Set
  4209. gsItemPopupX = sCenX;
  4210. gsItemPopupY = sCenY;
  4211. for ( cnt = 0; cnt < gubNumItemPopups; cnt++ )
  4212. {
  4213. // Build a mouse region here that is over any others.....
  4214. MSYS_DefineRegion( &gItemPopupRegions[cnt], (INT16)(sCenX + ( cnt * usPopupWidth ) ), sCenY , (INT16)(sCenX + ( (cnt+1) * usPopupWidth ) ),(INT16)( sCenY + gsItemPopupHeight ), MSYS_PRIORITY_HIGHEST,
  4215. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemPopupRegionCallback );
  4216. // Add region
  4217. MSYS_AddRegion( &gItemPopupRegions[cnt]);
  4218. MSYS_SetRegionUserData( &gItemPopupRegions[cnt], 0, cnt );
  4219. //OK, for each item, set dirty text if applicable!
  4220. SetRegionFastHelpText( &(gItemPopupRegions[ cnt ]), ItemNames[ pSoldier->inv[ ubPosition ].usItem ] );
  4221. SetRegionHelpEndCallback( &(gItemPopupRegions[ cnt ]), HelpTextDoneCallback );
  4222. gfItemPopupRegionCallbackEndFix = FALSE;
  4223. }
  4224. // Build a mouse region here that is over any others.....
  4225. MSYS_DefineRegion( &gItemPopupRegion, gsItemPopupInvX, gsItemPopupInvY ,(INT16)(gsItemPopupInvX + gsItemPopupInvWidth), (INT16)(gsItemPopupInvY + gsItemPopupInvHeight), MSYS_PRIORITY_HIGH,
  4226. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemPopupFullRegionCallback );
  4227. // Add region
  4228. MSYS_AddRegion( &gItemPopupRegion);
  4229. //Disable all faces
  4230. SetAllAutoFacesInactive( );
  4231. fInterfacePanelDirty = DIRTYLEVEL2;
  4232. //guiTacticalInterfaceFlags |= INTERFACE_NORENDERBUTTONS;
  4233. gfInItemStackPopup = TRUE;
  4234. // if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  4235. if( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  4236. {
  4237. EnableSMPanelButtons( FALSE, FALSE );
  4238. }
  4239. //Reserict mouse cursor to panel
  4240. aRect.iTop = sInvY;
  4241. aRect.iLeft = sInvX;
  4242. aRect.iBottom = sInvY + sInvHeight;
  4243. aRect.iRight = sInvX + sInvWidth;
  4244. RestrictMouseCursor( &aRect );
  4245. return( TRUE );
  4246. }
  4247. void EndItemStackPopupWithItemInHand( )
  4248. {
  4249. if ( gpItemPointer != NULL )
  4250. {
  4251. DeleteItemStackPopup( );
  4252. }
  4253. }
  4254. void RenderItemStackPopup( BOOLEAN fFullRender )
  4255. {
  4256. ETRLEObject *pTrav;
  4257. UINT32 usHeight, usWidth;
  4258. HVOBJECT hVObject;
  4259. UINT32 cnt;
  4260. INT16 sX, sY, sNewX, sNewY;
  4261. if ( gfInItemStackPopup )
  4262. {
  4263. //Disable all faces
  4264. SetAllAutoFacesInactive( );
  4265. // Shadow Area
  4266. if ( fFullRender )
  4267. {
  4268. ShadowVideoSurfaceRect( FRAME_BUFFER, gsItemPopupInvX, gsItemPopupInvY, gsItemPopupInvX + gsItemPopupInvWidth , gsItemPopupInvY + gsItemPopupInvHeight );
  4269. }
  4270. }
  4271. // TAKE A LOOK AT THE VIDEO OBJECT SIZE ( ONE OF TWO SIZES ) AND CENTER!
  4272. GetVideoObject( &hVObject, guiItemPopupBoxes );
  4273. pTrav = &(hVObject->pETRLEObject[ 0 ] );
  4274. usHeight = (UINT32)pTrav->usHeight;
  4275. usWidth = (UINT32)pTrav->usWidth;
  4276. for ( cnt = 0; cnt < gubNumItemPopups; cnt++ )
  4277. {
  4278. BltVideoObjectFromIndex( FRAME_BUFFER, guiItemPopupBoxes, 0, gsItemPopupX + ( cnt * usWidth ), gsItemPopupY, VO_BLT_SRCTRANSPARENCY, NULL );
  4279. if ( cnt < gpItemPopupObject->ubNumberOfObjects )
  4280. {
  4281. sX = (INT16)(gsItemPopupX + ( cnt * usWidth ) + 11);
  4282. sY = (INT16)( gsItemPopupY + 3 );
  4283. INVRenderItem( FRAME_BUFFER, NULL, gpItemPopupObject, sX, sY, 29, 23, DIRTYLEVEL2, NULL, (UINT8)RENDER_ITEM_NOSTATUS, FALSE, 0 );
  4284. // Do status bar here...
  4285. sNewX = (INT16)( gsItemPopupX + ( cnt * usWidth ) + 7 );
  4286. sNewY = gsItemPopupY + INV_BAR_DY + 3;
  4287. DrawItemUIBarEx( gpItemPopupObject, (UINT8)cnt, sNewX, sNewY, ITEM_BAR_WIDTH, ITEM_BAR_HEIGHT, Get16BPPColor( STATUS_BAR ), Get16BPPColor( STATUS_BAR_SHADOW ), TRUE , FRAME_BUFFER );
  4288. }
  4289. }
  4290. //RestoreExternBackgroundRect( gsItemPopupInvX, gsItemPopupInvY, gsItemPopupInvWidth, gsItemPopupInvHeight );
  4291. InvalidateRegion( gsItemPopupInvX, gsItemPopupInvY, gsItemPopupInvX + gsItemPopupInvWidth, gsItemPopupInvY + gsItemPopupInvHeight );
  4292. }
  4293. void HandleItemStackPopup( )
  4294. {
  4295. }
  4296. void DeleteItemStackPopup( )
  4297. {
  4298. INT32 cnt;
  4299. //Remove
  4300. DeleteVideoObjectFromIndex( guiItemPopupBoxes );
  4301. MSYS_RemoveRegion( &gItemPopupRegion);
  4302. gfInItemStackPopup = FALSE;
  4303. for ( cnt = 0; cnt < gubNumItemPopups; cnt++ )
  4304. {
  4305. MSYS_RemoveRegion( &gItemPopupRegions[cnt]);
  4306. }
  4307. fInterfacePanelDirty = DIRTYLEVEL2;
  4308. //guiTacticalInterfaceFlags &= (~INTERFACE_NORENDERBUTTONS);
  4309. // if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  4310. if( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  4311. {
  4312. EnableSMPanelButtons( TRUE, FALSE );
  4313. }
  4314. FreeMouseCursor( );
  4315. }
  4316. BOOLEAN InitKeyRingPopup( SOLDIERTYPE *pSoldier, INT16 sInvX, INT16 sInvY, INT16 sInvWidth, INT16 sInvHeight )
  4317. {
  4318. VOBJECT_DESC VObjectDesc;
  4319. SGPRect aRect;
  4320. ETRLEObject *pTrav;
  4321. HVOBJECT hVObject;
  4322. INT32 cnt;
  4323. UINT16 usPopupWidth, usPopupHeight;
  4324. UINT8 ubSlotSimilarToKeySlot = 10;
  4325. INT16 sKeyRingItemWidth = 0;
  4326. INT16 sOffSetY = 0, sOffSetX = 0;
  4327. if( guiCurrentScreen == MAP_SCREEN )
  4328. {
  4329. gsKeyRingPopupInvX = 0;
  4330. sKeyRingItemWidth = MAP_KEY_RING_ROW_WIDTH;
  4331. sOffSetX = 40;
  4332. sOffSetY = 15;
  4333. }
  4334. else
  4335. {
  4336. // Set some globals
  4337. gsKeyRingPopupInvX = sInvX + TACTICAL_INVENTORY_KEYRING_GRAPHIC_OFFSET_X;
  4338. sKeyRingItemWidth = KEY_RING_ROW_WIDTH;
  4339. sOffSetY = 8;
  4340. }
  4341. gsKeyRingPopupInvY = sInvY;
  4342. gsKeyRingPopupInvWidth = sInvWidth;
  4343. gsKeyRingPopupInvHeight = sInvHeight;
  4344. gpItemPopupSoldier = pSoldier;
  4345. // Load graphics
  4346. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  4347. strcpy( VObjectDesc.ImageFile, "INTERFACE\\extra_inventory.STI" );
  4348. CHECKF( AddVideoObject( &VObjectDesc, &guiItemPopupBoxes) );
  4349. // Get size
  4350. GetVideoObject( &hVObject, guiItemPopupBoxes );
  4351. pTrav = &(hVObject->pETRLEObject[ 0 ] );
  4352. usPopupWidth = pTrav->usWidth;
  4353. usPopupHeight = pTrav->usHeight;
  4354. // Determine position, height and width of mouse region, area
  4355. //GetSlotInvHeightWidth( ubSlotSimilarToKeySlot, &sItemSlotWidth, &sItemSlotHeight );
  4356. for ( cnt = 0; cnt < NUMBER_KEYS_ON_KEYRING; cnt++ )
  4357. {
  4358. // Build a mouse region here that is over any others.....
  4359. MSYS_DefineRegion( &gKeyRingRegions[cnt],
  4360. (INT16)( gsKeyRingPopupInvX + ( cnt % sKeyRingItemWidth * usPopupWidth ) + sOffSetX ), // top left
  4361. (INT16)( sInvY + sOffSetY +( cnt / sKeyRingItemWidth * usPopupHeight ) ), // top right
  4362. (INT16)( gsKeyRingPopupInvX + ( ( cnt % sKeyRingItemWidth ) + 1 ) * usPopupWidth + sOffSetX ), // bottom left
  4363. (INT16)( sInvY + ( (cnt / sKeyRingItemWidth + 1) * usPopupHeight ) + sOffSetY ), // bottom right
  4364. MSYS_PRIORITY_HIGHEST,
  4365. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, KeyRingSlotInvClickCallback );
  4366. // Add region
  4367. MSYS_AddRegion( &gKeyRingRegions[cnt]);
  4368. MSYS_SetRegionUserData( &gKeyRingRegions[cnt], 0, cnt );
  4369. //gfItemPopupRegionCallbackEndFix = FALSE;
  4370. }
  4371. // Build a mouse region here that is over any others.....
  4372. MSYS_DefineRegion( &gItemPopupRegion, sInvX, sInvY ,(INT16)(sInvX + sInvWidth), (INT16)(sInvY + sInvHeight), MSYS_PRIORITY_HIGH,
  4373. MSYS_NO_CURSOR, MSYS_NO_CALLBACK, ItemPopupFullRegionCallback );
  4374. // Add region
  4375. MSYS_AddRegion( &gItemPopupRegion);
  4376. //Disable all faces
  4377. SetAllAutoFacesInactive( );
  4378. fInterfacePanelDirty = DIRTYLEVEL2;
  4379. //guiTacticalInterfaceFlags |= INTERFACE_NORENDERBUTTONS;
  4380. // if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  4381. if( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  4382. {
  4383. EnableSMPanelButtons( FALSE , FALSE );
  4384. }
  4385. gfInKeyRingPopup = TRUE;
  4386. //Reserict mouse cursor to panel
  4387. aRect.iTop = sInvY;
  4388. aRect.iLeft = sInvX;
  4389. aRect.iBottom = sInvY + sInvHeight;
  4390. aRect.iRight = sInvX + sInvWidth;
  4391. RestrictMouseCursor( &aRect );
  4392. return( TRUE );
  4393. }
  4394. void RenderKeyRingPopup( BOOLEAN fFullRender )
  4395. {
  4396. ETRLEObject *pTrav;
  4397. UINT32 usHeight, usWidth;
  4398. HVOBJECT hVObject;
  4399. UINT32 cnt;
  4400. OBJECTTYPE pObject;
  4401. INT16 sKeyRingItemWidth = 0;
  4402. INT16 sOffSetY = 0, sOffSetX = 0;
  4403. if( guiCurrentScreen != MAP_SCREEN )
  4404. {
  4405. sOffSetY = 8;
  4406. }
  4407. else
  4408. {
  4409. sOffSetX = 40;
  4410. sOffSetY = 15;
  4411. }
  4412. if ( gfInKeyRingPopup )
  4413. {
  4414. //Disable all faces
  4415. SetAllAutoFacesInactive( );
  4416. // Shadow Area
  4417. if ( fFullRender )
  4418. {
  4419. ShadowVideoSurfaceRect( FRAME_BUFFER, 0, gsKeyRingPopupInvY, gsKeyRingPopupInvX + gsKeyRingPopupInvWidth , gsKeyRingPopupInvY + gsKeyRingPopupInvHeight );
  4420. }
  4421. }
  4422. memset( &pObject, 0, sizeof( OBJECTTYPE ) );
  4423. pObject.usItem = KEY_1;
  4424. pObject.bStatus[ 0 ] = 100;
  4425. // TAKE A LOOK AT THE VIDEO OBJECT SIZE ( ONE OF TWO SIZES ) AND CENTER!
  4426. GetVideoObject( &hVObject, guiItemPopupBoxes );
  4427. pTrav = &(hVObject->pETRLEObject[ 0 ] );
  4428. usHeight = (UINT32)pTrav->usHeight;
  4429. usWidth = (UINT32)pTrav->usWidth;
  4430. if( guiCurrentScreen == MAP_SCREEN )
  4431. {
  4432. sKeyRingItemWidth = MAP_KEY_RING_ROW_WIDTH;
  4433. }
  4434. else
  4435. {
  4436. // Set some globals
  4437. sKeyRingItemWidth = KEY_RING_ROW_WIDTH;
  4438. }
  4439. for ( cnt = 0; cnt < NUMBER_KEYS_ON_KEYRING; cnt++ )
  4440. {
  4441. BltVideoObjectFromIndex( FRAME_BUFFER, guiItemPopupBoxes, 0, (INT16)(gsKeyRingPopupInvX + ( cnt % sKeyRingItemWidth * usWidth ) + sOffSetX ), ( INT16 )( gsKeyRingPopupInvY + sOffSetY + ( cnt / sKeyRingItemWidth * usHeight ) ), VO_BLT_SRCTRANSPARENCY, NULL );
  4442. // will want to draw key here.. if there is one
  4443. if( ( gpItemPopupSoldier->pKeyRing[ cnt ].ubKeyID != INVALID_KEY_NUMBER ) && ( gpItemPopupSoldier->pKeyRing[ cnt ].ubNumber > 0 ) )
  4444. {
  4445. pObject.ubNumberOfObjects = gpItemPopupSoldier->pKeyRing[ cnt ].ubNumber;
  4446. // show 100% status for each
  4447. DrawItemUIBarEx( &pObject, 0, (INT16)( gsKeyRingPopupInvX + sOffSetX + ( cnt % sKeyRingItemWidth * usWidth ) + 7 ), ( INT16 )( gsKeyRingPopupInvY + sOffSetY + ( cnt / sKeyRingItemWidth * usHeight ) + 24 )
  4448. , ITEM_BAR_WIDTH, ITEM_BAR_HEIGHT, Get16BPPColor( STATUS_BAR ), Get16BPPColor( STATUS_BAR_SHADOW ), TRUE , FRAME_BUFFER );
  4449. // set item type
  4450. pObject.usItem = FIRST_KEY + LockTable[ gpItemPopupSoldier->pKeyRing[ cnt].ubKeyID ].usKeyItem;
  4451. // render the item
  4452. INVRenderItem( FRAME_BUFFER, NULL, &pObject, (INT16)(gsKeyRingPopupInvX + sOffSetX +( cnt % sKeyRingItemWidth * usWidth ) + 8), ( INT16 )( gsKeyRingPopupInvY + sOffSetY + ( cnt / sKeyRingItemWidth * usHeight ) ),
  4453. ( UINT16 )( usWidth - 8 ), ( UINT16 )( usHeight - 2 ) , DIRTYLEVEL2, NULL, 0, 0, 0 );
  4454. }
  4455. //BltVideoObjectFromIndex( FRAME_BUFFER, guiItemPopupBoxes, 0, (INT16)(gsKeyRingPopupInvX + ( cnt % KEY_RING_ROW_WIDTH * usWidth ) ), ( INT16 )( gsKeyRingPopupInvY + ( cnt / KEY_RING_ROW_WIDTH * usHeight ) ), VO_BLT_SRCTRANSPARENCY, NULL );
  4456. }
  4457. //RestoreExternBackgroundRect( gsItemPopupInvX, gsItemPopupInvY, gsItemPopupInvWidth, gsItemPopupInvHeight );
  4458. InvalidateRegion( gsKeyRingPopupInvX, gsKeyRingPopupInvY, gsKeyRingPopupInvX + gsKeyRingPopupInvWidth, gsKeyRingPopupInvY + gsKeyRingPopupInvHeight );
  4459. }
  4460. void DeleteKeyRingPopup( )
  4461. {
  4462. INT32 cnt;
  4463. if( gfInKeyRingPopup == FALSE )
  4464. {
  4465. // done,
  4466. return;
  4467. }
  4468. //Remove
  4469. DeleteVideoObjectFromIndex( guiItemPopupBoxes );
  4470. MSYS_RemoveRegion( &gItemPopupRegion);
  4471. gfInKeyRingPopup = FALSE;
  4472. for ( cnt = 0; cnt < NUMBER_KEYS_ON_KEYRING; cnt++ )
  4473. {
  4474. MSYS_RemoveRegion( &gKeyRingRegions[cnt]);
  4475. }
  4476. fInterfacePanelDirty = DIRTYLEVEL2;
  4477. //guiTacticalInterfaceFlags &= (~INTERFACE_NORENDERBUTTONS);
  4478. // if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  4479. if( guiCurrentItemDescriptionScreen != MAP_SCREEN )
  4480. {
  4481. EnableSMPanelButtons( TRUE, FALSE );
  4482. }
  4483. FreeMouseCursor( );
  4484. }
  4485. UINT32 GetInterfaceGraphicForItem( INVTYPE *pItem )
  4486. {
  4487. // CHECK SUBCLASS
  4488. if ( pItem->ubGraphicType == 0 )
  4489. {
  4490. return( guiGUNSM );
  4491. }
  4492. else if ( pItem->ubGraphicType == 1 )
  4493. {
  4494. return( guiP1ITEMS );
  4495. }
  4496. else if ( pItem->ubGraphicType == 2 )
  4497. {
  4498. return( guiP2ITEMS );
  4499. }
  4500. else
  4501. {
  4502. return( guiP3ITEMS );
  4503. }
  4504. }
  4505. UINT16 GetTileGraphicForItem( INVTYPE *pItem )
  4506. {
  4507. UINT16 usIndex;
  4508. // CHECK SUBCLASS
  4509. if ( pItem->ubGraphicType == 0 )
  4510. {
  4511. GetTileIndexFromTypeSubIndex( GUNS, (INT16)(pItem->ubGraphicNum+1), &usIndex );
  4512. }
  4513. else if ( pItem->ubGraphicType == 1 )
  4514. {
  4515. GetTileIndexFromTypeSubIndex( P1ITEMS, (INT16)(pItem->ubGraphicNum+1), &usIndex );
  4516. }
  4517. else if ( pItem->ubGraphicType == 2 )
  4518. {
  4519. GetTileIndexFromTypeSubIndex( P2ITEMS, (INT16)(pItem->ubGraphicNum+1), &usIndex );
  4520. }
  4521. else
  4522. {
  4523. GetTileIndexFromTypeSubIndex( P3ITEMS, (INT16)(pItem->ubGraphicNum+1), &usIndex );
  4524. }
  4525. return( usIndex );
  4526. }
  4527. BOOLEAN LoadTileGraphicForItem( INVTYPE *pItem, UINT32 *puiVo )
  4528. {
  4529. CHAR8 zName[ 100 ];
  4530. UINT32 uiVo;
  4531. VOBJECT_DESC VObjectDesc;
  4532. UINT8 ubGraphic;
  4533. // CHECK SUBCLASS
  4534. ubGraphic = pItem->ubGraphicNum;
  4535. if ( pItem->ubGraphicType == 0 )
  4536. {
  4537. // CHECK SUBCLASS
  4538. //ubGraphic++;
  4539. if ( ubGraphic < 10 )
  4540. {
  4541. sprintf( zName, "gun0%d.sti", ubGraphic );
  4542. }
  4543. else
  4544. {
  4545. sprintf( zName, "gun%d.sti", ubGraphic );
  4546. }
  4547. }
  4548. else if ( pItem->ubGraphicType == 1 )
  4549. {
  4550. if ( ubGraphic < 10 )
  4551. {
  4552. sprintf( zName, "p1item0%d.sti", ubGraphic );
  4553. }
  4554. else
  4555. {
  4556. sprintf( zName, "p1item%d.sti", ubGraphic );
  4557. }
  4558. }
  4559. else if ( pItem->ubGraphicType == 2 )
  4560. {
  4561. if ( ubGraphic < 10 )
  4562. {
  4563. sprintf( zName, "p2item0%d.sti", ubGraphic );
  4564. }
  4565. else
  4566. {
  4567. sprintf( zName, "p2item%d.sti", ubGraphic );
  4568. }
  4569. }
  4570. else
  4571. {
  4572. if ( ubGraphic < 10 )
  4573. {
  4574. sprintf( zName, "p3item0%d.sti", ubGraphic );
  4575. }
  4576. else
  4577. {
  4578. sprintf( zName, "p3item%d.sti", ubGraphic );
  4579. }
  4580. }
  4581. //Load item
  4582. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  4583. sprintf( VObjectDesc.ImageFile, "BIGITEMS\\%s", zName );
  4584. CHECKF( AddVideoObject( &VObjectDesc, &uiVo) );
  4585. *puiVo = uiVo;
  4586. return( TRUE );
  4587. }
  4588. void ItemDescMoveCallback( MOUSE_REGION * pRegion, INT32 iReason )
  4589. {
  4590. }
  4591. void ItemDescCallback( MOUSE_REGION * pRegion, INT32 iReason )
  4592. {
  4593. static BOOLEAN fRightDown = FALSE, fLeftDown = FALSE;
  4594. if (iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN)
  4595. {
  4596. fLeftDown = TRUE;
  4597. }
  4598. else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  4599. {
  4600. if ( fLeftDown )
  4601. {
  4602. fLeftDown = FALSE;
  4603. //Only exit the screen if we are NOT in the money interface. Only the DONE button should exit the money interface.
  4604. if( gpItemDescObject->usItem != MONEY )
  4605. {
  4606. DeleteItemDescriptionBox( );
  4607. }
  4608. }
  4609. }
  4610. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_DWN)
  4611. {
  4612. fRightDown = TRUE;
  4613. }
  4614. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  4615. {
  4616. if ( fRightDown )
  4617. {
  4618. fRightDown = FALSE;
  4619. //Only exit the screen if we are NOT in the money interface. Only the DONE button should exit the money interface.
  4620. // if( gpItemDescObject->usItem != MONEY )
  4621. {
  4622. DeleteItemDescriptionBox( );
  4623. }
  4624. }
  4625. }
  4626. }
  4627. void ItemDescDoneButtonCallback( GUI_BUTTON *btn, INT32 reason )
  4628. {
  4629. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  4630. {
  4631. btn->uiFlags|=(BUTTON_CLICKED_ON);
  4632. }
  4633. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  4634. {
  4635. if (btn->uiFlags & BUTTON_CLICKED_ON)
  4636. {
  4637. btn->uiFlags&=~(BUTTON_CLICKED_ON);
  4638. if( gpItemDescObject->usItem == MONEY )
  4639. {
  4640. RemoveMoney();
  4641. }
  4642. DeleteItemDescriptionBox( );
  4643. }
  4644. }
  4645. if(reason & MSYS_CALLBACK_REASON_RBUTTON_DWN )
  4646. {
  4647. btn->uiFlags|=(BUTTON_CLICKED_ON);
  4648. }
  4649. else if(reason & MSYS_CALLBACK_REASON_RBUTTON_UP )
  4650. {
  4651. if (btn->uiFlags & BUTTON_CLICKED_ON)
  4652. {
  4653. btn->uiFlags&=~(BUTTON_CLICKED_ON);
  4654. DeleteItemDescriptionBox( );
  4655. }
  4656. }
  4657. }
  4658. void ItemPopupRegionCallback( MOUSE_REGION * pRegion, INT32 iReason )
  4659. {
  4660. UINT32 uiItemPos;
  4661. uiItemPos = MSYS_GetRegionUserData( pRegion, 0 );
  4662. // TO ALLOW ME TO DELETE REGIONS IN CALLBACKS!
  4663. if ( gfItemPopupRegionCallbackEndFix )
  4664. {
  4665. return;
  4666. }
  4667. if (iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN)
  4668. {
  4669. //If one in our hand, place it
  4670. if ( gpItemPointer != NULL )
  4671. {
  4672. if ( !PlaceObjectAtObjectIndex( gpItemPointer, gpItemPopupObject, (UINT8)uiItemPos ) )
  4673. {
  4674. if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  4675. {
  4676. MAPEndItemPointer( );
  4677. }
  4678. else
  4679. {
  4680. gpItemPointer = NULL;
  4681. MSYS_ChangeRegionCursor( &gSMPanelRegion , CURSOR_NORMAL );
  4682. SetCurrentCursorFromDatabase( CURSOR_NORMAL );
  4683. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  4684. {
  4685. memset( &gMoveingItem, 0, sizeof( INVENTORY_IN_SLOT ) );
  4686. SetSkiCursor( CURSOR_NORMAL );
  4687. }
  4688. }
  4689. // re-evaluate repairs
  4690. gfReEvaluateEveryonesNothingToDo = TRUE;
  4691. }
  4692. //Dirty interface
  4693. //fInterfacePanelDirty = DIRTYLEVEL2;
  4694. //RenderItemStackPopup( FALSE );
  4695. }
  4696. else
  4697. {
  4698. if ( uiItemPos < gpItemPopupObject->ubNumberOfObjects )
  4699. {
  4700. // Here, grab an item and put in cursor to swap
  4701. //RemoveObjFrom( OBJECTTYPE * pObj, UINT8 ubRemoveIndex )
  4702. GetObjFrom( gpItemPopupObject, (UINT8)uiItemPos, &gItemPointer );
  4703. if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  4704. {
  4705. // pick it up
  4706. InternalMAPBeginItemPointer( gpItemPopupSoldier );
  4707. }
  4708. else
  4709. {
  4710. gpItemPointer = &gItemPointer;
  4711. gpItemPointerSoldier = gpItemPopupSoldier;
  4712. }
  4713. //if we are in the shop keeper interface
  4714. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  4715. {
  4716. // pick up stacked item into cursor and try to sell it ( unless CTRL is held down )
  4717. BeginSkiItemPointer( PLAYERS_INVENTORY, -1, ( BOOLEAN )!gfKeyState[ CTRL ] );
  4718. // if we've just removed the last one there
  4719. if ( gpItemPopupObject->ubNumberOfObjects == 0 )
  4720. {
  4721. // we must immediately get out of item stack popup, because the item has been deleted (memset to 0), and
  4722. // errors like a right bringing up an item description for item 0 could happen then. ARM.
  4723. DeleteItemStackPopup( );
  4724. }
  4725. }
  4726. // re-evaluate repairs
  4727. gfReEvaluateEveryonesNothingToDo = TRUE;
  4728. //Dirty interface
  4729. //RenderItemStackPopup( FALSE );
  4730. //fInterfacePanelDirty = DIRTYLEVEL2;
  4731. }
  4732. }
  4733. UpdateItemHatches();
  4734. }
  4735. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  4736. {
  4737. // Get Description....
  4738. // Some global stuff here - for esc, etc
  4739. //Remove
  4740. gfItemPopupRegionCallbackEndFix = TRUE;
  4741. DeleteItemStackPopup( );
  4742. if ( !InItemDescriptionBox( ) )
  4743. {
  4744. // RESTORE BACKGROUND
  4745. RestoreExternBackgroundRect( gsItemPopupInvX, gsItemPopupInvY, gsItemPopupInvWidth, gsItemPopupInvHeight );
  4746. if ( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  4747. {
  4748. MAPInternalInitItemDescriptionBox( gpItemPopupObject, (UINT8)uiItemPos, gpItemPopupSoldier );
  4749. }
  4750. else
  4751. {
  4752. InternalInitItemDescriptionBox( gpItemPopupObject, (INT16) ITEMDESC_START_X, (INT16) ITEMDESC_START_Y, (UINT8)uiItemPos, gpItemPopupSoldier );
  4753. }
  4754. }
  4755. }
  4756. }
  4757. void ItemPopupFullRegionCallback( MOUSE_REGION * pRegion, INT32 iReason )
  4758. {
  4759. UINT32 uiItemPos;
  4760. uiItemPos = MSYS_GetRegionUserData( pRegion, 0 );
  4761. if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  4762. {
  4763. if ( InItemStackPopup( ) )
  4764. {
  4765. // End stack popup and retain pointer
  4766. EndItemStackPopupWithItemInHand( );
  4767. }
  4768. else if( InKeyRingPopup() )
  4769. {
  4770. // end pop up with key in hand
  4771. DeleteKeyRingPopup( );
  4772. fTeamPanelDirty = TRUE;
  4773. }
  4774. }
  4775. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  4776. {
  4777. if ( InItemStackPopup( ) )
  4778. {
  4779. DeleteItemStackPopup( );
  4780. fTeamPanelDirty = TRUE;
  4781. }
  4782. else
  4783. {
  4784. DeleteKeyRingPopup( );
  4785. fTeamPanelDirty = TRUE;
  4786. }
  4787. }
  4788. }
  4789. #define NUM_PICKUP_SLOTS 6
  4790. typedef struct
  4791. {
  4792. ITEM_POOL *pItemPool;
  4793. INT16 sX;
  4794. INT16 sY;
  4795. INT16 sWidth;
  4796. INT16 sHeight;
  4797. INT8 bScrollPage;
  4798. INT32 ubScrollAnchor;
  4799. INT32 ubTotalItems;
  4800. INT32 bCurSelect;
  4801. UINT8 bNumSlotsPerPage;
  4802. UINT32 uiPanelVo;
  4803. INT32 iUpButtonImages;
  4804. INT32 iDownButtonImages;
  4805. INT32 iAllButtonImages;
  4806. INT32 iCancelButtonImages;
  4807. INT32 iOKButtonImages;
  4808. INT32 iUpButton;
  4809. INT32 iDownButton;
  4810. INT32 iAllButton;
  4811. INT32 iOKButton;
  4812. INT32 iCancelButton;
  4813. BOOLEAN fCanScrollUp;
  4814. BOOLEAN fCanScrollDown;
  4815. BOOLEAN fDirtyLevel;
  4816. INT32 iDirtyRect;
  4817. BOOLEAN fHandled;
  4818. INT16 sGridNo;
  4819. INT8 bZLevel;
  4820. INT16 sButtomPanelStartY;
  4821. SOLDIERTYPE *pSoldier;
  4822. ITEM_POOL *ItemPoolSlots[ NUM_PICKUP_SLOTS ];
  4823. MOUSE_REGION Regions[ NUM_PICKUP_SLOTS ];
  4824. MOUSE_REGION BackRegions;
  4825. MOUSE_REGION BackRegion;
  4826. BOOLEAN *pfSelectedArray;
  4827. BOOLEAN fAtLeastOneSelected;
  4828. OBJECTTYPE CompAmmoObject;
  4829. BOOLEAN fAllSelected;
  4830. } ITEM_PICKUP_MENU_STRUCT;
  4831. #define ITEMPICK_UP_X 55
  4832. #define ITEMPICK_UP_Y 5
  4833. #define ITEMPICK_DOWN_X 111
  4834. #define ITEMPICK_DOWN_Y 5
  4835. #define ITEMPICK_ALL_X 79
  4836. #define ITEMPICK_ALL_Y 6
  4837. #define ITEMPICK_OK_X 16
  4838. #define ITEMPICK_OK_Y 6
  4839. #define ITEMPICK_CANCEL_X 141
  4840. #define ITEMPICK_CANCEL_Y 6
  4841. #define ITEMPICK_START_X_OFFSET 10
  4842. #define ITEMPICK_START_Y_OFFSET 20
  4843. #define ITEMPICK_GRAPHIC_X 10
  4844. #define ITEMPICK_GRAPHIC_Y 12
  4845. #define ITEMPICK_GRAPHIC_YSPACE 26
  4846. #define ITEMPICK_TEXT_X 56
  4847. #define ITEMPICK_TEXT_Y 22
  4848. #define ITEMPICK_TEXT_YSPACE 26
  4849. #define ITEMPICK_TEXT_WIDTH 109
  4850. #define ITEMPICK_TEXT_HEIGHT 17
  4851. ITEM_PICKUP_MENU_STRUCT gItemPickupMenu;
  4852. BOOLEAN gfInItemPickupMenu = FALSE;
  4853. void ItemPickupScrollUp( GUI_BUTTON *btn, INT32 reason );
  4854. void ItemPickupScrollDown( GUI_BUTTON *btn, INT32 reason );
  4855. void ItemPickupAll( GUI_BUTTON *btn, INT32 reason );
  4856. void ItemPickupOK( GUI_BUTTON *btn, INT32 reason );
  4857. void ItemPickupCancel( GUI_BUTTON *btn, INT32 reason );
  4858. void SetupPickupPage( INT8 bPage );
  4859. void ItemPickMenuMouseMoveCallback( MOUSE_REGION * pRegion, INT32 iReason );
  4860. void ItemPickMenuMouseClickCallback( MOUSE_REGION * pRegion, INT32 iReason );
  4861. void CalculateItemPickupMenuDimensions( );
  4862. void ItemPickupBackgroundClick( MOUSE_REGION * pRegion, INT32 iReason );
  4863. // STUFF FOR POPUP ITEM INFO BOX
  4864. void SetItemPickupMenuDirty( BOOLEAN fDirtyLevel )
  4865. {
  4866. gItemPickupMenu.fDirtyLevel = fDirtyLevel;
  4867. }
  4868. BOOLEAN InitializeItemPickupMenu( SOLDIERTYPE *pSoldier, INT16 sGridNo, ITEM_POOL *pItemPool, INT16 sScreenX, INT16 sScreenY, INT8 bZLevel )
  4869. {
  4870. VOBJECT_DESC VObjectDesc;
  4871. UINT8 ubString[48];
  4872. ITEM_POOL *pTempItemPool;
  4873. INT32 cnt;
  4874. INT16 sCenX, sCenY, sX, sY, sCenterYVal;
  4875. // Erase other menus....
  4876. EraseInterfaceMenus( TRUE );
  4877. // Make sure menu is located if not on screen
  4878. LocateSoldier( pSoldier->ubID, FALSE );
  4879. // memset values
  4880. memset( &gItemPickupMenu, 0, sizeof( gItemPickupMenu ) );
  4881. //Set item pool value
  4882. gItemPickupMenu.pItemPool = pItemPool;
  4883. InterruptTime();
  4884. PauseGame();
  4885. LockPauseState( 18 );
  4886. // Pause timers as well....
  4887. PauseTime( TRUE );
  4888. // Alrighty, cancel lock UI if we havn't done so already
  4889. UnSetUIBusy( pSoldier->ubID );
  4890. // Change to INV panel if not there already...
  4891. gfSwitchPanel = TRUE;
  4892. gbNewPanel = SM_PANEL;
  4893. gubNewPanelParam = (UINT8)pSoldier->ubID;
  4894. //Determine total #
  4895. cnt = 0;
  4896. pTempItemPool = pItemPool;
  4897. while( pTempItemPool != NULL )
  4898. {
  4899. if ( ItemPoolOKForDisplay( pTempItemPool, bZLevel ) )
  4900. {
  4901. cnt++;
  4902. }
  4903. pTempItemPool = pTempItemPool->pNext;
  4904. }
  4905. gItemPickupMenu.ubTotalItems = (UINT8)cnt;
  4906. // Determine # of slots per page
  4907. if ( gItemPickupMenu.ubTotalItems > NUM_PICKUP_SLOTS )
  4908. {
  4909. gItemPickupMenu.bNumSlotsPerPage = NUM_PICKUP_SLOTS;
  4910. }
  4911. else
  4912. {
  4913. gItemPickupMenu.bNumSlotsPerPage = gItemPickupMenu.ubTotalItems;
  4914. }
  4915. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  4916. FilenameForBPP("INTERFACE\\itembox.sti", VObjectDesc.ImageFile);
  4917. CHECKF( AddVideoObject( &VObjectDesc, &(gItemPickupMenu.uiPanelVo) ) );
  4918. // Memalloc selection array...
  4919. gItemPickupMenu.pfSelectedArray = MemAlloc(( sizeof( UINT8 ) * gItemPickupMenu.ubTotalItems ) );
  4920. // seto to 0
  4921. memset( gItemPickupMenu.pfSelectedArray, 0, ( sizeof( UINT8 ) * gItemPickupMenu.ubTotalItems ) );
  4922. // Calcualate dimensions
  4923. CalculateItemPickupMenuDimensions( );
  4924. // Get XY
  4925. {
  4926. // First get mouse xy screen location
  4927. if( sGridNo != NOWHERE )
  4928. {
  4929. sX = gusMouseXPos;
  4930. sY = gusMouseYPos;
  4931. }
  4932. else
  4933. {
  4934. sX = sScreenX;
  4935. sY = sScreenY;
  4936. }
  4937. // CHECK FOR LEFT/RIGHT
  4938. if ( ( sX + gItemPickupMenu.sWidth ) > 640 )
  4939. {
  4940. sX = 640 - gItemPickupMenu.sWidth - ITEMPICK_START_X_OFFSET;
  4941. }
  4942. else
  4943. {
  4944. sX = sX + ITEMPICK_START_X_OFFSET;
  4945. }
  4946. // Now check for top
  4947. // Center in the y
  4948. sCenterYVal = gItemPickupMenu.sHeight / 2;
  4949. sY -= sCenterYVal;
  4950. if ( sY < gsVIEWPORT_WINDOW_START_Y )
  4951. {
  4952. sY = gsVIEWPORT_WINDOW_START_Y;
  4953. }
  4954. // Check for bottom
  4955. if ( ( sY + gItemPickupMenu.sHeight ) > 340 )
  4956. {
  4957. sY = 340 - gItemPickupMenu.sHeight;
  4958. }
  4959. }
  4960. // Set some values
  4961. gItemPickupMenu.sX = sX;
  4962. gItemPickupMenu.sY = sY;
  4963. gItemPickupMenu.bCurSelect = 0;
  4964. gItemPickupMenu.pSoldier = pSoldier;
  4965. gItemPickupMenu.fHandled = FALSE;
  4966. gItemPickupMenu.sGridNo = sGridNo;
  4967. gItemPickupMenu.bZLevel = bZLevel;
  4968. gItemPickupMenu.fAtLeastOneSelected = FALSE;
  4969. gItemPickupMenu.fAllSelected = FALSE;
  4970. //Load images for buttons
  4971. FilenameForBPP("INTERFACE\\itembox.sti", ubString );
  4972. gItemPickupMenu.iUpButtonImages = LoadButtonImage( ubString, -1,5,-1,10,-1 );
  4973. gItemPickupMenu.iDownButtonImages = UseLoadedButtonImage( gItemPickupMenu.iUpButtonImages, -1, 7, -1, 12, -1 );
  4974. gItemPickupMenu.iAllButtonImages = UseLoadedButtonImage( gItemPickupMenu.iUpButtonImages, -1, 6, -1,11, -1 );
  4975. gItemPickupMenu.iCancelButtonImages = UseLoadedButtonImage( gItemPickupMenu.iUpButtonImages, -1, 8, -1, 13, -1 );
  4976. gItemPickupMenu.iOKButtonImages = UseLoadedButtonImage( gItemPickupMenu.iUpButtonImages, -1, 4, -1, 9, -1 );
  4977. // Build a mouse region here that is over any others.....
  4978. MSYS_DefineRegion( &(gItemPickupMenu.BackRegion ), (INT16)( 532 ), (INT16)( 367 ), (INT16)( 640 ),(INT16)( 480 ), MSYS_PRIORITY_HIGHEST,
  4979. CURSOR_NORMAL, MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
  4980. // Add region
  4981. MSYS_AddRegion( &(gItemPickupMenu.BackRegion ) );
  4982. // Build a mouse region here that is over any others.....
  4983. MSYS_DefineRegion( &(gItemPickupMenu.BackRegions ), (INT16)(gItemPickupMenu.sX ), (INT16)(gItemPickupMenu.sY), (INT16)(gItemPickupMenu.sX + gItemPickupMenu.sWidth ),(INT16)( gItemPickupMenu.sY + gItemPickupMenu.sHeight ), MSYS_PRIORITY_HIGHEST,
  4984. CURSOR_NORMAL, MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
  4985. // Add region
  4986. MSYS_AddRegion( &(gItemPickupMenu.BackRegions ) );
  4987. // Create buttons
  4988. if ( gItemPickupMenu.bNumSlotsPerPage == NUM_PICKUP_SLOTS && gItemPickupMenu.ubTotalItems > NUM_PICKUP_SLOTS )
  4989. {
  4990. gItemPickupMenu.iUpButton = QuickCreateButton( gItemPickupMenu.iUpButtonImages, (INT16)(sX + ITEMPICK_UP_X), (INT16)(sY + gItemPickupMenu.sButtomPanelStartY + ITEMPICK_UP_Y),
  4991. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  4992. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemPickupScrollUp );
  4993. SetButtonFastHelpText( gItemPickupMenu.iUpButton, ItemPickupHelpPopup[ 1 ] );
  4994. gItemPickupMenu.iDownButton = QuickCreateButton( gItemPickupMenu.iDownButtonImages, (INT16)(sX + ITEMPICK_DOWN_X), (INT16)(sY + gItemPickupMenu.sButtomPanelStartY + ITEMPICK_DOWN_Y),
  4995. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  4996. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemPickupScrollDown );
  4997. SetButtonFastHelpText( gItemPickupMenu.iDownButton, ItemPickupHelpPopup[ 3 ] );
  4998. }
  4999. gItemPickupMenu.iOKButton = QuickCreateButton( gItemPickupMenu.iOKButtonImages, (INT16)(sX + ITEMPICK_OK_X), (INT16)(sY + gItemPickupMenu.sButtomPanelStartY + ITEMPICK_OK_Y),
  5000. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  5001. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemPickupOK );
  5002. SetButtonFastHelpText( gItemPickupMenu.iOKButton, ItemPickupHelpPopup[ 0 ] );
  5003. gItemPickupMenu.iAllButton = QuickCreateButton( gItemPickupMenu.iAllButtonImages, (INT16)(sX + ITEMPICK_ALL_X), (INT16)(sY + gItemPickupMenu.sButtomPanelStartY + ITEMPICK_ALL_Y),
  5004. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  5005. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemPickupAll );
  5006. SetButtonFastHelpText( gItemPickupMenu.iAllButton, ItemPickupHelpPopup[ 2 ] );
  5007. gItemPickupMenu.iCancelButton = QuickCreateButton( gItemPickupMenu.iCancelButtonImages, (INT16)(sX + ITEMPICK_CANCEL_X), (INT16)(sY + gItemPickupMenu.sButtomPanelStartY + ITEMPICK_CANCEL_Y),
  5008. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  5009. DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)ItemPickupCancel );
  5010. SetButtonFastHelpText( gItemPickupMenu.iCancelButton, ItemPickupHelpPopup[ 4 ] );
  5011. DisableButton( gItemPickupMenu.iOKButton );
  5012. // Create regions...
  5013. sCenX = gItemPickupMenu.sX;
  5014. sCenY = gItemPickupMenu.sY + ITEMPICK_GRAPHIC_Y;
  5015. for ( cnt = 0; cnt < gItemPickupMenu.bNumSlotsPerPage; cnt++ )
  5016. {
  5017. // Build a mouse region here that is over any others.....
  5018. MSYS_DefineRegion( &(gItemPickupMenu.Regions[cnt]), (INT16)(sCenX ), (INT16)(sCenY + 1), (INT16)(sCenX + gItemPickupMenu.sWidth ),(INT16)( sCenY + ITEMPICK_GRAPHIC_YSPACE ), MSYS_PRIORITY_HIGHEST,
  5019. CURSOR_NORMAL, ItemPickMenuMouseMoveCallback, ItemPickMenuMouseClickCallback );
  5020. // Add region
  5021. MSYS_AddRegion( &(gItemPickupMenu.Regions[cnt]) );
  5022. MSYS_SetRegionUserData( &(gItemPickupMenu.Regions[cnt]), 0, cnt );
  5023. sCenY += ITEMPICK_GRAPHIC_YSPACE;
  5024. }
  5025. //Save dirty rect
  5026. //gItemPickupMenu.iDirtyRect = RegisterBackgroundRect( BGND_FLAG_PERMANENT | BGND_FLAG_SAVERECT, NULL, gItemPickupMenu.sX, gItemPickupMenu.sY, (INT16)(gItemPickupMenu.sX + gItemPickupMenu.sWidth ) , (INT16)(gItemPickupMenu.sY + gItemPickupMenu.sHeight ) );
  5027. SetupPickupPage( 0 );
  5028. gfInItemPickupMenu = TRUE;
  5029. // Ignore scrolling
  5030. gfIgnoreScrolling = TRUE;
  5031. HandleAnyMercInSquadHasCompatibleStuff( (INT8) CurrentSquad( ), NULL, TRUE );
  5032. gubSelectSMPanelToMerc = pSoldier->ubID;
  5033. ReEvaluateDisabledINVPanelButtons( );
  5034. DisableTacticalTeamPanelButtons( TRUE );
  5035. //gfSMDisableForItems = TRUE;
  5036. return( TRUE );
  5037. }
  5038. void SetupPickupPage( INT8 bPage )
  5039. {
  5040. INT32 cnt, iStart, iEnd;
  5041. ITEM_POOL *pTempItemPool;
  5042. INT16 sValue;
  5043. OBJECTTYPE *pObject;
  5044. static INT16 pStr[ 200 ];
  5045. // Zero out page slots
  5046. memset( gItemPickupMenu.ItemPoolSlots, 0, sizeof( gItemPickupMenu.ItemPoolSlots ) );
  5047. // Zero page flags
  5048. gItemPickupMenu.fCanScrollUp = FALSE;
  5049. gItemPickupMenu.fCanScrollDown = FALSE;
  5050. // Get lower bound
  5051. iStart = bPage * NUM_PICKUP_SLOTS;
  5052. if ( iStart > gItemPickupMenu.ubTotalItems )
  5053. {
  5054. return;
  5055. }
  5056. if ( bPage > 0 )
  5057. {
  5058. gItemPickupMenu.fCanScrollUp = TRUE;
  5059. }
  5060. iEnd = iStart + NUM_PICKUP_SLOTS;
  5061. if ( iEnd >= gItemPickupMenu.ubTotalItems )
  5062. {
  5063. iEnd = gItemPickupMenu.ubTotalItems;
  5064. }
  5065. else
  5066. {
  5067. // We can go for more!
  5068. gItemPickupMenu.fCanScrollDown = TRUE;
  5069. }
  5070. // Setup slots!
  5071. // These slots contain an inventory pool pointer for each slot...
  5072. pTempItemPool = gItemPickupMenu.pItemPool;
  5073. // ATE: Patch fix here for crash :(
  5074. // Clear help text!
  5075. for ( cnt = 0; cnt < NUM_PICKUP_SLOTS; cnt++ )
  5076. {
  5077. SetRegionFastHelpText( &(gItemPickupMenu.Regions[cnt]), L"" );
  5078. }
  5079. for ( cnt = 0; cnt < iEnd; )
  5080. {
  5081. // Move to the closest one that can be displayed....
  5082. while( !ItemPoolOKForDisplay( pTempItemPool, gItemPickupMenu.bZLevel ) )
  5083. {
  5084. pTempItemPool = pTempItemPool->pNext;
  5085. }
  5086. if ( cnt >= iStart )
  5087. {
  5088. gItemPickupMenu.ItemPoolSlots[ cnt - iStart ] = pTempItemPool;
  5089. pObject = &(gWorldItems[ pTempItemPool->iItemIndex ].o );
  5090. sValue = pObject->bStatus[ 0 ];
  5091. // Adjust for ammo, other thingys..
  5092. if( Item[ pObject->usItem ].usItemClass & IC_AMMO || Item[ pObject->usItem ].usItemClass & IC_KEY )
  5093. {
  5094. swprintf( pStr, L"" );
  5095. }
  5096. else
  5097. {
  5098. swprintf( pStr, L"%d%%", sValue );
  5099. }
  5100. SetRegionFastHelpText( &(gItemPickupMenu.Regions[ cnt - iStart ]), pStr );
  5101. }
  5102. cnt++;
  5103. pTempItemPool = pTempItemPool->pNext;
  5104. }
  5105. gItemPickupMenu.bScrollPage = bPage;
  5106. gItemPickupMenu.ubScrollAnchor = (UINT8)iStart;
  5107. if ( gItemPickupMenu.bNumSlotsPerPage == NUM_PICKUP_SLOTS && gItemPickupMenu.ubTotalItems > NUM_PICKUP_SLOTS )
  5108. {
  5109. // Setup enabled/disabled buttons
  5110. if ( gItemPickupMenu.fCanScrollUp )
  5111. {
  5112. EnableButton( gItemPickupMenu.iUpButton );
  5113. }
  5114. else
  5115. {
  5116. DisableButton( gItemPickupMenu.iUpButton );
  5117. }
  5118. // Setup enabled/disabled buttons
  5119. if ( gItemPickupMenu.fCanScrollDown )
  5120. {
  5121. EnableButton( gItemPickupMenu.iDownButton );
  5122. }
  5123. else
  5124. {
  5125. DisableButton( gItemPickupMenu.iDownButton );
  5126. }
  5127. }
  5128. SetItemPickupMenuDirty( DIRTYLEVEL2 );
  5129. }
  5130. void CalculateItemPickupMenuDimensions( )
  5131. {
  5132. INT32 cnt;
  5133. INT16 sX, sY;
  5134. UINT16 usSubRegion, usHeight, usWidth;
  5135. // Build background
  5136. sX = 0;
  5137. sY = 0;
  5138. for ( cnt = 0; cnt < gItemPickupMenu.bNumSlotsPerPage; cnt++ )
  5139. {
  5140. if ( cnt == 0 )
  5141. {
  5142. usSubRegion = 0;
  5143. }
  5144. else
  5145. {
  5146. usSubRegion = 1;
  5147. }
  5148. // Add hieght of object
  5149. GetVideoObjectETRLESubregionProperties( gItemPickupMenu.uiPanelVo, usSubRegion, &usWidth, &usHeight );
  5150. sY += usHeight;
  5151. }
  5152. gItemPickupMenu.sButtomPanelStartY = sY;
  5153. // Do end
  5154. GetVideoObjectETRLESubregionProperties( gItemPickupMenu.uiPanelVo, 2, &usWidth, &usHeight );
  5155. sY += usHeight;
  5156. // Set height, width
  5157. gItemPickupMenu.sHeight = sY;
  5158. gItemPickupMenu.sWidth = usWidth;
  5159. }
  5160. // set pick up menu dirty level
  5161. void SetPickUpMenuDirtyLevel( BOOLEAN fDirtyLevel )
  5162. {
  5163. gItemPickupMenu.fDirtyLevel = fDirtyLevel;
  5164. return;
  5165. }
  5166. void RenderItemPickupMenu( )
  5167. {
  5168. INT32 cnt;
  5169. UINT16 usItemTileIndex;
  5170. INT16 sX, sY, sCenX, sCenY, sFontX, sFontY, sNewX, sNewY;
  5171. UINT32 uiDestPitchBYTES;
  5172. UINT8 *pDestBuf;
  5173. INT16 pStr[ 100 ];
  5174. UINT16 usSubRegion, usHeight, usWidth;
  5175. INVTYPE *pItem;
  5176. OBJECTTYPE *pObject;
  5177. UINT16 uiStringLength;
  5178. if ( !gfInItemPickupMenu )
  5179. {
  5180. return;
  5181. }
  5182. // Do everything!
  5183. if ( gItemPickupMenu.fDirtyLevel == DIRTYLEVEL2 )
  5184. {
  5185. MarkButtonsDirty( );
  5186. // Build background
  5187. sX = gItemPickupMenu.sX;
  5188. sY = gItemPickupMenu.sY;
  5189. for ( cnt = 0; cnt < gItemPickupMenu.bNumSlotsPerPage; cnt++ )
  5190. {
  5191. if ( cnt == 0 )
  5192. {
  5193. usSubRegion = 0;
  5194. }
  5195. else
  5196. {
  5197. usSubRegion = 1;
  5198. }
  5199. BltVideoObjectFromIndex( FRAME_BUFFER, gItemPickupMenu.uiPanelVo, usSubRegion, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL );
  5200. // Add hieght of object
  5201. GetVideoObjectETRLESubregionProperties( gItemPickupMenu.uiPanelVo, usSubRegion, &usWidth, &usHeight );
  5202. sY += usHeight;
  5203. }
  5204. // Do end
  5205. if ( gItemPickupMenu.bNumSlotsPerPage == NUM_PICKUP_SLOTS && gItemPickupMenu.ubTotalItems > NUM_PICKUP_SLOTS )
  5206. {
  5207. BltVideoObjectFromIndex( FRAME_BUFFER, gItemPickupMenu.uiPanelVo, 2, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL );
  5208. }
  5209. else
  5210. {
  5211. BltVideoObjectFromIndex( FRAME_BUFFER, gItemPickupMenu.uiPanelVo, 3, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL );
  5212. }
  5213. // Render items....
  5214. sX = ITEMPICK_GRAPHIC_X + gItemPickupMenu.sX;
  5215. sY = ITEMPICK_GRAPHIC_Y + gItemPickupMenu.sY;
  5216. pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
  5217. SetFont( ITEMDESC_FONT );
  5218. SetFontBackground( FONT_MCOLOR_BLACK );
  5219. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  5220. for ( cnt = 0; cnt < gItemPickupMenu.bNumSlotsPerPage; cnt++ )
  5221. {
  5222. if ( gItemPickupMenu.ItemPoolSlots[ cnt ] != NULL )
  5223. {
  5224. // Get item to render
  5225. pObject = &(gWorldItems[ gItemPickupMenu.ItemPoolSlots[ cnt ]->iItemIndex ].o );
  5226. pItem = &( Item[ pObject->usItem ] );
  5227. usItemTileIndex = GetTileGraphicForItem( pItem );
  5228. // Render
  5229. sX = ITEMPICK_GRAPHIC_X + gItemPickupMenu.sX;
  5230. sCenX = sX;
  5231. sCenY = sY;
  5232. // ATE: Adjust to basic shade.....
  5233. gTileDatabase[ usItemTileIndex ].hTileSurface->pShadeCurrent=gTileDatabase[ usItemTileIndex ].hTileSurface->pShades[4];
  5234. //else
  5235. {
  5236. if ( gItemPickupMenu.pfSelectedArray[ cnt + gItemPickupMenu.ubScrollAnchor ] )
  5237. {
  5238. //SetFontForeground( FONT_MCOLOR_LTYELLOW );
  5239. //SetFontShadow( ITEMDESC_FONTSHADOW2 );
  5240. Blt8BPPDataTo16BPPBufferOutline( (UINT16*)pDestBuf, uiDestPitchBYTES, gTileDatabase[ usItemTileIndex ].hTileSurface, sCenX, sCenY, gTileDatabase[ usItemTileIndex ].usRegionIndex, Get16BPPColor( FROMRGB( 255, 255, 0 ) ), TRUE );
  5241. }
  5242. else
  5243. {
  5244. //SetFontForeground( FONT_BLACK );
  5245. //SetFontShadow( ITEMDESC_FONTSHADOW2 );
  5246. Blt8BPPDataTo16BPPBufferOutline( (UINT16*)pDestBuf, uiDestPitchBYTES, gTileDatabase[ usItemTileIndex ].hTileSurface, sCenX, sCenY, gTileDatabase[ usItemTileIndex ].usRegionIndex, 0, FALSE );
  5247. }
  5248. }
  5249. // Draw text.....
  5250. SetFont( ITEM_FONT );
  5251. if ( pObject->ubNumberOfObjects > 1 )
  5252. {
  5253. SetFontForeground( FONT_GRAY4 );
  5254. SetFontShadow( DEFAULT_SHADOW );
  5255. sCenX = sX - 4;
  5256. sCenY = sY + 14;
  5257. swprintf( pStr, L"%d", pObject->ubNumberOfObjects );
  5258. VarFindFontRightCoordinates( sCenX, sCenY, 42, 1 , ITEM_FONT, &sFontX, &sFontY, pStr );
  5259. mprintf_buffer( pDestBuf, uiDestPitchBYTES, ITEM_FONT, sFontX, sFontY, pStr );
  5260. }
  5261. SetFont( ITEMDESC_FONT );
  5262. // Render attachment symbols
  5263. if ( ItemHasAttachments( pObject ) )
  5264. {
  5265. SetFontForeground( FONT_GREEN );
  5266. SetFontShadow( DEFAULT_SHADOW );
  5267. sNewY = sCenY + 2;
  5268. swprintf( pStr, L"*" );
  5269. // Get length of string
  5270. uiStringLength=StringPixLength( pStr, ITEM_FONT );
  5271. sNewX = sCenX + 43 - uiStringLength - 4;
  5272. mprintf_buffer( pDestBuf, uiDestPitchBYTES, ITEMDESC_FONT, sNewX, sNewY, pStr );
  5273. //gprintfinvalidate( sNewX, sNewY, pStr );
  5274. }
  5275. if ( gItemPickupMenu.bCurSelect == ( cnt + gItemPickupMenu.ubScrollAnchor ) )
  5276. {
  5277. //SetFontForeground( ITEMDESC_FONTSHADOW2 );
  5278. //if ( gItemPickupMenu.pfSelectedArray[ cnt + gItemPickupMenu.ubScrollAnchor ] )
  5279. //{
  5280. // SetFontForeground( FONT_MCOLOR_LTYELLOW );
  5281. // SetFontShadow( ITEMDESC_FONTSHADOW2 );
  5282. //}
  5283. //else
  5284. //{
  5285. SetFontForeground( FONT_WHITE );
  5286. SetFontShadow( DEFAULT_SHADOW );
  5287. //}
  5288. // Blt8BPPDataTo16BPPBufferOutline( (UINT16*)pDestBuf, uiDestPitchBYTES, gTileDatabase[ usItemTileIndex ].hTileSurface, sCenX, sCenY, gTileDatabase[ usItemTileIndex ].usRegionIndex, Get16BPPColor( FROMRGB( 255, 0, 0 ) ), TRUE );
  5289. // Blt8BPPDataTo16BPPBufferOutline( (UINT16*)pDestBuf, uiDestPitchBYTES, gTileDatabase[ usItemTileIndex ].hTileSurface, sCenX, sCenY, gTileDatabase[ usItemTileIndex ].usRegionIndex, Get16BPPColor( FROMRGB( 255, 0, 0 ) ), TRUE );
  5290. }
  5291. else
  5292. {
  5293. SetFontForeground( FONT_BLACK );
  5294. SetFontShadow( ITEMDESC_FONTSHADOW2 );
  5295. }
  5296. // Render name
  5297. sCenX = ITEMPICK_TEXT_X + gItemPickupMenu.sX;
  5298. sCenY = ITEMPICK_TEXT_Y + gItemPickupMenu.sY + ( ITEMPICK_TEXT_YSPACE * (INT16)cnt );
  5299. // If we are money...
  5300. if ( Item[ pObject->usItem ].usItemClass == IC_MONEY )
  5301. {
  5302. INT16 pStr2[20];
  5303. swprintf( pStr2, L"%ld", pObject->uiMoneyAmount );
  5304. InsertCommasForDollarFigure( pStr2 );
  5305. InsertDollarSignInToString( pStr2 );
  5306. swprintf( pStr, L"%s (%ls)", ItemNames[ pObject->usItem ], pStr2 );
  5307. }
  5308. else
  5309. {
  5310. swprintf( pStr, L"%s", ShortItemNames[ pObject->usItem ] );
  5311. }
  5312. VarFindFontCenterCoordinates( sCenX, sCenY, ITEMPICK_TEXT_WIDTH, 1 , ITEMDESC_FONT, &sFontX, &sFontY, pStr );
  5313. mprintf_buffer( pDestBuf, uiDestPitchBYTES, ITEMDESC_FONT, sFontX, sFontY, pStr );
  5314. sY += ITEMPICK_GRAPHIC_YSPACE;
  5315. }
  5316. }
  5317. SetFontShadow( DEFAULT_SHADOW );
  5318. UnLockVideoSurface( FRAME_BUFFER );
  5319. InvalidateRegion( gItemPickupMenu.sX, gItemPickupMenu.sY, gItemPickupMenu.sX + gItemPickupMenu.sWidth, gItemPickupMenu.sY + gItemPickupMenu.sHeight );
  5320. gItemPickupMenu.fDirtyLevel = 0;
  5321. }
  5322. }
  5323. void RemoveItemPickupMenu( )
  5324. {
  5325. INT32 cnt;
  5326. if ( gfInItemPickupMenu )
  5327. {
  5328. gfSMDisableForItems = FALSE;
  5329. HandleAnyMercInSquadHasCompatibleStuff( (INT8) CurrentSquad( ), NULL, TRUE );
  5330. UnLockPauseState();
  5331. UnPauseGame();
  5332. // UnPause timers as well....
  5333. PauseTime( FALSE );
  5334. // Unfreese guy!
  5335. gItemPickupMenu.pSoldier->fPauseAllAnimation = FALSE;
  5336. // Remove graphics!
  5337. DeleteVideoObjectFromIndex( gItemPickupMenu.uiPanelVo );
  5338. // Remove buttons
  5339. if ( gItemPickupMenu.bNumSlotsPerPage == NUM_PICKUP_SLOTS && gItemPickupMenu.ubTotalItems > NUM_PICKUP_SLOTS )
  5340. {
  5341. RemoveButton( gItemPickupMenu.iUpButton );
  5342. RemoveButton( gItemPickupMenu.iDownButton );
  5343. }
  5344. RemoveButton( gItemPickupMenu.iAllButton );
  5345. RemoveButton( gItemPickupMenu.iOKButton );
  5346. RemoveButton( gItemPickupMenu.iCancelButton );
  5347. // Remove button images
  5348. UnloadButtonImage( gItemPickupMenu.iUpButtonImages );
  5349. UnloadButtonImage( gItemPickupMenu.iDownButtonImages );
  5350. UnloadButtonImage( gItemPickupMenu.iAllButtonImages );
  5351. UnloadButtonImage( gItemPickupMenu.iCancelButtonImages );
  5352. UnloadButtonImage( gItemPickupMenu.iOKButtonImages );
  5353. MSYS_RemoveRegion( &(gItemPickupMenu.BackRegions ) );
  5354. MSYS_RemoveRegion( &(gItemPickupMenu.BackRegion ) );
  5355. // Remove regions
  5356. for ( cnt = 0; cnt < gItemPickupMenu.bNumSlotsPerPage; cnt++ )
  5357. {
  5358. MSYS_RemoveRegion( &(gItemPickupMenu.Regions[cnt]));
  5359. }
  5360. // Remove register rect
  5361. if ( gItemPickupMenu.iDirtyRect != -1 )
  5362. {
  5363. //FreeBackgroundRect( gItemPickupMenu.iDirtyRect );
  5364. }
  5365. // Free selection list...
  5366. MemFree( gItemPickupMenu.pfSelectedArray );
  5367. gItemPickupMenu.pfSelectedArray = NULL;
  5368. // Set cursor back to normal mode...
  5369. guiPendingOverrideEvent = A_CHANGE_TO_MOVE;
  5370. // Rerender world
  5371. SetRenderFlags( RENDER_FLAG_FULL );
  5372. gfInItemPickupMenu = FALSE;
  5373. //gfSMDisableForItems = FALSE;
  5374. //EnableButtonsForInItemBox( TRUE );
  5375. EnableSMPanelButtons( TRUE , TRUE );
  5376. gfSMDisableForItems = FALSE;
  5377. fInterfacePanelDirty = DIRTYLEVEL2;
  5378. // Turn off Ignore scrolling
  5379. gfIgnoreScrolling = FALSE;
  5380. DisableTacticalTeamPanelButtons( FALSE );
  5381. gubSelectSMPanelToMerc = gpSMCurrentMerc->ubID;
  5382. }
  5383. }
  5384. void ItemPickupScrollUp( GUI_BUTTON *btn, INT32 reason )
  5385. {
  5386. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  5387. {
  5388. btn->uiFlags |= BUTTON_CLICKED_ON;
  5389. }
  5390. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  5391. {
  5392. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5393. SetupPickupPage( (UINT8)( gItemPickupMenu.bScrollPage - 1 ) );
  5394. }
  5395. else if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  5396. {
  5397. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5398. }
  5399. }
  5400. void ItemPickupScrollDown( GUI_BUTTON *btn, INT32 reason )
  5401. {
  5402. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  5403. {
  5404. btn->uiFlags |= BUTTON_CLICKED_ON;
  5405. }
  5406. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  5407. {
  5408. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5409. SetupPickupPage( (UINT8)( gItemPickupMenu.bScrollPage + 1 ) );
  5410. }
  5411. else if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  5412. {
  5413. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5414. }
  5415. }
  5416. void ItemPickupAll( GUI_BUTTON *btn, INT32 reason )
  5417. {
  5418. INT32 cnt;
  5419. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  5420. {
  5421. btn->uiFlags |= BUTTON_CLICKED_ON;
  5422. }
  5423. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  5424. {
  5425. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5426. gItemPickupMenu.fAllSelected = !gItemPickupMenu.fAllSelected;
  5427. // OK, pickup item....
  5428. //gItemPickupMenu.fHandled = TRUE;
  5429. // Tell our soldier to pickup this item!
  5430. //SoldierGetItemFromWorld( gItemPickupMenu.pSoldier, ITEM_PICKUP_ACTION_ALL, gItemPickupMenu.sGridNo, gItemPickupMenu.bZLevel, NULL );
  5431. for ( cnt = 0; cnt < gItemPickupMenu.ubTotalItems; cnt++ )
  5432. {
  5433. gItemPickupMenu.pfSelectedArray[ cnt ] = gItemPickupMenu.fAllSelected;
  5434. }
  5435. if ( gItemPickupMenu.fAllSelected )
  5436. {
  5437. EnableButton( gItemPickupMenu.iOKButton );
  5438. }
  5439. else
  5440. {
  5441. DisableButton( gItemPickupMenu.iOKButton );
  5442. }
  5443. }
  5444. else if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  5445. {
  5446. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5447. }
  5448. }
  5449. void ItemPickupOK( GUI_BUTTON *btn, INT32 reason )
  5450. {
  5451. INT32 cnt = 0;
  5452. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  5453. {
  5454. btn->uiFlags |= BUTTON_CLICKED_ON;
  5455. }
  5456. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  5457. {
  5458. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5459. // OK, pickup item....
  5460. gItemPickupMenu.fHandled = TRUE;
  5461. // Tell our soldier to pickup this item!
  5462. SoldierGetItemFromWorld( gItemPickupMenu.pSoldier, ITEM_PICKUP_SELECTION, gItemPickupMenu.sGridNo, gItemPickupMenu.bZLevel, gItemPickupMenu.pfSelectedArray );
  5463. }
  5464. else if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  5465. {
  5466. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5467. }
  5468. }
  5469. void ItemPickupCancel( GUI_BUTTON *btn, INT32 reason )
  5470. {
  5471. INT32 cnt = 0;
  5472. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  5473. {
  5474. btn->uiFlags |= BUTTON_CLICKED_ON;
  5475. }
  5476. else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  5477. {
  5478. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5479. // OK, pickup item....
  5480. gItemPickupMenu.fHandled = TRUE;
  5481. }
  5482. else if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  5483. {
  5484. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5485. }
  5486. }
  5487. void ItemPickMenuMouseMoveCallback( MOUSE_REGION * pRegion, INT32 iReason )
  5488. {
  5489. UINT32 uiItemPos;
  5490. ITEM_POOL *pTempItemPool;
  5491. INT32 bPos;
  5492. static BOOLEAN bChecked = FALSE;
  5493. uiItemPos = MSYS_GetRegionUserData( pRegion, 0 );
  5494. if (iReason & MSYS_CALLBACK_REASON_MOVE)
  5495. {
  5496. bPos = ( uiItemPos + gItemPickupMenu.ubScrollAnchor );
  5497. if ( bPos < gItemPickupMenu.ubTotalItems )
  5498. {
  5499. // Set current selected guy....
  5500. gItemPickupMenu.bCurSelect = bPos;
  5501. if ( !bChecked )
  5502. {
  5503. // Show compatible ammo...
  5504. pTempItemPool = gItemPickupMenu.ItemPoolSlots[ gItemPickupMenu.bCurSelect - gItemPickupMenu.ubScrollAnchor ];
  5505. memcpy( &(gItemPickupMenu.CompAmmoObject), &( gWorldItems[ pTempItemPool->iItemIndex ].o ), sizeof( OBJECTTYPE ) );
  5506. // Turn off first...
  5507. HandleAnyMercInSquadHasCompatibleStuff( (INT8) CurrentSquad( ), NULL, TRUE );
  5508. InternalHandleCompatibleAmmoUI( gpSMCurrentMerc, &( gItemPickupMenu.CompAmmoObject ), TRUE );
  5509. HandleAnyMercInSquadHasCompatibleStuff( (INT8)CurrentSquad( ), &(gWorldItems[ pTempItemPool->iItemIndex ].o ), FALSE );
  5510. SetItemPickupMenuDirty( DIRTYLEVEL2 );
  5511. bChecked = TRUE;
  5512. }
  5513. }
  5514. }
  5515. else if( iReason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  5516. {
  5517. gItemPickupMenu.bCurSelect = 255;
  5518. InternalHandleCompatibleAmmoUI( gpSMCurrentMerc, &( gItemPickupMenu.CompAmmoObject ), FALSE );
  5519. HandleAnyMercInSquadHasCompatibleStuff( (INT8) CurrentSquad( ), NULL, TRUE );
  5520. SetItemPickupMenuDirty( DIRTYLEVEL2 );
  5521. bChecked = FALSE;
  5522. }
  5523. }
  5524. void ItemPickupBackgroundClick( MOUSE_REGION * pRegion, INT32 iReason )
  5525. {
  5526. if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  5527. {
  5528. // OK, goto team panel....
  5529. ToggleTacticalPanels();
  5530. }
  5531. }
  5532. void ItemPickMenuMouseClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
  5533. {
  5534. INT32 uiItemPos;
  5535. UINT8 cnt;
  5536. BOOLEAN fEnable = FALSE;
  5537. uiItemPos = MSYS_GetRegionUserData( pRegion, 0 );
  5538. if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  5539. {
  5540. if ( uiItemPos + gItemPickupMenu.ubScrollAnchor < gItemPickupMenu.ubTotalItems )
  5541. {
  5542. // Toggle selection... ONLY IF LEGAL!!
  5543. gItemPickupMenu.pfSelectedArray[ uiItemPos + gItemPickupMenu.ubScrollAnchor ] = !gItemPickupMenu.pfSelectedArray[ uiItemPos + gItemPickupMenu.ubScrollAnchor ];
  5544. // OK, pickup item....
  5545. //gItemPickupMenu.fHandled = TRUE;
  5546. //pTempItemPool = gItemPickupMenu.ItemPoolSlots[ gItemPickupMenu.bCurSelect - gItemPickupMenu.ubScrollAnchor ];
  5547. // Tell our soldier to pickup this item!
  5548. //SoldierGetItemFromWorld( gItemPickupMenu.pSoldier, pTempItemPool->iItemIndex, gItemPickupMenu.sGridNo, gItemPickupMenu.bZLevel );
  5549. }
  5550. // Loop through all and set /unset OK
  5551. for ( cnt = 0; cnt < gItemPickupMenu.ubTotalItems; cnt++ )
  5552. {
  5553. if ( gItemPickupMenu.pfSelectedArray[ cnt ] )
  5554. {
  5555. fEnable = TRUE;
  5556. break;
  5557. }
  5558. }
  5559. if ( fEnable )
  5560. {
  5561. EnableButton( gItemPickupMenu.iOKButton );
  5562. }
  5563. else
  5564. {
  5565. DisableButton( gItemPickupMenu.iOKButton );
  5566. }
  5567. }
  5568. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  5569. {
  5570. }
  5571. }
  5572. BOOLEAN HandleItemPickupMenu( )
  5573. {
  5574. if ( !gfInItemPickupMenu )
  5575. {
  5576. return( FALSE );
  5577. }
  5578. if ( gItemPickupMenu.fHandled )
  5579. {
  5580. RemoveItemPickupMenu( );
  5581. }
  5582. return( gItemPickupMenu.fHandled );
  5583. }
  5584. void BtnMoneyButtonCallback(GUI_BUTTON *btn,INT32 reason)
  5585. {
  5586. INT8 i;
  5587. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  5588. {
  5589. btn->uiFlags |= BUTTON_CLICKED_ON;
  5590. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  5591. }
  5592. if(reason & MSYS_CALLBACK_REASON_RBUTTON_DWN )
  5593. {
  5594. btn->uiFlags |= BUTTON_CLICKED_ON;
  5595. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  5596. }
  5597. if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  5598. {
  5599. UINT8 ubButton = (UINT8)MSYS_GetBtnUserData( btn, 0 );
  5600. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5601. switch( ubButton )
  5602. {
  5603. case M_1000:
  5604. if( gRemoveMoney.uiMoneyRemaining >= 1000 )
  5605. {
  5606. //if the player is removing money from their account, and they are removing more then $20,000
  5607. if( gfAddingMoneyToMercFromPlayersAccount && ( gRemoveMoney.uiMoneyRemoving + 1000 ) > MAX_MONEY_PER_SLOT )
  5608. {
  5609. if( guiCurrentScreen == SHOPKEEPER_SCREEN )
  5610. DoMessageBox( MSG_BOX_BASIC_STYLE, gzMoneyWithdrawMessageText[ MONEY_TEXT_WITHDRAW_MORE_THEN_MAXIMUM ], SHOPKEEPER_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL );
  5611. else
  5612. DoMessageBox( MSG_BOX_BASIC_STYLE, gzMoneyWithdrawMessageText[ MONEY_TEXT_WITHDRAW_MORE_THEN_MAXIMUM ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL );
  5613. return;
  5614. }
  5615. gRemoveMoney.uiMoneyRemaining -= 1000;
  5616. gRemoveMoney.uiMoneyRemoving += 1000;
  5617. }
  5618. break;
  5619. case M_100:
  5620. if( gRemoveMoney.uiMoneyRemaining >= 100 )
  5621. {
  5622. //if the player is removing money from their account, and they are removing more then $20,000
  5623. if( gfAddingMoneyToMercFromPlayersAccount && ( gRemoveMoney.uiMoneyRemoving + 100 ) > MAX_MONEY_PER_SLOT )
  5624. {
  5625. DoMessageBox( MSG_BOX_BASIC_STYLE, gzMoneyWithdrawMessageText[ MONEY_TEXT_WITHDRAW_MORE_THEN_MAXIMUM ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL );
  5626. return;
  5627. }
  5628. gRemoveMoney.uiMoneyRemaining -= 100;
  5629. gRemoveMoney.uiMoneyRemoving += 100;
  5630. }
  5631. break;
  5632. case M_10:
  5633. if( gRemoveMoney.uiMoneyRemaining >= 10 )
  5634. {
  5635. //if the player is removing money from their account, and they are removing more then $20,000
  5636. if( gfAddingMoneyToMercFromPlayersAccount && ( gRemoveMoney.uiMoneyRemoving + 10 ) > MAX_MONEY_PER_SLOT )
  5637. {
  5638. DoMessageBox( MSG_BOX_BASIC_STYLE, gzMoneyWithdrawMessageText[ MONEY_TEXT_WITHDRAW_MORE_THEN_MAXIMUM ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL );
  5639. return;
  5640. }
  5641. gRemoveMoney.uiMoneyRemaining -= 10;
  5642. gRemoveMoney.uiMoneyRemoving += 10;
  5643. }
  5644. break;
  5645. case M_DONE:
  5646. {
  5647. RemoveMoney();
  5648. DeleteItemDescriptionBox( );
  5649. }
  5650. break;
  5651. }
  5652. if( ubButton != M_DONE )
  5653. {
  5654. RenderItemDescriptionBox( );
  5655. for( i=0; i<MAX_ATTACHMENTS; i++ )
  5656. {
  5657. MarkAButtonDirty( guiMoneyButtonBtn[ i ] );
  5658. }
  5659. }
  5660. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  5661. }
  5662. if(reason & MSYS_CALLBACK_REASON_RBUTTON_UP )
  5663. {
  5664. UINT8 ubButton = (UINT8)MSYS_GetBtnUserData( btn, 0 );
  5665. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  5666. switch( ubButton )
  5667. {
  5668. case M_1000:
  5669. if( gRemoveMoney.uiMoneyRemoving >= 1000 )
  5670. {
  5671. gRemoveMoney.uiMoneyRemaining += 1000;
  5672. gRemoveMoney.uiMoneyRemoving -= 1000;
  5673. }
  5674. break;
  5675. case M_100:
  5676. if( gRemoveMoney.uiMoneyRemoving >= 100 )
  5677. {
  5678. gRemoveMoney.uiMoneyRemaining += 100;
  5679. gRemoveMoney.uiMoneyRemoving -= 100;
  5680. }
  5681. break;
  5682. case M_10:
  5683. if( gRemoveMoney.uiMoneyRemoving >= 10 )
  5684. {
  5685. gRemoveMoney.uiMoneyRemaining += 10;
  5686. gRemoveMoney.uiMoneyRemoving -= 10;
  5687. }
  5688. break;
  5689. }
  5690. RenderItemDescriptionBox( );
  5691. for( i=0; i<MAX_ATTACHMENTS; i++ )
  5692. {
  5693. MarkAButtonDirty( guiMoneyButtonBtn[ i ] );
  5694. }
  5695. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  5696. }
  5697. }
  5698. void RemoveMoney()
  5699. {
  5700. if( gRemoveMoney.uiMoneyRemoving != 0 )
  5701. {
  5702. //if we are in the shop keeper interface
  5703. if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE )
  5704. {
  5705. INVENTORY_IN_SLOT InvSlot;
  5706. memset( &InvSlot, 0, sizeof(INVENTORY_IN_SLOT) );
  5707. InvSlot.fActive = TRUE;
  5708. InvSlot.sItemIndex = MONEY;
  5709. InvSlot.bSlotIdInOtherLocation = -1;
  5710. //Remove the money from the money in the pocket
  5711. gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemaining;
  5712. //Create an item to get the money that is being removed
  5713. CreateItem( MONEY, 0, &InvSlot.ItemObject );
  5714. //Set the amount thast is being removed
  5715. InvSlot.ItemObject.uiMoneyAmount = gRemoveMoney.uiMoneyRemoving;
  5716. InvSlot.ubIdOfMercWhoOwnsTheItem = gpItemDescSoldier->ubProfile;
  5717. //if we are removing money from the players account
  5718. if( gfAddingMoneyToMercFromPlayersAccount )
  5719. {
  5720. gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemoving;
  5721. //take the money from the player
  5722. AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, gpSMCurrentMerc->ubProfile, GetWorldTotalMin() , -(INT32)( gpItemDescObject->uiMoneyAmount ) );
  5723. }
  5724. memcpy( &gMoveingItem, &InvSlot, sizeof( INVENTORY_IN_SLOT ) );
  5725. memcpy( &gItemPointer, &InvSlot.ItemObject, sizeof( OBJECTTYPE ) );
  5726. gpItemPointer = &gItemPointer;
  5727. gpItemPointerSoldier = gpSMCurrentMerc;
  5728. // Set mouse
  5729. SetSkiCursor( EXTERN_CURSOR );
  5730. //Restrict the cursor to the proper area
  5731. RestrictSkiMouseCursor();
  5732. }
  5733. else
  5734. {
  5735. CreateMoney( gRemoveMoney.uiMoneyRemoving, &gItemPointer );
  5736. gpItemPointer = &gItemPointer;
  5737. //Asign the soldier to be the currently selected soldier
  5738. gpItemPointerSoldier = gpItemDescSoldier;
  5739. //Remove the money from the money in the pocket
  5740. //if we are removing money from the players account
  5741. if( gfAddingMoneyToMercFromPlayersAccount )
  5742. {
  5743. gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemoving;
  5744. //take the money from the player
  5745. AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, gpSMCurrentMerc->ubProfile, GetWorldTotalMin() , -(INT32)( gpItemDescObject->uiMoneyAmount ) );
  5746. }
  5747. else
  5748. gpItemDescObject->uiMoneyAmount = gRemoveMoney.uiMoneyRemaining;
  5749. if( guiCurrentItemDescriptionScreen == MAP_SCREEN )
  5750. {
  5751. // Set mouse
  5752. guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) );
  5753. gusExternVoSubIndex = Item[ gpItemPointer->usItem ].ubGraphicNum;
  5754. MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR );
  5755. MSYS_SetCurrentCursor( EXTERN_CURSOR );
  5756. fMapInventoryItem=TRUE;
  5757. fTeamPanelDirty=TRUE;
  5758. }
  5759. }
  5760. }
  5761. // if( gfAddingMoneyToMercFromPlayersAccount )
  5762. // gfAddingMoneyToMercFromPlayersAccount = FALSE;
  5763. }
  5764. BOOLEAN AttemptToApplyCamo( SOLDIERTYPE *pSoldier, UINT16 usItemIndex )
  5765. {
  5766. return( FALSE );
  5767. }
  5768. void GetHelpTextForItem( INT16 *pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier )
  5769. {
  5770. INT16 pStr[ 250 ];
  5771. UINT16 usItem = pObject->usItem;
  5772. INT32 cnt = 0;
  5773. INT32 iNumAttachments = 0;
  5774. if( pSoldier != NULL )
  5775. {
  5776. if ( pSoldier->uiStatusFlags & SOLDIER_DEAD )
  5777. {
  5778. swprintf( pStr, L"" );
  5779. swprintf( pzStr, L"%s", pStr );
  5780. return;
  5781. }
  5782. }
  5783. if ( usItem == MONEY )
  5784. {
  5785. swprintf( pStr, L"%ld", pObject->uiMoneyAmount );
  5786. InsertCommasForDollarFigure( pStr );
  5787. InsertDollarSignInToString( pStr );
  5788. }
  5789. else if ( Item[ usItem ].usItemClass == IC_MONEY )
  5790. { // alternate money like silver or gold
  5791. INT16 pStr2[20];
  5792. swprintf( pStr2, L"%ld", pObject->uiMoneyAmount );
  5793. InsertCommasForDollarFigure( pStr2 );
  5794. InsertDollarSignInToString( pStr2 );
  5795. swprintf( pStr, L"%s (%ls)", ItemNames[ usItem ], pStr2 );
  5796. }
  5797. else if ( usItem != NOTHING )
  5798. {
  5799. if ( !gGameOptions.fGunNut && Item[ usItem ].usItemClass == IC_GUN && usItem != ROCKET_LAUNCHER && usItem != ROCKET_RIFLE )
  5800. {
  5801. swprintf( pStr, L"%s (%s)", ItemNames[ usItem ], AmmoCaliber[ Weapon[ usItem ].ubCalibre ] );
  5802. }
  5803. else
  5804. {
  5805. swprintf( pStr, L"%s", ItemNames[ usItem ] );
  5806. }
  5807. if ( ( pObject->usItem == ROCKET_RIFLE || pObject->usItem == AUTO_ROCKET_RIFLE ) && pObject->ubImprintID < NO_PROFILE )
  5808. {
  5809. INT16 pStr2[20];
  5810. swprintf( pStr2, L" [%s]", gMercProfiles[ pObject->ubImprintID ].zNickname );
  5811. wcscat( pStr, pStr2 );
  5812. }
  5813. // Add attachment string....
  5814. for ( cnt = 0; cnt < MAX_ATTACHMENTS; cnt++ )
  5815. {
  5816. if ( pObject->usAttachItem[ cnt ] != NOTHING )
  5817. {
  5818. iNumAttachments++;
  5819. if ( iNumAttachments == 1 )
  5820. {
  5821. wcscat( pStr, L" ( " );
  5822. }
  5823. else
  5824. {
  5825. wcscat( pStr, L", \n" );
  5826. }
  5827. wcscat( pStr, ItemNames[ pObject->usAttachItem[ cnt ] ] );
  5828. }
  5829. }
  5830. if ( iNumAttachments > 0 )
  5831. {
  5832. wcscat( pStr, pMessageStrings[ MSG_END_ATTACHMENT_LIST ] );
  5833. }
  5834. }
  5835. else
  5836. {
  5837. swprintf( pStr, L"" );
  5838. }
  5839. // Copy over...
  5840. swprintf( pzStr, L"%s", pStr );
  5841. }
  5842. UINT8 GetPrefferedItemSlotGraphicNum( UINT16 usItem )
  5843. {
  5844. // Check for small item...
  5845. if ( Item[usItem].ubPerPocket >= 1 )
  5846. {
  5847. // Small
  5848. return( 2 );
  5849. }
  5850. // Now it could be large or armour, check class...
  5851. if ( Item[ usItem ].usItemClass == IC_ARMOUR )
  5852. {
  5853. return( 1 );
  5854. }
  5855. // OK, it's a big one...
  5856. return( 0 );
  5857. }
  5858. void CancelItemPointer( )
  5859. {
  5860. // ATE: If we have an item pointer end it!
  5861. if ( gpItemPointer != NULL )
  5862. {
  5863. if ( gbItemPointerSrcSlot != NO_SLOT )
  5864. {
  5865. // Place it back in our hands!
  5866. PlaceObject( gpItemPointerSoldier, gbItemPointerSrcSlot, gpItemPointer );
  5867. // ATE: This could potnetially swap!
  5868. // Make sure # of items is 0, if not, auto place somewhere else...
  5869. if ( gpItemPointer->ubNumberOfObjects > 0 )
  5870. {
  5871. if ( !AutoPlaceObject( gpItemPointerSoldier, gpItemPointer, FALSE ) )
  5872. {
  5873. // Alright, place of the friggen ground!
  5874. AddItemToPool( gpItemPointerSoldier->sGridNo, gpItemPointer, 1, gpItemPointerSoldier->bLevel, 0 , -1 );
  5875. NotifySoldiersToLookforItems( );
  5876. }
  5877. }
  5878. }
  5879. else
  5880. {
  5881. // We drop it here.....
  5882. AddItemToPool( gpItemPointerSoldier->sGridNo, gpItemPointer, 1, gpItemPointerSoldier->bLevel, 0 , -1 );
  5883. NotifySoldiersToLookforItems( );
  5884. }
  5885. EndItemPointer( );
  5886. }
  5887. }
  5888. typedef struct
  5889. {
  5890. OBJECTTYPE ItemPointerInfo;
  5891. UINT8 ubSoldierID;
  5892. UINT8 ubInvSlot;
  5893. BOOLEAN fCursorActive;
  5894. INT8 bPadding[5];
  5895. } ITEM_CURSOR_SAVE_INFO;
  5896. BOOLEAN LoadItemCursorFromSavedGame( HWFILE hFile )
  5897. {
  5898. UINT32 uiLoadSize=0;
  5899. UINT32 uiNumBytesRead=0;
  5900. ITEM_CURSOR_SAVE_INFO SaveStruct;
  5901. // Load structure
  5902. uiLoadSize = sizeof( ITEM_CURSOR_SAVE_INFO );
  5903. FileRead( hFile, &SaveStruct, uiLoadSize, &uiNumBytesRead );
  5904. if( uiNumBytesRead != uiLoadSize )
  5905. {
  5906. return( FALSE );
  5907. }
  5908. // Now set things up.....
  5909. // Copy object
  5910. memcpy( &gItemPointer, &(SaveStruct.ItemPointerInfo), sizeof( OBJECTTYPE ) );
  5911. // Copy soldier ID
  5912. if ( SaveStruct.ubSoldierID == NOBODY )
  5913. {
  5914. gpItemPointerSoldier = NULL;
  5915. }
  5916. else
  5917. {
  5918. gpItemPointerSoldier = MercPtrs[ SaveStruct.ubSoldierID ];
  5919. }
  5920. // Inv slot
  5921. gbItemPointerSrcSlot = SaveStruct.ubInvSlot;
  5922. // Boolean
  5923. if ( SaveStruct.fCursorActive )
  5924. {
  5925. gpItemPointer = &( gItemPointer );
  5926. ReEvaluateDisabledINVPanelButtons( );
  5927. }
  5928. else
  5929. {
  5930. gpItemPointer = NULL;
  5931. }
  5932. return( TRUE );
  5933. }
  5934. BOOLEAN SaveItemCursorToSavedGame( HWFILE hFile )
  5935. {
  5936. UINT32 uiSaveSize=0;
  5937. UINT32 uiNumBytesWritten=0;
  5938. ITEM_CURSOR_SAVE_INFO SaveStruct;
  5939. // Setup structure;
  5940. memset( &SaveStruct, 0, sizeof( ITEM_CURSOR_SAVE_INFO ) );
  5941. memcpy( &(SaveStruct.ItemPointerInfo), &gItemPointer, sizeof( OBJECTTYPE ) );
  5942. // Soldier
  5943. if ( gpItemPointerSoldier != NULL )
  5944. {
  5945. SaveStruct.ubSoldierID = gpItemPointerSoldier->ubID;
  5946. }
  5947. else
  5948. {
  5949. SaveStruct.ubSoldierID = NOBODY;
  5950. }
  5951. // INv slot
  5952. SaveStruct.ubInvSlot = gbItemPointerSrcSlot;
  5953. // Boolean
  5954. if ( gpItemPointer != NULL )
  5955. {
  5956. SaveStruct.fCursorActive = TRUE;
  5957. }
  5958. else
  5959. {
  5960. SaveStruct.fCursorActive = FALSE;
  5961. }
  5962. // save locations of watched points
  5963. uiSaveSize = sizeof( ITEM_CURSOR_SAVE_INFO );
  5964. FileWrite( hFile, &SaveStruct, uiSaveSize, &uiNumBytesWritten );
  5965. if( uiNumBytesWritten != uiSaveSize )
  5966. {
  5967. return( FALSE );
  5968. }
  5969. // All done...
  5970. return( TRUE );
  5971. }
  5972. void UpdateItemHatches()
  5973. {
  5974. SOLDIERTYPE *pSoldier = NULL;
  5975. if ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
  5976. {
  5977. if ( fShowInventoryFlag && bSelectedInfoChar >= 0 )
  5978. {
  5979. pSoldier = MercPtrs[ gCharactersList[ bSelectedInfoChar ].usSolID ];
  5980. }
  5981. }
  5982. else
  5983. {
  5984. pSoldier = gpSMCurrentMerc;
  5985. }
  5986. if ( pSoldier != NULL )
  5987. {
  5988. ReevaluateItemHatches( pSoldier, ( BOOLEAN ) ( gpItemPointer == NULL ) );
  5989. }
  5990. }