Menu2.cpp 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030
  1. //------------------------------------------------------------------------------------------------
  2. // 0.0.1
  3. //------------------------------------------------------------------------------------------------
  4. #include <stdio.h>
  5. #include "3d_all.h"
  6. #include "Berusky3d_kofola_interface.h"
  7. #include "Berusky3d_kofola2d.h"
  8. #include "game_logic.h"
  9. #include "menu_script.h"
  10. #include "Command.h"
  11. #include "3D_graphic.h"
  12. #include "Menu.h"
  13. #include "Menu2.h"
  14. #include "Comics.h"
  15. #include "credits.h"
  16. #include "font3d.h"
  17. #include "controls3d.h"
  18. #include "menu_def.h"
  19. #include "Setup.h"
  20. #include "profiles.h"
  21. #include "Object.h"
  22. #include "animationk.h"
  23. #include "Demo.h"
  24. #include "load_level.h"
  25. #include "ambient_sounds.h"
  26. #include "Tools.h"
  27. #define RES_NUM 60
  28. #define HDC2DD -1
  29. extern SETUP setup;
  30. extern _3D_CURSOR _3dCur;
  31. extern char pBmpDir[MAX_FILENAME];
  32. extern PLAYER_PROFILE pPlayerProfile;
  33. extern char p3DMDir[MAX_FILENAME];
  34. extern int iActualLevel;
  35. extern int iActualScene;
  36. extern B2_FONT b2_3d_font;
  37. extern char cFontDir[5][64];
  38. extern AUDIO_DATA ad;
  39. typedef struct
  40. {
  41. CMD_LINE *cmd;
  42. int iWave;
  43. char bStop;
  44. } ANIMATION;
  45. extern HW_KONFIG hwconf;
  46. static ANIMATION anm[32];
  47. static DWORD timercnt = 0;
  48. static DWORD dwLTime;
  49. static int CompositDC;
  50. static int FontDC;
  51. static int BackDC;
  52. static int iCompositDC;
  53. static int iFontDC;
  54. //static int iBackDC;
  55. static char bBackDC = 0;
  56. static DeviceHandle iLoadScreenDevice = 0;
  57. static int iLoadScreenBitmap = K_CHYBA;
  58. static RECT iLoadScreenRect = { 0, 0, 1024, 768 };
  59. RECT_LINE rline;
  60. //extern int gi_EnumDisplaySettings(DEVMODE *pdevmode);
  61. int check_Save_Owner(char *cDir, WCHAR * wFileName);
  62. int LoadHelp(char *c_file);
  63. CMD_LINE *GetCMD2(CMD_LINE * cmp, CMD_LINE * pres)
  64. {
  65. int i;
  66. for (i = 0; i < RES_NUM; i++)
  67. if (!strcmp(cmp->cParam[1], pres[i].cParam[0]))
  68. return &pres[i];
  69. return NULL;
  70. }
  71. //------------------------------------------------------------------------------------------------
  72. // zastavi vsechny animace
  73. //------------------------------------------------------------------------------------------------
  74. void StopAll2(void)
  75. {
  76. int i;
  77. for (i = 0; i < 32; i++)
  78. if (anm[i].cmd)
  79. anm[i].bStop = 1;
  80. }
  81. //------------------------------------------------------------------------------------------------
  82. // zastavi animaci
  83. //------------------------------------------------------------------------------------------------
  84. void Stop2(CMD_LINE * cmd)
  85. {
  86. int i;
  87. for (i = 0; i < 32; i++)
  88. if (cmd == anm[i].cmd) {
  89. if (cmd->bEndActivate[0] && cmd->pCmdLine)
  90. cmd->pCmdLine[(int)cmd->bEndActivate[0]].bActive = 1;
  91. if (cmd->bEndActivate[1] && cmd->pCmdLine)
  92. cmd->pCmdLine[(int)cmd->bEndActivate[1]].bActive = 1;
  93. cmd->bActive = 0;
  94. anm[i].bStop = 1;
  95. return;
  96. }
  97. }
  98. int NextStep2(CMD_LINE * cmd)
  99. {
  100. if ((rand() % 100) < 60)
  101. return cmd->iAnim[cmd->iLastfrm][6];
  102. else
  103. return cmd->iAnim[cmd->iLastfrm][6 +
  104. rand() % (cmd->iAnim[cmd->iLastfrm][12])];
  105. }
  106. void DrawFrame2(CMD_LINE * cmd)
  107. {
  108. if (!cmd->iLayer) {
  109. if (cmd->iAnim[cmd->iLastfrm][6] >= 0) {
  110. RECT r;
  111. ddx2BitBlt(CompositDC,
  112. cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6],
  113. cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7],
  114. cmd->iAnim[cmd->iLastfrm][8], cmd->iAnim[cmd->iLastfrm][9],
  115. cmd->iAnim[cmd->iLastfrm][1],
  116. cmd->iAnim[cmd->iLastfrm][6], cmd->iAnim[cmd->iLastfrm][7]);
  117. r.left = cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6];
  118. r.top = cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7];
  119. r.right = cmd->iAnim[cmd->iLastfrm][8];
  120. r.bottom = cmd->iAnim[cmd->iLastfrm][9];
  121. ddx2AddRectItem(&rline, r, 1);
  122. }
  123. else
  124. ddx2DrawSurface(CompositDC, cmd->iAnim[cmd->iLastfrm], 1);
  125. }
  126. else
  127. ddx2DrawSurface(FontDC, cmd->iAnim[cmd->iLastfrm], 3);
  128. }
  129. //------------------------------------------------------------------------------------------------
  130. // provede animaci
  131. //------------------------------------------------------------------------------------------------
  132. void Animation2(CMD_LINE * cmd, int time)
  133. {
  134. ANIMATION_DRAW:
  135. while (time > 0) {
  136. if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
  137. Stop2(cmd);
  138. break;
  139. }
  140. time -= cmd->iAnim[cmd->iLastfrm][4];
  141. if (time > (cmd->iAnim[cmd->iAnim[cmd->iLastfrm][5]][4] / 2.0f)) {
  142. /* if(cmd->iAnim[cmd->iLastfrm][6] >= 0)
  143. cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);*/
  144. if (cmd->iAnim[cmd->iLastfrm][10] > 0)
  145. DrawFrame2(cmd);
  146. cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
  147. }
  148. }
  149. //----------------------------------------------------------------------
  150. DrawFrame2(cmd);
  151. if (!cmd->iAnim[cmd->iLastfrm][4]) {
  152. /* if(cmd->iAnim[cmd->iLastfrm][6] >= 0)
  153. cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);*/
  154. cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
  155. goto ANIMATION_DRAW;
  156. }
  157. if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
  158. Stop2(cmd);
  159. return;
  160. }
  161. /* if(cmd->iAnim[cmd->iLastfrm][6] >= 0)
  162. cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);*/
  163. cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
  164. }
  165. int RectCross2(RECT_LINE * p_rl, int idx)
  166. {
  167. int c = 0;
  168. int i;
  169. RECT *dr = &p_rl->rect[idx].rect;
  170. for (i = 0; i < rline.rlast; i++)
  171. if (i != idx)
  172. if (co2_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->top) ||
  173. co2_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->top) ||
  174. co2_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->bottom) ||
  175. co2_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->bottom))
  176. c++;
  177. return 0;
  178. }
  179. //------------------------------------------------------------------------------------------------
  180. // provede animace
  181. //------------------------------------------------------------------------------------------------
  182. void AnimationEvent2(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
  183. {
  184. DRAW_RECT *dr;
  185. int i;
  186. char bAnim = 0;
  187. DWORD e;
  188. //priprava
  189. //BitBltU(CompositDC,0,0,1024,768,NULL,0,0,WHITENESS);
  190. e = abs((int)(dwLTime - dwTime));
  191. for (i = 0; i < 32; i++)
  192. if (anm[i].cmd) {
  193. if (anm[i].bStop) {
  194. anm[i].cmd->iLastfrm = 1;
  195. anm[i].cmd->iCounter = 0;
  196. if(anm[i].iWave != -1)
  197. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, anm[i].iWave);
  198. anm[i].iWave = -1;
  199. anm[i].cmd = NULL;
  200. }
  201. else {
  202. anm[i].cmd->iCounter += e;
  203. if (anm[i].cmd->iCounter >=
  204. anm[i].cmd->iAnim[anm[i].cmd->iLastfrm][4]) {
  205. Animation2(anm[i].cmd, anm[i].cmd->iCounter);
  206. anm[i].cmd->iCounter = 0;
  207. bAnim = 1;
  208. }
  209. }
  210. }
  211. //prenos kreslenych dat;
  212. if (bAnim) {
  213. if (bBackDC) {
  214. for (i = 0; i < rline.rlast; i++) {
  215. dr = &rline.rect[i];
  216. ddx2TransparentBlt(BackDC, dr->rect.left, dr->rect.top, dr->rect.right, dr->rect.bottom, FontDC, dr->rect.left,
  217. dr->rect.top, TRANSCOLOR);
  218. }
  219. for (i = 0; i < rline.rlast; i++) {
  220. dr = &rline.rect[i];
  221. ddx2TransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
  222. dr->rect.right, dr->rect.bottom, BackDC, dr->rect.left,
  223. dr->rect.top, TRANSCOLOR);
  224. }
  225. }
  226. else
  227. for (i = 0; i < rline.rlast; i++) {
  228. dr = &rline.rect[i];
  229. ddx2TransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
  230. dr->rect.right, dr->rect.bottom, FontDC, dr->rect.left,
  231. dr->rect.top, TRANSCOLOR);
  232. }
  233. for (i = 0; i < rline.rlast; i++) {
  234. dr = &rline.rect[i];
  235. // ddx2UpdateMouse();
  236. //if(dr->iLayer >= 1 || RectCross(&rline, i))
  237. ddx2TransparentBltDisplay(dr->rect.left, dr->rect.top, dr->rect.right,
  238. dr->rect.bottom, CompositDC, dr->rect.left, dr->rect.top,
  239. dr->rect.right, dr->rect.bottom, TRANSCOLOR);
  240. }
  241. }
  242. dwLTime = dwTime;
  243. timercnt += e;
  244. //_2d_Clear_RectLine(&rline);
  245. }
  246. void InitRandomJumps2(CMD_LINE * cmd)
  247. {
  248. int i;
  249. for (i = 0; i < 200; i++)
  250. if (cmd->iAnim[i][6] >= 0)
  251. cmd->iAnim[i][5] = cmd->iAnim[i][6 + rand() % (cmd->iAnim[i][12])];
  252. }
  253. int FindAnimation2(CMD_LINE * cmd)
  254. {
  255. int i;
  256. for (i = 0; i < 32; i++)
  257. if (anm[i].cmd == cmd)
  258. return 1;
  259. return 0;
  260. }
  261. //------------------------------------------------------------------------------------------------
  262. // prida animaci
  263. //------------------------------------------------------------------------------------------------
  264. int AddAnimation2(CMD_LINE * cmd, AUDIO_DATA * p_ad, char bOnlyOnes)
  265. {
  266. int i, r;
  267. float pos[3] = { 0.0f, 0.0f, 1.0f };
  268. for (i = 0; i < 32; i++)
  269. if (!anm[i].cmd) {
  270. if (bOnlyOnes && FindAnimation2(cmd))
  271. return -1;
  272. // InitRandomJumps(cmd);
  273. anm[i].cmd = cmd;
  274. anm[i].bStop = 0;
  275. anm[i].iWave = -1;
  276. Animation2(anm[i].cmd, 0);
  277. if (cmd->iParam[0] == COM_RANDOMANIMATION) {
  278. r = rand() % 3;
  279. if (cmd->iParam[r + 2] < 0) {
  280. if (cmd->iParam[2] >= 0) {
  281. adas_Get_Listener_Position(pos);
  282. ap_Play_Sound(0,1,0,pos,cmd->iParam[2], NULL, &ad);
  283. }
  284. }
  285. else {
  286. adas_Get_Listener_Position(pos);
  287. ap_Play_Sound(0,1,0,pos,cmd->iParam[r+2], NULL, &ad);
  288. }
  289. }
  290. return i;
  291. }
  292. else if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0]) && !anm[i].bStop)
  293. return -1;
  294. return -1;
  295. }
  296. int ChooseBidedExitAnimation2(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
  297. {
  298. int id[32];
  299. int i, c = 0;
  300. for (i = Index; i < 32; i++)
  301. if (cmd[i].iParam[0] == COM_BINDEXITANIMATION) {
  302. id[c] = i;
  303. c++;
  304. if (c > 31)
  305. break;
  306. }
  307. else if (cmd[i].iParam[0] != COM_BINDANIMATION)
  308. break;
  309. if (c)
  310. return id[rand() % c];
  311. else
  312. return -1;
  313. }
  314. int ChooseBidedAnimation2(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
  315. {
  316. int id[32];
  317. int i, c = 0;
  318. for (i = Index; i < 32; i++)
  319. if (cmd[i].iParam[0] == COM_BINDANIMATION) {
  320. id[c] = i;
  321. c++;
  322. if (c > 31)
  323. break;
  324. }
  325. else if (cmd[i].iParam[0] != COM_BINDEXITANIMATION)
  326. break;
  327. if (c)
  328. return id[rand() % c];
  329. else
  330. return -1;
  331. }
  332. void FreeAnimations2(CMD_LINE * cmd, int csize)
  333. {
  334. int i, j;
  335. for (i = 0; i < csize; i++)
  336. for (j = 0; j < 32; j++)
  337. if (anm[j].cmd)
  338. if (anm[j].cmd == &cmd[i]) {
  339. anm[j].cmd->iLastfrm = 1;
  340. anm[j].cmd->iCounter = 0;
  341. anm[j].iWave = -1;
  342. anm[j].cmd = NULL;
  343. }
  344. }
  345. //------------------------------------------------------------------------------------------------
  346. // prida animaci
  347. //------------------------------------------------------------------------------------------------
  348. void CheckAnimation2(CMD_LINE * cmd, AUDIO_DATA * p_ad)
  349. {
  350. int i;
  351. // float pos[3] = { 0.0f, 0.0f, 1.0f };
  352. for (i = 0; i < 32; i++)
  353. if (anm[i].cmd)
  354. if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0])) {
  355. Stop2(anm[i].cmd);
  356. if (!cmd->iLayer) {
  357. //menucommand_Draw(_2dd.hDC, anm[i].cmd->iAnim[0] , 0);
  358. ddx2DrawDisplay(anm[i].cmd->iAnim[0], 0);
  359. }
  360. else {
  361. //menucommand_DrawT(_2dd.hDC, anm[i].cmd->iAnim[0]);
  362. ddx2DrawDisplayColorKey(anm[i].cmd->iAnim[0], 0, TRANSCOLOR);
  363. //menucommand_Draw(FontDC, anm[i].cmd->iAnim[0], 3);
  364. ddx2DrawSurface(FontDC, anm[i].cmd->iAnim[0], 3);
  365. }
  366. return;
  367. }
  368. }
  369. //------------------------------------------------------------------------------------------------
  370. // spusti nahodny zvuk podle zadani
  371. //------------------------------------------------------------------------------------------------
  372. int mPlaySound2(CMD_LINE * cmd, AUDIO_DATA * p_ad, int type)
  373. {
  374. float pos[3] = { 0.0f, 0.0f, 1.0f };
  375. int r = rand() % 4, ret = 0;
  376. if (cmd->iParam[r + 1] < 0) {
  377. if (cmd->iParam[1] >= 0) {
  378. adas_Get_Listener_Position(pos);
  379. ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[1], NULL, &ad);
  380. }
  381. }
  382. else {
  383. adas_Get_Listener_Position(pos);
  384. ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[r+1], NULL, &ad);
  385. }
  386. return ret;
  387. }
  388. int CreateFontAnimations2(CMD_LINE * res, int *lastcmd, int ycor, char bcor)
  389. {
  390. int lcmd = *lastcmd;
  391. char text[256];
  392. RECT r = { 0, 0, 0, 0 };
  393. int i;
  394. int sidx1, sidx2;
  395. int y;
  396. int ret;
  397. for (i = 0; i < lcmd; i++)
  398. if (res[i].iParam[0] == COM_SETRECT) {
  399. r.left = res[i].iParam[1];
  400. r.top = res[i].iParam[2];
  401. r.right = res[i].iParam[3];
  402. r.bottom = res[i].iParam[4];
  403. if (bcor) {
  404. r.top += ycor;
  405. r.bottom += ycor;
  406. }
  407. }
  408. y = r.top;
  409. for (i = 0; i < lcmd; i++)
  410. if (res[i].iParam[0] == COM_CREATEBUTTON)
  411. if (fn2_Gen_Menu_Text(0, HDC2DD, res[i].cParam[0], &sidx1,
  412. &sidx2) != -1)
  413. if (sidx1 != -1 && sidx2 != -1) {
  414. int ii;
  415. int oy = res[i].iParam[2];
  416. //int x = r.left + ftoi((r.right - r.left - _2dd.bitmap[sidx1].bitmap.bmWidth) / (float)2.0f);
  417. int x =
  418. r.left + ftoi((r.right - r.left -
  419. ddx2GetWidth(sidx1)) / (float) 2.0f);
  420. if (bcor)
  421. oy += ycor;
  422. if (res[i].iParam[1] != -1) {
  423. oy = res[i].iParam[2];
  424. if (bcor)
  425. oy += ycor;
  426. y = oy;
  427. x = res[i].iParam[1];
  428. }
  429. y += ddx2GetHeight(sidx1);
  430. //OnAbove(16,661,100,748, quit_game.txt, NO_EXEPTION)
  431. sprintf(text, "OnAbove(%d,%d,%d,%d, NO_EXEPTION, NO_EXEPTION)", x, oy, x + ddx2GetWidth(sidx1), y);
  432. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0], res[*lastcmd].cParam[1]);
  433. res[*lastcmd].uiTimerID = 0;
  434. res[*lastcmd].iLastfrm = 1;
  435. res[*lastcmd].iCounter = 0;
  436. /*
  437. (0, 123, 0, 640, 0, 1)
  438. (1, 124, 0, 640, 25, 2)
  439. (2, 124, 0, 640, 25, -1)
  440. */
  441. res[*lastcmd].iAnim[0][0] = 0;
  442. res[*lastcmd].iAnim[0][1] = sidx1;
  443. res[*lastcmd].iAnim[0][2] = x;
  444. res[*lastcmd].iAnim[0][3] = oy;
  445. res[*lastcmd].iAnim[0][4] = 0;
  446. res[*lastcmd].iAnim[0][5] = 1;
  447. for (ii = 6; ii < 13; ii++)
  448. res[*lastcmd].iAnim[0][ii] = -1;
  449. x = r.left + ftoi((r.right - r.left - ddx2GetWidth(sidx2)) / (float) 2.0f);
  450. if (res[i].iParam[1] != -1)
  451. x = res[i].iParam[1];
  452. res[*lastcmd].iAnim[1][0] = 1;
  453. res[*lastcmd].iAnim[1][1] = sidx2;
  454. res[*lastcmd].iAnim[1][2] = x;
  455. res[*lastcmd].iAnim[1][3] = oy;
  456. res[*lastcmd].iAnim[1][4] = 50;
  457. res[*lastcmd].iAnim[1][5] = 2;
  458. for (ii = 6; ii < 13; ii++)
  459. res[*lastcmd].iAnim[1][ii] = -1;
  460. res[*lastcmd].iAnim[2][0] = 2;
  461. res[*lastcmd].iAnim[2][1] = sidx2;
  462. res[*lastcmd].iAnim[2][2] = x;
  463. res[*lastcmd].iAnim[2][3] = oy;
  464. res[*lastcmd].iAnim[2][4] = 50;
  465. res[*lastcmd].iAnim[2][5] = -1;
  466. for (ii = 6; ii < 13; ii++)
  467. res[*lastcmd].iAnim[2][ii] = -1;
  468. res[*lastcmd].iLayer = 1;
  469. (*lastcmd)++;
  470. //Draw(1,0,0)
  471. sprintf(text, "Draw(%d,%d,%d)", sidx1, x, oy);
  472. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  473. res[*lastcmd].cParam[1]);
  474. res[*lastcmd].iLayer = 1;
  475. (*lastcmd)++;
  476. //OnClick(16,661,100,748, quit_gamec.txt, EXIT)
  477. ret = snprintf(text, sizeof(text),
  478. "OnClick(%d,%d,%d,%d, NO_EXEPTION, %s)", x, oy,
  479. x + ddx2GetWidth(sidx1), y, res[i].cParam[1]);
  480. assert(ret < (int)sizeof(text));
  481. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  482. res[*lastcmd].cParam[1]);
  483. res[*lastcmd].iLayer = 1;
  484. (*lastcmd)++;
  485. //BindSound(54,55,56,-1)
  486. strcpy(text, "BindSound(54,55,56,-1)");
  487. Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
  488. res[*lastcmd].cParam[1]);
  489. res[*lastcmd].iLayer = 0;
  490. (*lastcmd)++;
  491. }
  492. return y;
  493. }
  494. void SetTab2(int iTab, int iLTab, CONTROL_LIST_ITEM2 * p_list, int lsize,
  495. int *hdcTab)
  496. {
  497. int i;
  498. if (iLTab > -1) {
  499. //BitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, _2dd.hDC, TAB_X, TAB_Y, SRCCOPY);
  500. ddx2BitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, HDC2DD, TAB_X, TAB_Y);
  501. }
  502. for (i = 0; i < lsize; i++)
  503. if ((p_list + i)->iTab == iTab && !(p_list + i)->bDisabled)
  504. (p_list + i)->bActive = 1;
  505. else if ((p_list + i)->iTab != -1)
  506. (p_list + i)->bActive = 0;
  507. ddx2BitBltDisplay(TAB_X, TAB_Y, TAB_XRES, TAB_YRES, hdcTab[iTab], 0, 0);
  508. }
  509. void CharMenuCheckMultyKyes2(LIST_VIEW_CONTROL2 * p_li, int iKey)
  510. {
  511. int y;
  512. int i;
  513. RECT r;
  514. for (i = 0; i < p_li->listnum; i++)
  515. if (i != p_li->cSelected && p_li->piValue[i] == iKey) {
  516. y = i * 30;
  517. r.left = 550;
  518. r.top = y + 2;
  519. r.right = r.left + (ddx2GetWidth(p_li->bDCn) - 550);
  520. r.bottom = r.top + 28;
  521. ddx2FillRect(p_li->bDCn, &r, 0);
  522. ddx2FillRect(p_li->bDCs, &r, 0);
  523. char tmp[200];
  524. co2_List_Add_String(p_li, i, 550, Key2String(255, tmp), 255, 0);
  525. }
  526. }
  527. void SetCharMenu2(LIST_VIEW_CONTROL2 * p_li, LEVELINFO * p_Level,
  528. ANIMATION_MODULE * p_am, int mix, int miy)
  529. {
  530. char text[128];
  531. int y = p_li->cSelected * 30;
  532. // int xs = p_li->rectList.top + TAB_Y + y - p_li->dx;
  533. int xp = 0;
  534. int xt = 0;
  535. int i;
  536. RECT r;
  537. RECT rtmp;
  538. int iCursor = 0;
  539. mi.x = mix;
  540. mi.y = miy;
  541. if (!p_li->cSelected || p_li->cSelected == 11 || p_li->cSelected == 19)
  542. return;
  543. r.left = 550;
  544. r.top = y + 2;
  545. r.right = r.left + (ddx2GetWidth(p_li->bDCn) - 550);
  546. r.bottom = r.top + 28;
  547. ddx2FillRect(p_li->bDCn, &r, 0);
  548. ddx2FillRect(p_li->bDCs, &r, 0);
  549. if (y - p_li->dx < 0)
  550. xp = (y - p_li->dx) * -1;
  551. if ((p_li->rectList.top + TAB_Y + y - p_li->dx + 30) >
  552. p_li->rectList.bottom + TAB_Y)
  553. xt =
  554. (p_li->rectList.top + TAB_Y + y - p_li->dx + 30) -
  555. (p_li->rectList.bottom + TAB_Y);
  556. ddx2BitBlt(HDC2DD, p_li->rectList.left + TAB_X,
  557. p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddx2GetWidth(p_li->bDCs),
  558. 30 - xp - xt, p_li->bDCs, 0, y + xp);
  559. //spracuj_spravy(0);
  560. am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  561. r.top = p_li->rectList.top + TAB_Y + y - p_li->dx + xp - 2;
  562. r.left = 665;
  563. r.right = r.left + 220;
  564. r.bottom = r.top + 27;
  565. rtmp.left = r.left;
  566. rtmp.top = r.top;
  567. rtmp.right = 220;
  568. rtmp.bottom = 27;
  569. while (!key[0]) {
  570. if (iCursor < 100)
  571. ddx2FillRect(HDC2DD, &r, RGB(63, 122, 163));
  572. else if (iCursor > 99 && iCursor < 200)
  573. ddx2FillRect(HDC2DD, &r, 0);
  574. else {
  575. iCursor = 0;
  576. ddx2FillRect(HDC2DD, &r, 0);
  577. }
  578. ddx2AddRectItem(&rline, rtmp, 0);
  579. iCursor += 4;
  580. Sleep(10);
  581. am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  582. if (key[K_F1] || key[K_F2] || key[K_F3] || key[K_F10] || key[K_PLUS]
  583. || key[K_MINUS]) {
  584. key[0] = 0;
  585. key[K_F1] = 0;
  586. key[K_F2] = 0;
  587. key[K_F3] = 0;
  588. key[K_F10] = 0;
  589. key[K_PLUS] = 0;
  590. key[K_MINUS] = 0;
  591. }
  592. }
  593. key[0] = 0;
  594. for (i = 0; i < POCET_KLAVES; i++)
  595. if (key[i]) {
  596. Key2String(i, text);
  597. key[i] = 0;
  598. break;
  599. }
  600. co2_List_Add_String(p_li, p_li->cSelected, 550, text, i, 0);
  601. CharMenuCheckMultyKyes2(p_li, i);
  602. ddx2BitBlt(HDC2DD, p_li->rectList.left + TAB_X, p_li->rectList.top + TAB_Y,
  603. ddx2GetWidth(p_li->bDCn), p_li->rectList.bottom - p_li->rectList.top,
  604. p_li->bDCn, 0, p_li->dx);
  605. ddx2BitBlt(HDC2DD, p_li->rectList.left + TAB_X,
  606. p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddx2GetWidth(p_li->bDCs),
  607. 30 - xp - xt, p_li->bDCs, 0, y + xp);
  608. }
  609. void SetMenuSettings2(CONTROL_LIST_ITEM2 * citem, int *hdcTabUse)
  610. {
  611. int i;
  612. if (hdcTabUse[0]) {
  613. setup.posouvat_kameru = co2_Check_Get_State(citem, CLIST_ITEMC, 1);
  614. setup.ovladani = co2_Check_Get_State(citem, CLIST_ITEMC, 2);
  615. setup.bugs_highlight = co2_Check_Get_State(citem, CLIST_ITEMC, 10);
  616. setup.items_highlight = co2_Check_Get_State(citem, CLIST_ITEMC, 11);
  617. setup.ovladani_rohy = co2_Check_Get_State(citem, CLIST_ITEMC, 12);
  618. setup.camera_intro = co2_Check_Get_State(citem, CLIST_ITEMC, 16);
  619. i = co2_Check_Get_State(citem, CLIST_ITEMC, 13);
  620. if (i)
  621. setup.ovladani_rohy_default = 0;
  622. else
  623. setup.ovladani_rohy_default = 1;
  624. setup.ovladani_rohy_smer = co2_Check_Get_State(citem, CLIST_ITEMC, 15);
  625. //setup.ovladani_pr_posun = co2_Check_Get_State(citem, CLIST_ITEMC, 16);
  626. setup.ovladani_rohy_rychlost =
  627. co2_Progres_Get(citem, CLIST_ITEMC, 0) / 10.0f;
  628. setup.p_kamera_radius = co2_Progres_Get(citem, CLIST_ITEMC, 1) / 2.0f;
  629. }
  630. if (hdcTabUse[1]) {
  631. co2_Combo_Drop_Get_Sel(citem, CLIST_ITEMC, 10, &setup.text_ostrost);
  632. setup.ditering = co2_Check_Get_State(citem, CLIST_ITEMC, 7);
  633. setup.mirror_effects = co2_Check_Get_State(citem, CLIST_ITEMC, 4);
  634. setup.animace_okoli = co2_Check_Get_State(citem, CLIST_ITEMC, 8);
  635. }
  636. if (hdcTabUse[2]) {
  637. setup.soundvolume = co2_Progres_Get(citem, CLIST_ITEMC, 4);
  638. setup.ambientvolume = co2_Progres_Get(citem, CLIST_ITEMC, 5);
  639. setup.musicvolume = co2_Progres_Get(citem, CLIST_ITEMC, 6);
  640. }
  641. if (hdcTabUse[3]) {
  642. setup.key[1] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 1);
  643. setup.key[2] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 2);
  644. setup.key[3] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 3);
  645. setup.key[4] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 4);
  646. setup.key[5] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 5);
  647. setup.key[6] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 6);
  648. setup.key[7] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 7);
  649. setup.key[8] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 8);
  650. setup.key[9] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 9);
  651. setup.key[10] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 10);
  652. setup.key[12] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 12);
  653. setup.key[13] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 13);
  654. setup.key[14] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 14);
  655. setup.key[15] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 15);
  656. setup.key[16] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 16);
  657. setup.key[17] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 17);
  658. setup.key[18] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 18);
  659. setup.key[20] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 20);
  660. setup.key[21] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 21);
  661. setup.key[22] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 22);
  662. setup.key[23] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 23);
  663. setup.key[24] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 24);
  664. setup.key[25] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 25);
  665. setup.key[26] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 26);
  666. setup.key[27] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 27);
  667. setup.key[28] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 28);
  668. setup.key[29] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 29);
  669. setup.key[30] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 30);
  670. }
  671. }
  672. void SetMenuSettingsS2(CONTROL_LIST_ITEM2 * citem, int *hdcTabUse)
  673. {
  674. if (hdcTabUse[2]) {
  675. setup.soundvolume = co2_Progres_Get(citem, CLIST_ITEMC, 4);
  676. setup.ambientvolume = co2_Progres_Get(citem, CLIST_ITEMC, 5);
  677. setup.musicvolume = co2_Progres_Get(citem, CLIST_ITEMC, 6);
  678. }
  679. }
  680. void ControlFullScreenCallback2(void *p_control)
  681. {
  682. GRAPH3D *p_grf = (p_ber->p_age)->graph_get();
  683. p_grf->fullscreen_toggle();
  684. }
  685. void InitTab3d2(CONTROL_LIST_ITEM2 * citem, int *hdcTab)
  686. {
  687. int i;
  688. //kprintf(1, "##settings_sharpness");
  689. co2_Set_Text_Right(hdcTab[1], "##settings_sharpness", 0, 285, 97);
  690. citem[42].p_combod = co2_Create_Combo_Drop(hdcTab[1], 300, 90, 10);
  691. citem[42].iTab = 1;
  692. co2_Combo_Drop_Add_String(citem[42].p_combod, "-3.0", -3.0f);
  693. co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.75", -2.75f);
  694. co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.5", -2.5f);
  695. co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.25", -2.25f);
  696. co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.0", -2.0f);
  697. co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.75", -1.75f);
  698. co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.5", -1.5f);
  699. co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.25", -1.25f);
  700. co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.0", -1.0f);
  701. co2_Combo_Drop_Add_String(citem[42].p_combod, "-0.75", -0.75f);
  702. co2_Combo_Drop_Add_String(citem[42].p_combod, "-0.5", -0.5f);
  703. co2_Combo_Drop_Add_String(citem[42].p_combod, "-0.25", -0.25f);
  704. co2_Combo_Drop_Add_String(citem[42].p_combod, "0.0", 0.0f);
  705. co2_Combo_Drop_Add_String(citem[42].p_combod, "+0.25", 0.25f);
  706. co2_Combo_Drop_Add_String(citem[42].p_combod, "+0.5", 0.5f);
  707. co2_Combo_Drop_Add_String(citem[42].p_combod, "+0.75", 0.75f);
  708. co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.0", 1.0f);
  709. co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.25", 1.25f);
  710. co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.5", 1.5f);
  711. co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.75", 1.75f);
  712. co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.0", 2.0f);
  713. co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.25", 2.25f);
  714. co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.5", 2.5f);
  715. co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.75", 2.75f);
  716. co2_Combo_Drop_Add_String(citem[42].p_combod, "+3.0", 3.0f);
  717. i = ftoi(((setup.text_ostrost + 3) * 100) / 25.0f);
  718. if (i > 24)
  719. i = 24;
  720. co2_Combo_Drop_Set_Sel(hdcTab[1], citem[42].p_combod, i);
  721. //kprintf(1, "##settings_dithering");
  722. citem[29].p_check =
  723. co2_Create_CheckBox(hdcTab[1], 300, 150, "##settings_dithering", 0, 7);
  724. citem[29].iTab = 1;
  725. co2_Check_Set_State(citem[29].p_check, hdcTab[1], setup.ditering, 1);
  726. //kprintf(1, "##settings_animations");
  727. citem[11].p_check = co2_Create_CheckBox(hdcTab[1], 300, 180, "##settings_draw_mirror", 0, 4);
  728. citem[11].iTab = 1;
  729. co2_Check_Set_State(citem[11].p_check, hdcTab[1], setup.mirror_effects, 1);
  730. citem[30].p_check =
  731. co2_Create_CheckBox(hdcTab[1], 300, 210, "##settings_animations", 0, 8);
  732. citem[30].iTab = 1;
  733. co2_Check_Set_State(citem[30].p_check, hdcTab[1], setup.animace_okoli, 1);
  734. citem[31].p_check = co2_Create_CheckBox(hdcTab[1], 300, 240,
  735. "##settings_fullscreen", 0, 5, ControlFullScreenCallback2);
  736. citem[31].iTab = 1;
  737. co2_Check_Set_State(citem[31].p_check, hdcTab[1], setup.fullscreen, 1);
  738. }
  739. void InitTabSound2(CONTROL_LIST_ITEM2 * citem, int *hdcTab)
  740. {
  741. co2_Set_Text_Right(hdcTab[2], "##settings_sound", 0, 260, 50);
  742. citem[21].p_prog = co2_Create_Progres(hdcTab[2], 310, 50, 0, 100, 4);
  743. citem[21].iTab = 2;
  744. co2_Progres_Set(citem[21].p_prog, hdcTab[2], setup.soundvolume);
  745. co2_Set_Text_Right(hdcTab[2], "##settings_ambient", 0, 260, 85);
  746. citem[22].p_prog = co2_Create_Progres(hdcTab[2], 310, 85, 0, 100, 5);
  747. citem[22].iTab = 2;
  748. co2_Progres_Set(citem[22].p_prog, hdcTab[2], setup.ambientvolume);
  749. co2_Set_Text_Right(hdcTab[2], "##settings_music", 0, 260, 120);
  750. citem[23].p_prog = co2_Create_Progres(hdcTab[2], 310, 120, 0, 100, 6);
  751. citem[23].iTab = 2;
  752. co2_Progres_Set(citem[23].p_prog, hdcTab[2], setup.musicvolume);
  753. /*co2_Set_Text(hdcTab[2], 260 - TAB_X, 350 - TAB_Y, "##settings_sound", 0);
  754. citem[21].p_prog = co2_Create_Progres(hdcTab[2], 345 - TAB_X, 352 - TAB_Y, 0, 100, 4);
  755. citem[21].iTab = 2;
  756. co2_Progres_Set(citem[21].p_prog, hdcTab[2], setup.soundvolume);
  757. co2_Set_Text(hdcTab[2], 150 - TAB_X, 385 - TAB_Y, "##settings_ambient", 0);
  758. citem[22].p_prog = co2_Create_Progres(hdcTab[2], 345 - TAB_X, 387 - TAB_Y, 0, 100, 5);
  759. citem[22].iTab = 2;
  760. co2_Progres_Set(citem[22].p_prog, hdcTab[2], setup.ambientvolume);
  761. co2_Set_Text(hdcTab[2], 242 - TAB_X, 420 - TAB_Y, "##settings_music", 0);
  762. citem[23].p_prog = co2_Create_Progres(hdcTab[2], 345 - TAB_X, 422 - TAB_Y, 0, 100, 6);
  763. citem[23].iTab = 2;
  764. co2_Progres_Set(citem[23].p_prog, hdcTab[2], setup.musicvolume); */
  765. }
  766. void InitTabControls2(CONTROL_LIST_ITEM2 * citem, int *hdcTab)
  767. {
  768. char ctext[256];
  769. citem[24].p_list = co2_Create_List(hdcTab[3], 25, 50, 800, 580, 0, 31, 0);
  770. citem[24].iTab = 3;
  771. co2_List_Add_String(citem[24].p_list, 0, 2, "##control_beatle", 0, 1);
  772. co2_List_Add_String(citem[24].p_list, 1, 2, "##control_forward", 0, 0);
  773. co2_List_Add_String(citem[24].p_list, 2, 2, "##control_back", 0, 0);
  774. co2_List_Add_String(citem[24].p_list, 3, 2, "##control_left", 0, 0);
  775. co2_List_Add_String(citem[24].p_list, 4, 2, "##control_right", 0, 0);
  776. co2_List_Add_String(citem[24].p_list, 5, 2, "##control_nextb", 0, 0);
  777. co2_List_Add_String(citem[24].p_list, 6, 2, "##control_b1", 0, 0);
  778. co2_List_Add_String(citem[24].p_list, 7, 2, "##control_b2", 0, 0);
  779. co2_List_Add_String(citem[24].p_list, 8, 2, "##control_b3", 0, 0);
  780. co2_List_Add_String(citem[24].p_list, 9, 2, "##control_b4", 0, 0);
  781. co2_List_Add_String(citem[24].p_list, 10, 2, "##control_b5", 0, 0);
  782. co2_List_Add_String(citem[24].p_list, 11, 2, "##control_camera", 0, 1);
  783. co2_List_Add_String(citem[24].p_list, 12, 2, "##control_crotation", 0, 0);
  784. co2_List_Add_String(citem[24].p_list, 13, 2, "##control_cmove", 0, 0);
  785. co2_List_Add_String(citem[24].p_list, 14, 2, "##control_czoomin", 0, 0);
  786. co2_List_Add_String(citem[24].p_list, 15, 2, "##control_czoomout", 0, 0);
  787. co2_List_Add_String(citem[24].p_list, 16, 2, "##control_cfastleft", 0, 0);
  788. co2_List_Add_String(citem[24].p_list, 17, 2, "##control_cfastright", 0, 0);
  789. co2_List_Add_String(citem[24].p_list, 18, 2, "##control_ccamera", 0, 0);
  790. co2_List_Add_String(citem[24].p_list, 19, 2, "##control_game", 0, 1);
  791. co2_List_Add_String(citem[24].p_list, 20, 2, "##control_gmenu", 0, 0);
  792. co2_List_Add_String(citem[24].p_list, 21, 2, "##control_grestart", 0, 0);
  793. co2_List_Add_String(citem[24].p_list, 22, 2, "##control_ginventory", 0, 0);
  794. //co2_List_Add_String(citem[24].p_list, 23, 2, "##control_gusepack", 0, 0);
  795. co2_List_Add_String(citem[24].p_list, 23, 2, "##control_gnexttrack", 0, 0);
  796. co2_List_Add_String(citem[24].p_list, 24, 2, "##control_gturnoffi", 0, 0);
  797. co2_List_Add_String(citem[24].p_list, 25, 2, "##control_gturnofft", 0, 0);
  798. co2_List_Add_String(citem[24].p_list, 26, 2, "##control_gscreenshot", 0, 0);
  799. co2_List_Add_String(citem[24].p_list, 27, 2, "##control_gtransparent", 0, 0);
  800. co2_List_Add_String(citem[24].p_list, 28, 2, "##control_ghighlight", 0, 0);
  801. co2_List_Add_String(citem[24].p_list, 29, 2, "##control_gdrawconn", 0, 0);
  802. co2_List_Add_String(citem[24].p_list, 30, 2, "##control_pause", 0, 0);
  803. Key2String(setup.key[1], ctext);
  804. co2_List_Add_String(citem[24].p_list, 1, 550, ctext, setup.key[1], 0);
  805. Key2String(setup.key[2], ctext);
  806. co2_List_Add_String(citem[24].p_list, 2, 550, ctext, setup.key[2], 0);
  807. Key2String(setup.key[3], ctext);
  808. co2_List_Add_String(citem[24].p_list, 3, 550, ctext, setup.key[3], 0);
  809. Key2String(setup.key[4], ctext);
  810. co2_List_Add_String(citem[24].p_list, 4, 550, ctext, setup.key[4], 0);
  811. Key2String(setup.key[5], ctext);
  812. co2_List_Add_String(citem[24].p_list, 5, 550, ctext, setup.key[5], 0);
  813. Key2String(setup.key[6], ctext);
  814. co2_List_Add_String(citem[24].p_list, 6, 550, ctext, setup.key[6], 0);
  815. Key2String(setup.key[7], ctext);
  816. co2_List_Add_String(citem[24].p_list, 7, 550, ctext, setup.key[7], 0);
  817. Key2String(setup.key[8], ctext);
  818. co2_List_Add_String(citem[24].p_list, 8, 550, ctext, setup.key[8], 0);
  819. Key2String(setup.key[9], ctext);
  820. co2_List_Add_String(citem[24].p_list, 9, 550, ctext, setup.key[9], 0);
  821. Key2String(setup.key[10], ctext);
  822. co2_List_Add_String(citem[24].p_list, 10, 550, ctext, setup.key[10], 0);
  823. Key2String(setup.key[12], ctext);
  824. co2_List_Add_String(citem[24].p_list, 12, 550, ctext, setup.key[12], 0);
  825. Key2String(setup.key[13], ctext);
  826. co2_List_Add_String(citem[24].p_list, 13, 550, ctext, setup.key[13], 0);
  827. Key2String(setup.key[14], ctext);
  828. co2_List_Add_String(citem[24].p_list, 14, 550, ctext, setup.key[14], 0);
  829. Key2String(setup.key[15], ctext);
  830. co2_List_Add_String(citem[24].p_list, 15, 550, ctext, setup.key[15], 0);
  831. Key2String(setup.key[16], ctext);
  832. co2_List_Add_String(citem[24].p_list, 16, 550, ctext, setup.key[16], 0);
  833. Key2String(setup.key[17], ctext);
  834. co2_List_Add_String(citem[24].p_list, 17, 550, ctext, setup.key[17], 0);
  835. Key2String(setup.key[18], ctext);
  836. co2_List_Add_String(citem[24].p_list, 18, 550, ctext, setup.key[18], 0);
  837. Key2String(setup.key[20], ctext);
  838. co2_List_Add_String(citem[24].p_list, 20, 550, ctext, setup.key[20], 0);
  839. Key2String(setup.key[21], ctext);
  840. co2_List_Add_String(citem[24].p_list, 21, 550, ctext, setup.key[21], 0);
  841. Key2String(setup.key[22], ctext);
  842. co2_List_Add_String(citem[24].p_list, 22, 550, ctext, setup.key[22], 0);
  843. /*Key2String(setup.key[23], ctext);
  844. co2_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0); */
  845. Key2String(setup.key[23], ctext);
  846. co2_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0);
  847. Key2String(setup.key[24], ctext);
  848. co2_List_Add_String(citem[24].p_list, 24, 550, ctext, setup.key[24], 0);
  849. Key2String(setup.key[25], ctext);
  850. co2_List_Add_String(citem[24].p_list, 25, 550, ctext, setup.key[25], 0);
  851. Key2String(setup.key[26], ctext);
  852. co2_List_Add_String(citem[24].p_list, 26, 550, ctext, setup.key[26], 0);
  853. Key2String(setup.key[27], ctext);
  854. co2_List_Add_String(citem[24].p_list, 27, 550, ctext, setup.key[27], 0);
  855. Key2String(setup.key[28], ctext);
  856. co2_List_Add_String(citem[24].p_list, 28, 550, ctext, setup.key[28], 0);
  857. Key2String(setup.key[29], ctext);
  858. co2_List_Add_String(citem[24].p_list, 29, 550, ctext, setup.key[29], 0);
  859. Key2String(setup.key[30], ctext);
  860. co2_List_Add_String(citem[24].p_list, 30, 550, ctext, setup.key[30], 0);
  861. co2_List_Redraw(hdcTab[3], citem[24].p_list, 0);
  862. }
  863. void RunMenuSettings2(char *p_File_Name, AUDIO_DATA * p_ad,
  864. LEVELINFO * p_Level, ANIMATION_MODULE * p_am)
  865. {
  866. int mix, miy;
  867. RECT rTMP = { 0, 0, 1024, 768 };
  868. DWORD dwEplased = 0, dwStart, dwStop;
  869. int ActiveTab = 0;
  870. int hdcTab[TAB_NUM];
  871. int hdcTabUse[TAB_NUM];
  872. CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
  873. int lastcmd, lastanm, i;
  874. CMD_LINE *res = NULL;
  875. int lastabv = -1;
  876. char in, click = 0;
  877. int anmid = -1, resid = -1, anbind = -1;
  878. int bind;
  879. DeviceHandle dh = 0;
  880. int sh = K_CHYBA;
  881. _3d_End_Draw();
  882. p_Level->bResetini = 0;
  883. p_Level->iCursor = 133;
  884. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  885. _2d_Clear_RectLine(&rline);
  886. ddx2Init(200, RGB(255, 0, 255));
  887. dh = ddx2DeviceCreate(TRUE, 32);
  888. ddx2DeviceSetActive(dh);
  889. ddx2DeviceSetBackBufferSize(1024, 768);
  890. ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
  891. ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
  892. ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
  893. ddx2CleareSurface(DDX2_BACK_BUFFER);
  894. sh = ddx2LoadBitmap("settings.png", pBmpDir);
  895. LoadHelp("3dsettings_load.txt");
  896. ddx2FillRect(DDX2_BACK_BUFFER, &rTMP, RGB(255, 0, 255));
  897. ddx2SetRect(&rTMP, 1);
  898. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  899. // Stop renderu hry
  900. //ddx2GameRender(FALSE);
  901. // - volat jako soucast hry (po vykreslni listi)
  902. //void ddx2RenderDevices(G_KONFIG *p_ber)
  903. // - volat pokud jede menu bez hry - maze obrazovku a kresli menu
  904. //void ddx2RenderujVse(G_KONFIG *p_ber)
  905. // flipovat musis sam vzdycky
  906. // volej ale v kazdem frame jen jednu tuto funkci (podle toho jesli
  907. // 2D grafika je soucasti hry nebo jede samostatne)
  908. _2d_Clear_RectLine(&rline);
  909. res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
  910. Load_ini();
  911. iCompositDC = ddx2FindFreeSurface();
  912. CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
  913. iFontDC = ddx2FindFreeSurface();
  914. FontDC = ddx2CreateSurface(1024, 768, iFontDC);
  915. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
  916. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  917. fn2_Set_Font(cFontDir[2]);
  918. fn2_Load_Bitmaps();
  919. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  920. for (bind = 0; bind < RES_NUM; bind++) {
  921. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  922. res[bind].iAnim[lastcmd][11] = -1;
  923. res[bind].iAnim[lastcmd][0] = -1;
  924. }
  925. for (in = 0; in < 6; in++)
  926. res[bind].iParam[(int)in] = -1;
  927. res[bind].iLayer = 0;
  928. }
  929. lastcmd = 0;
  930. timercnt = 0;
  931. if (chdir(DATA_DIR)) {
  932. free((void *) res);
  933. return;
  934. }
  935. char dir[MAX_FILENAME];
  936. strcpy(dir, DATA_DIR);
  937. //natadhe skript menu
  938. LoadMenuScript(p_File_Name, res, &lastcmd);
  939. in = 0;
  940. CreateFontAnimations2(res, &lastcmd, 0, 0);
  941. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  942. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  943. // animace na OnAbove
  944. for (i = 0; i < lastcmd; i++) {
  945. lastanm = 0;
  946. switch (res[i].iParam[0]) {
  947. case COM_DRAW:
  948. if (!res[i].iLayer) {
  949. //ddx2DrawSurface(BackDC, res[i].iParam, 2);
  950. ddx2DrawDisplay(res[i].iParam, 0);
  951. }
  952. else {
  953. //ddx2DrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR );
  954. //ddx2DrawSurface(FontDC, res[i].iParam, 3);
  955. ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  956. ddx2DrawSurface(FontDC, res[i].iParam, 3);
  957. }
  958. break;
  959. case COM_RANDOMANIMATION:
  960. case COM_ONCLICK:
  961. case COM_ONABOVE:
  962. case COM_RUNANIMATION:
  963. case COM_BINDEXITANIMATION:
  964. case COM_BINDANIMATION:
  965. //nahrati animace k udalosti OnAbove
  966. LoadAnimationMenuScript(res, i, &lastanm);
  967. break;
  968. }
  969. }
  970. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  971. for (i = 0; i < TAB_NUM; i++) {
  972. hdcTab[i] = ddx2CreateSurface(TAB_XRES, TAB_YRES, ddx2FindFreeSurface());
  973. if (hdcTab[i])
  974. ddx2BitBlt(hdcTab[i], 0, 0, TAB_XRES, TAB_YRES, HDC2DD, TAB_X, TAB_Y);
  975. hdcTabUse[i] = 0;
  976. }
  977. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  978. if (!co2_Load_Graphic(0)) {
  979. kerror(1, "co2_Load_Graphic ... can't load controls!");
  980. }
  981. else {
  982. citem[0].bActive = 0;
  983. citem[1].bActive = 0;
  984. citem[3].p_check =
  985. co2_Create_CheckBox(hdcTab[0], 25, 50, "##settings_camera_mov", 0, 1);
  986. co2_Check_Set_State(citem[3].p_check, hdcTab[0], setup.posouvat_kameru,
  987. 1);
  988. citem[3].bActive = 1;
  989. citem[4].p_check =
  990. co2_Create_CheckBox(hdcTab[0], 25, 80, "##settings_b1_control", 0, 2);
  991. co2_Check_Set_State(citem[4].p_check, hdcTab[0], setup.ovladani, 1);
  992. citem[4].bActive = 1;
  993. citem[35].p_check = co2_Create_CheckBox(hdcTab[0], 25, 110, "##settings_beathe_vis_at_start", 0, 10);
  994. co2_Check_Set_State(citem[35].p_check, hdcTab[0], setup.bugs_highlight, 1);
  995. citem[35].bActive = 1;
  996. citem[36].p_check = co2_Create_CheckBox(hdcTab[0], 25, 140, "##settings_items_vis_at_start", 0, 11);
  997. co2_Check_Set_State(citem[36].p_check, hdcTab[0], setup.items_highlight, 1);
  998. citem[36].bActive = 1;
  999. citem[41].p_check =
  1000. co2_Create_CheckBox(hdcTab[0], 25, 200, "##settings_camera_intro", 0,
  1001. 16);
  1002. co2_Check_Set_State(citem[41].p_check, hdcTab[0], setup.camera_intro, 1);
  1003. citem[41].bActive = 1;
  1004. citem[37].p_check =
  1005. co2_Create_CheckBox(hdcTab[0], 25, 230, "##settings_camera_rect", 0,
  1006. 12);
  1007. co2_Check_Set_State(citem[37].p_check, hdcTab[0], setup.ovladani_rohy, 1);
  1008. citem[37].bActive = 1;
  1009. citem[38].p_check =
  1010. co2_Create_CheckBox(hdcTab[0], 25, 260, "##settings_implicit_move", 0,
  1011. 13);
  1012. if (setup.ovladani_rohy_default)
  1013. co2_Check_Set_State(citem[38].p_check, hdcTab[0], 0, 1);
  1014. else
  1015. co2_Check_Set_State(citem[38].p_check, hdcTab[0], 1, 1);
  1016. citem[38].bActive = 1;
  1017. citem[39].p_check =
  1018. co2_Create_CheckBox(hdcTab[0], 25, 290, "##settings_imlicit_rot", 0,
  1019. 14);
  1020. if (setup.ovladani_rohy_default)
  1021. co2_Check_Set_State(citem[39].p_check, hdcTab[0], 1, 1);
  1022. else
  1023. co2_Check_Set_State(citem[39].p_check, hdcTab[0], 0, 1);
  1024. citem[39].bActive = 1;
  1025. citem[40].p_check =
  1026. co2_Create_CheckBox(hdcTab[0], 25, 320, "##settings_camera_swap", 0,
  1027. 15);
  1028. co2_Check_Set_State(citem[40].p_check, hdcTab[0],
  1029. setup.ovladani_rohy_smer, 1);
  1030. citem[40].bActive = 1;
  1031. /*citem[41].p_check = co2_Create_CheckBox(hdcTab[0], 25, 350, "##setings_camera_move_cur", 0, 16);
  1032. co2_Check_Set_State(citem[41].p_check, hdcTab[0], setup.ovladani_pr_posun, 1);
  1033. citem[41].bActive = 1; */
  1034. co2_Set_Text_Right(hdcTab[0], "##setings_camera_speed", 0, 450, 390);
  1035. citem[42].p_prog = co2_Create_Progres(hdcTab[0], 500, 387, 0, 10, 0);
  1036. co2_Progres_Set(citem[42].p_prog, hdcTab[0],
  1037. ftoi(setup.ovladani_rohy_rychlost * 10));
  1038. citem[42].bActive = 1;
  1039. co2_Set_Text_Right(hdcTab[0], "##settings_trans_radius", 0, 450, 425);
  1040. citem[7].p_prog = co2_Create_Progres(hdcTab[0], 500, 412, 1, 20, 1);
  1041. co2_Progres_Set(citem[7].p_prog, hdcTab[0],
  1042. ftoi(setup.p_kamera_radius * 2));
  1043. citem[7].bActive = 1;
  1044. /*if(!setup.posouvat_kameru)
  1045. co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0); */
  1046. if (!setup.ovladani_rohy) {
  1047. co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 13);
  1048. co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 14);
  1049. co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 15);
  1050. //co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 16);
  1051. co2_Progres_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0, 1,
  1052. hdcTab[0]);
  1053. }
  1054. SetTab2(0, -1, citem, CLIST_ITEMC, hdcTab);
  1055. hdcTabUse[0] = 1;
  1056. /*if(!setup.posouvat_kameru)
  1057. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0); */
  1058. if (!setup.ovladani_rohy) {
  1059. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
  1060. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
  1061. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
  1062. //co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
  1063. co2_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 0,
  1064. HDC2DD);
  1065. }
  1066. }
  1067. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  1068. //BEGIN_MENU:
  1069. for (i = 0; i < lastcmd; i++)
  1070. if (res[i].iParam[0] == COM_RUNANIMATION) {
  1071. int iWave = AddAnimation2(&res[i], &ad, 0);
  1072. if (iWave != -1) {
  1073. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1074. anm[iWave].iWave = res[i + 1].iParam[5] =
  1075. mPlaySound2(&res[i + 1], &ad, 2);
  1076. }
  1077. }
  1078. mi.t1 = 0;
  1079. mi.t2 = 0;
  1080. mi.dx = 0;
  1081. mi.dy = 0;
  1082. anmid = -1;
  1083. resid = -1;
  1084. anbind = -1;
  1085. bind = -1;
  1086. lastabv = -1;
  1087. in = 0;
  1088. p_Level->iCursor = 0;
  1089. ddx2GameRender(FALSE);
  1090. ddx2DeviceSetRender(TRUE);
  1091. spracuj_spravy(0);
  1092. while (!key[K_ESC]) {
  1093. mix = mi.x;
  1094. miy = mi.y;
  1095. mi.x = (int) ceil(mi.x * scale_factor_x());
  1096. mi.y = (int) ceil(mi.y * scale_factor_y());
  1097. dwStart = timeGetTime();
  1098. //pohnul mysi
  1099. if (mi.dx || mi.dy) {
  1100. //dostala se mys do akcni oblasti (OnAbove)?
  1101. if (!click)
  1102. for (i = 0; i < lastcmd; i++)
  1103. if (res[i].iParam[0] == COM_ONABOVE) {
  1104. if ((mi.x >= res[i].iParam[1]) &&
  1105. (mi.x <= res[i].iParam[3]) &&
  1106. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  1107. //spusteni animace v OnAbove
  1108. if (i != lastabv) {
  1109. if (in) {
  1110. Stop2(&res[lastabv]);
  1111. if (!res[lastabv].iLayer) {
  1112. ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
  1113. ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  1114. }
  1115. else {
  1116. ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
  1117. TRANSCOLOR);
  1118. ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  1119. }
  1120. }
  1121. CheckAnimation2(&res[i], &ad);
  1122. lastabv = i;
  1123. AddAnimation2(&res[i], &ad, 0);
  1124. in = 1;
  1125. bind = ChooseBidedAnimation2(res, i + 1, &ad);
  1126. if (bind != -1) {
  1127. CheckAnimation2(&res[bind], &ad);
  1128. AddAnimation2(&res[bind], &ad, 1);
  1129. anbind = bind;
  1130. mPlaySound2(&res[bind], &ad, 0);
  1131. }
  1132. strcpy(dir, res[i].cParam[1]);
  1133. }
  1134. }
  1135. else if (lastabv == i) {
  1136. // odesel z oblasti, ktera byla aktivni -> stop animace
  1137. // a odznaceni oblasti
  1138. Stop2(&res[i]);
  1139. if (!res[i].iLayer) {
  1140. ddx2DrawDisplay(res[i].iAnim[0], 0);
  1141. ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
  1142. }
  1143. else {
  1144. ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  1145. ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
  1146. }
  1147. bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
  1148. if (bind != -1) {
  1149. int iAnim;
  1150. if (anbind != -1) {
  1151. Stop2(&res[anbind]);
  1152. if (!res[i].iLayer) {
  1153. ddx2DrawDisplay(res[anbind].iAnim[0], 0);
  1154. ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  1155. }
  1156. else {
  1157. ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
  1158. TRANSCOLOR);
  1159. ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
  1160. }
  1161. }
  1162. iAnim = AddAnimation2(&res[bind], &ad, 1);
  1163. if (iAnim != -1)
  1164. anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
  1165. }
  1166. lastabv = -1;
  1167. anbind = -1;
  1168. in = 0;
  1169. strcpy(dir, "");
  1170. }
  1171. }
  1172. mi.dx = 0;
  1173. mi.dy = 0;
  1174. }
  1175. co2_Handle_Controls(citem, CLIST_ITEMC, mi.x - TAB_X, mi.y - TAB_Y,
  1176. HDC2DD, TAB_X, TAB_Y);
  1177. if(co2_Progres_Changed(citem, CLIST_ITEMC, 4))
  1178. ad.Sound_Gain = co2_Progres_Get(citem, CLIST_ITEMC, 4) / 100.0f;
  1179. if (co2_Progres_Changed(citem, CLIST_ITEMC, 5)) {
  1180. float laf = ad.Ambient_Gain;
  1181. ad.Ambient_Gain = co2_Progres_Get(citem, CLIST_ITEMC, 5) / 100.0f;
  1182. adas_Set_Source_Gain(-1, LOOPING_TYPE, UNDEFINED_VALUE, ad.Ambient_Gain);
  1183. if(laf < 0.05f && ad.Ambient_Gain >= 0.05f)
  1184. {
  1185. adas_Release_Source(-1, LOOPING_TYPE, UNDEFINED_VALUE);
  1186. as_Start(p_Level->Environment.id, &ad, p_Level);
  1187. }
  1188. }
  1189. if (co2_Progres_Changed(citem, CLIST_ITEMC, 6)) {
  1190. float f = co2_Progres_Get(citem, CLIST_ITEMC, 6) / 100.0f;
  1191. ogg_gain(f);
  1192. ad.Music_Gain = f;
  1193. if(f >= 0.05f && !ogg_playing())
  1194. {
  1195. ad.Music_Gain = f;
  1196. ap_Stop_Song(&ad);
  1197. ap_Play_Song(0,1,&ad);
  1198. //adas_OGG_Set_Priority(p_Level->Base_Priority);
  1199. //ap_Play_Song(0,0,&ad);
  1200. }
  1201. }
  1202. //stlacil leve tlacitko
  1203. if (mi.t1 && !click) {
  1204. int iCheck = -1;
  1205. LIST_VIEW_CONTROL2 *p_li;
  1206. iCheck = co2_Check_Get_State_Change(citem, CLIST_ITEMC, 12);
  1207. if (iCheck != -1) {
  1208. if (!iCheck) {
  1209. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
  1210. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
  1211. co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
  1212. //co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
  1213. co2_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 1,
  1214. HDC2DD);
  1215. }
  1216. else {
  1217. co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
  1218. co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
  1219. co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
  1220. //co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
  1221. co2_Progres_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
  1222. }
  1223. }
  1224. if (ActiveTab == 0 && !citem[39].bDisabled) {
  1225. iCheck = co2_Check_Get_State_Change(citem, CLIST_ITEMC, 13);
  1226. if (iCheck != -1 && iCheck == 1)
  1227. co2_Check_Set_State(citem[39].p_check, HDC2DD, 0, 1);
  1228. else if (iCheck != -1 && !iCheck)
  1229. co2_Check_Set_State(citem[39].p_check, HDC2DD, 1, 1);
  1230. iCheck = co2_Check_Get_State_Change(citem, CLIST_ITEMC, 14);
  1231. if (iCheck != -1 && iCheck == 1)
  1232. co2_Check_Set_State(citem[38].p_check, HDC2DD, 0, 1);
  1233. else if (iCheck != -1 && !iCheck)
  1234. co2_Check_Set_State(citem[38].p_check, HDC2DD, 1, 1);
  1235. }
  1236. if (co2_List_Get_Clck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
  1237. float pos[3] = { 0, 0, 0 };
  1238. ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
  1239. SetCharMenu2(p_li, p_Level, p_am, mix, miy);
  1240. }
  1241. //dostala se mys do akcni oblasti (OnClick)?
  1242. for (i = 0; i < lastcmd; i++)
  1243. if (res[i].iParam[0] == COM_ONCLICK)
  1244. if ((mi.x >= res[i].iParam[1]) &&
  1245. (mi.x <= res[i].iParam[3]) &&
  1246. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  1247. if (res[i].iAnim[0][0] >= 0) {
  1248. //pokud je animace, tak ji spust
  1249. anmid = AddAnimation2(&res[i], &ad, 0);
  1250. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1251. mPlaySound2(&res[i + 1], &ad, 1);
  1252. resid = i;
  1253. click = 1;
  1254. }
  1255. else {
  1256. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1257. mPlaySound2(&res[i + 1], &ad, 1);
  1258. resid = i;
  1259. click = 1;
  1260. anmid = 31;
  1261. }
  1262. }
  1263. mi.t1 = 0;
  1264. }
  1265. //provedeni akce po animaci menu
  1266. if (click)
  1267. if (!anm[anmid].cmd) {
  1268. click = 0;
  1269. //StopAll();
  1270. if (!strcmp(res[resid].cParam[1], "EXIT")) {
  1271. float pos[3] = { 0, 0, 0 };
  1272. ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
  1273. key[K_ESC] = 1;
  1274. }
  1275. if (!strcmp(res[resid].cParam[1], "OK")) {
  1276. float pos[3] = { 0, 0, 0 };
  1277. ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
  1278. SetMenuSettings2(citem, hdcTabUse);
  1279. Save_ini();
  1280. key[K_ESC] = 1;
  1281. p_Level->bResetini = 1;
  1282. }
  1283. if (!strcmp(res[resid].cParam[1], "GAME") && ActiveTab) {
  1284. SetTab2(0, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  1285. ActiveTab = 0;
  1286. hdcTabUse[0]++;
  1287. }
  1288. if (!strcmp(res[resid].cParam[1], "3D") && ActiveTab != 1) {
  1289. if (!hdcTabUse[1])
  1290. InitTab3d2(citem, hdcTab);
  1291. SetTab2(1, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  1292. ActiveTab = 1;
  1293. hdcTabUse[1]++;
  1294. }
  1295. if (!strcmp(res[resid].cParam[1], "SOUND") && ActiveTab != 2) {
  1296. if (!hdcTabUse[2])
  1297. InitTabSound2(citem, hdcTab);
  1298. SetTab2(2, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  1299. ActiveTab = 2;
  1300. hdcTabUse[2]++;
  1301. }
  1302. if (!strcmp(res[resid].cParam[1], "CONTROLS") && ActiveTab != 3) {
  1303. if (!hdcTabUse[3])
  1304. InitTabControls2(citem, hdcTab);
  1305. SetTab2(3, ActiveTab, citem, CLIST_ITEMC, hdcTab);
  1306. ActiveTab = 3;
  1307. hdcTabUse[3]++;
  1308. }
  1309. resid = -1;
  1310. if (key[K_ESC]) {
  1311. for(i=0;i<lastcmd;i++) {
  1312. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1) {
  1313. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  1314. res[i].iParam[5] = -1;
  1315. }
  1316. }
  1317. goto __QUIT;
  1318. }
  1319. }
  1320. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  1321. if (timercnt > 500) {
  1322. timercnt = 0;
  1323. for (i = 0; i < lastcmd; i++)
  1324. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  1325. if (rand() % 200 <= res[i].iParam[1] &&
  1326. strcmp(dir, res[i].cParam[0])) {
  1327. CheckAnimation2(&res[i], &ad);
  1328. AddAnimation2(&res[i], &ad, 0);
  1329. }
  1330. }
  1331. dwStop = timeGetTime();
  1332. dwEplased += dwStop - dwStart;
  1333. AnimationEvent2(NULL, 0, 0, dwStop);
  1334. mi.x = mix;
  1335. mi.y = miy;
  1336. am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  1337. }
  1338. __QUIT:
  1339. ddx2ReleaseBitmap(iCompositDC);
  1340. ddx2ReleaseBitmap(iFontDC);
  1341. // ddx2ReleaseBitmap(iBackDC);
  1342. SetMenuSettingsS2(citem, hdcTabUse);
  1343. Save_ini();
  1344. fn2_Release_Font();
  1345. StopAll2();
  1346. co2_Handle_Release(citem, CLIST_ITEMC);
  1347. co2_Release_Graphic();
  1348. key[K_ESC] = 0;
  1349. if (dh) {
  1350. ddx2ReleaseBitmap(sh);
  1351. ddx2DeviceDeaktivuj();
  1352. ddx2DeviceRemove(dh);
  1353. ddx2Release();
  1354. dh = 0;
  1355. }
  1356. FreeAnimations2(res, RES_NUM);
  1357. free((void *) res);
  1358. // fn2_Set_Font("font3d.pak");
  1359. // fn2_Load_Bitmaps();
  1360. // Start renderu hry
  1361. ddx2GameRender(TRUE);
  1362. }
  1363. int FillListLoad2(LIST_VIEW_CONTROL2 * p_li, char *mask, char bAdd, char bLoad)
  1364. {
  1365. WCHAR wFile[128];
  1366. int x = 0;
  1367. int c = 0;
  1368. LIST_ITEM_ *list;
  1369. int isize;
  1370. if (chdir(SAVE_DIR))
  1371. return 0;
  1372. FillStringList(mask, &list, &isize);
  1373. if (!isize)
  1374. return 0;
  1375. for (c = 0; c < isize; c++) {
  1376. ZeroMemory(wFile, 128 * sizeof(WCHAR));
  1377. if (bLoad == 2) {
  1378. if (!demo_Check_Owner(pPlayerProfile.cName, list[c].text, wFile))
  1379. continue;
  1380. }
  1381. else if (!check_Save_Owner(list[c].text, wFile))
  1382. continue;
  1383. if (bAdd)
  1384. co2_List_Add_StringWC2(p_li, x, 2, wFile, list[c].text, x, 0);
  1385. x++;
  1386. }
  1387. free((void *) list);
  1388. return x;
  1389. }
  1390. static void RunMenuLoadGameLoad2ResizeCallback(void)
  1391. {
  1392. ddx2DeviceSetScreenRec((int) ceil(scale_back_factor_x() * 299),
  1393. (int) ceil(scale_back_factor_y() * 209),
  1394. (int) ceil(scale_back_factor_x() * 444),
  1395. (int) ceil(scale_back_factor_y() * 415));
  1396. }
  1397. int RunMenuLoadGameLoad2(char *p_File_Name, AUDIO_DATA * p_ad,
  1398. LEVELINFO * p_Level, ANIMATION_MODULE * p_am, char bLoad, WCHAR * cText)
  1399. {
  1400. int iReturn = 0;
  1401. int mix, miy;
  1402. RECT rTMP = { 299, 209, 444, 415 };
  1403. DWORD dwEplased = 0, dwStart, dwStop;
  1404. CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
  1405. int lastcmd, lastanm, i;
  1406. CMD_LINE *res = NULL;
  1407. int lastabv = -1;
  1408. char in, click = 0;
  1409. int anmid = -1, resid = -1, anbind = -1;
  1410. int bind;
  1411. DeviceHandle dh = 0;
  1412. int sh = K_CHYBA;
  1413. _3d_End_Draw();
  1414. //kprintf(1, "----------------- RunMenuLoadGameLoad2 ---------------------");
  1415. p_Level->bResetini = 0;
  1416. _2d_Clear_RectLine(&rline);
  1417. p_Level->iCursor = 133;
  1418. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  1419. p_Level->iCursor = 0;
  1420. ddx2Init(200, RGB(255, 0, 255));
  1421. dh = ddx2DeviceCreate(TRUE, 32);
  1422. ddx2DeviceSetActive(dh);
  1423. ddx2DeviceSetBackBufferSize(1024, 768);
  1424. ddx2DeviceSetBackBufferRect(299, 209, 444, 415);
  1425. ddx2DeviceSetTextRenderRec(0, 0, 444, 415);
  1426. ddx2DeviceSetScreenRecCallback(RunMenuLoadGameLoad2ResizeCallback);
  1427. ddx2DeviceSetRender(TRUE);
  1428. ddx2CleareSurface(DDX2_BACK_BUFFER);
  1429. sh = ddx2LoadBitmap("smallmenu.png", pBmpDir);
  1430. ddx2SetRect(&rTMP, 1);
  1431. ddx2GameRender(TRUE);
  1432. res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
  1433. iCompositDC = ddx2FindFreeSurface();
  1434. CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
  1435. iFontDC = ddx2FindFreeSurface();
  1436. FontDC = ddx2CreateSurface(1024, 768, iFontDC);
  1437. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
  1438. fn2_Set_Font(cFontDir[0]);
  1439. fn2_Load_Bitmaps();
  1440. for (bind = 0; bind < RES_NUM; bind++) {
  1441. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  1442. res[bind].iAnim[lastcmd][11] = -1;
  1443. res[bind].iAnim[lastcmd][0] = -1;
  1444. }
  1445. for (in = 0; in < 6; in++)
  1446. res[bind].iParam[(int)in] = -1;
  1447. res[bind].iLayer = 0;
  1448. }
  1449. lastcmd = 0;
  1450. timercnt = 0;
  1451. if (chdir(DATA_DIR)) {
  1452. free((void *) res);
  1453. return 0;
  1454. }
  1455. char dir[MAX_FILENAME];
  1456. strcpy(dir, DATA_DIR);
  1457. //natadhe skript menu
  1458. LoadMenuScript(p_File_Name, res, &lastcmd);
  1459. in = 0;
  1460. CreateFontAnimations2(res, &lastcmd, 0, 0);
  1461. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  1462. // animace na OnAbove
  1463. for (i = 0; i < lastcmd; i++) {
  1464. lastanm = 0;
  1465. switch (res[i].iParam[0]) {
  1466. case COM_DRAW:
  1467. if (!res[i].iLayer)
  1468. ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  1469. else {
  1470. ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  1471. ddx2DrawSurface(FontDC, res[i].iParam, 3);
  1472. }
  1473. break;
  1474. case COM_RANDOMANIMATION:
  1475. case COM_ONCLICK:
  1476. case COM_ONABOVE:
  1477. case COM_RUNANIMATION:
  1478. case COM_BINDEXITANIMATION:
  1479. case COM_BINDANIMATION:
  1480. //nahrati animace k udalosti OnAbove
  1481. LoadAnimationMenuScript(res, i, &lastanm);
  1482. break;
  1483. }
  1484. }
  1485. if (!co2_Load_Graphic(0))
  1486. kprintf(1, "co2_Load_Graphic ... con't load controls!");
  1487. else {
  1488. RECT r;
  1489. int xx;
  1490. r.left = 299;
  1491. r.top = 209;
  1492. r.right = 743;
  1493. r.bottom = 359;
  1494. if (!bLoad) //save
  1495. co2_Set_Text_Center(HDC2DD, "##menu_savegame", 0, r);
  1496. else if (bLoad == 1) // load
  1497. co2_Set_Text_Center(HDC2DD, "##menu_loadgame", 0, r);
  1498. else //save demo
  1499. co2_Set_Text_Center(HDC2DD, "##menu_savedemo", 0, r);
  1500. fn2_Release_Font();
  1501. fn2_Set_Font(cFontDir[2]);
  1502. fn2_Load_Bitmaps();
  1503. xx = FillListLoad2(NULL, "*", 0, bLoad);
  1504. if (bLoad == 1) {
  1505. if (xx < 6)
  1506. xx = 6;
  1507. citem[1].p_list = co2_Create_List(HDC2DD, 360, 320, 320, 185, 0, xx, 1);
  1508. citem[1].bActive = 1;
  1509. FillListLoad2(citem[1].p_list, "*", 1, bLoad);
  1510. }
  1511. else if (!bLoad) {
  1512. if (xx < 5)
  1513. xx = 5;
  1514. citem[0].p_edit = co2_Create_Edit(HDC2DD, 373, 485, 0);
  1515. citem[0].bActive = 1;
  1516. citem[1].p_list = co2_Create_List(HDC2DD, 360, 320, 320, 150, 0, xx, 1);
  1517. citem[1].bActive = 1;
  1518. FillListLoad2(citem[1].p_list, "*", 1, bLoad);
  1519. }
  1520. else {
  1521. xx = FillListLoad2(NULL, "*.dem", 0, bLoad);
  1522. if (xx < 5)
  1523. xx = 5;
  1524. citem[0].p_edit = co2_Create_Edit(HDC2DD, 373, 485, 0);
  1525. citem[0].bActive = 1;
  1526. citem[1].p_list = co2_Create_List(HDC2DD, 360, 320, 320, 150, 0, xx, 1);
  1527. citem[1].bActive = 1;
  1528. FillListLoad2(citem[1].p_list, "*.dem", 1, bLoad);
  1529. }
  1530. co2_List_Redraw(HDC2DD, citem[1].p_list, 0);
  1531. }
  1532. //BEGIN_MENU:
  1533. for (i = 0; i < lastcmd; i++)
  1534. if (res[i].iParam[0] == COM_RUNANIMATION) {
  1535. int iWave = AddAnimation2(&res[i], &ad, 0);
  1536. if (iWave != -1) {
  1537. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1538. anm[iWave].iWave = res[i + 1].iParam[5] =
  1539. mPlaySound2(&res[i + 1], &ad, 2);
  1540. }
  1541. }
  1542. mi.t1 = 0;
  1543. mi.t2 = 0;
  1544. mi.dx = 0;
  1545. mi.dy = 0;
  1546. anmid = -1;
  1547. resid = -1;
  1548. anbind = -1;
  1549. bind = -1;
  1550. lastabv = -1;
  1551. in = 0;
  1552. spracuj_spravy(0);
  1553. while (!key[K_ESC]) {
  1554. mix = mi.x;
  1555. miy = mi.y;
  1556. mi.x = (int) ceil(mi.x * scale_factor_x());
  1557. mi.y = (int) ceil(mi.y * scale_factor_y());
  1558. dwStart = timeGetTime();
  1559. //pohnul mysi
  1560. if ((mi.dx || mi.dy) && !p_Level->bRestart && !p_Level->bReturnToMenu) {
  1561. //dostala se mys do akcni oblasti (OnAbove)?
  1562. if (!click)
  1563. for (i = 0; i < lastcmd; i++)
  1564. if (res[i].iParam[0] == COM_ONABOVE) {
  1565. if ((mi.x >= res[i].iParam[1]) &&
  1566. (mi.x <= res[i].iParam[3]) &&
  1567. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  1568. //spusteni animace v OnAbove
  1569. if (i != lastabv) {
  1570. if (in) {
  1571. Stop2(&res[lastabv]);
  1572. if (!res[lastabv].iLayer) {
  1573. ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
  1574. ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  1575. }
  1576. else {
  1577. ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3, TRANSCOLOR);
  1578. ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  1579. }
  1580. }
  1581. CheckAnimation2(&res[i], &ad);
  1582. lastabv = i;
  1583. AddAnimation2(&res[i], &ad, 0);
  1584. in = 1;
  1585. bind = ChooseBidedAnimation2(res, i + 1, &ad);
  1586. if (bind != -1) {
  1587. CheckAnimation2(&res[bind], &ad);
  1588. AddAnimation2(&res[bind], &ad, 1);
  1589. anbind = bind;
  1590. mPlaySound2(&res[bind], &ad, 0);
  1591. }
  1592. strcpy(dir, res[i].cParam[1]);
  1593. }
  1594. }
  1595. else if (lastabv == i) {
  1596. // odesel z oblasti, ktera byla aktivni -> stop animace
  1597. // a odznaceni oblasti
  1598. Stop2(&res[i]);
  1599. if (!res[i].iLayer) {
  1600. ddx2DrawDisplay(res[i].iAnim[0], 0);
  1601. ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
  1602. }
  1603. else {
  1604. ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  1605. ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
  1606. }
  1607. bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
  1608. if (bind != -1) {
  1609. int iAnim;
  1610. if (anbind != -1) {
  1611. Stop2(&res[anbind]);
  1612. if (!res[i].iLayer) {
  1613. ddx2DrawDisplay(res[anbind].iAnim[0], 0);
  1614. ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  1615. }
  1616. else {
  1617. ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
  1618. TRANSCOLOR);
  1619. ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
  1620. }
  1621. }
  1622. iAnim = AddAnimation2(&res[bind], &ad, 1);
  1623. if (iAnim != -1)
  1624. anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
  1625. }
  1626. lastabv = -1;
  1627. anbind = -1;
  1628. in = 0;
  1629. strcpy(dir, "");
  1630. }
  1631. }
  1632. mi.dx = 0;
  1633. mi.dy = 0;
  1634. }
  1635. if (!p_Level->bRestart && !p_Level->bReturnToMenu)
  1636. co2_Handle_Controls(citem, CLIST_ITEMC, mi.x, mi.y, HDC2DD, 0, 0);
  1637. //stlacil leve tlacitko
  1638. if (mi.t1 && !click && !p_Level->bRestart && !p_Level->bReturnToMenu) {
  1639. LIST_VIEW_CONTROL2 *p_li;
  1640. if (co2_List_Get_Clck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
  1641. if (p_li->cSelected != -1) {
  1642. float pos[3] = { 0, 0, 0 };
  1643. ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
  1644. if (!bLoad || bLoad == 2)
  1645. co2_Edit_Set_Text(citem[0].p_edit, p_li->pwText[p_li->cSelected],
  1646. 1, HDC2DD, 0, 0);
  1647. }
  1648. }
  1649. if (co2_List_Get_Dbclck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
  1650. float pos[3] = { 0, 0, 0 };
  1651. ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
  1652. if (p_li->cSelected != -1)
  1653. if (p_li->pwText[p_li->cSelected]) {
  1654. if (!bLoad || bLoad == 2)
  1655. wcscpy(cText, citem[0].p_edit->wtext);
  1656. else
  1657. wcscpy(cText, p_li->pwText[p_li->cSelected]);
  1658. if (!bLoad || bLoad == 2)
  1659. iReturn++;
  1660. key[K_ESC] = 1;
  1661. }
  1662. }
  1663. //dostala se mys do akcni oblasti (OnClick)?
  1664. if (!p_Level->bRestart && !p_Level->bReturnToMenu)
  1665. for (i = 0; i < lastcmd; i++)
  1666. if (res[i].iParam[0] == COM_ONCLICK)
  1667. if ((mi.x >= res[i].iParam[1]) &&
  1668. (mi.x <= res[i].iParam[3]) &&
  1669. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  1670. if (res[i].iAnim[0][0] >= 0) {
  1671. //pokud je animace, tak ji spust
  1672. anmid = AddAnimation2(&res[i], &ad, 0);
  1673. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1674. mPlaySound2(&res[i + 1], &ad, 1);
  1675. resid = i;
  1676. click = 1;
  1677. }
  1678. else {
  1679. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  1680. mPlaySound2(&res[i + 1], &ad, 1);
  1681. resid = i;
  1682. click = 1;
  1683. anmid = 31;
  1684. }
  1685. }
  1686. mi.t1 = 0;
  1687. }
  1688. //provedeni akce po animaci menu
  1689. if (click)
  1690. if (!anm[anmid].cmd) {
  1691. click = 0;
  1692. if (!strcmp(res[resid].cParam[1], "OK")) {
  1693. if (!bLoad || bLoad == 2)
  1694. wcscpy(cText, citem[0].p_edit->wtext);
  1695. else if (citem[1].p_list->cClckSel != -1)
  1696. if (citem[1].p_list->pwText[citem[1].p_list->cClckSel])
  1697. wcscpy(cText,
  1698. citem[1].p_list->pwText[citem[1].p_list->cClckSel]);
  1699. if (wcslen(cText)) {
  1700. char ccheck[] = "profiles";
  1701. WCHAR wcheck[64];
  1702. MultiByteToWideChar(CP_ACP, 0, ccheck, strlen(ccheck) + 1, wcheck,
  1703. sizeof(wcheck) / sizeof(wcheck[0]));
  1704. if (wcscasecmp(cText, wcheck)) {
  1705. if (!bLoad || bLoad == 2)
  1706. iReturn++;
  1707. key[K_ESC] = 1;
  1708. }
  1709. }
  1710. }
  1711. if (!strcmp(res[resid].cParam[1], "EXIT") ||
  1712. !strcmp(res[resid].cParam[1], "CANCEL")) {
  1713. ZeroMemory(cText, 128 * sizeof(WCHAR));
  1714. key[K_ESC] = 1;
  1715. //break;
  1716. }
  1717. resid = -1;
  1718. if (key[K_ESC]) {
  1719. for(i=0;i<lastcmd;i++)
  1720. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
  1721. {
  1722. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  1723. res[i].iParam[5] = -1;
  1724. }
  1725. //goto __QUIT;
  1726. }
  1727. }
  1728. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  1729. if (timercnt > 500) {
  1730. timercnt = 0;
  1731. for (i = 0; i < lastcmd; i++)
  1732. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  1733. if (rand() % 200 <= res[i].iParam[1] &&
  1734. strcmp(dir, res[i].cParam[0])) {
  1735. CheckAnimation2(&res[i], &ad);
  1736. AddAnimation2(&res[i], &ad, 0);
  1737. }
  1738. }
  1739. dwStop = timeGetTime();
  1740. dwEplased += dwStop - dwStart;
  1741. AnimationEvent2(NULL, 0, 0, dwStop);
  1742. mi.x = mix;
  1743. mi.y = miy;
  1744. if (iReturn) {
  1745. char ccheck[256];
  1746. ZeroMemory(ccheck, 256);
  1747. if (!bLoad)
  1748. lsi_Save_Exist(cText, ccheck);
  1749. else
  1750. demo_Exist(cText, ccheck);
  1751. if (strlen(ccheck)) {
  1752. if (!bLoad)
  1753. p_Level->bRestart = 1;
  1754. else
  1755. p_Level->bReturnToMenu = 1;
  1756. p_Level->iMessageBoxReturn = -1;
  1757. key[K_ESC] = 0;
  1758. iReturn = 0;
  1759. }
  1760. }
  1761. if ((p_Level->bRestart || p_Level->bReturnToMenu) && mi.t1) {
  1762. if (!p_Level->iMessageBoxReturn) {
  1763. iReturn = 0;
  1764. p_Level->bRestart = 0;
  1765. p_Level->bReturnToMenu = 0;
  1766. p_Level->iMessageBoxReturn = -1;
  1767. }
  1768. else if (p_Level->iMessageBoxReturn == 1) {
  1769. iReturn = 1;
  1770. key[K_ESC] = 1;
  1771. p_Level->bRestart = 0;
  1772. p_Level->bReturnToMenu = 0;
  1773. p_Level->iMessageBoxReturn = -1;
  1774. }
  1775. mi.t1 = 0;
  1776. }
  1777. am_Flip(p_Level, p_am, 0, &rline, CLIST_ITEMC, 0, 0, 0);
  1778. }
  1779. //__QUIT:
  1780. ddx2ReleaseBitmap(iCompositDC);
  1781. ddx2ReleaseBitmap(iFontDC);
  1782. fn2_Release_Font();
  1783. StopAll2();
  1784. co2_Handle_Release(citem, CLIST_ITEMC);
  1785. co2_Release_Graphic();
  1786. key[K_ESC] = 0;
  1787. if (dh) {
  1788. ddx2ReleaseBitmap(sh);
  1789. ddx2DeviceDeaktivuj();
  1790. ddx2DeviceRemove(dh);
  1791. ddx2Release();
  1792. dh = 0;
  1793. }
  1794. FreeAnimations2(res, RES_NUM);
  1795. free((void *) res);
  1796. // fn2_Set_Font("font3d.pak");
  1797. // fn2_Load_Bitmaps();
  1798. ddx2GameRender(TRUE);
  1799. p_Level->bRestart = 0;
  1800. return iReturn;
  1801. }
  1802. int LoadHelp(char *c_file)
  1803. {
  1804. int c = 0, i = -1;
  1805. char text[MAX_FILENAME];
  1806. FILE *file;
  1807. construct_path(text, MAX_FILENAME, 2, pBmpDir, c_file);
  1808. file = fopen(text, "r");
  1809. if (!file)
  1810. return -1;
  1811. while (!feof(file)) {
  1812. memset(text, 0, 256);
  1813. if (fgets(text, 256, file) && text[0]) {
  1814. newline_cut(text);
  1815. if (!c)
  1816. i = ddx2LoadBitmap(text, pBmpDir);
  1817. else
  1818. ddx2LoadBitmap(text, pBmpDir);
  1819. //kprintf(1, "%s - %d", text, t);
  1820. c++;
  1821. }
  1822. }
  1823. fclose(file);
  1824. return i;
  1825. }
  1826. int DrawHelp(int iBmp, int iSurface, int *iHelpIndex)
  1827. {
  1828. int y, ty;
  1829. RECT rect = { 10, 0, 776, 1000 };
  1830. if (iSurface == -1)
  1831. return 0;
  1832. iHelpIndex[0] = 0;
  1833. co2_Set_Text(iSurface, 10, 10, "##help_introduction_main", 1);
  1834. y =
  1835. co2_Set_Text_Formated_Rect(iSurface, 10, 60, "##help_introduction_h", 0,
  1836. &rect) + 50;
  1837. //BERUSKA/////////////////////////////////////////////////////////////////////////////////////////////////
  1838. iHelpIndex[1] = y;
  1839. co2_Set_Text(iSurface, 10, y, "##help_beatle_main", 1);
  1840. y += 50;
  1841. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 3), ddx2GetHeight(iBmp + 3),
  1842. iBmp + 3, 0, 0);
  1843. rect.left = 10 + ddx2GetWidth(iBmp + 3);
  1844. y =
  1845. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_beatle_h", 0,
  1846. &rect) + 50;
  1847. //EXIT/////////////////////////////////////////////////////////////////////////////////////////////////
  1848. iHelpIndex[2] = y;
  1849. co2_Set_Text(iSurface, 10, y, "##help_exit_main", 1);
  1850. y += 50;
  1851. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 4), ddx2GetHeight(iBmp + 4),
  1852. iBmp + 4, 0, 0);
  1853. rect.left = 10 + ddx2GetWidth(iBmp + 4);
  1854. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_exit_h", 0,
  1855. &rect);
  1856. y += ddx2GetHeight(iBmp + 4) + 50;
  1857. //ZED/////////////////////////////////////////////////////////////////////////////////////////////////
  1858. iHelpIndex[3] = y;
  1859. co2_Set_Text(iSurface, 10, y, "##help_wall_main", 1);
  1860. y += 50;
  1861. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 15),
  1862. ddx2GetHeight(iBmp + 15), iBmp + 15, 0, 0);
  1863. rect.left = 10 + ddx2GetWidth(iBmp + 15);
  1864. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_wall_h", 0,
  1865. &rect);
  1866. y += ddx2GetHeight(iBmp + 15) + 50;
  1867. //SIKMINA/////////////////////////////////////////////////////////////////////////////////////////////////
  1868. iHelpIndex[4] = y;
  1869. co2_Set_Text(iSurface, 10, y, "##help_up_main", 1);
  1870. y += 50;
  1871. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 8), ddx2GetHeight(iBmp + 8),
  1872. iBmp + 8, 0, 0);
  1873. rect.left = 10 + ddx2GetWidth(iBmp + 8);
  1874. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_up_h", 0, &rect);
  1875. y += ddx2GetHeight(iBmp + 8) + 50;
  1876. //BEDNA LEHKA /////////////////////////////////////////////////////////////////////////////////////////////////
  1877. iHelpIndex[5] = y;
  1878. co2_Set_Text(iSurface, 10, y, "##help_empty_box_main", 1);
  1879. y += 50;
  1880. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 1), ddx2GetHeight(iBmp + 1),
  1881. iBmp + 1, 0, 0);
  1882. rect.left = 10 + ddx2GetWidth(iBmp + 1);
  1883. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_empty_box_h", 0,
  1884. &rect);
  1885. y += ddx2GetHeight(iBmp + 1) + 50;
  1886. //BEDNA TEZKA /////////////////////////////////////////////////////////////////////////////////////////////////
  1887. iHelpIndex[6] = y;
  1888. co2_Set_Text(iSurface, 10, y, "##help_full_box_main", 1);
  1889. y += 50;
  1890. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 2), ddx2GetHeight(iBmp + 2),
  1891. iBmp + 2, 0, 0);
  1892. rect.left = 10 + ddx2GetWidth(iBmp + 2);
  1893. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_full_box_h", 0,
  1894. &rect);
  1895. y += ddx2GetHeight(iBmp + 2) + 50;
  1896. //BEDNA TNT /////////////////////////////////////////////////////////////////////////////////////////////////
  1897. iHelpIndex[7] = y;
  1898. co2_Set_Text(iSurface, 10, y, "##help_tnt_box_main", 1);
  1899. y += 50;
  1900. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 11),
  1901. ddx2GetHeight(iBmp + 11), iBmp + 11, 0, 0);
  1902. rect.left = 10 + ddx2GetWidth(iBmp + 11);
  1903. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_tnt_box_h", 0,
  1904. &rect);
  1905. y += ddx2GetHeight(iBmp + 11) + 50;
  1906. //KAMEN /////////////////////////////////////////////////////////////////////////////////////////////////
  1907. iHelpIndex[8] = y;
  1908. co2_Set_Text(iSurface, 10, y, "##help_rock_main", 1);
  1909. y += 50;
  1910. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 5), ddx2GetHeight(iBmp + 5),
  1911. iBmp + 5, 0, 0);
  1912. rect.left = 10 + ddx2GetWidth(iBmp + 5);
  1913. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_rock_h", 0,
  1914. &rect);
  1915. y += ddx2GetHeight(iBmp + 5) + 50;
  1916. //Tlacitko /////////////////////////////////////////////////////////////////////////////////////////////////
  1917. iHelpIndex[9] = y;
  1918. co2_Set_Text(iSurface, 10, y, "##help_button_main", 1);
  1919. y += 50;
  1920. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 10),
  1921. ddx2GetHeight(iBmp + 10), iBmp + 10, 0, 0);
  1922. rect.left = 10 + ddx2GetWidth(iBmp + 10);
  1923. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_button_h", 0,
  1924. &rect);
  1925. y += ddx2GetHeight(iBmp + 10) + 50;
  1926. //TELEPORT /////////////////////////////////////////////////////////////////////////////////////////////////
  1927. iHelpIndex[10] = y;
  1928. co2_Set_Text(iSurface, 10, y, "##help_teleport_main", 1);
  1929. y += 50;
  1930. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 9), ddx2GetHeight(iBmp + 9),
  1931. iBmp + 9, 0, 0);
  1932. rect.left = 10 + ddx2GetWidth(iBmp + 9);
  1933. ty = y + ddx2GetHeight(iBmp + 9) + 50;
  1934. y =
  1935. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_teleport_h", 0,
  1936. &rect) + 50;
  1937. //TELEPORT NA TLACITKO/////////////////////////////////////////////////////////////////////////////////////////////////
  1938. iHelpIndex[11] = y;
  1939. co2_Set_Text(iSurface, rect.left, y, "##help_teleport_button_main", 1);
  1940. y += 50;
  1941. y =
  1942. co2_Set_Text_Formated_Rect(iSurface, rect.left, y,
  1943. "##help_teleport_button_h", 0, &rect);
  1944. y = ty;
  1945. //VYTAH /////////////////////////////////////////////////////////////////////////////////////////////////
  1946. iHelpIndex[12] = y;
  1947. co2_Set_Text(iSurface, 10, y, "##help_lift_main", 1);
  1948. y += 50;
  1949. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 12),
  1950. ddx2GetHeight(iBmp + 12), iBmp + 12, 0, 0);
  1951. rect.left = 10 + ddx2GetWidth(iBmp + 12);
  1952. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_lift_h", 0,
  1953. &rect);
  1954. y += ddx2GetHeight(iBmp + 12) + 50;
  1955. //VYTAH NA VAHU /////////////////////////////////////////////////////////////////////////////////////////////////
  1956. iHelpIndex[13] = y;
  1957. co2_Set_Text(iSurface, 10, y, "##help_lift_weight_main", 1);
  1958. y += 50;
  1959. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 17),
  1960. ddx2GetHeight(iBmp + 17), iBmp + 17, 0, 0);
  1961. rect.left = 10 + ddx2GetWidth(iBmp + 17);
  1962. ty = y + ddx2GetHeight(iBmp + 17) + 50;
  1963. y =
  1964. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_lift_weight_h",
  1965. 0, &rect);
  1966. y += 50;
  1967. //VYTAH NA TLACITKO /////////////////////////////////////////////////////////////////////////////////////////////////
  1968. iHelpIndex[14] = y;
  1969. co2_Set_Text(iSurface, 10, y, "##help_lift_button_main", 1);
  1970. y += 50;
  1971. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 18),
  1972. ddx2GetHeight(iBmp + 18), iBmp + 18, 0, 0);
  1973. rect.left = 10 + ddx2GetWidth(iBmp + 18);
  1974. ty = y + ddx2GetHeight(iBmp + 18) + 50;
  1975. y =
  1976. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_lift_button_h",
  1977. 0, &rect);
  1978. y = ty;
  1979. //VODA /////////////////////////////////////////////////////////////////////////////////////////////////
  1980. iHelpIndex[15] = y;
  1981. co2_Set_Text(iSurface, 10, y, "##help_water_main", 1);
  1982. y += 50;
  1983. rect.left = 10;
  1984. y =
  1985. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_water_h", 0,
  1986. &rect);
  1987. y += 50;
  1988. //PROPADLO /////////////////////////////////////////////////////////////////////////////////////////////////
  1989. iHelpIndex[16] = y;
  1990. co2_Set_Text(iSurface, 10, y, "##help_trap_door_main", 1);
  1991. y += 50;
  1992. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 7), ddx2GetHeight(iBmp + 7),
  1993. iBmp + 7, 0, 0);
  1994. rect.left = 10 + ddx2GetWidth(iBmp + 7);
  1995. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_trap_door_h", 0,
  1996. &rect);
  1997. y += ddx2GetHeight(iBmp + 7) + 50;
  1998. //SNORCHL /////////////////////////////////////////////////////////////////////////////////////////////////
  1999. iHelpIndex[17] = y;
  2000. co2_Set_Text(iSurface, 10, y, "##help_water_pipe_main", 1);
  2001. y += 50;
  2002. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 16),
  2003. ddx2GetHeight(iBmp + 16), iBmp + 16, 0, 0);
  2004. rect.left = 10 + ddx2GetWidth(iBmp + 16);
  2005. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_water_pipe_h", 0,
  2006. &rect);
  2007. y += ddx2GetHeight(iBmp + 16) + 50;
  2008. //JIDLO /////////////////////////////////////////////////////////////////////////////////////////////////
  2009. iHelpIndex[18] = y;
  2010. co2_Set_Text(iSurface, 10, y, "##help_hormonal_vitamine_main", 1);
  2011. y += 50;
  2012. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 13),
  2013. ddx2GetHeight(iBmp + 13), iBmp + 13, 0, 0);
  2014. rect.left = 10 + ddx2GetWidth(iBmp + 13);
  2015. co2_Set_Text_Formated_Rect(iSurface, rect.left, y,
  2016. "##help_hormonal_vitamine_h", 0, &rect);
  2017. y += ddx2GetHeight(iBmp + 13) + 50;
  2018. //ZAVAZI /////////////////////////////////////////////////////////////////////////////////////////////////
  2019. iHelpIndex[19] = y;
  2020. co2_Set_Text(iSurface, 10, y, "##help_iron_main", 1);
  2021. y += 50;
  2022. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 14),
  2023. ddx2GetHeight(iBmp + 14), iBmp + 14, 0, 0);
  2024. rect.left = 10 + ddx2GetWidth(iBmp + 14);
  2025. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_iron_h", 0,
  2026. &rect);
  2027. y += ddx2GetHeight(iBmp + 14) + 50;
  2028. //KROMPAC /////////////////////////////////////////////////////////////////////////////////////////////////
  2029. iHelpIndex[20] = y;
  2030. co2_Set_Text(iSurface, 10, y, "##help_rock_axe_main", 1);
  2031. y += 50;
  2032. ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 6), ddx2GetHeight(iBmp + 6),
  2033. iBmp + 6, 0, 0);
  2034. rect.left = 10 + ddx2GetWidth(iBmp + 6);
  2035. co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_rock_axe_h", 0,
  2036. &rect);
  2037. y += ddx2GetHeight(iBmp + 6) + 50;
  2038. return 1;
  2039. }
  2040. void RunMenuHelp2(char *p_File_Name, AUDIO_DATA * p_ad, LEVELINFO * p_Level,
  2041. ANIMATION_MODULE * p_am)
  2042. {
  2043. int mix, miy;
  2044. RECT rTMP = { 0, 0, 1024, 768 };
  2045. DWORD dwEplased = 0, dwStart, dwStop;
  2046. CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
  2047. int lastcmd, lastanm, i;
  2048. CMD_LINE *res = NULL;
  2049. int lastabv = -1;
  2050. char in, click = 0;
  2051. int anmid = -1, resid = -1, anbind = -1;
  2052. int bind;
  2053. DeviceHandle dh = 0;
  2054. int sh = K_CHYBA;
  2055. int sh1 = K_CHYBA;
  2056. int sh2 = K_CHYBA;
  2057. int iBmp;
  2058. int iHelpIndex[23];
  2059. int iComboSel = 0;
  2060. int iComboActSel = 0;
  2061. _3d_End_Draw();
  2062. ZeroMemory(iHelpIndex, 23 * sizeof(int));
  2063. _2d_Clear_RectLine(&rline);
  2064. p_Level->iCursor = 133;
  2065. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2066. ddx2Init(200, RGB(255, 0, 255));
  2067. dh = ddx2DeviceCreate(TRUE, 32);
  2068. ddx2DeviceSetActive(dh);
  2069. ddx2DeviceSetBackBufferSize(1024, 768);
  2070. ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
  2071. ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
  2072. ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
  2073. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2074. ddx2CleareSurface(DDX2_BACK_BUFFER);
  2075. sh = ddx2LoadBitmap("help_frame.png", pBmpDir);
  2076. sh1 = ddx2LoadBitmap("set_back2-1.png", pBmpDir);
  2077. sh2 = ddx2LoadBitmap("set_back1-1.png", pBmpDir);
  2078. ddx2FillRect(DDX2_BACK_BUFFER, &rTMP, RGB(255, 0, 255));
  2079. ddx2SetRect(&rTMP, 1);
  2080. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2081. res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
  2082. LoadHelp("helpbook.txt");
  2083. iBmp = LoadHelp("helpload.txt");
  2084. iCompositDC = ddx2FindFreeSurface();
  2085. CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
  2086. iFontDC = ddx2FindFreeSurface();
  2087. FontDC = ddx2CreateSurface(1024, 768, iFontDC);
  2088. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2089. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
  2090. fn2_Set_Font(cFontDir[2]);
  2091. fn2_Load_Bitmaps();
  2092. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2093. for (bind = 0; bind < RES_NUM; bind++) {
  2094. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  2095. res[bind].iAnim[lastcmd][11] = -1;
  2096. res[bind].iAnim[lastcmd][0] = -1;
  2097. }
  2098. for (in = 0; in < 6; in++)
  2099. res[bind].iParam[(int)in] = -1;
  2100. res[bind].iLayer = 0;
  2101. }
  2102. lastcmd = 0;
  2103. timercnt = 0;
  2104. if (chdir(DATA_DIR)) {
  2105. free((void *) res);
  2106. return;
  2107. }
  2108. char dir[MAX_FILENAME];
  2109. strcpy(dir, DATA_DIR);
  2110. //natadhe skript menu
  2111. LoadMenuScript(p_File_Name, res, &lastcmd);
  2112. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2113. in = 0;
  2114. //CreateFontAnimations2(res, &lastcmd);
  2115. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  2116. // animace na OnAbove
  2117. for (i = 0; i < lastcmd; i++) {
  2118. lastanm = 0;
  2119. switch (res[i].iParam[0]) {
  2120. case COM_DRAW:
  2121. // if(!res[i].iLayer)
  2122. ddx2DrawDisplay(res[i].iParam, 0);
  2123. /* else
  2124. ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR );
  2125. ddx2DrawSurface(FontDC, res[i].iParam, 3);*/
  2126. break;
  2127. case COM_RANDOMANIMATION:
  2128. case COM_ONCLICK:
  2129. case COM_ONABOVE:
  2130. case COM_RUNANIMATION:
  2131. case COM_BINDEXITANIMATION:
  2132. case COM_BINDANIMATION:
  2133. //nahrati animace k udalosti OnAbove
  2134. LoadAnimationMenuScript(res, i, &lastanm);
  2135. break;
  2136. }
  2137. }
  2138. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2139. if (!co2_Load_Graphic(1)) {
  2140. kprintf(1, "co2_Load_Graphic ... con't load controls!");
  2141. assert(0);
  2142. }
  2143. else {
  2144. citem[0].p_combo = co2_Create_Combo(HDC2DD, 100, 67, 500, 0);
  2145. citem[0].bActive = 1;
  2146. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_introduction_mainc");
  2147. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_beatle_mainc");
  2148. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_exit_mainc");
  2149. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_wall_mainc");
  2150. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_up_mainc");
  2151. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_empty_box_mainc");
  2152. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_full_box_mainc");
  2153. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_tnt_box_mainc");
  2154. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_rock_mainc");
  2155. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_button_mainc");
  2156. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_teleport_mainc");
  2157. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_teleport_button_mainc");
  2158. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_lift_mainc");
  2159. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_lift_weight_mainc");
  2160. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_lift_button_mainc");
  2161. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_water_mainc");
  2162. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_trap_door_mainc");
  2163. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_water_pipe_mainc");
  2164. co2_Combo_Add_StringWC(citem[0].p_combo,
  2165. "##help_hormonal_vitamine_mainc");
  2166. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_iron_mainc");
  2167. co2_Combo_Add_StringWC(citem[0].p_combo, "##help_rock_axe_mainc");
  2168. co2_Combo_Set_Params(citem[0].p_combo, 19);
  2169. co2_Combo_Set_Sel(HDC2DD, citem[0].p_combo, 0);
  2170. citem[1].p_list_v =
  2171. co2_Create_List_View(HDC2DD, 100, 107, 828, 622, 0, 6800);
  2172. citem[1].bActive = 1;
  2173. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2174. DrawHelp(iBmp, co2_Get_List_View_DC(citem[1].p_list_v), iHelpIndex);
  2175. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2176. co2_List_View_Redraw(HDC2DD, citem[1].p_list_v, 0);
  2177. }
  2178. for (i = 0; i < lastcmd; i++)
  2179. if (res[i].iParam[0] == COM_RUNANIMATION) {
  2180. int iWave = AddAnimation2(&res[i], &ad, 0);
  2181. if (iWave != -1) {
  2182. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2183. anm[iWave].iWave = res[i + 1].iParam[5] =
  2184. mPlaySound2(&res[i + 1], &ad, 2);
  2185. }
  2186. }
  2187. mi.t1 = 0;
  2188. mi.t2 = 0;
  2189. mi.dx = 0;
  2190. mi.dy = 0;
  2191. anmid = -1;
  2192. resid = -1;
  2193. anbind = -1;
  2194. bind = -1;
  2195. lastabv = -1;
  2196. in = 0;
  2197. p_Level->iCursor = 0;
  2198. ddx2GameRender(FALSE);
  2199. ddx2DeviceSetRender(TRUE);
  2200. spracuj_spravy(0);
  2201. while (!key[K_ESC]) {
  2202. mix = mi.x;
  2203. miy = mi.y;
  2204. mi.x = (int) ceil(mi.x * scale_factor_x());
  2205. mi.y = (int) ceil(mi.y * scale_factor_y());
  2206. dwStart = timeGetTime();
  2207. //pohnul mysi
  2208. if (mi.dx || mi.dy) {
  2209. //dostala se mys do akcni oblasti (OnAbove)?
  2210. if (!click)
  2211. for (i = 0; i < lastcmd; i++)
  2212. if (res[i].iParam[0] == COM_ONABOVE) {
  2213. if ((mi.x >= res[i].iParam[1]) &&
  2214. (mi.x <= res[i].iParam[3]) &&
  2215. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  2216. //spusteni animace v OnAbove
  2217. if (i != lastabv) {
  2218. if (in) {
  2219. Stop2(&res[lastabv]);
  2220. if (!res[lastabv].iLayer) {
  2221. ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
  2222. ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  2223. }
  2224. else {
  2225. ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
  2226. TRANSCOLOR);
  2227. ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  2228. }
  2229. }
  2230. CheckAnimation2(&res[i], &ad);
  2231. lastabv = i;
  2232. AddAnimation2(&res[i], &ad, 0);
  2233. in = 1;
  2234. bind = ChooseBidedAnimation2(res, i + 1, &ad);
  2235. if (bind != -1) {
  2236. CheckAnimation2(&res[bind], &ad);
  2237. AddAnimation2(&res[bind], &ad, 1);
  2238. anbind = bind;
  2239. mPlaySound2(&res[bind], &ad, 0);
  2240. }
  2241. strcpy(dir, res[i].cParam[1]);
  2242. }
  2243. }
  2244. else if (lastabv == i) {
  2245. // odesel z oblasti, ktera byla aktivni -> stop animace
  2246. // a odznaceni oblasti
  2247. Stop2(&res[i]);
  2248. if (!res[i].iLayer) {
  2249. ddx2DrawDisplay(res[i].iAnim[0], 0);
  2250. ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
  2251. }
  2252. else {
  2253. ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  2254. ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
  2255. }
  2256. bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
  2257. if (bind != -1) {
  2258. int iAnim;
  2259. if (anbind != -1) {
  2260. Stop2(&res[anbind]);
  2261. if (!res[i].iLayer) {
  2262. ddx2DrawDisplay(res[anbind].iAnim[0], 0);
  2263. ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  2264. }
  2265. else {
  2266. ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
  2267. TRANSCOLOR);
  2268. ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
  2269. }
  2270. }
  2271. iAnim = AddAnimation2(&res[bind], &ad, 1);
  2272. if (iAnim != -1)
  2273. anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
  2274. }
  2275. lastabv = -1;
  2276. anbind = -1;
  2277. in = 0;
  2278. strcpy(dir, "");
  2279. }
  2280. }
  2281. mi.dx = 0;
  2282. mi.dy = 0;
  2283. }
  2284. co2_Handle_Controls(citem, CLIST_ITEMC, mi.x, mi.y, HDC2DD, 0, 0);
  2285. iComboActSel = co2_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 0);
  2286. if (iComboActSel != iComboSel && iComboActSel != -1) {
  2287. co2_Set_List_View_List_Pos(citem[1].p_list_v, iHelpIndex[iComboActSel],
  2288. HDC2DD, 0, 0);
  2289. iComboSel = iComboActSel;
  2290. }
  2291. //stlacil leve tlacitko
  2292. if (mi.t1 && !click) {
  2293. if (co2_Is_Button_Activated(citem, CLIST_ITEMC, 0)) {
  2294. float pos[3] = { 0, 0, 0 };
  2295. ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
  2296. key[K_ESC] = 1;
  2297. p_Level->bResetini = 1;
  2298. }
  2299. //dostala se mys do akcni oblasti (OnClick)?
  2300. for (i = 0; i < lastcmd; i++)
  2301. if (res[i].iParam[0] == COM_ONCLICK)
  2302. if ((mi.x >= res[i].iParam[1]) &&
  2303. (mi.x <= res[i].iParam[3]) &&
  2304. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  2305. if (res[i].iAnim[0][0] >= 0) {
  2306. //pokud je animace, tak ji spust
  2307. anmid = AddAnimation2(&res[i], &ad, 0);
  2308. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2309. mPlaySound2(&res[i + 1], &ad, 1);
  2310. resid = i;
  2311. click = 1;
  2312. }
  2313. else {
  2314. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2315. mPlaySound2(&res[i + 1], &ad, 1);
  2316. resid = i;
  2317. click = 1;
  2318. anmid = 31;
  2319. }
  2320. }
  2321. mi.t1 = 0;
  2322. }
  2323. //provedeni akce po animaci menu
  2324. if (click)
  2325. if (!anm[anmid].cmd) {
  2326. click = 0;
  2327. //StopAll();
  2328. if (!strcmp(res[resid].cParam[1], "EXIT")) {
  2329. key[K_ESC] = 1;
  2330. //break;
  2331. }
  2332. resid = -1;
  2333. if (key[K_ESC]) {
  2334. for(i=0;i<lastcmd;i++)
  2335. if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1) {
  2336. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  2337. res[i].iParam[5] = -1;
  2338. }
  2339. goto __QUIT;
  2340. }
  2341. }
  2342. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  2343. if (timercnt > 500) {
  2344. timercnt = 0;
  2345. for (i = 0; i < lastcmd; i++)
  2346. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  2347. if (rand() % 200 <= res[i].iParam[1] &&
  2348. strcmp(dir, res[i].cParam[0])) {
  2349. CheckAnimation2(&res[i], &ad);
  2350. AddAnimation2(&res[i], &ad, 0);
  2351. }
  2352. }
  2353. dwStop = timeGetTime();
  2354. dwEplased += dwStop - dwStart;
  2355. AnimationEvent2(NULL, 0, 0, dwStop);
  2356. mi.x = mix;
  2357. mi.y = miy;
  2358. am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2359. }
  2360. __QUIT:
  2361. ddx2ReleaseBitmap(iCompositDC);
  2362. ddx2ReleaseBitmap(iFontDC);
  2363. fn2_Release_Font();
  2364. StopAll2();
  2365. co2_Handle_Release(citem, CLIST_ITEMC);
  2366. co2_Release_Graphic();
  2367. key[K_ESC] = 0;
  2368. if (dh) {
  2369. ddx2ReleaseBitmap(sh);
  2370. ddx2ReleaseBitmap(sh1);
  2371. ddx2ReleaseBitmap(sh2);
  2372. ddx2DeviceDeaktivuj();
  2373. ddx2DeviceRemove(dh);
  2374. ddx2Release();
  2375. dh = 0;
  2376. }
  2377. FreeAnimations2(res, RES_NUM);
  2378. free((void *) res);
  2379. // fn2_Set_Font("font3d.pak");
  2380. // fn2_Load_Bitmaps();
  2381. // Start renderu hry
  2382. ddx2GameRender(TRUE);
  2383. }
  2384. void GetSceneString(char *cscene)
  2385. {
  2386. if (iActualScene < 0 || iActualScene > 12)
  2387. strcpy(cscene, "##scene_name_unknown");
  2388. else
  2389. sprintf(cscene, "##scene_name_%d", iActualScene);
  2390. return;
  2391. }
  2392. void GetLevelTime(char *ctime, LEVELINFO * p_Level)
  2393. {
  2394. long iTime = (int) floor(p_Level->dwPlayTime / 1000.0f);
  2395. int sec = iTime % 60;
  2396. int min;
  2397. int hour;
  2398. char cmin[12];
  2399. char csec[12];
  2400. iTime = (int) floor(iTime / 60.0f);
  2401. min = iTime % 60;
  2402. iTime = (int) floor(iTime / 60.0f);
  2403. hour = iTime % 60;
  2404. if (sec < 10)
  2405. sprintf(csec, "0%d", sec);
  2406. else
  2407. sprintf(csec, "%d", sec);
  2408. if (min < 10)
  2409. sprintf(cmin, "0%d", min);
  2410. else
  2411. sprintf(cmin, "%d", min);
  2412. if (!min && !hour) {
  2413. sprintf(ctime, "00:%d", sec);
  2414. /*sprintf(ctime, "%d sekund", sec);
  2415. if(sec < 2)
  2416. strcat(ctime, "a");
  2417. if(sec > 1 && sec < 5)
  2418. strcat(ctime, "y"); */
  2419. }
  2420. else if (!hour)
  2421. sprintf(ctime, "%s:%s", cmin, csec);
  2422. else
  2423. sprintf(ctime, "%d:%s:%s", hour, cmin, csec);
  2424. }
  2425. int LoadCList2(char *cFile)
  2426. {
  2427. int c = 0, i = -1;
  2428. char text[MAX_FILENAME];
  2429. FILE *file;
  2430. construct_path(text, MAX_FILENAME, 2, pBmpDir, cFile);
  2431. file = fopen(text, "r");
  2432. if (!file)
  2433. return -1;
  2434. while (!feof(file)) {
  2435. memset(text, 0, 256);
  2436. if (fgets(text, 256, file) && text[0]) {
  2437. newline_cut(text);
  2438. if (!c)
  2439. i = ddx2LoadBitmap(text, pBmpDir);
  2440. else
  2441. ddx2LoadBitmap(text, pBmpDir);
  2442. c++;
  2443. }
  2444. }
  2445. fclose(file);
  2446. return i;
  2447. }
  2448. void RunMenuLevelStats2(char *p_File_Name, AUDIO_DATA * p_ad,
  2449. LEVELINFO * p_Level, ANIMATION_MODULE * p_am)
  2450. {
  2451. int mix, miy;
  2452. RECT rTMP = { 0, 0, 1024, 768 };
  2453. DWORD dwEplased = 0, dwStart, dwStop;
  2454. CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
  2455. int lastcmd, lastanm, i;
  2456. CMD_LINE *res = NULL;
  2457. int lastabv = -1;
  2458. char in, click = 0;
  2459. int anmid = -1, resid = -1, anbind = -1;
  2460. int bind;
  2461. DeviceHandle dh = 0;
  2462. int sh = K_CHYBA;
  2463. int ifdx = 0;
  2464. _2d_Clear_RectLine(&rline);
  2465. _2d_Add_RectItem(&rline, rTMP, 0);
  2466. ddx2Init(200, RGB(255, 0, 255));
  2467. dh = ddx2DeviceCreate(TRUE, 32);
  2468. ddx2DeviceSetActive(dh);
  2469. ddx2DeviceSetBackBufferSize(1024, 768);
  2470. ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
  2471. ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
  2472. ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
  2473. ddx2DeviceSetRender(TRUE);
  2474. ddx2CleareSurface(DDX2_BACK_BUFFER);
  2475. switch (iActualScene) {
  2476. case 1:
  2477. case 2:
  2478. case 3:
  2479. case 4:
  2480. case 7:
  2481. sh = ddx2LoadBitmap("end_screen3.png", pBmpDir);
  2482. ifdx = 2;
  2483. break;
  2484. case 5:
  2485. case 8:
  2486. sh = ddx2LoadBitmap("end_screen1.png", pBmpDir);
  2487. ifdx = 0;
  2488. break;
  2489. case 0:
  2490. case 6:
  2491. case 9:
  2492. case 10:
  2493. case 11:
  2494. sh = ddx2LoadBitmap("end_screen2.png", pBmpDir);
  2495. ifdx = 1;
  2496. break;
  2497. case 12:
  2498. sh = ddx2LoadBitmap("end_screen4.png", pBmpDir);
  2499. ifdx = 3;
  2500. break;
  2501. default:
  2502. sh = ddx2LoadBitmap("end_screen4.png", pBmpDir);
  2503. ifdx = 3;
  2504. break;
  2505. }
  2506. if (sh == -1) {
  2507. kprintf(1, "RunMenuLevelStats2 ... sh == -1 !!!");
  2508. ddx2DeviceDeaktivuj();
  2509. ddx2DeviceRemove(dh);
  2510. ddx2Release();
  2511. ddx2GameRender(TRUE);
  2512. return;
  2513. }
  2514. ddx2SetRect(&rTMP, 1);
  2515. ddx2GameRender(FALSE);
  2516. res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
  2517. iCompositDC = ddx2FindFreeSurface();
  2518. CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
  2519. iFontDC = ddx2FindFreeSurface();
  2520. FontDC = ddx2CreateSurface(1024, 768, iFontDC);
  2521. LoadCList2("load_bs.txt");
  2522. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
  2523. fn2_Set_Font(cFontDir[3]);
  2524. fn2_Load_Bitmaps();
  2525. for (bind = 0; bind < RES_NUM; bind++) {
  2526. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  2527. res[bind].iAnim[lastcmd][11] = -1;
  2528. res[bind].iAnim[lastcmd][0] = -1;
  2529. }
  2530. for (in = 0; in < 6; in++)
  2531. res[bind].iParam[(int)in] = -1;
  2532. res[bind].iLayer = 0;
  2533. }
  2534. lastcmd = 0;
  2535. timercnt = 0;
  2536. if (chdir(DATA_DIR)) {
  2537. free((void *) res);
  2538. return;
  2539. }
  2540. char dir[MAX_FILENAME];
  2541. strcpy(dir, DATA_DIR);
  2542. //natadhe skript menu
  2543. LoadMenuScript(p_File_Name, res, &lastcmd);
  2544. in = 0;
  2545. //CreateFontAnimations2(res, &lastcmd, 0, 0);
  2546. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  2547. // animace na OnAbove
  2548. for (i = 0; i < lastcmd; i++) {
  2549. lastanm = 0;
  2550. switch (res[i].iParam[0]) {
  2551. case COM_DRAW:
  2552. //if(!res[i].iLayer)
  2553. ddx2DrawDisplay(res[i].iParam, 0);
  2554. break;
  2555. case COM_RANDOMANIMATION:
  2556. case COM_ONCLICK:
  2557. case COM_ONABOVE:
  2558. case COM_RUNANIMATION:
  2559. case COM_BINDEXITANIMATION:
  2560. case COM_BINDANIMATION:
  2561. //nahrati animace k udalosti OnAbove
  2562. LoadAnimationMenuScript(res, i, &lastanm);
  2563. break;
  2564. }
  2565. }
  2566. co2_Set_Text(HDC2DD, 50, 50, "##stats_scene", ifdx);
  2567. co2_Set_Text(HDC2DD, 50, 80, "##stats_time", ifdx);
  2568. co2_Set_Text(HDC2DD, 50, 110, "##stats_steps", ifdx);
  2569. GetSceneString(dir);
  2570. co2_Set_Text(HDC2DD, 250, 50, dir, ifdx);
  2571. GetLevelTime(dir, p_Level);
  2572. co2_Set_TextWC(HDC2DD, 250, 80, dir, ifdx);
  2573. co2_Set_TextWC(HDC2DD, 250, 110, itoa(p_Level->iNumOfSteps, dir, 10), ifdx);
  2574. for (i = 0; i < lastcmd; i++)
  2575. if (res[i].iParam[0] == COM_RUNANIMATION) {
  2576. int iWave = AddAnimation2(&res[i], &ad, 0);
  2577. if (iWave != -1) {
  2578. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2579. anm[iWave].iWave = res[i + 1].iParam[5] =
  2580. mPlaySound2(&res[i + 1], &ad, 2);
  2581. }
  2582. }
  2583. mi.t1 = 0;
  2584. mi.t2 = 0;
  2585. mi.dx = 0;
  2586. mi.dy = 0;
  2587. anmid = -1;
  2588. resid = -1;
  2589. anbind = -1;
  2590. bind = -1;
  2591. lastabv = -1;
  2592. in = 0;
  2593. spracuj_spravy(0);
  2594. while (!key[K_ESC] && !key[K_ENTER]) {
  2595. mix = mi.x;
  2596. miy = mi.y;
  2597. mi.x = (int) ceil(mi.x * scale_factor_x());
  2598. mi.y = (int) ceil(mi.y * scale_factor_y());
  2599. dwStart = timeGetTime();
  2600. //pohnul mysi
  2601. if (mi.dx || mi.dy) {
  2602. //dostala se mys do akcni oblasti (OnAbove)?
  2603. if (!click)
  2604. for (i = 0; i < lastcmd; i++)
  2605. if (res[i].iParam[0] == COM_ONABOVE) {
  2606. if ((mi.x >= res[i].iParam[1]) &&
  2607. (mi.x <= res[i].iParam[3]) &&
  2608. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  2609. //kprintf(1, "i = %d, lastabv = %d", i, lastabv);
  2610. //spusteni animace v OnAbove
  2611. if (i != lastabv) {
  2612. //kprintf(1, "in = %d, %d, %d, %d = mi = %d, %d", res[i].iParam[1], res[i].iParam[2], res[i].iParam[3], res[i].iParam[4], mi.x, mi.y);
  2613. if (in) {
  2614. Stop2(&res[lastabv]);
  2615. if (!res[lastabv].iLayer) {
  2616. ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
  2617. ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  2618. }
  2619. else {
  2620. ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
  2621. TRANSCOLOR);
  2622. ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  2623. }
  2624. }
  2625. CheckAnimation2(&res[i], &ad);
  2626. lastabv = i;
  2627. AddAnimation2(&res[i], &ad, 0);
  2628. in = 1;
  2629. bind = ChooseBidedAnimation2(res, i + 1, &ad);
  2630. if (bind != -1) {
  2631. CheckAnimation2(&res[bind], &ad);
  2632. AddAnimation2(&res[bind], &ad, 1);
  2633. anbind = bind;
  2634. mPlaySound2(&res[bind], &ad, 0);
  2635. }
  2636. strcpy(dir, res[i].cParam[1]);
  2637. }
  2638. }
  2639. else if (lastabv == i) {
  2640. //kprintf(1, "out mi = %d, %d", mi.x, mi.y);
  2641. // odesel z oblasti, ktera byla aktivni -> stop animace
  2642. // a odznaceni oblasti
  2643. Stop2(&res[i]);
  2644. if (!res[i].iLayer) {
  2645. ddx2DrawDisplay(res[i].iAnim[0], 0);
  2646. ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
  2647. }
  2648. else {
  2649. ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  2650. ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
  2651. }
  2652. bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
  2653. if (bind != -1) {
  2654. int iAnim;
  2655. if (anbind != -1) {
  2656. Stop2(&res[anbind]);
  2657. if (!res[i].iLayer) {
  2658. ddx2DrawDisplay(res[anbind].iAnim[0], 0);
  2659. ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  2660. }
  2661. else {
  2662. ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,TRANSCOLOR);
  2663. ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
  2664. }
  2665. }
  2666. iAnim = AddAnimation2(&res[bind], &ad, 1);
  2667. if (iAnim != -1)
  2668. anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
  2669. }
  2670. lastabv = -1;
  2671. anbind = -1;
  2672. in = 0;
  2673. strcpy(dir, "");
  2674. }
  2675. }
  2676. mi.dx = 0;
  2677. mi.dy = 0;
  2678. }
  2679. //stlacil leve tlacitko
  2680. if (mi.t1 && !click) {
  2681. //dostala se mys do akcni oblasti (OnClick)?
  2682. for (i = 0; i < lastcmd; i++) {
  2683. if (res[i].iParam[0] == COM_ONCLICK) {
  2684. if ((mi.x >= res[i].iParam[1]) &&
  2685. (mi.x <= res[i].iParam[3]) &&
  2686. (mi.y >= res[i].iParam[2]) &&
  2687. (mi.y <= res[i].iParam[4]))
  2688. {
  2689. if (res[i].iAnim[0][0] >= 0) {
  2690. //pokud je animace, tak ji spust
  2691. anmid = AddAnimation2(&res[i], &ad, 0);
  2692. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2693. mPlaySound2(&res[i + 1], &ad, 1);
  2694. resid = i;
  2695. click = 1;
  2696. }
  2697. else {
  2698. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2699. mPlaySound2(&res[i + 1], &ad, 1);
  2700. resid = i;
  2701. click = 1;
  2702. anmid = 31;
  2703. }
  2704. }
  2705. }
  2706. }
  2707. mi.t1 = 0;
  2708. }
  2709. //provedeni akce po animaci menu
  2710. if (click) {
  2711. if (!anm[anmid].cmd) {
  2712. click = 0;
  2713. if (!strcmp(res[resid].cParam[1], "EXIT")) {
  2714. key[K_ESC] = 1;
  2715. //break;
  2716. }
  2717. resid = -1;
  2718. if (key[K_ESC]) {
  2719. goto __QUIT;
  2720. }
  2721. }
  2722. }
  2723. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  2724. if (timercnt > 500) {
  2725. timercnt = 0;
  2726. for (i = 0; i < lastcmd; i++) {
  2727. if (res[i].iParam[0] == COM_RANDOMANIMATION) {
  2728. if (rand() % 200 <= res[i].iParam[1] && strcmp(dir, res[i].cParam[0])) {
  2729. CheckAnimation2(&res[i], &ad);
  2730. AddAnimation2(&res[i], &ad, 0);
  2731. }
  2732. }
  2733. }
  2734. }
  2735. dwStop = timeGetTime();
  2736. dwEplased += dwStop - dwStart;
  2737. AnimationEvent2(NULL, 0, 0, dwStop);
  2738. mi.x = mix;
  2739. mi.y = miy;
  2740. am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2741. }
  2742. __QUIT:
  2743. ddx2ReleaseBitmap(iCompositDC);
  2744. ddx2ReleaseBitmap(iFontDC);
  2745. fn2_Release_Font();
  2746. StopAll2();
  2747. key[K_ESC] = 0;
  2748. key[K_ENTER] = 0;
  2749. if (dh) {
  2750. ddx2ReleaseBitmap(sh);
  2751. ddx2DeviceDeaktivuj();
  2752. ddx2DeviceRemove(dh);
  2753. ddx2Release();
  2754. dh = 0;
  2755. }
  2756. FreeAnimations2(res, RES_NUM);
  2757. free((void *) res);
  2758. // Start renderu hry
  2759. ddx2GameRender(TRUE);
  2760. }
  2761. static void RunMenuTutorial2ResizeCallback(void)
  2762. {
  2763. ddx2DeviceSetScreenRec(ftoi(10 * scale_back_factor_x()),
  2764. ftoi(200 * scale_back_factor_y()),
  2765. ftoi(900 * scale_back_factor_x()),
  2766. ftoi(450 * scale_back_factor_y()));
  2767. }
  2768. void RunMenuTutorial2(char *p_File_Name, AUDIO_DATA * p_ad,
  2769. LEVELINFO * p_Level, ANIMATION_MODULE * p_am)
  2770. {
  2771. int mix, miy;
  2772. RECT rTMP = { 0, 0, 1024, 768 };
  2773. DWORD dwEplased = 0, dwStart, dwStop;
  2774. CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
  2775. int lastcmd, lastanm, i;
  2776. CMD_LINE *res = NULL;
  2777. int lastabv = -1;
  2778. char in, click = 0;
  2779. int anmid = -1, resid = -1, anbind = -1;
  2780. int bind;
  2781. DeviceHandle dh = 0;
  2782. int ycorrection = 0;
  2783. EDIT_TEXT ttext;
  2784. ZeroMemory(&ttext, sizeof(EDIT_TEXT));
  2785. p_Level->iCursor = 133;
  2786. am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
  2787. p_Level->iCursor = 0;
  2788. txt_trida(TEXT_MENU);
  2789. kom_set_default_text_config(0, 0, 1, 0, 0, 1);
  2790. txt_nahraj_texturu_z_func(p3DMDir, "tutor_frame.png", &ttext, 0, 1, NULL, bmp_nahraj);
  2791. kom_ret_default_text_config();
  2792. _2d_Clear_RectLine(&rline);
  2793. ddx2Init(200, RGB(255, 0, 255));
  2794. dh = ddx2DeviceCreate(FALSE, 32);
  2795. if (!dh)
  2796. return;
  2797. ddx2DeviceSetActive(dh);
  2798. ddx2DeviceSetBackBufferSize(1024, 768);
  2799. ddx2DeviceSetBackBufferRect(10, 200, 900, 450);
  2800. ddx2DeviceSetTextRenderRec(0, 0, 900, 450);
  2801. ddx2DeviceSetScreenRecCallback(RunMenuTutorial2ResizeCallback);
  2802. ddx2DeviceSetRender(TRUE);
  2803. ddx2CleareSurface(DDX2_BACK_BUFFER);
  2804. ddx2SetRect(&rTMP, 1);
  2805. // Stop renderu hry
  2806. ddx2GameRender(TRUE);
  2807. res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
  2808. iCompositDC = ddx2FindFreeSurface();
  2809. CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
  2810. iFontDC = ddx2FindFreeSurface();
  2811. FontDC = ddx2CreateSurface(1024, 768, iFontDC);
  2812. ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
  2813. fn2_Set_Font(cFontDir[2]);
  2814. fn2_Load_Bitmaps();
  2815. for (bind = 0; bind < RES_NUM; bind++) {
  2816. for (lastcmd = 0; lastcmd < 200; lastcmd++) {
  2817. res[bind].iAnim[lastcmd][11] = -1;
  2818. res[bind].iAnim[lastcmd][0] = -1;
  2819. }
  2820. for (in = 0; in < 6; in++)
  2821. res[bind].iParam[(int)in] = -1;
  2822. res[bind].iLayer = 0;
  2823. }
  2824. lastcmd = 0;
  2825. timercnt = 0;
  2826. if (chdir(DATA_DIR)) {
  2827. free((void *) res);
  2828. return;
  2829. }
  2830. char dir[MAX_FILENAME];
  2831. strcpy(dir, DATA_DIR);
  2832. //natadhe skript menu
  2833. LoadMenuScript(p_File_Name, res, &lastcmd);
  2834. //lastcmd--;
  2835. in = 0;
  2836. {
  2837. int ycor = 0;
  2838. char tt[256];
  2839. RECT rr = { 20, 210, 890, 758 };
  2840. sprintf(tt, "##tutorial_%d", iActualLevel - 200);
  2841. ycor = co2_Set_Text_Formated_Rect(HDC2DD, 20, 210, tt, 0, &rr);
  2842. //ycor = (200 + ycor + 50) - 600;
  2843. ycor = (ycor + 50) - 600;
  2844. _2d_Clear_RectLine(&rline);
  2845. rr.left = 10;
  2846. rr.top = 200;
  2847. rr.right = 910;
  2848. rr.bottom = 460;
  2849. ddx2AddRectItem(&rline, rr, 0);
  2850. ycorrection = CreateFontAnimations2(res, &lastcmd, ycor, 1);
  2851. //ycor = ftoi((ycor - 25) * s_factor[1]);
  2852. //ycor = ycor - 50;
  2853. //ycorrection = 650 + ycor;
  2854. }
  2855. // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
  2856. // animace na OnAbove
  2857. for (i = 0; i < lastcmd; i++) {
  2858. lastanm = 0;
  2859. switch (res[i].iParam[0]) {
  2860. case COM_DRAW:
  2861. if (!res[i].iLayer)
  2862. ddx2DrawDisplay(res[i].iParam, 0);
  2863. else
  2864. ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
  2865. ddx2DrawSurface(FontDC, res[i].iParam, 3);
  2866. break;
  2867. case COM_RANDOMANIMATION:
  2868. case COM_ONCLICK:
  2869. case COM_ONABOVE:
  2870. case COM_RUNANIMATION:
  2871. case COM_BINDEXITANIMATION:
  2872. case COM_BINDANIMATION:
  2873. //nahrati animace k udalosti OnAbove
  2874. LoadAnimationMenuScript(res, i, &lastanm);
  2875. break;
  2876. }
  2877. }
  2878. for (i = 0; i < lastcmd; i++)
  2879. if (res[i].iParam[0] == COM_RUNANIMATION) {
  2880. int iWave = AddAnimation2(&res[i], &ad, 0);
  2881. if (iWave != -1) {
  2882. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2883. anm[iWave].iWave = res[i + 1].iParam[5] =
  2884. mPlaySound2(&res[i + 1], &ad, 2);
  2885. }
  2886. }
  2887. mi.t1 = 0;
  2888. mi.t2 = 0;
  2889. mi.dx = 0;
  2890. mi.dy = 0;
  2891. anmid = -1;
  2892. resid = -1;
  2893. anbind = -1;
  2894. bind = -1;
  2895. lastabv = -1;
  2896. in = 0;
  2897. spracuj_spravy(0);
  2898. while (!key[K_ESC] && !key[K_ENTER]) {
  2899. mix = mi.x;
  2900. miy = mi.y;
  2901. mi.x = (int) ceil(mi.x * scale_factor_x());
  2902. mi.y = (int) ceil(mi.y * scale_factor_y());
  2903. dwStart = timeGetTime();
  2904. //pohnul mysi
  2905. if (mi.dx || mi.dy) {
  2906. //dostala se mys do akcni oblasti (OnAbove)?
  2907. if (!click)
  2908. for (i = 0; i < lastcmd; i++)
  2909. if (res[i].iParam[0] == COM_ONABOVE) {
  2910. if ((mi.x >= res[i].iParam[1]) &&
  2911. (mi.x <= res[i].iParam[3]) &&
  2912. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  2913. //kprintf(1, "i = %d, lastabv = %d", i, lastabv);
  2914. //spusteni animace v OnAbove
  2915. if (i != lastabv) {
  2916. //kprintf(1, "in = %d, %d, %d, %d = mi = %d, %d", res[i].iParam[1], res[i].iParam[2], res[i].iParam[3], res[i].iParam[4], mi.x, mi.y);
  2917. if (in) {
  2918. Stop2(&res[lastabv]);
  2919. if (!res[lastabv].iLayer) {
  2920. ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
  2921. ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
  2922. }
  2923. else {
  2924. ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
  2925. TRANSCOLOR);
  2926. ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
  2927. }
  2928. }
  2929. CheckAnimation2(&res[i], &ad);
  2930. lastabv = i;
  2931. AddAnimation2(&res[i], &ad, 0);
  2932. in = 1;
  2933. bind = ChooseBidedAnimation2(res, i + 1, &ad);
  2934. if (bind != -1) {
  2935. CheckAnimation2(&res[bind], &ad);
  2936. AddAnimation2(&res[bind], &ad, 1);
  2937. anbind = bind;
  2938. mPlaySound2(&res[bind], &ad, 0);
  2939. }
  2940. strcpy(dir, res[i].cParam[1]);
  2941. }
  2942. }
  2943. else if (lastabv == i) {
  2944. //kprintf(1, "out mi = %d, %d", mi.x, mi.y);
  2945. // odesel z oblasti, ktera byla aktivni -> stop animace
  2946. // a odznaceni oblasti
  2947. Stop2(&res[i]);
  2948. if (!res[i].iLayer) {
  2949. ddx2DrawDisplay(res[i].iAnim[0], 0);
  2950. ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
  2951. }
  2952. else {
  2953. ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
  2954. ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
  2955. }
  2956. bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
  2957. if (bind != -1) {
  2958. int iAnim;
  2959. if (anbind != -1) {
  2960. Stop2(&res[anbind]);
  2961. if (!res[i].iLayer) {
  2962. ddx2DrawDisplay(res[anbind].iAnim[0], 0);
  2963. ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
  2964. }
  2965. else {
  2966. ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
  2967. TRANSCOLOR);
  2968. ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
  2969. }
  2970. }
  2971. iAnim = AddAnimation2(&res[bind], &ad, 1);
  2972. if (iAnim != -1)
  2973. anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
  2974. }
  2975. lastabv = -1;
  2976. anbind = -1;
  2977. in = 0;
  2978. strcpy(dir, "");
  2979. }
  2980. }
  2981. mi.dx = 0;
  2982. mi.dy = 0;
  2983. }
  2984. //stlacil leve tlacitko
  2985. if (mi.t1 && !click) {
  2986. //dostala se mys do akcni oblasti (OnClick)?
  2987. for (i = 0; i < lastcmd; i++)
  2988. if (res[i].iParam[0] == COM_ONCLICK)
  2989. if ((mi.x >= res[i].iParam[1]) &&
  2990. (mi.x <= res[i].iParam[3]) &&
  2991. (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
  2992. if (res[i].iAnim[0][0] >= 0) {
  2993. //pokud je animace, tak ji spust
  2994. anmid = AddAnimation2(&res[i], &ad, 0);
  2995. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  2996. mPlaySound2(&res[i + 1], &ad, 1);
  2997. resid = i;
  2998. click = 1;
  2999. }
  3000. else {
  3001. if (res[i + 1].iParam[0] == COM_BINDSOUND)
  3002. mPlaySound2(&res[i + 1], &ad, 1);
  3003. resid = i;
  3004. click = 1;
  3005. anmid = 31;
  3006. }
  3007. }
  3008. mi.t1 = 0;
  3009. }
  3010. //provedeni akce po animaci menu
  3011. if (click)
  3012. if (!anm[anmid].cmd) {
  3013. click = 0;
  3014. //StopAll();
  3015. if (!strcmp(res[resid].cParam[1], "EXIT")) {
  3016. key[K_ESC] = 1;
  3017. //break;
  3018. }
  3019. resid = -1;
  3020. if (key[K_ESC]) {
  3021. for (i = 0; i < lastcmd; i++)
  3022. if (res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1) {
  3023. adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
  3024. res[i].iParam[5] = -1;
  3025. }
  3026. goto __QUIT;
  3027. }
  3028. }
  3029. //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
  3030. if (timercnt > 500) {
  3031. timercnt = 0;
  3032. for (i = 0; i < lastcmd; i++)
  3033. if (res[i].iParam[0] == COM_RANDOMANIMATION)
  3034. if (rand() % 200 <= res[i].iParam[1] &&
  3035. strcmp(dir, res[i].cParam[0])) {
  3036. CheckAnimation2(&res[i], &ad);
  3037. AddAnimation2(&res[i], &ad, 0);
  3038. }
  3039. }
  3040. dwStop = timeGetTime();
  3041. dwEplased += dwStop - dwStart;
  3042. AnimationEvent2(NULL, 0, 0, dwStop);
  3043. mi.x = mix;
  3044. mi.y = miy;
  3045. am_Flip(p_Level, p_am, 0, &rline, CLIST_ITEMC, 1, ttext.text,
  3046. ycorrection);
  3047. }
  3048. __QUIT:
  3049. ddx2ReleaseBitmap(iCompositDC);
  3050. ddx2ReleaseBitmap(iFontDC);
  3051. fn2_Release_Font();
  3052. StopAll2();
  3053. key[K_ESC] = 0;
  3054. key[K_ENTER] = 0;
  3055. if (dh) {
  3056. // ddx2ReleaseBitmap(sh);
  3057. ddx2DeviceDeaktivuj();
  3058. ddx2DeviceRemove(dh);
  3059. ddx2Release();
  3060. dh = 0;
  3061. }
  3062. FreeAnimations2(res, RES_NUM);
  3063. free((void *) res);
  3064. // fn2_Set_Font("font3d.pak");
  3065. // fn2_Load_Bitmaps();
  3066. // Start renderu hry
  3067. ddx2GameRender(TRUE);
  3068. txt_zrus_texturu(&ttext);
  3069. }
  3070. void RunMenuLoadScreen2(void)
  3071. {
  3072. RECT r = { 0, 0, 891, 149 };
  3073. int i = rand() % 49;
  3074. char text[256];
  3075. int sh, ty;
  3076. sprintf(text, "##load_hint_%d", i);
  3077. kprintf(1, "ddx2Init");
  3078. ddx2Init(10000, RGB(255, 0, 255));
  3079. iLoadScreenDevice = ddx2DeviceCreate(TRUE, 32);
  3080. if (!iLoadScreenDevice)
  3081. return;
  3082. ddx2DeviceSetActive(iLoadScreenDevice);
  3083. ddx2DeviceSetBackBufferSize(1024, 768);
  3084. ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
  3085. ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
  3086. ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
  3087. ddx2DeviceSetRender(TRUE);
  3088. ddx2CleareSurface(DDX2_BACK_BUFFER);
  3089. if (iActualScene < 13) {
  3090. char text[256];
  3091. sprintf(text, "scene%d.png", iActualScene);
  3092. iLoadScreenBitmap = ddx2LoadBitmap(text, pBmpDir);
  3093. }
  3094. else
  3095. iLoadScreenBitmap = ddx2LoadBitmap("LoadScreen.png", pBmpDir);
  3096. ddx2SetRect(&iLoadScreenRect, 1);
  3097. ddx2GameRender(FALSE);
  3098. ddx2BitBltDisplay(0, 0, 1024, 768, iLoadScreenBitmap, 0, 0);
  3099. if (iActualScene < 13) {
  3100. fn2_Set_Font(cFontDir[2]);
  3101. fn2_Load_Bitmaps();
  3102. sh = ddx2CreateSurface(891, 149, ddx2FindFreeSurface());
  3103. if (sh != K_CHYBA) {
  3104. ty = co2_Set_Text_Formated_Rect(sh, 0, 0, text, 0, &r);
  3105. ddx2TransparentBltDisplay(83,
  3106. 33 + ftoi(((6 * b2_3d_font.iYPlus) - ty) / 2.0f), 891, 149, sh, 0, 0,
  3107. 891, 149, TRANSCOLOR);
  3108. ddx2ReleaseBitmap(sh);
  3109. }
  3110. fn2_Release_Font();
  3111. }
  3112. ddx2RenderujVse(p_ber);
  3113. flip();
  3114. }
  3115. void RunMenuLoadScreenRelease(int iCount)
  3116. {
  3117. if (iLoadScreenDevice) {
  3118. ddx2CleareSurfaceColor(DDX2_BACK_BUFFER, 0);
  3119. for (int i = 0; i < iCount; i++) {
  3120. ddx2RenderujVse(p_ber);
  3121. flip();
  3122. }
  3123. ddx2ReleaseBitmap(iLoadScreenBitmap);
  3124. ddx2DeviceDeaktivuj();
  3125. ddx2DeviceRemove(iLoadScreenDevice);
  3126. ddx2Release();
  3127. iLoadScreenDevice = 0;
  3128. }
  3129. ddx2GameRender(TRUE);
  3130. }
  3131. static float ProgressStatus;
  3132. static float ProgressPlus;
  3133. void RunMenuLoadScreenInitBar(int iNumOfItems)
  3134. {
  3135. ProgressStatus = 0;
  3136. ProgressPlus = 100.0f / (float) iNumOfItems;
  3137. }
  3138. void RunMenuLoadScreenAddProgress(float fPercent)
  3139. {
  3140. if (fPercent >= 0)
  3141. ProgressStatus += fPercent;
  3142. else
  3143. ProgressStatus += ProgressPlus;
  3144. if(ProgressStatus > 100.0f)
  3145. ProgressStatus = 100.0f;
  3146. }
  3147. void RunMenuLoadScreenDrawProgress(int x, int y)
  3148. {
  3149. RECT r = { 0, 753, 0, 768 };
  3150. int Width;
  3151. Width = (int) ftoi((1024 * ProgressStatus) / 100.0f);
  3152. r.right = Width;
  3153. switch (iActualScene) {
  3154. case 1:
  3155. case 2:
  3156. case 3:
  3157. case 4:
  3158. case 7:
  3159. ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(166, 200, 145));
  3160. break;
  3161. case 5:
  3162. case 8:
  3163. ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(224, 211, 188));
  3164. break;
  3165. case 0:
  3166. case 10:
  3167. case 11:
  3168. ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(2, 25, 77));
  3169. break;
  3170. case 6:
  3171. case 9:
  3172. ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(170, 193, 245));
  3173. break;
  3174. case 12:
  3175. ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(255, 196, 129));
  3176. break;
  3177. default:
  3178. ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(255, 0, 0));
  3179. break;
  3180. }
  3181. ddx2RenderujVse(p_ber);
  3182. flip();
  3183. }