1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530 |
- //------------------------------------------------------------------------------------------------
- // 0.0.1
- //------------------------------------------------------------------------------------------------
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include "3d_all.h"
- #include "Berusky3d_kofola_interface.h"
- #include "game_logic.h"
- #include "menu_script.h"
- #include "Command.h"
- #include "3D_graphic.h"
- #include "2D_graphic.h"
- #include "Menu.h"
- #include "Comics.h"
- #include "credits.h"
- #include "font.h"
- #include "controls.h"
- #include "menu_def.h"
- #include "Setup.h"
- #include "profiles.h"
- #include "Apak.h"
- #include "3D_menus.h"
- #include "Demo.h"
- #include "load_level.h"
- #include "Menu.h"
- #include "Menu2.h"
- #include "menu_def.h"
- #include "Tools.h"
- #ifdef LINUX
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <time.h>
- #include <dirent.h>
- #include <fnmatch.h>
- #endif
- #define HDC2DD -1
- #define RES_NUM 200
- extern SETUP setup;
- extern _3D_CURSOR _3dCur;
- extern APAK_HANDLE *pBmpArchive;
- extern APAK_HANDLE *pDataArchive;
- extern PLAYER_PROFILE pPlayerProfile;
- extern HINT_TEXTURE pHintTexture[26];
- extern char cFontFile[5][64];
- extern int bWindowMenu;
- extern int iLanguageVersion;
- typedef struct __2D_HINT
- {
- int x;
- int y;
- int iSurface;
- int iBSurface;
- char bUsed;
- } _2D_HINT;
- typedef struct
- {
- CMD_LINE *cmd;
- int iWave;
- char bStop;
- } ANIMATION;
- extern _2D_DATA _2dd;
- extern HW_KONFIG hwconf;
- MOUSE_INFO dim;
- static ANIMATION anm[32];
- static DWORD timercnt = 0;
- static DWORD timercntframe = 0;
- static DWORD dwLTime;
- static char cRestartMainMenu;
- char cBrutalRestart = 0;
- int CompositDC;
- int FontDC;
- int BackDC;
- int iCompositDC, iFontDC, iBackDC;
- static char bBackDC = 0;
- int iActualScene = 0;
- int iActualLevel = 0;
- static char bNewScene = 0;
- static _2D_HINT _2d_hint;
- extern RECT_LINE rline;
- extern int gi_Change_Grafic_Mode(int xPels, int yPels, int Bits, int freq,
- DWORD dwflags);
- //extern int gi_EnumDisplaySettings(DEVMODE *pdevmode);
- extern int iMaxBpp;
- extern int iMaxFreq;
- char cCheckMusicExeption = 0;
- void RunMenuSceneMap(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu,
- char *cSceneBmp, char *cSceneAnim, int iScene, int iLevelStart,
- int iNumOfLevels, char *cLevelList, int xTV, int yTV, char bLoadGame,
- char *cSaveFile, char bTutorial, int xBack, int yBack);
- void RunMenuStartGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
- int cpu);
- int RunMenuComix(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int iScene);
- void DrawClock(int *iClock, int i);
- int FillComboProfiles(COMBO_CONTROL * p_co, int *iSel);
- int LoadClock(int *iClock);
- void RunMenuCibron(char *cBmp);
- CMD_LINE *GetCMD(CMD_LINE * cmp, CMD_LINE * pres)
- {
- int i;
- for (i = 0; i < RES_NUM; i++)
- if (!strcmp(cmp->cParam[1], pres[i].cParam[0]))
- return &pres[i];
- return NULL;
- }
- int CheckScenePresence(int iScene)
- {
- char t[256];
- sprintf(t, "scene%d", iScene);
- return GetPrivateProfileInt("Internet", t, 0, ini_file);
- }
- //------------------------------------------------------------------------------------------------
- // zastavi vsechny animace
- //------------------------------------------------------------------------------------------------
- void StopAll(void)
- {
- int i;
- for (i = 0; i < 32; i++)
- if (anm[i].cmd)
- anm[i].bStop = 1;
- }
- //------------------------------------------------------------------------------------------------
- // zastavi animaci
- //------------------------------------------------------------------------------------------------
- void Stop(CMD_LINE * cmd)
- {
- int i;
- if (cmd->iAnim[0][0] == -1)
- return;
- for (i = 0; i < 32; i++)
- if (cmd == anm[i].cmd) {
- if (cmd->bEndActivate[0] && cmd->pCmdLine) {
- cmd->pCmdLine[cmd->bEndActivate[0]].bActive = 1;
- cmd->bActive = 0;
- }
- if (cmd->bEndActivate[1] && cmd->pCmdLine) {
- cmd->pCmdLine[cmd->bEndActivate[1]].bActive = 1;
- cmd->bActive = 0;
- }
- anm[i].bStop = 1;
- return;
- }
- }
- int NextStep(CMD_LINE * cmd)
- {
- if ((rand() % 100) < 60)
- return cmd->iAnim[cmd->iLastfrm][11];
- else
- return cmd->iAnim[cmd->iLastfrm][11 +
- rand() % (cmd->iAnim[cmd->iLastfrm][17])];
- }
- void DrawFrame(CMD_LINE * cmd, AUDIO_DATA * p_ad)
- {
- if (cmd->iAnim[cmd->iLastfrm][10] == 2) {
- float p[3] = { 0, 0, 0 };
- //kprintf(1, "Play");
- // if(karmin_aktivni)
- // ap_Play_Sound(0, 1, 0, p, 147 + (rand()%2), NULL, p_ad);
- }
- if (!cmd->iLayer) {
- if (cmd->iAnim[cmd->iLastfrm][6] >= 0) {
- RECT r;
- ddxBitBlt(CompositDC,
- cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6],
- cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7],
- cmd->iAnim[cmd->iLastfrm][8], cmd->iAnim[cmd->iLastfrm][9],
- cmd->iAnim[cmd->iLastfrm][1],
- cmd->iAnim[cmd->iLastfrm][6], cmd->iAnim[cmd->iLastfrm][7]);
- r.left = cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6];
- r.top = cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7];
- r.right = cmd->iAnim[cmd->iLastfrm][8];
- r.bottom = cmd->iAnim[cmd->iLastfrm][9];
- ddxAddRectItem(&rline, r, 1);
- }
- else
- ddxDrawSurface(CompositDC, cmd->iAnim[cmd->iLastfrm], 1);
- }
- else if (cmd->iLayer == 10)
- ddxDrawSurfaceColorKey(CompositDC, cmd->iAnim[cmd->iLastfrm], 1,
- TRANSCOLOR);
- else
- ddxDrawSurface(FontDC, cmd->iAnim[cmd->iLastfrm], 3);
- }
- //------------------------------------------------------------------------------------------------
- // provede animaci
- //------------------------------------------------------------------------------------------------
- void Animation(CMD_LINE * cmd, int time, AUDIO_DATA * p_ad)
- {
- ANIMATION_DRAW:
- while (time > 0) {
- if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
- Stop(cmd);
- break;
- }
- time -= cmd->iAnim[cmd->iLastfrm][4];
- if (time > (cmd->iAnim[cmd->iAnim[cmd->iLastfrm][5]][4] / 2.0f)) {
- if (cmd->iAnim[cmd->iLastfrm][11] >= 0)
- cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);
- if (cmd->iAnim[cmd->iLastfrm][10] > 0)
- DrawFrame(cmd, p_ad);
- cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
- }
- }
- //----------------------------------------------------------------------
- DrawFrame(cmd, p_ad);
- if (!cmd->iAnim[cmd->iLastfrm][4]) {
- if (cmd->iAnim[cmd->iLastfrm][11] >= 0)
- cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);
- cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
- goto ANIMATION_DRAW;
- }
- if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
- Stop(cmd);
- return;
- }
- if (cmd->iAnim[cmd->iLastfrm][11] >= 0)
- cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);
- cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
- }
- int RectCross(RECT_LINE * p_rl, int idx)
- {
- int c = 0;
- int i;
- RECT *dr = &p_rl->rect[idx].rect;
- for (i = 0; i < rline.rlast; i++)
- if (i != idx)
- if (co_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->top) ||
- co_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->top) ||
- co_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->bottom) ||
- co_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->bottom))
- c++;
- return 0;
- }
- //------------------------------------------------------------------------------------------------
- // provede animace
- //------------------------------------------------------------------------------------------------
- void AnimationEvent(DWORD dwTime, AUDIO_DATA * p_ad)
- {
- DRAW_RECT *dr;
- int i;
- char bAnim = 0;
- DWORD e;
- e = abs(dwLTime - dwTime);
- for (i = 0; i < 32; i++)
- if (anm[i].cmd) {
- if (anm[i].bStop) {
- anm[i].cmd->iLastfrm = 1;
- anm[i].cmd->iCounter = 0;
- if (anm[i].iWave > -1) {
- //kprintf(1, "%d", anm[i].iWave);
- //adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, anm[i].iWave);
- }
- anm[i].iWave = -1;
- anm[i].cmd = NULL;
- }
- else {
- anm[i].cmd->iCounter += e;
- if (anm[i].cmd->iCounter >=
- anm[i].cmd->iAnim[anm[i].cmd->iLastfrm][4]) {
- Animation(anm[i].cmd, anm[i].cmd->iCounter, p_ad);
- anm[i].cmd->iCounter = 0;
- bAnim = 1;
- }
- }
- }
- //prenos kreslenych dat;
- if (bAnim || rline.rlast) {
- if (bBackDC) {
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddxTransparentBlt(BackDC, dr->rect.left, dr->rect.top, dr->rect.right,
- dr->rect.bottom, FontDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, TRANSCOLOR);
- }
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddxTransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, BackDC, dr->rect.left,
- dr->rect.top, dr->rect.right, dr->rect.bottom, TRANSCOLOR);
- }
- }
- else {
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddxTransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, FontDC, dr->rect.left,
- dr->rect.top, dr->rect.right, dr->rect.bottom, TRANSCOLOR);
- }
- }
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddxTransparentBltDisplay(dr->rect.left, dr->rect.top, dr->rect.right,
- dr->rect.bottom, CompositDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, TRANSCOLOR);
- }
- ddxUpdateMouse();
- DisplayFrame();
- bAnim = 1;
- }
- timercntframe += e;
- if(!bAnim && (dim.dx || dim.dy) && timercntframe > 9)
- {
- timercntframe = 0;
- DisplayFrame();
- }
- dwLTime = dwTime;
- timercnt += e;
- _2d_Clear_RectLine(&rline);
- }
- void InitRandomJumps(CMD_LINE * cmd)
- {
- int i;
- for (i = 0; i < 200; i++)
- if (cmd->iAnim[i][11] >= 0)
- cmd->iAnim[i][5] = cmd->iAnim[i][11 + rand() % (cmd->iAnim[i][17])];
- }
- int FindAnimation(CMD_LINE * cmd)
- {
- int i;
- for (i = 0; i < 32; i++)
- if (anm[i].cmd == cmd)
- return 1;
- return 0;
- }
- //------------------------------------------------------------------------------------------------
- // prida animaci
- //------------------------------------------------------------------------------------------------
- int AddAnimation(CMD_LINE * cmd, AUDIO_DATA * p_ad, char bOnlyOnes,
- char bButton)
- {
- int i, r;
- float pos[3] = { 0.0f, 0.0f, 1.0f };
- if (!bButton && bWindowMenu)
- return -1;
- if (cmd->iAnim[0][0] == -1)
- return -1;
- for (i = 0; i < 32; i++)
- if (!anm[i].cmd) {
- if (bOnlyOnes && FindAnimation(cmd))
- return -1;
- InitRandomJumps(cmd);
- anm[i].cmd = cmd;
- anm[i].bStop = 0;
- anm[i].iWave = -1;
- Animation(anm[i].cmd, 0, p_ad);
- if (cmd->iParam[0] == COM_RANDOMANIMATION) {
- r = rand() % 3;
- if (cmd->iParam[r + 2] < 0) {
- if (cmd->iParam[2] >= 0) {
- // adas_Get_Listener_Position(pos);
- // if(karmin_aktivni)
- // ap_Play_Sound(0,1,0,pos,cmd->iParam[2], NULL, p_ad);
- }
- }
- else {
- // adas_Get_Listener_Position(pos);
- //if(karmin_aktivni)
- //ap_Play_Sound(0,1,0,pos,cmd->iParam[r+2], NULL, p_ad);
- }
- }
- return i;
- }
- else if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0]) && !anm[i].bStop)
- return -1;
- return -1;
- }
- int ChooseBidedExitAnimation(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
- {
- int id[RES_NUM];
- int i, c = 0;
- for (i = Index; i < RES_NUM; i++)
- if (cmd[i].iParam[0] == COM_BINDEXITANIMATION) {
- id[c] = i;
- c++;
- if (c > RES_NUM - 1)
- break;
- }
- else if (cmd[i].iParam[0] != COM_BINDANIMATION)
- break;
- if (c)
- return id[rand() % c];
- else
- return -1;
- }
- int ChooseBidedAnimation(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
- {
- int id[RES_NUM];
- int i, c = 0;
- for (i = Index; i < RES_NUM; i++)
- if (cmd[i].iParam[0] == COM_BINDANIMATION) {
- id[c] = i;
- c++;
- if (c > RES_NUM - 1)
- break;
- }
- else if (cmd[i].iParam[0] != COM_BINDEXITANIMATION)
- break;
- if (c)
- return id[rand() % c];
- else
- return -1;
- }
- void ZeroAnimations(void)
- {
- int i;
- for (i = 0; i < 32; i++) {
- anm[i].bStop = 0;
- anm[i].iWave = -1;
- anm[i].cmd = NULL;
- }
- }
- void FreeAnimations(CMD_LINE * cmd, int csize)
- {
- int i, j;
- for (i = 0; i < csize; i++)
- for (j = 0; j < 32; j++)
- if (anm[j].cmd)
- if (anm[j].cmd == &cmd[i]) {
- anm[j].cmd->iLastfrm = 1;
- anm[j].cmd->iCounter = 0;
- anm[j].iWave = -1;
- anm[j].cmd = NULL;
- }
- }
- //------------------------------------------------------------------------------------------------
- // prida animaci
- //------------------------------------------------------------------------------------------------
- void CheckAnimation(CMD_LINE * cmd, AUDIO_DATA * p_ad)
- {
- int i;
- float pos[3] = { 0.0f, 0.0f, 1.0f };
- for (i = 0; i < 32; i++)
- if (anm[i].cmd)
- if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0])) {
- Stop(anm[i].cmd);
- /*if(!cmd->iLayer)
- {
- //menucommand_Draw(_2dd.hDC, anm[i].cmd->iAnim[0] , 0);
- ddxDrawDisplay(anm[i].cmd->iAnim[0] , 0);
- }
- else
- {
- //menucommand_DrawT(_2dd.hDC, anm[i].cmd->iAnim[0]);
- ddxDrawDisplayColorKey(anm[i].cmd->iAnim[0], 0, TRANSCOLOR);
- //menucommand_Draw(FontDC, anm[i].cmd->iAnim[0], 3);
- ddxDrawSurface(FontDC, anm[i].cmd->iAnim[0], 3);
- } */
- return;
- }
- }
- void StretchAnimation(RECT * rStart, RECT * rFinish, int iSurface, int iSpeed,
- AUDIO_DATA * p_ad)
- {
- DWORD dwS, dwF, dwE;
- char done = 0;
- int max = 0;
- int i;
- int p[4]; //{left, top, right, bottom}
- float s[4];
- RECT rBmp;
- RECT rDraw;
- p[0] = rFinish->left - rStart->left;
- p[1] = rFinish->top - rStart->top;
- p[2] = rFinish->right - rStart->right;
- p[3] = rFinish->bottom - rStart->bottom;
- for (i = 0; i < 4; i++)
- if (abs(p[i]) > max)
- max = abs(p[i]);
- for (i = 0; i < 4; i++)
- s[i] = p[i] / (float) max;
- StopAll();
- rBmp.left = 0;
- rBmp.top = 0;
- rBmp.right = ddxGetWidth(iSurface);
- rBmp.bottom = ddxGetHight(iSurface);
- memcpy(&rDraw, rStart, sizeof(RECT));
- dwS = timeGetTime();
- while (!done) {
- ddxStretchBltDisplay(&rDraw, iSurface, &rBmp);
- DisplayFrame();
- dwF = timeGetTime();
- dwE = dwF - dwS;
- rDraw.left = rStart->left + ftoi((s[0] * dwE) / (float) iSpeed);
- rDraw.top = rStart->top + ftoi((s[1] * dwE) / (float) iSpeed);
- rDraw.right = rStart->right + ftoi((s[2] * dwE) / (float) iSpeed);
- rDraw.bottom = rStart->bottom + ftoi((s[3] * dwE) / (float) iSpeed);
- //kprintf(1, "rDraw.left, rFinish->left: [%d, %d]", rDraw.left, rFinish->left);
- if (rDraw.left <= rFinish->left && p[0]) {
- rDraw.left = rFinish->left;
- done = 1;
- }
- //kprintf(1, "rDraw.top, rFinish->top: [%d, %d]", rDraw.top, rFinish->top);
- if (rDraw.top <= rFinish->top && p[1]) {
- rDraw.top = rFinish->top;
- done = 1;
- }
- //kprintf(1, "rDraw.right, rFinish->right: [%d, %d]", rDraw.right, rFinish->right);
- if (rDraw.right >= rFinish->right && p[2]) {
- rDraw.right = rFinish->right;
- done = 1;
- }
- //kprintf(1, "rDraw.bottom, rFinish->bottom: [%d, %d]", rDraw.bottom, rFinish->bottom);
- if (rDraw.bottom >= rFinish->bottom && p[3]) {
- rDraw.bottom = rFinish->bottom;
- done = 1;
- }
- spracuj_spravy(0);
- ddxUpdateMouse();
- /*if(rDraw.left <= rFinish->left &&
- rDraw.top <= rFinish->top &&
- rDraw.bottom >= rFinish->bottom &&
- rDraw.right >= rFinish->right)
- done = 1; */
- if (ddxRestore(p_ad))
- return;
- }
- ddxStretchBltDisplay(rFinish, iSurface, &rBmp);
- DisplayFrame();
- ddxStretchBltDisplay(rFinish, iSurface, &rBmp);
- }
- //------------------------------------------------------------------------------------------------
- // spusti nahodny zvuk podle zadani
- //------------------------------------------------------------------------------------------------
- int mPlaySound(CMD_LINE * cmd, AUDIO_DATA * p_ad, int type)
- {
- float pos[3] = { 0.0f, 0.0f, 1.0f };
- int r = rand() % 4, ret = -1;
- if (cmd->iParam[r + 1] < 0) {
- if (cmd->iParam[1] >= 0) {
- //adas_Get_Listener_Position(pos);
- //if(karmin_aktivni)
- //ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[1], NULL, p_ad);
- }
- }
- else {
- // adas_Get_Listener_Position(pos);
- //if(karmin_aktivni)
- //ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[r+1], NULL, p_ad);
- }
- return ret;
- }
- void GetSceneParam(int iScene, int *iStartLevel, int *iNumOfLevels)
- {
- switch (iScene) {
- case 1:
- *iStartLevel = 0;
- *iNumOfLevels = 11;
- return;
- case 2:
- *iStartLevel = 11;
- *iNumOfLevels = 10;
- return;
- case 3:
- *iStartLevel = 21;
- *iNumOfLevels = 12;
- return;
- case 4:
- *iStartLevel = 33;
- *iNumOfLevels = 10;
- return;
- case 5:
- *iStartLevel = 43;
- *iNumOfLevels = 10;
- return;
- case 6:
- *iStartLevel = 53;
- *iNumOfLevels = 10;
- return;
- case 7:
- *iStartLevel = 63;
- *iNumOfLevels = 10;
- return;
- case 8:
- *iStartLevel = 73;
- *iNumOfLevels = 12;
- return;
- case 9:
- *iStartLevel = 85;
- *iNumOfLevels = 10;
- return;
- }
- }
- int SceneDone(void)
- {
- int i;
- int iStartLevel = 0;
- int iNumOfLevels = 0;
- GetSceneParam(iActualScene, &iStartLevel, &iNumOfLevels);
- for (i = iStartLevel; i < iStartLevel + iNumOfLevels; i++)
- if (!pPlayerProfile.cLevel[i])
- return 0;
- return 1;
- }
- //------------------------------------------------------------------------------------------------
- // spusti level
- //------------------------------------------------------------------------------------------------
- int RunLevel(HWND hWnd, AUDIO_DATA * p_ad, int cpu, char *lvl, char *env)
- {
- int ret;
- unsigned int Timer_ID;
- char cenv[64];
- float f = 0; //p_ad->Music_Gain;
- strcpy(cenv, env);
- /*
- if(ogg_playing())
- {
- while(f >= 0.05f)
- {
- f -= 0.05f;
- ogg_gain(f);
- Sleep(25);
- }
- ap_Stop_Song(p_ad);
- }
- */
- // Sleep(1000);
- ddxRelease();
- FreeDirectDraw();
- ShowCursor(FALSE);
- if (kom_graf_init()) {
- RunMenuLoadScreen2();
- RunMenuLoadScreenInitBar(15);
- RunMenuLoadScreenAddProgress(-1);
- RunMenuLoadScreenDrawProgress(-1, -1);
- _3d_Init();
- _3d_Load_List("3D_load.dat");
- _3d_Gen_Hints(pHintTexture, 26);
- RunMenuLoadScreenAddProgress(-1);
- _3d_Load_Indikace();
- Timer_ID = SetTimer(NULL, 0, 250, (TIMERPROC) gl_Set_Frame_Rate);
- /*
- adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
- adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
- */
- ret = gl_Run_Level(lvl, cenv, NULL, cpu);
- if (ret == 1)
- pPlayerProfile.cLevel[iActualLevel] = 1;
- else if (ret == -1)
- RunMenuLoadScreenRelease(3);
- kprintf(1, "KillTimer");
- KillTimer(NULL, Timer_ID);
- kprintf(1, "_3d_Release_Hints");
- _3d_Release_Hints(pHintTexture, 26);
- kprintf(1, "_3d_Release");
- _3d_Release();
- kprintf(1, "kom_graf_konec");
- kom_graf_konec(!bWindowMenu);
- spracuj_spravy(0);
- //maximalizuj_okno(NULL);
- ShowCursor(TRUE);
- spracuj_spravy(0);
- }
- else {
- //----------------------- MessageBox ......
- kprintf(1, "kom_graf_init - nepodarilo se nahodit");
- MyMessageBox(NULL, "##error_title", "##kom_graf_init_error", "");
- spracuj_spravy(0);
- //maximalizuj_okno(NULL);
- ShowCursor(TRUE);
- spracuj_spravy(0);
- }
- kprintf(1, "ddxInit");
- ddxInit();
- spracuj_spravy(0);
- kprintf(1, "InitDirectDraw");
- InitDirectDraw(NULL, 1024, 768, GetPrivateProfileInt("hra", "menu_bpp", 16,
- ini_file));
- spracuj_spravy(0);
- kprintf(1, "ddxLoadList");
- ddxLoadList("2d_load.dat", 0);
- spracuj_spravy(0);
- kprintf(1, "ddxFindFreeSurface");
- iCompositDC = ddxFindFreeSurface();
- kprintf(1, "ddxCreateSurface");
- CompositDC = ddxCreateSurface(1024, 768, iCompositDC);
- kprintf(1, "ddxFindFreeSurface");
- iFontDC = ddxFindFreeSurface();
- kprintf(1, "ddxCreateSurface");
- FontDC = ddxCreateSurface(1024, 768, iFontDC);
- kprintf(1, "ddxFindFreeSurface");
- iBackDC = ddxFindFreeSurface();
- kprintf(1, "ddxCreateSurface");
- BackDC = ddxCreateSurface(1024, 768, iBackDC);
- spracuj_spravy(0);
- ZeroAnimations();
- bNewScene = 0;
- #ifndef __DEMO
- //pokud se jedna o herni scenu
- if (iActualScene > 0 && iActualScene < 10)
- if (SceneDone() && !pPlayerProfile.cMovie[iActualScene]) {
- PLAYER_PROFILE pProfile;
- pPlayerProfile.cMovie[iActualScene] = 1;
- pr_SaveProfile(&pPlayerProfile);
- if (iActualScene < 9) {
- memcpy(&pProfile, &pPlayerProfile, sizeof(PLAYER_PROFILE));
- pProfile.cScene[iActualScene + 1] = 1;
- pr_SaveProfile(&pProfile);
- }
- //ogg_gain(p_ad->Music_Gain);
- RunMenuComix("menu_comix.txt", NULL, p_ad, iActualScene);
- if (iActualScene < 9)
- bNewScene = 1;
- if (iActualScene == 9) {
- cr_Credits(NULL, p_ad);
- cRestartMainMenu = 1;
- bNewScene = 1;
- iActualScene = 0;
- }
- }
- else {
- //ap_Play_Song(0,0,p_ad);
- //adas_OGG_Set_Priority(cpu);
- }
- else {
- //ap_Play_Song(0,0,p_ad);
- //adas_OGG_Set_Priority(cpu);
- }
- #endif
- #ifdef __DEMO
- //ap_Play_Song(0,0,p_ad);
- #endif
- cBrutalRestart = 1;
- return ret;
- }
- //------------------------------------------------------------------------------------------------
- // spusti credity
- //------------------------------------------------------------------------------------------------
- void Credits(HWND hWnd, AUDIO_DATA * p_ad, int cpu)
- {
- char dir[256];
- StopAll();
- /*
- if(ogg_playing())
- ap_Stop_Song(p_ad);
- */
- SetCursor(NULL);
- _2d_Release();
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- cr_Credits(NULL, p_ad);
- _2d_Init();
- _2d_APAK_Load_List("2d_load.dat");
- //ap_Play_Song(0,0,p_ad);
- //adas_OGG_Set_Priority(cpu);
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //SetCursor(LoadCursor(NULL, IDC_ARROW));
- spracuj_spravy(0);
- ShowCursor(TRUE);
- spracuj_spravy(0);
- }
- void CreateFontAnimations(CMD_LINE * res, int *lastcmd)
- {
- int lcmd = *lastcmd;
- char text[256];
- RECT r = { 0, 0, 0, 0 };
- int i;
- int sidx1, sidx2;
- int y;
- for (i = 0; i < lcmd; i++)
- if (res[i].iParam[0] == COM_SETRECT) {
- r.left = res[i].iParam[1];
- r.top = res[i].iParam[2];
- r.right = res[i].iParam[3];
- r.bottom = res[i].iParam[4];
- }
- y = r.top;
- for (i = 0; i < lcmd; i++)
- if (res[i].iParam[0] == COM_CREATEBUTTON)
- if (fn_Gen_Menu_Text(0, HDC2DD, res[i].cParam[0], &sidx1, &sidx2) != -1)
- if (sidx1 != -1 && sidx2 != -1) {
- int ii;
- int oy = res[i].iParam[2];
- //int x = r.left + ftoi((r.right - r.left - _2dd.bitmap[sidx1].bitmap.bmWidth) / (float)2.0f);
- int x =
- r.left + ftoi((r.right - r.left -
- ddxGetWidth(sidx1)) / (float) 2.0f);
- if (res[i].iParam[1] != -1) {
- oy = res[i].iParam[2];
- y = oy;
- x = res[i].iParam[1];
- }
- else {
- oy = res[i].iParam[2];
- y = oy;
- }
- y += ddxGetHight(sidx1);
- //OnAbove(16,661,100,748, quit_game.txt, NO_EXEPTION)
- sprintf(text, "OnAbove(%d,%d,%d,%d, NO_EXEPTION, NO_EXEPTION)", x,
- oy, x + ddxGetWidth(sidx1), y);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].uiTimerID = 0;
- res[*lastcmd].iLastfrm = 1;
- res[*lastcmd].iCounter = 0;
- /*
- (0, 123, 0, 640, 0, 1)
- (1, 124, 0, 640, 25, 2)
- (2, 124, 0, 640, 25, -1)
- */
- res[*lastcmd].iAnim[0][0] = 0;
- res[*lastcmd].iAnim[0][1] = sidx1;
- res[*lastcmd].iAnim[0][2] = x;
- res[*lastcmd].iAnim[0][3] = oy;
- res[*lastcmd].iAnim[0][4] = 0;
- res[*lastcmd].iAnim[0][5] = 1;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[0][ii] = -1;
- x =
- r.left + ftoi((r.right - r.left -
- ddxGetWidth(sidx2)) / (float) 2.0f);
- if (res[i].iParam[1] != -1)
- x = res[i].iParam[1];
- res[*lastcmd].iAnim[1][0] = 1;
- res[*lastcmd].iAnim[1][1] = sidx2;
- res[*lastcmd].iAnim[1][2] = x;
- res[*lastcmd].iAnim[1][3] = oy;
- res[*lastcmd].iAnim[1][4] = 50;
- res[*lastcmd].iAnim[1][5] = 2;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[1][ii] = -1;
- res[*lastcmd].iAnim[2][0] = 2;
- res[*lastcmd].iAnim[2][1] = sidx2;
- res[*lastcmd].iAnim[2][2] = x;
- res[*lastcmd].iAnim[2][3] = oy;
- res[*lastcmd].iAnim[2][4] = 50;
- res[*lastcmd].iAnim[2][5] = -1;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[2][ii] = -1;
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //Draw(1,0,0)
- sprintf(text, "Draw(%d,%d,%d)", sidx1, x, oy);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //OnClick(16,661,100,748, quit_gamec.txt, EXIT)
- sprintf(text, "OnClick(%d,%d,%d,%d, NO_EXEPTION, %s)", x, oy,
- x + ddxGetWidth(sidx1), y, res[i].cParam[1]);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //BindSound(54,55,56,-1)
- strcpy(text, "BindSound(54,55,56,-1)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 0;
- (*lastcmd)++;
- }
- }
- void SetTab(int iTab, int iLTab, CONTROL_LIST_ITEM * p_list, int lsize,
- int *hdcTab)
- {
- int i;
- if (iLTab > -1) {
- //BitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, _2dd.hDC, TAB_X, TAB_Y, SRCCOPY);
- ddxBitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, HDC2DD, TAB_X, TAB_Y);
- }
- for (i = 0; i < lsize; i++)
- if ((p_list + i)->iTab == iTab && !(p_list + i)->bDisabled)
- (p_list + i)->bActive = 1;
- else if ((p_list + i)->iTab != -1)
- (p_list + i)->bActive = 0;
- //BitBlt(_2dd.hDC, TAB_X, TAB_Y, TAB_XRES, TAB_YRES, hdcTab[iTab], 0, 0, SRCCOPY);
- ddxBitBltDisplay(TAB_X, TAB_Y, TAB_XRES, TAB_YRES, hdcTab[iTab], 0, 0);
- DisplayFrame();
- }
- int CheckRozliseni(ROZLISENI * res, int roz_size, DWORD x, DWORD y, DWORD bpp)
- {
- int i;
- for (i = 0; i < roz_size; i++)
- if (res[i].x == x && res[i].y == y && res[i].bpp == bpp)
- return 1;
- return 0;
- }
- void EnumRozliseni(ROZLISENI ** res, int *roz_size)
- {
- /*
- int i=0 , j=0;
- DEVMODE dmSettings;
-
- memset(&dmSettings,0,sizeof(dmSettings));
- dmSettings.dmSize = sizeof(DEVMODE);
- kprintf(1, "Detekce rozliseni ---------------------------------------------------- ");
- while(EnumDisplaySettings(NULL,i,&dmSettings))
- {
- kprintf(1, "%d x %d x %d [%dHz]", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel, dmSettings.dmDisplayFrequency);
- memset(&dmSettings,0,sizeof(dmSettings));
- dmSettings.dmSize = sizeof(DEVMODE);
- i++;
- }
- (*roz_size) = i;
- kprintf(1, "Pocet rozliseni = %d", i);
- (*res) = malloc((*roz_size) * sizeof(ROZLISENI));
- memset((*res), 0, (*roz_size) * sizeof(ROZLISENI));
- j = 0;
- i = 0;
- while(EnumDisplaySettings(NULL,i,&dmSettings))
- {
- if(dmSettings.dmBitsPerPel > 8 && dmSettings.dmPelsWidth > 600)
- {
- if(CheckRozliseni((*res), j, dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel))
- {
- kprintf(1, "Skip (%d x %d x %d)", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel);
- goto NEXT_ENUM;
- }
- */
- /*if(j > 0)
- if((*res)[j-1].bpp == dmSettings.dmBitsPerPel &&
- (*res)[j-1].x == dmSettings.dmPelsWidth &&
- (*res)[j-1].y == dmSettings.dmPelsHeight)
- {
- kprintf(1, "Skip (%d x %d x %d)", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel);
- goto NEXT_ENUM;
- } */
- /*
- (*res)[j].bpp = dmSettings.dmBitsPerPel;
- (*res)[j].x = dmSettings.dmPelsWidth;
- (*res)[j].y = dmSettings.dmPelsHeight;
- (*res)[j].freq = dmSettings.dmDisplayFrequency;
- j++;
- kprintf(1, "ComboAddItem (%d x %d x %d)", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel);
- if(j >= (*roz_size))
- break;
- }
- NEXT_ENUM:
- memset(&dmSettings,0,sizeof(dmSettings));
- dmSettings.dmSize = sizeof(DEVMODE);
- i++;
- }
- */
- }
- void Key2String(int k, char *text)
- {
- sprintf(text, "##control_k_%d", k);
- return;
- }
- void CharMenuCheckMultyKyes(LIST_VIEW_CONTROL * p_li, int iKey)
- {
- int y;
- int i;
- RECT r;
- for (i = 0; i < p_li->listnum; i++)
- if (i != p_li->cSelected && p_li->piValue[i].iValue == iKey) {
- y = i * 30;
- r.left = 550;
- r.top = y + 2;
- r.right = r.left + (ddxGetWidth(p_li->bDCn) - 550);
- r.bottom = r.top + 28;
- ddxFillRect(p_li->bDCn, &r, 0);
- ddxFillRect(p_li->bDCs, &r, 0);
- co_List_Add_String(p_li, i, 550, "##control_k_255", 255, 0);
- }
- }
- void SetCharMenu(LIST_VIEW_CONTROL * p_li)
- {
- char text[128];
- int y = p_li->cSelected * 30;
- int xs = p_li->rectList.top + TAB_Y + y - p_li->dx;
- int xp = 0;
- int xt = 0;
- int i;
- int iCursor = 0;
- RECT r;
- if (!p_li->cSelected || p_li->cSelected == 11 || p_li->cSelected == 19)
- return;
- r.left = 550;
- r.top = y + 2;
- r.right = r.left + (ddxGetWidth(p_li->bDCn) - 550);
- r.bottom = r.top + 28;
- ddxFillRect(p_li->bDCn, &r, 0);
- ddxFillRect(p_li->bDCs, &r, 0);
- if (y - p_li->dx < 0)
- xp = (y - p_li->dx) * -1;
- if ((p_li->rectList.top + TAB_Y + y - p_li->dx + 30) >
- p_li->rectList.bottom + TAB_Y)
- xt =
- (p_li->rectList.top + TAB_Y + y - p_li->dx + 30) -
- (p_li->rectList.bottom + TAB_Y);
- ddxBitBlt(HDC2DD, p_li->rectList.left + TAB_X,
- p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddxGetWidth(p_li->bDCs),
- 30 - xp - xt, p_li->bDCs, 0, y + xp);
- r.top = p_li->rectList.top + TAB_Y + y - p_li->dx + xp - 2;
- r.left = 665;
- r.right = r.left + 220;
- r.bottom = r.top + 27;
- DisplayFrame();
- while (!key[0]) {
- Sleep(10);
- spracuj_spravy(0);
- ddxUpdateMouse();
- if (key[K_F1] || key[K_F2] || key[K_F3] || key[K_F10] || key[K_PLUS]
- || key[K_MINUS]) {
- key[0] = 0;
- key[K_F1] = 0;
- key[K_F2] = 0;
- key[K_F3] = 0;
- key[K_F10] = 0;
- key[K_PLUS] = 0;
- key[K_MINUS] = 0;
- }
- if (iCursor < 100)
- ddxFillRectDisplay(&r, RGB(63, 122, 163));
- else if (iCursor > 99 && iCursor < 200)
- ddxFillRectDisplay(&r, 0);
- else {
- iCursor = 0;
- ddxFillRectDisplay(&r, 0);
- }
- iCursor += 4;
- //if(dim.dx || dim.dy)
- DisplayFrame();
- }
- key[0] = 0;
- for (i = 0; i < POCET_KLAVES; i++)
- if (key[i]) {
- sprintf(text, "##control_k_%d", i);
- key[i] = 0;
- break;
- }
- co_List_Add_String(p_li, p_li->cSelected, 550, text, i, 0);
- CharMenuCheckMultyKyes(p_li, i);
- ddxBitBlt(HDC2DD, p_li->rectList.left + TAB_X, p_li->rectList.top + TAB_Y,
- ddxGetWidth(p_li->bDCn), p_li->rectList.bottom - p_li->rectList.top,
- p_li->bDCn, 0, p_li->dx);
- ddxBitBlt(HDC2DD, p_li->rectList.left + TAB_X,
- p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddxGetWidth(p_li->bDCs),
- 30 - xp - xt, p_li->bDCs, 0, y + xp);
- DisplayFrame();
- }
- void SetMenuSettings(ROZLISENI * roz, CONTROL_LIST_ITEM * citem,
- int *hdcTabUse)
- {
- float f;
- int i;
- if (hdcTabUse[0]) {
- //setup.pohled_berusky = co_Check_Get_State(citem, CLIST_ITEMC, 0);
- setup.posouvat_kameru = co_Check_Get_State(citem, CLIST_ITEMC, 1);
- setup.ovladani = co_Check_Get_State(citem, CLIST_ITEMC, 2);
- //setup.menu_vram_load = co_Check_Get_State(citem, CLIST_ITEMC, 3);
- setup.start_zpruhlednovani = co_Check_Get_State(citem, CLIST_ITEMC, 10);
- setup.start_zvyraznovani = co_Check_Get_State(citem, CLIST_ITEMC, 11);
- setup.ovladani_rohy = co_Check_Get_State(citem, CLIST_ITEMC, 12);
- setup.camera_intro = co_Check_Get_State(citem, CLIST_ITEMC, 16);
- i = co_Check_Get_State(citem, CLIST_ITEMC, 13);
- if (i)
- setup.ovladani_rohy_default = 0;
- else
- setup.ovladani_rohy_default = 1;
- setup.ovladani_rohy_smer = co_Check_Get_State(citem, CLIST_ITEMC, 15);
- //setup.ovladani_pr_posun = co_Check_Get_State(citem, CLIST_ITEMC, 16);
- setup.ovladani_rohy_rychlost =
- co_Progres_Get(citem, CLIST_ITEMC, 0) / 10.0f;
- setup.p_kamera_radius = co_Progres_Get(citem, CLIST_ITEMC, 1) / 2.0f;
- }
- if (hdcTabUse[1]) {
- i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 0);
- setup.xres = roz[i].x;
- setup.yres = roz[i].y;
- setup.bpp = (char) roz[i].bpp;
- setup.general_3d = co_Combo_Get_Sel(citem, CLIST_ITEMC, 1);
- i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 2);
- if (!i)
- setup.extra_light_vertex = 1;
- else
- setup.extra_light_vertex = 0;
- setup.kvalita_casticv = co_Combo_Get_Sel(citem, CLIST_ITEMC, 5);
- i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 6);
- if (i == 3)
- setup.light_dyn = 0;
- else {
- setup.light_dyn = 1;
- setup.light_rychlost = i + 1;
- }
- setup.text_detail2 = co_Combo_Get_Sel(citem, CLIST_ITEMC, 3);
- setup.text_detail3 = co_Combo_Get_Sel(citem, CLIST_ITEMC, 4);
- i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 7);
- switch (i) {
- case 2:
- setup.bump_mapping = 0;
- break;
- case 1:
- setup.bump_mapping = 1;
- setup.text_bump2 = 1;
- setup.text_bump3 = 0;
- break;
- case 0:
- setup.bump_mapping = 1;
- setup.text_bump2 = 1;
- setup.text_bump3 = 1;
- break;
- }
- setup.text_mip_mapping = co_Combo_Get_Sel(citem, CLIST_ITEMC, 8);
- i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 9);
- if (!i)
- setup.text_bpp = 32;
- else
- setup.text_bpp = 16;
- i = co_Combo_Drop_Get_Sel(citem, CLIST_ITEMC, 0, &f);
- if (!i)
- setup.text_ans = 0;
- else {
- setup.text_ans = 1;
- setup.text_ans_stupen = i;
- }
- setup.text_kvalita = co_Combo_Get_Sel(citem, CLIST_ITEMC, 10);
- setup.text_komprese = co_Check_Get_State(citem, CLIST_ITEMC, 6);
- setup.ditering = co_Check_Get_State(citem, CLIST_ITEMC, 7);
- setup.zrcado_aktivni = co_Check_Get_State(citem, CLIST_ITEMC, 4);
- setup.scene_materialy = co_Check_Get_State(citem, CLIST_ITEMC, 8);
- setup.vertex_arrays = co_Check_Get_State(citem, CLIST_ITEMC, 9);
- setup.menu_vram_load = co_Check_Get_State(citem, CLIST_ITEMC, 10);
- co_Combo_Drop_Get_Sel(citem, CLIST_ITEMC, 10, &setup.text_ostrost);
- }
- if (hdcTabUse[2]) {
- setup.soundvolume = co_Progres_Get(citem, CLIST_ITEMC, 4);
- setup.ambientvolume = co_Progres_Get(citem, CLIST_ITEMC, 5);
- setup.musicvolume = co_Progres_Get(citem, CLIST_ITEMC, 6);
- }
- if (hdcTabUse[3]) {
- setup.key[1] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 1);
- setup.key[2] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 2);
- setup.key[3] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 3);
- setup.key[4] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 4);
- setup.key[5] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 5);
- setup.key[6] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 6);
- setup.key[7] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 7);
- setup.key[8] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 8);
- setup.key[9] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 9);
- setup.key[10] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 10);
- setup.key[12] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 12);
- setup.key[13] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 13);
- setup.key[14] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 14);
- setup.key[15] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 15);
- setup.key[16] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 16);
- setup.key[17] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 17);
- setup.key[18] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 18);
- setup.key[20] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 20);
- setup.key[21] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 21);
- setup.key[22] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 22);
- setup.key[23] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 23);
- setup.key[24] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 24);
- setup.key[25] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 25);
- setup.key[26] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 26);
- setup.key[27] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 27);
- setup.key[28] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 28);
- setup.key[29] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 29);
- setup.key[30] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 30);
- }
- }
- void SetMenuSettingsS(ROZLISENI * roz, CONTROL_LIST_ITEM * citem,
- int *hdcTabUse)
- {
- if (hdcTabUse[2]) {
- setup.soundvolume = co_Progres_Get(citem, CLIST_ITEMC, 4);
- setup.ambientvolume = co_Progres_Get(citem, CLIST_ITEMC, 5);
- setup.musicvolume = co_Progres_Get(citem, CLIST_ITEMC, 6);
- }
- }
- void InitTab3d(CONTROL_LIST_ITEM * citem, int *hdcTab, ROZLISENI * roz,
- int roz_size)
- {
- int i;
- int count = 0;
- int iClock;
- iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
- ddxResizeCursorBack(iClock);
- DrawClock(&iClock, 0);
- co_Set_Text_Right(hdcTab[1], "##settings_resolution", 0, 285, 57);
- citem[8].p_combo = co_Create_Combo(hdcTab[1], 300, 50, 450, 0);
- citem[8].iTab = 1;
- for (i = 0; i < roz_size; i++) {
- if (roz[i].bpp > 0) {
- char text[256];
- sprintf(text, "%dx%dx%d", roz[i].x, roz[i].y, roz[i].bpp);
- co_Combo_Add_String(citem[8].p_combo, text);
- count++;
- }
- }
- if (count > 10)
- co_Combo_Set_Params(citem[8].p_combo, 10);
- else
- co_Combo_Set_Params(citem[8].p_combo, count);
- co_Combo_Set_Sel(hdcTab[1], citem[8].p_combo, GetResCombobox(roz,
- roz_size));
- //////////////////////////////##settings_gemeral_3d
- co_Set_Text_Right(hdcTab[1], "##settings_gemeral_3d", 0, 285, 97);
- citem[9].p_combo = co_Create_Combo(hdcTab[1], 300, 90, 100, 1);
- citem[9].iTab = 1;
- co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_high");
- co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_normal");
- co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_low");
- co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_elow");
- co_Combo_Set_Params(citem[9].p_combo, 4);
- co_Combo_Set_Sel(hdcTab[1], citem[9].p_combo, setup.general_3d);
- /////////////////////////////////##settings_model
- co_Set_Text_Right(hdcTab[1], "##settings_model", 0, 285, 137);
- citem[33].p_combo = co_Create_Combo(hdcTab[1], 300, 130, 100, 2);
- citem[33].iTab = 1;
- co_Combo_Add_StringWC(citem[33].p_combo, "##settings_gemeral_3d_high");
- co_Combo_Add_StringWC(citem[33].p_combo, "##settings_gemeral_3d_normal");
- co_Combo_Set_Params(citem[33].p_combo, 2);
- if (!setup.extra_light_vertex)
- co_Combo_Set_Sel(hdcTab[1], citem[33].p_combo, 1);
- else
- co_Combo_Set_Sel(hdcTab[1], citem[33].p_combo, 0);
- co_Set_Text_Right(hdcTab[1], "##settings_partices_weather", 0, 285, 177);
- citem[10].p_combo = co_Create_Combo(hdcTab[1], 300, 170, 100, 5);
- citem[10].iTab = 1;
- co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_high");
- co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_normal");
- co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_low");
- co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_elow");
- co_Combo_Set_Params(citem[10].p_combo, 4);
- co_Combo_Set_Sel(hdcTab[1], citem[10].p_combo, setup.kvalita_casticv);
- co_Set_Text_Right(hdcTab[1], "#settings_lights", 0, 285, 217);
- citem[32].p_combo = co_Create_Combo(hdcTab[1], 300, 210, 130, 6);
- citem[32].iTab = 1;
- co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_high");
- co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_normal");
- co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_low");
- //co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_elow");
- co_Combo_Add_StringWC(citem[32].p_combo, "##settings_lights_off");
- co_Combo_Set_Params(citem[32].p_combo, 4);
- if (!setup.light_dyn)
- co_Combo_Set_Sel(hdcTab[1], citem[32].p_combo, 3);
- else
- co_Combo_Set_Sel(hdcTab[1], citem[32].p_combo, setup.light_rychlost - 1);
- /////////////////////////////////##settings_item_textures
- co_Set_Text_Right(hdcTab[1], "##settings_item_textures", 0, 285, 257);
- citem[34].p_combo = co_Create_Combo(hdcTab[1], 300, 250, 100, 3);
- citem[34].iTab = 1;
- co_Combo_Add_StringWC(citem[34].p_combo, "##settings_gemeral_3d_high");
- co_Combo_Add_StringWC(citem[34].p_combo, "##settings_gemeral_3d_normal");
- co_Combo_Add_StringWC(citem[34].p_combo, "##settings_gemeral_3d_low");
- co_Combo_Set_Params(citem[34].p_combo, 3);
- co_Combo_Set_Sel(hdcTab[1], citem[34].p_combo, setup.text_detail2);
- /////////////////////////////////##settings_scene_textures
- co_Set_Text_Right(hdcTab[1], "##settings_scene_textures", 0, 285, 297);
- citem[35].p_combo = co_Create_Combo(hdcTab[1], 300, 290, 100, 4);
- citem[35].iTab = 1;
- co_Combo_Add_StringWC(citem[35].p_combo, "##settings_gemeral_3d_high");
- co_Combo_Add_StringWC(citem[35].p_combo, "##settings_gemeral_3d_normal");
- co_Combo_Add_StringWC(citem[35].p_combo, "##settings_gemeral_3d_low");
- co_Combo_Set_Params(citem[35].p_combo, 3);
- co_Combo_Set_Sel(hdcTab[1], citem[35].p_combo, setup.text_detail3);
- co_Set_Text_Right(hdcTab[1], "##settings_bump", 0, 285, 337);
- citem[25].p_combo = co_Create_Combo(hdcTab[1], 300, 330, 100, 7);
- citem[25].iTab = 1;
- co_Combo_Add_StringWC(citem[25].p_combo, "##settings_combo_all");
- co_Combo_Add_StringWC(citem[25].p_combo, "##settings_combo_items");
- co_Combo_Add_StringWC(citem[25].p_combo, "##settings_combo_turnoff");
- co_Combo_Set_Params(citem[25].p_combo, 3);
- if (!setup.bump_mapping)
- co_Combo_Set_Sel(hdcTab[1], citem[25].p_combo, 2);
- else if (setup.bump_mapping && setup.text_bump2 && !setup.text_bump3)
- co_Combo_Set_Sel(hdcTab[1], citem[25].p_combo, 1);
- else
- co_Combo_Set_Sel(hdcTab[1], citem[25].p_combo, 0);
- co_Set_Text_Right(hdcTab[1], "##settings_texture_filterig", 0, 285, 377);
- citem[18].p_combo = co_Create_Combo(hdcTab[1], 300, 370, 100, 8);
- citem[18].iTab = 1;
- co_Combo_Add_StringWC(citem[18].p_combo,
- "##settings_texture_filterig_linear");
- co_Combo_Add_StringWC(citem[18].p_combo, "##settings_texture_mip_mapping");
- co_Combo_Set_Params(citem[18].p_combo, 2);
- co_Combo_Set_Sel(hdcTab[1], citem[18].p_combo, setup.text_mip_mapping);
- co_Set_Text_Right(hdcTab[1], "##settings_texture_depth", 0, 285, 417);
- citem[26].p_combo = co_Create_Combo(hdcTab[1], 300, 410, 100, 9);
- citem[26].iTab = 1;
- co_Combo_Add_StringWC(citem[26].p_combo, "##settings_texture_depth_32");
- co_Combo_Add_StringWC(citem[26].p_combo, "##settings_texture_depth_16");
- co_Combo_Set_Params(citem[26].p_combo, 2);
- if (setup.text_bpp == 32)
- co_Combo_Set_Sel(hdcTab[1], citem[26].p_combo, 0);
- else
- co_Combo_Set_Sel(hdcTab[1], citem[26].p_combo, 1);
- co_Set_Text_Right(hdcTab[1], "##settings_anisotropic_filtering", 0, 285,
- 457);
- citem[27].p_combod = co_Create_Combo_Drop(hdcTab[1], 300, 450, 0);
- citem[27].iTab = 1;
- co_Combo_Drop_Add_StringWC(citem[27].p_combod, "##settings_lights_turnoff",
- 0.0f);
- co_Combo_Drop_Add_String(citem[27].p_combod, "2", 2.0f);
- co_Combo_Drop_Add_String(citem[27].p_combod, "4", 4.0f);
- co_Combo_Drop_Add_String(citem[27].p_combod, "8", 8.0f);
- co_Combo_Drop_Add_String(citem[27].p_combod, "16", 16.0f);
- co_Combo_Drop_Add_String(citem[27].p_combod, "32", 32.0f);
- if (!setup.text_ans)
- co_Combo_Drop_Set_Sel(hdcTab[1], citem[27].p_combod, 0);
- else
- co_Combo_Drop_Set_Sel(hdcTab[1], citem[27].p_combod,
- setup.text_ans_stupen);
- co_Set_Text_Right(hdcTab[1], "##settings_sharpness", 0, 285, 497);
- citem[42].p_combod = co_Create_Combo_Drop(hdcTab[1], 300, 490, 10);
- citem[42].iTab = 1;
- co_Combo_Drop_Add_String(citem[42].p_combod, "-3.0", -3.0f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-2.75", -2.75f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-2.5", -2.5f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-2.25", -2.25f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-2.0", -2.0f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-1.75", -1.75f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-1.5", -1.5f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-1.25", -1.25f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-1.0", -1.0f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-0.75", -0.75f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-0.5", -0.5f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "-0.25", -0.25f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "0.0", 0.0f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+0.25", 0.25f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+0.5", 0.5f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+0.75", 0.75f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+1.0", 1.0f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+1.25", 1.25f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+1.5", 1.5f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+1.75", 1.75f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+2.0", 2.0f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+2.25", 2.25f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+2.5", 2.5f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+2.75", 2.75f);
- co_Combo_Drop_Add_String(citem[42].p_combod, "+3.0", 3.0f);
- i = ftoi(((setup.text_ostrost + 3) * 100) / 25.0f);
- if (i > 24)
- i = 24;
- co_Combo_Drop_Set_Sel(hdcTab[1], citem[42].p_combod, i);
- co_Set_Text_Right(hdcTab[1], "##settings_opengl", 0, 285, 537);
- citem[28].p_combo = co_Create_Combo(hdcTab[1], 300, 530, 100, 10);
- citem[28].iTab = 1;
- co_Combo_Add_StringWC(citem[28].p_combo, "##settings_opengl_rychlost");
- co_Combo_Add_StringWC(citem[28].p_combo, "##settings_opengl_kvalita");
- co_Combo_Set_Params(citem[28].p_combo, 2);
- co_Combo_Set_Sel(hdcTab[1], citem[28].p_combo, setup.text_kvalita);
- citem[16].p_check =
- co_Create_CheckBox(hdcTab[1], 525, 255, "##settings_texture_commpression",
- 0, 6);
- citem[16].iTab = 1;
- co_Check_Set_State(citem[16].p_check, hdcTab[1], setup.text_komprese, 1);
- citem[29].p_check =
- co_Create_CheckBox(hdcTab[1], 525, 415, "##settings_dithering", 0, 7);
- citem[29].iTab = 1;
- co_Check_Set_State(citem[29].p_check, hdcTab[1], setup.ditering, 1);
- citem[11].p_check =
- co_Create_CheckBox(hdcTab[1], 525, 135, "##settings_draw_mirror", 0, 4);
- citem[11].iTab = 1;
- co_Check_Set_State(citem[11].p_check, hdcTab[1], setup.zrcado_aktivni, 1);
- citem[30].p_check =
- co_Create_CheckBox(hdcTab[1], 525, 535, "##settings_caustic", 0, 8);
- citem[30].iTab = 1;
- co_Check_Set_State(citem[30].p_check, hdcTab[1], setup.scene_materialy, 1);
- citem[31].p_check =
- co_Create_CheckBox(hdcTab[1], 300, 580, "##settings_vertex", 0, 9);
- citem[31].iTab = 1;
- co_Check_Set_State(citem[31].p_check, hdcTab[1], setup.vertex_arrays, 1);
- citem[44].p_check =
- co_Create_CheckBox(hdcTab[1], 300, 610, "##settings_load_menu_vram", 0,
- 10);
- citem[44].iTab = 1;
- co_Check_Set_State(citem[44].p_check, hdcTab[1], setup.menu_vram_load, 1);
- ddxSetCursor(0);
- DisplayFrame();
- DisplayFrame();
- ddxResizeCursorBack(0);
- ddxSetCursorSurface(0);
- ddxSetCursor(1);
- DisplayFrame();
- DisplayFrame();
- ddxReleaseBitmap(iClock);
- }
- void InitTabSound(CONTROL_LIST_ITEM * citem, int *hdcTab)
- {
- co_Set_Text_Right(hdcTab[2], "##settings_sound", 0, 260, 50);
- citem[21].p_prog = co_Create_Progres(hdcTab[2], 310, 50, 0, 100, 4);
- citem[21].iTab = 2;
- co_Progres_Set(citem[21].p_prog, hdcTab[2], setup.soundvolume);
- co_Set_Text_Right(hdcTab[2], "##settings_ambient", 0, 260, 85);
- citem[22].p_prog = co_Create_Progres(hdcTab[2], 310, 85, 0, 100, 5);
- citem[22].iTab = 2;
- co_Progres_Set(citem[22].p_prog, hdcTab[2], setup.ambientvolume);
- co_Set_Text_Right(hdcTab[2], "##settings_music", 0, 260, 120);
- citem[23].p_prog = co_Create_Progres(hdcTab[2], 310, 120, 0, 100, 6);
- citem[23].iTab = 2;
- co_Progres_Set(citem[23].p_prog, hdcTab[2], setup.musicvolume);
- }
- void InitTabControls(CONTROL_LIST_ITEM * citem, int *hdcTab)
- {
- char ctext[256];
- int iClock;
- iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
- ddxResizeCursorBack(iClock);
- DrawClock(&iClock, 0);
- citem[24].p_list = co_Create_List(hdcTab[3], 25, 50, 800, 580, 0, 31, 0);
- citem[24].iTab = 3;
- co_List_Add_String(citem[24].p_list, 0, 2, "##control_beatle", 0, 1);
- co_List_Add_String(citem[24].p_list, 1, 2, "##control_forward", 0, 0);
- co_List_Add_String(citem[24].p_list, 2, 2, "##control_back", 0, 0);
- co_List_Add_String(citem[24].p_list, 3, 2, "##control_left", 0, 0);
- co_List_Add_String(citem[24].p_list, 4, 2, "##control_right", 0, 0);
- co_List_Add_String(citem[24].p_list, 5, 2, "##control_nextb", 0, 0);
- co_List_Add_String(citem[24].p_list, 6, 2, "##control_b1", 0, 0);
- co_List_Add_String(citem[24].p_list, 7, 2, "##control_b2", 0, 0);
- co_List_Add_String(citem[24].p_list, 8, 2, "##control_b3", 0, 0);
- co_List_Add_String(citem[24].p_list, 9, 2, "##control_b4", 0, 0);
- co_List_Add_String(citem[24].p_list, 10, 2, "##control_b5", 0, 0);
- co_List_Add_String(citem[24].p_list, 11, 2, "##control_camera", 0, 1);
- co_List_Add_String(citem[24].p_list, 12, 2, "##control_crotation", 0, 0);
- co_List_Add_String(citem[24].p_list, 13, 2, "##control_cmove", 0, 0);
- co_List_Add_String(citem[24].p_list, 14, 2, "##control_czoomin", 0, 0);
- co_List_Add_String(citem[24].p_list, 15, 2, "##control_czoomout", 0, 0);
- co_List_Add_String(citem[24].p_list, 16, 2, "##control_cfastleft", 0, 0);
- co_List_Add_String(citem[24].p_list, 17, 2, "##control_cfastright", 0, 0);
- co_List_Add_String(citem[24].p_list, 18, 2, "##control_ccamera", 0, 0);
- co_List_Add_String(citem[24].p_list, 19, 2, "##control_game", 0, 1);
- co_List_Add_String(citem[24].p_list, 20, 2, "##control_gmenu", 0, 0);
- co_List_Add_String(citem[24].p_list, 21, 2, "##control_grestart", 0, 0);
- co_List_Add_String(citem[24].p_list, 22, 2, "##control_ginventory", 0, 0);
- //co_List_Add_String(citem[24].p_list, 23, 2, "##control_gusepack", 0, 0);
- co_List_Add_String(citem[24].p_list, 23, 2, "##control_gnexttrack", 0, 0);
- co_List_Add_String(citem[24].p_list, 24, 2, "##control_gturnoffi", 0, 0);
- co_List_Add_String(citem[24].p_list, 25, 2, "##control_gturnofft", 0, 0);
- co_List_Add_String(citem[24].p_list, 26, 2, "##control_gscreenshot", 0, 0);
- co_List_Add_String(citem[24].p_list, 27, 2, "##control_gtransparent", 0, 0);
- co_List_Add_String(citem[24].p_list, 28, 2, "##control_ghighlight", 0, 0);
- co_List_Add_String(citem[24].p_list, 29, 2, "##control_gdrawconn", 0, 0);
- co_List_Add_String(citem[24].p_list, 30, 2, "##control_pause", 0, 0);
- Key2String(setup.key[1], ctext);
- co_List_Add_String(citem[24].p_list, 1, 550, ctext, setup.key[1], 0);
- Key2String(setup.key[2], ctext);
- co_List_Add_String(citem[24].p_list, 2, 550, ctext, setup.key[2], 0);
- Key2String(setup.key[3], ctext);
- co_List_Add_String(citem[24].p_list, 3, 550, ctext, setup.key[3], 0);
- Key2String(setup.key[4], ctext);
- co_List_Add_String(citem[24].p_list, 4, 550, ctext, setup.key[4], 0);
- Key2String(setup.key[5], ctext);
- co_List_Add_String(citem[24].p_list, 5, 550, ctext, setup.key[5], 0);
- Key2String(setup.key[6], ctext);
- co_List_Add_String(citem[24].p_list, 6, 550, ctext, setup.key[6], 0);
- Key2String(setup.key[7], ctext);
- co_List_Add_String(citem[24].p_list, 7, 550, ctext, setup.key[7], 0);
- Key2String(setup.key[8], ctext);
- co_List_Add_String(citem[24].p_list, 8, 550, ctext, setup.key[8], 0);
- Key2String(setup.key[9], ctext);
- co_List_Add_String(citem[24].p_list, 9, 550, ctext, setup.key[9], 0);
- Key2String(setup.key[10], ctext);
- co_List_Add_String(citem[24].p_list, 10, 550, ctext, setup.key[10], 0);
- Key2String(setup.key[12], ctext);
- co_List_Add_String(citem[24].p_list, 12, 550, ctext, setup.key[12], 0);
- Key2String(setup.key[13], ctext);
- co_List_Add_String(citem[24].p_list, 13, 550, ctext, setup.key[13], 0);
- Key2String(setup.key[14], ctext);
- co_List_Add_String(citem[24].p_list, 14, 550, ctext, setup.key[14], 0);
- Key2String(setup.key[15], ctext);
- co_List_Add_String(citem[24].p_list, 15, 550, ctext, setup.key[15], 0);
- Key2String(setup.key[16], ctext);
- co_List_Add_String(citem[24].p_list, 16, 550, ctext, setup.key[16], 0);
- Key2String(setup.key[17], ctext);
- co_List_Add_String(citem[24].p_list, 17, 550, ctext, setup.key[17], 0);
- Key2String(setup.key[18], ctext);
- co_List_Add_String(citem[24].p_list, 18, 550, ctext, setup.key[18], 0);
- Key2String(setup.key[20], ctext);
- co_List_Add_String(citem[24].p_list, 20, 550, ctext, setup.key[20], 0);
- Key2String(setup.key[21], ctext);
- co_List_Add_String(citem[24].p_list, 21, 550, ctext, setup.key[21], 0);
- Key2String(setup.key[22], ctext);
- co_List_Add_String(citem[24].p_list, 22, 550, ctext, setup.key[22], 0);
- //Key2String(setup.key[23], ctext);
- //co_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0);
- Key2String(setup.key[23], ctext);
- co_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0);
- Key2String(setup.key[24], ctext);
- co_List_Add_String(citem[24].p_list, 24, 550, ctext, setup.key[24], 0);
- Key2String(setup.key[25], ctext);
- co_List_Add_String(citem[24].p_list, 25, 550, ctext, setup.key[25], 0);
- Key2String(setup.key[26], ctext);
- co_List_Add_String(citem[24].p_list, 26, 550, ctext, setup.key[26], 0);
- Key2String(setup.key[27], ctext);
- co_List_Add_String(citem[24].p_list, 27, 550, ctext, setup.key[27], 0);
- Key2String(setup.key[28], ctext);
- co_List_Add_String(citem[24].p_list, 28, 550, ctext, setup.key[28], 0);
- Key2String(setup.key[29], ctext);
- co_List_Add_String(citem[24].p_list, 29, 550, ctext, setup.key[29], 0);
- Key2String(setup.key[30], ctext);
- co_List_Add_String(citem[24].p_list, 30, 550, ctext, setup.key[30], 0);
- co_List_Redraw(hdcTab[3], citem[24].p_list, 0);
- ddxSetCursor(0);
- DisplayFrame();
- DisplayFrame();
- ddxResizeCursorBack(0);
- ddxSetCursorSurface(0);
- ddxSetCursor(1);
- DisplayFrame();
- DisplayFrame();
- ddxReleaseBitmap(iClock);
- }
- void RunMenuSetGeneralSettings(CONTROL_LIST_ITEM * citem, int iset)
- {
- int i;
- ddxSetFlip(0);
- for (i = 0; i < 2; i++) {
- switch (iset) {
- case 0:
- //modely
- co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 0);
- //castice
- co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 0);
- //svetla
- setup.light_dyn = 1;
- co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 0);
- //textury predmetu
- co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 0);
- //textury okoli
- co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 0);
- //zrcadlo
- co_Check_Set_State(citem[11].p_check, HDC2DD, 1, 1);
- //caustic
- co_Check_Set_State(citem[30].p_check, HDC2DD, 1, 1);
- break;
- case 1:
- //modely
- co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 1);
- //castice
- co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 1);
- //svetla
- setup.light_dyn = 1;
- co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 1);
- //textury predmetu
- co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 1);
- //textury okoli
- co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 1);
- //zrcadlo
- co_Check_Set_State(citem[11].p_check, HDC2DD, 0, 1);
- //caustic
- co_Check_Set_State(citem[30].p_check, HDC2DD, 0, 1);
- break;
- case 2:
- //modely
- co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 1);
- //castice
- co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 2);
- //svetla
- setup.light_dyn = 1;
- co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 2);
- //textury predmetu
- co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 1);
- //textury okoli
- co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 2);
- //zrcadlo
- co_Check_Set_State(citem[11].p_check, HDC2DD, 0, 1);
- //caustic
- co_Check_Set_State(citem[30].p_check, HDC2DD, 0, 1);
- break;
- case 3:
- //modely
- co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 1);
- //castice
- co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 2);
- //svetla
- setup.light_dyn = 0;
- co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 3);
- //textury predmetu
- co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 2);
- //textury okoli
- co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 2);
- //zrcadlo
- co_Check_Set_State(citem[11].p_check, HDC2DD, 0, 1);
- //caustic
- co_Check_Set_State(citem[30].p_check, HDC2DD, 0, 1);
- break;
- }
- if (!i)
- DisplayFrame();
- }
- ddxSetFlip(1);
- }
- void RunMenuSettings(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- ROZLISENI *roz;
- int roz_size = 0;
- int ActiveTab = 0;
- int hdcTab[TAB_NUM];
- int hdcTabUse[TAB_NUM];
- CONTROL_LIST_ITEM citem[CLIST_ITEMC];
- int iClock[12];
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- //CMD_LINE res[RES_NUM];
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- int igeneral_3d;
- int iComboActSel = -1;
- for (i = 0; i < 12; i++)
- iClock[i] = -1;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuSettings: Out of Memory");
- return;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- EnumRozliseni(&roz, &roz_size);
- Load_ini();
- igeneral_3d = setup.general_3d;
- //BitBltU(FontDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
- //BitBltU(BackDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- ddxCleareSurface(CompositDC);
- LoadClock(iClock);
- if (iClock[0] != -1) {
- ddxResizeCursorBack(iClock[0]);
- DrawClock(iClock, 0);
- }
- MENU_SETTING_BRUTAL_RESTART:
- ActiveTab = 0;
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
- fn_Set_Font(cFontFile[2]);
- fn_Load_Bitmaps();
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][11] = -1;
- res[bind].iAnim[lastcmd][0] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- //CreateFontAnimations(res, &lastcmd);
- DrawClock(iClock, 1);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer) {
- ddxDrawSurface(BackDC, res[i].iParam, 2);
- //menucommand_Draw(BackDC, res[i].iParam, 2);
- }
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- //ddxDrawSurface(BackDC, res[i].iParam, 2);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- //menucommand_DrawT(BackDC, res[i].iParam);
- //menucommand_Draw(FontDC, res[i].iParam, 3);
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- DrawClock(iClock, 2);
- //DisplayFrame();
- for (i = 0; i < TAB_NUM; i++) {
- //hdcTab[i] = fn_CreateDC(_2dd.hDC, TAB_XRES, TAB_YRES, _2d_Find_Free_Surface());
- hdcTab[i] = ddxCreateSurface(TAB_XRES, TAB_YRES, ddxFindFreeSurface());
- if (hdcTab[i]) {
- ddxBitBlt(hdcTab[i], 0, 0, TAB_XRES, TAB_YRES, BackDC, TAB_X, TAB_Y);
- //BitBlt(hdcTab[i], 0, 0, TAB_XRES, TAB_YRES, BackDC, TAB_X, TAB_Y, SRCCOPY);
- }
- hdcTabUse[i] = 0;
- }
- DrawClock(iClock, 3);
- if (co_Load_Graphic(0)) {
- int count = 0;
- DrawClock(iClock, 4);
- citem[0].bActive = 0;
- citem[1].bActive = 0;
- //citem[2].p_check = co_Create_CheckBox(hdcTab[0], 25, 50, "##settings_camera_rot", 0, 0);
- //co_Check_Set_State(citem[2].p_check, hdcTab[0], setup.pohled_berusky, 1);
- citem[2].bActive = 1;
- citem[3].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 50, "##settings_camera_mov", 0, 1);
- co_Check_Set_State(citem[3].p_check, hdcTab[0], setup.posouvat_kameru, 1);
- citem[3].bActive = 1;
- citem[4].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 80, "##settings_b1_control", 0, 2);
- co_Check_Set_State(citem[4].p_check, hdcTab[0], setup.ovladani, 1);
- citem[4].bActive = 1;
- citem[45].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 110, "##settings_beathe_vis_at_start",
- 0, 10);
- co_Check_Set_State(citem[45].p_check, hdcTab[0],
- setup.start_zpruhlednovani, 1);
- citem[45].bActive = 1;
- citem[46].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 140, "##settings_items_vis_at_start",
- 0, 11);
- co_Check_Set_State(citem[46].p_check, hdcTab[0], setup.start_zvyraznovani,
- 1);
- citem[46].bActive = 1;
- citem[51].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 200, "##settings_camera_intro", 0,
- 16);
- co_Check_Set_State(citem[51].p_check, hdcTab[0], setup.camera_intro, 1);
- citem[51].bActive = 1;
- citem[47].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 230, "##settings_camera_rect", 0, 12);
- co_Check_Set_State(citem[47].p_check, hdcTab[0], setup.ovladani_rohy, 1);
- citem[47].bActive = 1;
- citem[48].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 260, "##settings_implicit_move", 0,
- 13);
- if (setup.ovladani_rohy_default)
- co_Check_Set_State(citem[48].p_check, hdcTab[0], 0, 1);
- else
- co_Check_Set_State(citem[48].p_check, hdcTab[0], 1, 1);
- DrawClock(iClock, 5);
- citem[48].bActive = 1;
- citem[49].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 290, "##settings_imlicit_rot", 0, 14);
- if (setup.ovladani_rohy_default)
- co_Check_Set_State(citem[49].p_check, hdcTab[0], 1, 1);
- else
- co_Check_Set_State(citem[49].p_check, hdcTab[0], 0, 1);
- citem[49].bActive = 1;
- citem[50].p_check =
- co_Create_CheckBox(hdcTab[0], 25, 320, "##settings_camera_swap", 0, 15);
- co_Check_Set_State(citem[50].p_check, hdcTab[0], setup.ovladani_rohy_smer,
- 1);
- citem[50].bActive = 1;
- //citem[51].p_check = co_Create_CheckBox(hdcTab[0], 25, 350, "##setings_camera_move_cur", 0, 16);
- //co_Check_Set_State(citem[51].p_check, hdcTab[0], setup.ovladani_pr_posun, 1);
- //citem[51].bActive = 1;
- //co_Set_Text_Right(hdcTab[0], "##settings_transparency", 0, 450, 300);
- //citem[6].p_prog = co_Create_Progres(hdcTab[0], 500, 300, 2, 18, 0);
- //co_Progres_Set(citem[6].p_prog, hdcTab[0], ftoi(setup.p_kamera_alfa * 20));
- //citem[6].bActive = 1;
- co_Set_Text_Right(hdcTab[0], "##setings_camera_speed", 0, 450, 390);
- citem[52].p_prog = co_Create_Progres(hdcTab[0], 500, 387, 0, 10, 0);
- co_Progres_Set(citem[52].p_prog, hdcTab[0],
- ftoi(setup.ovladani_rohy_rychlost * 10));
- citem[52].bActive = 1;
- co_Set_Text_Right(hdcTab[0], "##settings_trans_radius", 0, 450, 425);
- citem[7].p_prog = co_Create_Progres(hdcTab[0], 500, 412, 1, 20, 1);
- co_Progres_Set(citem[7].p_prog, hdcTab[0],
- ftoi(setup.p_kamera_radius * 2));
- citem[7].bActive = 1;
- //if(!setup.posouvat_kameru)
- //co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0);
- if (!setup.ovladani_rohy) {
- co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 13);
- co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 14);
- co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 15);
- //co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 16);
- co_Progres_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0, 1,
- hdcTab[0]);
- }
- DrawClock(iClock, 6);
- ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
- SetTab(0, -1, citem, CLIST_ITEMC, hdcTab);
- //if(!setup.posouvat_kameru)
- // co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
- if (!setup.ovladani_rohy) {
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
- //co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
- co_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 0,
- HDC2DD);
- }
- DrawClock(iClock, 7);
- ddxCleareSurface(BackDC);
- hdcTabUse[0] = 1;
- ddxSetCursor(0);
- DisplayFrame();
- DisplayFrame();
- ddxResizeCursorBack(0);
- ddxSetCursorSurface(0);
- ddxSetCursor(1);
- DisplayFrame();
- DisplayFrame();
- for (i = 0; i < 12; i++)
- if (iClock[i] != -1) {
- ddxReleaseBitmap(iClock[i]);
- iClock[i] = -1;
- }
- }
- //BEGIN_MENU:
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 3,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- //menucommand_Draw(FontDC, res[i].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[anbind].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- co_Handle_Controls(citem, CLIST_ITEMC, dim.x - TAB_X, dim.y - TAB_Y,
- HDC2DD, TAB_X, TAB_Y);
- /*
- if(co_Progres_Changed(citem, CLIST_ITEMC, 4))
- p_ad->Sound_Gain = co_Progres_Get(citem, CLIST_ITEMC, 4) / 100.0f;
- */
- if (co_Progres_Changed(citem, CLIST_ITEMC, 6)) {
- float f = co_Progres_Get(citem, CLIST_ITEMC, 6) / 100.0f;
- //ogg_gain(f);
- //p_ad->Music_Gain = f;
- if (f >= 0.05f && !ogg_playing()) {
- // p_ad->Music_Gain = f;
- //ap_Play_Song(0,0,p_ad);
- }
- }
- if (ActiveTab == 1) {
- iComboActSel = co_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 1);
- if (iComboActSel != -1 && iComboActSel != igeneral_3d) {
- igeneral_3d = iComboActSel;
- RunMenuSetGeneralSettings(citem, igeneral_3d);
- }
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- int iCheck = -1;
- LIST_VIEW_CONTROL *p_li;
- if (co_List_Get_Clck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
- float pos[3] = { 0, 0, 0 };
- //if(karmin_aktivni)
- //ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, p_ad);
- SetCharMenu(p_li);
- }
- /*iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 1);
- if(iCheck != -1)
- {
- if(!iCheck)
- {
- co_Check_Set_State(citem[2].p_check, HDC2DD, 0, 1);
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
- }
- else
- co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
- } */
- iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 12);
- if (iCheck != -1) {
- if (!iCheck) {
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
- co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
- //co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
- co_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 1,
- HDC2DD);
- }
- else {
- co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
- co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
- co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
- //co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
- co_Progres_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
- }
- }
- if (ActiveTab == 0 && !citem[49].bDisabled) {
- iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 13);
- if (iCheck != -1 && iCheck == 1)
- co_Check_Set_State(citem[49].p_check, HDC2DD, 0, 1);
- else if (iCheck != -1 && !iCheck)
- co_Check_Set_State(citem[49].p_check, HDC2DD, 1, 1);
- iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 14);
- if (iCheck != -1 && iCheck == 1)
- co_Check_Set_State(citem[48].p_check, HDC2DD, 0, 1);
- else if (iCheck != -1 && !iCheck)
- co_Check_Set_State(citem[48].p_check, HDC2DD, 1, 1);
- }
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "OK")) {
- float pos[3] = { 0, 0, 0 };
- //if(karmin_aktivni)
- //ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, p_ad);
- SetMenuSettings(roz, citem, hdcTabUse);
- Save_ini();
- key[K_ESC] = 1;
- }
- if (!strcmp(res[resid].cParam[1], "EXIT")) {
- float pos[3] = { 0, 0, 0 };
- //if(karmin_aktivni)
- //ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, p_ad);
- key[K_ESC] = 1;
- }
- if (!strcmp(res[resid].cParam[1], "GAME") && ActiveTab) {
- SetTab(0, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 0;
- hdcTabUse[0]++;
- }
- if (!strcmp(res[resid].cParam[1], "3D") && ActiveTab != 1) {
- if (!hdcTabUse[1])
- InitTab3d(citem, hdcTab, roz, roz_size);
- SetTab(1, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 1;
- hdcTabUse[1]++;
- }
- if (!strcmp(res[resid].cParam[1], "SOUND") && ActiveTab != 2) {
- if (!hdcTabUse[2])
- InitTabSound(citem, hdcTab);
- SetTab(2, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 2;
- hdcTabUse[2]++;
- }
- if (!strcmp(res[resid].cParam[1], "CONTROLS") && ActiveTab != 3) {
- if (!hdcTabUse[3])
- InitTabControls(citem, hdcTab);
- SetTab(3, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 3;
- hdcTabUse[3]++;
- }
- /* if(!strcmp(res[resid].cParam[1], "NEW_GAME"))
- NewGame(hWnd, p_ad, cpu);*/
- /*
- for(i=0;i<lastcmd;i++)
- {
- switch(res[i].iParam[0])
- {
- case COM_DRAW:
- if(!res[i].iLayer)
- menucommand_Draw(_2dd.hDC, res[i].iParam);
- else
- {
- menucommand_DrawT(_2dd.hDC, res[i].iParam);
- menucommand_Draw(FontDC, res[i].iParam);
- }
- break;
- }
- }
- */
- resid = -1;
- if (key[K_ESC]) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- /*else
- goto BEGIN_MENU; */
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- /* spracuj_spravy(0);
- ddxUpdateMouse();
- if(dim.dx || dim.dy)
- DisplayFrame();*/
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad))
- goto MENU_SETTING_BRUTAL_RESTART;
- }
- __QUIT:
- //BitBltU(FontDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
- //BitBltU(BackDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- ddxCleareSurface(CompositDC);
- SetMenuSettingsS(roz, citem, hdcTabUse);
- Save_ini();
- fn_Release_Font(1);
- StopAll();
- co_Handle_Release(citem, CLIST_ITEMC);
- co_Release_Graphic();
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- free((void *) roz);
- }
- void RunStretchAnimation(char *cScene, int x, int y, AUDIO_DATA * p_ad)
- {
- int idx;
- RECT r;
- RECT s = { 0, 0, 1024, 768 };
- APAK_HANDLE *hArchive = NULL;
- char cFile[MAX_PATH];
- char cDir[MAX_PATH];
- if (iLanguageVersion == 4) {
- GetPrivateProfileString("game", "bitmap_dir", "c:\\", cDir, MAX_PATH,
- ini_file);
- working_file_translate(cDir, MAX_PATH);
- sprintf(cFile, "%s\\scene%d.pak", cDir, iActualScene);
- apak_dir_correction(cDir);
- hArchive = apakopen(cFile, cDir, &idx);
- if (!hArchive) {
- kprintf(1, "Nepodarilo se otevrit archiv [%s]\n", cFile);
- return;
- }
- else
- hArchive->pActualNode = hArchive->pRootNode->pNextNode;
- idx = ddxLoadBitmap(cScene, hArchive);
- }
- else
- idx = ddxLoadBitmap(cScene, pBmpArchive);
- if (idx < 0) {
- if (iLanguageVersion == 4)
- apakclose(hArchive);
- return;
- }
- r.left = x;
- r.top = y;
- r.right = r.left + ddxGetWidth(180);
- r.bottom = r.top + ddxGetHight(180);
- StretchAnimation(&r, &s, idx, 1, p_ad);
- ddxReleaseBitmap(idx);
- if (iLanguageVersion == 4)
- apakclose(hArchive);
- }
- void RunMenuNewGameSceneActivate(CMD_LINE * res)
- {
- #ifndef __DEMO
- int i;
- for (i = 1; i < 10; i++)
- if (pPlayerProfile.cScene[i]) {
- res[i + 8].bActive = 1;
- res[i + 17].bActive = 1;
- ddxDrawSurface(BackDC, res[i + 8].iAnim[0], 2);
- if (i > 1)
- ddxDrawSurface(BackDC, res[i - 1].iAnim[6], 2);
- }
- #endif
- #ifdef __DEMO
- res[6 + 8].bActive = 1;
- res[6 + 17].bActive = 1;
- ddxDrawSurface(BackDC, res[6 + 8].iAnim[0], 2);
- #endif
- }
- void GetRunMenuNewGameSceneLoadGame(char *cscene, char *cscenemap,
- char *csceneanim, char *cscenelevel, int *iLevelStart, int *iNumOfLevels,
- int *xTV, int *yTV, char *bTutorial, int *xBack, int *yBack)
- {
- *bTutorial = 0;
- switch (iActualScene) {
- case 0:
- *iLevelStart = 200;
- *iNumOfLevels = 20;
- *xTV = 0;
- *yTV = 0;
- *bTutorial = 1;
- *xBack = 975;
- *yBack = 7;
- break;
- case 1:
- *iLevelStart = 0;
- *iNumOfLevels = 11;
- *xTV = 919;
- *yTV = 677;
- *xBack = 713;
- *yBack = 679;
- break;
- case 2:
- *iLevelStart = 11;
- *iNumOfLevels = 10;
- *xTV = 916;
- *yTV = 8;
- *xBack = 971;
- *yBack = 703;
- break;
- case 3:
- *iLevelStart = 21;
- *iNumOfLevels = 12;
- *xTV = 918;
- *yTV = 7;
- *xBack = 973;
- *yBack = 413;
- break;
- case 4:
- *iLevelStart = 33;
- *iNumOfLevels = 10;
- *xTV = 197;
- *yTV = 9;
- *xBack = 8;
- *yBack = 16;
- break;
- case 5:
- *iLevelStart = 43;
- *iNumOfLevels = 10;
- *xTV = 918;
- *yTV = 9;
- *xBack = 976;
- *yBack = 309;
- break;
- case 6:
- *iLevelStart = 53;
- #ifndef __DEMO
- *iNumOfLevels = 10;
- #endif
- #ifdef __DEMO
- *iNumOfLevels = 6;
- #endif
- *xTV = 920;
- *yTV = 8;
- *xBack = 967;
- *yBack = 211;
- break;
- case 7:
- *iLevelStart = 63;
- *iNumOfLevels = 10;
- *xTV = 11;
- *yTV = 6;
- *xBack = 8;
- *yBack = 279;
- break;
- case 8:
- *iLevelStart = 73;
- *iNumOfLevels = 12;
- *xTV = 15;
- *yTV = 677;
- *xBack = 12;
- *yBack = 490;
- break;
- case 9:
- *iLevelStart = 85;
- *iNumOfLevels = 10;
- *xTV = 918;
- *yTV = 7;
- *xBack = 971;
- *yBack = 338;
- break;
- case 10:
- *iLevelStart = 300;
- *iNumOfLevels = 15;
- *xTV = 920;
- *yTV = 5;
- *xBack = 706;
- *yBack = 6;
- break;
- case 11:
- *iLevelStart = 315;
- *iNumOfLevels = 15;
- *xTV = 920;
- *yTV = 5;
- *xBack = 750;
- *yBack = 5;
- break;
- case 12:
- *iLevelStart = 330;
- *iNumOfLevels = 15;
- *xTV = 920;
- *yTV = 7;
- *xBack = 973;
- *yBack = 229;
- break;
- }
- sprintf(cscenemap, "scene%d_map.bmp", iActualScene);
- sprintf(csceneanim, "scene%d_anim", iActualScene);
- sprintf(cscenelevel, "scene%d_levels.txt", iActualScene);
- sprintf(cscene, "Mmnew_game_scene%d_map.txt", iActualScene);
- }
- void RunMenuNewGameSceneLoadGame(HWND hWnd, AUDIO_DATA * p_ad, int cpu,
- char bLoadGame, char *cSaveFile)
- {
- char cscene[64] = "";
- char cscenemap[64] = "";
- char csceneanim[64] = "";
- char cscenelevel[64] = "";
- int iLevelStart = 0;
- int iNumOfLevels = 0;
- int xTV = 0;
- int yTV = 0;
- int xBack = 0;
- int yBack = 0;
- char bTutorial = 0;
- GetRunMenuNewGameSceneLoadGame(cscene, cscenemap, csceneanim, cscenelevel,
- &iLevelStart, &iNumOfLevels, &xTV, &yTV, &bTutorial, &xBack, &yBack);
- RunMenuSceneMap(cscene, NULL, p_ad, cpu, cscenemap,
- csceneanim, iActualScene, iLevelStart,
- iNumOfLevels, cscenelevel, xTV, yTV, 1, cSaveFile, bTutorial, 0, 0);
- }
- void RunMenuNewGameScene(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
- int cpu, char bLoadGame, char *cSaveFile, char bNewGame)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- //CMD_LINE res[RES_NUM];
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- bBackDC = 0;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuNewGameScene: Out of Memory");
- return;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- #ifndef __DEMO
- if (!pPlayerProfile.cMovie[0] && bNewGame) {
- pPlayerProfile.cMovie[0] = 1;
- pr_SaveProfile(&pPlayerProfile);
- RunMenuComix("menu_comix.txt", NULL, p_ad, 0);
- }
- #endif
- ////////////////////////////LOAD GAME
- if (bLoadGame) {
- if (lsi_Get_Save_Info(cSaveFile, &iActualLevel, &iActualScene)) {
- RunMenuNewGameSceneLoadGame(NULL, p_ad, cpu, bLoadGame, cSaveFile);
- bLoadGame = 0;
- if (!iActualScene) {
- free((void *) res);
- return;
- }
- } ////////////////////////////LOAD GAME
- }
- else if (!iActualScene) {
- RunMenuSceneMap("Mmnew_game_scene0_map.txt", NULL, p_ad, cpu,
- "scene0_map.bmp", "scene0_anim", 0, 200, 20, "scene0_levels.txt", 0, 0,
- 0, NULL, 1, 975, 7);
- bLoadGame = 0;
- if (!iActualScene) {
- free((void *) res);
- return;
- }
- }
- else if (iActualScene == 10) {
- RunMenuSceneMap("Mmnew_game_scene10_map.txt", NULL, p_ad, cpu,
- "scene10_map.bmp", "scene10_anim", 10, 300, 15, "scene10_levels.txt",
- 920, 2, 0, NULL, 0, 706, 6);
- bLoadGame = 0;
- if (iActualScene == 10) {
- free((void *) res);
- return;
- }
- }
- else if (iActualScene == 11) {
- RunMenuSceneMap("Mmnew_game_scene11_map.txt", NULL, p_ad, cpu,
- "scene11_map.bmp", "scene11_anim", 11, 315, 15, "scene11_levels.txt",
- 920, 2, 0, NULL, 0, 750, 5);
- bLoadGame = 0;
- if (iActualScene == 11) {
- free((void *) res);
- return;
- }
- }
- else if (iActualScene == 12) {
- RunMenuSceneMap("Mmnew_game_scene12_map.txt", NULL, p_ad, cpu,
- "scene12_map.bmp", "scene12_anim", 12, 330, 15, "scene12_levels.txt",
- 920, 7, 0, NULL, 0, 973, 229);
- bLoadGame = 0;
- if (iActualScene == 12) {
- free((void *) res);
- return;
- }
- }
- ddxCleareSurface(CompositDC);
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- BEGIN_MENU_NEWGAMESCENE_BRUTAL:
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].pCmdLine = res;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- //ddxDrawDisplay(res[i].iParam, 0);
- ddxDrawSurface(BackDC, res[i].iParam, 0);
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- RunMenuNewGameSceneActivate(res);
- ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
- ddxCleareSurface(BackDC);
- //DisplayFrame();
- BEGIN_MENU_NEWGAMESCENE:
- //NOVA CESTA ////////////////////////////////////////////////////////////////////////////////////
- if (bNewScene) {
- bNewScene = 0;
- // 1 = prvni animace way1_2
- /*res[1].bEndActivate[0] = 10; //prvni OnAbove
- res[1].bEndActivate[1] = 19; //prvni OnClick
- res[1].bActive = 1; *///aktivace
- // 1 = prvni animace way1_2
- res[iActualScene].bEndActivate[0] = 10 + (iActualScene - 1); //prvni OnAbove
- res[iActualScene].bEndActivate[1] = 19 + (iActualScene - 1); //prvni OnClick
- res[iActualScene].bActive = 1; //aktivace
- pPlayerProfile.cScene[iActualScene + 1] = 1;
- pr_SaveProfile(&pPlayerProfile);
- }
- //aktivace tlacitka zpet
- res[27].bActive = 1;
- res[28].bActive = 1;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION && res[i].bActive) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 1);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- dwLTime = timeGetTime();
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE && res[i].bActive) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- LEAVE_ANIMATION:
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[anbind].iLayer) {
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK && res[i].bActive)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- key[K_ESC] = 1;
- cRestartMainMenu = 1;
- //break;
- }
- if (!strcmp(res[resid].cParam[1], "SCENE1")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(1)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 1;
- RunStretchAnimation("scene1_map.bmp", 0, 129, p_ad);
- RunMenuSceneMap("Mmnew_game_scene1_map.txt", NULL, p_ad, cpu,
- "scene1_map.bmp", "scene1_anim", 1, 0, 11, "scene1_levels.txt",
- 919, 677, 0, NULL, 0, 713, 679);
- }
- }
- if (!strcmp(res[resid].cParam[1], "SCENE2")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(2)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 2;
- RunStretchAnimation("scene2_map.bmp", 215, 0, p_ad);
- RunMenuSceneMap("Mmnew_game_scene2_map.txt", NULL, p_ad, cpu,
- "scene2_map.bmp", "scene2_anim", 2, 11, 10, "scene2_levels.txt",
- 916, 8, 0, NULL, 0, 971, 703);
- }
- }
- if (!strcmp(res[resid].cParam[1], "SCENE3")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(3)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 3;
- RunStretchAnimation("scene3_map.bmp", 177, 248, p_ad);
- RunMenuSceneMap("Mmnew_game_scene3_map.txt", NULL, p_ad, cpu,
- "scene3_map.bmp", "scene3_anim", 3, 21, 12, "scene3_levels.txt",
- 918, 7, 0, NULL, 0, 973, 413);
- }
- }
- if (!strcmp(res[resid].cParam[1], "SCENE4")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(4)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 4;
- RunStretchAnimation("scene4_map.bmp", 444, 64, p_ad);
- RunMenuSceneMap("Mmnew_game_scene4_map.txt", NULL, p_ad, cpu,
- "scene4_map.bmp", "scene4_anim", 4, 33, 10, "scene4_levels.txt",
- 197, 9, 0, NULL, 0, 8, 16);
- }
- }
- if (!strcmp(res[resid].cParam[1], "SCENE5")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(5)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 5;
- RunStretchAnimation("scene5_map.bmp", 465, 386, p_ad);
- RunMenuSceneMap("Mmnew_game_scene5_map.txt", NULL, p_ad, cpu,
- "scene5_map.bmp", "scene5_anim", 5, 43, 10, "scene5_levels.txt",
- 918, 9, 0, NULL, 0, 976, 309);
- }
- }
- #ifndef __DEMO
- if (!strcmp(res[resid].cParam[1], "SCENE6")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(6)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 6;
- RunStretchAnimation("scene6_map.bmp", 37, 495, p_ad);
- RunMenuSceneMap("Mmnew_game_scene6_map.txt", NULL, p_ad, cpu,
- "scene6_map.bmp", "scene6_anim", 6, 53, 10, "scene6_levels.txt",
- 920, 8, 0, NULL, 0, 967, 211);
- }
- }
- #endif
- #ifdef __DEMO
- if (!strcmp(res[resid].cParam[1], "SCENE6")) {
- iActualScene = 6;
- RunStretchAnimation("scene6_map.bmp", 37, 495, p_ad);
- RunMenuSceneMap("Mmnew_game_scene6_map.txt", NULL, p_ad, cpu,
- "scene6_map.bmp", "scene6_anim", 6, 53, 6, "scene6_levels.txt",
- 920, 8, 0, NULL, 0, 967, 211);
- }
- #endif
- if (!strcmp(res[resid].cParam[1], "SCENE7")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(7)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 7;
- RunStretchAnimation("scene7_map.bmp", 616, 638, p_ad);
- RunMenuSceneMap("Mmnew_game_scene7_map.txt", NULL, p_ad, cpu,
- "scene7_map.bmp", "scene7_anim", 7, 63, 10, "scene7_levels.txt",
- 11, 6, 0, NULL, 0, 8, 279);
- }
- }
- if (!strcmp(res[resid].cParam[1], "SCENE8")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(8)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 8;
- RunStretchAnimation("scene8_map.bmp", 836, 469, p_ad);
- RunMenuSceneMap("Mmnew_game_scene8_map.txt", NULL, p_ad, cpu,
- "scene8_map.bmp", "scene8_anim", 8, 73, 12, "scene8_levels.txt",
- 15, 677, 0, NULL, 0, 12, 490);
- }
- }
- if (!strcmp(res[resid].cParam[1], "SCENE9")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(9)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- i = lastabv;
- goto LEAVE_ANIMATION;
- }
- else {
- iActualScene = 9;
- RunStretchAnimation("scene9_map.bmp", 836, 49, p_ad);
- RunMenuSceneMap("Mmnew_game_scene9_map.txt", NULL, p_ad, cpu,
- "scene9_map.bmp", "scene9_anim", 9, 85, 10, "scene9_levels.txt",
- 918, 7, 0, NULL, 0, 971, 338);
- }
- }
- resid = -1;
- if (!iActualScene)
- key[K_ESC] = 1;
- if (key[K_ESC]) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- else {
- for (i = 0; i < lastcmd; i++) {
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- ddxDrawSurface(BackDC, res[i].iParam, 0);
- break;
- }
- }
- RunMenuNewGameSceneActivate(res);
- ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
- ddxCleareSurface(BackDC);
- goto BEGIN_MENU_NEWGAMESCENE;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- /* spracuj_spravy(0);
- ddxUpdateMouse();
- if(dim.dx || dim.dy)
- DisplayFrame();*/
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- StopAll();
- FreeAnimations(res, RES_NUM);
- goto BEGIN_MENU_NEWGAMESCENE_BRUTAL;
- }
- }
- __QUIT:
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- ddxCleareSurface(CompositDC);
- cRestartMainMenu = 1;
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- void LoadSceneMap(int *pBmp, char *cSceneBmp, char *cSceneAnim, int iScene,
- int *iClock)
- {
- int i;
- char text[256];
- APAK_HANDLE *hArchive = NULL;
- char cFile[MAX_PATH];
- char cDir[MAX_PATH];
- if (iLanguageVersion == 4) {
- GetPrivateProfileString("game", "bitmap_dir", "c:\\", cDir, MAX_PATH,
- ini_file);
- working_file_translate(cDir, MAX_PATH);
- sprintf(cFile, "%s\\scene%d.pak", cDir, iScene);
- apak_dir_correction(cDir);
- hArchive = apakopen(cFile, cDir, &i);
- if (!hArchive) {
- kprintf(1, "Nepodarilo se otevrit archiv [%s]\n", cFile);
- return;
- }
- else
- hArchive->pActualNode = hArchive->pRootNode->pNextNode;
- pBmp[0] = ddxLoadBitmap(cSceneBmp, hArchive);
- for (i = 1; i < 6; i++) {
- sprintf(text, "%s%d.bmp", cSceneAnim, i);
- pBmp[i] = ddxLoadBitmap(text, hArchive);
- DrawClock(iClock, i);
- }
- apakclose(hArchive);
- }
- else {
- pBmp[0] = ddxLoadBitmap(cSceneBmp, pBmpArchive);
- for (i = 1; i < 6; i++) {
- sprintf(text, "%s%d.bmp", cSceneAnim, i);
- pBmp[i] = ddxLoadBitmap(text, pBmpArchive);
- DrawClock(iClock, i);
- }
- }
- switch (iScene) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 7:
- pBmp[6] = ddxLoadBitmap("level_green.bmp", pBmpArchive);
- pBmp[7] = ddxLoadBitmap("level_ok_green.bmp", pBmpArchive);
- pBmp[8] = ddxLoadBitmap("b1_green.bmp", pBmpArchive);
- pBmp[9] = ddxLoadBitmap("b2_green.bmp", pBmpArchive);
- pBmp[10] = ddxLoadBitmap("level_green_l.bmp", pBmpArchive);
- pBmp[11] = ddxLoadBitmap("level_ok_green_l.bmp", pBmpArchive);
- break;
- case 5:
- case 8:
- pBmp[6] = ddxLoadBitmap("level_brown.bmp", pBmpArchive);
- pBmp[7] = ddxLoadBitmap("level_ok_brown.bmp", pBmpArchive);
- pBmp[8] = ddxLoadBitmap("b1_brown.bmp", pBmpArchive);
- pBmp[9] = ddxLoadBitmap("b2_brown.bmp", pBmpArchive);
- pBmp[10] = ddxLoadBitmap("level_brown_l.bmp", pBmpArchive);
- pBmp[11] = ddxLoadBitmap("level_ok_brown_l.bmp", pBmpArchive);
- break;
- case 0:
- pBmp[6] = ddxLoadBitmap("level_tutorial.bmp", pBmpArchive);
- pBmp[7] = ddxLoadBitmap("level_ok_tutorial.bmp", pBmpArchive);
- pBmp[8] = ddxLoadBitmap("b1_blue.bmp", pBmpArchive);
- pBmp[9] = ddxLoadBitmap("b2_blue.bmp", pBmpArchive);
- pBmp[10] = ddxLoadBitmap("level_tutorial_l.bmp", pBmpArchive);
- pBmp[11] = ddxLoadBitmap("level_ok_tutorial_l.bmp", pBmpArchive);
- break;
- case 6:
- case 9:
- case 10:
- case 11:
- pBmp[6] = ddxLoadBitmap("level_blue.bmp", pBmpArchive);
- pBmp[7] = ddxLoadBitmap("level_ok_blue.bmp", pBmpArchive);
- pBmp[8] = ddxLoadBitmap("b1_blue.bmp", pBmpArchive);
- pBmp[9] = ddxLoadBitmap("b2_blue.bmp", pBmpArchive);
- pBmp[10] = ddxLoadBitmap("level_blue_l.bmp", pBmpArchive);
- pBmp[11] = ddxLoadBitmap("level_ok_blue_l.bmp", pBmpArchive);
- break;
- case 12:
- pBmp[6] = ddxLoadBitmap("level_yellow.bmp", pBmpArchive);
- pBmp[7] = ddxLoadBitmap("level_ok_yellow.bmp", pBmpArchive);
- pBmp[8] = ddxLoadBitmap("b1_yellow.bmp", pBmpArchive);
- pBmp[9] = ddxLoadBitmap("b2_yellow.bmp", pBmpArchive);
- pBmp[10] = ddxLoadBitmap("level_yellow_l.bmp", pBmpArchive);
- pBmp[11] = ddxLoadBitmap("level_ok_yellow_l.bmp", pBmpArchive);
- break;
- }
- DrawClock(iClock, 6);
- }
- void DrawLevelHint(int x, int y, int iLevel)
- {
- int idx;
- char text[256];
- sprintf(text, "t_%d.bmp", iLevel - 200);
- idx = ddxLoadBitmap(text, pBmpArchive);
- if (idx == -1)
- return;
- ddxBitBlt(FontDC, x, y, ddxGetWidth(idx), ddxGetHight(idx), idx, 0, 0);
- ddxTransparentBlt(BackDC, x, y, ddxGetWidth(idx), ddxGetHight(idx), idx, 0,
- 0, ddxGetWidth(idx), ddxGetHight(idx), TRANSCOLOR);
- ddxReleaseBitmap(idx);
- }
- void CreateLevelButton(int x, int y, CMD_LINE * res, int *lastcmd, int *pBmp,
- char *cMessage, char bDone, int iDificulty, char bTuturial, int iLevel)
- {
- int ii;
- char text[1024];
- //Draw(1,0,0)
- sprintf(text, "Draw(%d,%d,%d)", pBmp[6 + bDone], x, y);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- /*if(bTuturial)
- DrawLevelHint(x + ddxGetWidth(pBmp[6+bDone]), y, iLevel); */
- //OnAbove(16,661,100,748, NO_EXEPTION, NO_EXEPTION)
- sprintf(text, "OnAbove(%d,%d,%d,%d, %s, NO_EXEPTION)", x, y,
- x + ddxGetWidth(pBmp[6 + bDone]), y + ddxGetHight(pBmp[6 + bDone]),
- cMessage);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- res[*lastcmd].uiTimerID = 0;
- res[*lastcmd].iLastfrm = 1;
- res[*lastcmd].iCounter = 0;
- res[*lastcmd].iAnim[0][0] = 0;
- res[*lastcmd].iAnim[0][1] = pBmp[6 + bDone];
- res[*lastcmd].iAnim[0][2] = x;
- res[*lastcmd].iAnim[0][3] = y;
- res[*lastcmd].iAnim[0][4] = 0;
- res[*lastcmd].iAnim[0][5] = 1;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[0][ii] = -1;
- res[*lastcmd].iAnim[1][0] = 1;
- res[*lastcmd].iAnim[1][1] = pBmp[10 + bDone];
- res[*lastcmd].iAnim[1][2] = x;
- res[*lastcmd].iAnim[1][3] = y;
- res[*lastcmd].iAnim[1][4] = 50;
- res[*lastcmd].iAnim[1][5] = 2;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[1][ii] = -1;
- res[*lastcmd].iAnim[2][0] = 2;
- res[*lastcmd].iAnim[2][1] = pBmp[10 + bDone];
- res[*lastcmd].iAnim[2][2] = x;
- res[*lastcmd].iAnim[2][3] = y;
- res[*lastcmd].iAnim[2][4] = 50;
- res[*lastcmd].iAnim[2][5] = -1;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[2][ii] = -1;
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- if (!bTuturial) {
- if (!iDificulty) {
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize6.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- }
- else if (iDificulty == 1) {
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize7.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize8.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- }
- else if (iDificulty == 2) {
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize9.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- }
- else if (iDificulty == 3) {
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize10.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- }
- else {
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize11.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
- sprintf(text,
- "BindAnimation(118, -1, -1, -1, televize12.txt, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- }
- //BindExitAnimation(114,115,116,117, televize.txt)
- sprintf(text, "BindExitAnimation(114,115,116,117, televize.txt)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- (*lastcmd)++;
- }
- /* else
- {
- //OnAbove(16,661,100,748, NO_EXEPTION, NO_EXEPTION)
- sprintf(text,"OnAbove(%d,%d,%d,%d, %s, NO_EXEPTION)", x, y, x + ddxGetWidth(pBmp[6+bDone]), y + ddxGetHight(pBmp[6+bDone]), cMessage);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0], res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- }*/
- //OnClick(16,661,100,748, quit_gamec.txt, EXIT)
- sprintf(text, "OnClick(%d,%d,%d,%d, NO_EXEPTION, %s)", x, y,
- x + ddxGetWidth(pBmp[6 + bDone]), y + ddxGetHight(pBmp[6 + bDone]),
- cMessage);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //BindSound(54,55,56,-1)
- strcpy(text, "BindSound(54,55,56,-1)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 0;
- (*lastcmd)++;
- }
- void CreateLevelButtons(CMD_LINE * res, int *lastcmd, int *pBmp, int iScene,
- int iLevelStart, int iNumOfLevels, char *cLevelList, char bTutorial)
- {
- char text[256];
- int r[4];
- int i;
- FILE *file;
- file = aopen(pDataArchive, cLevelList, "r");
- if (!file)
- return;
- for (i = iLevelStart; i < iLevelStart + iNumOfLevels; i++) {
- Parse_AnimLine(file, r, 4);
- if (bTutorial && i != iLevelStart)
- if (!pPlayerProfile.cLevel[i - 1])
- break;
- CreateLevelButton(r[1], r[2], res, lastcmd, pBmp, itoa(r[0], text, 10),
- pPlayerProfile.cLevel[i], r[3], bTutorial, i);
- }
- aclose(file);
- }
- int LoadTV(void)
- {
- int c = 0, i = -1, t;
- char text[256];
- FILE *file;
- file = aopen(pBmpArchive, "tvload.txt", "r");
- if (!file)
- return -1;
- while (!aeof(file)) {
- memset(text, 0, 256);
- agets(text, 256, file);
- if (strlen(text)) {
- text[strlen(text) - 1] = '\0';
- if (!c)
- i = ddxLoadBitmap(text, pBmpArchive);
- else
- t = ddxLoadBitmap(text, pBmpArchive);
- c++;
- }
- }
- aclose(file);
- pBmpArchive->bError = 0;
- return i;
- }
- void CorrectTV(CMD_LINE * res, int iAnim, int iLast, int x, int y, int idx,
- int iScene)
- {
- int tvcoridx = -1;
- int i, d;
- switch (iScene) {
- case 5:
- case 8:
- tvcoridx = ddxLoadBitmap("tvcor_brown.bmp", pBmpArchive);
- break;
- case 0:
- case 6:
- case 9:
- case 10:
- case 11:
- tvcoridx = ddxLoadBitmap("tvcor_blue.bmp", pBmpArchive);
- break;
- case 12:
- tvcoridx = ddxLoadBitmap("tvcor_yellow.bmp", pBmpArchive);
- break;
- }
- for (i = 0; i < iLast; i++) {
- res[iAnim].iAnim[i][2] = x;
- res[iAnim].iAnim[i][3] = y;
- res[iAnim].iAnim[i][1] += (idx - 250);
- d = res[iAnim].iAnim[i][1];
- if (tvcoridx != -1 && res[iAnim].iAnim[i][0] != -1)
- ddxTransparentBlt(d, 0, 0, ddxGetWidth(d), ddxGetHight(d), tvcoridx,
- 0, 0, ddxGetWidth(tvcoridx), ddxGetHight(tvcoridx), TRANSCOLOR);
- //kprintf(1, "tv corrected to %d", res[iAnim].iAnim[i][1]);
- }
- if (tvcoridx != -1)
- ddxReleaseBitmap(tvcoridx);
- }
- void CreateBackButton(CMD_LINE * res, int *lastcmd, int sidx1, int sidx2,
- int xBack, int yBack)
- {
- int lcmd = *lastcmd;
- int i, ii;
- for (i = 0; i < lcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- res[i].uiTimerID = 0;
- res[i].iLastfrm = 1;
- res[i].iCounter = 0;
- /*
- (0, 123, 0, 640, 0, 1)
- (1, 124, 0, 640, 25, 2)
- (2, 124, 0, 640, 25, -1)
- */
- res[i].iAnim[0][0] = 0;
- res[i].iAnim[0][1] = sidx1;
- res[i].iAnim[0][2] = xBack;
- res[i].iAnim[0][3] = yBack;
- res[i].iAnim[0][4] = 0;
- res[i].iAnim[0][5] = 1;
- for (ii = 6; ii < 13; ii++)
- res[i].iAnim[0][ii] = -1;
- res[i].iAnim[1][0] = 1;
- res[i].iAnim[1][1] = sidx2;
- res[i].iAnim[1][2] = xBack;
- res[i].iAnim[1][3] = yBack;
- res[i].iAnim[1][4] = 50;
- res[i].iAnim[1][5] = 2;
- for (ii = 6; ii < 13; ii++)
- res[i].iAnim[1][ii] = -1;
- res[i].iAnim[2][0] = 2;
- res[i].iAnim[2][1] = sidx2;
- res[i].iAnim[2][2] = xBack;
- res[i].iAnim[2][3] = yBack;
- res[i].iAnim[2][4] = 50;
- res[i].iAnim[2][5] = -1;
- for (ii = 6; ii < 13; ii++)
- res[i].iAnim[2][ii] = -1;
- res[i].iLayer = 0;
- return;
- }
- }
- void DrawClock(int *iClock, int i)
- {
- if (iClock[i] == -1)
- return;
- spracuj_spravy(0);
- ddxSetCursorSurface(iClock[i]);
- ddxUpdateMouse();
- DisplayFrame();
- }
- int LoadClock(int *iClock)
- {
- int c = 0, i = -1, t;
- char text[256];
- FILE *file;
- file = aopen(pBmpArchive, "loadclock.txt", "r");
- if (!file)
- return -1;
- while (!aeof(file)) {
- ZeroMemory(text, 256);
- agets(text, 256, file);
- if (!strlen(text))
- break;
- text[strlen(text) - 1] = '\0';
- if (!c) {
- i = ddxLoadBitmap(text, pBmpArchive);
- iClock[c] = i;
- /* if(i != -1)
- {
- int x = dim.x - ftoi(ddxGetWidth(i) / 2.0f);
- int y = dim.y - ftoi(ddxGetHight(i) / 2.0f);
- ddxTransparentBltDisplay(x, y, ddxGetWidth(i), ddxGetHight(i), i, 0, 0, ddxGetWidth(i), ddxGetHight(i), TRANSCOLOR);
- }*/
- }
- else {
- t = ddxLoadBitmap(text, pBmpArchive);
- iClock[c] = t;
- }
- c++;
- }
- aclose(file);
- pBmpArchive->bError = 0;
- return i;
- }
- /*void MenuInitHint(char bTutorial)
- {
- if(bTutorial)
- _2d_hint.iSurface = ddxLoadBitmap("hint_frame.bmp", pBmpArchive);
- else
- _2d_hint.iSurface = -1;
- _2d_hint.iBSurface = -1;
- }
- void DrawHint(int x, int y)
- {
- RECT r;
- if(_2d_hint.iSurface == -1)
- return;
- _2d_hint.iBSurface = ddxCreateSurface(ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), ddxFindFreeSurface());
- if(_2d_hint.iBSurface == -1)
- return;
- if(x + ddxGetWidth(_2d_hint.iSurface) > 1014)
- x = 1014 - ddxGetWidth(_2d_hint.iSurface);
- _2d_hint.x = x;
- _2d_hint.y = y;
- ddxBitBlt(_2d_hint.iBSurface, 0, 0, ddxGetWidth(_2d_hint.iBSurface), ddxGetHight(_2d_hint.iBSurface), HDC2DD, x, y);
- ddxBitBlt(CompositDC, x, y, ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), _2d_hint.iSurface, 0, 0);
- ddxBitBltDisplay(x, y, ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), _2d_hint.iSurface, 0, 0);
- r.left = x;
- r.top = y;
- r.right = ddxGetWidth(_2d_hint.iSurface);
- r.bottom = ddxGetHight(_2d_hint.iSurface);
- _2d_Add_RectItem(&rline, r, 2);
- _2d_hint.bUsed = 1;
- }
- void SetHintRect(void)
- {
- RECT r;
- if(!_2d_hint.bUsed)
- return;
-
- r.left = _2d_hint.x;
- r.top = _2d_hint.y;
- r.right = ddxGetWidth(_2d_hint.iSurface);
- r.bottom = ddxGetHight(_2d_hint.iSurface);
- _2d_Add_RectItem(&rline, r, 2);
- }
- void UpdateHintBackup(void)
- {
- if(!_2d_hint.bUsed)
- return;
- if(_2d_hint.iSurface == -1)
- return;
- ddxBitBlt(CompositDC, _2d_hint.x, _2d_hint.y, ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), _2d_hint.iSurface, 0, 0);
- }
- void ReleaseHint(char bFull, char bRestore)
- {
- if(_2d_hint.iSurface != -1 && bFull)
- {
- ddxReleaseBitmap(_2d_hint.iSurface);
- _2d_hint.iSurface = -1;
- }
- if(_2d_hint.iBSurface != -1)
- {
- if(bRestore)
- {
- RECT r;
-
- r.left = _2d_hint.x;
- r.top = _2d_hint.y;
- r.right = r.left + ddxGetWidth(_2d_hint.iBSurface);
- r.bottom = r.top + ddxGetHight(_2d_hint.iBSurface);
- ddxFillRect(CompositDC, &r, RGB(255, 0, 255));
- ddxBitBltDisplay(_2d_hint.x, _2d_hint.y, ddxGetWidth(_2d_hint.iBSurface), ddxGetHight(_2d_hint.iBSurface),
- _2d_hint.iBSurface, 0, 0);
- }
- ddxReleaseBitmap(_2d_hint.iBSurface);
- _2d_hint.iBSurface = -1;
- }
- _2d_hint.bUsed = 0;
- }
- */
- void RunMenuSceneMap(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu,
- char *cSceneBmp, char *cSceneAnim, int iScene, int iLevelStart,
- int iNumOfLevels, char *cLevelList, int xTV, int yTV, char bLoadGame,
- char *cSaveFile, char bTutorial, int xBack, int yBack)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- int iBmp[12];
- int iTV = -1;
- int iClock[12];
- int cc = 0;
- char cscenemap[64];
- char csceneanim[64];
- char csrriptname[64];
- char cscenelevels[64];
- char bReload = 0;
- ZeroMemory(&_2d_hint, sizeof(_2D_HINT));
- for (i = 0; i < 12; i++)
- iClock[i] = -1;
- pPlayerProfile.cScene[iScene] = 1;
- pr_SaveProfile(&pPlayerProfile);
- ////////////////////////////LOAD GAME/////////////////////////////////////////
- if (bLoadGame) {
- sprintf(dir, "%s.lv6", cSaveFile);
- if (RunLevel(NULL, p_ad, cpu, dir, "LOAD_GAME") == 1) {
- pPlayerProfile.cLevel[iActualLevel] = 1;
- pr_SaveProfile(&pPlayerProfile);
- }
- for (i = 0; i < 32; i++)
- anm[i].cmd = NULL;
- //TODO - pokud se jedna o tutorial, detskou ci custom, tak to crushne .... proc?
- }
- ////////////////////////////LOAD GAME/////////////////////////////////////////
- LoadClock(iClock);
- if (iClock[0] != -1) {
- ddxResizeCursorBack(iClock[0]);
- DrawClock(iClock, 0);
- }
- for (i = 0; i < 12; i++)
- iBmp[i] = -1;
- bBackDC = 0;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuSceneMap: Out of Memory");
- return;
- }
- BRUTAL_RESTART_SCENE_MAP_MENU:
- bReload = 1;
- bBackDC = 0;
- _2d_Clear_RectLine(&rline);
- ddxSetFlip(TRUE);
- cc = 0;
- iTV = -1;
- anmid = -1;
- resid = -1;
- anbind = -1;
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- GetRunMenuNewGameSceneLoadGame(csrriptname, cscenemap, csceneanim,
- cscenelevels, &iLevelStart, &iNumOfLevels, &xTV, &yTV, &bTutorial, &xBack,
- &yBack);
- LoadSceneMap(iBmp, cscenemap, csceneanim, iActualScene, iClock);
- ddxCleareSurface(CompositDC);
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].pCmdLine = res;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(csrriptname, res, &lastcmd);
- DrawClock(iClock, 7);
- in = 0;
- ddxBitBlt(BackDC, 0, 0, 1024, 768, iBmp[0], 0, 0);
- CreateLevelButtons(res, &lastcmd, iBmp, iActualScene, iLevelStart,
- iNumOfLevels, cscenelevels, bTutorial);
- DrawClock(iClock, 8);
- if (!bTutorial) {
- iTV = LoadTV();
- if (iTV == -1)
- kprintf(1, "Saaakra ... neporalo se nahrat bmpka televize");
- }
- DrawClock(iClock, 9);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer)
- ddxDrawSurface(BackDC, res[i].iParam, 0);
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- file = aopen(pDataArchive, res[i].cParam[0], "r");
- if (file) {
- while (!aeof(file)) {
- Parse_AnimLine(file, res[i].iAnim[lastanm], 18);
- if (!cc)
- res[i].iAnim[lastanm][1] = iBmp[res[i].iAnim[lastanm][1]];
- lastanm++;
- }
- if (!cc)
- res[i].iLayer = 10;
- else if (!bTutorial)
- CorrectTV(res, i, lastanm, xTV, yTV, iTV, iActualScene);
- aclose(file);
- }
- cc++;
- break;
- }
- }
- DrawClock(iClock, 10);
- CreateBackButton(res, &lastcmd, iBmp[8], iBmp[9], xBack, yBack);
- // MenuInitHint(bTutorial);
- ddxResizeCursorBack(0);
- ddxSetCursorSurface(0);
- for (i = 0; i < 12; i++)
- if (iClock[i] != -1) {
- ddxReleaseBitmap(iClock[i]);
- iClock[i] = -1;
- }
- ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
- ddxCleareSurface(BackDC);
- //BEGIN_MENU_NEWGAMESCENE:
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- if (res[lastabv].iAnim[0][0] != -1) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- // ReleaseHint(0, 1);
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- /* if(bTutorial)
- DrawHint(res[lastabv].iAnim[0][2], res[lastabv].iAnim[0][3] - 35);*/
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (res[i].iAnim[0][0] != -1) {
- if (!res[i].iLayer) {
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[anbind].iLayer) {
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- // ReleaseHint(0, 1);
- }
- //dim.dx = 0;
- //dim.dy = 0;
- }
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- key[K_ESC] = 1;
- cRestartMainMenu = 1;
- //break;
- }
- else {
- char cLevel[256];
- iActualLevel = iLevelStart + atoi(res[resid].cParam[1]) - 1;
- // ReleaseHint(1, 0);
- kprintf(1, "Kliknuto na level : %s", res[resid].cParam[1]);
- sprintf(cLevel, "level%d.lv6", iActualLevel);
- if (RunLevel(NULL, p_ad, cpu, cLevel, "RUN_LEVEL") == 1) {
- pPlayerProfile.cLevel[iActualLevel] = 1;
- pr_SaveProfile(&pPlayerProfile);
- }
- for (i = 0; i < 32; i++)
- anm[i].cmd = NULL;
- bReload = 0;
- if (bNewScene)
- key[K_ESC] = 1;
- else
- goto BRUTAL_RESTART_SCENE_MAP_MENU;
- }
- resid = -1;
- if (key[K_ESC]) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- StopAll();
- FreeAnimations(res, RES_NUM);
- goto BRUTAL_RESTART_SCENE_MAP_MENU;
- }
- }
- __QUIT:
- /*
- adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
- adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
- */
- StopAll();
- if (bReload) {
- for (i = 0; i < 12; i++)
- ddxReleaseBitmap(iBmp[i]);
- if (!bTutorial)
- for (i = iTV; i < iTV + 91; i++)
- ddxReleaseBitmap(i);
- }
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- ddxCleareSurface(CompositDC);
- cRestartMainMenu = 1;
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- int RunMenuNewGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- int ret = 0;
- int c = 0;
- CONTROL_LIST_ITEM citem[CLIST_ITEMC];
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- char bDone = 0;
- int inumofitems = 0;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuNewGame: Out of Memory");
- return 0;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- bBackDC = 0;
- ddxCleareSurface(BackDC);
- ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0, 0);
- ddxCleareSurface(FontDC);
- //kprintf(1, "bitblt");
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- fn_Set_Font(cFontFile[0]);
- fn_Load_Bitmaps();
- CreateFontAnimations(res, &lastcmd);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- {
- if (!c) {
- RECT rr;
- ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
- ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
- res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
- rr.left = res[i].iParam[2];
- rr.top = res[i].iParam[3];
- rr.right = ddxGetWidth(res[i].iParam[1]);
- rr.bottom = ddxGetHight(res[i].iParam[1]);
- _2d_Add_RectItem(&rline, rr, 0);
- }
- else
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- c++;
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- if (co_Load_Graphic(1)) {
- int xx, sel = -1;
- RECT r;
- r.left = 299;
- r.top = 209;
- r.right = 743;
- r.bottom = 359;
- co_Set_Text_Center(BackDC, "##mainmenu_player_name", 0, r);
- r.top = 359;
- r.bottom = 509;
- co_Set_Text_Center(BackDC, "##mainmenu_new_player_name", 0, r);
- fn_Release_Font(1);
- fn_Set_Font(cFontFile[2]);
- fn_Load_Bitmaps();
- citem[0].p_edit = co_Create_Edit(BackDC, 360, 470, 0);
- citem[0].bActive = 1;
- citem[1].p_combo = co_Create_Combo(BackDC, 360, 320, 100, 0);
- citem[1].bActive = 1;
- xx = FillComboProfiles(citem[1].p_combo, &sel);
- if (xx > 5)
- co_Combo_Set_Params(citem[1].p_combo, 5);
- else
- co_Combo_Set_Params(citem[1].p_combo, xx);
- kprintf(1, "set_sel %d", sel);
- co_Combo_Set_Sel(BackDC, citem[1].p_combo, sel);
- inumofitems = xx;
- if (!inumofitems)
- citem[0].p_edit->bActive = 1;
- }
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- bBackDC = 1;
- BEGIN_MENU_NEWGAME:
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!bDone) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click) {
- for (i = 0; i < lastcmd; i++) {
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- co_Handle_Controls(citem, CLIST_ITEMC, dim.x, dim.y, BackDC, 0, 0);
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++) {
- if (res[i].iParam[0] == COM_ONCLICK) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click || key[K_ENTER])
- if (!anm[anmid].cmd || key[K_ENTER]) {
- click = 0;
- if (key[K_ENTER])
- goto MENU_ENTER;
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- bDone = 1;
- }
- if (!strcmp(res[resid].cParam[1], "OK")) {
- int c;
- WCHAR *pName;
- MENU_ENTER:
- c = 0;
- pName = co_Edit_Get_Text(citem[0].p_edit);
- key[K_ENTER] = 0;
- if (!wcslen(pName)) {
- int iComboActSel = co_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 0);
- kprintf(1, "%d", iComboActSel);
- if (iComboActSel != -1) {
- if (citem[1].p_combo->pItem) {
- if (citem[1].p_combo->pItem[iComboActSel].text) {
- if (pr_ReadProfile(citem[1].p_combo->pItem[iComboActSel].text, &pPlayerProfile)) {
- WritePrivateProfileString("hra", "last_profile",citem[1].p_combo->pItem[iComboActSel].text, ini_file);
- c++;
- }
- }
- }
- }
- }
- else if (pr_CreateProfile(pName))
- c++;
- if (c) {
- iActualScene = 1;
- bDone = 1;
- }
- }
- resid = -1;
- if (bDone) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- else
- goto BEGIN_MENU_NEWGAME;
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- fn_Release_Font(0);
- free((void *) res);
- return 1;
- }
- }
- __QUIT:
- ddxCleareSurface(FontDC);
- ddxCleareSurface(CompositDC);
- bBackDC = 0;
- ddxCleareSurface(BackDC);
- fn_Release_Font(1);
- co_Handle_Release(citem, CLIST_ITEMC);
- co_Release_Graphic();
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- return ret;
- }
- char check_profile(char *p_name)
- {
- WCHAR wc[128];
- MultiByteToWideChar(CP_ACP, 0, p_name, strlen(p_name) + 1, wc,
- sizeof(wc) / sizeof(wc[0]));
- if (!wcscmp(pPlayerProfile.cName, wc))
- return 1;
- else
- return 0;
- }
- int compare(const void *arg1, const void *arg2)
- {
- LIST_ITEM_ *pP1 = (LIST_ITEM_ *) arg1;
- LIST_ITEM_ *pP2 = (LIST_ITEM_ *) arg2;
- return pP2->timespamp - pP1->timespamp;
- }
- #ifdef LINUX
- static char *p_file_mask;
- static int filter(const struct dirent *file)
- {
- return(!fnmatch(p_file_mask, file->d_name, 0));
- }
-
- int FillStringList(char *cmask, LIST_ITEM_ ** list, int *isize)
- {
- struct dirent **namelist;
- int i;
- struct stat sb;
-
- p_file_mask = cmask;
- int c = scandir(".", &namelist, &filter, alphasort);
-
- if (c < 0) {
- (*isize) = 0;
- return 0;
- }
- (*list) = (LIST_ITEM_ *) malloc(c * sizeof(LIST_ITEM_));
- memset((*list), 0, c * sizeof(LIST_ITEM_));
- for(i = 0; i < c; i++) {
- strcpy((*list)[i].text, namelist[i]->d_name);
- (*list)[c].timespamp = !stat(namelist[i]->d_name, &sb) ? sb.st_mtime : 0;
- free(namelist[i]);
- }
- free(namelist);
-
- qsort((*list), c, sizeof(LIST_ITEM_), compare);
- (*isize) = c;
- return c;
- }
- #endif
- int FillComboProfiles(COMBO_CONTROL * p_co, int *iSel)
- {
- int retsel = 0;
- char cprofile[128];
- char dir[256];
- WCHAR wName[256];
- PLAYER_PROFILE Profile;
- int c = 0;
- int x = 0;
- LIST_ITEM_ *list;
- int isize;
- GetPrivateProfileString("game", "profile_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- GetPrivateProfileString("hra", "last_profile", "c:\\", cprofile, 128,
- ini_file);
- chdir((dir));
- FillStringList("*.prf", &list, &isize);
- if (!isize)
- return 0;
- for (c = 0; c < isize; c++) {
- ZeroMemory(wName, 256 * sizeof(WCHAR));
- if (pr_GetPlayerName(list[c].text, wName)) {
- co_Combo_Add_StringWC2(p_co, wName, list[c].text);
- if ((*iSel) == -1) //new game -> nastavit profil, kterej byl hran naposed
- {
- if (!strcmp(cprofile, list[c].text)) {
- retsel = x;
- pr_ReadProfile(list[c].text, &Profile);
- }
- }
- if (!x)
- pr_ReadProfile(list[c].text, &Profile);
- x++;
- }
- }
- memcpy(&pPlayerProfile, &Profile, sizeof(PLAYER_PROFILE));
- *iSel = retsel;
- if ((*iSel) < 0)
- (*iSel) = 0;
- free((void *) list);
- return x;
- }
- int check_Save_Owner(char *cDir, WCHAR * wFileName)
- {
- char text[256];
- FILE *file;
- PLAYER_PROFILE pProfile;
- LEVEL_HEADER l_h;
- char dir[MAX_PATH + 1];
- WCHAR wdir[MAX_PATH + 1];
- int ver;
- getcwd(dir, MAX_PATH);
- chdir((cDir));
- ZeroMemory(&pProfile, sizeof(PLAYER_PROFILE));
- strcpy(text, cDir);
- strcat(text, ".lvc");
- file = fopen(text, "rb");
- if (!file) {
- chdir((dir));
- return 0;
- }
- fread(&pProfile, sizeof(PLAYER_PROFILE), 1, file);
- fread(wFileName, 32 * sizeof(WCHAR), 1, file);
- fread(&ver, sizeof(int), 1, file);
- if (ver != SAVE_VER) {
- fclose(file);
- return 0;
- }
- fread(wdir, (MAX_PATH + 1) * sizeof(WCHAR), 1, file);
- fread(&l_h, sizeof(LEVEL_HEADER), 1, file);
- fclose(file);
- chdir((dir));
- if (wcscmp(pPlayerProfile.cName, pProfile.cName))
- return 0;
- if (iLanguageVersion == 4) {
- sprintf(dir, "scene%d", l_h.rezerved[1]);
- if (!GetPrivateProfileInt("Internet", dir, 0, ini_file))
- return 0;
- }
- return 1;
- }
- int FillListLoad(LIST_VIEW_CONTROL * p_li, char *mask, char bAdd,
- int LoadGame)
- {
- char dir[256];
- WCHAR wFile[128];
- int x = 0;
- int c = 0;
- LIST_ITEM_ *list;
- int isize;
- GetPrivateProfileString("game", "save_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- FillStringList(mask, &list, &isize);
- if (!isize)
- return 0;
- for (c = 0; c < isize; c++) {
- ZeroMemory(wFile, 128 * sizeof(WCHAR));
- if (!LoadGame) {
- if (!demo_Check_Owner(pPlayerProfile.cName, list[c].text, wFile))
- continue;
- }
- else if (!check_Save_Owner(list[c].text, wFile))
- continue;
- if (bAdd)
- co_List_Add_StringWC2(p_li, x, 2, wFile, list[c].text, x, 0);
- x++;
- }
- free((void *) list);
- return x;
- }
- void CreateLevelCommandLine(char *cLevel, char *cLine)
- {
- sprintf(cLine, "%s.lv6 fp:%s", cLevel, cLevel);
- }
- void RunMenuLoadGameLoad(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
- int cpu, int LoadGame)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- int c = 0;
- int idx;
- int hdcBT;
- RECT r;
- LIST_VIEW_CONTROL *p_li;
- PLAYER_PROFILE pOldProfile;
- CONTROL_LIST_ITEM citem[CLIST_ITEMC];
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- //CMD_LINE res[RES_NUM];
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- // int iComboSel = 0;
- // int iComboActSel = 0;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuLoadGameLoad: Out of Memory");
- return;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- ddxCleareSurface(FontDC);
- // ddxCleareSurface(BackDC);
- bBackDC = 0;
- memcpy(&pOldProfile, &pPlayerProfile, sizeof(PLAYER_PROFILE));
- //kprintf(1, "bitblt");
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- //kprintf(1, "load");
- in = 0;
- fn_Set_Font(cFontFile[0]);
- fn_Load_Bitmaps();
- //kprintf(1, "fn_Set_Font");
- CreateFontAnimations(res, &lastcmd);
- //fn_Release_Font();
- //kprintf(1, "CreateFontAnimations");
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- {
- if (!c) {
- /* hdcBT = fn_CreateDC(_2dd.hDC, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight, _2d_Find_Free_Surface());*/
- hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
- /*BitBlt(BackDC,res[i].iParam[2], res[i].iParam[3], _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
- _2dd.bitmap[res[i].iParam[1]].bitmapDC, 0, 0, SRCCOPY); */
- ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
- ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
- res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
- /*BitBlt(hdcBT, 0, 0, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
- _2dd.hDC, res[i].iParam[2], res[i].iParam[3], SRCCOPY); */
- ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]),
- HDC2DD, res[i].iParam[2], res[i].iParam[3]);
- //menucommand_DrawT(_2dd.hDC, res[i].iParam);
- idx = i;
- }
- else {
- //menucommand_DrawT(BackDC, res[i].iParam);
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- }
- //menucommand_DrawT(_2dd.hDC, res[i].iParam);
- c++;
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- //co_Load_Graphic(1);
- //co_List_Redraw(Ltmp1DC, llcitem[1].p_list, 0);
- if (!co_Load_Graphic(1))
- assert(0);
- else {
- int xx, sel = 0;
- r.left = 299;
- r.top = 209;
- r.right = 743;
- r.bottom = 359;
- if (LoadGame)
- co_Set_Text_Center(BackDC, "##menu_loadgame", 0, r);
- else
- co_Set_Text_Center(BackDC, "##menu_playdemo", 0, r);
- fn_Release_Font(1);
- fn_Set_Font(cFontFile[2]);
- fn_Load_Bitmaps();
- /* citem[0].p_combo = co_Create_Combo(BackDC, 360, 320, 100, 0);
- citem[0].bActive = 1;
- xx = FillComboProfiles(citem[0].p_combo, &sel);
- if(xx > 5)
- co_Combo_Set_Params(citem[0].p_combo, 5);
- else
- co_Combo_Set_Params(citem[0].p_combo, xx);
- co_Combo_Set_Sel(BackDC, citem[0].p_combo, sel);*/
- if (LoadGame) {
- xx = FillListLoad(NULL, "*", 0, LoadGame);
- if (xx < 7)
- xx = 7;
- citem[1].p_list = co_Create_List(BackDC, 360, 320, 320, 200, 0, xx, 1);
- citem[1].bActive = 1;
- FillListLoad(citem[1].p_list, "*", 1, LoadGame);
- }
- else {
- xx = FillListLoad(NULL, "*.dem", 0, LoadGame);
- if (xx < 7)
- xx = 7;
- citem[1].p_list = co_Create_List(BackDC, 360, 320, 320, 200, 0, xx, 1);
- citem[1].bActive = 1;
- FillListLoad(citem[1].p_list, "*.dem", 1, LoadGame);
- }
- co_List_Redraw(BackDC, citem[1].p_list, 0);
- fn_Release_Font(1);
- }
- //BEGIN_MENU:
- bBackDC = 1;
- //TransparentBltU(BackDC, 0, 0, 1024, 768, Ltmp1DC, 0, 0, 1024, 768, RGB(255, 0, 255));
- // ddxTransparentBlt(BackDC, 0, 0, 1024, 768, Ltmp1DC, 0, 0, 1024, 768, TRANSCOLOR);
- //Sleep(10000);
- //TransparentBltU(_2dd.hDC, 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, RGB(255, 0, 255));
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[i].iAnim[0]);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- co_Handle_Controls(citem, CLIST_ITEMC, dim.x, dim.y, BackDC, 0, 0);
- //////////////LOAD LEVEL/DEMO ///////////////////////////////////////////////////
- if (co_List_Get_Dbclck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
- if (p_li->piValue[p_li->cSelected].cValue)
- if (strlen(p_li->piValue[p_li->cSelected].cValue)) {
- //citem[0].bActive = 0;
- citem[1].bActive = 0;
- if (LoadGame) //LOAD GAME
- {
- //fn_Release_Font(1);
- StopAll();
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 1,
- p_li->piValue[p_li->cSelected].cValue, 0);
- fn_Set_Font("font_system.pak");
- fn_Load_Bitmaps();
- key[K_ESC] = 1;
- }
- else //LOAD DEMO
- {
- char ctext[256];
- CreateLevelCommandLine(p_li->piValue[p_li->cSelected].cValue,
- ctext);
- demo_Set_Scene_Level(p_li->piValue[p_li->cSelected].cValue,
- &iActualScene, &iActualLevel);
- RunLevel(NULL, p_ad, cpu, ctext, "LOAD_DEMO");
- for (i = 0; i < 32; i++)
- anm[i].cmd = NULL;
- key[K_ESC] = 1;
- }
- p_li->bDblClck = 0;
- p_li->bClck = 0;
- }
- }
- /* iComboActSel = co_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 0);
- if(iComboActSel != iComboSel && iComboActSel != -1)
- {
- int xx;
- pr_ReadProfile(citem[0].p_combo->pItem[iComboActSel].text, &pPlayerProfile);
- if(LoadGame)
- {
- xx = FillListLoad(NULL, "*", 0, LoadGame);
-
- if(xx < 4)
- xx = 4;
- co_Cleare_List(citem[1].p_list, xx, BackDC, 0, 0);
- FillListLoad(citem[1].p_list, "*", 1, LoadGame);
- }
- else
- {
- xx = FillListLoad(NULL, "*.dem", 0, LoadGame);
-
- if(xx < 4)
- xx = 4;
- co_Cleare_List(citem[1].p_list, xx, BackDC, 0, 0);
- FillListLoad(citem[1].p_list, "*.dem", 1, LoadGame);
- }
-
- co_List_Redraw(BackDC, citem[1].p_list, 0);
- iComboSel = iComboActSel;
- }
- */
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "CANCEL")) {
- memcpy(&pPlayerProfile, &pOldProfile, sizeof(PLAYER_PROFILE));
- key[K_ESC] = 1;
- }
- if (!strcmp(res[resid].cParam[1], "EXIT"))
- key[K_ESC] = 1;
- if (!strcmp(res[resid].cParam[1], "OK") && p_li->cClckSel != -1) {
- if (p_li->piValue[p_li->cClckSel].cValue)
- if (strlen(p_li->piValue[p_li->cClckSel].cValue)) {
- citem[0].bActive = 0;
- citem[1].bActive = 0;
- if (LoadGame) //LOAD GAME
- {
- //fn_Release_Font(1);
- StopAll();
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu,
- 1, p_li->piValue[p_li->cClckSel].cValue, 0);
- //fn_Set_Font("font_system.pak");
- //fn_Load_Bitmaps();
- key[K_ESC] = 1;
- }
- else //LOAD DEMO
- {
- char ctext[256];
- CreateLevelCommandLine(p_li->piValue[p_li->cClckSel].cValue,
- ctext);
- demo_Set_Scene_Level(p_li->piValue[p_li->cClckSel].cValue,
- &iActualScene, &iActualLevel);
- RunLevel(NULL, p_ad, cpu, ctext, "LOAD_DEMO");
- for (i = 0; i < 32; i++)
- anm[i].cmd = NULL;
- key[K_ESC] = 1;
- }
- p_li->bDblClck = 0;
- p_li->bClck = 0;
- }
- }
- resid = -1;
- if (key[K_ESC]) {
- /* for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- cRestartMainMenu = 1;
- key[K_ESC] = 1;
- }
- }
- __QUIT:
- if (!cBrutalRestart) {
- ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
- ddxTransparentBlt(BackDC, res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]),
- res[idx].iParam[1], 0, 0, ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), TRANSCOLOR);
- ddxReleaseBitmap(hdcBT);
- ddxCleareSurface(FontDC);
- co_Handle_Release(citem, CLIST_ITEMC);
- co_Release_Graphic();
- }
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- void RunMenuLoadGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- RECT r;
- int c = 0;
- int idx;
- int hdcBT;
- CONTROL_LIST_ITEM citem[CLIST_ITEMC];
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- //CMD_LINE res[RES_NUM];
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- int iNadpisDC = -1;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuLoadGame: Out of Memory");
- return;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- //bBackDC = 1;
- // ddxCleareSurface(FontDC);
- // ddxCleareSurface(BackDC);
- ddxCleareSurface(BackDC);
- ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0,
- 0);
- ddxCleareSurface(FontDC);
- //kprintf(1, "bitblt");
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- //kprintf(1, "load");
- in = 0;
- fn_Set_Font(cFontFile[0]);
- fn_Load_Bitmaps();
- //kprintf(1, "fn_Set_Font");
- CreateFontAnimations(res, &lastcmd);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- {
- if (!c) {
- hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
- ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]),
- HDC2DD, res[i].iParam[2], res[i].iParam[3]);
- ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
- ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
- res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
- idx = i;
- }
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- }
- c++;
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- r.left = 299;
- r.top = 209;
- r.right = 743;
- r.bottom = 359;
- co_Set_Text_Center(BackDC, "##menu_lgametitle", 0, r);
- iNadpisDC =
- ddxCreateSurface(r.right - r.left, r.bottom - r.top,
- ddxFindFreeSurface());
- ddxBitBlt(iNadpisDC, 0, 0, ddxGetWidth(iNadpisDC), ddxGetHight(iNadpisDC),
- BackDC, r.left, r.top);
- fn_Release_Font(1);
- BEGIN_MENU_LOAD:
- bBackDC = 1;
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- DisplayFrame();
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[i].iAnim[0]);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- //co_Handle_Controls(citem, CLIST_ITEMC, mi.x, mi.y);
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- key[K_ESC] = 1;
- //break;
- }
- if (!strcmp(res[resid].cParam[1], "LOAD_GAME_LOAD"))
- RunMenuLoadGameLoad("Mmload_game_load.txt", NULL, p_ad, cpu, 1);
- if (!strcmp(res[resid].cParam[1], "LOAD_GAME_DEMO"))
- RunMenuLoadGameLoad("Mmload_game_load.txt", NULL, p_ad, cpu, 0);
- if (cBrutalRestart)
- key[K_ESC] = 1;
- if (!cBrutalRestart) {
- for (i = 0; i < lastcmd; i++) {
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iParam);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- }
- }
- ddxTransparentBltDisplay(r.left, r.top, ddxGetWidth(iNadpisDC),
- ddxGetHight(iNadpisDC), iNadpisDC, 0, 0, ddxGetWidth(iNadpisDC),
- ddxGetHight(iNadpisDC), TRANSCOLOR);
- ddxTransparentBlt(BackDC, r.left, r.top, ddxGetWidth(iNadpisDC),
- ddxGetHight(iNadpisDC), iNadpisDC, 0, 0, ddxGetWidth(iNadpisDC),
- ddxGetHight(iNadpisDC), TRANSCOLOR);
- }
- resid = -1;
- if (key[K_ESC]) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- else
- goto BEGIN_MENU_LOAD;
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- /*spracuj_spravy(0);
- ddxUpdateMouse();
- if(dim.dx || dim.dy)
- DisplayFrame(); */
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- cRestartMainMenu = 1;
- key[K_ESC] = 1;
- }
- }
- __QUIT:
- //BitBltU(FontDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
- ddxCleareSurface(FontDC);
- //TransparentBltU(_2dd.hDC, 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, RGB(255, 0, 255));
- if (!cBrutalRestart)
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- //BitBltU(BackDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
- ddxCleareSurface(BackDC);
- bBackDC = 0;
- /*BitBlt(_2dd.hDC, res[idx].iParam[2], res[idx].iParam[3],
- _2dd.bitmap[res[idx].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[idx].iParam[1]].bitmap.bmHeight,
- hdcBT, 0, 0, SRCCOPY); */
- if (!cBrutalRestart) {
- ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
- ddxTransparentBlt(BackDC, res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]),
- res[idx].iParam[1], 0, 0, ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), TRANSCOLOR);
- ddxReleaseBitmap(hdcBT);
- ddxReleaseBitmap(iNadpisDC);
- }
- ddxCleareSurface(CompositDC);
- //fn_Release_Font();
- //co_Handle_Release(citem, CLIST_ITEMC);
- //co_Release_Graphic();
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- void RunMenuCibron(char *cBmp)
- {
- int idx = ddxCreateSurface(1024, 768, ddxFindFreeSurface());
- int cib;
- if (idx == -1)
- return;
- ddxBitBlt(idx, 0, 0, 1024, 768, HDC2DD, 0, 0);
- cib = ddxLoadBitmap(cBmp, pBmpArchive);
- if (cib == -1) {
- ddxReleaseBitmap(idx);
- return;
- }
- ddxBitBltDisplay(0, 0, 1024, 768, cib, 0, 0);
- DisplayFrame();
- while (!key[0] && !dim.t1 && !dim.t2) {
- spracuj_spravy(0);
- ddxUpdateMouse();
- DisplayFrame();
- Sleep(10);
- }
- dim.tf1 = 0;
- dim.tf2 = 0;
- dim.t1 = 0;
- dim.t2 = 0;
- memset(key, 0, POCET_KLAVES * sizeof(char));
- ddxBitBlt(HDC2DD, 0, 0, 1024, 768, idx, 0, 0);
- ddxReleaseBitmap(idx);
- ddxReleaseBitmap(cib);
- }
- void RunMenuCinemax(void)
- {
- int c = 0;
- int cib;
- pBmpArchive->pActualNode = pBmpArchive->pRootNode->pNextNode;
- cib = ddxLoadBitmap("cinemax.bmp", pBmpArchive);
- if (cib == -1) {
- pBmpArchive->bError = 0;
- return;
- }
- ddxSetCursor(0);
- ddxSetFlip(0);
- ddxBitBltDisplay(0, 0, 1024, 768, cib, 0, 0);
- DisplayFrame();
- ddxBitBltDisplay(0, 0, 1024, 768, cib, 0, 0);
- while (!key[0] && !dim.t1 && !dim.t2) {
- Sleep(10);
- c += 10;
- if (c > 1000)
- break;
- }
- dim.tf1 = 0;
- dim.tf2 = 0;
- dim.t1 = 0;
- dim.t2 = 0;
- memset(key, 0, POCET_KLAVES * sizeof(char));
- ddxReleaseBitmap(cib);
- ddxSetCursor(1);
- ddxSetFlip(1);
- }
- void RunMenuDrawVersion(int iSurface)
- {
- char text[256];
- sprintf(text, "v%d.%d", VERZEHI, VERZELO);
- //co_Set_Text_RightWC(HDC2DD, text, 1, 990, 318);
- co_Set_Text_RightWC(HDC2DD, text, 0, 1024, 0);
- //co_Set_Text(HDC2DD, 280, 0, "##sale", 0);
- co_Set_Text_RightWC(iSurface, text, 0, 1024, 0);
- //co_Set_Text(iSurface, 280, 0, "##sale", 0);
- }
- void RunMenuDrawDemoEndScreen(void)
- {
- int idx;
- ddxSetFlip(1);
- key[0] = 0;
- idx = ddxLoadBitmap("final_screen.bmp", pBmpArchive);
- if (idx == -1)
- return;
- ddxSetCursor(1);
- ddxBitBltDisplay(0, 0, 1024, 768, idx, 0, 0);
- ddxSetFlip(0);
- while (!key[0] && !mi.t1 && !mi.t2) {
- Sleep(25);
- spracuj_spravy(1);
- ddxUpdateMouse();
- if (mi.dx || mi.dy)
- DisplayFrame();
- }
- ddxReleaseBitmap(idx);
- ddxSetCursor(0);
- }
- //------------------------------------------------------------------------------------------------
- // spusti menu
- //------------------------------------------------------------------------------------------------
- void RunMenu(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- char bStop = 1;
- char dir[256];
- int lastcmd, lastanm, i, j;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- int cStartCount = 0;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenu: Out of Memory");
- return;
- }
- RUN_MENU_BRUTAL_RESTART:
- ZeroAnimations();
- bNewScene = 0;
- cRestartMainMenu = 0;
- if (cBrutalRestart) {
- fn_Set_Font(cFontFile[0]);
- fn_Load_Bitmaps();
- for (i = 0; i < 32; i++)
- anm[i].cmd = NULL;
- cRestartMainMenu = 1;
- }
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- if (!cBrutalRestart) {
- iCompositDC = ddxFindFreeSurface();
- CompositDC = ddxCreateSurface(1024, 768, iCompositDC);
- iFontDC = ddxFindFreeSurface();
- FontDC = ddxCreateSurface(1024, 768, iFontDC);
- iBackDC = ddxFindFreeSurface();
- BackDC = ddxCreateSurface(1024, 768, iBackDC);
- }
- cBrutalRestart = 0;
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- CreateFontAnimations(res, &lastcmd);
- fn_Release_Font(1);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- fn_Set_Font(cFontFile[2]);
- fn_Load_Bitmaps();
- ddxSetFlip(0);
- for (j = 0; j < 2; j++) {
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer)
- ddxDrawDisplay(res[i].iParam, 0);
- else {
- ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- if (!j)
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- RunMenuDrawVersion(res[0].iParam[1]);
- DisplayFrame();
- }
- fn_Release_Font(1);
- ddxSetFlip(1);
- BEGIN_MENU:
- if (bStop || cRestartMainMenu)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- kprintf(1, "COM_RUNANIMATION = %d, iWAVE = %d", i, iWave);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- if (!cStartCount) {
- int idx = ddxCreateSurface(1024, 768, ddxFindFreeSurface());
- if (idx == -1)
- exit(0);
- ddxBitBlt(idx, 0, 0, 1024, 768, HDC2DD, 0, 0);
- if (RunMenuNewGame("Mmnew_game.txt", NULL, p_ad, cpu)) {
- //ddxReleaseBitmap(idx);
- goto RUN_MENU_BRUTAL_RESTART;
- }
- ddxBitBltDisplay(0, 0, 1024, 768, idx, 0, 0);
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (res[i].iLayer)
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- break;
- }
- }
- ddxReleaseBitmap(idx);
- cStartCount = 1;
- }
- cRestartMainMenu = 0;
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1; // posledni animace -> co bezi?
- in = 0;
- bStop = 1;
- spracuj_spravy(0);
- dwEplased = 0;
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- // There's already running one - stop it
- Stop(&res[lastabv]);
- // Draw frame 0 -> clear the animation from screen
- if (!res[lastabv].iLayer) {
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- }
- else {
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
- //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i; // set last animation
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- ddxDrawDisplay(res[i].iAnim[0], 0);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
- //menucommand_Draw(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- }
- else {
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
- //menucommand_Draw(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- if (!strcmp(res[resid].cParam[1], "NEW_GAME") ||
- !strcmp(res[resid].cParam[1], "LOAD_GAME") ||
- !strcmp(res[resid].cParam[1], "PLAYER_NAME"))
- bStop = 0;
- if (bStop)
- StopAll();
- if (!strcmp(res[resid].cParam[1], "CIBRA")) {
- StopAll();
- RunMenuCibron("cibra.bmp");
- click = 0;
- }
- if (!strcmp(res[resid].cParam[1], "EXIT"))
- key[K_ESC] = 1;
- if (!strcmp(res[resid].cParam[1], "PLAYER_NAME")) {
- if (RunMenuNewGame("Mmnew_game.txt", NULL, p_ad, cpu))
- goto RUN_MENU_BRUTAL_RESTART;
- bStop = 1;
- }
- if (!strcmp(res[resid].cParam[1], "CREDITS")) {
- int lid = GetPrivateProfileInt("game", "languageid", 0, ini_file);
- StopAll();
- bStop = 1;
- if (lid < 2 || lid == 4) {
- if (cr_Credits(NULL, p_ad))
- goto RUN_MENU_BRUTAL_RESTART;
- }
- else {
- if (cr_CreditsUNI(NULL, p_ad))
- goto RUN_MENU_BRUTAL_RESTART;
- }
- }
- if (!strcmp(res[resid].cParam[1], "NEW_GAME")) {
- //RunMenuNewGame("Mmnew_game.txt", hWnd, p_ad, cpu);
- RunMenuStartGame("Mmstart_game.txt", NULL, p_ad, cpu);
- if (cBrutalRestart)
- goto RUN_MENU_BRUTAL_RESTART;
- }
- if (!strcmp(res[resid].cParam[1], "LOAD_GAME")) {
- RunMenuLoadGame("Mmload_game.txt", NULL, p_ad, cpu);
- if (cBrutalRestart)
- goto RUN_MENU_BRUTAL_RESTART;
- }
- if (!strcmp(res[resid].cParam[1], "SETTINGS")) {
- RunMenuSettings("Mmsettings.txt", NULL, p_ad, cpu);
- if (cBrutalRestart)
- goto RUN_MENU_BRUTAL_RESTART;
- cRestartMainMenu = 1;
- }
- if (bStop || cRestartMainMenu)
- StopAll();
- for (i = 0; i < lastcmd; i++) {
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer) {
- if (bStop || cRestartMainMenu)
- ddxDrawSurface(BackDC, res[i].iParam, 0);
- }
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- }
- }
- if (cRestartMainMenu || bStop) {
- ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
- ddxCleareSurface(BackDC);
- }
- resid = -1;
- if (key[K_ESC]) {
- /* for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- else
- goto BEGIN_MENU;
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++) {
- if (res[i].iParam[0] == COM_RANDOMANIMATION) {
- if (rand() % 200 <= res[i].iParam[1] && strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad))
- goto RUN_MENU_BRUTAL_RESTART;
- // updatuj_pozici_mysi();
- }
- __QUIT:
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- //fn_Release_Font();
- adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
- adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
- */
- StopAll();
- ddxReleaseBitmap(iCompositDC);
- ddxReleaseBitmap(iFontDC);
- ddxReleaseBitmap(iBackDC);
- //ddxReleaseBitmap(Ltmp1DC);
- // free((void *) llcitem);
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- void RunMenuChildGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
- int cpu)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- int c = 0;
- int idx;
- int hdcBT;
- CONTROL_LIST_ITEM citem[CLIST_ITEMC];
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- //CMD_LINE res[RES_NUM];
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuChildGame: Out of Memory");
- return;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- ddxCleareSurface(FontDC);
- //ddxCleareSurface(BackDC);
- /* ddxCleareSurface(BackDC);
- ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0, 0);
- ddxCleareSurface(FontDC);*/
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- //lastcmd--;
- in = 0;
- fn_Set_Font(cFontFile[0]);
- fn_Load_Bitmaps();
- CreateFontAnimations(res, &lastcmd);
- fn_Release_Font(1);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- {
- if (!c) {
- hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
- ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]),
- HDC2DD, res[i].iParam[2], res[i].iParam[3]);
- ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
- ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
- res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
- idx = i;
- }
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- }
- c++;
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- /* {
- RECT r;
- r.left = 299;
- r.top = 209;
- r.right = 743;
- r.bottom = 359;
- co_Set_Text_Center(BackDC, "##menu_child_toughness", 0, r);
- }
- fn_Release_Font();*/
- BEGIN_MENU_CHILDNEWGAME:
- bBackDC = 1;
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- DisplayFrame();
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[i].iAnim[0]);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- key[K_ESC] = 1;
- //break;
- }
- if (!strcmp(res[resid].cParam[1], "EASY")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(10)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- }
- else {
- StopAll();
- bBackDC = 0;
- iActualScene = 10;
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
- NULL, 0);
- key[K_ESC] = 1;
- }
- }
- if (!strcmp(res[resid].cParam[1], "NORMAL")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(11)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- }
- else {
- StopAll();
- bBackDC = 0;
- iActualScene = 11;
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
- NULL, 0);
- key[K_ESC] = 1;
- }
- }
- if (!strcmp(res[resid].cParam[1], "HARD")) {
- if (iLanguageVersion == 4 && !CheckScenePresence(12)) {
- RunMenuCibron("buy.bmp");
- click = 0;
- }
- else {
- StopAll();
- bBackDC = 0;
- iActualScene = 12;
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
- NULL, 0);
- key[K_ESC] = 1;
- }
- }
- if (!cRestartMainMenu)
- for (i = 0; i < lastcmd; i++) {
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iParam);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[i].iParam);
- ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- //menucommand_DrawT(BackDC, res[i].iParam);
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[i].iParam, 3);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- }
- }
- resid = -1;
- if (key[K_ESC]) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- else
- goto BEGIN_MENU_CHILDNEWGAME;
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- cRestartMainMenu = 1;
- key[K_ESC] = 1;
- }
- }
- __QUIT:
- ddxCleareSurface(FontDC);
- /* if(!cRestartMainMenu)
- ddxTransparentBltDisplay( 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, TRANSCOLOR);*/
- //ddxCleareSurface(BackDC);
- if (!cRestartMainMenu) {
- ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
- ddxTransparentBlt(BackDC, res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]),
- res[idx].iParam[1], 0, 0, ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), TRANSCOLOR);
- }
- //BRUTAL_RELEASE .... nenicit
- if (!cBrutalRestart)
- ddxReleaseBitmap(hdcBT);
- ddxCleareSurface(CompositDC);
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- void RunMenuStartGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
- int cpu)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- int c = 0;
- int idx;
- int hdcBT;
- CONTROL_LIST_ITEM citem[CLIST_ITEMC];
- // FILE *file;
- char dir[256];
- int lastcmd, lastanm, i;
- //CMD_LINE res[RES_NUM];
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuLoadGame: Out of Memory");
- return;
- }
- else
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- //bBackDC = 1;
- //ddxCleareSurface(FontDC);
- //ddxCleareSurface(BackDC);
- ddxCleareSurface(BackDC);
- ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0,
- 0);
- ddxCleareSurface(FontDC);
- //kprintf(1, "bitblt");
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- //kprintf(1, "load");
- in = 0;
- fn_Set_Font(cFontFile[0]);
- fn_Load_Bitmaps();
- //kprintf(1, "fn_Set_Font");
- CreateFontAnimations(res, &lastcmd);
- fn_Release_Font(1);
- //kprintf(1, "CreateFontAnimations");
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- {
- if (!c) {
- /* hdcBT = fn_CreateDC(_2dd.hDC, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight, _2d_Find_Free_Surface());*/
- /*hdcBT = fn_CreateDC(_2dd.hDC, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight, ddxFindFreeSurface()); */
- hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
- /*BitBlt(hdcBT, 0, 0, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
- _2dd.hDC, res[i].iParam[2], res[i].iParam[3], SRCCOPY); */
- ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]),
- HDC2DD, res[i].iParam[2], res[i].iParam[3]);
- /*BitBlt(BackDC,res[i].iParam[2], res[i].iParam[3], _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
- _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
- _2dd.bitmap[res[i].iParam[1]].bitmapDC, 0, 0, SRCCOPY); */
- ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
- ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
- res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
- ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
- //menucommand_DrawT(_2dd.hDC, res[i].iParam);
- idx = i;
- }
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- //menucommand_DrawT(BackDC, res[i].iParam);
- }
- //menucommand_DrawT(_2dd.hDC, res[i].iParam);
- c++;
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- BEGIN_MENU_NEWGAME:
- bBackDC = 1;
- //TransparentBltU(_2dd.hDC, 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, RGB(255, 0, 255));
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- DisplayFrame();
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- dwStart = timeGetTime();
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[i].iAnim[0]);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- dim.dx = 0;
- dim.dy = 0;
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- key[K_ESC] = 1;
- //break;
- }
- if (!strcmp(res[resid].cParam[1], "NEW_GAME")) {
- iActualScene = 1;
- StopAll();
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
- NULL, 1);
- key[K_ESC] = 1;
- }
- if (!strcmp(res[resid].cParam[1], "CHILD_SCENE")) {
- RunMenuChildGame("Mmstart_child_game.txt", NULL, p_ad, cpu);
- if (cRestartMainMenu) {
- StopAll();
- key[K_ESC] = 1;
- }
- }
- if (!strcmp(res[resid].cParam[1], "TUTORIAL")) {
- StopAll();
- bBackDC = 0;
- iActualScene = 0;
- RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
- NULL, 0);
- key[K_ESC] = 1;
- }
- if (!cRestartMainMenu)
- for (i = 0; i < lastcmd; i++) {
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer) {
- //menucommand_Draw(_2dd.hDC, res[i].iParam);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- }
- }
- resid = -1;
- if (key[K_ESC]) {
- /*
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- else
- goto BEGIN_MENU_NEWGAME;
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- spracuj_spravy(0);
- ddxUpdateMouse();
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- if (ddxRestore(p_ad)) {
- cRestartMainMenu = 1;
- key[K_ESC] = 1;
- }
- }
- __QUIT:
- ddxCleareSurface(FontDC);
- if (!cRestartMainMenu)
- ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
- TRANSCOLOR);
- ddxCleareSurface(BackDC);
- bBackDC = 0;
- if (!cRestartMainMenu) {
- ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
- ddxGetWidth(res[idx].iParam[1]),
- ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
- }
- //BRUTAL_RELEASE .... nenicit
- if (!cBrutalRestart)
- ddxReleaseBitmap(hdcBT);
- ddxCleareSurface(CompositDC);
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- }
- int LoadCList(char *cFile, int *p_count, int *p_bmp, int *iClock,
- APAK_HANDLE * hArchive)
- {
- int c = 0, i = -1, t;
- char text[256];
- FILE *file;
- file = aopen(pBmpArchive, cFile, "r");
- if (!file)
- return -1;
- while (!aeof(file)) {
- memset(text, 0, 256);
- agets(text, 256, file);
- if (strlen(text)) {
- text[strlen(text) - 1] = '\0';
- if (!c) {
- i = ddxLoadBitmap(text, hArchive);
- p_bmp[c] = i;
- }
- else {
- t = ddxLoadBitmap(text, hArchive);
- p_bmp[c] = t;
- }
- DrawClock(iClock, 0);
- c++;
- }
- }
- aclose(file);
- pBmpArchive->bError = 0;
- (*p_count) = c;
- return i;
- }
- int GetComixTime(int iScene)
- {
- char text[256];
- int i;
- FILE *file;
- file = aopen(pDataArchive, "comix_times.txt", "r");
- if (!file)
- return 1000;
- for (i = 0; i < iScene + 1; i++)
- agets(text, 256, file);
- aclose(file);
- return atoi(text);
- }
- int RunMenuComixB(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int iScene)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- FILE *file;
- char dir[256];
- int lastcmd, lastanm, i, j;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- int cc = 0;
- int iTVBmp = -1;
- int iTVTBmp = -1;
- int iTVBut = -1;
- int iComix = -1;
- char ccomix[64];
- int y = 0;
- int iSongTime = 1000;
- int ccc;
- int iClock;
- iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
- ddxResizeCursorBack(iClock);
- DrawClock(&iClock, 0);
- /*
- if(ogg_playing())
- {
- float f;
- f = p_ad->Music_Gain;
- while(f >= 0.05f)
- {
- f -= 0.05f;
- ogg_gain(f);
- Sleep(25);
- }
- ap_Stop_Song(p_ad);
- }
- */
- Sleep(1000);
- bBackDC = 0;
- res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
- if (!res) {
- kprintf(1, "RunMenuSceneMap: Out of Memory");
- return 0;
- }
- _2d_Clear_RectLine(&rline);
- ddxSetFlip(TRUE);
- cc = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
- ddxCleareSurface(CompositDC);
- ddxCleareSurface(FontDC);
- DrawClock(&iClock, 0);
- iTVBmp = ddxLoadBitmap("televize.bmp", pBmpArchive);
- iTVTBmp = ddxLoadBitmap("televizet.bmp", pBmpArchive);
- DrawClock(&iClock, 0);
- iTVBut = LoadCList("telload.txt", &ccc, &ccc, &ccc, pBmpArchive);
- sprintf(ccomix, "comix%d.bmp", iScene);
- //iComix = LoadCList(ccomix);
- iComix = ddxLoadBitmap(ccomix, pBmpArchive);
- if (iTVBmp == -1 || iTVBut == -1 || iComix == -1 || iTVTBmp == -1) {
- kprintf(1, "saaaaakra ... nepodarilo se nahrat nejakou grafiku na comix");
- return 0;
- }
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][0] = -1;
- res[bind].iAnim[lastcmd][11] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[in] = -1;
- res[bind].pCmdLine = res;
- }
- lastcmd = 0;
- timercnt = 0;
- GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
- working_file_translate(dir, 256);
- chdir((dir));
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- //kerekce televize
- res[0].iParam[1] = iTVBmp;
- //korekce animace komixu;
- //strcpy(res[1].cParam[0], ccomix);
- DrawClock(&iClock, 0);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer)
- ddxDrawSurface(BackDC, res[i].iParam, 0);
- else {
- ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- file = aopen(pDataArchive, res[i].cParam[0], "r");
- if (file) {
- while (!aeof(file)) {
- Parse_AnimLine(file, res[i].iAnim[lastanm], 18);
- lastanm++;
- }
- aclose(file);
- for (j = 0; j < lastanm; j++)
- res[i].iAnim[j][1] += iTVBut;
- }
- cc++;
- break;
- }
- }
- DrawClock(&iClock, 0);
- ddxSetCursor(0);
- DisplayFrame();
- DisplayFrame();
- ddxResizeCursorBack(0);
- ddxSetCursorSurface(0);
- ddxSetCursor(1);
- DisplayFrame();
- DisplayFrame();
- ddxReleaseBitmap(iClock);
- ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
- ddxCleareSurface(BackDC);
- ddxTransparentBlt(FontDC, 0, 0, 1024, 768, iTVTBmp, 0, 0, 1024, 768,
- TRANSCOLOR);
- _2d_Clear_RectLine(&rline);
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation(&res[i], p_ad, 0, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound(&res[i + 1], p_ad, 2);
- }
- }
- dim.t1 = 0;
- dim.t2 = 0;
- dim.dx = 0;
- dim.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- /*
- if(ogg_playing())
- ap_Stop_Song(p_ad);
- */
- iSongTime = GetComixTime(iScene);
- //ap_Play_Song(iScene+1,0, p_ad);
- /* if (p_ad->bAudio && p_ad->Music_Gain >= 0.05f)
- ap_Setup_and_Play_Song(iScene+1,0, p_ad);
- if (p_ad->bAudio && p_ad->Music_Gain >= 0.05f)
- adas_OGG_Play_Stream();*/
- dwLTime = timeGetTime();
- ddxSetFlip(FALSE);
- dwStart = timeGetTime();
- while (!key[K_ESC]) {
- //pohnul mysi
- if (dim.dx || dim.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- if (res[lastabv].iAnim[0][0] != -1) {
- Stop(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddxDrawDisplay(res[lastabv].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- }
- CheckAnimation(&res[i], p_ad);
- lastabv = i;
- AddAnimation(&res[i], p_ad, 0, 1);
- in = 1;
- bind = ChooseBidedAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- CheckAnimation(&res[bind], p_ad);
- AddAnimation(&res[bind], p_ad, 1, 1);
- anbind = bind;
- mPlaySound(&res[bind], p_ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop(&res[i]);
- if (res[i].iAnim[0][0] != -1) {
- if (!res[i].iLayer) {
- ddxDrawDisplay(res[i].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- }
- bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop(&res[anbind]);
- if (!res[anbind].iLayer) {
- ddxDrawDisplay(res[anbind].iAnim[0], 0);
- ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- }
- //stlacil leve tlacitko
- if (dim.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((dim.x >= res[i].iParam[1]) &&
- (dim.x <= res[i].iParam[3]) &&
- (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation(&res[i], p_ad, 0, 1);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound(&res[i + 1], p_ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- dim.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- key[K_ESC] = 1;
- cRestartMainMenu = 1;
- }
- resid = -1;
- if (key[K_ESC]) {
- /* for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- */
- goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation(&res[i], p_ad);
- AddAnimation(&res[i], p_ad, 0, 0);
- }
- }
- //dwStop = timeGetTime();
- //dwEplased += dwStop - dwLTime;
- //dwStart = timeGetTime();
- spracuj_spravy(0);
- ddxUpdateMouse();
- {
- RECT rr;
- rr.left = 124;
- rr.top = 161;
- rr.right = 700;
- rr.bottom = 549;
- y =
- (int) ftoi((dwEplased * (ddxGetHight(iComix) -
- 550)) / (float) iSongTime);
- if (y >= ddxGetHight(iComix) - 550)
- key[K_ESC] = 1;
- ddxBitBlt(CompositDC, 124, 161, ddxGetWidth(iComix), 549, iComix, 0, y);
- _2d_Add_RectItem(&rline, rr, 0);
- }
- AnimationEvent(dwStop, p_ad);
- if (dim.tf1) {
- dim.t1 = 1;
- dim.tf1 = 0;
- }
- if (dim.tf2) {
- dim.t2 = 1;
- dim.tf2 = 0;
- }
- dwStop = timeGetTime();
- dwEplased = dwStop - dwStart;
- //kprintf(1, "%d", dwEplased);
- if (ddxRestore(p_ad))
- return 1;
- }
- __QUIT:
- //kprintf(1, "%d", dwEplased);
- /*
- adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
- adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
- */
- StopAll();
- ddxReleaseBitmap(iTVBmp);
- ddxReleaseBitmap(iTVTBmp);
- for (i = iTVBut; i < iTVBut + 9; i++)
- ddxReleaseBitmap(i);
- ddxReleaseBitmap(iComix);
- ddxCleareSurface(FontDC);
- ddxCleareSurface(BackDC);
- ddxCleareSurface(CompositDC);
- key[K_ESC] = 0;
- FreeAnimations(res, RES_NUM);
- free((void *) res);
- /*
- if(ogg_playing())
- ap_Stop_Song(p_ad);
- */
- //ap_Play_Song(0, 0, p_ad);
- ddxSetFlip(TRUE);
- return 0;
- }
- int RunMenuComix(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int iScene)
- {
- DWORD dwEplased = 0, dwStart, dwStop;
- int iComix = -1;
- char ccomix[64];
- int iSongTime = 1000;
- int bmpc = 0;
- int iClock;
- int idx = -1;
- int lidx = -1;
- int bmp[64];
- int i;
- APAK_HANDLE *hArchive = NULL;
- char cFile[MAX_PATH];
- char cDir[MAX_PATH];
- if (iLanguageVersion == 4) {
- GetPrivateProfileString("game", "bitmap_dir", "c:\\", cDir, MAX_PATH,
- ini_file);
- working_file_translate(cDir, MAX_PATH);
- //sprintf(cFile, "%s\\scene%d.pak", cDir, iScene); - DIR?
- sprintf(cFile, "%s/scene%d.pak", cDir, iScene);
- apak_dir_correction(cDir);
- hArchive = apakopen(cFile, cDir, &idx);
- if (!hArchive) {
- kprintf(1, "Nepodarilo se otevrit archiv [%s]\n", cFile);
- return 0;
- }
- else
- hArchive->pActualNode = hArchive->pRootNode->pNextNode;
- }
- cCheckMusicExeption = 1;
- for (i = 0; i < 64; i++)
- bmp[i] = -1;
- ddxSetFlip(0);
- iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
- ddxResizeCursorBack(iClock);
- DrawClock(&iClock, 0);
- /*
- if(ogg_playing())
- {
- float f;
- f = p_ad->Music_Gain;
- while(f >= 0.05f)
- {
- f -= 0.05f;
- ogg_gain(f);
- Sleep(25);
- }
- ap_Stop_Song(p_ad);
- }
- */
- ddxSetFlip(0);
- DrawClock(&iClock, 0);
- sprintf(ccomix, "comix%d.txt", iScene);
- if (iLanguageVersion == 4) {
- iComix = LoadCList(ccomix, &bmpc, bmp, &iClock, hArchive);
- apakclose(hArchive);
- }
- else
- iComix = LoadCList(ccomix, &bmpc, bmp, &iClock, pBmpArchive);
- DrawClock(&iClock, 0);
- ddxSetCursor(0);
- DisplayFrame();
- DisplayFrame();
- ddxResizeCursorBack(0);
- ddxSetCursorSurface(0);
- ddxSetCursor(1);
- DisplayFrame();
- DisplayFrame();
- ddxReleaseBitmap(iClock);
- ddxSetCursor(0);
- spracuj_spravy(0);
- if (ogg_playing())
- ap_Stop_Song(p_ad);
- iSongTime = GetComixTime(iScene);
- //ap_Play_Song(iScene+1,0, p_ad);
- dwStart = timeGetTime();
- while (!key[K_ESC]) {
- spracuj_spravy(0);
- dwStop = timeGetTime();
- dwEplased = dwStop - dwStart;
- if (dwEplased >= (unsigned) iSongTime)
- break;
- lidx = idx;
- idx = (int) floor((dwEplased * bmpc) / (float) iSongTime);
- if (lidx != idx) {
- lidx = idx;
- if (idx >= 0 && idx < 64)
- if (bmp[idx] != -1) {
- ddxBitBltDisplay(0, 0, 1024, 768, bmp[idx], 0, 0);
- DisplayFrame();
- }
- else
- break;
- else
- break;
- }
- if (key[K_SPACE]) {
- key[K_SPACE] = 0;
- do {
- dwStart -= 1000;
- dwEplased = dwStop - dwStart;
- idx = (int) floor((dwEplased * bmpc) / (float) iSongTime);
- }
- while (idx == lidx);
- dwStart -= ftoi(iSongTime / (float) bmpc);
- }
- if (ddxRestore(p_ad)) {
- cCheckMusicExeption = 0;
- return 1;
- }
- }
- /*
- adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
- adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
- */
- key[K_ESC] = 0;
- for (i = 0; i < 64; i++)
- if (bmp[i] != -1)
- ddxReleaseBitmap(bmp[i]);
- /*
- if(ogg_playing())
- {
- float f;
- f = p_ad->Music_Gain;
- while(f >= 0.05f)
- {
- f -= 0.05f;
- ogg_gain(f);
- Sleep(25);
- }
- ap_Stop_Song(p_ad);
- }
- */
- Sleep(1000);
- //ap_Play_Song(0, 0, p_ad);
- ddxCleareSurfaceColorDisplay(0);
- DisplayFrame();
- ddxCleareSurfaceColorDisplay(0);
- ddxSetFlip(1);
- ddxSetCursor(1);
- cCheckMusicExeption = 0;
- return 0;
- }
- char MenuCheckBossExit(void)
- {
- spracuj_spravy(0);
- if ((key[K_SHIFT] || key[K_SHFT_P]) && key[K_F11])
- return 1;
- else
- return 0;
- }
- char MenuCheckSuccessExit(void)
- {
- spracuj_spravy(0);
- if (key[K_CTRL] && key[K_E])
- return 1;
- else
- return 0;
- }
|