Menu.cpp 224 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530
  1. //------------------------------------------------------------------------------------------------
  2. // 0.0.1
  3. //------------------------------------------------------------------------------------------------
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include "3d_all.h"
  8. #include "Berusky3d_kofola_interface.h"
  9. #include "game_logic.h"
  10. #include "menu_script.h"
  11. #include "Command.h"
  12. #include "3D_graphic.h"
  13. #include "2D_graphic.h"
  14. #include "Menu.h"
  15. #include "Comics.h"
  16. #include "credits.h"
  17. #include "font.h"
  18. #include "controls.h"
  19. #include "menu_def.h"
  20. #include "Setup.h"
  21. #include "profiles.h"
  22. #include "Apak.h"
  23. #include "3D_menus.h"
  24. #include "Demo.h"
  25. #include "load_level.h"
  26. #include "Menu.h"
  27. #include "Menu2.h"
  28. #include "menu_def.h"
  29. #include "Tools.h"
  30. #ifdef LINUX
  31. #include <sys/types.h>
  32. #include <sys/stat.h>
  33. #include <time.h>
  34. #include <dirent.h>
  35. #include <fnmatch.h>
  36. #endif
  37. #define HDC2DD -1
  38. #define RES_NUM 200
  39. extern SETUP setup;
  40. extern _3D_CURSOR _3dCur;
  41. extern APAK_HANDLE *pBmpArchive;
  42. extern APAK_HANDLE *pDataArchive;
  43. extern PLAYER_PROFILE pPlayerProfile;
  44. extern HINT_TEXTURE pHintTexture[26];
  45. extern char cFontFile[5][64];
  46. extern int bWindowMenu;
  47. extern int iLanguageVersion;
  48. typedef struct __2D_HINT
  49. {
  50. int x;
  51. int y;
  52. int iSurface;
  53. int iBSurface;
  54. char bUsed;
  55. } _2D_HINT;
  56. typedef struct
  57. {
  58. CMD_LINE *cmd;
  59. int iWave;
  60. char bStop;
  61. } ANIMATION;
  62. extern _2D_DATA _2dd;
  63. extern HW_KONFIG hwconf;
  64. MOUSE_INFO dim;
  65. static ANIMATION anm[32];
  66. static DWORD timercnt = 0;
  67. static DWORD timercntframe = 0;
  68. static DWORD dwLTime;
  69. static char cRestartMainMenu;
  70. char cBrutalRestart = 0;
  71. int CompositDC;
  72. int FontDC;
  73. int BackDC;
  74. int iCompositDC, iFontDC, iBackDC;
  75. static char bBackDC = 0;
  76. int iActualScene = 0;
  77. int iActualLevel = 0;
  78. static char bNewScene = 0;
  79. static _2D_HINT _2d_hint;
  80. extern RECT_LINE rline;
  81. extern int gi_Change_Grafic_Mode(int xPels, int yPels, int Bits, int freq,
  82. DWORD dwflags);
  83. //extern int gi_EnumDisplaySettings(DEVMODE *pdevmode);
  84. extern int iMaxBpp;
  85. extern int iMaxFreq;
  86. char cCheckMusicExeption = 0;
  87. void RunMenuSceneMap(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu,
  88. char *cSceneBmp, char *cSceneAnim, int iScene, int iLevelStart,
  89. int iNumOfLevels, char *cLevelList, int xTV, int yTV, char bLoadGame,
  90. char *cSaveFile, char bTutorial, int xBack, int yBack);
  91. void RunMenuStartGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
  92. int cpu);
  93. int RunMenuComix(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int iScene);
  94. void DrawClock(int *iClock, int i);
  95. int FillComboProfiles(COMBO_CONTROL * p_co, int *iSel);
  96. int LoadClock(int *iClock);
  97. void RunMenuCibron(char *cBmp);
  98. CMD_LINE *GetCMD(CMD_LINE * cmp, CMD_LINE * pres)
  99. {
  100. int i;
  101. for (i = 0; i < RES_NUM; i++)
  102. if (!strcmp(cmp->cParam[1], pres[i].cParam[0]))
  103. return &pres[i];
  104. return NULL;
  105. }
  106. int CheckScenePresence(int iScene)
  107. {
  108. char t[256];
  109. sprintf(t, "scene%d", iScene);
  110. return GetPrivateProfileInt("Internet", t, 0, ini_file);
  111. }
  112. //------------------------------------------------------------------------------------------------
  113. // zastavi vsechny animace
  114. //------------------------------------------------------------------------------------------------
  115. void StopAll(void)
  116. {
  117. int i;
  118. for (i = 0; i < 32; i++)
  119. if (anm[i].cmd)
  120. anm[i].bStop = 1;
  121. }
  122. //------------------------------------------------------------------------------------------------
  123. // zastavi animaci
  124. //------------------------------------------------------------------------------------------------
  125. void Stop(CMD_LINE * cmd)
  126. {
  127. int i;
  128. if (cmd->iAnim[0][0] == -1)
  129. return;
  130. for (i = 0; i < 32; i++)
  131. if (cmd == anm[i].cmd) {
  132. if (cmd->bEndActivate[0] && cmd->pCmdLine) {
  133. cmd->pCmdLine[cmd->bEndActivate[0]].bActive = 1;
  134. cmd->bActive = 0;
  135. }
  136. if (cmd->bEndActivate[1] && cmd->pCmdLine) {
  137. cmd->pCmdLine[cmd->bEndActivate[1]].bActive = 1;
  138. cmd->bActive = 0;
  139. }
  140. anm[i].bStop = 1;
  141. return;
  142. }
  143. }
  144. int NextStep(CMD_LINE * cmd)
  145. {
  146. if ((rand() % 100) < 60)
  147. return cmd->iAnim[cmd->iLastfrm][11];
  148. else
  149. return cmd->iAnim[cmd->iLastfrm][11 +
  150. rand() % (cmd->iAnim[cmd->iLastfrm][17])];
  151. }
  152. void DrawFrame(CMD_LINE * cmd, AUDIO_DATA * p_ad)
  153. {
  154. if (cmd->iAnim[cmd->iLastfrm][10] == 2) {
  155. float p[3] = { 0, 0, 0 };
  156. //kprintf(1, "Play");
  157. // if(karmin_aktivni)
  158. // ap_Play_Sound(0, 1, 0, p, 147 + (rand()%2), NULL, p_ad);
  159. }
  160. if (!cmd->iLayer) {
  161. if (cmd->iAnim[cmd->iLastfrm][6] >= 0) {
  162. RECT r;
  163. ddxBitBlt(CompositDC,
  164. cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6],
  165. cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7],
  166. cmd->iAnim[cmd->iLastfrm][8], cmd->iAnim[cmd->iLastfrm][9],
  167. cmd->iAnim[cmd->iLastfrm][1],
  168. cmd->iAnim[cmd->iLastfrm][6], cmd->iAnim[cmd->iLastfrm][7]);
  169. r.left = cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6];
  170. r.top = cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7];
  171. r.right = cmd->iAnim[cmd->iLastfrm][8];
  172. r.bottom = cmd->iAnim[cmd->iLastfrm][9];
  173. ddxAddRectItem(&rline, r, 1);
  174. }
  175. else
  176. ddxDrawSurface(CompositDC, cmd->iAnim[cmd->iLastfrm], 1);
  177. }
  178. else if (cmd->iLayer == 10)
  179. ddxDrawSurfaceColorKey(CompositDC, cmd->iAnim[cmd->iLastfrm], 1,
  180. TRANSCOLOR);
  181. else
  182. ddxDrawSurface(FontDC, cmd->iAnim[cmd->iLastfrm], 3);
  183. }
  184. //------------------------------------------------------------------------------------------------
  185. // provede animaci
  186. //------------------------------------------------------------------------------------------------
  187. void Animation(CMD_LINE * cmd, int time, AUDIO_DATA * p_ad)
  188. {
  189. ANIMATION_DRAW:
  190. while (time > 0) {
  191. if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
  192. Stop(cmd);
  193. break;
  194. }
  195. time -= cmd->iAnim[cmd->iLastfrm][4];
  196. if (time > (cmd->iAnim[cmd->iAnim[cmd->iLastfrm][5]][4] / 2.0f)) {
  197. if (cmd->iAnim[cmd->iLastfrm][11] >= 0)
  198. cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);
  199. if (cmd->iAnim[cmd->iLastfrm][10] > 0)
  200. DrawFrame(cmd, p_ad);
  201. cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
  202. }
  203. }
  204. //----------------------------------------------------------------------
  205. DrawFrame(cmd, p_ad);
  206. if (!cmd->iAnim[cmd->iLastfrm][4]) {
  207. if (cmd->iAnim[cmd->iLastfrm][11] >= 0)
  208. cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);
  209. cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
  210. goto ANIMATION_DRAW;
  211. }
  212. if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
  213. Stop(cmd);
  214. return;
  215. }
  216. if (cmd->iAnim[cmd->iLastfrm][11] >= 0)
  217. cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);
  218. cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
  219. }
  220. int RectCross(RECT_LINE * p_rl, int idx)
  221. {
  222. int c = 0;
  223. int i;
  224. RECT *dr = &p_rl->rect[idx].rect;
  225. for (i = 0; i < rline.rlast; i++)
  226. if (i != idx)
  227. if (co_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->top) ||
  228. co_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->top) ||
  229. co_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->bottom) ||
  230. co_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->bottom))
  231. c++;
  232. return 0;
  233. }
  234. //------------------------------------------------------------------------------------------------
  235. // provede animace
  236. //------------------------------------------------------------------------------------------------
  237. void AnimationEvent(DWORD dwTime, AUDIO_DATA * p_ad)
  238. {
  239. DRAW_RECT *dr;
  240. int i;
  241. char bAnim = 0;
  242. DWORD e;
  243. e = abs(dwLTime - dwTime);
  244. for (i = 0; i < 32; i++)
  245. if (anm[i].cmd) {
  246. if (anm[i].bStop) {
  247. anm[i].cmd->iLastfrm = 1;
  248. anm[i].cmd->iCounter = 0;
  249. if (anm[i].iWave > -1) {
  250. //kprintf(1, "%d", anm[i].iWave);
  251. //adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, anm[i].iWave);
  252. }
  253. anm[i].iWave = -1;
  254. anm[i].cmd = NULL;
  255. }
  256. else {
  257. anm[i].cmd->iCounter += e;
  258. if (anm[i].cmd->iCounter >=
  259. anm[i].cmd->iAnim[anm[i].cmd->iLastfrm][4]) {
  260. Animation(anm[i].cmd, anm[i].cmd->iCounter, p_ad);
  261. anm[i].cmd->iCounter = 0;
  262. bAnim = 1;
  263. }
  264. }
  265. }
  266. //prenos kreslenych dat;
  267. if (bAnim || rline.rlast) {
  268. if (bBackDC) {
  269. for (i = 0; i < rline.rlast; i++) {
  270. dr = &rline.rect[i];
  271. ddxTransparentBlt(BackDC, dr->rect.left, dr->rect.top, dr->rect.right,
  272. dr->rect.bottom, FontDC, dr->rect.left, dr->rect.top,
  273. dr->rect.right, dr->rect.bottom, TRANSCOLOR);
  274. }
  275. for (i = 0; i < rline.rlast; i++) {
  276. dr = &rline.rect[i];
  277. ddxTransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
  278. dr->rect.right, dr->rect.bottom, BackDC, dr->rect.left,
  279. dr->rect.top, dr->rect.right, dr->rect.bottom, TRANSCOLOR);
  280. }
  281. }
  282. else {
  283. for (i = 0; i < rline.rlast; i++) {
  284. dr = &rline.rect[i];
  285. ddxTransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
  286. dr->rect.right, dr->rect.bottom, FontDC, dr->rect.left,
  287. dr->rect.top, dr->rect.right, dr->rect.bottom, TRANSCOLOR);
  288. }
  289. }
  290. for (i = 0; i < rline.rlast; i++) {
  291. dr = &rline.rect[i];
  292. ddxTransparentBltDisplay(dr->rect.left, dr->rect.top, dr->rect.right,
  293. dr->rect.bottom, CompositDC, dr->rect.left, dr->rect.top,
  294. dr->rect.right, dr->rect.bottom, TRANSCOLOR);
  295. }
  296. ddxUpdateMouse();
  297. DisplayFrame();
  298. bAnim = 1;
  299. }
  300. timercntframe += e;
  301. if(!bAnim && (dim.dx || dim.dy) && timercntframe > 9)
  302. {
  303. timercntframe = 0;
  304. DisplayFrame();
  305. }
  306. dwLTime = dwTime;
  307. timercnt += e;
  308. _2d_Clear_RectLine(&rline);
  309. }
  310. void InitRandomJumps(CMD_LINE * cmd)
  311. {
  312. int i;
  313. for (i = 0; i < 200; i++)
  314. if (cmd->iAnim[i][11] >= 0)
  315. cmd->iAnim[i][5] = cmd->iAnim[i][11 + rand() % (cmd->iAnim[i][17])];
  316. }
  317. int FindAnimation(CMD_LINE * cmd)
  318. {
  319. int i;
  320. for (i = 0; i < 32; i++)
  321. if (anm[i].cmd == cmd)
  322. return 1;
  323. return 0;
  324. }
  325. //------------------------------------------------------------------------------------------------
  326. // prida animaci
  327. //------------------------------------------------------------------------------------------------
  328. int AddAnimation(CMD_LINE * cmd, AUDIO_DATA * p_ad, char bOnlyOnes,
  329. char bButton)
  330. {
  331. int i, r;
  332. float pos[3] = { 0.0f, 0.0f, 1.0f };
  333. if (!bButton && bWindowMenu)
  334. return -1;
  335. if (cmd->iAnim[0][0] == -1)
  336. return -1;
  337. for (i = 0; i < 32; i++)
  338. if (!anm[i].cmd) {
  339. if (bOnlyOnes && FindAnimation(cmd))
  340. return -1;
  341. InitRandomJumps(cmd);
  342. anm[i].cmd = cmd;
  343. anm[i].bStop = 0;
  344. anm[i].iWave = -1;
  345. Animation(anm[i].cmd, 0, p_ad);
  346. if (cmd->iParam[0] == COM_RANDOMANIMATION) {
  347. r = rand() % 3;
  348. if (cmd->iParam[r + 2] < 0) {
  349. if (cmd->iParam[2] >= 0) {
  350. // adas_Get_Listener_Position(pos);
  351. // if(karmin_aktivni)
  352. // ap_Play_Sound(0,1,0,pos,cmd->iParam[2], NULL, p_ad);
  353. }
  354. }
  355. else {
  356. // adas_Get_Listener_Position(pos);
  357. //if(karmin_aktivni)
  358. //ap_Play_Sound(0,1,0,pos,cmd->iParam[r+2], NULL, p_ad);
  359. }
  360. }
  361. return i;
  362. }
  363. else if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0]) && !anm[i].bStop)
  364. return -1;
  365. return -1;
  366. }
  367. int ChooseBidedExitAnimation(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
  368. {
  369. int id[RES_NUM];
  370. int i, c = 0;
  371. for (i = Index; i < RES_NUM; i++)
  372. if (cmd[i].iParam[0] == COM_BINDEXITANIMATION) {
  373. id[c] = i;
  374. c++;
  375. if (c > RES_NUM - 1)
  376. break;
  377. }
  378. else if (cmd[i].iParam[0] != COM_BINDANIMATION)
  379. break;
  380. if (c)
  381. return id[rand() % c];
  382. else
  383. return -1;
  384. }
  385. int ChooseBidedAnimation(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
  386. {
  387. int id[RES_NUM];
  388. int i, c = 0;
  389. for (i = Index; i < RES_NUM; i++)
  390. if (cmd[i].iParam[0] == COM_BINDANIMATION) {
  391. id[c] = i;
  392. c++;
  393. if (c > RES_NUM - 1)
  394. break;
  395. }
  396. else if (cmd[i].iParam[0] != COM_BINDEXITANIMATION)
  397. break;
  398. if (c)
  399. return id[rand() % c];
  400. else
  401. return -1;
  402. }
  403. void ZeroAnimations(void)
  404. {
  405. int i;
  406. for (i = 0; i < 32; i++) {
  407. anm[i].bStop = 0;
  408. anm[i].iWave = -1;
  409. anm[i].cmd = NULL;
  410. }
  411. }
  412. void FreeAnimations(CMD_LINE * cmd, int csize)
  413. {
  414. int i, j;
  415. for (i = 0; i < csize; i++)
  416. for (j = 0; j < 32; j++)
  417. if (anm[j].cmd)
  418. if (anm[j].cmd == &cmd[i]) {
  419. anm[j].cmd->iLastfrm = 1;
  420. anm[j].cmd->iCounter = 0;
  421. anm[j].iWave = -1;
  422. anm[j].cmd = NULL;
  423. }
  424. }
  425. //------------------------------------------------------------------------------------------------
  426. // prida animaci
  427. //------------------------------------------------------------------------------------------------
  428. void CheckAnimation(CMD_LINE * cmd, AUDIO_DATA * p_ad)
  429. {
  430. int i;
  431. float pos[3] = { 0.0f, 0.0f, 1.0f };
  432. for (i = 0; i < 32; i++)
  433. if (anm[i].cmd)
  434. if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0])) {
  435. Stop(anm[i].cmd);
  436. /*if(!cmd->iLayer)
  437. {
  438. //menucommand_Draw(_2dd.hDC, anm[i].cmd->iAnim[0] , 0);
  439. ddxDrawDisplay(anm[i].cmd->iAnim[0] , 0);
  440. }
  441. else
  442. {
  443. //menucommand_DrawT(_2dd.hDC, anm[i].cmd->iAnim[0]);
  444. ddxDrawDisplayColorKey(anm[i].cmd->iAnim[0], 0, TRANSCOLOR);
  445. //menucommand_Draw(FontDC, anm[i].cmd->iAnim[0], 3);
  446. ddxDrawSurface(FontDC, anm[i].cmd->iAnim[0], 3);
  447. } */
  448. return;
  449. }
  450. }
  451. void StretchAnimation(RECT * rStart, RECT * rFinish, int iSurface, int iSpeed,
  452. AUDIO_DATA * p_ad)
  453. {
  454. DWORD dwS, dwF, dwE;
  455. char done = 0;
  456. int max = 0;
  457. int i;
  458. int p[4]; //{left, top, right, bottom}
  459. float s[4];
  460. RECT rBmp;
  461. RECT rDraw;
  462. p[0] = rFinish->left - rStart->left;
  463. p[1] = rFinish->top - rStart->top;
  464. p[2] = rFinish->right - rStart->right;
  465. p[3] = rFinish->bottom - rStart->bottom;
  466. for (i = 0; i < 4; i++)
  467. if (abs(p[i]) > max)
  468. max = abs(p[i]);
  469. for (i = 0; i < 4; i++)
  470. s[i] = p[i] / (float) max;
  471. StopAll();
  472. rBmp.left = 0;
  473. rBmp.top = 0;
  474. rBmp.right = ddxGetWidth(iSurface);
  475. rBmp.bottom = ddxGetHight(iSurface);
  476. memcpy(&rDraw, rStart, sizeof(RECT));
  477. dwS = timeGetTime();
  478. while (!done) {
  479. ddxStretchBltDisplay(&rDraw, iSurface, &rBmp);
  480. DisplayFrame();
  481. dwF = timeGetTime();
  482. dwE = dwF - dwS;
  483. rDraw.left = rStart->left + ftoi((s[0] * dwE) / (float) iSpeed);
  484. rDraw.top = rStart->top + ftoi((s[1] * dwE) / (float) iSpeed);
  485. rDraw.right = rStart->right + ftoi((s[2] * dwE) / (float) iSpeed);
  486. rDraw.bottom = rStart->bottom + ftoi((s[3] * dwE) / (float) iSpeed);
  487. //kprintf(1, "rDraw.left, rFinish->left: [%d, %d]", rDraw.left, rFinish->left);
  488. if (rDraw.left <= rFinish->left && p[0]) {
  489. rDraw.left = rFinish->left;
  490. done = 1;
  491. }
  492. //kprintf(1, "rDraw.top, rFinish->top: [%d, %d]", rDraw.top, rFinish->top);
  493. if (rDraw.top <= rFinish->top && p[1]) {
  494. rDraw.top = rFinish->top;
  495. done = 1;
  496. }
  497. //kprintf(1, "rDraw.right, rFinish->right: [%d, %d]", rDraw.right, rFinish->right);
  498. if (rDraw.right >= rFinish->right && p[2]) {
  499. rDraw.right = rFinish->right;
  500. done = 1;
  501. }
  502. //kprintf(1, "rDraw.bottom, rFinish->bottom: [%d, %d]", rDraw.bottom, rFinish->bottom);
  503. if (rDraw.bottom >= rFinish->bottom && p[3]) {
  504. rDraw.bottom = rFinish->bottom;
  505. done = 1;
  506. }
  507. spracuj_spravy(0);
  508. ddxUpdateMouse();
  509. /*if(rDraw.left <= rFinish->left &&
  510. rDraw.top <= rFinish->top &&
  511. rDraw.bottom >= rFinish->bottom &&
  512. rDraw.right >= rFinish->right)
  513. done = 1; */
  514. if (ddxRestore(p_ad))
  515. return;
  516. }
  517. ddxStretchBltDisplay(rFinish, iSurface, &rBmp);
  518. DisplayFrame();
  519. ddxStretchBltDisplay(rFinish, iSurface, &rBmp);
  520. }
  521. //------------------------------------------------------------------------------------------------
  522. // spusti nahodny zvuk podle zadani
  523. //------------------------------------------------------------------------------------------------
  524. int mPlaySound(CMD_LINE * cmd, AUDIO_DATA * p_ad, int type)
  525. {
  526. float pos[3] = { 0.0f, 0.0f, 1.0f };
  527. int r = rand() % 4, ret = -1;
  528. if (cmd->iParam[r + 1] < 0) {
  529. if (cmd->iParam[1] >= 0) {
  530. //adas_Get_Listener_Position(pos);
  531. //if(karmin_aktivni)
  532. //ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[1], NULL, p_ad);
  533. }
  534. }
  535. else {
  536. // adas_Get_Listener_Position(pos);
  537. //if(karmin_aktivni)
  538. //ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[r+1], NULL, p_ad);
  539. }
  540. return ret;
  541. }
  542. void GetSceneParam(int iScene, int *iStartLevel, int *iNumOfLevels)
  543. {
  544. switch (iScene) {
  545. case 1:
  546. *iStartLevel = 0;
  547. *iNumOfLevels = 11;
  548. return;
  549. case 2:
  550. *iStartLevel = 11;
  551. *iNumOfLevels = 10;
  552. return;
  553. case 3:
  554. *iStartLevel = 21;
  555. *iNumOfLevels = 12;
  556. return;
  557. case 4:
  558. *iStartLevel = 33;
  559. *iNumOfLevels = 10;
  560. return;
  561. case 5:
  562. *iStartLevel = 43;
  563. *iNumOfLevels = 10;
  564. return;
  565. case 6:
  566. *iStartLevel = 53;
  567. *iNumOfLevels = 10;
  568. return;
  569. case 7:
  570. *iStartLevel = 63;
  571. *iNumOfLevels = 10;
  572. return;
  573. case 8:
  574. *iStartLevel = 73;
  575. *iNumOfLevels = 12;
  576. return;
  577. case 9:
  578. *iStartLevel = 85;
  579. *iNumOfLevels = 10;
  580. return;
  581. }
  582. }
  583. int SceneDone(void)
  584. {
  585. int i;
  586. int iStartLevel = 0;
  587. int iNumOfLevels = 0;
  588. GetSceneParam(iActualScene, &iStartLevel, &iNumOfLevels);
  589. for (i = iStartLevel; i < iStartLevel + iNumOfLevels; i++)
  590. if (!pPlayerProfile.cLevel[i])
  591. return 0;
  592. return 1;
  593. }
  594. //------------------------------------------------------------------------------------------------
  595. // spusti level
  596. //------------------------------------------------------------------------------------------------
  597. int RunLevel(HWND hWnd, AUDIO_DATA * p_ad, int cpu, char *lvl, char *env)
  598. {
  599. int ret;
  600. unsigned int Timer_ID;
  601. char cenv[64];
  602. float f = 0; //p_ad->Music_Gain;
  603. strcpy(cenv, env);
  604. /*
  605. if(ogg_playing())
  606. {
  607. while(f >= 0.05f)
  608. {
  609. f -= 0.05f;
  610. ogg_gain(f);
  611. Sleep(25);
  612. }
  613. ap_Stop_Song(p_ad);
  614. }
  615. */
  616. // Sleep(1000);
  617. ddxRelease();
  618. FreeDirectDraw();
  619. ShowCursor(FALSE);
  620. if (kom_graf_init()) {
  621. RunMenuLoadScreen2();
  622. RunMenuLoadScreenInitBar(15);
  623. RunMenuLoadScreenAddProgress(-1);
  624. RunMenuLoadScreenDrawProgress(-1, -1);
  625. _3d_Init();
  626. _3d_Load_List("3D_load.dat");
  627. _3d_Gen_Hints(pHintTexture, 26);
  628. RunMenuLoadScreenAddProgress(-1);
  629. _3d_Load_Indikace();
  630. Timer_ID = SetTimer(NULL, 0, 250, (TIMERPROC) gl_Set_Frame_Rate);
  631. /*
  632. adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
  633. adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
  634. */
  635. ret = gl_Run_Level(lvl, cenv, NULL, cpu);
  636. if (ret == 1)
  637. pPlayerProfile.cLevel[iActualLevel] = 1;
  638. else if (ret == -1)
  639. RunMenuLoadScreenRelease(3);
  640. kprintf(1, "KillTimer");
  641. KillTimer(NULL, Timer_ID);
  642. kprintf(1, "_3d_Release_Hints");
  643. _3d_Release_Hints(pHintTexture, 26);
  644. kprintf(1, "_3d_Release");
  645. _3d_Release();
  646. kprintf(1, "kom_graf_konec");
  647. kom_graf_konec(!bWindowMenu);
  648. spracuj_spravy(0);
  649. //maximalizuj_okno(NULL);
  650. ShowCursor(TRUE);
  651. spracuj_spravy(0);
  652. }
  653. else {
  654. //----------------------- MessageBox ......
  655. kprintf(1, "kom_graf_init - nepodarilo se nahodit");
  656. MyMessageBox(NULL, "##error_title", "##kom_graf_init_error", "");
  657. spracuj_spravy(0);
  658. //maximalizuj_okno(NULL);
  659. ShowCursor(TRUE);
  660. spracuj_spravy(0);
  661. }
  662. kprintf(1, "ddxInit");
  663. ddxInit();
  664. spracuj_spravy(0);
  665. kprintf(1, "InitDirectDraw");
  666. InitDirectDraw(NULL, 1024, 768, GetPrivateProfileInt("hra", "menu_bpp", 16,
  667. ini_file));
  668. spracuj_spravy(0);
  669. kprintf(1, "ddxLoadList");
  670. ddxLoadList("2d_load.dat", 0);
  671. spracuj_spravy(0);
  672. kprintf(1, "ddxFindFreeSurface");
  673. iCompositDC = ddxFindFreeSurface();
  674. kprintf(1, "ddxCreateSurface");
  675. CompositDC = ddxCreateSurface(1024, 768, iCompositDC);
  676. kprintf(1, "ddxFindFreeSurface");
  677. iFontDC = ddxFindFreeSurface();
  678. kprintf(1, "ddxCreateSurface");
  679. FontDC = ddxCreateSurface(1024, 768, iFontDC);
  680. kprintf(1, "ddxFindFreeSurface");
  681. iBackDC = ddxFindFreeSurface();
  682. kprintf(1, "ddxCreateSurface");
  683. BackDC = ddxCreateSurface(1024, 768, iBackDC);
  684. spracuj_spravy(0);
  685. ZeroAnimations();
  686. bNewScene = 0;
  687. #ifndef __DEMO
  688. //pokud se jedna o herni scenu
  689. if (iActualScene > 0 && iActualScene < 10)
  690. if (SceneDone() && !pPlayerProfile.cMovie[iActualScene]) {
  691. PLAYER_PROFILE pProfile;
  692. pPlayerProfile.cMovie[iActualScene] = 1;
  693. pr_SaveProfile(&pPlayerProfile);
  694. if (iActualScene < 9) {
  695. memcpy(&pProfile, &pPlayerProfile, sizeof(PLAYER_PROFILE));
  696. pProfile.cScene[iActualScene + 1] = 1;
  697. pr_SaveProfile(&pProfile);
  698. }
  699. //ogg_gain(p_ad->Music_Gain);
  700. RunMenuComix("menu_comix.txt", NULL, p_ad, iActualScene);
  701. if (iActualScene < 9)
  702. bNewScene = 1;
  703. if (iActualScene == 9) {
  704. cr_Credits(NULL, p_ad);
  705. cRestartMainMenu = 1;
  706. bNewScene = 1;
  707. iActualScene = 0;
  708. }
  709. }
  710. else {
  711. //ap_Play_Song(0,0,p_ad);
  712. //adas_OGG_Set_Priority(cpu);
  713. }
  714. else {
  715. //ap_Play_Song(0,0,p_ad);
  716. //adas_OGG_Set_Priority(cpu);
  717. }
  718. #endif
  719. #ifdef __DEMO
  720. //ap_Play_Song(0,0,p_ad);
  721. #endif
  722. cBrutalRestart = 1;
  723. return ret;
  724. }
  725. //------------------------------------------------------------------------------------------------
  726. // spusti credity
  727. //------------------------------------------------------------------------------------------------
  728. void Credits(HWND hWnd, AUDIO_DATA * p_ad, int cpu)
  729. {
  730. char dir[256];
  731. StopAll();
  732. /*
  733. if(ogg_playing())
  734. ap_Stop_Song(p_ad);
  735. */
  736. SetCursor(NULL);
  737. _2d_Release();
  738. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  739. working_file_translate(dir, 256);
  740. chdir((dir));
  741. cr_Credits(NULL, p_ad);
  742. _2d_Init();
  743. _2d_APAK_Load_List("2d_load.dat");
  744. //ap_Play_Song(0,0,p_ad);
  745. //adas_OGG_Set_Priority(cpu);
  746. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  747. working_file_translate(dir, 256);
  748. chdir((dir));
  749. //SetCursor(LoadCursor(NULL, IDC_ARROW));
  750. spracuj_spravy(0);
  751. ShowCursor(TRUE);
  752. spracuj_spravy(0);
  753. }
  754. void CreateFontAnimations(CMD_LINE * res, int *lastcmd)
  755. {
  756. int lcmd = *lastcmd;
  757. char text[256];
  758. RECT r = { 0, 0, 0, 0 };
  759. int i;
  760. int sidx1, sidx2;
  761. int y;
  762. for (i = 0; i < lcmd; i++)
  763. if (res[i].iParam[0] == COM_SETRECT) {
  764. r.left = res[i].iParam[1];
  765. r.top = res[i].iParam[2];
  766. r.right = res[i].iParam[3];
  767. r.bottom = res[i].iParam[4];
  768. }
  769. y = r.top;
  770. for (i = 0; i < lcmd; i++)
  771. if (res[i].iParam[0] == COM_CREATEBUTTON)
  772. if (fn_Gen_Menu_Text(0, HDC2DD, res[i].cParam[0], &sidx1, &sidx2) != -1)
  773. if (sidx1 != -1 && sidx2 != -1) {
  774. int ii;
  775. int oy = res[i].iParam[2];
  776. //int x = r.left + ftoi((r.right - r.left - _2dd.bitmap[sidx1].bitmap.bmWidth) / (float)2.0f);
  777. int x =
  778. r.left + ftoi((r.right - r.left -
  779. ddxGetWidth(sidx1)) / (float) 2.0f);
  780. if (res[i].iParam[1] != -1) {
  781. oy = res[i].iParam[2];
  782. y = oy;
  783. x = res[i].iParam[1];
  784. }
  785. else {
  786. oy = res[i].iParam[2];
  787. y = oy;
  788. }
  789. y += ddxGetHight(sidx1);
  790. //OnAbove(16,661,100,748, quit_game.txt, NO_EXEPTION)
  791. sprintf(text, "OnAbove(%d,%d,%d,%d, NO_EXEPTION, NO_EXEPTION)", x,
  792. oy, x + ddxGetWidth(sidx1), y);
  793. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  794. res[*lastcmd].cParam[1]);
  795. res[*lastcmd].uiTimerID = 0;
  796. res[*lastcmd].iLastfrm = 1;
  797. res[*lastcmd].iCounter = 0;
  798. /*
  799. (0, 123, 0, 640, 0, 1)
  800. (1, 124, 0, 640, 25, 2)
  801. (2, 124, 0, 640, 25, -1)
  802. */
  803. res[*lastcmd].iAnim[0][0] = 0;
  804. res[*lastcmd].iAnim[0][1] = sidx1;
  805. res[*lastcmd].iAnim[0][2] = x;
  806. res[*lastcmd].iAnim[0][3] = oy;
  807. res[*lastcmd].iAnim[0][4] = 0;
  808. res[*lastcmd].iAnim[0][5] = 1;
  809. for (ii = 6; ii < 13; ii++)
  810. res[*lastcmd].iAnim[0][ii] = -1;
  811. x =
  812. r.left + ftoi((r.right - r.left -
  813. ddxGetWidth(sidx2)) / (float) 2.0f);
  814. if (res[i].iParam[1] != -1)
  815. x = res[i].iParam[1];
  816. res[*lastcmd].iAnim[1][0] = 1;
  817. res[*lastcmd].iAnim[1][1] = sidx2;
  818. res[*lastcmd].iAnim[1][2] = x;
  819. res[*lastcmd].iAnim[1][3] = oy;
  820. res[*lastcmd].iAnim[1][4] = 50;
  821. res[*lastcmd].iAnim[1][5] = 2;
  822. for (ii = 6; ii < 13; ii++)
  823. res[*lastcmd].iAnim[1][ii] = -1;
  824. res[*lastcmd].iAnim[2][0] = 2;
  825. res[*lastcmd].iAnim[2][1] = sidx2;
  826. res[*lastcmd].iAnim[2][2] = x;
  827. res[*lastcmd].iAnim[2][3] = oy;
  828. res[*lastcmd].iAnim[2][4] = 50;
  829. res[*lastcmd].iAnim[2][5] = -1;
  830. for (ii = 6; ii < 13; ii++)
  831. res[*lastcmd].iAnim[2][ii] = -1;
  832. res[*lastcmd].iLayer = 1;
  833. (*lastcmd)++;
  834. //Draw(1,0,0)
  835. sprintf(text, "Draw(%d,%d,%d)", sidx1, x, oy);
  836. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  837. res[*lastcmd].cParam[1]);
  838. res[*lastcmd].iLayer = 1;
  839. (*lastcmd)++;
  840. //OnClick(16,661,100,748, quit_gamec.txt, EXIT)
  841. sprintf(text, "OnClick(%d,%d,%d,%d, NO_EXEPTION, %s)", x, oy,
  842. x + ddxGetWidth(sidx1), y, res[i].cParam[1]);
  843. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  844. res[*lastcmd].cParam[1]);
  845. res[*lastcmd].iLayer = 1;
  846. (*lastcmd)++;
  847. //BindSound(54,55,56,-1)
  848. strcpy(text, "BindSound(54,55,56,-1)");
  849. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  850. res[*lastcmd].cParam[1]);
  851. res[*lastcmd].iLayer = 0;
  852. (*lastcmd)++;
  853. }
  854. }
  855. void SetTab(int iTab, int iLTab, CONTROL_LIST_ITEM * p_list, int lsize,
  856. int *hdcTab)
  857. {
  858. int i;
  859. if (iLTab > -1) {
  860. //BitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, _2dd.hDC, TAB_X, TAB_Y, SRCCOPY);
  861. ddxBitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, HDC2DD, TAB_X, TAB_Y);
  862. }
  863. for (i = 0; i < lsize; i++)
  864. if ((p_list + i)->iTab == iTab && !(p_list + i)->bDisabled)
  865. (p_list + i)->bActive = 1;
  866. else if ((p_list + i)->iTab != -1)
  867. (p_list + i)->bActive = 0;
  868. //BitBlt(_2dd.hDC, TAB_X, TAB_Y, TAB_XRES, TAB_YRES, hdcTab[iTab], 0, 0, SRCCOPY);
  869. ddxBitBltDisplay(TAB_X, TAB_Y, TAB_XRES, TAB_YRES, hdcTab[iTab], 0, 0);
  870. DisplayFrame();
  871. }
  872. int CheckRozliseni(ROZLISENI * res, int roz_size, DWORD x, DWORD y, DWORD bpp)
  873. {
  874. int i;
  875. for (i = 0; i < roz_size; i++)
  876. if (res[i].x == x && res[i].y == y && res[i].bpp == bpp)
  877. return 1;
  878. return 0;
  879. }
  880. void EnumRozliseni(ROZLISENI ** res, int *roz_size)
  881. {
  882. /*
  883. int i=0 , j=0;
  884. DEVMODE dmSettings;
  885. memset(&dmSettings,0,sizeof(dmSettings));
  886. dmSettings.dmSize = sizeof(DEVMODE);
  887. kprintf(1, "Detekce rozliseni ---------------------------------------------------- ");
  888. while(EnumDisplaySettings(NULL,i,&dmSettings))
  889. {
  890. kprintf(1, "%d x %d x %d [%dHz]", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel, dmSettings.dmDisplayFrequency);
  891. memset(&dmSettings,0,sizeof(dmSettings));
  892. dmSettings.dmSize = sizeof(DEVMODE);
  893. i++;
  894. }
  895. (*roz_size) = i;
  896. kprintf(1, "Pocet rozliseni = %d", i);
  897. (*res) = malloc((*roz_size) * sizeof(ROZLISENI));
  898. memset((*res), 0, (*roz_size) * sizeof(ROZLISENI));
  899. j = 0;
  900. i = 0;
  901. while(EnumDisplaySettings(NULL,i,&dmSettings))
  902. {
  903. if(dmSettings.dmBitsPerPel > 8 && dmSettings.dmPelsWidth > 600)
  904. {
  905. if(CheckRozliseni((*res), j, dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel))
  906. {
  907. kprintf(1, "Skip (%d x %d x %d)", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel);
  908. goto NEXT_ENUM;
  909. }
  910. */
  911. /*if(j > 0)
  912. if((*res)[j-1].bpp == dmSettings.dmBitsPerPel &&
  913. (*res)[j-1].x == dmSettings.dmPelsWidth &&
  914. (*res)[j-1].y == dmSettings.dmPelsHeight)
  915. {
  916. kprintf(1, "Skip (%d x %d x %d)", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel);
  917. goto NEXT_ENUM;
  918. } */
  919. /*
  920. (*res)[j].bpp = dmSettings.dmBitsPerPel;
  921. (*res)[j].x = dmSettings.dmPelsWidth;
  922. (*res)[j].y = dmSettings.dmPelsHeight;
  923. (*res)[j].freq = dmSettings.dmDisplayFrequency;
  924. j++;
  925. kprintf(1, "ComboAddItem (%d x %d x %d)", dmSettings.dmPelsWidth, dmSettings.dmPelsHeight, dmSettings.dmBitsPerPel);
  926. if(j >= (*roz_size))
  927. break;
  928. }
  929. NEXT_ENUM:
  930. memset(&dmSettings,0,sizeof(dmSettings));
  931. dmSettings.dmSize = sizeof(DEVMODE);
  932. i++;
  933. }
  934. */
  935. }
  936. void Key2String(int k, char *text)
  937. {
  938. sprintf(text, "##control_k_%d", k);
  939. return;
  940. }
  941. void CharMenuCheckMultyKyes(LIST_VIEW_CONTROL * p_li, int iKey)
  942. {
  943. int y;
  944. int i;
  945. RECT r;
  946. for (i = 0; i < p_li->listnum; i++)
  947. if (i != p_li->cSelected && p_li->piValue[i].iValue == iKey) {
  948. y = i * 30;
  949. r.left = 550;
  950. r.top = y + 2;
  951. r.right = r.left + (ddxGetWidth(p_li->bDCn) - 550);
  952. r.bottom = r.top + 28;
  953. ddxFillRect(p_li->bDCn, &r, 0);
  954. ddxFillRect(p_li->bDCs, &r, 0);
  955. co_List_Add_String(p_li, i, 550, "##control_k_255", 255, 0);
  956. }
  957. }
  958. void SetCharMenu(LIST_VIEW_CONTROL * p_li)
  959. {
  960. char text[128];
  961. int y = p_li->cSelected * 30;
  962. int xs = p_li->rectList.top + TAB_Y + y - p_li->dx;
  963. int xp = 0;
  964. int xt = 0;
  965. int i;
  966. int iCursor = 0;
  967. RECT r;
  968. if (!p_li->cSelected || p_li->cSelected == 11 || p_li->cSelected == 19)
  969. return;
  970. r.left = 550;
  971. r.top = y + 2;
  972. r.right = r.left + (ddxGetWidth(p_li->bDCn) - 550);
  973. r.bottom = r.top + 28;
  974. ddxFillRect(p_li->bDCn, &r, 0);
  975. ddxFillRect(p_li->bDCs, &r, 0);
  976. if (y - p_li->dx < 0)
  977. xp = (y - p_li->dx) * -1;
  978. if ((p_li->rectList.top + TAB_Y + y - p_li->dx + 30) >
  979. p_li->rectList.bottom + TAB_Y)
  980. xt =
  981. (p_li->rectList.top + TAB_Y + y - p_li->dx + 30) -
  982. (p_li->rectList.bottom + TAB_Y);
  983. ddxBitBlt(HDC2DD, p_li->rectList.left + TAB_X,
  984. p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddxGetWidth(p_li->bDCs),
  985. 30 - xp - xt, p_li->bDCs, 0, y + xp);
  986. r.top = p_li->rectList.top + TAB_Y + y - p_li->dx + xp - 2;
  987. r.left = 665;
  988. r.right = r.left + 220;
  989. r.bottom = r.top + 27;
  990. DisplayFrame();
  991. while (!key[0]) {
  992. Sleep(10);
  993. spracuj_spravy(0);
  994. ddxUpdateMouse();
  995. if (key[K_F1] || key[K_F2] || key[K_F3] || key[K_F10] || key[K_PLUS]
  996. || key[K_MINUS]) {
  997. key[0] = 0;
  998. key[K_F1] = 0;
  999. key[K_F2] = 0;
  1000. key[K_F3] = 0;
  1001. key[K_F10] = 0;
  1002. key[K_PLUS] = 0;
  1003. key[K_MINUS] = 0;
  1004. }
  1005. if (iCursor < 100)
  1006. ddxFillRectDisplay(&r, RGB(63, 122, 163));
  1007. else if (iCursor > 99 && iCursor < 200)
  1008. ddxFillRectDisplay(&r, 0);
  1009. else {
  1010. iCursor = 0;
  1011. ddxFillRectDisplay(&r, 0);
  1012. }
  1013. iCursor += 4;
  1014. //if(dim.dx || dim.dy)
  1015. DisplayFrame();
  1016. }
  1017. key[0] = 0;
  1018. for (i = 0; i < POCET_KLAVES; i++)
  1019. if (key[i]) {
  1020. sprintf(text, "##control_k_%d", i);
  1021. key[i] = 0;
  1022. break;
  1023. }
  1024. co_List_Add_String(p_li, p_li->cSelected, 550, text, i, 0);
  1025. CharMenuCheckMultyKyes(p_li, i);
  1026. ddxBitBlt(HDC2DD, p_li->rectList.left + TAB_X, p_li->rectList.top + TAB_Y,
  1027. ddxGetWidth(p_li->bDCn), p_li->rectList.bottom - p_li->rectList.top,
  1028. p_li->bDCn, 0, p_li->dx);
  1029. ddxBitBlt(HDC2DD, p_li->rectList.left + TAB_X,
  1030. p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddxGetWidth(p_li->bDCs),
  1031. 30 - xp - xt, p_li->bDCs, 0, y + xp);
  1032. DisplayFrame();
  1033. }
  1034. void SetMenuSettings(ROZLISENI * roz, CONTROL_LIST_ITEM * citem,
  1035. int *hdcTabUse)
  1036. {
  1037. float f;
  1038. int i;
  1039. if (hdcTabUse[0]) {
  1040. //setup.pohled_berusky = co_Check_Get_State(citem, CLIST_ITEMC, 0);
  1041. setup.posouvat_kameru = co_Check_Get_State(citem, CLIST_ITEMC, 1);
  1042. setup.ovladani = co_Check_Get_State(citem, CLIST_ITEMC, 2);
  1043. //setup.menu_vram_load = co_Check_Get_State(citem, CLIST_ITEMC, 3);
  1044. setup.start_zpruhlednovani = co_Check_Get_State(citem, CLIST_ITEMC, 10);
  1045. setup.start_zvyraznovani = co_Check_Get_State(citem, CLIST_ITEMC, 11);
  1046. setup.ovladani_rohy = co_Check_Get_State(citem, CLIST_ITEMC, 12);
  1047. setup.camera_intro = co_Check_Get_State(citem, CLIST_ITEMC, 16);
  1048. i = co_Check_Get_State(citem, CLIST_ITEMC, 13);
  1049. if (i)
  1050. setup.ovladani_rohy_default = 0;
  1051. else
  1052. setup.ovladani_rohy_default = 1;
  1053. setup.ovladani_rohy_smer = co_Check_Get_State(citem, CLIST_ITEMC, 15);
  1054. //setup.ovladani_pr_posun = co_Check_Get_State(citem, CLIST_ITEMC, 16);
  1055. setup.ovladani_rohy_rychlost =
  1056. co_Progres_Get(citem, CLIST_ITEMC, 0) / 10.0f;
  1057. setup.p_kamera_radius = co_Progres_Get(citem, CLIST_ITEMC, 1) / 2.0f;
  1058. }
  1059. if (hdcTabUse[1]) {
  1060. i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 0);
  1061. setup.xres = roz[i].x;
  1062. setup.yres = roz[i].y;
  1063. setup.bpp = (char) roz[i].bpp;
  1064. setup.general_3d = co_Combo_Get_Sel(citem, CLIST_ITEMC, 1);
  1065. i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 2);
  1066. if (!i)
  1067. setup.extra_light_vertex = 1;
  1068. else
  1069. setup.extra_light_vertex = 0;
  1070. setup.kvalita_casticv = co_Combo_Get_Sel(citem, CLIST_ITEMC, 5);
  1071. i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 6);
  1072. if (i == 3)
  1073. setup.light_dyn = 0;
  1074. else {
  1075. setup.light_dyn = 1;
  1076. setup.light_rychlost = i + 1;
  1077. }
  1078. setup.text_detail2 = co_Combo_Get_Sel(citem, CLIST_ITEMC, 3);
  1079. setup.text_detail3 = co_Combo_Get_Sel(citem, CLIST_ITEMC, 4);
  1080. i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 7);
  1081. switch (i) {
  1082. case 2:
  1083. setup.bump_mapping = 0;
  1084. break;
  1085. case 1:
  1086. setup.bump_mapping = 1;
  1087. setup.text_bump2 = 1;
  1088. setup.text_bump3 = 0;
  1089. break;
  1090. case 0:
  1091. setup.bump_mapping = 1;
  1092. setup.text_bump2 = 1;
  1093. setup.text_bump3 = 1;
  1094. break;
  1095. }
  1096. setup.text_mip_mapping = co_Combo_Get_Sel(citem, CLIST_ITEMC, 8);
  1097. i = co_Combo_Get_Sel(citem, CLIST_ITEMC, 9);
  1098. if (!i)
  1099. setup.text_bpp = 32;
  1100. else
  1101. setup.text_bpp = 16;
  1102. i = co_Combo_Drop_Get_Sel(citem, CLIST_ITEMC, 0, &f);
  1103. if (!i)
  1104. setup.text_ans = 0;
  1105. else {
  1106. setup.text_ans = 1;
  1107. setup.text_ans_stupen = i;
  1108. }
  1109. setup.text_kvalita = co_Combo_Get_Sel(citem, CLIST_ITEMC, 10);
  1110. setup.text_komprese = co_Check_Get_State(citem, CLIST_ITEMC, 6);
  1111. setup.ditering = co_Check_Get_State(citem, CLIST_ITEMC, 7);
  1112. setup.zrcado_aktivni = co_Check_Get_State(citem, CLIST_ITEMC, 4);
  1113. setup.scene_materialy = co_Check_Get_State(citem, CLIST_ITEMC, 8);
  1114. setup.vertex_arrays = co_Check_Get_State(citem, CLIST_ITEMC, 9);
  1115. setup.menu_vram_load = co_Check_Get_State(citem, CLIST_ITEMC, 10);
  1116. co_Combo_Drop_Get_Sel(citem, CLIST_ITEMC, 10, &setup.text_ostrost);
  1117. }
  1118. if (hdcTabUse[2]) {
  1119. setup.soundvolume = co_Progres_Get(citem, CLIST_ITEMC, 4);
  1120. setup.ambientvolume = co_Progres_Get(citem, CLIST_ITEMC, 5);
  1121. setup.musicvolume = co_Progres_Get(citem, CLIST_ITEMC, 6);
  1122. }
  1123. if (hdcTabUse[3]) {
  1124. setup.key[1] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 1);
  1125. setup.key[2] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 2);
  1126. setup.key[3] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 3);
  1127. setup.key[4] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 4);
  1128. setup.key[5] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 5);
  1129. setup.key[6] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 6);
  1130. setup.key[7] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 7);
  1131. setup.key[8] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 8);
  1132. setup.key[9] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 9);
  1133. setup.key[10] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 10);
  1134. setup.key[12] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 12);
  1135. setup.key[13] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 13);
  1136. setup.key[14] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 14);
  1137. setup.key[15] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 15);
  1138. setup.key[16] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 16);
  1139. setup.key[17] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 17);
  1140. setup.key[18] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 18);
  1141. setup.key[20] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 20);
  1142. setup.key[21] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 21);
  1143. setup.key[22] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 22);
  1144. setup.key[23] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 23);
  1145. setup.key[24] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 24);
  1146. setup.key[25] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 25);
  1147. setup.key[26] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 26);
  1148. setup.key[27] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 27);
  1149. setup.key[28] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 28);
  1150. setup.key[29] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 29);
  1151. setup.key[30] = co_List_Get_Value(citem, CLIST_ITEMC, 0, 30);
  1152. }
  1153. }
  1154. void SetMenuSettingsS(ROZLISENI * roz, CONTROL_LIST_ITEM * citem,
  1155. int *hdcTabUse)
  1156. {
  1157. if (hdcTabUse[2]) {
  1158. setup.soundvolume = co_Progres_Get(citem, CLIST_ITEMC, 4);
  1159. setup.ambientvolume = co_Progres_Get(citem, CLIST_ITEMC, 5);
  1160. setup.musicvolume = co_Progres_Get(citem, CLIST_ITEMC, 6);
  1161. }
  1162. }
  1163. void InitTab3d(CONTROL_LIST_ITEM * citem, int *hdcTab, ROZLISENI * roz,
  1164. int roz_size)
  1165. {
  1166. int i;
  1167. int count = 0;
  1168. int iClock;
  1169. iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
  1170. ddxResizeCursorBack(iClock);
  1171. DrawClock(&iClock, 0);
  1172. co_Set_Text_Right(hdcTab[1], "##settings_resolution", 0, 285, 57);
  1173. citem[8].p_combo = co_Create_Combo(hdcTab[1], 300, 50, 450, 0);
  1174. citem[8].iTab = 1;
  1175. for (i = 0; i < roz_size; i++) {
  1176. if (roz[i].bpp > 0) {
  1177. char text[256];
  1178. sprintf(text, "%dx%dx%d", roz[i].x, roz[i].y, roz[i].bpp);
  1179. co_Combo_Add_String(citem[8].p_combo, text);
  1180. count++;
  1181. }
  1182. }
  1183. if (count > 10)
  1184. co_Combo_Set_Params(citem[8].p_combo, 10);
  1185. else
  1186. co_Combo_Set_Params(citem[8].p_combo, count);
  1187. co_Combo_Set_Sel(hdcTab[1], citem[8].p_combo, GetResCombobox(roz,
  1188. roz_size));
  1189. //////////////////////////////##settings_gemeral_3d
  1190. co_Set_Text_Right(hdcTab[1], "##settings_gemeral_3d", 0, 285, 97);
  1191. citem[9].p_combo = co_Create_Combo(hdcTab[1], 300, 90, 100, 1);
  1192. citem[9].iTab = 1;
  1193. co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_high");
  1194. co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_normal");
  1195. co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_low");
  1196. co_Combo_Add_StringWC(citem[9].p_combo, "##settings_gemeral_3d_elow");
  1197. co_Combo_Set_Params(citem[9].p_combo, 4);
  1198. co_Combo_Set_Sel(hdcTab[1], citem[9].p_combo, setup.general_3d);
  1199. /////////////////////////////////##settings_model
  1200. co_Set_Text_Right(hdcTab[1], "##settings_model", 0, 285, 137);
  1201. citem[33].p_combo = co_Create_Combo(hdcTab[1], 300, 130, 100, 2);
  1202. citem[33].iTab = 1;
  1203. co_Combo_Add_StringWC(citem[33].p_combo, "##settings_gemeral_3d_high");
  1204. co_Combo_Add_StringWC(citem[33].p_combo, "##settings_gemeral_3d_normal");
  1205. co_Combo_Set_Params(citem[33].p_combo, 2);
  1206. if (!setup.extra_light_vertex)
  1207. co_Combo_Set_Sel(hdcTab[1], citem[33].p_combo, 1);
  1208. else
  1209. co_Combo_Set_Sel(hdcTab[1], citem[33].p_combo, 0);
  1210. co_Set_Text_Right(hdcTab[1], "##settings_partices_weather", 0, 285, 177);
  1211. citem[10].p_combo = co_Create_Combo(hdcTab[1], 300, 170, 100, 5);
  1212. citem[10].iTab = 1;
  1213. co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_high");
  1214. co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_normal");
  1215. co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_low");
  1216. co_Combo_Add_StringWC(citem[10].p_combo, "##settings_gemeral_3d_elow");
  1217. co_Combo_Set_Params(citem[10].p_combo, 4);
  1218. co_Combo_Set_Sel(hdcTab[1], citem[10].p_combo, setup.kvalita_casticv);
  1219. co_Set_Text_Right(hdcTab[1], "#settings_lights", 0, 285, 217);
  1220. citem[32].p_combo = co_Create_Combo(hdcTab[1], 300, 210, 130, 6);
  1221. citem[32].iTab = 1;
  1222. co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_high");
  1223. co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_normal");
  1224. co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_low");
  1225. //co_Combo_Add_StringWC(citem[32].p_combo, "##settings_gemeral_3d_elow");
  1226. co_Combo_Add_StringWC(citem[32].p_combo, "##settings_lights_off");
  1227. co_Combo_Set_Params(citem[32].p_combo, 4);
  1228. if (!setup.light_dyn)
  1229. co_Combo_Set_Sel(hdcTab[1], citem[32].p_combo, 3);
  1230. else
  1231. co_Combo_Set_Sel(hdcTab[1], citem[32].p_combo, setup.light_rychlost - 1);
  1232. /////////////////////////////////##settings_item_textures
  1233. co_Set_Text_Right(hdcTab[1], "##settings_item_textures", 0, 285, 257);
  1234. citem[34].p_combo = co_Create_Combo(hdcTab[1], 300, 250, 100, 3);
  1235. citem[34].iTab = 1;
  1236. co_Combo_Add_StringWC(citem[34].p_combo, "##settings_gemeral_3d_high");
  1237. co_Combo_Add_StringWC(citem[34].p_combo, "##settings_gemeral_3d_normal");
  1238. co_Combo_Add_StringWC(citem[34].p_combo, "##settings_gemeral_3d_low");
  1239. co_Combo_Set_Params(citem[34].p_combo, 3);
  1240. co_Combo_Set_Sel(hdcTab[1], citem[34].p_combo, setup.text_detail2);
  1241. /////////////////////////////////##settings_scene_textures
  1242. co_Set_Text_Right(hdcTab[1], "##settings_scene_textures", 0, 285, 297);
  1243. citem[35].p_combo = co_Create_Combo(hdcTab[1], 300, 290, 100, 4);
  1244. citem[35].iTab = 1;
  1245. co_Combo_Add_StringWC(citem[35].p_combo, "##settings_gemeral_3d_high");
  1246. co_Combo_Add_StringWC(citem[35].p_combo, "##settings_gemeral_3d_normal");
  1247. co_Combo_Add_StringWC(citem[35].p_combo, "##settings_gemeral_3d_low");
  1248. co_Combo_Set_Params(citem[35].p_combo, 3);
  1249. co_Combo_Set_Sel(hdcTab[1], citem[35].p_combo, setup.text_detail3);
  1250. co_Set_Text_Right(hdcTab[1], "##settings_bump", 0, 285, 337);
  1251. citem[25].p_combo = co_Create_Combo(hdcTab[1], 300, 330, 100, 7);
  1252. citem[25].iTab = 1;
  1253. co_Combo_Add_StringWC(citem[25].p_combo, "##settings_combo_all");
  1254. co_Combo_Add_StringWC(citem[25].p_combo, "##settings_combo_items");
  1255. co_Combo_Add_StringWC(citem[25].p_combo, "##settings_combo_turnoff");
  1256. co_Combo_Set_Params(citem[25].p_combo, 3);
  1257. if (!setup.bump_mapping)
  1258. co_Combo_Set_Sel(hdcTab[1], citem[25].p_combo, 2);
  1259. else if (setup.bump_mapping && setup.text_bump2 && !setup.text_bump3)
  1260. co_Combo_Set_Sel(hdcTab[1], citem[25].p_combo, 1);
  1261. else
  1262. co_Combo_Set_Sel(hdcTab[1], citem[25].p_combo, 0);
  1263. co_Set_Text_Right(hdcTab[1], "##settings_texture_filterig", 0, 285, 377);
  1264. citem[18].p_combo = co_Create_Combo(hdcTab[1], 300, 370, 100, 8);
  1265. citem[18].iTab = 1;
  1266. co_Combo_Add_StringWC(citem[18].p_combo,
  1267. "##settings_texture_filterig_linear");
  1268. co_Combo_Add_StringWC(citem[18].p_combo, "##settings_texture_mip_mapping");
  1269. co_Combo_Set_Params(citem[18].p_combo, 2);
  1270. co_Combo_Set_Sel(hdcTab[1], citem[18].p_combo, setup.text_mip_mapping);
  1271. co_Set_Text_Right(hdcTab[1], "##settings_texture_depth", 0, 285, 417);
  1272. citem[26].p_combo = co_Create_Combo(hdcTab[1], 300, 410, 100, 9);
  1273. citem[26].iTab = 1;
  1274. co_Combo_Add_StringWC(citem[26].p_combo, "##settings_texture_depth_32");
  1275. co_Combo_Add_StringWC(citem[26].p_combo, "##settings_texture_depth_16");
  1276. co_Combo_Set_Params(citem[26].p_combo, 2);
  1277. if (setup.text_bpp == 32)
  1278. co_Combo_Set_Sel(hdcTab[1], citem[26].p_combo, 0);
  1279. else
  1280. co_Combo_Set_Sel(hdcTab[1], citem[26].p_combo, 1);
  1281. co_Set_Text_Right(hdcTab[1], "##settings_anisotropic_filtering", 0, 285,
  1282. 457);
  1283. citem[27].p_combod = co_Create_Combo_Drop(hdcTab[1], 300, 450, 0);
  1284. citem[27].iTab = 1;
  1285. co_Combo_Drop_Add_StringWC(citem[27].p_combod, "##settings_lights_turnoff",
  1286. 0.0f);
  1287. co_Combo_Drop_Add_String(citem[27].p_combod, "2", 2.0f);
  1288. co_Combo_Drop_Add_String(citem[27].p_combod, "4", 4.0f);
  1289. co_Combo_Drop_Add_String(citem[27].p_combod, "8", 8.0f);
  1290. co_Combo_Drop_Add_String(citem[27].p_combod, "16", 16.0f);
  1291. co_Combo_Drop_Add_String(citem[27].p_combod, "32", 32.0f);
  1292. if (!setup.text_ans)
  1293. co_Combo_Drop_Set_Sel(hdcTab[1], citem[27].p_combod, 0);
  1294. else
  1295. co_Combo_Drop_Set_Sel(hdcTab[1], citem[27].p_combod,
  1296. setup.text_ans_stupen);
  1297. co_Set_Text_Right(hdcTab[1], "##settings_sharpness", 0, 285, 497);
  1298. citem[42].p_combod = co_Create_Combo_Drop(hdcTab[1], 300, 490, 10);
  1299. citem[42].iTab = 1;
  1300. co_Combo_Drop_Add_String(citem[42].p_combod, "-3.0", -3.0f);
  1301. co_Combo_Drop_Add_String(citem[42].p_combod, "-2.75", -2.75f);
  1302. co_Combo_Drop_Add_String(citem[42].p_combod, "-2.5", -2.5f);
  1303. co_Combo_Drop_Add_String(citem[42].p_combod, "-2.25", -2.25f);
  1304. co_Combo_Drop_Add_String(citem[42].p_combod, "-2.0", -2.0f);
  1305. co_Combo_Drop_Add_String(citem[42].p_combod, "-1.75", -1.75f);
  1306. co_Combo_Drop_Add_String(citem[42].p_combod, "-1.5", -1.5f);
  1307. co_Combo_Drop_Add_String(citem[42].p_combod, "-1.25", -1.25f);
  1308. co_Combo_Drop_Add_String(citem[42].p_combod, "-1.0", -1.0f);
  1309. co_Combo_Drop_Add_String(citem[42].p_combod, "-0.75", -0.75f);
  1310. co_Combo_Drop_Add_String(citem[42].p_combod, "-0.5", -0.5f);
  1311. co_Combo_Drop_Add_String(citem[42].p_combod, "-0.25", -0.25f);
  1312. co_Combo_Drop_Add_String(citem[42].p_combod, "0.0", 0.0f);
  1313. co_Combo_Drop_Add_String(citem[42].p_combod, "+0.25", 0.25f);
  1314. co_Combo_Drop_Add_String(citem[42].p_combod, "+0.5", 0.5f);
  1315. co_Combo_Drop_Add_String(citem[42].p_combod, "+0.75", 0.75f);
  1316. co_Combo_Drop_Add_String(citem[42].p_combod, "+1.0", 1.0f);
  1317. co_Combo_Drop_Add_String(citem[42].p_combod, "+1.25", 1.25f);
  1318. co_Combo_Drop_Add_String(citem[42].p_combod, "+1.5", 1.5f);
  1319. co_Combo_Drop_Add_String(citem[42].p_combod, "+1.75", 1.75f);
  1320. co_Combo_Drop_Add_String(citem[42].p_combod, "+2.0", 2.0f);
  1321. co_Combo_Drop_Add_String(citem[42].p_combod, "+2.25", 2.25f);
  1322. co_Combo_Drop_Add_String(citem[42].p_combod, "+2.5", 2.5f);
  1323. co_Combo_Drop_Add_String(citem[42].p_combod, "+2.75", 2.75f);
  1324. co_Combo_Drop_Add_String(citem[42].p_combod, "+3.0", 3.0f);
  1325. i = ftoi(((setup.text_ostrost + 3) * 100) / 25.0f);
  1326. if (i > 24)
  1327. i = 24;
  1328. co_Combo_Drop_Set_Sel(hdcTab[1], citem[42].p_combod, i);
  1329. co_Set_Text_Right(hdcTab[1], "##settings_opengl", 0, 285, 537);
  1330. citem[28].p_combo = co_Create_Combo(hdcTab[1], 300, 530, 100, 10);
  1331. citem[28].iTab = 1;
  1332. co_Combo_Add_StringWC(citem[28].p_combo, "##settings_opengl_rychlost");
  1333. co_Combo_Add_StringWC(citem[28].p_combo, "##settings_opengl_kvalita");
  1334. co_Combo_Set_Params(citem[28].p_combo, 2);
  1335. co_Combo_Set_Sel(hdcTab[1], citem[28].p_combo, setup.text_kvalita);
  1336. citem[16].p_check =
  1337. co_Create_CheckBox(hdcTab[1], 525, 255, "##settings_texture_commpression",
  1338. 0, 6);
  1339. citem[16].iTab = 1;
  1340. co_Check_Set_State(citem[16].p_check, hdcTab[1], setup.text_komprese, 1);
  1341. citem[29].p_check =
  1342. co_Create_CheckBox(hdcTab[1], 525, 415, "##settings_dithering", 0, 7);
  1343. citem[29].iTab = 1;
  1344. co_Check_Set_State(citem[29].p_check, hdcTab[1], setup.ditering, 1);
  1345. citem[11].p_check =
  1346. co_Create_CheckBox(hdcTab[1], 525, 135, "##settings_draw_mirror", 0, 4);
  1347. citem[11].iTab = 1;
  1348. co_Check_Set_State(citem[11].p_check, hdcTab[1], setup.zrcado_aktivni, 1);
  1349. citem[30].p_check =
  1350. co_Create_CheckBox(hdcTab[1], 525, 535, "##settings_caustic", 0, 8);
  1351. citem[30].iTab = 1;
  1352. co_Check_Set_State(citem[30].p_check, hdcTab[1], setup.scene_materialy, 1);
  1353. citem[31].p_check =
  1354. co_Create_CheckBox(hdcTab[1], 300, 580, "##settings_vertex", 0, 9);
  1355. citem[31].iTab = 1;
  1356. co_Check_Set_State(citem[31].p_check, hdcTab[1], setup.vertex_arrays, 1);
  1357. citem[44].p_check =
  1358. co_Create_CheckBox(hdcTab[1], 300, 610, "##settings_load_menu_vram", 0,
  1359. 10);
  1360. citem[44].iTab = 1;
  1361. co_Check_Set_State(citem[44].p_check, hdcTab[1], setup.menu_vram_load, 1);
  1362. ddxSetCursor(0);
  1363. DisplayFrame();
  1364. DisplayFrame();
  1365. ddxResizeCursorBack(0);
  1366. ddxSetCursorSurface(0);
  1367. ddxSetCursor(1);
  1368. DisplayFrame();
  1369. DisplayFrame();
  1370. ddxReleaseBitmap(iClock);
  1371. }
  1372. void InitTabSound(CONTROL_LIST_ITEM * citem, int *hdcTab)
  1373. {
  1374. co_Set_Text_Right(hdcTab[2], "##settings_sound", 0, 260, 50);
  1375. citem[21].p_prog = co_Create_Progres(hdcTab[2], 310, 50, 0, 100, 4);
  1376. citem[21].iTab = 2;
  1377. co_Progres_Set(citem[21].p_prog, hdcTab[2], setup.soundvolume);
  1378. co_Set_Text_Right(hdcTab[2], "##settings_ambient", 0, 260, 85);
  1379. citem[22].p_prog = co_Create_Progres(hdcTab[2], 310, 85, 0, 100, 5);
  1380. citem[22].iTab = 2;
  1381. co_Progres_Set(citem[22].p_prog, hdcTab[2], setup.ambientvolume);
  1382. co_Set_Text_Right(hdcTab[2], "##settings_music", 0, 260, 120);
  1383. citem[23].p_prog = co_Create_Progres(hdcTab[2], 310, 120, 0, 100, 6);
  1384. citem[23].iTab = 2;
  1385. co_Progres_Set(citem[23].p_prog, hdcTab[2], setup.musicvolume);
  1386. }
  1387. void InitTabControls(CONTROL_LIST_ITEM * citem, int *hdcTab)
  1388. {
  1389. char ctext[256];
  1390. int iClock;
  1391. iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
  1392. ddxResizeCursorBack(iClock);
  1393. DrawClock(&iClock, 0);
  1394. citem[24].p_list = co_Create_List(hdcTab[3], 25, 50, 800, 580, 0, 31, 0);
  1395. citem[24].iTab = 3;
  1396. co_List_Add_String(citem[24].p_list, 0, 2, "##control_beatle", 0, 1);
  1397. co_List_Add_String(citem[24].p_list, 1, 2, "##control_forward", 0, 0);
  1398. co_List_Add_String(citem[24].p_list, 2, 2, "##control_back", 0, 0);
  1399. co_List_Add_String(citem[24].p_list, 3, 2, "##control_left", 0, 0);
  1400. co_List_Add_String(citem[24].p_list, 4, 2, "##control_right", 0, 0);
  1401. co_List_Add_String(citem[24].p_list, 5, 2, "##control_nextb", 0, 0);
  1402. co_List_Add_String(citem[24].p_list, 6, 2, "##control_b1", 0, 0);
  1403. co_List_Add_String(citem[24].p_list, 7, 2, "##control_b2", 0, 0);
  1404. co_List_Add_String(citem[24].p_list, 8, 2, "##control_b3", 0, 0);
  1405. co_List_Add_String(citem[24].p_list, 9, 2, "##control_b4", 0, 0);
  1406. co_List_Add_String(citem[24].p_list, 10, 2, "##control_b5", 0, 0);
  1407. co_List_Add_String(citem[24].p_list, 11, 2, "##control_camera", 0, 1);
  1408. co_List_Add_String(citem[24].p_list, 12, 2, "##control_crotation", 0, 0);
  1409. co_List_Add_String(citem[24].p_list, 13, 2, "##control_cmove", 0, 0);
  1410. co_List_Add_String(citem[24].p_list, 14, 2, "##control_czoomin", 0, 0);
  1411. co_List_Add_String(citem[24].p_list, 15, 2, "##control_czoomout", 0, 0);
  1412. co_List_Add_String(citem[24].p_list, 16, 2, "##control_cfastleft", 0, 0);
  1413. co_List_Add_String(citem[24].p_list, 17, 2, "##control_cfastright", 0, 0);
  1414. co_List_Add_String(citem[24].p_list, 18, 2, "##control_ccamera", 0, 0);
  1415. co_List_Add_String(citem[24].p_list, 19, 2, "##control_game", 0, 1);
  1416. co_List_Add_String(citem[24].p_list, 20, 2, "##control_gmenu", 0, 0);
  1417. co_List_Add_String(citem[24].p_list, 21, 2, "##control_grestart", 0, 0);
  1418. co_List_Add_String(citem[24].p_list, 22, 2, "##control_ginventory", 0, 0);
  1419. //co_List_Add_String(citem[24].p_list, 23, 2, "##control_gusepack", 0, 0);
  1420. co_List_Add_String(citem[24].p_list, 23, 2, "##control_gnexttrack", 0, 0);
  1421. co_List_Add_String(citem[24].p_list, 24, 2, "##control_gturnoffi", 0, 0);
  1422. co_List_Add_String(citem[24].p_list, 25, 2, "##control_gturnofft", 0, 0);
  1423. co_List_Add_String(citem[24].p_list, 26, 2, "##control_gscreenshot", 0, 0);
  1424. co_List_Add_String(citem[24].p_list, 27, 2, "##control_gtransparent", 0, 0);
  1425. co_List_Add_String(citem[24].p_list, 28, 2, "##control_ghighlight", 0, 0);
  1426. co_List_Add_String(citem[24].p_list, 29, 2, "##control_gdrawconn", 0, 0);
  1427. co_List_Add_String(citem[24].p_list, 30, 2, "##control_pause", 0, 0);
  1428. Key2String(setup.key[1], ctext);
  1429. co_List_Add_String(citem[24].p_list, 1, 550, ctext, setup.key[1], 0);
  1430. Key2String(setup.key[2], ctext);
  1431. co_List_Add_String(citem[24].p_list, 2, 550, ctext, setup.key[2], 0);
  1432. Key2String(setup.key[3], ctext);
  1433. co_List_Add_String(citem[24].p_list, 3, 550, ctext, setup.key[3], 0);
  1434. Key2String(setup.key[4], ctext);
  1435. co_List_Add_String(citem[24].p_list, 4, 550, ctext, setup.key[4], 0);
  1436. Key2String(setup.key[5], ctext);
  1437. co_List_Add_String(citem[24].p_list, 5, 550, ctext, setup.key[5], 0);
  1438. Key2String(setup.key[6], ctext);
  1439. co_List_Add_String(citem[24].p_list, 6, 550, ctext, setup.key[6], 0);
  1440. Key2String(setup.key[7], ctext);
  1441. co_List_Add_String(citem[24].p_list, 7, 550, ctext, setup.key[7], 0);
  1442. Key2String(setup.key[8], ctext);
  1443. co_List_Add_String(citem[24].p_list, 8, 550, ctext, setup.key[8], 0);
  1444. Key2String(setup.key[9], ctext);
  1445. co_List_Add_String(citem[24].p_list, 9, 550, ctext, setup.key[9], 0);
  1446. Key2String(setup.key[10], ctext);
  1447. co_List_Add_String(citem[24].p_list, 10, 550, ctext, setup.key[10], 0);
  1448. Key2String(setup.key[12], ctext);
  1449. co_List_Add_String(citem[24].p_list, 12, 550, ctext, setup.key[12], 0);
  1450. Key2String(setup.key[13], ctext);
  1451. co_List_Add_String(citem[24].p_list, 13, 550, ctext, setup.key[13], 0);
  1452. Key2String(setup.key[14], ctext);
  1453. co_List_Add_String(citem[24].p_list, 14, 550, ctext, setup.key[14], 0);
  1454. Key2String(setup.key[15], ctext);
  1455. co_List_Add_String(citem[24].p_list, 15, 550, ctext, setup.key[15], 0);
  1456. Key2String(setup.key[16], ctext);
  1457. co_List_Add_String(citem[24].p_list, 16, 550, ctext, setup.key[16], 0);
  1458. Key2String(setup.key[17], ctext);
  1459. co_List_Add_String(citem[24].p_list, 17, 550, ctext, setup.key[17], 0);
  1460. Key2String(setup.key[18], ctext);
  1461. co_List_Add_String(citem[24].p_list, 18, 550, ctext, setup.key[18], 0);
  1462. Key2String(setup.key[20], ctext);
  1463. co_List_Add_String(citem[24].p_list, 20, 550, ctext, setup.key[20], 0);
  1464. Key2String(setup.key[21], ctext);
  1465. co_List_Add_String(citem[24].p_list, 21, 550, ctext, setup.key[21], 0);
  1466. Key2String(setup.key[22], ctext);
  1467. co_List_Add_String(citem[24].p_list, 22, 550, ctext, setup.key[22], 0);
  1468. //Key2String(setup.key[23], ctext);
  1469. //co_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0);
  1470. Key2String(setup.key[23], ctext);
  1471. co_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0);
  1472. Key2String(setup.key[24], ctext);
  1473. co_List_Add_String(citem[24].p_list, 24, 550, ctext, setup.key[24], 0);
  1474. Key2String(setup.key[25], ctext);
  1475. co_List_Add_String(citem[24].p_list, 25, 550, ctext, setup.key[25], 0);
  1476. Key2String(setup.key[26], ctext);
  1477. co_List_Add_String(citem[24].p_list, 26, 550, ctext, setup.key[26], 0);
  1478. Key2String(setup.key[27], ctext);
  1479. co_List_Add_String(citem[24].p_list, 27, 550, ctext, setup.key[27], 0);
  1480. Key2String(setup.key[28], ctext);
  1481. co_List_Add_String(citem[24].p_list, 28, 550, ctext, setup.key[28], 0);
  1482. Key2String(setup.key[29], ctext);
  1483. co_List_Add_String(citem[24].p_list, 29, 550, ctext, setup.key[29], 0);
  1484. Key2String(setup.key[30], ctext);
  1485. co_List_Add_String(citem[24].p_list, 30, 550, ctext, setup.key[30], 0);
  1486. co_List_Redraw(hdcTab[3], citem[24].p_list, 0);
  1487. ddxSetCursor(0);
  1488. DisplayFrame();
  1489. DisplayFrame();
  1490. ddxResizeCursorBack(0);
  1491. ddxSetCursorSurface(0);
  1492. ddxSetCursor(1);
  1493. DisplayFrame();
  1494. DisplayFrame();
  1495. ddxReleaseBitmap(iClock);
  1496. }
  1497. void RunMenuSetGeneralSettings(CONTROL_LIST_ITEM * citem, int iset)
  1498. {
  1499. int i;
  1500. ddxSetFlip(0);
  1501. for (i = 0; i < 2; i++) {
  1502. switch (iset) {
  1503. case 0:
  1504. //modely
  1505. co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 0);
  1506. //castice
  1507. co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 0);
  1508. //svetla
  1509. setup.light_dyn = 1;
  1510. co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 0);
  1511. //textury predmetu
  1512. co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 0);
  1513. //textury okoli
  1514. co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 0);
  1515. //zrcadlo
  1516. co_Check_Set_State(citem[11].p_check, HDC2DD, 1, 1);
  1517. //caustic
  1518. co_Check_Set_State(citem[30].p_check, HDC2DD, 1, 1);
  1519. break;
  1520. case 1:
  1521. //modely
  1522. co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 1);
  1523. //castice
  1524. co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 1);
  1525. //svetla
  1526. setup.light_dyn = 1;
  1527. co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 1);
  1528. //textury predmetu
  1529. co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 1);
  1530. //textury okoli
  1531. co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 1);
  1532. //zrcadlo
  1533. co_Check_Set_State(citem[11].p_check, HDC2DD, 0, 1);
  1534. //caustic
  1535. co_Check_Set_State(citem[30].p_check, HDC2DD, 0, 1);
  1536. break;
  1537. case 2:
  1538. //modely
  1539. co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 1);
  1540. //castice
  1541. co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 2);
  1542. //svetla
  1543. setup.light_dyn = 1;
  1544. co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 2);
  1545. //textury predmetu
  1546. co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 1);
  1547. //textury okoli
  1548. co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 2);
  1549. //zrcadlo
  1550. co_Check_Set_State(citem[11].p_check, HDC2DD, 0, 1);
  1551. //caustic
  1552. co_Check_Set_State(citem[30].p_check, HDC2DD, 0, 1);
  1553. break;
  1554. case 3:
  1555. //modely
  1556. co_Combo_Set_Sel(HDC2DD, citem[33].p_combo, 1);
  1557. //castice
  1558. co_Combo_Set_Sel(HDC2DD, citem[10].p_combo, 2);
  1559. //svetla
  1560. setup.light_dyn = 0;
  1561. co_Combo_Set_Sel(HDC2DD, citem[32].p_combo, 3);
  1562. //textury predmetu
  1563. co_Combo_Set_Sel(HDC2DD, citem[34].p_combo, 2);
  1564. //textury okoli
  1565. co_Combo_Set_Sel(HDC2DD, citem[35].p_combo, 2);
  1566. //zrcadlo
  1567. co_Check_Set_State(citem[11].p_check, HDC2DD, 0, 1);
  1568. //caustic
  1569. co_Check_Set_State(citem[30].p_check, HDC2DD, 0, 1);
  1570. break;
  1571. }
  1572. if (!i)
  1573. DisplayFrame();
  1574. }
  1575. ddxSetFlip(1);
  1576. }
  1577. void RunMenuSettings(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
  1578. {
  1579. DWORD dwEplased = 0, dwStart, dwStop;
  1580. ROZLISENI *roz;
  1581. int roz_size = 0;
  1582. int ActiveTab = 0;
  1583. int hdcTab[TAB_NUM];
  1584. int hdcTabUse[TAB_NUM];
  1585. CONTROL_LIST_ITEM citem[CLIST_ITEMC];
  1586. int iClock[12];
  1587. // FILE *file;
  1588. char dir[256];
  1589. int lastcmd, lastanm, i;
  1590. //CMD_LINE res[RES_NUM];
  1591. CMD_LINE *res = NULL;
  1592. int lastabv = -1;
  1593. char in, click = 0;
  1594. int anmid = -1, resid = -1, anbind = -1;
  1595. int bind;
  1596. int igeneral_3d;
  1597. int iComboActSel = -1;
  1598. for (i = 0; i < 12; i++)
  1599. iClock[i] = -1;
  1600. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  1601. if (!res) {
  1602. kprintf(1, "RunMenuSettings: Out of Memory");
  1603. return;
  1604. }
  1605. else
  1606. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  1607. EnumRozliseni(&roz, &roz_size);
  1608. Load_ini();
  1609. igeneral_3d = setup.general_3d;
  1610. //BitBltU(FontDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
  1611. //BitBltU(BackDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
  1612. ddxCleareSurface(FontDC);
  1613. ddxCleareSurface(BackDC);
  1614. ddxCleareSurface(CompositDC);
  1615. LoadClock(iClock);
  1616. if (iClock[0] != -1) {
  1617. ddxResizeCursorBack(iClock[0]);
  1618. DrawClock(iClock, 0);
  1619. }
  1620. MENU_SETTING_BRUTAL_RESTART:
  1621. ActiveTab = 0;
  1622. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
  1623. fn_Set_Font(cFontFile[2]);
  1624. fn_Load_Bitmaps();
  1625. for (bind = 0; bind < RES_NUM; bind++) {
  1626. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  1627. res[bind].iAnim[lastcmd][11] = -1;
  1628. res[bind].iAnim[lastcmd][0] = -1;
  1629. }
  1630. for (in = 0; in < 6; in++)
  1631. res[bind].iParam[in] = -1;
  1632. res[bind].iLayer = 0;
  1633. }
  1634. lastcmd = 0;
  1635. timercnt = 0;
  1636. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  1637. working_file_translate(dir, 256);
  1638. chdir((dir));
  1639. //natadhe skript menu
  1640. LoadMenuScript(p_File_Name, res, &lastcmd);
  1641. in = 0;
  1642. //CreateFontAnimations(res, &lastcmd);
  1643. DrawClock(iClock, 1);
  1644. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  1645. // animace na OnAbove
  1646. for (i = 0; i < lastcmd; i++) {
  1647. lastanm = 0;
  1648. switch (res[i].iParam[0]) {
  1649. case COM_DRAW:
  1650. if (!res[i].iLayer) {
  1651. ddxDrawSurface(BackDC, res[i].iParam, 2);
  1652. //menucommand_Draw(BackDC, res[i].iParam, 2);
  1653. }
  1654. else {
  1655. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  1656. //ddxDrawSurface(BackDC, res[i].iParam, 2);
  1657. ddxDrawSurface(FontDC, res[i].iParam, 3);
  1658. //menucommand_DrawT(BackDC, res[i].iParam);
  1659. //menucommand_Draw(FontDC, res[i].iParam, 3);
  1660. }
  1661. break;
  1662. case COM_RANDOMANIMATION:
  1663. case COM_ONCLICK:
  1664. case COM_ONABOVE:
  1665. case COM_RUNANIMATION:
  1666. case COM_BINDEXITANIMATION:
  1667. case COM_BINDANIMATION:
  1668. //nahrati animace k udalosti OnAbove
  1669. LoadAnimationMenuScript(res, i, &lastanm);
  1670. break;
  1671. }
  1672. }
  1673. DrawClock(iClock, 2);
  1674. //DisplayFrame();
  1675. for (i = 0; i < TAB_NUM; i++) {
  1676. //hdcTab[i] = fn_CreateDC(_2dd.hDC, TAB_XRES, TAB_YRES, _2d_Find_Free_Surface());
  1677. hdcTab[i] = ddxCreateSurface(TAB_XRES, TAB_YRES, ddxFindFreeSurface());
  1678. if (hdcTab[i]) {
  1679. ddxBitBlt(hdcTab[i], 0, 0, TAB_XRES, TAB_YRES, BackDC, TAB_X, TAB_Y);
  1680. //BitBlt(hdcTab[i], 0, 0, TAB_XRES, TAB_YRES, BackDC, TAB_X, TAB_Y, SRCCOPY);
  1681. }
  1682. hdcTabUse[i] = 0;
  1683. }
  1684. DrawClock(iClock, 3);
  1685. if (co_Load_Graphic(0)) {
  1686. int count = 0;
  1687. DrawClock(iClock, 4);
  1688. citem[0].bActive = 0;
  1689. citem[1].bActive = 0;
  1690. //citem[2].p_check = co_Create_CheckBox(hdcTab[0], 25, 50, "##settings_camera_rot", 0, 0);
  1691. //co_Check_Set_State(citem[2].p_check, hdcTab[0], setup.pohled_berusky, 1);
  1692. citem[2].bActive = 1;
  1693. citem[3].p_check =
  1694. co_Create_CheckBox(hdcTab[0], 25, 50, "##settings_camera_mov", 0, 1);
  1695. co_Check_Set_State(citem[3].p_check, hdcTab[0], setup.posouvat_kameru, 1);
  1696. citem[3].bActive = 1;
  1697. citem[4].p_check =
  1698. co_Create_CheckBox(hdcTab[0], 25, 80, "##settings_b1_control", 0, 2);
  1699. co_Check_Set_State(citem[4].p_check, hdcTab[0], setup.ovladani, 1);
  1700. citem[4].bActive = 1;
  1701. citem[45].p_check =
  1702. co_Create_CheckBox(hdcTab[0], 25, 110, "##settings_beathe_vis_at_start",
  1703. 0, 10);
  1704. co_Check_Set_State(citem[45].p_check, hdcTab[0],
  1705. setup.start_zpruhlednovani, 1);
  1706. citem[45].bActive = 1;
  1707. citem[46].p_check =
  1708. co_Create_CheckBox(hdcTab[0], 25, 140, "##settings_items_vis_at_start",
  1709. 0, 11);
  1710. co_Check_Set_State(citem[46].p_check, hdcTab[0], setup.start_zvyraznovani,
  1711. 1);
  1712. citem[46].bActive = 1;
  1713. citem[51].p_check =
  1714. co_Create_CheckBox(hdcTab[0], 25, 200, "##settings_camera_intro", 0,
  1715. 16);
  1716. co_Check_Set_State(citem[51].p_check, hdcTab[0], setup.camera_intro, 1);
  1717. citem[51].bActive = 1;
  1718. citem[47].p_check =
  1719. co_Create_CheckBox(hdcTab[0], 25, 230, "##settings_camera_rect", 0, 12);
  1720. co_Check_Set_State(citem[47].p_check, hdcTab[0], setup.ovladani_rohy, 1);
  1721. citem[47].bActive = 1;
  1722. citem[48].p_check =
  1723. co_Create_CheckBox(hdcTab[0], 25, 260, "##settings_implicit_move", 0,
  1724. 13);
  1725. if (setup.ovladani_rohy_default)
  1726. co_Check_Set_State(citem[48].p_check, hdcTab[0], 0, 1);
  1727. else
  1728. co_Check_Set_State(citem[48].p_check, hdcTab[0], 1, 1);
  1729. DrawClock(iClock, 5);
  1730. citem[48].bActive = 1;
  1731. citem[49].p_check =
  1732. co_Create_CheckBox(hdcTab[0], 25, 290, "##settings_imlicit_rot", 0, 14);
  1733. if (setup.ovladani_rohy_default)
  1734. co_Check_Set_State(citem[49].p_check, hdcTab[0], 1, 1);
  1735. else
  1736. co_Check_Set_State(citem[49].p_check, hdcTab[0], 0, 1);
  1737. citem[49].bActive = 1;
  1738. citem[50].p_check =
  1739. co_Create_CheckBox(hdcTab[0], 25, 320, "##settings_camera_swap", 0, 15);
  1740. co_Check_Set_State(citem[50].p_check, hdcTab[0], setup.ovladani_rohy_smer,
  1741. 1);
  1742. citem[50].bActive = 1;
  1743. //citem[51].p_check = co_Create_CheckBox(hdcTab[0], 25, 350, "##setings_camera_move_cur", 0, 16);
  1744. //co_Check_Set_State(citem[51].p_check, hdcTab[0], setup.ovladani_pr_posun, 1);
  1745. //citem[51].bActive = 1;
  1746. //co_Set_Text_Right(hdcTab[0], "##settings_transparency", 0, 450, 300);
  1747. //citem[6].p_prog = co_Create_Progres(hdcTab[0], 500, 300, 2, 18, 0);
  1748. //co_Progres_Set(citem[6].p_prog, hdcTab[0], ftoi(setup.p_kamera_alfa * 20));
  1749. //citem[6].bActive = 1;
  1750. co_Set_Text_Right(hdcTab[0], "##setings_camera_speed", 0, 450, 390);
  1751. citem[52].p_prog = co_Create_Progres(hdcTab[0], 500, 387, 0, 10, 0);
  1752. co_Progres_Set(citem[52].p_prog, hdcTab[0],
  1753. ftoi(setup.ovladani_rohy_rychlost * 10));
  1754. citem[52].bActive = 1;
  1755. co_Set_Text_Right(hdcTab[0], "##settings_trans_radius", 0, 450, 425);
  1756. citem[7].p_prog = co_Create_Progres(hdcTab[0], 500, 412, 1, 20, 1);
  1757. co_Progres_Set(citem[7].p_prog, hdcTab[0],
  1758. ftoi(setup.p_kamera_radius * 2));
  1759. citem[7].bActive = 1;
  1760. //if(!setup.posouvat_kameru)
  1761. //co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0);
  1762. if (!setup.ovladani_rohy) {
  1763. co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 13);
  1764. co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 14);
  1765. co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 15);
  1766. //co_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 16);
  1767. co_Progres_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0, 1,
  1768. hdcTab[0]);
  1769. }
  1770. DrawClock(iClock, 6);
  1771. ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
  1772. SetTab(0, -1, citem, CLIST_ITEMC, hdcTab);
  1773. //if(!setup.posouvat_kameru)
  1774. // co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
  1775. if (!setup.ovladani_rohy) {
  1776. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
  1777. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
  1778. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
  1779. //co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
  1780. co_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 0,
  1781. HDC2DD);
  1782. }
  1783. DrawClock(iClock, 7);
  1784. ddxCleareSurface(BackDC);
  1785. hdcTabUse[0] = 1;
  1786. ddxSetCursor(0);
  1787. DisplayFrame();
  1788. DisplayFrame();
  1789. ddxResizeCursorBack(0);
  1790. ddxSetCursorSurface(0);
  1791. ddxSetCursor(1);
  1792. DisplayFrame();
  1793. DisplayFrame();
  1794. for (i = 0; i < 12; i++)
  1795. if (iClock[i] != -1) {
  1796. ddxReleaseBitmap(iClock[i]);
  1797. iClock[i] = -1;
  1798. }
  1799. }
  1800. //BEGIN_MENU:
  1801. for (i = 0; i < lastcmd; i++)
  1802. if (res[i].iParam[0] == COM_RUNANIMATION) {
  1803. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  1804. if (iWave != -1) {
  1805. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1806. anm[iWave].iWave = res[i + 1].iParam[5] =
  1807. mPlaySound(&res[i + 1], p_ad, 2);
  1808. }
  1809. }
  1810. dim.t1 = 0;
  1811. dim.t2 = 0;
  1812. dim.dx = 0;
  1813. dim.dy = 0;
  1814. anmid = -1;
  1815. resid = -1;
  1816. anbind = -1;
  1817. bind = -1;
  1818. lastabv = -1;
  1819. in = 0;
  1820. spracuj_spravy(0);
  1821. while (!key[K_ESC]) {
  1822. dwStart = timeGetTime();
  1823. //pohnul mysi
  1824. if (dim.dx || dim.dy) {
  1825. //dostala se mys do akcni oblasti (OnAbove)?
  1826. if (!click)
  1827. for (i = 0; i < lastcmd; i++)
  1828. if (res[i].iParam[0] == COM_ONABOVE) {
  1829. if ((dim.x >= res[i].iParam[1]) &&
  1830. (dim.x <= res[i].iParam[3]) &&
  1831. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  1832. //spusteni animace v OnAbove
  1833. if (i != lastabv) {
  1834. if (in) {
  1835. Stop(&res[lastabv]);
  1836. if (!res[lastabv].iLayer) {
  1837. //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
  1838. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  1839. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  1840. }
  1841. else {
  1842. //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
  1843. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 3,
  1844. TRANSCOLOR);
  1845. //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
  1846. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  1847. }
  1848. }
  1849. CheckAnimation(&res[i], p_ad);
  1850. lastabv = i;
  1851. AddAnimation(&res[i], p_ad, 0, 1);
  1852. in = 1;
  1853. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  1854. if (bind != -1) {
  1855. CheckAnimation(&res[bind], p_ad);
  1856. AddAnimation(&res[bind], p_ad, 1, 1);
  1857. anbind = bind;
  1858. mPlaySound(&res[bind], p_ad, 0);
  1859. }
  1860. strcpy(dir, res[i].cParam[1]);
  1861. }
  1862. }
  1863. else if (lastabv == i) {
  1864. // odesel z oblasti, ktera byla aktivni -> stop animace
  1865. // a odznaceni oblasti
  1866. Stop(&res[i]);
  1867. if (!res[i].iLayer) {
  1868. //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
  1869. ddxDrawDisplay(res[i].iAnim[0], 0);
  1870. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  1871. }
  1872. else {
  1873. //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
  1874. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  1875. //menucommand_Draw(FontDC, res[i].iAnim[0], 3);
  1876. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  1877. }
  1878. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  1879. if (bind != -1) {
  1880. int iAnim;
  1881. if (anbind != -1) {
  1882. Stop(&res[anbind]);
  1883. if (!res[i].iLayer) {
  1884. //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
  1885. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  1886. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  1887. }
  1888. else {
  1889. //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
  1890. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  1891. TRANSCOLOR);
  1892. //menucommand_Draw(FontDC, res[anbind].iAnim[0], 3);
  1893. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  1894. }
  1895. }
  1896. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  1897. if (iAnim != -1)
  1898. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  1899. }
  1900. lastabv = -1;
  1901. anbind = -1;
  1902. in = 0;
  1903. strcpy(dir, "");
  1904. }
  1905. }
  1906. dim.dx = 0;
  1907. dim.dy = 0;
  1908. }
  1909. co_Handle_Controls(citem, CLIST_ITEMC, dim.x - TAB_X, dim.y - TAB_Y,
  1910. HDC2DD, TAB_X, TAB_Y);
  1911. /*
  1912. if(co_Progres_Changed(citem, CLIST_ITEMC, 4))
  1913. p_ad->Sound_Gain = co_Progres_Get(citem, CLIST_ITEMC, 4) / 100.0f;
  1914. */
  1915. if (co_Progres_Changed(citem, CLIST_ITEMC, 6)) {
  1916. float f = co_Progres_Get(citem, CLIST_ITEMC, 6) / 100.0f;
  1917. //ogg_gain(f);
  1918. //p_ad->Music_Gain = f;
  1919. if (f >= 0.05f && !ogg_playing()) {
  1920. // p_ad->Music_Gain = f;
  1921. //ap_Play_Song(0,0,p_ad);
  1922. }
  1923. }
  1924. if (ActiveTab == 1) {
  1925. iComboActSel = co_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 1);
  1926. if (iComboActSel != -1 && iComboActSel != igeneral_3d) {
  1927. igeneral_3d = iComboActSel;
  1928. RunMenuSetGeneralSettings(citem, igeneral_3d);
  1929. }
  1930. }
  1931. //stlacil leve tlacitko
  1932. if (dim.t1 && !click) {
  1933. int iCheck = -1;
  1934. LIST_VIEW_CONTROL *p_li;
  1935. if (co_List_Get_Clck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
  1936. float pos[3] = { 0, 0, 0 };
  1937. //if(karmin_aktivni)
  1938. //ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, p_ad);
  1939. SetCharMenu(p_li);
  1940. }
  1941. /*iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 1);
  1942. if(iCheck != -1)
  1943. {
  1944. if(!iCheck)
  1945. {
  1946. co_Check_Set_State(citem[2].p_check, HDC2DD, 0, 1);
  1947. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
  1948. }
  1949. else
  1950. co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
  1951. } */
  1952. iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 12);
  1953. if (iCheck != -1) {
  1954. if (!iCheck) {
  1955. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
  1956. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
  1957. co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
  1958. //co_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
  1959. co_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 1,
  1960. HDC2DD);
  1961. }
  1962. else {
  1963. co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
  1964. co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
  1965. co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
  1966. //co_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
  1967. co_Progres_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
  1968. }
  1969. }
  1970. if (ActiveTab == 0 && !citem[49].bDisabled) {
  1971. iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 13);
  1972. if (iCheck != -1 && iCheck == 1)
  1973. co_Check_Set_State(citem[49].p_check, HDC2DD, 0, 1);
  1974. else if (iCheck != -1 && !iCheck)
  1975. co_Check_Set_State(citem[49].p_check, HDC2DD, 1, 1);
  1976. iCheck = co_Check_Get_State_Change(citem, CLIST_ITEMC, 14);
  1977. if (iCheck != -1 && iCheck == 1)
  1978. co_Check_Set_State(citem[48].p_check, HDC2DD, 0, 1);
  1979. else if (iCheck != -1 && !iCheck)
  1980. co_Check_Set_State(citem[48].p_check, HDC2DD, 1, 1);
  1981. }
  1982. //dostala se mys do akcni oblasti (OnClick)?
  1983. for (i = 0; i < lastcmd; i++)
  1984. if (res[i].iParam[0] == COM_ONCLICK)
  1985. if ((dim.x >= res[i].iParam[1]) &&
  1986. (dim.x <= res[i].iParam[3]) &&
  1987. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  1988. if (res[i].iAnim[0][0] >= 0) {
  1989. //pokud je animace, tak ji spust
  1990. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  1991. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1992. mPlaySound(&res[i + 1], p_ad, 1);
  1993. resid = i;
  1994. click = 1;
  1995. }
  1996. else {
  1997. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1998. mPlaySound(&res[i + 1], p_ad, 1);
  1999. resid = i;
  2000. click = 1;
  2001. anmid = 31;
  2002. }
  2003. }
  2004. dim.t1 = 0;
  2005. }
  2006. //provedeni akce po animaci menu
  2007. if (click)
  2008. if (!anm[anmid].cmd) {
  2009. click = 0;
  2010. //StopAll();
  2011. if (!strcmp(res[resid].cParam[1], "OK")) {
  2012. float pos[3] = { 0, 0, 0 };
  2013. //if(karmin_aktivni)
  2014. //ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, p_ad);
  2015. SetMenuSettings(roz, citem, hdcTabUse);
  2016. Save_ini();
  2017. key[K_ESC] = 1;
  2018. }
  2019. if (!strcmp(res[resid].cParam[1], "EXIT")) {
  2020. float pos[3] = { 0, 0, 0 };
  2021. //if(karmin_aktivni)
  2022. //ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, p_ad);
  2023. key[K_ESC] = 1;
  2024. }
  2025. if (!strcmp(res[resid].cParam[1], "GAME") && ActiveTab) {
  2026. SetTab(0, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  2027. ActiveTab = 0;
  2028. hdcTabUse[0]++;
  2029. }
  2030. if (!strcmp(res[resid].cParam[1], "3D") && ActiveTab != 1) {
  2031. if (!hdcTabUse[1])
  2032. InitTab3d(citem, hdcTab, roz, roz_size);
  2033. SetTab(1, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  2034. ActiveTab = 1;
  2035. hdcTabUse[1]++;
  2036. }
  2037. if (!strcmp(res[resid].cParam[1], "SOUND") && ActiveTab != 2) {
  2038. if (!hdcTabUse[2])
  2039. InitTabSound(citem, hdcTab);
  2040. SetTab(2, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  2041. ActiveTab = 2;
  2042. hdcTabUse[2]++;
  2043. }
  2044. if (!strcmp(res[resid].cParam[1], "CONTROLS") && ActiveTab != 3) {
  2045. if (!hdcTabUse[3])
  2046. InitTabControls(citem, hdcTab);
  2047. SetTab(3, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  2048. ActiveTab = 3;
  2049. hdcTabUse[3]++;
  2050. }
  2051. /* if(!strcmp(res[resid].cParam[1], "NEW_GAME"))
  2052. NewGame(hWnd, p_ad, cpu);*/
  2053. /*
  2054. for(i=0;i<lastcmd;i++)
  2055. {
  2056. switch(res[i].iParam[0])
  2057. {
  2058. case COM_DRAW:
  2059. if(!res[i].iLayer)
  2060. menucommand_Draw(_2dd.hDC, res[i].iParam);
  2061. else
  2062. {
  2063. menucommand_DrawT(_2dd.hDC, res[i].iParam);
  2064. menucommand_Draw(FontDC, res[i].iParam);
  2065. }
  2066. break;
  2067. }
  2068. }
  2069. */
  2070. resid = -1;
  2071. if (key[K_ESC]) {
  2072. /*
  2073. for(i=0;i<lastcmd;i++)
  2074. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  2075. {
  2076. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  2077. res[i].iParam[5] = -1;
  2078. }
  2079. */
  2080. goto __QUIT;
  2081. }
  2082. /*else
  2083. goto BEGIN_MENU; */
  2084. }
  2085. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  2086. if (timercnt > 500) {
  2087. timercnt = 0;
  2088. for (i = 0; i < lastcmd; i++)
  2089. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  2090. if (rand() % 200 <= res[i].iParam[1] &&
  2091. strcmp(dir, res[i].cParam[0])) {
  2092. CheckAnimation(&res[i], p_ad);
  2093. AddAnimation(&res[i], p_ad, 0, 0);
  2094. }
  2095. }
  2096. /* spracuj_spravy(0);
  2097. ddxUpdateMouse();
  2098. if(dim.dx || dim.dy)
  2099. DisplayFrame();*/
  2100. dwStop = timeGetTime();
  2101. dwEplased += dwStop - dwStart;
  2102. spracuj_spravy(0);
  2103. ddxUpdateMouse();
  2104. AnimationEvent(dwStop, p_ad);
  2105. if (dim.tf1) {
  2106. dim.t1 = 1;
  2107. dim.tf1 = 0;
  2108. }
  2109. if (dim.tf2) {
  2110. dim.t2 = 1;
  2111. dim.tf2 = 0;
  2112. }
  2113. if (ddxRestore(p_ad))
  2114. goto MENU_SETTING_BRUTAL_RESTART;
  2115. }
  2116. __QUIT:
  2117. //BitBltU(FontDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
  2118. //BitBltU(BackDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
  2119. ddxCleareSurface(FontDC);
  2120. ddxCleareSurface(BackDC);
  2121. ddxCleareSurface(CompositDC);
  2122. SetMenuSettingsS(roz, citem, hdcTabUse);
  2123. Save_ini();
  2124. fn_Release_Font(1);
  2125. StopAll();
  2126. co_Handle_Release(citem, CLIST_ITEMC);
  2127. co_Release_Graphic();
  2128. key[K_ESC] = 0;
  2129. FreeAnimations(res, RES_NUM);
  2130. free((void *) res);
  2131. free((void *) roz);
  2132. }
  2133. void RunStretchAnimation(char *cScene, int x, int y, AUDIO_DATA * p_ad)
  2134. {
  2135. int idx;
  2136. RECT r;
  2137. RECT s = { 0, 0, 1024, 768 };
  2138. APAK_HANDLE *hArchive = NULL;
  2139. char cFile[MAX_PATH];
  2140. char cDir[MAX_PATH];
  2141. if (iLanguageVersion == 4) {
  2142. GetPrivateProfileString("game", "bitmap_dir", "c:\\", cDir, MAX_PATH,
  2143. ini_file);
  2144. working_file_translate(cDir, MAX_PATH);
  2145. sprintf(cFile, "%s\\scene%d.pak", cDir, iActualScene);
  2146. apak_dir_correction(cDir);
  2147. hArchive = apakopen(cFile, cDir, &idx);
  2148. if (!hArchive) {
  2149. kprintf(1, "Nepodarilo se otevrit archiv [%s]\n", cFile);
  2150. return;
  2151. }
  2152. else
  2153. hArchive->pActualNode = hArchive->pRootNode->pNextNode;
  2154. idx = ddxLoadBitmap(cScene, hArchive);
  2155. }
  2156. else
  2157. idx = ddxLoadBitmap(cScene, pBmpArchive);
  2158. if (idx < 0) {
  2159. if (iLanguageVersion == 4)
  2160. apakclose(hArchive);
  2161. return;
  2162. }
  2163. r.left = x;
  2164. r.top = y;
  2165. r.right = r.left + ddxGetWidth(180);
  2166. r.bottom = r.top + ddxGetHight(180);
  2167. StretchAnimation(&r, &s, idx, 1, p_ad);
  2168. ddxReleaseBitmap(idx);
  2169. if (iLanguageVersion == 4)
  2170. apakclose(hArchive);
  2171. }
  2172. void RunMenuNewGameSceneActivate(CMD_LINE * res)
  2173. {
  2174. #ifndef __DEMO
  2175. int i;
  2176. for (i = 1; i < 10; i++)
  2177. if (pPlayerProfile.cScene[i]) {
  2178. res[i + 8].bActive = 1;
  2179. res[i + 17].bActive = 1;
  2180. ddxDrawSurface(BackDC, res[i + 8].iAnim[0], 2);
  2181. if (i > 1)
  2182. ddxDrawSurface(BackDC, res[i - 1].iAnim[6], 2);
  2183. }
  2184. #endif
  2185. #ifdef __DEMO
  2186. res[6 + 8].bActive = 1;
  2187. res[6 + 17].bActive = 1;
  2188. ddxDrawSurface(BackDC, res[6 + 8].iAnim[0], 2);
  2189. #endif
  2190. }
  2191. void GetRunMenuNewGameSceneLoadGame(char *cscene, char *cscenemap,
  2192. char *csceneanim, char *cscenelevel, int *iLevelStart, int *iNumOfLevels,
  2193. int *xTV, int *yTV, char *bTutorial, int *xBack, int *yBack)
  2194. {
  2195. *bTutorial = 0;
  2196. switch (iActualScene) {
  2197. case 0:
  2198. *iLevelStart = 200;
  2199. *iNumOfLevels = 20;
  2200. *xTV = 0;
  2201. *yTV = 0;
  2202. *bTutorial = 1;
  2203. *xBack = 975;
  2204. *yBack = 7;
  2205. break;
  2206. case 1:
  2207. *iLevelStart = 0;
  2208. *iNumOfLevels = 11;
  2209. *xTV = 919;
  2210. *yTV = 677;
  2211. *xBack = 713;
  2212. *yBack = 679;
  2213. break;
  2214. case 2:
  2215. *iLevelStart = 11;
  2216. *iNumOfLevels = 10;
  2217. *xTV = 916;
  2218. *yTV = 8;
  2219. *xBack = 971;
  2220. *yBack = 703;
  2221. break;
  2222. case 3:
  2223. *iLevelStart = 21;
  2224. *iNumOfLevels = 12;
  2225. *xTV = 918;
  2226. *yTV = 7;
  2227. *xBack = 973;
  2228. *yBack = 413;
  2229. break;
  2230. case 4:
  2231. *iLevelStart = 33;
  2232. *iNumOfLevels = 10;
  2233. *xTV = 197;
  2234. *yTV = 9;
  2235. *xBack = 8;
  2236. *yBack = 16;
  2237. break;
  2238. case 5:
  2239. *iLevelStart = 43;
  2240. *iNumOfLevels = 10;
  2241. *xTV = 918;
  2242. *yTV = 9;
  2243. *xBack = 976;
  2244. *yBack = 309;
  2245. break;
  2246. case 6:
  2247. *iLevelStart = 53;
  2248. #ifndef __DEMO
  2249. *iNumOfLevels = 10;
  2250. #endif
  2251. #ifdef __DEMO
  2252. *iNumOfLevels = 6;
  2253. #endif
  2254. *xTV = 920;
  2255. *yTV = 8;
  2256. *xBack = 967;
  2257. *yBack = 211;
  2258. break;
  2259. case 7:
  2260. *iLevelStart = 63;
  2261. *iNumOfLevels = 10;
  2262. *xTV = 11;
  2263. *yTV = 6;
  2264. *xBack = 8;
  2265. *yBack = 279;
  2266. break;
  2267. case 8:
  2268. *iLevelStart = 73;
  2269. *iNumOfLevels = 12;
  2270. *xTV = 15;
  2271. *yTV = 677;
  2272. *xBack = 12;
  2273. *yBack = 490;
  2274. break;
  2275. case 9:
  2276. *iLevelStart = 85;
  2277. *iNumOfLevels = 10;
  2278. *xTV = 918;
  2279. *yTV = 7;
  2280. *xBack = 971;
  2281. *yBack = 338;
  2282. break;
  2283. case 10:
  2284. *iLevelStart = 300;
  2285. *iNumOfLevels = 15;
  2286. *xTV = 920;
  2287. *yTV = 5;
  2288. *xBack = 706;
  2289. *yBack = 6;
  2290. break;
  2291. case 11:
  2292. *iLevelStart = 315;
  2293. *iNumOfLevels = 15;
  2294. *xTV = 920;
  2295. *yTV = 5;
  2296. *xBack = 750;
  2297. *yBack = 5;
  2298. break;
  2299. case 12:
  2300. *iLevelStart = 330;
  2301. *iNumOfLevels = 15;
  2302. *xTV = 920;
  2303. *yTV = 7;
  2304. *xBack = 973;
  2305. *yBack = 229;
  2306. break;
  2307. }
  2308. sprintf(cscenemap, "scene%d_map.bmp", iActualScene);
  2309. sprintf(csceneanim, "scene%d_anim", iActualScene);
  2310. sprintf(cscenelevel, "scene%d_levels.txt", iActualScene);
  2311. sprintf(cscene, "Mmnew_game_scene%d_map.txt", iActualScene);
  2312. }
  2313. void RunMenuNewGameSceneLoadGame(HWND hWnd, AUDIO_DATA * p_ad, int cpu,
  2314. char bLoadGame, char *cSaveFile)
  2315. {
  2316. char cscene[64] = "";
  2317. char cscenemap[64] = "";
  2318. char csceneanim[64] = "";
  2319. char cscenelevel[64] = "";
  2320. int iLevelStart = 0;
  2321. int iNumOfLevels = 0;
  2322. int xTV = 0;
  2323. int yTV = 0;
  2324. int xBack = 0;
  2325. int yBack = 0;
  2326. char bTutorial = 0;
  2327. GetRunMenuNewGameSceneLoadGame(cscene, cscenemap, csceneanim, cscenelevel,
  2328. &iLevelStart, &iNumOfLevels, &xTV, &yTV, &bTutorial, &xBack, &yBack);
  2329. RunMenuSceneMap(cscene, NULL, p_ad, cpu, cscenemap,
  2330. csceneanim, iActualScene, iLevelStart,
  2331. iNumOfLevels, cscenelevel, xTV, yTV, 1, cSaveFile, bTutorial, 0, 0);
  2332. }
  2333. void RunMenuNewGameScene(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
  2334. int cpu, char bLoadGame, char *cSaveFile, char bNewGame)
  2335. {
  2336. DWORD dwEplased = 0, dwStart, dwStop;
  2337. // FILE *file;
  2338. char dir[256];
  2339. int lastcmd, lastanm, i;
  2340. //CMD_LINE res[RES_NUM];
  2341. CMD_LINE *res = NULL;
  2342. int lastabv = -1;
  2343. char in, click = 0;
  2344. int anmid = -1, resid = -1, anbind = -1;
  2345. int bind;
  2346. bBackDC = 0;
  2347. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  2348. if (!res) {
  2349. kprintf(1, "RunMenuNewGameScene: Out of Memory");
  2350. return;
  2351. }
  2352. else
  2353. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  2354. #ifndef __DEMO
  2355. if (!pPlayerProfile.cMovie[0] && bNewGame) {
  2356. pPlayerProfile.cMovie[0] = 1;
  2357. pr_SaveProfile(&pPlayerProfile);
  2358. RunMenuComix("menu_comix.txt", NULL, p_ad, 0);
  2359. }
  2360. #endif
  2361. ////////////////////////////LOAD GAME
  2362. if (bLoadGame) {
  2363. if (lsi_Get_Save_Info(cSaveFile, &iActualLevel, &iActualScene)) {
  2364. RunMenuNewGameSceneLoadGame(NULL, p_ad, cpu, bLoadGame, cSaveFile);
  2365. bLoadGame = 0;
  2366. if (!iActualScene) {
  2367. free((void *) res);
  2368. return;
  2369. }
  2370. } ////////////////////////////LOAD GAME
  2371. }
  2372. else if (!iActualScene) {
  2373. RunMenuSceneMap("Mmnew_game_scene0_map.txt", NULL, p_ad, cpu,
  2374. "scene0_map.bmp", "scene0_anim", 0, 200, 20, "scene0_levels.txt", 0, 0,
  2375. 0, NULL, 1, 975, 7);
  2376. bLoadGame = 0;
  2377. if (!iActualScene) {
  2378. free((void *) res);
  2379. return;
  2380. }
  2381. }
  2382. else if (iActualScene == 10) {
  2383. RunMenuSceneMap("Mmnew_game_scene10_map.txt", NULL, p_ad, cpu,
  2384. "scene10_map.bmp", "scene10_anim", 10, 300, 15, "scene10_levels.txt",
  2385. 920, 2, 0, NULL, 0, 706, 6);
  2386. bLoadGame = 0;
  2387. if (iActualScene == 10) {
  2388. free((void *) res);
  2389. return;
  2390. }
  2391. }
  2392. else if (iActualScene == 11) {
  2393. RunMenuSceneMap("Mmnew_game_scene11_map.txt", NULL, p_ad, cpu,
  2394. "scene11_map.bmp", "scene11_anim", 11, 315, 15, "scene11_levels.txt",
  2395. 920, 2, 0, NULL, 0, 750, 5);
  2396. bLoadGame = 0;
  2397. if (iActualScene == 11) {
  2398. free((void *) res);
  2399. return;
  2400. }
  2401. }
  2402. else if (iActualScene == 12) {
  2403. RunMenuSceneMap("Mmnew_game_scene12_map.txt", NULL, p_ad, cpu,
  2404. "scene12_map.bmp", "scene12_anim", 12, 330, 15, "scene12_levels.txt",
  2405. 920, 7, 0, NULL, 0, 973, 229);
  2406. bLoadGame = 0;
  2407. if (iActualScene == 12) {
  2408. free((void *) res);
  2409. return;
  2410. }
  2411. }
  2412. ddxCleareSurface(CompositDC);
  2413. ddxCleareSurface(FontDC);
  2414. ddxCleareSurface(BackDC);
  2415. BEGIN_MENU_NEWGAMESCENE_BRUTAL:
  2416. for (bind = 0; bind < RES_NUM; bind++) {
  2417. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  2418. res[bind].iAnim[lastcmd][0] = -1;
  2419. res[bind].iAnim[lastcmd][11] = -1;
  2420. }
  2421. for (in = 0; in < 6; in++)
  2422. res[bind].iParam[in] = -1;
  2423. res[bind].pCmdLine = res;
  2424. }
  2425. lastcmd = 0;
  2426. timercnt = 0;
  2427. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  2428. working_file_translate(dir, 256);
  2429. chdir((dir));
  2430. //natadhe skript menu
  2431. LoadMenuScript(p_File_Name, res, &lastcmd);
  2432. in = 0;
  2433. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  2434. // animace na OnAbove
  2435. for (i = 0; i < lastcmd; i++) {
  2436. lastanm = 0;
  2437. switch (res[i].iParam[0]) {
  2438. case COM_DRAW:
  2439. //ddxDrawDisplay(res[i].iParam, 0);
  2440. ddxDrawSurface(BackDC, res[i].iParam, 0);
  2441. break;
  2442. case COM_RANDOMANIMATION:
  2443. case COM_ONCLICK:
  2444. case COM_ONABOVE:
  2445. case COM_RUNANIMATION:
  2446. case COM_BINDEXITANIMATION:
  2447. case COM_BINDANIMATION:
  2448. //nahrati animace k udalosti OnAbove
  2449. LoadAnimationMenuScript(res, i, &lastanm);
  2450. break;
  2451. }
  2452. }
  2453. RunMenuNewGameSceneActivate(res);
  2454. ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
  2455. ddxCleareSurface(BackDC);
  2456. //DisplayFrame();
  2457. BEGIN_MENU_NEWGAMESCENE:
  2458. //NOVA CESTA ////////////////////////////////////////////////////////////////////////////////////
  2459. if (bNewScene) {
  2460. bNewScene = 0;
  2461. // 1 = prvni animace way1_2
  2462. /*res[1].bEndActivate[0] = 10; //prvni OnAbove
  2463. res[1].bEndActivate[1] = 19; //prvni OnClick
  2464. res[1].bActive = 1; *///aktivace
  2465. // 1 = prvni animace way1_2
  2466. res[iActualScene].bEndActivate[0] = 10 + (iActualScene - 1); //prvni OnAbove
  2467. res[iActualScene].bEndActivate[1] = 19 + (iActualScene - 1); //prvni OnClick
  2468. res[iActualScene].bActive = 1; //aktivace
  2469. pPlayerProfile.cScene[iActualScene + 1] = 1;
  2470. pr_SaveProfile(&pPlayerProfile);
  2471. }
  2472. //aktivace tlacitka zpet
  2473. res[27].bActive = 1;
  2474. res[28].bActive = 1;
  2475. for (i = 0; i < lastcmd; i++)
  2476. if (res[i].iParam[0] == COM_RUNANIMATION && res[i].bActive) {
  2477. int iWave = AddAnimation(&res[i], p_ad, 0, 1);
  2478. if (iWave != -1) {
  2479. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2480. anm[iWave].iWave = res[i + 1].iParam[5] =
  2481. mPlaySound(&res[i + 1], p_ad, 2);
  2482. }
  2483. }
  2484. dim.t1 = 0;
  2485. dim.t2 = 0;
  2486. dim.dx = 0;
  2487. dim.dy = 0;
  2488. anmid = -1;
  2489. resid = -1;
  2490. anbind = -1;
  2491. bind = -1;
  2492. lastabv = -1;
  2493. in = 0;
  2494. spracuj_spravy(0);
  2495. dwLTime = timeGetTime();
  2496. while (!key[K_ESC]) {
  2497. dwStart = timeGetTime();
  2498. //pohnul mysi
  2499. if (dim.dx || dim.dy) {
  2500. //dostala se mys do akcni oblasti (OnAbove)?
  2501. if (!click)
  2502. for (i = 0; i < lastcmd; i++)
  2503. if (res[i].iParam[0] == COM_ONABOVE && res[i].bActive) {
  2504. if ((dim.x >= res[i].iParam[1]) &&
  2505. (dim.x <= res[i].iParam[3]) &&
  2506. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  2507. //spusteni animace v OnAbove
  2508. if (i != lastabv) {
  2509. if (in) {
  2510. Stop(&res[lastabv]);
  2511. if (!res[lastabv].iLayer) {
  2512. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  2513. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  2514. }
  2515. else {
  2516. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  2517. TRANSCOLOR);
  2518. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  2519. }
  2520. }
  2521. CheckAnimation(&res[i], p_ad);
  2522. lastabv = i;
  2523. AddAnimation(&res[i], p_ad, 0, 1);
  2524. in = 1;
  2525. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  2526. if (bind != -1) {
  2527. CheckAnimation(&res[bind], p_ad);
  2528. AddAnimation(&res[bind], p_ad, 1, 1);
  2529. anbind = bind;
  2530. mPlaySound(&res[bind], p_ad, 0);
  2531. }
  2532. strcpy(dir, res[i].cParam[1]);
  2533. }
  2534. }
  2535. else if (lastabv == i) {
  2536. LEAVE_ANIMATION:
  2537. // odesel z oblasti, ktera byla aktivni -> stop animace
  2538. // a odznaceni oblasti
  2539. Stop(&res[i]);
  2540. if (!res[i].iLayer) {
  2541. ddxDrawDisplay(res[i].iAnim[0], 0);
  2542. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  2543. }
  2544. else {
  2545. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  2546. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  2547. }
  2548. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  2549. if (bind != -1) {
  2550. int iAnim;
  2551. if (anbind != -1) {
  2552. Stop(&res[anbind]);
  2553. if (!res[anbind].iLayer) {
  2554. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  2555. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  2556. }
  2557. else {
  2558. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  2559. TRANSCOLOR);
  2560. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  2561. }
  2562. }
  2563. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  2564. if (iAnim != -1)
  2565. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  2566. }
  2567. lastabv = -1;
  2568. anbind = -1;
  2569. in = 0;
  2570. strcpy(dir, "");
  2571. }
  2572. dim.dx = 0;
  2573. dim.dy = 0;
  2574. }
  2575. }
  2576. //stlacil leve tlacitko
  2577. if (dim.t1 && !click) {
  2578. //dostala se mys do akcni oblasti (OnClick)?
  2579. for (i = 0; i < lastcmd; i++)
  2580. if (res[i].iParam[0] == COM_ONCLICK && res[i].bActive)
  2581. if ((dim.x >= res[i].iParam[1]) &&
  2582. (dim.x <= res[i].iParam[3]) &&
  2583. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  2584. if (res[i].iAnim[0][0] >= 0) {
  2585. //pokud je animace, tak ji spust
  2586. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  2587. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2588. mPlaySound(&res[i + 1], p_ad, 1);
  2589. resid = i;
  2590. click = 1;
  2591. }
  2592. else {
  2593. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2594. mPlaySound(&res[i + 1], p_ad, 1);
  2595. resid = i;
  2596. click = 1;
  2597. anmid = 31;
  2598. }
  2599. }
  2600. dim.t1 = 0;
  2601. }
  2602. //provedeni akce po animaci menu
  2603. if (click)
  2604. if (!anm[anmid].cmd) {
  2605. click = 0;
  2606. //StopAll();
  2607. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  2608. !strcmp(res[resid].cParam[1], "CANCEL")) {
  2609. key[K_ESC] = 1;
  2610. cRestartMainMenu = 1;
  2611. //break;
  2612. }
  2613. if (!strcmp(res[resid].cParam[1], "SCENE1")) {
  2614. if (iLanguageVersion == 4 && !CheckScenePresence(1)) {
  2615. RunMenuCibron("buy.bmp");
  2616. click = 0;
  2617. i = lastabv;
  2618. goto LEAVE_ANIMATION;
  2619. }
  2620. else {
  2621. iActualScene = 1;
  2622. RunStretchAnimation("scene1_map.bmp", 0, 129, p_ad);
  2623. RunMenuSceneMap("Mmnew_game_scene1_map.txt", NULL, p_ad, cpu,
  2624. "scene1_map.bmp", "scene1_anim", 1, 0, 11, "scene1_levels.txt",
  2625. 919, 677, 0, NULL, 0, 713, 679);
  2626. }
  2627. }
  2628. if (!strcmp(res[resid].cParam[1], "SCENE2")) {
  2629. if (iLanguageVersion == 4 && !CheckScenePresence(2)) {
  2630. RunMenuCibron("buy.bmp");
  2631. click = 0;
  2632. i = lastabv;
  2633. goto LEAVE_ANIMATION;
  2634. }
  2635. else {
  2636. iActualScene = 2;
  2637. RunStretchAnimation("scene2_map.bmp", 215, 0, p_ad);
  2638. RunMenuSceneMap("Mmnew_game_scene2_map.txt", NULL, p_ad, cpu,
  2639. "scene2_map.bmp", "scene2_anim", 2, 11, 10, "scene2_levels.txt",
  2640. 916, 8, 0, NULL, 0, 971, 703);
  2641. }
  2642. }
  2643. if (!strcmp(res[resid].cParam[1], "SCENE3")) {
  2644. if (iLanguageVersion == 4 && !CheckScenePresence(3)) {
  2645. RunMenuCibron("buy.bmp");
  2646. click = 0;
  2647. i = lastabv;
  2648. goto LEAVE_ANIMATION;
  2649. }
  2650. else {
  2651. iActualScene = 3;
  2652. RunStretchAnimation("scene3_map.bmp", 177, 248, p_ad);
  2653. RunMenuSceneMap("Mmnew_game_scene3_map.txt", NULL, p_ad, cpu,
  2654. "scene3_map.bmp", "scene3_anim", 3, 21, 12, "scene3_levels.txt",
  2655. 918, 7, 0, NULL, 0, 973, 413);
  2656. }
  2657. }
  2658. if (!strcmp(res[resid].cParam[1], "SCENE4")) {
  2659. if (iLanguageVersion == 4 && !CheckScenePresence(4)) {
  2660. RunMenuCibron("buy.bmp");
  2661. click = 0;
  2662. i = lastabv;
  2663. goto LEAVE_ANIMATION;
  2664. }
  2665. else {
  2666. iActualScene = 4;
  2667. RunStretchAnimation("scene4_map.bmp", 444, 64, p_ad);
  2668. RunMenuSceneMap("Mmnew_game_scene4_map.txt", NULL, p_ad, cpu,
  2669. "scene4_map.bmp", "scene4_anim", 4, 33, 10, "scene4_levels.txt",
  2670. 197, 9, 0, NULL, 0, 8, 16);
  2671. }
  2672. }
  2673. if (!strcmp(res[resid].cParam[1], "SCENE5")) {
  2674. if (iLanguageVersion == 4 && !CheckScenePresence(5)) {
  2675. RunMenuCibron("buy.bmp");
  2676. click = 0;
  2677. i = lastabv;
  2678. goto LEAVE_ANIMATION;
  2679. }
  2680. else {
  2681. iActualScene = 5;
  2682. RunStretchAnimation("scene5_map.bmp", 465, 386, p_ad);
  2683. RunMenuSceneMap("Mmnew_game_scene5_map.txt", NULL, p_ad, cpu,
  2684. "scene5_map.bmp", "scene5_anim", 5, 43, 10, "scene5_levels.txt",
  2685. 918, 9, 0, NULL, 0, 976, 309);
  2686. }
  2687. }
  2688. #ifndef __DEMO
  2689. if (!strcmp(res[resid].cParam[1], "SCENE6")) {
  2690. if (iLanguageVersion == 4 && !CheckScenePresence(6)) {
  2691. RunMenuCibron("buy.bmp");
  2692. click = 0;
  2693. i = lastabv;
  2694. goto LEAVE_ANIMATION;
  2695. }
  2696. else {
  2697. iActualScene = 6;
  2698. RunStretchAnimation("scene6_map.bmp", 37, 495, p_ad);
  2699. RunMenuSceneMap("Mmnew_game_scene6_map.txt", NULL, p_ad, cpu,
  2700. "scene6_map.bmp", "scene6_anim", 6, 53, 10, "scene6_levels.txt",
  2701. 920, 8, 0, NULL, 0, 967, 211);
  2702. }
  2703. }
  2704. #endif
  2705. #ifdef __DEMO
  2706. if (!strcmp(res[resid].cParam[1], "SCENE6")) {
  2707. iActualScene = 6;
  2708. RunStretchAnimation("scene6_map.bmp", 37, 495, p_ad);
  2709. RunMenuSceneMap("Mmnew_game_scene6_map.txt", NULL, p_ad, cpu,
  2710. "scene6_map.bmp", "scene6_anim", 6, 53, 6, "scene6_levels.txt",
  2711. 920, 8, 0, NULL, 0, 967, 211);
  2712. }
  2713. #endif
  2714. if (!strcmp(res[resid].cParam[1], "SCENE7")) {
  2715. if (iLanguageVersion == 4 && !CheckScenePresence(7)) {
  2716. RunMenuCibron("buy.bmp");
  2717. click = 0;
  2718. i = lastabv;
  2719. goto LEAVE_ANIMATION;
  2720. }
  2721. else {
  2722. iActualScene = 7;
  2723. RunStretchAnimation("scene7_map.bmp", 616, 638, p_ad);
  2724. RunMenuSceneMap("Mmnew_game_scene7_map.txt", NULL, p_ad, cpu,
  2725. "scene7_map.bmp", "scene7_anim", 7, 63, 10, "scene7_levels.txt",
  2726. 11, 6, 0, NULL, 0, 8, 279);
  2727. }
  2728. }
  2729. if (!strcmp(res[resid].cParam[1], "SCENE8")) {
  2730. if (iLanguageVersion == 4 && !CheckScenePresence(8)) {
  2731. RunMenuCibron("buy.bmp");
  2732. click = 0;
  2733. i = lastabv;
  2734. goto LEAVE_ANIMATION;
  2735. }
  2736. else {
  2737. iActualScene = 8;
  2738. RunStretchAnimation("scene8_map.bmp", 836, 469, p_ad);
  2739. RunMenuSceneMap("Mmnew_game_scene8_map.txt", NULL, p_ad, cpu,
  2740. "scene8_map.bmp", "scene8_anim", 8, 73, 12, "scene8_levels.txt",
  2741. 15, 677, 0, NULL, 0, 12, 490);
  2742. }
  2743. }
  2744. if (!strcmp(res[resid].cParam[1], "SCENE9")) {
  2745. if (iLanguageVersion == 4 && !CheckScenePresence(9)) {
  2746. RunMenuCibron("buy.bmp");
  2747. click = 0;
  2748. i = lastabv;
  2749. goto LEAVE_ANIMATION;
  2750. }
  2751. else {
  2752. iActualScene = 9;
  2753. RunStretchAnimation("scene9_map.bmp", 836, 49, p_ad);
  2754. RunMenuSceneMap("Mmnew_game_scene9_map.txt", NULL, p_ad, cpu,
  2755. "scene9_map.bmp", "scene9_anim", 9, 85, 10, "scene9_levels.txt",
  2756. 918, 7, 0, NULL, 0, 971, 338);
  2757. }
  2758. }
  2759. resid = -1;
  2760. if (!iActualScene)
  2761. key[K_ESC] = 1;
  2762. if (key[K_ESC]) {
  2763. /*
  2764. for(i=0;i<lastcmd;i++)
  2765. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  2766. {
  2767. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  2768. res[i].iParam[5] = -1;
  2769. }
  2770. */
  2771. goto __QUIT;
  2772. }
  2773. else {
  2774. for (i = 0; i < lastcmd; i++) {
  2775. switch (res[i].iParam[0]) {
  2776. case COM_DRAW:
  2777. ddxDrawSurface(BackDC, res[i].iParam, 0);
  2778. break;
  2779. }
  2780. }
  2781. RunMenuNewGameSceneActivate(res);
  2782. ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
  2783. ddxCleareSurface(BackDC);
  2784. goto BEGIN_MENU_NEWGAMESCENE;
  2785. }
  2786. }
  2787. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  2788. if (timercnt > 500) {
  2789. timercnt = 0;
  2790. for (i = 0; i < lastcmd; i++)
  2791. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  2792. if (rand() % 200 <= res[i].iParam[1] &&
  2793. strcmp(dir, res[i].cParam[0])) {
  2794. CheckAnimation(&res[i], p_ad);
  2795. AddAnimation(&res[i], p_ad, 0, 0);
  2796. }
  2797. }
  2798. /* spracuj_spravy(0);
  2799. ddxUpdateMouse();
  2800. if(dim.dx || dim.dy)
  2801. DisplayFrame();*/
  2802. dwStop = timeGetTime();
  2803. dwEplased += dwStop - dwStart;
  2804. spracuj_spravy(0);
  2805. ddxUpdateMouse();
  2806. AnimationEvent(dwStop, p_ad);
  2807. if (dim.tf1) {
  2808. dim.t1 = 1;
  2809. dim.tf1 = 0;
  2810. }
  2811. if (dim.tf2) {
  2812. dim.t2 = 1;
  2813. dim.tf2 = 0;
  2814. }
  2815. if (ddxRestore(p_ad)) {
  2816. StopAll();
  2817. FreeAnimations(res, RES_NUM);
  2818. goto BEGIN_MENU_NEWGAMESCENE_BRUTAL;
  2819. }
  2820. }
  2821. __QUIT:
  2822. ddxCleareSurface(FontDC);
  2823. ddxCleareSurface(BackDC);
  2824. ddxCleareSurface(CompositDC);
  2825. cRestartMainMenu = 1;
  2826. key[K_ESC] = 0;
  2827. FreeAnimations(res, RES_NUM);
  2828. free((void *) res);
  2829. }
  2830. void LoadSceneMap(int *pBmp, char *cSceneBmp, char *cSceneAnim, int iScene,
  2831. int *iClock)
  2832. {
  2833. int i;
  2834. char text[256];
  2835. APAK_HANDLE *hArchive = NULL;
  2836. char cFile[MAX_PATH];
  2837. char cDir[MAX_PATH];
  2838. if (iLanguageVersion == 4) {
  2839. GetPrivateProfileString("game", "bitmap_dir", "c:\\", cDir, MAX_PATH,
  2840. ini_file);
  2841. working_file_translate(cDir, MAX_PATH);
  2842. sprintf(cFile, "%s\\scene%d.pak", cDir, iScene);
  2843. apak_dir_correction(cDir);
  2844. hArchive = apakopen(cFile, cDir, &i);
  2845. if (!hArchive) {
  2846. kprintf(1, "Nepodarilo se otevrit archiv [%s]\n", cFile);
  2847. return;
  2848. }
  2849. else
  2850. hArchive->pActualNode = hArchive->pRootNode->pNextNode;
  2851. pBmp[0] = ddxLoadBitmap(cSceneBmp, hArchive);
  2852. for (i = 1; i < 6; i++) {
  2853. sprintf(text, "%s%d.bmp", cSceneAnim, i);
  2854. pBmp[i] = ddxLoadBitmap(text, hArchive);
  2855. DrawClock(iClock, i);
  2856. }
  2857. apakclose(hArchive);
  2858. }
  2859. else {
  2860. pBmp[0] = ddxLoadBitmap(cSceneBmp, pBmpArchive);
  2861. for (i = 1; i < 6; i++) {
  2862. sprintf(text, "%s%d.bmp", cSceneAnim, i);
  2863. pBmp[i] = ddxLoadBitmap(text, pBmpArchive);
  2864. DrawClock(iClock, i);
  2865. }
  2866. }
  2867. switch (iScene) {
  2868. case 1:
  2869. case 2:
  2870. case 3:
  2871. case 4:
  2872. case 7:
  2873. pBmp[6] = ddxLoadBitmap("level_green.bmp", pBmpArchive);
  2874. pBmp[7] = ddxLoadBitmap("level_ok_green.bmp", pBmpArchive);
  2875. pBmp[8] = ddxLoadBitmap("b1_green.bmp", pBmpArchive);
  2876. pBmp[9] = ddxLoadBitmap("b2_green.bmp", pBmpArchive);
  2877. pBmp[10] = ddxLoadBitmap("level_green_l.bmp", pBmpArchive);
  2878. pBmp[11] = ddxLoadBitmap("level_ok_green_l.bmp", pBmpArchive);
  2879. break;
  2880. case 5:
  2881. case 8:
  2882. pBmp[6] = ddxLoadBitmap("level_brown.bmp", pBmpArchive);
  2883. pBmp[7] = ddxLoadBitmap("level_ok_brown.bmp", pBmpArchive);
  2884. pBmp[8] = ddxLoadBitmap("b1_brown.bmp", pBmpArchive);
  2885. pBmp[9] = ddxLoadBitmap("b2_brown.bmp", pBmpArchive);
  2886. pBmp[10] = ddxLoadBitmap("level_brown_l.bmp", pBmpArchive);
  2887. pBmp[11] = ddxLoadBitmap("level_ok_brown_l.bmp", pBmpArchive);
  2888. break;
  2889. case 0:
  2890. pBmp[6] = ddxLoadBitmap("level_tutorial.bmp", pBmpArchive);
  2891. pBmp[7] = ddxLoadBitmap("level_ok_tutorial.bmp", pBmpArchive);
  2892. pBmp[8] = ddxLoadBitmap("b1_blue.bmp", pBmpArchive);
  2893. pBmp[9] = ddxLoadBitmap("b2_blue.bmp", pBmpArchive);
  2894. pBmp[10] = ddxLoadBitmap("level_tutorial_l.bmp", pBmpArchive);
  2895. pBmp[11] = ddxLoadBitmap("level_ok_tutorial_l.bmp", pBmpArchive);
  2896. break;
  2897. case 6:
  2898. case 9:
  2899. case 10:
  2900. case 11:
  2901. pBmp[6] = ddxLoadBitmap("level_blue.bmp", pBmpArchive);
  2902. pBmp[7] = ddxLoadBitmap("level_ok_blue.bmp", pBmpArchive);
  2903. pBmp[8] = ddxLoadBitmap("b1_blue.bmp", pBmpArchive);
  2904. pBmp[9] = ddxLoadBitmap("b2_blue.bmp", pBmpArchive);
  2905. pBmp[10] = ddxLoadBitmap("level_blue_l.bmp", pBmpArchive);
  2906. pBmp[11] = ddxLoadBitmap("level_ok_blue_l.bmp", pBmpArchive);
  2907. break;
  2908. case 12:
  2909. pBmp[6] = ddxLoadBitmap("level_yellow.bmp", pBmpArchive);
  2910. pBmp[7] = ddxLoadBitmap("level_ok_yellow.bmp", pBmpArchive);
  2911. pBmp[8] = ddxLoadBitmap("b1_yellow.bmp", pBmpArchive);
  2912. pBmp[9] = ddxLoadBitmap("b2_yellow.bmp", pBmpArchive);
  2913. pBmp[10] = ddxLoadBitmap("level_yellow_l.bmp", pBmpArchive);
  2914. pBmp[11] = ddxLoadBitmap("level_ok_yellow_l.bmp", pBmpArchive);
  2915. break;
  2916. }
  2917. DrawClock(iClock, 6);
  2918. }
  2919. void DrawLevelHint(int x, int y, int iLevel)
  2920. {
  2921. int idx;
  2922. char text[256];
  2923. sprintf(text, "t_%d.bmp", iLevel - 200);
  2924. idx = ddxLoadBitmap(text, pBmpArchive);
  2925. if (idx == -1)
  2926. return;
  2927. ddxBitBlt(FontDC, x, y, ddxGetWidth(idx), ddxGetHight(idx), idx, 0, 0);
  2928. ddxTransparentBlt(BackDC, x, y, ddxGetWidth(idx), ddxGetHight(idx), idx, 0,
  2929. 0, ddxGetWidth(idx), ddxGetHight(idx), TRANSCOLOR);
  2930. ddxReleaseBitmap(idx);
  2931. }
  2932. void CreateLevelButton(int x, int y, CMD_LINE * res, int *lastcmd, int *pBmp,
  2933. char *cMessage, char bDone, int iDificulty, char bTuturial, int iLevel)
  2934. {
  2935. int ii;
  2936. char text[1024];
  2937. //Draw(1,0,0)
  2938. sprintf(text, "Draw(%d,%d,%d)", pBmp[6 + bDone], x, y);
  2939. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  2940. res[*lastcmd].cParam[1]);
  2941. res[*lastcmd].iLayer = 1;
  2942. (*lastcmd)++;
  2943. /*if(bTuturial)
  2944. DrawLevelHint(x + ddxGetWidth(pBmp[6+bDone]), y, iLevel); */
  2945. //OnAbove(16,661,100,748, NO_EXEPTION, NO_EXEPTION)
  2946. sprintf(text, "OnAbove(%d,%d,%d,%d, %s, NO_EXEPTION)", x, y,
  2947. x + ddxGetWidth(pBmp[6 + bDone]), y + ddxGetHight(pBmp[6 + bDone]),
  2948. cMessage);
  2949. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  2950. res[*lastcmd].cParam[1]);
  2951. res[*lastcmd].iLayer = 1;
  2952. res[*lastcmd].uiTimerID = 0;
  2953. res[*lastcmd].iLastfrm = 1;
  2954. res[*lastcmd].iCounter = 0;
  2955. res[*lastcmd].iAnim[0][0] = 0;
  2956. res[*lastcmd].iAnim[0][1] = pBmp[6 + bDone];
  2957. res[*lastcmd].iAnim[0][2] = x;
  2958. res[*lastcmd].iAnim[0][3] = y;
  2959. res[*lastcmd].iAnim[0][4] = 0;
  2960. res[*lastcmd].iAnim[0][5] = 1;
  2961. for (ii = 6; ii < 13; ii++)
  2962. res[*lastcmd].iAnim[0][ii] = -1;
  2963. res[*lastcmd].iAnim[1][0] = 1;
  2964. res[*lastcmd].iAnim[1][1] = pBmp[10 + bDone];
  2965. res[*lastcmd].iAnim[1][2] = x;
  2966. res[*lastcmd].iAnim[1][3] = y;
  2967. res[*lastcmd].iAnim[1][4] = 50;
  2968. res[*lastcmd].iAnim[1][5] = 2;
  2969. for (ii = 6; ii < 13; ii++)
  2970. res[*lastcmd].iAnim[1][ii] = -1;
  2971. res[*lastcmd].iAnim[2][0] = 2;
  2972. res[*lastcmd].iAnim[2][1] = pBmp[10 + bDone];
  2973. res[*lastcmd].iAnim[2][2] = x;
  2974. res[*lastcmd].iAnim[2][3] = y;
  2975. res[*lastcmd].iAnim[2][4] = 50;
  2976. res[*lastcmd].iAnim[2][5] = -1;
  2977. for (ii = 6; ii < 13; ii++)
  2978. res[*lastcmd].iAnim[2][ii] = -1;
  2979. res[*lastcmd].iLayer = 1;
  2980. (*lastcmd)++;
  2981. if (!bTuturial) {
  2982. if (!iDificulty) {
  2983. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  2984. sprintf(text,
  2985. "BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)");
  2986. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  2987. res[*lastcmd].cParam[1]);
  2988. (*lastcmd)++;
  2989. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  2990. sprintf(text,
  2991. "BindAnimation(118, -1, -1, -1, televize6.txt, televize.txt)");
  2992. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  2993. res[*lastcmd].cParam[1]);
  2994. (*lastcmd)++;
  2995. }
  2996. else if (iDificulty == 1) {
  2997. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  2998. sprintf(text,
  2999. "BindAnimation(118, -1, -1, -1, televize7.txt, televize.txt)");
  3000. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3001. res[*lastcmd].cParam[1]);
  3002. (*lastcmd)++;
  3003. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  3004. sprintf(text,
  3005. "BindAnimation(118, -1, -1, -1, televize8.txt, televize.txt)");
  3006. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3007. res[*lastcmd].cParam[1]);
  3008. (*lastcmd)++;
  3009. }
  3010. else if (iDificulty == 2) {
  3011. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  3012. sprintf(text,
  3013. "BindAnimation(118, -1, -1, -1, televize9.txt, televize.txt)");
  3014. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3015. res[*lastcmd].cParam[1]);
  3016. (*lastcmd)++;
  3017. }
  3018. else if (iDificulty == 3) {
  3019. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  3020. sprintf(text,
  3021. "BindAnimation(118, -1, -1, -1, televize10.txt, televize.txt)");
  3022. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3023. res[*lastcmd].cParam[1]);
  3024. (*lastcmd)++;
  3025. }
  3026. else {
  3027. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  3028. sprintf(text,
  3029. "BindAnimation(118, -1, -1, -1, televize11.txt, televize.txt)");
  3030. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3031. res[*lastcmd].cParam[1]);
  3032. (*lastcmd)++;
  3033. //BindAnimation(118, -1, -1, -1, televize5.txt, televize.txt)
  3034. sprintf(text,
  3035. "BindAnimation(118, -1, -1, -1, televize12.txt, televize.txt)");
  3036. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3037. res[*lastcmd].cParam[1]);
  3038. (*lastcmd)++;
  3039. }
  3040. //BindExitAnimation(114,115,116,117, televize.txt)
  3041. sprintf(text, "BindExitAnimation(114,115,116,117, televize.txt)");
  3042. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3043. res[*lastcmd].cParam[1]);
  3044. (*lastcmd)++;
  3045. }
  3046. /* else
  3047. {
  3048. //OnAbove(16,661,100,748, NO_EXEPTION, NO_EXEPTION)
  3049. sprintf(text,"OnAbove(%d,%d,%d,%d, %s, NO_EXEPTION)", x, y, x + ddxGetWidth(pBmp[6+bDone]), y + ddxGetHight(pBmp[6+bDone]), cMessage);
  3050. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0], res[*lastcmd].cParam[1]);
  3051. res[*lastcmd].iLayer = 1;
  3052. (*lastcmd)++;
  3053. }*/
  3054. //OnClick(16,661,100,748, quit_gamec.txt, EXIT)
  3055. sprintf(text, "OnClick(%d,%d,%d,%d, NO_EXEPTION, %s)", x, y,
  3056. x + ddxGetWidth(pBmp[6 + bDone]), y + ddxGetHight(pBmp[6 + bDone]),
  3057. cMessage);
  3058. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3059. res[*lastcmd].cParam[1]);
  3060. res[*lastcmd].iLayer = 1;
  3061. (*lastcmd)++;
  3062. //BindSound(54,55,56,-1)
  3063. strcpy(text, "BindSound(54,55,56,-1)");
  3064. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  3065. res[*lastcmd].cParam[1]);
  3066. res[*lastcmd].iLayer = 0;
  3067. (*lastcmd)++;
  3068. }
  3069. void CreateLevelButtons(CMD_LINE * res, int *lastcmd, int *pBmp, int iScene,
  3070. int iLevelStart, int iNumOfLevels, char *cLevelList, char bTutorial)
  3071. {
  3072. char text[256];
  3073. int r[4];
  3074. int i;
  3075. FILE *file;
  3076. file = aopen(pDataArchive, cLevelList, "r");
  3077. if (!file)
  3078. return;
  3079. for (i = iLevelStart; i < iLevelStart + iNumOfLevels; i++) {
  3080. Parse_AnimLine(file, r, 4);
  3081. if (bTutorial && i != iLevelStart)
  3082. if (!pPlayerProfile.cLevel[i - 1])
  3083. break;
  3084. CreateLevelButton(r[1], r[2], res, lastcmd, pBmp, itoa(r[0], text, 10),
  3085. pPlayerProfile.cLevel[i], r[3], bTutorial, i);
  3086. }
  3087. aclose(file);
  3088. }
  3089. int LoadTV(void)
  3090. {
  3091. int c = 0, i = -1, t;
  3092. char text[256];
  3093. FILE *file;
  3094. file = aopen(pBmpArchive, "tvload.txt", "r");
  3095. if (!file)
  3096. return -1;
  3097. while (!aeof(file)) {
  3098. memset(text, 0, 256);
  3099. agets(text, 256, file);
  3100. if (strlen(text)) {
  3101. text[strlen(text) - 1] = '\0';
  3102. if (!c)
  3103. i = ddxLoadBitmap(text, pBmpArchive);
  3104. else
  3105. t = ddxLoadBitmap(text, pBmpArchive);
  3106. c++;
  3107. }
  3108. }
  3109. aclose(file);
  3110. pBmpArchive->bError = 0;
  3111. return i;
  3112. }
  3113. void CorrectTV(CMD_LINE * res, int iAnim, int iLast, int x, int y, int idx,
  3114. int iScene)
  3115. {
  3116. int tvcoridx = -1;
  3117. int i, d;
  3118. switch (iScene) {
  3119. case 5:
  3120. case 8:
  3121. tvcoridx = ddxLoadBitmap("tvcor_brown.bmp", pBmpArchive);
  3122. break;
  3123. case 0:
  3124. case 6:
  3125. case 9:
  3126. case 10:
  3127. case 11:
  3128. tvcoridx = ddxLoadBitmap("tvcor_blue.bmp", pBmpArchive);
  3129. break;
  3130. case 12:
  3131. tvcoridx = ddxLoadBitmap("tvcor_yellow.bmp", pBmpArchive);
  3132. break;
  3133. }
  3134. for (i = 0; i < iLast; i++) {
  3135. res[iAnim].iAnim[i][2] = x;
  3136. res[iAnim].iAnim[i][3] = y;
  3137. res[iAnim].iAnim[i][1] += (idx - 250);
  3138. d = res[iAnim].iAnim[i][1];
  3139. if (tvcoridx != -1 && res[iAnim].iAnim[i][0] != -1)
  3140. ddxTransparentBlt(d, 0, 0, ddxGetWidth(d), ddxGetHight(d), tvcoridx,
  3141. 0, 0, ddxGetWidth(tvcoridx), ddxGetHight(tvcoridx), TRANSCOLOR);
  3142. //kprintf(1, "tv corrected to %d", res[iAnim].iAnim[i][1]);
  3143. }
  3144. if (tvcoridx != -1)
  3145. ddxReleaseBitmap(tvcoridx);
  3146. }
  3147. void CreateBackButton(CMD_LINE * res, int *lastcmd, int sidx1, int sidx2,
  3148. int xBack, int yBack)
  3149. {
  3150. int lcmd = *lastcmd;
  3151. int i, ii;
  3152. for (i = 0; i < lcmd; i++)
  3153. if (res[i].iParam[0] == COM_ONABOVE) {
  3154. res[i].uiTimerID = 0;
  3155. res[i].iLastfrm = 1;
  3156. res[i].iCounter = 0;
  3157. /*
  3158. (0, 123, 0, 640, 0, 1)
  3159. (1, 124, 0, 640, 25, 2)
  3160. (2, 124, 0, 640, 25, -1)
  3161. */
  3162. res[i].iAnim[0][0] = 0;
  3163. res[i].iAnim[0][1] = sidx1;
  3164. res[i].iAnim[0][2] = xBack;
  3165. res[i].iAnim[0][3] = yBack;
  3166. res[i].iAnim[0][4] = 0;
  3167. res[i].iAnim[0][5] = 1;
  3168. for (ii = 6; ii < 13; ii++)
  3169. res[i].iAnim[0][ii] = -1;
  3170. res[i].iAnim[1][0] = 1;
  3171. res[i].iAnim[1][1] = sidx2;
  3172. res[i].iAnim[1][2] = xBack;
  3173. res[i].iAnim[1][3] = yBack;
  3174. res[i].iAnim[1][4] = 50;
  3175. res[i].iAnim[1][5] = 2;
  3176. for (ii = 6; ii < 13; ii++)
  3177. res[i].iAnim[1][ii] = -1;
  3178. res[i].iAnim[2][0] = 2;
  3179. res[i].iAnim[2][1] = sidx2;
  3180. res[i].iAnim[2][2] = xBack;
  3181. res[i].iAnim[2][3] = yBack;
  3182. res[i].iAnim[2][4] = 50;
  3183. res[i].iAnim[2][5] = -1;
  3184. for (ii = 6; ii < 13; ii++)
  3185. res[i].iAnim[2][ii] = -1;
  3186. res[i].iLayer = 0;
  3187. return;
  3188. }
  3189. }
  3190. void DrawClock(int *iClock, int i)
  3191. {
  3192. if (iClock[i] == -1)
  3193. return;
  3194. spracuj_spravy(0);
  3195. ddxSetCursorSurface(iClock[i]);
  3196. ddxUpdateMouse();
  3197. DisplayFrame();
  3198. }
  3199. int LoadClock(int *iClock)
  3200. {
  3201. int c = 0, i = -1, t;
  3202. char text[256];
  3203. FILE *file;
  3204. file = aopen(pBmpArchive, "loadclock.txt", "r");
  3205. if (!file)
  3206. return -1;
  3207. while (!aeof(file)) {
  3208. ZeroMemory(text, 256);
  3209. agets(text, 256, file);
  3210. if (!strlen(text))
  3211. break;
  3212. text[strlen(text) - 1] = '\0';
  3213. if (!c) {
  3214. i = ddxLoadBitmap(text, pBmpArchive);
  3215. iClock[c] = i;
  3216. /* if(i != -1)
  3217. {
  3218. int x = dim.x - ftoi(ddxGetWidth(i) / 2.0f);
  3219. int y = dim.y - ftoi(ddxGetHight(i) / 2.0f);
  3220. ddxTransparentBltDisplay(x, y, ddxGetWidth(i), ddxGetHight(i), i, 0, 0, ddxGetWidth(i), ddxGetHight(i), TRANSCOLOR);
  3221. }*/
  3222. }
  3223. else {
  3224. t = ddxLoadBitmap(text, pBmpArchive);
  3225. iClock[c] = t;
  3226. }
  3227. c++;
  3228. }
  3229. aclose(file);
  3230. pBmpArchive->bError = 0;
  3231. return i;
  3232. }
  3233. /*void MenuInitHint(char bTutorial)
  3234. {
  3235. if(bTutorial)
  3236. _2d_hint.iSurface = ddxLoadBitmap("hint_frame.bmp", pBmpArchive);
  3237. else
  3238. _2d_hint.iSurface = -1;
  3239. _2d_hint.iBSurface = -1;
  3240. }
  3241. void DrawHint(int x, int y)
  3242. {
  3243. RECT r;
  3244. if(_2d_hint.iSurface == -1)
  3245. return;
  3246. _2d_hint.iBSurface = ddxCreateSurface(ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), ddxFindFreeSurface());
  3247. if(_2d_hint.iBSurface == -1)
  3248. return;
  3249. if(x + ddxGetWidth(_2d_hint.iSurface) > 1014)
  3250. x = 1014 - ddxGetWidth(_2d_hint.iSurface);
  3251. _2d_hint.x = x;
  3252. _2d_hint.y = y;
  3253. ddxBitBlt(_2d_hint.iBSurface, 0, 0, ddxGetWidth(_2d_hint.iBSurface), ddxGetHight(_2d_hint.iBSurface), HDC2DD, x, y);
  3254. ddxBitBlt(CompositDC, x, y, ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), _2d_hint.iSurface, 0, 0);
  3255. ddxBitBltDisplay(x, y, ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), _2d_hint.iSurface, 0, 0);
  3256. r.left = x;
  3257. r.top = y;
  3258. r.right = ddxGetWidth(_2d_hint.iSurface);
  3259. r.bottom = ddxGetHight(_2d_hint.iSurface);
  3260. _2d_Add_RectItem(&rline, r, 2);
  3261. _2d_hint.bUsed = 1;
  3262. }
  3263. void SetHintRect(void)
  3264. {
  3265. RECT r;
  3266. if(!_2d_hint.bUsed)
  3267. return;
  3268. r.left = _2d_hint.x;
  3269. r.top = _2d_hint.y;
  3270. r.right = ddxGetWidth(_2d_hint.iSurface);
  3271. r.bottom = ddxGetHight(_2d_hint.iSurface);
  3272. _2d_Add_RectItem(&rline, r, 2);
  3273. }
  3274. void UpdateHintBackup(void)
  3275. {
  3276. if(!_2d_hint.bUsed)
  3277. return;
  3278. if(_2d_hint.iSurface == -1)
  3279. return;
  3280. ddxBitBlt(CompositDC, _2d_hint.x, _2d_hint.y, ddxGetWidth(_2d_hint.iSurface), ddxGetHight(_2d_hint.iSurface), _2d_hint.iSurface, 0, 0);
  3281. }
  3282. void ReleaseHint(char bFull, char bRestore)
  3283. {
  3284. if(_2d_hint.iSurface != -1 && bFull)
  3285. {
  3286. ddxReleaseBitmap(_2d_hint.iSurface);
  3287. _2d_hint.iSurface = -1;
  3288. }
  3289. if(_2d_hint.iBSurface != -1)
  3290. {
  3291. if(bRestore)
  3292. {
  3293. RECT r;
  3294. r.left = _2d_hint.x;
  3295. r.top = _2d_hint.y;
  3296. r.right = r.left + ddxGetWidth(_2d_hint.iBSurface);
  3297. r.bottom = r.top + ddxGetHight(_2d_hint.iBSurface);
  3298. ddxFillRect(CompositDC, &r, RGB(255, 0, 255));
  3299. ddxBitBltDisplay(_2d_hint.x, _2d_hint.y, ddxGetWidth(_2d_hint.iBSurface), ddxGetHight(_2d_hint.iBSurface),
  3300. _2d_hint.iBSurface, 0, 0);
  3301. }
  3302. ddxReleaseBitmap(_2d_hint.iBSurface);
  3303. _2d_hint.iBSurface = -1;
  3304. }
  3305. _2d_hint.bUsed = 0;
  3306. }
  3307. */
  3308. void RunMenuSceneMap(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu,
  3309. char *cSceneBmp, char *cSceneAnim, int iScene, int iLevelStart,
  3310. int iNumOfLevels, char *cLevelList, int xTV, int yTV, char bLoadGame,
  3311. char *cSaveFile, char bTutorial, int xBack, int yBack)
  3312. {
  3313. DWORD dwEplased = 0, dwStart, dwStop;
  3314. FILE *file;
  3315. char dir[256];
  3316. int lastcmd, lastanm, i;
  3317. CMD_LINE *res = NULL;
  3318. int lastabv = -1;
  3319. char in, click = 0;
  3320. int anmid = -1, resid = -1, anbind = -1;
  3321. int bind;
  3322. int iBmp[12];
  3323. int iTV = -1;
  3324. int iClock[12];
  3325. int cc = 0;
  3326. char cscenemap[64];
  3327. char csceneanim[64];
  3328. char csrriptname[64];
  3329. char cscenelevels[64];
  3330. char bReload = 0;
  3331. ZeroMemory(&_2d_hint, sizeof(_2D_HINT));
  3332. for (i = 0; i < 12; i++)
  3333. iClock[i] = -1;
  3334. pPlayerProfile.cScene[iScene] = 1;
  3335. pr_SaveProfile(&pPlayerProfile);
  3336. ////////////////////////////LOAD GAME/////////////////////////////////////////
  3337. if (bLoadGame) {
  3338. sprintf(dir, "%s.lv6", cSaveFile);
  3339. if (RunLevel(NULL, p_ad, cpu, dir, "LOAD_GAME") == 1) {
  3340. pPlayerProfile.cLevel[iActualLevel] = 1;
  3341. pr_SaveProfile(&pPlayerProfile);
  3342. }
  3343. for (i = 0; i < 32; i++)
  3344. anm[i].cmd = NULL;
  3345. //TODO - pokud se jedna o tutorial, detskou ci custom, tak to crushne .... proc?
  3346. }
  3347. ////////////////////////////LOAD GAME/////////////////////////////////////////
  3348. LoadClock(iClock);
  3349. if (iClock[0] != -1) {
  3350. ddxResizeCursorBack(iClock[0]);
  3351. DrawClock(iClock, 0);
  3352. }
  3353. for (i = 0; i < 12; i++)
  3354. iBmp[i] = -1;
  3355. bBackDC = 0;
  3356. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  3357. if (!res) {
  3358. kprintf(1, "RunMenuSceneMap: Out of Memory");
  3359. return;
  3360. }
  3361. BRUTAL_RESTART_SCENE_MAP_MENU:
  3362. bReload = 1;
  3363. bBackDC = 0;
  3364. _2d_Clear_RectLine(&rline);
  3365. ddxSetFlip(TRUE);
  3366. cc = 0;
  3367. iTV = -1;
  3368. anmid = -1;
  3369. resid = -1;
  3370. anbind = -1;
  3371. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  3372. GetRunMenuNewGameSceneLoadGame(csrriptname, cscenemap, csceneanim,
  3373. cscenelevels, &iLevelStart, &iNumOfLevels, &xTV, &yTV, &bTutorial, &xBack,
  3374. &yBack);
  3375. LoadSceneMap(iBmp, cscenemap, csceneanim, iActualScene, iClock);
  3376. ddxCleareSurface(CompositDC);
  3377. ddxCleareSurface(FontDC);
  3378. ddxCleareSurface(BackDC);
  3379. for (bind = 0; bind < RES_NUM; bind++) {
  3380. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  3381. res[bind].iAnim[lastcmd][0] = -1;
  3382. res[bind].iAnim[lastcmd][11] = -1;
  3383. }
  3384. for (in = 0; in < 6; in++)
  3385. res[bind].iParam[in] = -1;
  3386. res[bind].pCmdLine = res;
  3387. }
  3388. lastcmd = 0;
  3389. timercnt = 0;
  3390. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  3391. working_file_translate(dir, 256);
  3392. chdir((dir));
  3393. //natadhe skript menu
  3394. LoadMenuScript(csrriptname, res, &lastcmd);
  3395. DrawClock(iClock, 7);
  3396. in = 0;
  3397. ddxBitBlt(BackDC, 0, 0, 1024, 768, iBmp[0], 0, 0);
  3398. CreateLevelButtons(res, &lastcmd, iBmp, iActualScene, iLevelStart,
  3399. iNumOfLevels, cscenelevels, bTutorial);
  3400. DrawClock(iClock, 8);
  3401. if (!bTutorial) {
  3402. iTV = LoadTV();
  3403. if (iTV == -1)
  3404. kprintf(1, "Saaakra ... neporalo se nahrat bmpka televize");
  3405. }
  3406. DrawClock(iClock, 9);
  3407. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  3408. // animace na OnAbove
  3409. for (i = 0; i < lastcmd; i++) {
  3410. lastanm = 0;
  3411. switch (res[i].iParam[0]) {
  3412. case COM_DRAW:
  3413. if (!res[i].iLayer)
  3414. ddxDrawSurface(BackDC, res[i].iParam, 0);
  3415. else {
  3416. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  3417. ddxDrawSurface(FontDC, res[i].iParam, 3);
  3418. }
  3419. break;
  3420. case COM_RANDOMANIMATION:
  3421. case COM_ONCLICK:
  3422. case COM_ONABOVE:
  3423. case COM_RUNANIMATION:
  3424. case COM_BINDEXITANIMATION:
  3425. case COM_BINDANIMATION:
  3426. //nahrati animace k udalosti OnAbove
  3427. file = aopen(pDataArchive, res[i].cParam[0], "r");
  3428. if (file) {
  3429. while (!aeof(file)) {
  3430. Parse_AnimLine(file, res[i].iAnim[lastanm], 18);
  3431. if (!cc)
  3432. res[i].iAnim[lastanm][1] = iBmp[res[i].iAnim[lastanm][1]];
  3433. lastanm++;
  3434. }
  3435. if (!cc)
  3436. res[i].iLayer = 10;
  3437. else if (!bTutorial)
  3438. CorrectTV(res, i, lastanm, xTV, yTV, iTV, iActualScene);
  3439. aclose(file);
  3440. }
  3441. cc++;
  3442. break;
  3443. }
  3444. }
  3445. DrawClock(iClock, 10);
  3446. CreateBackButton(res, &lastcmd, iBmp[8], iBmp[9], xBack, yBack);
  3447. // MenuInitHint(bTutorial);
  3448. ddxResizeCursorBack(0);
  3449. ddxSetCursorSurface(0);
  3450. for (i = 0; i < 12; i++)
  3451. if (iClock[i] != -1) {
  3452. ddxReleaseBitmap(iClock[i]);
  3453. iClock[i] = -1;
  3454. }
  3455. ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
  3456. ddxCleareSurface(BackDC);
  3457. //BEGIN_MENU_NEWGAMESCENE:
  3458. for (i = 0; i < lastcmd; i++)
  3459. if (res[i].iParam[0] == COM_RUNANIMATION) {
  3460. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  3461. if (iWave != -1) {
  3462. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3463. anm[iWave].iWave = res[i + 1].iParam[5] =
  3464. mPlaySound(&res[i + 1], p_ad, 2);
  3465. }
  3466. }
  3467. dim.t1 = 0;
  3468. dim.t2 = 0;
  3469. dim.dx = 0;
  3470. dim.dy = 0;
  3471. anmid = -1;
  3472. resid = -1;
  3473. anbind = -1;
  3474. bind = -1;
  3475. lastabv = -1;
  3476. in = 0;
  3477. spracuj_spravy(0);
  3478. while (!key[K_ESC]) {
  3479. dwStart = timeGetTime();
  3480. //pohnul mysi
  3481. if (dim.dx || dim.dy) {
  3482. //dostala se mys do akcni oblasti (OnAbove)?
  3483. if (!click)
  3484. for (i = 0; i < lastcmd; i++)
  3485. if (res[i].iParam[0] == COM_ONABOVE) {
  3486. if ((dim.x >= res[i].iParam[1]) &&
  3487. (dim.x <= res[i].iParam[3]) &&
  3488. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  3489. //spusteni animace v OnAbove
  3490. if (i != lastabv) {
  3491. if (in) {
  3492. if (res[lastabv].iAnim[0][0] != -1) {
  3493. Stop(&res[lastabv]);
  3494. if (!res[lastabv].iLayer) {
  3495. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  3496. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  3497. }
  3498. else {
  3499. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  3500. TRANSCOLOR);
  3501. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  3502. }
  3503. }
  3504. // ReleaseHint(0, 1);
  3505. }
  3506. CheckAnimation(&res[i], p_ad);
  3507. lastabv = i;
  3508. AddAnimation(&res[i], p_ad, 0, 1);
  3509. in = 1;
  3510. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  3511. if (bind != -1) {
  3512. CheckAnimation(&res[bind], p_ad);
  3513. AddAnimation(&res[bind], p_ad, 1, 1);
  3514. anbind = bind;
  3515. mPlaySound(&res[bind], p_ad, 0);
  3516. }
  3517. strcpy(dir, res[i].cParam[1]);
  3518. /* if(bTutorial)
  3519. DrawHint(res[lastabv].iAnim[0][2], res[lastabv].iAnim[0][3] - 35);*/
  3520. }
  3521. }
  3522. else if (lastabv == i) {
  3523. // odesel z oblasti, ktera byla aktivni -> stop animace
  3524. // a odznaceni oblasti
  3525. Stop(&res[i]);
  3526. if (res[i].iAnim[0][0] != -1) {
  3527. if (!res[i].iLayer) {
  3528. ddxDrawDisplay(res[i].iAnim[0], 0);
  3529. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  3530. }
  3531. else {
  3532. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  3533. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  3534. }
  3535. }
  3536. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  3537. if (bind != -1) {
  3538. int iAnim;
  3539. if (anbind != -1) {
  3540. Stop(&res[anbind]);
  3541. if (!res[anbind].iLayer) {
  3542. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  3543. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  3544. }
  3545. else {
  3546. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  3547. TRANSCOLOR);
  3548. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  3549. }
  3550. }
  3551. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  3552. if (iAnim != -1)
  3553. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  3554. }
  3555. lastabv = -1;
  3556. anbind = -1;
  3557. in = 0;
  3558. strcpy(dir, "");
  3559. // ReleaseHint(0, 1);
  3560. }
  3561. //dim.dx = 0;
  3562. //dim.dy = 0;
  3563. }
  3564. }
  3565. //stlacil leve tlacitko
  3566. if (dim.t1 && !click) {
  3567. //dostala se mys do akcni oblasti (OnClick)?
  3568. for (i = 0; i < lastcmd; i++)
  3569. if (res[i].iParam[0] == COM_ONCLICK)
  3570. if ((dim.x >= res[i].iParam[1]) &&
  3571. (dim.x <= res[i].iParam[3]) &&
  3572. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  3573. if (res[i].iAnim[0][0] >= 0) {
  3574. //pokud je animace, tak ji spust
  3575. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  3576. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3577. mPlaySound(&res[i + 1], p_ad, 1);
  3578. resid = i;
  3579. click = 1;
  3580. }
  3581. else {
  3582. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3583. mPlaySound(&res[i + 1], p_ad, 1);
  3584. resid = i;
  3585. click = 1;
  3586. anmid = 31;
  3587. }
  3588. }
  3589. dim.t1 = 0;
  3590. }
  3591. //provedeni akce po animaci menu
  3592. if (click)
  3593. if (!anm[anmid].cmd) {
  3594. click = 0;
  3595. StopAll();
  3596. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  3597. !strcmp(res[resid].cParam[1], "CANCEL")) {
  3598. key[K_ESC] = 1;
  3599. cRestartMainMenu = 1;
  3600. //break;
  3601. }
  3602. else {
  3603. char cLevel[256];
  3604. iActualLevel = iLevelStart + atoi(res[resid].cParam[1]) - 1;
  3605. // ReleaseHint(1, 0);
  3606. kprintf(1, "Kliknuto na level : %s", res[resid].cParam[1]);
  3607. sprintf(cLevel, "level%d.lv6", iActualLevel);
  3608. if (RunLevel(NULL, p_ad, cpu, cLevel, "RUN_LEVEL") == 1) {
  3609. pPlayerProfile.cLevel[iActualLevel] = 1;
  3610. pr_SaveProfile(&pPlayerProfile);
  3611. }
  3612. for (i = 0; i < 32; i++)
  3613. anm[i].cmd = NULL;
  3614. bReload = 0;
  3615. if (bNewScene)
  3616. key[K_ESC] = 1;
  3617. else
  3618. goto BRUTAL_RESTART_SCENE_MAP_MENU;
  3619. }
  3620. resid = -1;
  3621. if (key[K_ESC]) {
  3622. /*
  3623. for(i=0;i<lastcmd;i++)
  3624. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  3625. {
  3626. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  3627. res[i].iParam[5] = -1;
  3628. }
  3629. */
  3630. goto __QUIT;
  3631. }
  3632. }
  3633. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  3634. if (timercnt > 500) {
  3635. timercnt = 0;
  3636. for (i = 0; i < lastcmd; i++)
  3637. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  3638. if (rand() % 200 <= res[i].iParam[1] &&
  3639. strcmp(dir, res[i].cParam[0])) {
  3640. CheckAnimation(&res[i], p_ad);
  3641. AddAnimation(&res[i], p_ad, 0, 0);
  3642. }
  3643. }
  3644. dwStop = timeGetTime();
  3645. dwEplased += dwStop - dwStart;
  3646. spracuj_spravy(0);
  3647. ddxUpdateMouse();
  3648. AnimationEvent(dwStop, p_ad);
  3649. if (dim.tf1) {
  3650. dim.t1 = 1;
  3651. dim.tf1 = 0;
  3652. }
  3653. if (dim.tf2) {
  3654. dim.t2 = 1;
  3655. dim.tf2 = 0;
  3656. }
  3657. if (ddxRestore(p_ad)) {
  3658. StopAll();
  3659. FreeAnimations(res, RES_NUM);
  3660. goto BRUTAL_RESTART_SCENE_MAP_MENU;
  3661. }
  3662. }
  3663. __QUIT:
  3664. /*
  3665. adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
  3666. adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
  3667. */
  3668. StopAll();
  3669. if (bReload) {
  3670. for (i = 0; i < 12; i++)
  3671. ddxReleaseBitmap(iBmp[i]);
  3672. if (!bTutorial)
  3673. for (i = iTV; i < iTV + 91; i++)
  3674. ddxReleaseBitmap(i);
  3675. }
  3676. ddxCleareSurface(FontDC);
  3677. ddxCleareSurface(BackDC);
  3678. ddxCleareSurface(CompositDC);
  3679. cRestartMainMenu = 1;
  3680. key[K_ESC] = 0;
  3681. FreeAnimations(res, RES_NUM);
  3682. free((void *) res);
  3683. }
  3684. int RunMenuNewGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
  3685. {
  3686. DWORD dwEplased = 0, dwStart, dwStop;
  3687. int ret = 0;
  3688. int c = 0;
  3689. CONTROL_LIST_ITEM citem[CLIST_ITEMC];
  3690. // FILE *file;
  3691. char dir[256];
  3692. int lastcmd, lastanm, i;
  3693. CMD_LINE *res = NULL;
  3694. int lastabv = -1;
  3695. char in, click = 0;
  3696. int anmid = -1, resid = -1, anbind = -1;
  3697. int bind;
  3698. char bDone = 0;
  3699. int inumofitems = 0;
  3700. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  3701. if (!res) {
  3702. kprintf(1, "RunMenuNewGame: Out of Memory");
  3703. return 0;
  3704. }
  3705. else
  3706. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  3707. bBackDC = 0;
  3708. ddxCleareSurface(BackDC);
  3709. ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0, 0);
  3710. ddxCleareSurface(FontDC);
  3711. //kprintf(1, "bitblt");
  3712. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
  3713. for (bind = 0; bind < RES_NUM; bind++) {
  3714. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  3715. res[bind].iAnim[lastcmd][0] = -1;
  3716. res[bind].iAnim[lastcmd][11] = -1;
  3717. }
  3718. for (in = 0; in < 6; in++)
  3719. res[bind].iParam[in] = -1;
  3720. res[bind].iLayer = 0;
  3721. }
  3722. lastcmd = 0;
  3723. timercnt = 0;
  3724. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  3725. working_file_translate(dir, 256);
  3726. chdir((dir));
  3727. //natadhe skript menu
  3728. LoadMenuScript(p_File_Name, res, &lastcmd);
  3729. in = 0;
  3730. fn_Set_Font(cFontFile[0]);
  3731. fn_Load_Bitmaps();
  3732. CreateFontAnimations(res, &lastcmd);
  3733. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  3734. // animace na OnAbove
  3735. for (i = 0; i < lastcmd; i++) {
  3736. lastanm = 0;
  3737. switch (res[i].iParam[0]) {
  3738. case COM_DRAW:
  3739. {
  3740. if (!c) {
  3741. RECT rr;
  3742. ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
  3743. ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
  3744. res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
  3745. ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
  3746. rr.left = res[i].iParam[2];
  3747. rr.top = res[i].iParam[3];
  3748. rr.right = ddxGetWidth(res[i].iParam[1]);
  3749. rr.bottom = ddxGetHight(res[i].iParam[1]);
  3750. _2d_Add_RectItem(&rline, rr, 0);
  3751. }
  3752. else
  3753. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  3754. c++;
  3755. }
  3756. break;
  3757. case COM_RANDOMANIMATION:
  3758. case COM_ONCLICK:
  3759. case COM_ONABOVE:
  3760. case COM_RUNANIMATION:
  3761. case COM_BINDEXITANIMATION:
  3762. case COM_BINDANIMATION:
  3763. //nahrati animace k udalosti OnAbove
  3764. LoadAnimationMenuScript(res, i, &lastanm);
  3765. break;
  3766. }
  3767. }
  3768. if (co_Load_Graphic(1)) {
  3769. int xx, sel = -1;
  3770. RECT r;
  3771. r.left = 299;
  3772. r.top = 209;
  3773. r.right = 743;
  3774. r.bottom = 359;
  3775. co_Set_Text_Center(BackDC, "##mainmenu_player_name", 0, r);
  3776. r.top = 359;
  3777. r.bottom = 509;
  3778. co_Set_Text_Center(BackDC, "##mainmenu_new_player_name", 0, r);
  3779. fn_Release_Font(1);
  3780. fn_Set_Font(cFontFile[2]);
  3781. fn_Load_Bitmaps();
  3782. citem[0].p_edit = co_Create_Edit(BackDC, 360, 470, 0);
  3783. citem[0].bActive = 1;
  3784. citem[1].p_combo = co_Create_Combo(BackDC, 360, 320, 100, 0);
  3785. citem[1].bActive = 1;
  3786. xx = FillComboProfiles(citem[1].p_combo, &sel);
  3787. if (xx > 5)
  3788. co_Combo_Set_Params(citem[1].p_combo, 5);
  3789. else
  3790. co_Combo_Set_Params(citem[1].p_combo, xx);
  3791. kprintf(1, "set_sel %d", sel);
  3792. co_Combo_Set_Sel(BackDC, citem[1].p_combo, sel);
  3793. inumofitems = xx;
  3794. if (!inumofitems)
  3795. citem[0].p_edit->bActive = 1;
  3796. }
  3797. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  3798. TRANSCOLOR);
  3799. bBackDC = 1;
  3800. BEGIN_MENU_NEWGAME:
  3801. for (i = 0; i < lastcmd; i++)
  3802. if (res[i].iParam[0] == COM_RUNANIMATION) {
  3803. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  3804. if (iWave != -1) {
  3805. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3806. anm[iWave].iWave = res[i + 1].iParam[5] =
  3807. mPlaySound(&res[i + 1], p_ad, 2);
  3808. }
  3809. }
  3810. dim.t1 = 0;
  3811. dim.t2 = 0;
  3812. dim.dx = 0;
  3813. dim.dy = 0;
  3814. anmid = -1;
  3815. resid = -1;
  3816. anbind = -1;
  3817. bind = -1;
  3818. lastabv = -1;
  3819. in = 0;
  3820. spracuj_spravy(0);
  3821. while (!bDone) {
  3822. dwStart = timeGetTime();
  3823. //pohnul mysi
  3824. if (dim.dx || dim.dy) {
  3825. //dostala se mys do akcni oblasti (OnAbove)?
  3826. if (!click) {
  3827. for (i = 0; i < lastcmd; i++) {
  3828. if (res[i].iParam[0] == COM_ONABOVE) {
  3829. if ((dim.x >= res[i].iParam[1]) &&
  3830. (dim.x <= res[i].iParam[3]) &&
  3831. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  3832. //spusteni animace v OnAbove
  3833. if (i != lastabv) {
  3834. if (in) {
  3835. Stop(&res[lastabv]);
  3836. if (!res[lastabv].iLayer) {
  3837. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  3838. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  3839. }
  3840. else {
  3841. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  3842. TRANSCOLOR);
  3843. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  3844. }
  3845. }
  3846. CheckAnimation(&res[i], p_ad);
  3847. lastabv = i;
  3848. AddAnimation(&res[i], p_ad, 0, 1);
  3849. in = 1;
  3850. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  3851. if (bind != -1) {
  3852. CheckAnimation(&res[bind], p_ad);
  3853. AddAnimation(&res[bind], p_ad, 1, 1);
  3854. anbind = bind;
  3855. mPlaySound(&res[bind], p_ad, 0);
  3856. }
  3857. strcpy(dir, res[i].cParam[1]);
  3858. }
  3859. }
  3860. else if (lastabv == i) {
  3861. // odesel z oblasti, ktera byla aktivni -> stop animace
  3862. // a odznaceni oblasti
  3863. Stop(&res[i]);
  3864. if (!res[i].iLayer) {
  3865. ddxDrawDisplay(res[i].iAnim[0], 0);
  3866. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  3867. }
  3868. else {
  3869. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  3870. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  3871. }
  3872. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  3873. if (bind != -1) {
  3874. int iAnim;
  3875. if (anbind != -1) {
  3876. Stop(&res[anbind]);
  3877. if (!res[i].iLayer) {
  3878. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  3879. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  3880. }
  3881. else {
  3882. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  3883. TRANSCOLOR);
  3884. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  3885. }
  3886. }
  3887. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  3888. if (iAnim != -1)
  3889. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  3890. }
  3891. lastabv = -1;
  3892. anbind = -1;
  3893. in = 0;
  3894. strcpy(dir, "");
  3895. }
  3896. }
  3897. }
  3898. }
  3899. dim.dx = 0;
  3900. dim.dy = 0;
  3901. }
  3902. co_Handle_Controls(citem, CLIST_ITEMC, dim.x, dim.y, BackDC, 0, 0);
  3903. //stlacil leve tlacitko
  3904. if (dim.t1 && !click) {
  3905. //dostala se mys do akcni oblasti (OnClick)?
  3906. for (i = 0; i < lastcmd; i++) {
  3907. if (res[i].iParam[0] == COM_ONCLICK) {
  3908. if ((dim.x >= res[i].iParam[1]) &&
  3909. (dim.x <= res[i].iParam[3]) &&
  3910. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  3911. if (res[i].iAnim[0][0] >= 0) {
  3912. //pokud je animace, tak ji spust
  3913. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  3914. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3915. mPlaySound(&res[i + 1], p_ad, 1);
  3916. resid = i;
  3917. click = 1;
  3918. }
  3919. else {
  3920. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3921. mPlaySound(&res[i + 1], p_ad, 1);
  3922. resid = i;
  3923. click = 1;
  3924. anmid = 31;
  3925. }
  3926. }
  3927. }
  3928. }
  3929. dim.t1 = 0;
  3930. }
  3931. //provedeni akce po animaci menu
  3932. if (click || key[K_ENTER])
  3933. if (!anm[anmid].cmd || key[K_ENTER]) {
  3934. click = 0;
  3935. if (key[K_ENTER])
  3936. goto MENU_ENTER;
  3937. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  3938. !strcmp(res[resid].cParam[1], "CANCEL")) {
  3939. bDone = 1;
  3940. }
  3941. if (!strcmp(res[resid].cParam[1], "OK")) {
  3942. int c;
  3943. WCHAR *pName;
  3944. MENU_ENTER:
  3945. c = 0;
  3946. pName = co_Edit_Get_Text(citem[0].p_edit);
  3947. key[K_ENTER] = 0;
  3948. if (!wcslen(pName)) {
  3949. int iComboActSel = co_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 0);
  3950. kprintf(1, "%d", iComboActSel);
  3951. if (iComboActSel != -1) {
  3952. if (citem[1].p_combo->pItem) {
  3953. if (citem[1].p_combo->pItem[iComboActSel].text) {
  3954. if (pr_ReadProfile(citem[1].p_combo->pItem[iComboActSel].text, &pPlayerProfile)) {
  3955. WritePrivateProfileString("hra", "last_profile",citem[1].p_combo->pItem[iComboActSel].text, ini_file);
  3956. c++;
  3957. }
  3958. }
  3959. }
  3960. }
  3961. }
  3962. else if (pr_CreateProfile(pName))
  3963. c++;
  3964. if (c) {
  3965. iActualScene = 1;
  3966. bDone = 1;
  3967. }
  3968. }
  3969. resid = -1;
  3970. if (bDone) {
  3971. /*
  3972. for(i=0;i<lastcmd;i++)
  3973. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  3974. {
  3975. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  3976. res[i].iParam[5] = -1;
  3977. }
  3978. */
  3979. goto __QUIT;
  3980. }
  3981. else
  3982. goto BEGIN_MENU_NEWGAME;
  3983. }
  3984. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  3985. if (timercnt > 500) {
  3986. timercnt = 0;
  3987. for (i = 0; i < lastcmd; i++)
  3988. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  3989. if (rand() % 200 <= res[i].iParam[1] &&
  3990. strcmp(dir, res[i].cParam[0])) {
  3991. CheckAnimation(&res[i], p_ad);
  3992. AddAnimation(&res[i], p_ad, 0, 0);
  3993. }
  3994. }
  3995. dwStop = timeGetTime();
  3996. dwEplased += dwStop - dwStart;
  3997. spracuj_spravy(0);
  3998. ddxUpdateMouse();
  3999. AnimationEvent(dwStop, p_ad);
  4000. if (dim.tf1) {
  4001. dim.t1 = 1;
  4002. dim.tf1 = 0;
  4003. }
  4004. if (dim.tf2) {
  4005. dim.t2 = 1;
  4006. dim.tf2 = 0;
  4007. }
  4008. if (ddxRestore(p_ad)) {
  4009. fn_Release_Font(0);
  4010. free((void *) res);
  4011. return 1;
  4012. }
  4013. }
  4014. __QUIT:
  4015. ddxCleareSurface(FontDC);
  4016. ddxCleareSurface(CompositDC);
  4017. bBackDC = 0;
  4018. ddxCleareSurface(BackDC);
  4019. fn_Release_Font(1);
  4020. co_Handle_Release(citem, CLIST_ITEMC);
  4021. co_Release_Graphic();
  4022. key[K_ESC] = 0;
  4023. FreeAnimations(res, RES_NUM);
  4024. free((void *) res);
  4025. return ret;
  4026. }
  4027. char check_profile(char *p_name)
  4028. {
  4029. WCHAR wc[128];
  4030. MultiByteToWideChar(CP_ACP, 0, p_name, strlen(p_name) + 1, wc,
  4031. sizeof(wc) / sizeof(wc[0]));
  4032. if (!wcscmp(pPlayerProfile.cName, wc))
  4033. return 1;
  4034. else
  4035. return 0;
  4036. }
  4037. int compare(const void *arg1, const void *arg2)
  4038. {
  4039. LIST_ITEM_ *pP1 = (LIST_ITEM_ *) arg1;
  4040. LIST_ITEM_ *pP2 = (LIST_ITEM_ *) arg2;
  4041. return pP2->timespamp - pP1->timespamp;
  4042. }
  4043. #ifdef LINUX
  4044. static char *p_file_mask;
  4045. static int filter(const struct dirent *file)
  4046. {
  4047. return(!fnmatch(p_file_mask, file->d_name, 0));
  4048. }
  4049. int FillStringList(char *cmask, LIST_ITEM_ ** list, int *isize)
  4050. {
  4051. struct dirent **namelist;
  4052. int i;
  4053. struct stat sb;
  4054. p_file_mask = cmask;
  4055. int c = scandir(".", &namelist, &filter, alphasort);
  4056. if (c < 0) {
  4057. (*isize) = 0;
  4058. return 0;
  4059. }
  4060. (*list) = (LIST_ITEM_ *) malloc(c * sizeof(LIST_ITEM_));
  4061. memset((*list), 0, c * sizeof(LIST_ITEM_));
  4062. for(i = 0; i < c; i++) {
  4063. strcpy((*list)[i].text, namelist[i]->d_name);
  4064. (*list)[c].timespamp = !stat(namelist[i]->d_name, &sb) ? sb.st_mtime : 0;
  4065. free(namelist[i]);
  4066. }
  4067. free(namelist);
  4068. qsort((*list), c, sizeof(LIST_ITEM_), compare);
  4069. (*isize) = c;
  4070. return c;
  4071. }
  4072. #endif
  4073. int FillComboProfiles(COMBO_CONTROL * p_co, int *iSel)
  4074. {
  4075. int retsel = 0;
  4076. char cprofile[128];
  4077. char dir[256];
  4078. WCHAR wName[256];
  4079. PLAYER_PROFILE Profile;
  4080. int c = 0;
  4081. int x = 0;
  4082. LIST_ITEM_ *list;
  4083. int isize;
  4084. GetPrivateProfileString("game", "profile_dir", "c:\\", dir, 256, ini_file);
  4085. working_file_translate(dir, 256);
  4086. GetPrivateProfileString("hra", "last_profile", "c:\\", cprofile, 128,
  4087. ini_file);
  4088. chdir((dir));
  4089. FillStringList("*.prf", &list, &isize);
  4090. if (!isize)
  4091. return 0;
  4092. for (c = 0; c < isize; c++) {
  4093. ZeroMemory(wName, 256 * sizeof(WCHAR));
  4094. if (pr_GetPlayerName(list[c].text, wName)) {
  4095. co_Combo_Add_StringWC2(p_co, wName, list[c].text);
  4096. if ((*iSel) == -1) //new game -> nastavit profil, kterej byl hran naposed
  4097. {
  4098. if (!strcmp(cprofile, list[c].text)) {
  4099. retsel = x;
  4100. pr_ReadProfile(list[c].text, &Profile);
  4101. }
  4102. }
  4103. if (!x)
  4104. pr_ReadProfile(list[c].text, &Profile);
  4105. x++;
  4106. }
  4107. }
  4108. memcpy(&pPlayerProfile, &Profile, sizeof(PLAYER_PROFILE));
  4109. *iSel = retsel;
  4110. if ((*iSel) < 0)
  4111. (*iSel) = 0;
  4112. free((void *) list);
  4113. return x;
  4114. }
  4115. int check_Save_Owner(char *cDir, WCHAR * wFileName)
  4116. {
  4117. char text[256];
  4118. FILE *file;
  4119. PLAYER_PROFILE pProfile;
  4120. LEVEL_HEADER l_h;
  4121. char dir[MAX_PATH + 1];
  4122. WCHAR wdir[MAX_PATH + 1];
  4123. int ver;
  4124. getcwd(dir, MAX_PATH);
  4125. chdir((cDir));
  4126. ZeroMemory(&pProfile, sizeof(PLAYER_PROFILE));
  4127. strcpy(text, cDir);
  4128. strcat(text, ".lvc");
  4129. file = fopen(text, "rb");
  4130. if (!file) {
  4131. chdir((dir));
  4132. return 0;
  4133. }
  4134. fread(&pProfile, sizeof(PLAYER_PROFILE), 1, file);
  4135. fread(wFileName, 32 * sizeof(WCHAR), 1, file);
  4136. fread(&ver, sizeof(int), 1, file);
  4137. if (ver != SAVE_VER) {
  4138. fclose(file);
  4139. return 0;
  4140. }
  4141. fread(wdir, (MAX_PATH + 1) * sizeof(WCHAR), 1, file);
  4142. fread(&l_h, sizeof(LEVEL_HEADER), 1, file);
  4143. fclose(file);
  4144. chdir((dir));
  4145. if (wcscmp(pPlayerProfile.cName, pProfile.cName))
  4146. return 0;
  4147. if (iLanguageVersion == 4) {
  4148. sprintf(dir, "scene%d", l_h.rezerved[1]);
  4149. if (!GetPrivateProfileInt("Internet", dir, 0, ini_file))
  4150. return 0;
  4151. }
  4152. return 1;
  4153. }
  4154. int FillListLoad(LIST_VIEW_CONTROL * p_li, char *mask, char bAdd,
  4155. int LoadGame)
  4156. {
  4157. char dir[256];
  4158. WCHAR wFile[128];
  4159. int x = 0;
  4160. int c = 0;
  4161. LIST_ITEM_ *list;
  4162. int isize;
  4163. GetPrivateProfileString("game", "save_dir", "c:\\", dir, 256, ini_file);
  4164. working_file_translate(dir, 256);
  4165. chdir((dir));
  4166. FillStringList(mask, &list, &isize);
  4167. if (!isize)
  4168. return 0;
  4169. for (c = 0; c < isize; c++) {
  4170. ZeroMemory(wFile, 128 * sizeof(WCHAR));
  4171. if (!LoadGame) {
  4172. if (!demo_Check_Owner(pPlayerProfile.cName, list[c].text, wFile))
  4173. continue;
  4174. }
  4175. else if (!check_Save_Owner(list[c].text, wFile))
  4176. continue;
  4177. if (bAdd)
  4178. co_List_Add_StringWC2(p_li, x, 2, wFile, list[c].text, x, 0);
  4179. x++;
  4180. }
  4181. free((void *) list);
  4182. return x;
  4183. }
  4184. void CreateLevelCommandLine(char *cLevel, char *cLine)
  4185. {
  4186. sprintf(cLine, "%s.lv6 fp:%s", cLevel, cLevel);
  4187. }
  4188. void RunMenuLoadGameLoad(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
  4189. int cpu, int LoadGame)
  4190. {
  4191. DWORD dwEplased = 0, dwStart, dwStop;
  4192. int c = 0;
  4193. int idx;
  4194. int hdcBT;
  4195. RECT r;
  4196. LIST_VIEW_CONTROL *p_li;
  4197. PLAYER_PROFILE pOldProfile;
  4198. CONTROL_LIST_ITEM citem[CLIST_ITEMC];
  4199. // FILE *file;
  4200. char dir[256];
  4201. int lastcmd, lastanm, i;
  4202. //CMD_LINE res[RES_NUM];
  4203. CMD_LINE *res = NULL;
  4204. int lastabv = -1;
  4205. char in, click = 0;
  4206. int anmid = -1, resid = -1, anbind = -1;
  4207. int bind;
  4208. // int iComboSel = 0;
  4209. // int iComboActSel = 0;
  4210. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  4211. if (!res) {
  4212. kprintf(1, "RunMenuLoadGameLoad: Out of Memory");
  4213. return;
  4214. }
  4215. else
  4216. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  4217. ddxCleareSurface(FontDC);
  4218. // ddxCleareSurface(BackDC);
  4219. bBackDC = 0;
  4220. memcpy(&pOldProfile, &pPlayerProfile, sizeof(PLAYER_PROFILE));
  4221. //kprintf(1, "bitblt");
  4222. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
  4223. for (bind = 0; bind < RES_NUM; bind++) {
  4224. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  4225. res[bind].iAnim[lastcmd][0] = -1;
  4226. res[bind].iAnim[lastcmd][11] = -1;
  4227. }
  4228. for (in = 0; in < 6; in++)
  4229. res[bind].iParam[in] = -1;
  4230. res[bind].iLayer = 0;
  4231. }
  4232. lastcmd = 0;
  4233. timercnt = 0;
  4234. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  4235. working_file_translate(dir, 256);
  4236. chdir((dir));
  4237. //natadhe skript menu
  4238. LoadMenuScript(p_File_Name, res, &lastcmd);
  4239. //kprintf(1, "load");
  4240. in = 0;
  4241. fn_Set_Font(cFontFile[0]);
  4242. fn_Load_Bitmaps();
  4243. //kprintf(1, "fn_Set_Font");
  4244. CreateFontAnimations(res, &lastcmd);
  4245. //fn_Release_Font();
  4246. //kprintf(1, "CreateFontAnimations");
  4247. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  4248. // animace na OnAbove
  4249. for (i = 0; i < lastcmd; i++) {
  4250. lastanm = 0;
  4251. switch (res[i].iParam[0]) {
  4252. case COM_DRAW:
  4253. {
  4254. if (!c) {
  4255. /* hdcBT = fn_CreateDC(_2dd.hDC, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  4256. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight, _2d_Find_Free_Surface());*/
  4257. hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
  4258. ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
  4259. /*BitBlt(BackDC,res[i].iParam[2], res[i].iParam[3], _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  4260. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
  4261. _2dd.bitmap[res[i].iParam[1]].bitmapDC, 0, 0, SRCCOPY); */
  4262. ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
  4263. ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
  4264. res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
  4265. ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
  4266. /*BitBlt(hdcBT, 0, 0, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  4267. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
  4268. _2dd.hDC, res[i].iParam[2], res[i].iParam[3], SRCCOPY); */
  4269. ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
  4270. ddxGetHight(res[i].iParam[1]),
  4271. HDC2DD, res[i].iParam[2], res[i].iParam[3]);
  4272. //menucommand_DrawT(_2dd.hDC, res[i].iParam);
  4273. idx = i;
  4274. }
  4275. else {
  4276. //menucommand_DrawT(BackDC, res[i].iParam);
  4277. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  4278. }
  4279. //menucommand_DrawT(_2dd.hDC, res[i].iParam);
  4280. c++;
  4281. }
  4282. break;
  4283. case COM_RANDOMANIMATION:
  4284. case COM_ONCLICK:
  4285. case COM_ONABOVE:
  4286. case COM_RUNANIMATION:
  4287. case COM_BINDEXITANIMATION:
  4288. case COM_BINDANIMATION:
  4289. //nahrati animace k udalosti OnAbove
  4290. LoadAnimationMenuScript(res, i, &lastanm);
  4291. break;
  4292. }
  4293. }
  4294. //co_Load_Graphic(1);
  4295. //co_List_Redraw(Ltmp1DC, llcitem[1].p_list, 0);
  4296. if (!co_Load_Graphic(1))
  4297. assert(0);
  4298. else {
  4299. int xx, sel = 0;
  4300. r.left = 299;
  4301. r.top = 209;
  4302. r.right = 743;
  4303. r.bottom = 359;
  4304. if (LoadGame)
  4305. co_Set_Text_Center(BackDC, "##menu_loadgame", 0, r);
  4306. else
  4307. co_Set_Text_Center(BackDC, "##menu_playdemo", 0, r);
  4308. fn_Release_Font(1);
  4309. fn_Set_Font(cFontFile[2]);
  4310. fn_Load_Bitmaps();
  4311. /* citem[0].p_combo = co_Create_Combo(BackDC, 360, 320, 100, 0);
  4312. citem[0].bActive = 1;
  4313. xx = FillComboProfiles(citem[0].p_combo, &sel);
  4314. if(xx > 5)
  4315. co_Combo_Set_Params(citem[0].p_combo, 5);
  4316. else
  4317. co_Combo_Set_Params(citem[0].p_combo, xx);
  4318. co_Combo_Set_Sel(BackDC, citem[0].p_combo, sel);*/
  4319. if (LoadGame) {
  4320. xx = FillListLoad(NULL, "*", 0, LoadGame);
  4321. if (xx < 7)
  4322. xx = 7;
  4323. citem[1].p_list = co_Create_List(BackDC, 360, 320, 320, 200, 0, xx, 1);
  4324. citem[1].bActive = 1;
  4325. FillListLoad(citem[1].p_list, "*", 1, LoadGame);
  4326. }
  4327. else {
  4328. xx = FillListLoad(NULL, "*.dem", 0, LoadGame);
  4329. if (xx < 7)
  4330. xx = 7;
  4331. citem[1].p_list = co_Create_List(BackDC, 360, 320, 320, 200, 0, xx, 1);
  4332. citem[1].bActive = 1;
  4333. FillListLoad(citem[1].p_list, "*.dem", 1, LoadGame);
  4334. }
  4335. co_List_Redraw(BackDC, citem[1].p_list, 0);
  4336. fn_Release_Font(1);
  4337. }
  4338. //BEGIN_MENU:
  4339. bBackDC = 1;
  4340. //TransparentBltU(BackDC, 0, 0, 1024, 768, Ltmp1DC, 0, 0, 1024, 768, RGB(255, 0, 255));
  4341. // ddxTransparentBlt(BackDC, 0, 0, 1024, 768, Ltmp1DC, 0, 0, 1024, 768, TRANSCOLOR);
  4342. //Sleep(10000);
  4343. //TransparentBltU(_2dd.hDC, 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, RGB(255, 0, 255));
  4344. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  4345. TRANSCOLOR);
  4346. for (i = 0; i < lastcmd; i++)
  4347. if (res[i].iParam[0] == COM_RUNANIMATION) {
  4348. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  4349. if (iWave != -1) {
  4350. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  4351. anm[iWave].iWave = res[i + 1].iParam[5] =
  4352. mPlaySound(&res[i + 1], p_ad, 2);
  4353. }
  4354. }
  4355. dim.t1 = 0;
  4356. dim.t2 = 0;
  4357. dim.dx = 0;
  4358. dim.dy = 0;
  4359. anmid = -1;
  4360. resid = -1;
  4361. anbind = -1;
  4362. bind = -1;
  4363. lastabv = -1;
  4364. in = 0;
  4365. spracuj_spravy(0);
  4366. while (!key[K_ESC]) {
  4367. dwStart = timeGetTime();
  4368. //pohnul mysi
  4369. if (dim.dx || dim.dy) {
  4370. //dostala se mys do akcni oblasti (OnAbove)?
  4371. if (!click)
  4372. for (i = 0; i < lastcmd; i++)
  4373. if (res[i].iParam[0] == COM_ONABOVE) {
  4374. if ((dim.x >= res[i].iParam[1]) &&
  4375. (dim.x <= res[i].iParam[3]) &&
  4376. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  4377. //spusteni animace v OnAbove
  4378. if (i != lastabv) {
  4379. if (in) {
  4380. Stop(&res[lastabv]);
  4381. if (!res[lastabv].iLayer) {
  4382. //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
  4383. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  4384. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  4385. }
  4386. else {
  4387. //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
  4388. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  4389. TRANSCOLOR);
  4390. //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
  4391. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  4392. }
  4393. }
  4394. CheckAnimation(&res[i], p_ad);
  4395. lastabv = i;
  4396. AddAnimation(&res[i], p_ad, 0, 1);
  4397. in = 1;
  4398. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  4399. if (bind != -1) {
  4400. CheckAnimation(&res[bind], p_ad);
  4401. AddAnimation(&res[bind], p_ad, 1, 1);
  4402. anbind = bind;
  4403. mPlaySound(&res[bind], p_ad, 0);
  4404. }
  4405. strcpy(dir, res[i].cParam[1]);
  4406. }
  4407. }
  4408. else if (lastabv == i) {
  4409. // odesel z oblasti, ktera byla aktivni -> stop animace
  4410. // a odznaceni oblasti
  4411. Stop(&res[i]);
  4412. if (!res[i].iLayer) {
  4413. //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
  4414. ddxDrawDisplay(res[i].iAnim[0], 0);
  4415. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  4416. }
  4417. else {
  4418. //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
  4419. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  4420. //menucommand_DrawT(FontDC, res[i].iAnim[0]);
  4421. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  4422. }
  4423. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  4424. if (bind != -1) {
  4425. int iAnim;
  4426. if (anbind != -1) {
  4427. Stop(&res[anbind]);
  4428. if (!res[i].iLayer) {
  4429. //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
  4430. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  4431. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  4432. }
  4433. else {
  4434. //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
  4435. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  4436. TRANSCOLOR);
  4437. //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
  4438. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  4439. }
  4440. }
  4441. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  4442. if (iAnim != -1)
  4443. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  4444. }
  4445. lastabv = -1;
  4446. anbind = -1;
  4447. in = 0;
  4448. strcpy(dir, "");
  4449. }
  4450. }
  4451. dim.dx = 0;
  4452. dim.dy = 0;
  4453. }
  4454. co_Handle_Controls(citem, CLIST_ITEMC, dim.x, dim.y, BackDC, 0, 0);
  4455. //////////////LOAD LEVEL/DEMO ///////////////////////////////////////////////////
  4456. if (co_List_Get_Dbclck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
  4457. if (p_li->piValue[p_li->cSelected].cValue)
  4458. if (strlen(p_li->piValue[p_li->cSelected].cValue)) {
  4459. //citem[0].bActive = 0;
  4460. citem[1].bActive = 0;
  4461. if (LoadGame) //LOAD GAME
  4462. {
  4463. //fn_Release_Font(1);
  4464. StopAll();
  4465. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 1,
  4466. p_li->piValue[p_li->cSelected].cValue, 0);
  4467. fn_Set_Font("font_system.pak");
  4468. fn_Load_Bitmaps();
  4469. key[K_ESC] = 1;
  4470. }
  4471. else //LOAD DEMO
  4472. {
  4473. char ctext[256];
  4474. CreateLevelCommandLine(p_li->piValue[p_li->cSelected].cValue,
  4475. ctext);
  4476. demo_Set_Scene_Level(p_li->piValue[p_li->cSelected].cValue,
  4477. &iActualScene, &iActualLevel);
  4478. RunLevel(NULL, p_ad, cpu, ctext, "LOAD_DEMO");
  4479. for (i = 0; i < 32; i++)
  4480. anm[i].cmd = NULL;
  4481. key[K_ESC] = 1;
  4482. }
  4483. p_li->bDblClck = 0;
  4484. p_li->bClck = 0;
  4485. }
  4486. }
  4487. /* iComboActSel = co_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 0);
  4488. if(iComboActSel != iComboSel && iComboActSel != -1)
  4489. {
  4490. int xx;
  4491. pr_ReadProfile(citem[0].p_combo->pItem[iComboActSel].text, &pPlayerProfile);
  4492. if(LoadGame)
  4493. {
  4494. xx = FillListLoad(NULL, "*", 0, LoadGame);
  4495. if(xx < 4)
  4496. xx = 4;
  4497. co_Cleare_List(citem[1].p_list, xx, BackDC, 0, 0);
  4498. FillListLoad(citem[1].p_list, "*", 1, LoadGame);
  4499. }
  4500. else
  4501. {
  4502. xx = FillListLoad(NULL, "*.dem", 0, LoadGame);
  4503. if(xx < 4)
  4504. xx = 4;
  4505. co_Cleare_List(citem[1].p_list, xx, BackDC, 0, 0);
  4506. FillListLoad(citem[1].p_list, "*.dem", 1, LoadGame);
  4507. }
  4508. co_List_Redraw(BackDC, citem[1].p_list, 0);
  4509. iComboSel = iComboActSel;
  4510. }
  4511. */
  4512. //stlacil leve tlacitko
  4513. if (dim.t1 && !click) {
  4514. //dostala se mys do akcni oblasti (OnClick)?
  4515. for (i = 0; i < lastcmd; i++)
  4516. if (res[i].iParam[0] == COM_ONCLICK)
  4517. if ((dim.x >= res[i].iParam[1]) &&
  4518. (dim.x <= res[i].iParam[3]) &&
  4519. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  4520. if (res[i].iAnim[0][0] >= 0) {
  4521. //pokud je animace, tak ji spust
  4522. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  4523. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  4524. mPlaySound(&res[i + 1], p_ad, 1);
  4525. resid = i;
  4526. click = 1;
  4527. }
  4528. else {
  4529. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  4530. mPlaySound(&res[i + 1], p_ad, 1);
  4531. resid = i;
  4532. click = 1;
  4533. anmid = 31;
  4534. }
  4535. }
  4536. dim.t1 = 0;
  4537. }
  4538. //provedeni akce po animaci menu
  4539. if (click)
  4540. if (!anm[anmid].cmd) {
  4541. click = 0;
  4542. //StopAll();
  4543. if (!strcmp(res[resid].cParam[1], "CANCEL")) {
  4544. memcpy(&pPlayerProfile, &pOldProfile, sizeof(PLAYER_PROFILE));
  4545. key[K_ESC] = 1;
  4546. }
  4547. if (!strcmp(res[resid].cParam[1], "EXIT"))
  4548. key[K_ESC] = 1;
  4549. if (!strcmp(res[resid].cParam[1], "OK") && p_li->cClckSel != -1) {
  4550. if (p_li->piValue[p_li->cClckSel].cValue)
  4551. if (strlen(p_li->piValue[p_li->cClckSel].cValue)) {
  4552. citem[0].bActive = 0;
  4553. citem[1].bActive = 0;
  4554. if (LoadGame) //LOAD GAME
  4555. {
  4556. //fn_Release_Font(1);
  4557. StopAll();
  4558. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu,
  4559. 1, p_li->piValue[p_li->cClckSel].cValue, 0);
  4560. //fn_Set_Font("font_system.pak");
  4561. //fn_Load_Bitmaps();
  4562. key[K_ESC] = 1;
  4563. }
  4564. else //LOAD DEMO
  4565. {
  4566. char ctext[256];
  4567. CreateLevelCommandLine(p_li->piValue[p_li->cClckSel].cValue,
  4568. ctext);
  4569. demo_Set_Scene_Level(p_li->piValue[p_li->cClckSel].cValue,
  4570. &iActualScene, &iActualLevel);
  4571. RunLevel(NULL, p_ad, cpu, ctext, "LOAD_DEMO");
  4572. for (i = 0; i < 32; i++)
  4573. anm[i].cmd = NULL;
  4574. key[K_ESC] = 1;
  4575. }
  4576. p_li->bDblClck = 0;
  4577. p_li->bClck = 0;
  4578. }
  4579. }
  4580. resid = -1;
  4581. if (key[K_ESC]) {
  4582. /* for(i=0;i<lastcmd;i++)
  4583. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  4584. {
  4585. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  4586. res[i].iParam[5] = -1;
  4587. }
  4588. */
  4589. goto __QUIT;
  4590. }
  4591. }
  4592. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  4593. if (timercnt > 500) {
  4594. timercnt = 0;
  4595. for (i = 0; i < lastcmd; i++)
  4596. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  4597. if (rand() % 200 <= res[i].iParam[1] &&
  4598. strcmp(dir, res[i].cParam[0])) {
  4599. CheckAnimation(&res[i], p_ad);
  4600. AddAnimation(&res[i], p_ad, 0, 0);
  4601. }
  4602. }
  4603. dwStop = timeGetTime();
  4604. dwEplased += dwStop - dwStart;
  4605. spracuj_spravy(0);
  4606. ddxUpdateMouse();
  4607. AnimationEvent(dwStop, p_ad);
  4608. if (dim.tf1) {
  4609. dim.t1 = 1;
  4610. dim.tf1 = 0;
  4611. }
  4612. if (dim.tf2) {
  4613. dim.t2 = 1;
  4614. dim.tf2 = 0;
  4615. }
  4616. if (ddxRestore(p_ad)) {
  4617. cRestartMainMenu = 1;
  4618. key[K_ESC] = 1;
  4619. }
  4620. }
  4621. __QUIT:
  4622. if (!cBrutalRestart) {
  4623. ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
  4624. ddxGetWidth(res[idx].iParam[1]),
  4625. ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
  4626. ddxTransparentBlt(BackDC, res[idx].iParam[2], res[idx].iParam[3],
  4627. ddxGetWidth(res[idx].iParam[1]),
  4628. ddxGetHight(res[idx].iParam[1]),
  4629. res[idx].iParam[1], 0, 0, ddxGetWidth(res[idx].iParam[1]),
  4630. ddxGetHight(res[idx].iParam[1]), TRANSCOLOR);
  4631. ddxReleaseBitmap(hdcBT);
  4632. ddxCleareSurface(FontDC);
  4633. co_Handle_Release(citem, CLIST_ITEMC);
  4634. co_Release_Graphic();
  4635. }
  4636. key[K_ESC] = 0;
  4637. FreeAnimations(res, RES_NUM);
  4638. free((void *) res);
  4639. }
  4640. void RunMenuLoadGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
  4641. {
  4642. DWORD dwEplased = 0, dwStart, dwStop;
  4643. RECT r;
  4644. int c = 0;
  4645. int idx;
  4646. int hdcBT;
  4647. CONTROL_LIST_ITEM citem[CLIST_ITEMC];
  4648. // FILE *file;
  4649. char dir[256];
  4650. int lastcmd, lastanm, i;
  4651. //CMD_LINE res[RES_NUM];
  4652. CMD_LINE *res = NULL;
  4653. int lastabv = -1;
  4654. char in, click = 0;
  4655. int anmid = -1, resid = -1, anbind = -1;
  4656. int bind;
  4657. int iNadpisDC = -1;
  4658. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  4659. if (!res) {
  4660. kprintf(1, "RunMenuLoadGame: Out of Memory");
  4661. return;
  4662. }
  4663. else
  4664. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  4665. //bBackDC = 1;
  4666. // ddxCleareSurface(FontDC);
  4667. // ddxCleareSurface(BackDC);
  4668. ddxCleareSurface(BackDC);
  4669. ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0,
  4670. 0);
  4671. ddxCleareSurface(FontDC);
  4672. //kprintf(1, "bitblt");
  4673. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
  4674. for (bind = 0; bind < RES_NUM; bind++) {
  4675. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  4676. res[bind].iAnim[lastcmd][0] = -1;
  4677. res[bind].iAnim[lastcmd][11] = -1;
  4678. }
  4679. for (in = 0; in < 6; in++)
  4680. res[bind].iParam[in] = -1;
  4681. res[bind].iLayer = 0;
  4682. }
  4683. lastcmd = 0;
  4684. timercnt = 0;
  4685. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  4686. working_file_translate(dir, 256);
  4687. chdir((dir));
  4688. //natadhe skript menu
  4689. LoadMenuScript(p_File_Name, res, &lastcmd);
  4690. //kprintf(1, "load");
  4691. in = 0;
  4692. fn_Set_Font(cFontFile[0]);
  4693. fn_Load_Bitmaps();
  4694. //kprintf(1, "fn_Set_Font");
  4695. CreateFontAnimations(res, &lastcmd);
  4696. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  4697. // animace na OnAbove
  4698. for (i = 0; i < lastcmd; i++) {
  4699. lastanm = 0;
  4700. switch (res[i].iParam[0]) {
  4701. case COM_DRAW:
  4702. {
  4703. if (!c) {
  4704. hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
  4705. ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
  4706. ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
  4707. ddxGetHight(res[i].iParam[1]),
  4708. HDC2DD, res[i].iParam[2], res[i].iParam[3]);
  4709. ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
  4710. ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
  4711. res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
  4712. ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
  4713. idx = i;
  4714. }
  4715. else {
  4716. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  4717. }
  4718. c++;
  4719. }
  4720. break;
  4721. case COM_RANDOMANIMATION:
  4722. case COM_ONCLICK:
  4723. case COM_ONABOVE:
  4724. case COM_RUNANIMATION:
  4725. case COM_BINDEXITANIMATION:
  4726. case COM_BINDANIMATION:
  4727. //nahrati animace k udalosti OnAbove
  4728. LoadAnimationMenuScript(res, i, &lastanm);
  4729. break;
  4730. }
  4731. }
  4732. r.left = 299;
  4733. r.top = 209;
  4734. r.right = 743;
  4735. r.bottom = 359;
  4736. co_Set_Text_Center(BackDC, "##menu_lgametitle", 0, r);
  4737. iNadpisDC =
  4738. ddxCreateSurface(r.right - r.left, r.bottom - r.top,
  4739. ddxFindFreeSurface());
  4740. ddxBitBlt(iNadpisDC, 0, 0, ddxGetWidth(iNadpisDC), ddxGetHight(iNadpisDC),
  4741. BackDC, r.left, r.top);
  4742. fn_Release_Font(1);
  4743. BEGIN_MENU_LOAD:
  4744. bBackDC = 1;
  4745. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  4746. TRANSCOLOR);
  4747. DisplayFrame();
  4748. for (i = 0; i < lastcmd; i++)
  4749. if (res[i].iParam[0] == COM_RUNANIMATION) {
  4750. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  4751. if (iWave != -1) {
  4752. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  4753. anm[iWave].iWave = res[i + 1].iParam[5] =
  4754. mPlaySound(&res[i + 1], p_ad, 2);
  4755. }
  4756. }
  4757. dim.t1 = 0;
  4758. dim.t2 = 0;
  4759. dim.dx = 0;
  4760. dim.dy = 0;
  4761. anmid = -1;
  4762. resid = -1;
  4763. anbind = -1;
  4764. bind = -1;
  4765. lastabv = -1;
  4766. in = 0;
  4767. spracuj_spravy(0);
  4768. while (!key[K_ESC]) {
  4769. dwStart = timeGetTime();
  4770. //pohnul mysi
  4771. if (dim.dx || dim.dy) {
  4772. //dostala se mys do akcni oblasti (OnAbove)?
  4773. if (!click)
  4774. for (i = 0; i < lastcmd; i++)
  4775. if (res[i].iParam[0] == COM_ONABOVE) {
  4776. if ((dim.x >= res[i].iParam[1]) &&
  4777. (dim.x <= res[i].iParam[3]) &&
  4778. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  4779. //spusteni animace v OnAbove
  4780. if (i != lastabv) {
  4781. if (in) {
  4782. Stop(&res[lastabv]);
  4783. if (!res[lastabv].iLayer) {
  4784. //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
  4785. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  4786. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  4787. }
  4788. else {
  4789. //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
  4790. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  4791. TRANSCOLOR);
  4792. //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
  4793. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  4794. }
  4795. }
  4796. CheckAnimation(&res[i], p_ad);
  4797. lastabv = i;
  4798. AddAnimation(&res[i], p_ad, 0, 1);
  4799. in = 1;
  4800. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  4801. if (bind != -1) {
  4802. CheckAnimation(&res[bind], p_ad);
  4803. AddAnimation(&res[bind], p_ad, 1, 1);
  4804. anbind = bind;
  4805. mPlaySound(&res[bind], p_ad, 0);
  4806. }
  4807. strcpy(dir, res[i].cParam[1]);
  4808. }
  4809. }
  4810. else if (lastabv == i) {
  4811. // odesel z oblasti, ktera byla aktivni -> stop animace
  4812. // a odznaceni oblasti
  4813. Stop(&res[i]);
  4814. if (!res[i].iLayer) {
  4815. //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
  4816. ddxDrawDisplay(res[i].iAnim[0], 0);
  4817. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  4818. }
  4819. else {
  4820. //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
  4821. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  4822. //menucommand_DrawT(FontDC, res[i].iAnim[0]);
  4823. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  4824. }
  4825. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  4826. if (bind != -1) {
  4827. int iAnim;
  4828. if (anbind != -1) {
  4829. Stop(&res[anbind]);
  4830. if (!res[i].iLayer) {
  4831. //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
  4832. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  4833. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  4834. }
  4835. else {
  4836. //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
  4837. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  4838. TRANSCOLOR);
  4839. //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
  4840. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  4841. }
  4842. }
  4843. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  4844. if (iAnim != -1)
  4845. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  4846. }
  4847. lastabv = -1;
  4848. anbind = -1;
  4849. in = 0;
  4850. strcpy(dir, "");
  4851. }
  4852. }
  4853. dim.dx = 0;
  4854. dim.dy = 0;
  4855. }
  4856. //co_Handle_Controls(citem, CLIST_ITEMC, mi.x, mi.y);
  4857. //stlacil leve tlacitko
  4858. if (dim.t1 && !click) {
  4859. //dostala se mys do akcni oblasti (OnClick)?
  4860. for (i = 0; i < lastcmd; i++)
  4861. if (res[i].iParam[0] == COM_ONCLICK)
  4862. if ((dim.x >= res[i].iParam[1]) &&
  4863. (dim.x <= res[i].iParam[3]) &&
  4864. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  4865. if (res[i].iAnim[0][0] >= 0) {
  4866. //pokud je animace, tak ji spust
  4867. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  4868. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  4869. mPlaySound(&res[i + 1], p_ad, 1);
  4870. resid = i;
  4871. click = 1;
  4872. }
  4873. else {
  4874. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  4875. mPlaySound(&res[i + 1], p_ad, 1);
  4876. resid = i;
  4877. click = 1;
  4878. anmid = 31;
  4879. }
  4880. }
  4881. dim.t1 = 0;
  4882. }
  4883. //provedeni akce po animaci menu
  4884. if (click)
  4885. if (!anm[anmid].cmd) {
  4886. click = 0;
  4887. //StopAll();
  4888. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  4889. !strcmp(res[resid].cParam[1], "CANCEL")) {
  4890. key[K_ESC] = 1;
  4891. //break;
  4892. }
  4893. if (!strcmp(res[resid].cParam[1], "LOAD_GAME_LOAD"))
  4894. RunMenuLoadGameLoad("Mmload_game_load.txt", NULL, p_ad, cpu, 1);
  4895. if (!strcmp(res[resid].cParam[1], "LOAD_GAME_DEMO"))
  4896. RunMenuLoadGameLoad("Mmload_game_load.txt", NULL, p_ad, cpu, 0);
  4897. if (cBrutalRestart)
  4898. key[K_ESC] = 1;
  4899. if (!cBrutalRestart) {
  4900. for (i = 0; i < lastcmd; i++) {
  4901. switch (res[i].iParam[0]) {
  4902. case COM_DRAW:
  4903. if (!res[i].iLayer) {
  4904. //menucommand_Draw(_2dd.hDC, res[i].iParam);
  4905. }
  4906. else {
  4907. ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  4908. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2,
  4909. TRANSCOLOR);
  4910. ddxDrawSurface(FontDC, res[i].iParam, 3);
  4911. }
  4912. break;
  4913. }
  4914. }
  4915. ddxTransparentBltDisplay(r.left, r.top, ddxGetWidth(iNadpisDC),
  4916. ddxGetHight(iNadpisDC), iNadpisDC, 0, 0, ddxGetWidth(iNadpisDC),
  4917. ddxGetHight(iNadpisDC), TRANSCOLOR);
  4918. ddxTransparentBlt(BackDC, r.left, r.top, ddxGetWidth(iNadpisDC),
  4919. ddxGetHight(iNadpisDC), iNadpisDC, 0, 0, ddxGetWidth(iNadpisDC),
  4920. ddxGetHight(iNadpisDC), TRANSCOLOR);
  4921. }
  4922. resid = -1;
  4923. if (key[K_ESC]) {
  4924. /*
  4925. for(i=0;i<lastcmd;i++)
  4926. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  4927. {
  4928. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  4929. res[i].iParam[5] = -1;
  4930. }
  4931. */
  4932. goto __QUIT;
  4933. }
  4934. else
  4935. goto BEGIN_MENU_LOAD;
  4936. }
  4937. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  4938. if (timercnt > 500) {
  4939. timercnt = 0;
  4940. for (i = 0; i < lastcmd; i++)
  4941. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  4942. if (rand() % 200 <= res[i].iParam[1] &&
  4943. strcmp(dir, res[i].cParam[0])) {
  4944. CheckAnimation(&res[i], p_ad);
  4945. AddAnimation(&res[i], p_ad, 0, 0);
  4946. }
  4947. }
  4948. /*spracuj_spravy(0);
  4949. ddxUpdateMouse();
  4950. if(dim.dx || dim.dy)
  4951. DisplayFrame(); */
  4952. dwStop = timeGetTime();
  4953. dwEplased += dwStop - dwStart;
  4954. spracuj_spravy(0);
  4955. ddxUpdateMouse();
  4956. AnimationEvent(dwStop, p_ad);
  4957. if (dim.tf1) {
  4958. dim.t1 = 1;
  4959. dim.tf1 = 0;
  4960. }
  4961. if (dim.tf2) {
  4962. dim.t2 = 1;
  4963. dim.tf2 = 0;
  4964. }
  4965. if (ddxRestore(p_ad)) {
  4966. cRestartMainMenu = 1;
  4967. key[K_ESC] = 1;
  4968. }
  4969. }
  4970. __QUIT:
  4971. //BitBltU(FontDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
  4972. ddxCleareSurface(FontDC);
  4973. //TransparentBltU(_2dd.hDC, 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, RGB(255, 0, 255));
  4974. if (!cBrutalRestart)
  4975. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  4976. TRANSCOLOR);
  4977. //BitBltU(BackDC, 0, 0, 1024, 768, NULL, 0, 0, WHITENESS);
  4978. ddxCleareSurface(BackDC);
  4979. bBackDC = 0;
  4980. /*BitBlt(_2dd.hDC, res[idx].iParam[2], res[idx].iParam[3],
  4981. _2dd.bitmap[res[idx].iParam[1]].bitmap.bmWidth,
  4982. _2dd.bitmap[res[idx].iParam[1]].bitmap.bmHeight,
  4983. hdcBT, 0, 0, SRCCOPY); */
  4984. if (!cBrutalRestart) {
  4985. ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
  4986. ddxGetWidth(res[idx].iParam[1]),
  4987. ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
  4988. ddxTransparentBlt(BackDC, res[idx].iParam[2], res[idx].iParam[3],
  4989. ddxGetWidth(res[idx].iParam[1]),
  4990. ddxGetHight(res[idx].iParam[1]),
  4991. res[idx].iParam[1], 0, 0, ddxGetWidth(res[idx].iParam[1]),
  4992. ddxGetHight(res[idx].iParam[1]), TRANSCOLOR);
  4993. ddxReleaseBitmap(hdcBT);
  4994. ddxReleaseBitmap(iNadpisDC);
  4995. }
  4996. ddxCleareSurface(CompositDC);
  4997. //fn_Release_Font();
  4998. //co_Handle_Release(citem, CLIST_ITEMC);
  4999. //co_Release_Graphic();
  5000. key[K_ESC] = 0;
  5001. FreeAnimations(res, RES_NUM);
  5002. free((void *) res);
  5003. }
  5004. void RunMenuCibron(char *cBmp)
  5005. {
  5006. int idx = ddxCreateSurface(1024, 768, ddxFindFreeSurface());
  5007. int cib;
  5008. if (idx == -1)
  5009. return;
  5010. ddxBitBlt(idx, 0, 0, 1024, 768, HDC2DD, 0, 0);
  5011. cib = ddxLoadBitmap(cBmp, pBmpArchive);
  5012. if (cib == -1) {
  5013. ddxReleaseBitmap(idx);
  5014. return;
  5015. }
  5016. ddxBitBltDisplay(0, 0, 1024, 768, cib, 0, 0);
  5017. DisplayFrame();
  5018. while (!key[0] && !dim.t1 && !dim.t2) {
  5019. spracuj_spravy(0);
  5020. ddxUpdateMouse();
  5021. DisplayFrame();
  5022. Sleep(10);
  5023. }
  5024. dim.tf1 = 0;
  5025. dim.tf2 = 0;
  5026. dim.t1 = 0;
  5027. dim.t2 = 0;
  5028. memset(key, 0, POCET_KLAVES * sizeof(char));
  5029. ddxBitBlt(HDC2DD, 0, 0, 1024, 768, idx, 0, 0);
  5030. ddxReleaseBitmap(idx);
  5031. ddxReleaseBitmap(cib);
  5032. }
  5033. void RunMenuCinemax(void)
  5034. {
  5035. int c = 0;
  5036. int cib;
  5037. pBmpArchive->pActualNode = pBmpArchive->pRootNode->pNextNode;
  5038. cib = ddxLoadBitmap("cinemax.bmp", pBmpArchive);
  5039. if (cib == -1) {
  5040. pBmpArchive->bError = 0;
  5041. return;
  5042. }
  5043. ddxSetCursor(0);
  5044. ddxSetFlip(0);
  5045. ddxBitBltDisplay(0, 0, 1024, 768, cib, 0, 0);
  5046. DisplayFrame();
  5047. ddxBitBltDisplay(0, 0, 1024, 768, cib, 0, 0);
  5048. while (!key[0] && !dim.t1 && !dim.t2) {
  5049. Sleep(10);
  5050. c += 10;
  5051. if (c > 1000)
  5052. break;
  5053. }
  5054. dim.tf1 = 0;
  5055. dim.tf2 = 0;
  5056. dim.t1 = 0;
  5057. dim.t2 = 0;
  5058. memset(key, 0, POCET_KLAVES * sizeof(char));
  5059. ddxReleaseBitmap(cib);
  5060. ddxSetCursor(1);
  5061. ddxSetFlip(1);
  5062. }
  5063. void RunMenuDrawVersion(int iSurface)
  5064. {
  5065. char text[256];
  5066. sprintf(text, "v%d.%d", VERZEHI, VERZELO);
  5067. //co_Set_Text_RightWC(HDC2DD, text, 1, 990, 318);
  5068. co_Set_Text_RightWC(HDC2DD, text, 0, 1024, 0);
  5069. //co_Set_Text(HDC2DD, 280, 0, "##sale", 0);
  5070. co_Set_Text_RightWC(iSurface, text, 0, 1024, 0);
  5071. //co_Set_Text(iSurface, 280, 0, "##sale", 0);
  5072. }
  5073. void RunMenuDrawDemoEndScreen(void)
  5074. {
  5075. int idx;
  5076. ddxSetFlip(1);
  5077. key[0] = 0;
  5078. idx = ddxLoadBitmap("final_screen.bmp", pBmpArchive);
  5079. if (idx == -1)
  5080. return;
  5081. ddxSetCursor(1);
  5082. ddxBitBltDisplay(0, 0, 1024, 768, idx, 0, 0);
  5083. ddxSetFlip(0);
  5084. while (!key[0] && !mi.t1 && !mi.t2) {
  5085. Sleep(25);
  5086. spracuj_spravy(1);
  5087. ddxUpdateMouse();
  5088. if (mi.dx || mi.dy)
  5089. DisplayFrame();
  5090. }
  5091. ddxReleaseBitmap(idx);
  5092. ddxSetCursor(0);
  5093. }
  5094. //------------------------------------------------------------------------------------------------
  5095. // spusti menu
  5096. //------------------------------------------------------------------------------------------------
  5097. void RunMenu(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int cpu)
  5098. {
  5099. DWORD dwEplased = 0, dwStart, dwStop;
  5100. char bStop = 1;
  5101. char dir[256];
  5102. int lastcmd, lastanm, i, j;
  5103. CMD_LINE *res = NULL;
  5104. int lastabv = -1;
  5105. char in, click = 0;
  5106. int anmid = -1, resid = -1, anbind = -1;
  5107. int bind;
  5108. int cStartCount = 0;
  5109. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  5110. if (!res) {
  5111. kprintf(1, "RunMenu: Out of Memory");
  5112. return;
  5113. }
  5114. RUN_MENU_BRUTAL_RESTART:
  5115. ZeroAnimations();
  5116. bNewScene = 0;
  5117. cRestartMainMenu = 0;
  5118. if (cBrutalRestart) {
  5119. fn_Set_Font(cFontFile[0]);
  5120. fn_Load_Bitmaps();
  5121. for (i = 0; i < 32; i++)
  5122. anm[i].cmd = NULL;
  5123. cRestartMainMenu = 1;
  5124. }
  5125. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  5126. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  5127. working_file_translate(dir, 256);
  5128. chdir((dir));
  5129. if (!cBrutalRestart) {
  5130. iCompositDC = ddxFindFreeSurface();
  5131. CompositDC = ddxCreateSurface(1024, 768, iCompositDC);
  5132. iFontDC = ddxFindFreeSurface();
  5133. FontDC = ddxCreateSurface(1024, 768, iFontDC);
  5134. iBackDC = ddxFindFreeSurface();
  5135. BackDC = ddxCreateSurface(1024, 768, iBackDC);
  5136. }
  5137. cBrutalRestart = 0;
  5138. for (bind = 0; bind < RES_NUM; bind++) {
  5139. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  5140. res[bind].iAnim[lastcmd][0] = -1;
  5141. res[bind].iAnim[lastcmd][11] = -1;
  5142. }
  5143. for (in = 0; in < 6; in++)
  5144. res[bind].iParam[in] = -1;
  5145. res[bind].iLayer = 0;
  5146. }
  5147. lastcmd = 0;
  5148. timercnt = 0;
  5149. //natadhe skript menu
  5150. LoadMenuScript(p_File_Name, res, &lastcmd);
  5151. in = 0;
  5152. CreateFontAnimations(res, &lastcmd);
  5153. fn_Release_Font(1);
  5154. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  5155. // animace na OnAbove
  5156. fn_Set_Font(cFontFile[2]);
  5157. fn_Load_Bitmaps();
  5158. ddxSetFlip(0);
  5159. for (j = 0; j < 2; j++) {
  5160. for (i = 0; i < lastcmd; i++) {
  5161. lastanm = 0;
  5162. switch (res[i].iParam[0]) {
  5163. case COM_DRAW:
  5164. if (!res[i].iLayer)
  5165. ddxDrawDisplay(res[i].iParam, 0);
  5166. else {
  5167. ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  5168. ddxDrawSurface(FontDC, res[i].iParam, 3);
  5169. }
  5170. break;
  5171. case COM_RANDOMANIMATION:
  5172. case COM_ONCLICK:
  5173. case COM_ONABOVE:
  5174. case COM_RUNANIMATION:
  5175. case COM_BINDEXITANIMATION:
  5176. case COM_BINDANIMATION:
  5177. //nahrati animace k udalosti OnAbove
  5178. if (!j)
  5179. LoadAnimationMenuScript(res, i, &lastanm);
  5180. break;
  5181. }
  5182. }
  5183. RunMenuDrawVersion(res[0].iParam[1]);
  5184. DisplayFrame();
  5185. }
  5186. fn_Release_Font(1);
  5187. ddxSetFlip(1);
  5188. BEGIN_MENU:
  5189. if (bStop || cRestartMainMenu)
  5190. for (i = 0; i < lastcmd; i++)
  5191. if (res[i].iParam[0] == COM_RUNANIMATION) {
  5192. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  5193. kprintf(1, "COM_RUNANIMATION = %d, iWAVE = %d", i, iWave);
  5194. if (iWave != -1) {
  5195. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5196. anm[iWave].iWave = res[i + 1].iParam[5] =
  5197. mPlaySound(&res[i + 1], p_ad, 2);
  5198. }
  5199. }
  5200. if (!cStartCount) {
  5201. int idx = ddxCreateSurface(1024, 768, ddxFindFreeSurface());
  5202. if (idx == -1)
  5203. exit(0);
  5204. ddxBitBlt(idx, 0, 0, 1024, 768, HDC2DD, 0, 0);
  5205. if (RunMenuNewGame("Mmnew_game.txt", NULL, p_ad, cpu)) {
  5206. //ddxReleaseBitmap(idx);
  5207. goto RUN_MENU_BRUTAL_RESTART;
  5208. }
  5209. ddxBitBltDisplay(0, 0, 1024, 768, idx, 0, 0);
  5210. for (i = 0; i < lastcmd; i++) {
  5211. lastanm = 0;
  5212. switch (res[i].iParam[0]) {
  5213. case COM_DRAW:
  5214. if (res[i].iLayer)
  5215. ddxDrawSurface(FontDC, res[i].iParam, 3);
  5216. break;
  5217. }
  5218. }
  5219. ddxReleaseBitmap(idx);
  5220. cStartCount = 1;
  5221. }
  5222. cRestartMainMenu = 0;
  5223. dim.t1 = 0;
  5224. dim.t2 = 0;
  5225. dim.dx = 0;
  5226. dim.dy = 0;
  5227. anmid = -1;
  5228. resid = -1;
  5229. anbind = -1;
  5230. bind = -1;
  5231. lastabv = -1; // posledni animace -> co bezi?
  5232. in = 0;
  5233. bStop = 1;
  5234. spracuj_spravy(0);
  5235. dwEplased = 0;
  5236. while (!key[K_ESC]) {
  5237. dwStart = timeGetTime();
  5238. //pohnul mysi
  5239. if (dim.dx || dim.dy) {
  5240. //dostala se mys do akcni oblasti (OnAbove)?
  5241. if (!click)
  5242. for (i = 0; i < lastcmd; i++)
  5243. if (res[i].iParam[0] == COM_ONABOVE) {
  5244. if ((dim.x >= res[i].iParam[1]) &&
  5245. (dim.x <= res[i].iParam[3]) &&
  5246. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  5247. //spusteni animace v OnAbove
  5248. if (i != lastabv) {
  5249. if (in) {
  5250. // There's already running one - stop it
  5251. Stop(&res[lastabv]);
  5252. // Draw frame 0 -> clear the animation from screen
  5253. if (!res[lastabv].iLayer) {
  5254. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  5255. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  5256. }
  5257. else {
  5258. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  5259. TRANSCOLOR);
  5260. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  5261. //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
  5262. //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
  5263. }
  5264. }
  5265. CheckAnimation(&res[i], p_ad);
  5266. lastabv = i; // set last animation
  5267. AddAnimation(&res[i], p_ad, 0, 1);
  5268. in = 1;
  5269. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  5270. if (bind != -1) {
  5271. CheckAnimation(&res[bind], p_ad);
  5272. AddAnimation(&res[bind], p_ad, 1, 1);
  5273. anbind = bind;
  5274. mPlaySound(&res[bind], p_ad, 0);
  5275. }
  5276. strcpy(dir, res[i].cParam[1]);
  5277. }
  5278. }
  5279. else if (lastabv == i) {
  5280. // odesel z oblasti, ktera byla aktivni -> stop animace
  5281. // a odznaceni oblasti
  5282. Stop(&res[i]);
  5283. if (!res[i].iLayer) {
  5284. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  5285. ddxDrawDisplay(res[i].iAnim[0], 0);
  5286. }
  5287. else {
  5288. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  5289. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  5290. //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
  5291. //menucommand_Draw(FontDC, res[i].iAnim[0], 3);
  5292. }
  5293. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  5294. if (bind != -1) {
  5295. int iAnim;
  5296. if (anbind != -1) {
  5297. Stop(&res[anbind]);
  5298. if (!res[i].iLayer) {
  5299. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  5300. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  5301. }
  5302. else {
  5303. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  5304. TRANSCOLOR);
  5305. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  5306. //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
  5307. //menucommand_Draw(FontDC, res[anbind].iAnim[0], 3);
  5308. }
  5309. }
  5310. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  5311. if (iAnim != -1)
  5312. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  5313. }
  5314. lastabv = -1;
  5315. anbind = -1;
  5316. in = 0;
  5317. strcpy(dir, "");
  5318. }
  5319. }
  5320. dim.dx = 0;
  5321. dim.dy = 0;
  5322. }
  5323. //stlacil leve tlacitko
  5324. if (dim.t1 && !click) {
  5325. //dostala se mys do akcni oblasti (OnClick)?
  5326. for (i = 0; i < lastcmd; i++)
  5327. if (res[i].iParam[0] == COM_ONCLICK)
  5328. if ((dim.x >= res[i].iParam[1]) &&
  5329. (dim.x <= res[i].iParam[3]) &&
  5330. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  5331. if (res[i].iAnim[0][0] >= 0) {
  5332. //pokud je animace, tak ji spust
  5333. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  5334. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5335. mPlaySound(&res[i + 1], p_ad, 1);
  5336. resid = i;
  5337. click = 1;
  5338. }
  5339. else {
  5340. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5341. mPlaySound(&res[i + 1], p_ad, 1);
  5342. resid = i;
  5343. click = 1;
  5344. anmid = 31;
  5345. }
  5346. }
  5347. dim.t1 = 0;
  5348. }
  5349. //provedeni akce po animaci menu
  5350. if (click)
  5351. if (!anm[anmid].cmd) {
  5352. click = 0;
  5353. if (!strcmp(res[resid].cParam[1], "NEW_GAME") ||
  5354. !strcmp(res[resid].cParam[1], "LOAD_GAME") ||
  5355. !strcmp(res[resid].cParam[1], "PLAYER_NAME"))
  5356. bStop = 0;
  5357. if (bStop)
  5358. StopAll();
  5359. if (!strcmp(res[resid].cParam[1], "CIBRA")) {
  5360. StopAll();
  5361. RunMenuCibron("cibra.bmp");
  5362. click = 0;
  5363. }
  5364. if (!strcmp(res[resid].cParam[1], "EXIT"))
  5365. key[K_ESC] = 1;
  5366. if (!strcmp(res[resid].cParam[1], "PLAYER_NAME")) {
  5367. if (RunMenuNewGame("Mmnew_game.txt", NULL, p_ad, cpu))
  5368. goto RUN_MENU_BRUTAL_RESTART;
  5369. bStop = 1;
  5370. }
  5371. if (!strcmp(res[resid].cParam[1], "CREDITS")) {
  5372. int lid = GetPrivateProfileInt("game", "languageid", 0, ini_file);
  5373. StopAll();
  5374. bStop = 1;
  5375. if (lid < 2 || lid == 4) {
  5376. if (cr_Credits(NULL, p_ad))
  5377. goto RUN_MENU_BRUTAL_RESTART;
  5378. }
  5379. else {
  5380. if (cr_CreditsUNI(NULL, p_ad))
  5381. goto RUN_MENU_BRUTAL_RESTART;
  5382. }
  5383. }
  5384. if (!strcmp(res[resid].cParam[1], "NEW_GAME")) {
  5385. //RunMenuNewGame("Mmnew_game.txt", hWnd, p_ad, cpu);
  5386. RunMenuStartGame("Mmstart_game.txt", NULL, p_ad, cpu);
  5387. if (cBrutalRestart)
  5388. goto RUN_MENU_BRUTAL_RESTART;
  5389. }
  5390. if (!strcmp(res[resid].cParam[1], "LOAD_GAME")) {
  5391. RunMenuLoadGame("Mmload_game.txt", NULL, p_ad, cpu);
  5392. if (cBrutalRestart)
  5393. goto RUN_MENU_BRUTAL_RESTART;
  5394. }
  5395. if (!strcmp(res[resid].cParam[1], "SETTINGS")) {
  5396. RunMenuSettings("Mmsettings.txt", NULL, p_ad, cpu);
  5397. if (cBrutalRestart)
  5398. goto RUN_MENU_BRUTAL_RESTART;
  5399. cRestartMainMenu = 1;
  5400. }
  5401. if (bStop || cRestartMainMenu)
  5402. StopAll();
  5403. for (i = 0; i < lastcmd; i++) {
  5404. switch (res[i].iParam[0]) {
  5405. case COM_DRAW:
  5406. if (!res[i].iLayer) {
  5407. if (bStop || cRestartMainMenu)
  5408. ddxDrawSurface(BackDC, res[i].iParam, 0);
  5409. }
  5410. else {
  5411. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 0, TRANSCOLOR);
  5412. ddxDrawSurface(FontDC, res[i].iParam, 3);
  5413. }
  5414. break;
  5415. }
  5416. }
  5417. if (cRestartMainMenu || bStop) {
  5418. ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
  5419. ddxCleareSurface(BackDC);
  5420. }
  5421. resid = -1;
  5422. if (key[K_ESC]) {
  5423. /* for(i=0;i<lastcmd;i++)
  5424. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  5425. {
  5426. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  5427. res[i].iParam[5] = -1;
  5428. }
  5429. */
  5430. goto __QUIT;
  5431. }
  5432. else
  5433. goto BEGIN_MENU;
  5434. }
  5435. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  5436. if (timercnt > 500) {
  5437. timercnt = 0;
  5438. for (i = 0; i < lastcmd; i++) {
  5439. if (res[i].iParam[0] == COM_RANDOMANIMATION) {
  5440. if (rand() % 200 <= res[i].iParam[1] && strcmp(dir, res[i].cParam[0])) {
  5441. CheckAnimation(&res[i], p_ad);
  5442. AddAnimation(&res[i], p_ad, 0, 0);
  5443. }
  5444. }
  5445. }
  5446. }
  5447. dwStop = timeGetTime();
  5448. dwEplased += dwStop - dwStart;
  5449. spracuj_spravy(0);
  5450. ddxUpdateMouse();
  5451. AnimationEvent(dwStop, p_ad);
  5452. if (dim.tf1) {
  5453. dim.t1 = 1;
  5454. dim.tf1 = 0;
  5455. }
  5456. if (dim.tf2) {
  5457. dim.t2 = 1;
  5458. dim.tf2 = 0;
  5459. }
  5460. if (ddxRestore(p_ad))
  5461. goto RUN_MENU_BRUTAL_RESTART;
  5462. // updatuj_pozici_mysi();
  5463. }
  5464. __QUIT:
  5465. /*
  5466. for(i=0;i<lastcmd;i++)
  5467. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  5468. {
  5469. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  5470. res[i].iParam[5] = -1;
  5471. }
  5472. //fn_Release_Font();
  5473. adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
  5474. adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
  5475. */
  5476. StopAll();
  5477. ddxReleaseBitmap(iCompositDC);
  5478. ddxReleaseBitmap(iFontDC);
  5479. ddxReleaseBitmap(iBackDC);
  5480. //ddxReleaseBitmap(Ltmp1DC);
  5481. // free((void *) llcitem);
  5482. key[K_ESC] = 0;
  5483. FreeAnimations(res, RES_NUM);
  5484. free((void *) res);
  5485. }
  5486. void RunMenuChildGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
  5487. int cpu)
  5488. {
  5489. DWORD dwEplased = 0, dwStart, dwStop;
  5490. int c = 0;
  5491. int idx;
  5492. int hdcBT;
  5493. CONTROL_LIST_ITEM citem[CLIST_ITEMC];
  5494. // FILE *file;
  5495. char dir[256];
  5496. int lastcmd, lastanm, i;
  5497. //CMD_LINE res[RES_NUM];
  5498. CMD_LINE *res = NULL;
  5499. int lastabv = -1;
  5500. char in, click = 0;
  5501. int anmid = -1, resid = -1, anbind = -1;
  5502. int bind;
  5503. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  5504. if (!res) {
  5505. kprintf(1, "RunMenuChildGame: Out of Memory");
  5506. return;
  5507. }
  5508. else
  5509. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  5510. ddxCleareSurface(FontDC);
  5511. //ddxCleareSurface(BackDC);
  5512. /* ddxCleareSurface(BackDC);
  5513. ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0, 0);
  5514. ddxCleareSurface(FontDC);*/
  5515. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
  5516. for (bind = 0; bind < RES_NUM; bind++) {
  5517. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  5518. res[bind].iAnim[lastcmd][0] = -1;
  5519. res[bind].iAnim[lastcmd][11] = -1;
  5520. }
  5521. for (in = 0; in < 6; in++)
  5522. res[bind].iParam[in] = -1;
  5523. res[bind].iLayer = 0;
  5524. }
  5525. lastcmd = 0;
  5526. timercnt = 0;
  5527. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  5528. working_file_translate(dir, 256);
  5529. chdir((dir));
  5530. //natadhe skript menu
  5531. LoadMenuScript(p_File_Name, res, &lastcmd);
  5532. //lastcmd--;
  5533. in = 0;
  5534. fn_Set_Font(cFontFile[0]);
  5535. fn_Load_Bitmaps();
  5536. CreateFontAnimations(res, &lastcmd);
  5537. fn_Release_Font(1);
  5538. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  5539. // animace na OnAbove
  5540. for (i = 0; i < lastcmd; i++) {
  5541. lastanm = 0;
  5542. switch (res[i].iParam[0]) {
  5543. case COM_DRAW:
  5544. {
  5545. if (!c) {
  5546. hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
  5547. ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
  5548. ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
  5549. ddxGetHight(res[i].iParam[1]),
  5550. HDC2DD, res[i].iParam[2], res[i].iParam[3]);
  5551. ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
  5552. ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
  5553. res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
  5554. ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
  5555. idx = i;
  5556. }
  5557. else {
  5558. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  5559. }
  5560. c++;
  5561. }
  5562. break;
  5563. case COM_RANDOMANIMATION:
  5564. case COM_ONCLICK:
  5565. case COM_ONABOVE:
  5566. case COM_RUNANIMATION:
  5567. case COM_BINDEXITANIMATION:
  5568. case COM_BINDANIMATION:
  5569. //nahrati animace k udalosti OnAbove
  5570. LoadAnimationMenuScript(res, i, &lastanm);
  5571. break;
  5572. }
  5573. }
  5574. /* {
  5575. RECT r;
  5576. r.left = 299;
  5577. r.top = 209;
  5578. r.right = 743;
  5579. r.bottom = 359;
  5580. co_Set_Text_Center(BackDC, "##menu_child_toughness", 0, r);
  5581. }
  5582. fn_Release_Font();*/
  5583. BEGIN_MENU_CHILDNEWGAME:
  5584. bBackDC = 1;
  5585. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  5586. TRANSCOLOR);
  5587. DisplayFrame();
  5588. for (i = 0; i < lastcmd; i++)
  5589. if (res[i].iParam[0] == COM_RUNANIMATION) {
  5590. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  5591. if (iWave != -1) {
  5592. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5593. anm[iWave].iWave = res[i + 1].iParam[5] =
  5594. mPlaySound(&res[i + 1], p_ad, 2);
  5595. }
  5596. }
  5597. dim.t1 = 0;
  5598. dim.t2 = 0;
  5599. dim.dx = 0;
  5600. dim.dy = 0;
  5601. anmid = -1;
  5602. resid = -1;
  5603. anbind = -1;
  5604. bind = -1;
  5605. lastabv = -1;
  5606. in = 0;
  5607. spracuj_spravy(0);
  5608. while (!key[K_ESC]) {
  5609. dwStart = timeGetTime();
  5610. //pohnul mysi
  5611. if (dim.dx || dim.dy) {
  5612. //dostala se mys do akcni oblasti (OnAbove)?
  5613. if (!click)
  5614. for (i = 0; i < lastcmd; i++)
  5615. if (res[i].iParam[0] == COM_ONABOVE) {
  5616. if ((dim.x >= res[i].iParam[1]) &&
  5617. (dim.x <= res[i].iParam[3]) &&
  5618. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  5619. //spusteni animace v OnAbove
  5620. if (i != lastabv) {
  5621. if (in) {
  5622. Stop(&res[lastabv]);
  5623. if (!res[lastabv].iLayer) {
  5624. //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
  5625. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  5626. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  5627. }
  5628. else {
  5629. //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
  5630. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  5631. TRANSCOLOR);
  5632. //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
  5633. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  5634. }
  5635. }
  5636. CheckAnimation(&res[i], p_ad);
  5637. lastabv = i;
  5638. AddAnimation(&res[i], p_ad, 0, 1);
  5639. in = 1;
  5640. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  5641. if (bind != -1) {
  5642. CheckAnimation(&res[bind], p_ad);
  5643. AddAnimation(&res[bind], p_ad, 1, 1);
  5644. anbind = bind;
  5645. mPlaySound(&res[bind], p_ad, 0);
  5646. }
  5647. strcpy(dir, res[i].cParam[1]);
  5648. }
  5649. }
  5650. else if (lastabv == i) {
  5651. // odesel z oblasti, ktera byla aktivni -> stop animace
  5652. // a odznaceni oblasti
  5653. Stop(&res[i]);
  5654. if (!res[i].iLayer) {
  5655. //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
  5656. ddxDrawDisplay(res[i].iAnim[0], 0);
  5657. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  5658. }
  5659. else {
  5660. //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
  5661. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  5662. //menucommand_DrawT(FontDC, res[i].iAnim[0]);
  5663. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  5664. }
  5665. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  5666. if (bind != -1) {
  5667. int iAnim;
  5668. if (anbind != -1) {
  5669. Stop(&res[anbind]);
  5670. if (!res[i].iLayer) {
  5671. //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
  5672. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  5673. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  5674. }
  5675. else {
  5676. //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
  5677. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  5678. TRANSCOLOR);
  5679. //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
  5680. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  5681. }
  5682. }
  5683. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  5684. if (iAnim != -1)
  5685. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  5686. }
  5687. lastabv = -1;
  5688. anbind = -1;
  5689. in = 0;
  5690. strcpy(dir, "");
  5691. }
  5692. }
  5693. dim.dx = 0;
  5694. dim.dy = 0;
  5695. }
  5696. //stlacil leve tlacitko
  5697. if (dim.t1 && !click) {
  5698. //dostala se mys do akcni oblasti (OnClick)?
  5699. for (i = 0; i < lastcmd; i++)
  5700. if (res[i].iParam[0] == COM_ONCLICK)
  5701. if ((dim.x >= res[i].iParam[1]) &&
  5702. (dim.x <= res[i].iParam[3]) &&
  5703. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  5704. if (res[i].iAnim[0][0] >= 0) {
  5705. //pokud je animace, tak ji spust
  5706. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  5707. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5708. mPlaySound(&res[i + 1], p_ad, 1);
  5709. resid = i;
  5710. click = 1;
  5711. }
  5712. else {
  5713. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5714. mPlaySound(&res[i + 1], p_ad, 1);
  5715. resid = i;
  5716. click = 1;
  5717. anmid = 31;
  5718. }
  5719. }
  5720. dim.t1 = 0;
  5721. }
  5722. //provedeni akce po animaci menu
  5723. if (click)
  5724. if (!anm[anmid].cmd) {
  5725. click = 0;
  5726. //StopAll();
  5727. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  5728. !strcmp(res[resid].cParam[1], "CANCEL")) {
  5729. key[K_ESC] = 1;
  5730. //break;
  5731. }
  5732. if (!strcmp(res[resid].cParam[1], "EASY")) {
  5733. if (iLanguageVersion == 4 && !CheckScenePresence(10)) {
  5734. RunMenuCibron("buy.bmp");
  5735. click = 0;
  5736. }
  5737. else {
  5738. StopAll();
  5739. bBackDC = 0;
  5740. iActualScene = 10;
  5741. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
  5742. NULL, 0);
  5743. key[K_ESC] = 1;
  5744. }
  5745. }
  5746. if (!strcmp(res[resid].cParam[1], "NORMAL")) {
  5747. if (iLanguageVersion == 4 && !CheckScenePresence(11)) {
  5748. RunMenuCibron("buy.bmp");
  5749. click = 0;
  5750. }
  5751. else {
  5752. StopAll();
  5753. bBackDC = 0;
  5754. iActualScene = 11;
  5755. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
  5756. NULL, 0);
  5757. key[K_ESC] = 1;
  5758. }
  5759. }
  5760. if (!strcmp(res[resid].cParam[1], "HARD")) {
  5761. if (iLanguageVersion == 4 && !CheckScenePresence(12)) {
  5762. RunMenuCibron("buy.bmp");
  5763. click = 0;
  5764. }
  5765. else {
  5766. StopAll();
  5767. bBackDC = 0;
  5768. iActualScene = 12;
  5769. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
  5770. NULL, 0);
  5771. key[K_ESC] = 1;
  5772. }
  5773. }
  5774. if (!cRestartMainMenu)
  5775. for (i = 0; i < lastcmd; i++) {
  5776. switch (res[i].iParam[0]) {
  5777. case COM_DRAW:
  5778. if (!res[i].iLayer) {
  5779. //menucommand_Draw(_2dd.hDC, res[i].iParam);
  5780. }
  5781. else {
  5782. //menucommand_DrawT(_2dd.hDC, res[i].iParam);
  5783. ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  5784. //menucommand_DrawT(BackDC, res[i].iParam);
  5785. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2,
  5786. TRANSCOLOR);
  5787. //menucommand_Draw(FontDC, res[i].iParam, 3);
  5788. ddxDrawSurface(FontDC, res[i].iParam, 3);
  5789. }
  5790. break;
  5791. }
  5792. }
  5793. resid = -1;
  5794. if (key[K_ESC]) {
  5795. /*
  5796. for(i=0;i<lastcmd;i++)
  5797. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  5798. {
  5799. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  5800. res[i].iParam[5] = -1;
  5801. }
  5802. */
  5803. goto __QUIT;
  5804. }
  5805. else
  5806. goto BEGIN_MENU_CHILDNEWGAME;
  5807. }
  5808. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  5809. if (timercnt > 500) {
  5810. timercnt = 0;
  5811. for (i = 0; i < lastcmd; i++)
  5812. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  5813. if (rand() % 200 <= res[i].iParam[1] &&
  5814. strcmp(dir, res[i].cParam[0])) {
  5815. CheckAnimation(&res[i], p_ad);
  5816. AddAnimation(&res[i], p_ad, 0, 0);
  5817. }
  5818. }
  5819. dwStop = timeGetTime();
  5820. dwEplased += dwStop - dwStart;
  5821. spracuj_spravy(0);
  5822. ddxUpdateMouse();
  5823. AnimationEvent(dwStop, p_ad);
  5824. if (dim.tf1) {
  5825. dim.t1 = 1;
  5826. dim.tf1 = 0;
  5827. }
  5828. if (dim.tf2) {
  5829. dim.t2 = 1;
  5830. dim.tf2 = 0;
  5831. }
  5832. if (ddxRestore(p_ad)) {
  5833. cRestartMainMenu = 1;
  5834. key[K_ESC] = 1;
  5835. }
  5836. }
  5837. __QUIT:
  5838. ddxCleareSurface(FontDC);
  5839. /* if(!cRestartMainMenu)
  5840. ddxTransparentBltDisplay( 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, TRANSCOLOR);*/
  5841. //ddxCleareSurface(BackDC);
  5842. if (!cRestartMainMenu) {
  5843. ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
  5844. ddxGetWidth(res[idx].iParam[1]),
  5845. ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
  5846. ddxTransparentBlt(BackDC, res[idx].iParam[2], res[idx].iParam[3],
  5847. ddxGetWidth(res[idx].iParam[1]),
  5848. ddxGetHight(res[idx].iParam[1]),
  5849. res[idx].iParam[1], 0, 0, ddxGetWidth(res[idx].iParam[1]),
  5850. ddxGetHight(res[idx].iParam[1]), TRANSCOLOR);
  5851. }
  5852. //BRUTAL_RELEASE .... nenicit
  5853. if (!cBrutalRestart)
  5854. ddxReleaseBitmap(hdcBT);
  5855. ddxCleareSurface(CompositDC);
  5856. key[K_ESC] = 0;
  5857. FreeAnimations(res, RES_NUM);
  5858. free((void *) res);
  5859. }
  5860. void RunMenuStartGame(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad,
  5861. int cpu)
  5862. {
  5863. DWORD dwEplased = 0, dwStart, dwStop;
  5864. int c = 0;
  5865. int idx;
  5866. int hdcBT;
  5867. CONTROL_LIST_ITEM citem[CLIST_ITEMC];
  5868. // FILE *file;
  5869. char dir[256];
  5870. int lastcmd, lastanm, i;
  5871. //CMD_LINE res[RES_NUM];
  5872. CMD_LINE *res = NULL;
  5873. int lastabv = -1;
  5874. char in, click = 0;
  5875. int anmid = -1, resid = -1, anbind = -1;
  5876. int bind;
  5877. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  5878. if (!res) {
  5879. kprintf(1, "RunMenuLoadGame: Out of Memory");
  5880. return;
  5881. }
  5882. else
  5883. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  5884. //bBackDC = 1;
  5885. //ddxCleareSurface(FontDC);
  5886. //ddxCleareSurface(BackDC);
  5887. ddxCleareSurface(BackDC);
  5888. ddxBitBlt(BackDC, 0, 0, ddxGetWidth(BackDC), ddxGetHight(BackDC), FontDC, 0,
  5889. 0);
  5890. ddxCleareSurface(FontDC);
  5891. //kprintf(1, "bitblt");
  5892. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM));
  5893. for (bind = 0; bind < RES_NUM; bind++) {
  5894. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  5895. res[bind].iAnim[lastcmd][0] = -1;
  5896. res[bind].iAnim[lastcmd][11] = -1;
  5897. }
  5898. for (in = 0; in < 6; in++)
  5899. res[bind].iParam[in] = -1;
  5900. res[bind].iLayer = 0;
  5901. }
  5902. lastcmd = 0;
  5903. timercnt = 0;
  5904. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  5905. working_file_translate(dir, 256);
  5906. chdir((dir));
  5907. //natadhe skript menu
  5908. LoadMenuScript(p_File_Name, res, &lastcmd);
  5909. //kprintf(1, "load");
  5910. in = 0;
  5911. fn_Set_Font(cFontFile[0]);
  5912. fn_Load_Bitmaps();
  5913. //kprintf(1, "fn_Set_Font");
  5914. CreateFontAnimations(res, &lastcmd);
  5915. fn_Release_Font(1);
  5916. //kprintf(1, "CreateFontAnimations");
  5917. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  5918. // animace na OnAbove
  5919. for (i = 0; i < lastcmd; i++) {
  5920. lastanm = 0;
  5921. switch (res[i].iParam[0]) {
  5922. case COM_DRAW:
  5923. {
  5924. if (!c) {
  5925. /* hdcBT = fn_CreateDC(_2dd.hDC, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  5926. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight, _2d_Find_Free_Surface());*/
  5927. /*hdcBT = fn_CreateDC(_2dd.hDC, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  5928. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight, ddxFindFreeSurface()); */
  5929. hdcBT = ddxCreateSurface(ddxGetWidth(res[i].iParam[1]),
  5930. ddxGetHight(res[i].iParam[1]), ddxFindFreeSurface());
  5931. /*BitBlt(hdcBT, 0, 0, _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  5932. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
  5933. _2dd.hDC, res[i].iParam[2], res[i].iParam[3], SRCCOPY); */
  5934. ddxBitBlt(hdcBT, 0, 0, ddxGetWidth(res[i].iParam[1]),
  5935. ddxGetHight(res[i].iParam[1]),
  5936. HDC2DD, res[i].iParam[2], res[i].iParam[3]);
  5937. /*BitBlt(BackDC,res[i].iParam[2], res[i].iParam[3], _2dd.bitmap[res[i].iParam[1]].bitmap.bmWidth,
  5938. _2dd.bitmap[res[i].iParam[1]].bitmap.bmHeight,
  5939. _2dd.bitmap[res[i].iParam[1]].bitmapDC, 0, 0, SRCCOPY); */
  5940. ddxTransparentBlt(BackDC, res[i].iParam[2], res[i].iParam[3],
  5941. ddxGetWidth(res[i].iParam[1]), ddxGetHight(res[i].iParam[1]),
  5942. res[i].iParam[1], 0, 0, ddxGetWidth(res[i].iParam[1]),
  5943. ddxGetHight(res[i].iParam[1]), TRANSCOLOR);
  5944. //menucommand_DrawT(_2dd.hDC, res[i].iParam);
  5945. idx = i;
  5946. }
  5947. else {
  5948. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  5949. //menucommand_DrawT(BackDC, res[i].iParam);
  5950. }
  5951. //menucommand_DrawT(_2dd.hDC, res[i].iParam);
  5952. c++;
  5953. }
  5954. break;
  5955. case COM_RANDOMANIMATION:
  5956. case COM_ONCLICK:
  5957. case COM_ONABOVE:
  5958. case COM_RUNANIMATION:
  5959. case COM_BINDEXITANIMATION:
  5960. case COM_BINDANIMATION:
  5961. //nahrati animace k udalosti OnAbove
  5962. LoadAnimationMenuScript(res, i, &lastanm);
  5963. break;
  5964. }
  5965. }
  5966. BEGIN_MENU_NEWGAME:
  5967. bBackDC = 1;
  5968. //TransparentBltU(_2dd.hDC, 0, 0, 1024, 768, BackDC, 0, 0, 1024, 768, RGB(255, 0, 255));
  5969. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  5970. TRANSCOLOR);
  5971. DisplayFrame();
  5972. for (i = 0; i < lastcmd; i++)
  5973. if (res[i].iParam[0] == COM_RUNANIMATION) {
  5974. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  5975. if (iWave != -1) {
  5976. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  5977. anm[iWave].iWave = res[i + 1].iParam[5] =
  5978. mPlaySound(&res[i + 1], p_ad, 2);
  5979. }
  5980. }
  5981. dim.t1 = 0;
  5982. dim.t2 = 0;
  5983. dim.dx = 0;
  5984. dim.dy = 0;
  5985. anmid = -1;
  5986. resid = -1;
  5987. anbind = -1;
  5988. bind = -1;
  5989. lastabv = -1;
  5990. in = 0;
  5991. spracuj_spravy(0);
  5992. while (!key[K_ESC]) {
  5993. dwStart = timeGetTime();
  5994. //pohnul mysi
  5995. if (dim.dx || dim.dy) {
  5996. //dostala se mys do akcni oblasti (OnAbove)?
  5997. if (!click)
  5998. for (i = 0; i < lastcmd; i++)
  5999. if (res[i].iParam[0] == COM_ONABOVE) {
  6000. if ((dim.x >= res[i].iParam[1]) &&
  6001. (dim.x <= res[i].iParam[3]) &&
  6002. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  6003. //spusteni animace v OnAbove
  6004. if (i != lastabv) {
  6005. if (in) {
  6006. Stop(&res[lastabv]);
  6007. if (!res[lastabv].iLayer) {
  6008. //menucommand_Draw(_2dd.hDC, res[lastabv].iAnim[0], 0);
  6009. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  6010. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  6011. }
  6012. else {
  6013. //menucommand_DrawT(_2dd.hDC, res[lastabv].iAnim[0]);
  6014. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  6015. TRANSCOLOR);
  6016. //menucommand_Draw(FontDC, res[lastabv].iAnim[0], 3);
  6017. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  6018. }
  6019. }
  6020. CheckAnimation(&res[i], p_ad);
  6021. lastabv = i;
  6022. AddAnimation(&res[i], p_ad, 0, 1);
  6023. in = 1;
  6024. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  6025. if (bind != -1) {
  6026. CheckAnimation(&res[bind], p_ad);
  6027. AddAnimation(&res[bind], p_ad, 1, 1);
  6028. anbind = bind;
  6029. mPlaySound(&res[bind], p_ad, 0);
  6030. }
  6031. strcpy(dir, res[i].cParam[1]);
  6032. }
  6033. }
  6034. else if (lastabv == i) {
  6035. // odesel z oblasti, ktera byla aktivni -> stop animace
  6036. // a odznaceni oblasti
  6037. Stop(&res[i]);
  6038. if (!res[i].iLayer) {
  6039. //menucommand_Draw(_2dd.hDC, res[i].iAnim[0], 0);
  6040. ddxDrawDisplay(res[i].iAnim[0], 0);
  6041. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  6042. }
  6043. else {
  6044. //menucommand_DrawT(_2dd.hDC, res[i].iAnim[0]);
  6045. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  6046. //menucommand_DrawT(FontDC, res[i].iAnim[0]);
  6047. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  6048. }
  6049. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  6050. if (bind != -1) {
  6051. int iAnim;
  6052. if (anbind != -1) {
  6053. Stop(&res[anbind]);
  6054. if (!res[i].iLayer) {
  6055. //menucommand_Draw(_2dd.hDC, res[anbind].iAnim[0], 0);
  6056. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  6057. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  6058. }
  6059. else {
  6060. //menucommand_DrawT(_2dd.hDC, res[anbind].iAnim[0]);
  6061. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  6062. TRANSCOLOR);
  6063. //menucommand_DrawT(FontDC, res[anbind].iAnim[0]);
  6064. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  6065. }
  6066. }
  6067. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  6068. if (iAnim != -1)
  6069. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  6070. }
  6071. lastabv = -1;
  6072. anbind = -1;
  6073. in = 0;
  6074. strcpy(dir, "");
  6075. }
  6076. }
  6077. dim.dx = 0;
  6078. dim.dy = 0;
  6079. }
  6080. //stlacil leve tlacitko
  6081. if (dim.t1 && !click) {
  6082. //dostala se mys do akcni oblasti (OnClick)?
  6083. for (i = 0; i < lastcmd; i++)
  6084. if (res[i].iParam[0] == COM_ONCLICK)
  6085. if ((dim.x >= res[i].iParam[1]) &&
  6086. (dim.x <= res[i].iParam[3]) &&
  6087. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  6088. if (res[i].iAnim[0][0] >= 0) {
  6089. //pokud je animace, tak ji spust
  6090. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  6091. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  6092. mPlaySound(&res[i + 1], p_ad, 1);
  6093. resid = i;
  6094. click = 1;
  6095. }
  6096. else {
  6097. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  6098. mPlaySound(&res[i + 1], p_ad, 1);
  6099. resid = i;
  6100. click = 1;
  6101. anmid = 31;
  6102. }
  6103. }
  6104. dim.t1 = 0;
  6105. }
  6106. //provedeni akce po animaci menu
  6107. if (click)
  6108. if (!anm[anmid].cmd) {
  6109. click = 0;
  6110. //StopAll();
  6111. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  6112. !strcmp(res[resid].cParam[1], "CANCEL")) {
  6113. key[K_ESC] = 1;
  6114. //break;
  6115. }
  6116. if (!strcmp(res[resid].cParam[1], "NEW_GAME")) {
  6117. iActualScene = 1;
  6118. StopAll();
  6119. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
  6120. NULL, 1);
  6121. key[K_ESC] = 1;
  6122. }
  6123. if (!strcmp(res[resid].cParam[1], "CHILD_SCENE")) {
  6124. RunMenuChildGame("Mmstart_child_game.txt", NULL, p_ad, cpu);
  6125. if (cRestartMainMenu) {
  6126. StopAll();
  6127. key[K_ESC] = 1;
  6128. }
  6129. }
  6130. if (!strcmp(res[resid].cParam[1], "TUTORIAL")) {
  6131. StopAll();
  6132. bBackDC = 0;
  6133. iActualScene = 0;
  6134. RunMenuNewGameScene("Mmnew_game_scene.txt", NULL, p_ad, cpu, 0,
  6135. NULL, 0);
  6136. key[K_ESC] = 1;
  6137. }
  6138. if (!cRestartMainMenu)
  6139. for (i = 0; i < lastcmd; i++) {
  6140. switch (res[i].iParam[0]) {
  6141. case COM_DRAW:
  6142. if (!res[i].iLayer) {
  6143. //menucommand_Draw(_2dd.hDC, res[i].iParam);
  6144. }
  6145. else {
  6146. ddxDrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  6147. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2,
  6148. TRANSCOLOR);
  6149. ddxDrawSurface(FontDC, res[i].iParam, 3);
  6150. }
  6151. break;
  6152. }
  6153. }
  6154. resid = -1;
  6155. if (key[K_ESC]) {
  6156. /*
  6157. for(i=0;i<lastcmd;i++)
  6158. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  6159. {
  6160. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  6161. res[i].iParam[5] = -1;
  6162. }
  6163. */
  6164. goto __QUIT;
  6165. }
  6166. else
  6167. goto BEGIN_MENU_NEWGAME;
  6168. }
  6169. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  6170. if (timercnt > 500) {
  6171. timercnt = 0;
  6172. for (i = 0; i < lastcmd; i++)
  6173. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  6174. if (rand() % 200 <= res[i].iParam[1] &&
  6175. strcmp(dir, res[i].cParam[0])) {
  6176. CheckAnimation(&res[i], p_ad);
  6177. AddAnimation(&res[i], p_ad, 0, 0);
  6178. }
  6179. }
  6180. dwStop = timeGetTime();
  6181. dwEplased += dwStop - dwStart;
  6182. spracuj_spravy(0);
  6183. ddxUpdateMouse();
  6184. AnimationEvent(dwStop, p_ad);
  6185. if (dim.tf1) {
  6186. dim.t1 = 1;
  6187. dim.tf1 = 0;
  6188. }
  6189. if (dim.tf2) {
  6190. dim.t2 = 1;
  6191. dim.tf2 = 0;
  6192. }
  6193. if (ddxRestore(p_ad)) {
  6194. cRestartMainMenu = 1;
  6195. key[K_ESC] = 1;
  6196. }
  6197. }
  6198. __QUIT:
  6199. ddxCleareSurface(FontDC);
  6200. if (!cRestartMainMenu)
  6201. ddxTransparentBltDisplay(0, 0, 1024, 768, BackDC, 0, 0, 1024, 768,
  6202. TRANSCOLOR);
  6203. ddxCleareSurface(BackDC);
  6204. bBackDC = 0;
  6205. if (!cRestartMainMenu) {
  6206. ddxBitBltDisplay(res[idx].iParam[2], res[idx].iParam[3],
  6207. ddxGetWidth(res[idx].iParam[1]),
  6208. ddxGetHight(res[idx].iParam[1]), hdcBT, 0, 0);
  6209. }
  6210. //BRUTAL_RELEASE .... nenicit
  6211. if (!cBrutalRestart)
  6212. ddxReleaseBitmap(hdcBT);
  6213. ddxCleareSurface(CompositDC);
  6214. key[K_ESC] = 0;
  6215. FreeAnimations(res, RES_NUM);
  6216. free((void *) res);
  6217. }
  6218. int LoadCList(char *cFile, int *p_count, int *p_bmp, int *iClock,
  6219. APAK_HANDLE * hArchive)
  6220. {
  6221. int c = 0, i = -1, t;
  6222. char text[256];
  6223. FILE *file;
  6224. file = aopen(pBmpArchive, cFile, "r");
  6225. if (!file)
  6226. return -1;
  6227. while (!aeof(file)) {
  6228. memset(text, 0, 256);
  6229. agets(text, 256, file);
  6230. if (strlen(text)) {
  6231. text[strlen(text) - 1] = '\0';
  6232. if (!c) {
  6233. i = ddxLoadBitmap(text, hArchive);
  6234. p_bmp[c] = i;
  6235. }
  6236. else {
  6237. t = ddxLoadBitmap(text, hArchive);
  6238. p_bmp[c] = t;
  6239. }
  6240. DrawClock(iClock, 0);
  6241. c++;
  6242. }
  6243. }
  6244. aclose(file);
  6245. pBmpArchive->bError = 0;
  6246. (*p_count) = c;
  6247. return i;
  6248. }
  6249. int GetComixTime(int iScene)
  6250. {
  6251. char text[256];
  6252. int i;
  6253. FILE *file;
  6254. file = aopen(pDataArchive, "comix_times.txt", "r");
  6255. if (!file)
  6256. return 1000;
  6257. for (i = 0; i < iScene + 1; i++)
  6258. agets(text, 256, file);
  6259. aclose(file);
  6260. return atoi(text);
  6261. }
  6262. int RunMenuComixB(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int iScene)
  6263. {
  6264. DWORD dwEplased = 0, dwStart, dwStop;
  6265. FILE *file;
  6266. char dir[256];
  6267. int lastcmd, lastanm, i, j;
  6268. CMD_LINE *res = NULL;
  6269. int lastabv = -1;
  6270. char in, click = 0;
  6271. int anmid = -1, resid = -1, anbind = -1;
  6272. int bind;
  6273. int cc = 0;
  6274. int iTVBmp = -1;
  6275. int iTVTBmp = -1;
  6276. int iTVBut = -1;
  6277. int iComix = -1;
  6278. char ccomix[64];
  6279. int y = 0;
  6280. int iSongTime = 1000;
  6281. int ccc;
  6282. int iClock;
  6283. iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
  6284. ddxResizeCursorBack(iClock);
  6285. DrawClock(&iClock, 0);
  6286. /*
  6287. if(ogg_playing())
  6288. {
  6289. float f;
  6290. f = p_ad->Music_Gain;
  6291. while(f >= 0.05f)
  6292. {
  6293. f -= 0.05f;
  6294. ogg_gain(f);
  6295. Sleep(25);
  6296. }
  6297. ap_Stop_Song(p_ad);
  6298. }
  6299. */
  6300. Sleep(1000);
  6301. bBackDC = 0;
  6302. res = (CMD_LINE *) malloc(RES_NUM * sizeof(CMD_LINE));
  6303. if (!res) {
  6304. kprintf(1, "RunMenuSceneMap: Out of Memory");
  6305. return 0;
  6306. }
  6307. _2d_Clear_RectLine(&rline);
  6308. ddxSetFlip(TRUE);
  6309. cc = 0;
  6310. anmid = -1;
  6311. resid = -1;
  6312. anbind = -1;
  6313. ZeroMemory(res, RES_NUM * sizeof(CMD_LINE));
  6314. ddxCleareSurface(CompositDC);
  6315. ddxCleareSurface(FontDC);
  6316. DrawClock(&iClock, 0);
  6317. iTVBmp = ddxLoadBitmap("televize.bmp", pBmpArchive);
  6318. iTVTBmp = ddxLoadBitmap("televizet.bmp", pBmpArchive);
  6319. DrawClock(&iClock, 0);
  6320. iTVBut = LoadCList("telload.txt", &ccc, &ccc, &ccc, pBmpArchive);
  6321. sprintf(ccomix, "comix%d.bmp", iScene);
  6322. //iComix = LoadCList(ccomix);
  6323. iComix = ddxLoadBitmap(ccomix, pBmpArchive);
  6324. if (iTVBmp == -1 || iTVBut == -1 || iComix == -1 || iTVTBmp == -1) {
  6325. kprintf(1, "saaaaakra ... nepodarilo se nahrat nejakou grafiku na comix");
  6326. return 0;
  6327. }
  6328. for (bind = 0; bind < RES_NUM; bind++) {
  6329. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  6330. res[bind].iAnim[lastcmd][0] = -1;
  6331. res[bind].iAnim[lastcmd][11] = -1;
  6332. }
  6333. for (in = 0; in < 6; in++)
  6334. res[bind].iParam[in] = -1;
  6335. res[bind].pCmdLine = res;
  6336. }
  6337. lastcmd = 0;
  6338. timercnt = 0;
  6339. GetPrivateProfileString("game", "data_dir", "c:\\", dir, 256, ini_file);
  6340. working_file_translate(dir, 256);
  6341. chdir((dir));
  6342. //natadhe skript menu
  6343. LoadMenuScript(p_File_Name, res, &lastcmd);
  6344. in = 0;
  6345. //kerekce televize
  6346. res[0].iParam[1] = iTVBmp;
  6347. //korekce animace komixu;
  6348. //strcpy(res[1].cParam[0], ccomix);
  6349. DrawClock(&iClock, 0);
  6350. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  6351. // animace na OnAbove
  6352. for (i = 0; i < lastcmd; i++) {
  6353. lastanm = 0;
  6354. switch (res[i].iParam[0]) {
  6355. case COM_DRAW:
  6356. if (!res[i].iLayer)
  6357. ddxDrawSurface(BackDC, res[i].iParam, 0);
  6358. else {
  6359. ddxDrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR);
  6360. ddxDrawSurface(FontDC, res[i].iParam, 3);
  6361. }
  6362. break;
  6363. case COM_RANDOMANIMATION:
  6364. case COM_ONCLICK:
  6365. case COM_ONABOVE:
  6366. case COM_RUNANIMATION:
  6367. case COM_BINDEXITANIMATION:
  6368. case COM_BINDANIMATION:
  6369. file = aopen(pDataArchive, res[i].cParam[0], "r");
  6370. if (file) {
  6371. while (!aeof(file)) {
  6372. Parse_AnimLine(file, res[i].iAnim[lastanm], 18);
  6373. lastanm++;
  6374. }
  6375. aclose(file);
  6376. for (j = 0; j < lastanm; j++)
  6377. res[i].iAnim[j][1] += iTVBut;
  6378. }
  6379. cc++;
  6380. break;
  6381. }
  6382. }
  6383. DrawClock(&iClock, 0);
  6384. ddxSetCursor(0);
  6385. DisplayFrame();
  6386. DisplayFrame();
  6387. ddxResizeCursorBack(0);
  6388. ddxSetCursorSurface(0);
  6389. ddxSetCursor(1);
  6390. DisplayFrame();
  6391. DisplayFrame();
  6392. ddxReleaseBitmap(iClock);
  6393. ddxBitBltDisplay(0, 0, 1024, 768, BackDC, 0, 0);
  6394. ddxCleareSurface(BackDC);
  6395. ddxTransparentBlt(FontDC, 0, 0, 1024, 768, iTVTBmp, 0, 0, 1024, 768,
  6396. TRANSCOLOR);
  6397. _2d_Clear_RectLine(&rline);
  6398. for (i = 0; i < lastcmd; i++)
  6399. if (res[i].iParam[0] == COM_RUNANIMATION) {
  6400. int iWave = AddAnimation(&res[i], p_ad, 0, 0);
  6401. if (iWave != -1) {
  6402. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  6403. anm[iWave].iWave = res[i + 1].iParam[5] =
  6404. mPlaySound(&res[i + 1], p_ad, 2);
  6405. }
  6406. }
  6407. dim.t1 = 0;
  6408. dim.t2 = 0;
  6409. dim.dx = 0;
  6410. dim.dy = 0;
  6411. anmid = -1;
  6412. resid = -1;
  6413. anbind = -1;
  6414. bind = -1;
  6415. lastabv = -1;
  6416. in = 0;
  6417. spracuj_spravy(0);
  6418. /*
  6419. if(ogg_playing())
  6420. ap_Stop_Song(p_ad);
  6421. */
  6422. iSongTime = GetComixTime(iScene);
  6423. //ap_Play_Song(iScene+1,0, p_ad);
  6424. /* if (p_ad->bAudio && p_ad->Music_Gain >= 0.05f)
  6425. ap_Setup_and_Play_Song(iScene+1,0, p_ad);
  6426. if (p_ad->bAudio && p_ad->Music_Gain >= 0.05f)
  6427. adas_OGG_Play_Stream();*/
  6428. dwLTime = timeGetTime();
  6429. ddxSetFlip(FALSE);
  6430. dwStart = timeGetTime();
  6431. while (!key[K_ESC]) {
  6432. //pohnul mysi
  6433. if (dim.dx || dim.dy) {
  6434. //dostala se mys do akcni oblasti (OnAbove)?
  6435. if (!click)
  6436. for (i = 0; i < lastcmd; i++)
  6437. if (res[i].iParam[0] == COM_ONABOVE) {
  6438. if ((dim.x >= res[i].iParam[1]) &&
  6439. (dim.x <= res[i].iParam[3]) &&
  6440. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  6441. //spusteni animace v OnAbove
  6442. if (i != lastabv) {
  6443. if (in) {
  6444. if (res[lastabv].iAnim[0][0] != -1) {
  6445. Stop(&res[lastabv]);
  6446. if (!res[lastabv].iLayer) {
  6447. ddxDrawDisplay(res[lastabv].iAnim[0], 0);
  6448. ddxDrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  6449. }
  6450. else {
  6451. ddxDrawDisplayColorKey(res[lastabv].iAnim[0], 0,
  6452. TRANSCOLOR);
  6453. ddxDrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  6454. }
  6455. }
  6456. }
  6457. CheckAnimation(&res[i], p_ad);
  6458. lastabv = i;
  6459. AddAnimation(&res[i], p_ad, 0, 1);
  6460. in = 1;
  6461. bind = ChooseBidedAnimation(res, i + 1, p_ad);
  6462. if (bind != -1) {
  6463. CheckAnimation(&res[bind], p_ad);
  6464. AddAnimation(&res[bind], p_ad, 1, 1);
  6465. anbind = bind;
  6466. mPlaySound(&res[bind], p_ad, 0);
  6467. }
  6468. strcpy(dir, res[i].cParam[1]);
  6469. }
  6470. }
  6471. else if (lastabv == i) {
  6472. // odesel z oblasti, ktera byla aktivni -> stop animace
  6473. // a odznaceni oblasti
  6474. Stop(&res[i]);
  6475. if (res[i].iAnim[0][0] != -1) {
  6476. if (!res[i].iLayer) {
  6477. ddxDrawDisplay(res[i].iAnim[0], 0);
  6478. ddxDrawSurface(CompositDC, res[i].iAnim[0], 3);
  6479. }
  6480. else {
  6481. ddxDrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  6482. ddxDrawSurface(FontDC, res[i].iAnim[0], 3);
  6483. }
  6484. }
  6485. bind = ChooseBidedExitAnimation(res, i + 1, p_ad);
  6486. if (bind != -1) {
  6487. int iAnim;
  6488. if (anbind != -1) {
  6489. Stop(&res[anbind]);
  6490. if (!res[anbind].iLayer) {
  6491. ddxDrawDisplay(res[anbind].iAnim[0], 0);
  6492. ddxDrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  6493. }
  6494. else {
  6495. ddxDrawDisplayColorKey(res[anbind].iAnim[0], 0,
  6496. TRANSCOLOR);
  6497. ddxDrawSurface(FontDC, res[anbind].iAnim[0], 3);
  6498. }
  6499. }
  6500. iAnim = AddAnimation(&res[bind], p_ad, 1, 1);
  6501. if (iAnim != -1)
  6502. anm[iAnim].iWave = mPlaySound(&res[bind], p_ad, 2);
  6503. }
  6504. lastabv = -1;
  6505. anbind = -1;
  6506. in = 0;
  6507. strcpy(dir, "");
  6508. }
  6509. }
  6510. }
  6511. //stlacil leve tlacitko
  6512. if (dim.t1 && !click) {
  6513. //dostala se mys do akcni oblasti (OnClick)?
  6514. for (i = 0; i < lastcmd; i++)
  6515. if (res[i].iParam[0] == COM_ONCLICK)
  6516. if ((dim.x >= res[i].iParam[1]) &&
  6517. (dim.x <= res[i].iParam[3]) &&
  6518. (dim.y >= res[i].iParam[2]) && (dim.y <= res[i].iParam[4])) {
  6519. if (res[i].iAnim[0][0] >= 0) {
  6520. //pokud je animace, tak ji spust
  6521. anmid = AddAnimation(&res[i], p_ad, 0, 1);
  6522. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  6523. mPlaySound(&res[i + 1], p_ad, 1);
  6524. resid = i;
  6525. click = 1;
  6526. }
  6527. else {
  6528. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  6529. mPlaySound(&res[i + 1], p_ad, 1);
  6530. resid = i;
  6531. click = 1;
  6532. anmid = 31;
  6533. }
  6534. }
  6535. dim.t1 = 0;
  6536. }
  6537. //provedeni akce po animaci menu
  6538. if (click)
  6539. if (!anm[anmid].cmd) {
  6540. click = 0;
  6541. StopAll();
  6542. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  6543. !strcmp(res[resid].cParam[1], "CANCEL")) {
  6544. key[K_ESC] = 1;
  6545. cRestartMainMenu = 1;
  6546. }
  6547. resid = -1;
  6548. if (key[K_ESC]) {
  6549. /* for(i=0;i<lastcmd;i++)
  6550. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  6551. {
  6552. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  6553. res[i].iParam[5] = -1;
  6554. }
  6555. */
  6556. goto __QUIT;
  6557. }
  6558. }
  6559. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  6560. if (timercnt > 500) {
  6561. timercnt = 0;
  6562. for (i = 0; i < lastcmd; i++)
  6563. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  6564. if (rand() % 200 <= res[i].iParam[1] &&
  6565. strcmp(dir, res[i].cParam[0])) {
  6566. CheckAnimation(&res[i], p_ad);
  6567. AddAnimation(&res[i], p_ad, 0, 0);
  6568. }
  6569. }
  6570. //dwStop = timeGetTime();
  6571. //dwEplased += dwStop - dwLTime;
  6572. //dwStart = timeGetTime();
  6573. spracuj_spravy(0);
  6574. ddxUpdateMouse();
  6575. {
  6576. RECT rr;
  6577. rr.left = 124;
  6578. rr.top = 161;
  6579. rr.right = 700;
  6580. rr.bottom = 549;
  6581. y =
  6582. (int) ftoi((dwEplased * (ddxGetHight(iComix) -
  6583. 550)) / (float) iSongTime);
  6584. if (y >= ddxGetHight(iComix) - 550)
  6585. key[K_ESC] = 1;
  6586. ddxBitBlt(CompositDC, 124, 161, ddxGetWidth(iComix), 549, iComix, 0, y);
  6587. _2d_Add_RectItem(&rline, rr, 0);
  6588. }
  6589. AnimationEvent(dwStop, p_ad);
  6590. if (dim.tf1) {
  6591. dim.t1 = 1;
  6592. dim.tf1 = 0;
  6593. }
  6594. if (dim.tf2) {
  6595. dim.t2 = 1;
  6596. dim.tf2 = 0;
  6597. }
  6598. dwStop = timeGetTime();
  6599. dwEplased = dwStop - dwStart;
  6600. //kprintf(1, "%d", dwEplased);
  6601. if (ddxRestore(p_ad))
  6602. return 1;
  6603. }
  6604. __QUIT:
  6605. //kprintf(1, "%d", dwEplased);
  6606. /*
  6607. adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
  6608. adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
  6609. */
  6610. StopAll();
  6611. ddxReleaseBitmap(iTVBmp);
  6612. ddxReleaseBitmap(iTVTBmp);
  6613. for (i = iTVBut; i < iTVBut + 9; i++)
  6614. ddxReleaseBitmap(i);
  6615. ddxReleaseBitmap(iComix);
  6616. ddxCleareSurface(FontDC);
  6617. ddxCleareSurface(BackDC);
  6618. ddxCleareSurface(CompositDC);
  6619. key[K_ESC] = 0;
  6620. FreeAnimations(res, RES_NUM);
  6621. free((void *) res);
  6622. /*
  6623. if(ogg_playing())
  6624. ap_Stop_Song(p_ad);
  6625. */
  6626. //ap_Play_Song(0, 0, p_ad);
  6627. ddxSetFlip(TRUE);
  6628. return 0;
  6629. }
  6630. int RunMenuComix(char *p_File_Name, HWND hWnd, AUDIO_DATA * p_ad, int iScene)
  6631. {
  6632. DWORD dwEplased = 0, dwStart, dwStop;
  6633. int iComix = -1;
  6634. char ccomix[64];
  6635. int iSongTime = 1000;
  6636. int bmpc = 0;
  6637. int iClock;
  6638. int idx = -1;
  6639. int lidx = -1;
  6640. int bmp[64];
  6641. int i;
  6642. APAK_HANDLE *hArchive = NULL;
  6643. char cFile[MAX_PATH];
  6644. char cDir[MAX_PATH];
  6645. if (iLanguageVersion == 4) {
  6646. GetPrivateProfileString("game", "bitmap_dir", "c:\\", cDir, MAX_PATH,
  6647. ini_file);
  6648. working_file_translate(cDir, MAX_PATH);
  6649. //sprintf(cFile, "%s\\scene%d.pak", cDir, iScene); - DIR?
  6650. sprintf(cFile, "%s/scene%d.pak", cDir, iScene);
  6651. apak_dir_correction(cDir);
  6652. hArchive = apakopen(cFile, cDir, &idx);
  6653. if (!hArchive) {
  6654. kprintf(1, "Nepodarilo se otevrit archiv [%s]\n", cFile);
  6655. return 0;
  6656. }
  6657. else
  6658. hArchive->pActualNode = hArchive->pRootNode->pNextNode;
  6659. }
  6660. cCheckMusicExeption = 1;
  6661. for (i = 0; i < 64; i++)
  6662. bmp[i] = -1;
  6663. ddxSetFlip(0);
  6664. iClock = ddxLoadBitmap("clock1-1.bmp", pBmpArchive);
  6665. ddxResizeCursorBack(iClock);
  6666. DrawClock(&iClock, 0);
  6667. /*
  6668. if(ogg_playing())
  6669. {
  6670. float f;
  6671. f = p_ad->Music_Gain;
  6672. while(f >= 0.05f)
  6673. {
  6674. f -= 0.05f;
  6675. ogg_gain(f);
  6676. Sleep(25);
  6677. }
  6678. ap_Stop_Song(p_ad);
  6679. }
  6680. */
  6681. ddxSetFlip(0);
  6682. DrawClock(&iClock, 0);
  6683. sprintf(ccomix, "comix%d.txt", iScene);
  6684. if (iLanguageVersion == 4) {
  6685. iComix = LoadCList(ccomix, &bmpc, bmp, &iClock, hArchive);
  6686. apakclose(hArchive);
  6687. }
  6688. else
  6689. iComix = LoadCList(ccomix, &bmpc, bmp, &iClock, pBmpArchive);
  6690. DrawClock(&iClock, 0);
  6691. ddxSetCursor(0);
  6692. DisplayFrame();
  6693. DisplayFrame();
  6694. ddxResizeCursorBack(0);
  6695. ddxSetCursorSurface(0);
  6696. ddxSetCursor(1);
  6697. DisplayFrame();
  6698. DisplayFrame();
  6699. ddxReleaseBitmap(iClock);
  6700. ddxSetCursor(0);
  6701. spracuj_spravy(0);
  6702. if (ogg_playing())
  6703. ap_Stop_Song(p_ad);
  6704. iSongTime = GetComixTime(iScene);
  6705. //ap_Play_Song(iScene+1,0, p_ad);
  6706. dwStart = timeGetTime();
  6707. while (!key[K_ESC]) {
  6708. spracuj_spravy(0);
  6709. dwStop = timeGetTime();
  6710. dwEplased = dwStop - dwStart;
  6711. if (dwEplased >= (unsigned) iSongTime)
  6712. break;
  6713. lidx = idx;
  6714. idx = (int) floor((dwEplased * bmpc) / (float) iSongTime);
  6715. if (lidx != idx) {
  6716. lidx = idx;
  6717. if (idx >= 0 && idx < 64)
  6718. if (bmp[idx] != -1) {
  6719. ddxBitBltDisplay(0, 0, 1024, 768, bmp[idx], 0, 0);
  6720. DisplayFrame();
  6721. }
  6722. else
  6723. break;
  6724. else
  6725. break;
  6726. }
  6727. if (key[K_SPACE]) {
  6728. key[K_SPACE] = 0;
  6729. do {
  6730. dwStart -= 1000;
  6731. dwEplased = dwStop - dwStart;
  6732. idx = (int) floor((dwEplased * bmpc) / (float) iSongTime);
  6733. }
  6734. while (idx == lidx);
  6735. dwStart -= ftoi(iSongTime / (float) bmpc);
  6736. }
  6737. if (ddxRestore(p_ad)) {
  6738. cCheckMusicExeption = 0;
  6739. return 1;
  6740. }
  6741. }
  6742. /*
  6743. adas_Release_Source(-1, ALL_TYPES, UNDEFINED_VALUE);
  6744. adas_Release_Source(ALL_SOUND_SOURCES, ALL_TYPES,UNDEFINED_VALUE);
  6745. */
  6746. key[K_ESC] = 0;
  6747. for (i = 0; i < 64; i++)
  6748. if (bmp[i] != -1)
  6749. ddxReleaseBitmap(bmp[i]);
  6750. /*
  6751. if(ogg_playing())
  6752. {
  6753. float f;
  6754. f = p_ad->Music_Gain;
  6755. while(f >= 0.05f)
  6756. {
  6757. f -= 0.05f;
  6758. ogg_gain(f);
  6759. Sleep(25);
  6760. }
  6761. ap_Stop_Song(p_ad);
  6762. }
  6763. */
  6764. Sleep(1000);
  6765. //ap_Play_Song(0, 0, p_ad);
  6766. ddxCleareSurfaceColorDisplay(0);
  6767. DisplayFrame();
  6768. ddxCleareSurfaceColorDisplay(0);
  6769. ddxSetFlip(1);
  6770. ddxSetCursor(1);
  6771. cCheckMusicExeption = 0;
  6772. return 0;
  6773. }
  6774. char MenuCheckBossExit(void)
  6775. {
  6776. spracuj_spravy(0);
  6777. if ((key[K_SHIFT] || key[K_SHFT_P]) && key[K_F11])
  6778. return 1;
  6779. else
  6780. return 0;
  6781. }
  6782. char MenuCheckSuccessExit(void)
  6783. {
  6784. spracuj_spravy(0);
  6785. if (key[K_CTRL] && key[K_E])
  6786. return 1;
  6787. else
  6788. return 0;
  6789. }