1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030 |
- //------------------------------------------------------------------------------------------------
- // 0.0.1
- //------------------------------------------------------------------------------------------------
- #include <stdio.h>
- #include "3d_all.h"
- #include "Berusky3d_kofola_interface.h"
- #include "Berusky3d_kofola2d.h"
- #include "game_logic.h"
- #include "menu_script.h"
- #include "Command.h"
- #include "3D_graphic.h"
- #include "Menu.h"
- #include "Menu2.h"
- #include "Comics.h"
- #include "credits.h"
- #include "font3d.h"
- #include "controls3d.h"
- #include "menu_def.h"
- #include "Setup.h"
- #include "profiles.h"
- #include "Object.h"
- #include "animationk.h"
- #include "Demo.h"
- #include "load_level.h"
- #include "ambient_sounds.h"
- #include "Tools.h"
- #define RES_NUM 60
- #define HDC2DD -1
- extern SETUP setup;
- extern _3D_CURSOR _3dCur;
- extern char pBmpDir[MAX_FILENAME];
- extern PLAYER_PROFILE pPlayerProfile;
- extern char p3DMDir[MAX_FILENAME];
- extern int iActualLevel;
- extern int iActualScene;
- extern B2_FONT b2_3d_font;
- extern char cFontDir[5][64];
- extern AUDIO_DATA ad;
- typedef struct
- {
- CMD_LINE *cmd;
- int iWave;
- char bStop;
- } ANIMATION;
- extern HW_KONFIG hwconf;
- static ANIMATION anm[32];
- static DWORD timercnt = 0;
- static DWORD dwLTime;
- static int CompositDC;
- static int FontDC;
- static int BackDC;
- static int iCompositDC;
- static int iFontDC;
- //static int iBackDC;
- static char bBackDC = 0;
- static DeviceHandle iLoadScreenDevice = 0;
- static int iLoadScreenBitmap = K_CHYBA;
- static RECT iLoadScreenRect = { 0, 0, 1024, 768 };
- RECT_LINE rline;
- //extern int gi_EnumDisplaySettings(DEVMODE *pdevmode);
- int check_Save_Owner(char *cDir, WCHAR * wFileName);
- int LoadHelp(char *c_file);
- CMD_LINE *GetCMD2(CMD_LINE * cmp, CMD_LINE * pres)
- {
- int i;
- for (i = 0; i < RES_NUM; i++)
- if (!strcmp(cmp->cParam[1], pres[i].cParam[0]))
- return &pres[i];
- return NULL;
- }
- //------------------------------------------------------------------------------------------------
- // zastavi vsechny animace
- //------------------------------------------------------------------------------------------------
- void StopAll2(void)
- {
- int i;
- for (i = 0; i < 32; i++)
- if (anm[i].cmd)
- anm[i].bStop = 1;
- }
- //------------------------------------------------------------------------------------------------
- // zastavi animaci
- //------------------------------------------------------------------------------------------------
- void Stop2(CMD_LINE * cmd)
- {
- int i;
- for (i = 0; i < 32; i++)
- if (cmd == anm[i].cmd) {
- if (cmd->bEndActivate[0] && cmd->pCmdLine)
- cmd->pCmdLine[(int)cmd->bEndActivate[0]].bActive = 1;
- if (cmd->bEndActivate[1] && cmd->pCmdLine)
- cmd->pCmdLine[(int)cmd->bEndActivate[1]].bActive = 1;
- cmd->bActive = 0;
- anm[i].bStop = 1;
- return;
- }
- }
- int NextStep2(CMD_LINE * cmd)
- {
- if ((rand() % 100) < 60)
- return cmd->iAnim[cmd->iLastfrm][6];
- else
- return cmd->iAnim[cmd->iLastfrm][6 +
- rand() % (cmd->iAnim[cmd->iLastfrm][12])];
- }
- void DrawFrame2(CMD_LINE * cmd)
- {
- if (!cmd->iLayer) {
- if (cmd->iAnim[cmd->iLastfrm][6] >= 0) {
- RECT r;
- ddx2BitBlt(CompositDC,
- cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6],
- cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7],
- cmd->iAnim[cmd->iLastfrm][8], cmd->iAnim[cmd->iLastfrm][9],
- cmd->iAnim[cmd->iLastfrm][1],
- cmd->iAnim[cmd->iLastfrm][6], cmd->iAnim[cmd->iLastfrm][7]);
- r.left = cmd->iAnim[cmd->iLastfrm][2] + cmd->iAnim[cmd->iLastfrm][6];
- r.top = cmd->iAnim[cmd->iLastfrm][3] + cmd->iAnim[cmd->iLastfrm][7];
- r.right = cmd->iAnim[cmd->iLastfrm][8];
- r.bottom = cmd->iAnim[cmd->iLastfrm][9];
- ddx2AddRectItem(&rline, r, 1);
- }
- else
- ddx2DrawSurface(CompositDC, cmd->iAnim[cmd->iLastfrm], 1);
- }
- else
- ddx2DrawSurface(FontDC, cmd->iAnim[cmd->iLastfrm], 3);
- }
- //------------------------------------------------------------------------------------------------
- // provede animaci
- //------------------------------------------------------------------------------------------------
- void Animation2(CMD_LINE * cmd, int time)
- {
- ANIMATION_DRAW:
- while (time > 0) {
- if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
- Stop2(cmd);
- break;
- }
- time -= cmd->iAnim[cmd->iLastfrm][4];
- if (time > (cmd->iAnim[cmd->iAnim[cmd->iLastfrm][5]][4] / 2.0f)) {
- /* if(cmd->iAnim[cmd->iLastfrm][6] >= 0)
- cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);*/
- if (cmd->iAnim[cmd->iLastfrm][10] > 0)
- DrawFrame2(cmd);
- cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
- }
- }
- //----------------------------------------------------------------------
- DrawFrame2(cmd);
- if (!cmd->iAnim[cmd->iLastfrm][4]) {
- /* if(cmd->iAnim[cmd->iLastfrm][6] >= 0)
- cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);*/
- cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
- goto ANIMATION_DRAW;
- }
- if (cmd->iAnim[cmd->iLastfrm][5] == -1) {
- Stop2(cmd);
- return;
- }
- /* if(cmd->iAnim[cmd->iLastfrm][6] >= 0)
- cmd->iAnim[cmd->iLastfrm][5] = NextStep(cmd);*/
- cmd->iLastfrm = cmd->iAnim[cmd->iLastfrm][5];
- }
- int RectCross2(RECT_LINE * p_rl, int idx)
- {
- int c = 0;
- int i;
- RECT *dr = &p_rl->rect[idx].rect;
- for (i = 0; i < rline.rlast; i++)
- if (i != idx)
- if (co2_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->top) ||
- co2_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->top) ||
- co2_Rect_Hit(p_rl->rect[i].rect, dr->left, dr->bottom) ||
- co2_Rect_Hit(p_rl->rect[i].rect, dr->right, dr->bottom))
- c++;
- return 0;
- }
- //------------------------------------------------------------------------------------------------
- // provede animace
- //------------------------------------------------------------------------------------------------
- void AnimationEvent2(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
- {
- DRAW_RECT *dr;
- int i;
- char bAnim = 0;
- DWORD e;
- //priprava
- //BitBltU(CompositDC,0,0,1024,768,NULL,0,0,WHITENESS);
- e = abs((int)(dwLTime - dwTime));
- for (i = 0; i < 32; i++)
- if (anm[i].cmd) {
- if (anm[i].bStop) {
- anm[i].cmd->iLastfrm = 1;
- anm[i].cmd->iCounter = 0;
- if(anm[i].iWave != -1)
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, anm[i].iWave);
- anm[i].iWave = -1;
- anm[i].cmd = NULL;
- }
- else {
- anm[i].cmd->iCounter += e;
- if (anm[i].cmd->iCounter >=
- anm[i].cmd->iAnim[anm[i].cmd->iLastfrm][4]) {
- Animation2(anm[i].cmd, anm[i].cmd->iCounter);
- anm[i].cmd->iCounter = 0;
- bAnim = 1;
- }
- }
- }
- //prenos kreslenych dat;
- if (bAnim) {
- if (bBackDC) {
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddx2TransparentBlt(BackDC, dr->rect.left, dr->rect.top, dr->rect.right, dr->rect.bottom, FontDC, dr->rect.left,
- dr->rect.top, TRANSCOLOR);
- }
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddx2TransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, BackDC, dr->rect.left,
- dr->rect.top, TRANSCOLOR);
- }
- }
- else
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- ddx2TransparentBlt(CompositDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, FontDC, dr->rect.left,
- dr->rect.top, TRANSCOLOR);
- }
- for (i = 0; i < rline.rlast; i++) {
- dr = &rline.rect[i];
- // ddx2UpdateMouse();
- //if(dr->iLayer >= 1 || RectCross(&rline, i))
- ddx2TransparentBltDisplay(dr->rect.left, dr->rect.top, dr->rect.right,
- dr->rect.bottom, CompositDC, dr->rect.left, dr->rect.top,
- dr->rect.right, dr->rect.bottom, TRANSCOLOR);
- }
- }
- dwLTime = dwTime;
- timercnt += e;
- //_2d_Clear_RectLine(&rline);
- }
- void InitRandomJumps2(CMD_LINE * cmd)
- {
- int i;
- for (i = 0; i < 200; i++)
- if (cmd->iAnim[i][6] >= 0)
- cmd->iAnim[i][5] = cmd->iAnim[i][6 + rand() % (cmd->iAnim[i][12])];
- }
- int FindAnimation2(CMD_LINE * cmd)
- {
- int i;
- for (i = 0; i < 32; i++)
- if (anm[i].cmd == cmd)
- return 1;
- return 0;
- }
- //------------------------------------------------------------------------------------------------
- // prida animaci
- //------------------------------------------------------------------------------------------------
- int AddAnimation2(CMD_LINE * cmd, AUDIO_DATA * p_ad, char bOnlyOnes)
- {
- int i, r;
- float pos[3] = { 0.0f, 0.0f, 1.0f };
- for (i = 0; i < 32; i++)
- if (!anm[i].cmd) {
- if (bOnlyOnes && FindAnimation2(cmd))
- return -1;
- // InitRandomJumps(cmd);
- anm[i].cmd = cmd;
- anm[i].bStop = 0;
- anm[i].iWave = -1;
- Animation2(anm[i].cmd, 0);
- if (cmd->iParam[0] == COM_RANDOMANIMATION) {
- r = rand() % 3;
- if (cmd->iParam[r + 2] < 0) {
- if (cmd->iParam[2] >= 0) {
- adas_Get_Listener_Position(pos);
- ap_Play_Sound(0,1,0,pos,cmd->iParam[2], NULL, &ad);
- }
- }
- else {
- adas_Get_Listener_Position(pos);
- ap_Play_Sound(0,1,0,pos,cmd->iParam[r+2], NULL, &ad);
- }
- }
- return i;
- }
- else if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0]) && !anm[i].bStop)
- return -1;
- return -1;
- }
- int ChooseBidedExitAnimation2(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
- {
- int id[32];
- int i, c = 0;
- for (i = Index; i < 32; i++)
- if (cmd[i].iParam[0] == COM_BINDEXITANIMATION) {
- id[c] = i;
- c++;
- if (c > 31)
- break;
- }
- else if (cmd[i].iParam[0] != COM_BINDANIMATION)
- break;
- if (c)
- return id[rand() % c];
- else
- return -1;
- }
- int ChooseBidedAnimation2(CMD_LINE * cmd, int Index, AUDIO_DATA * p_ad)
- {
- int id[32];
- int i, c = 0;
- for (i = Index; i < 32; i++)
- if (cmd[i].iParam[0] == COM_BINDANIMATION) {
- id[c] = i;
- c++;
- if (c > 31)
- break;
- }
- else if (cmd[i].iParam[0] != COM_BINDEXITANIMATION)
- break;
- if (c)
- return id[rand() % c];
- else
- return -1;
- }
- void FreeAnimations2(CMD_LINE * cmd, int csize)
- {
- int i, j;
- for (i = 0; i < csize; i++)
- for (j = 0; j < 32; j++)
- if (anm[j].cmd)
- if (anm[j].cmd == &cmd[i]) {
- anm[j].cmd->iLastfrm = 1;
- anm[j].cmd->iCounter = 0;
- anm[j].iWave = -1;
- anm[j].cmd = NULL;
- }
- }
- //------------------------------------------------------------------------------------------------
- // prida animaci
- //------------------------------------------------------------------------------------------------
- void CheckAnimation2(CMD_LINE * cmd, AUDIO_DATA * p_ad)
- {
- int i;
- // float pos[3] = { 0.0f, 0.0f, 1.0f };
- for (i = 0; i < 32; i++)
- if (anm[i].cmd)
- if (!strcmp(cmd->cParam[1], anm[i].cmd->cParam[0])) {
- Stop2(anm[i].cmd);
- if (!cmd->iLayer) {
- //menucommand_Draw(_2dd.hDC, anm[i].cmd->iAnim[0] , 0);
- ddx2DrawDisplay(anm[i].cmd->iAnim[0], 0);
- }
- else {
- //menucommand_DrawT(_2dd.hDC, anm[i].cmd->iAnim[0]);
- ddx2DrawDisplayColorKey(anm[i].cmd->iAnim[0], 0, TRANSCOLOR);
- //menucommand_Draw(FontDC, anm[i].cmd->iAnim[0], 3);
- ddx2DrawSurface(FontDC, anm[i].cmd->iAnim[0], 3);
- }
- return;
- }
- }
- //------------------------------------------------------------------------------------------------
- // spusti nahodny zvuk podle zadani
- //------------------------------------------------------------------------------------------------
- int mPlaySound2(CMD_LINE * cmd, AUDIO_DATA * p_ad, int type)
- {
- float pos[3] = { 0.0f, 0.0f, 1.0f };
- int r = rand() % 4, ret = 0;
- if (cmd->iParam[r + 1] < 0) {
- if (cmd->iParam[1] >= 0) {
- adas_Get_Listener_Position(pos);
- ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[1], NULL, &ad);
- }
- }
- else {
- adas_Get_Listener_Position(pos);
- ret = ap_Play_Sound(type,1,0,pos,cmd->iParam[r+1], NULL, &ad);
- }
- return ret;
- }
- int CreateFontAnimations2(CMD_LINE * res, int *lastcmd, int ycor, char bcor)
- {
- int lcmd = *lastcmd;
- char text[256];
- RECT r = { 0, 0, 0, 0 };
- int i;
- int sidx1, sidx2;
- int y;
- int ret;
- for (i = 0; i < lcmd; i++)
- if (res[i].iParam[0] == COM_SETRECT) {
- r.left = res[i].iParam[1];
- r.top = res[i].iParam[2];
- r.right = res[i].iParam[3];
- r.bottom = res[i].iParam[4];
- if (bcor) {
- r.top += ycor;
- r.bottom += ycor;
- }
- }
- y = r.top;
- for (i = 0; i < lcmd; i++)
- if (res[i].iParam[0] == COM_CREATEBUTTON)
- if (fn2_Gen_Menu_Text(0, HDC2DD, res[i].cParam[0], &sidx1,
- &sidx2) != -1)
- if (sidx1 != -1 && sidx2 != -1) {
- int ii;
- int oy = res[i].iParam[2];
- //int x = r.left + ftoi((r.right - r.left - _2dd.bitmap[sidx1].bitmap.bmWidth) / (float)2.0f);
- int x =
- r.left + ftoi((r.right - r.left -
- ddx2GetWidth(sidx1)) / (float) 2.0f);
- if (bcor)
- oy += ycor;
- if (res[i].iParam[1] != -1) {
- oy = res[i].iParam[2];
- if (bcor)
- oy += ycor;
- y = oy;
- x = res[i].iParam[1];
- }
- y += ddx2GetHeight(sidx1);
- //OnAbove(16,661,100,748, quit_game.txt, NO_EXEPTION)
- sprintf(text, "OnAbove(%d,%d,%d,%d, NO_EXEPTION, NO_EXEPTION)", x, oy, x + ddx2GetWidth(sidx1), y);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0], res[*lastcmd].cParam[1]);
- res[*lastcmd].uiTimerID = 0;
- res[*lastcmd].iLastfrm = 1;
- res[*lastcmd].iCounter = 0;
- /*
- (0, 123, 0, 640, 0, 1)
- (1, 124, 0, 640, 25, 2)
- (2, 124, 0, 640, 25, -1)
- */
- res[*lastcmd].iAnim[0][0] = 0;
- res[*lastcmd].iAnim[0][1] = sidx1;
- res[*lastcmd].iAnim[0][2] = x;
- res[*lastcmd].iAnim[0][3] = oy;
- res[*lastcmd].iAnim[0][4] = 0;
- res[*lastcmd].iAnim[0][5] = 1;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[0][ii] = -1;
- x = r.left + ftoi((r.right - r.left - ddx2GetWidth(sidx2)) / (float) 2.0f);
- if (res[i].iParam[1] != -1)
- x = res[i].iParam[1];
- res[*lastcmd].iAnim[1][0] = 1;
- res[*lastcmd].iAnim[1][1] = sidx2;
- res[*lastcmd].iAnim[1][2] = x;
- res[*lastcmd].iAnim[1][3] = oy;
- res[*lastcmd].iAnim[1][4] = 50;
- res[*lastcmd].iAnim[1][5] = 2;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[1][ii] = -1;
- res[*lastcmd].iAnim[2][0] = 2;
- res[*lastcmd].iAnim[2][1] = sidx2;
- res[*lastcmd].iAnim[2][2] = x;
- res[*lastcmd].iAnim[2][3] = oy;
- res[*lastcmd].iAnim[2][4] = 50;
- res[*lastcmd].iAnim[2][5] = -1;
- for (ii = 6; ii < 13; ii++)
- res[*lastcmd].iAnim[2][ii] = -1;
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //Draw(1,0,0)
- sprintf(text, "Draw(%d,%d,%d)", sidx1, x, oy);
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //OnClick(16,661,100,748, quit_gamec.txt, EXIT)
- ret = snprintf(text, sizeof(text),
- "OnClick(%d,%d,%d,%d, NO_EXEPTION, %s)", x, oy,
- x + ddx2GetWidth(sidx1), y, res[i].cParam[1]);
- assert(ret < (int)sizeof(text));
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 1;
- (*lastcmd)++;
- //BindSound(54,55,56,-1)
- strcpy(text, "BindSound(54,55,56,-1)");
- Parse_LineT(text, res[*lastcmd].iParam, 6, res[*lastcmd].cParam[0],
- res[*lastcmd].cParam[1]);
- res[*lastcmd].iLayer = 0;
- (*lastcmd)++;
- }
- return y;
- }
- void SetTab2(int iTab, int iLTab, CONTROL_LIST_ITEM2 * p_list, int lsize,
- int *hdcTab)
- {
- int i;
- if (iLTab > -1) {
- //BitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, _2dd.hDC, TAB_X, TAB_Y, SRCCOPY);
- ddx2BitBlt(hdcTab[iLTab], 0, 0, TAB_XRES, TAB_YRES, HDC2DD, TAB_X, TAB_Y);
- }
- for (i = 0; i < lsize; i++)
- if ((p_list + i)->iTab == iTab && !(p_list + i)->bDisabled)
- (p_list + i)->bActive = 1;
- else if ((p_list + i)->iTab != -1)
- (p_list + i)->bActive = 0;
- ddx2BitBltDisplay(TAB_X, TAB_Y, TAB_XRES, TAB_YRES, hdcTab[iTab], 0, 0);
- }
- void CharMenuCheckMultyKyes2(LIST_VIEW_CONTROL2 * p_li, int iKey)
- {
- int y;
- int i;
- RECT r;
- for (i = 0; i < p_li->listnum; i++)
- if (i != p_li->cSelected && p_li->piValue[i] == iKey) {
- y = i * 30;
- r.left = 550;
- r.top = y + 2;
- r.right = r.left + (ddx2GetWidth(p_li->bDCn) - 550);
- r.bottom = r.top + 28;
- ddx2FillRect(p_li->bDCn, &r, 0);
- ddx2FillRect(p_li->bDCs, &r, 0);
- char tmp[200];
- co2_List_Add_String(p_li, i, 550, Key2String(255, tmp), 255, 0);
- }
- }
- void SetCharMenu2(LIST_VIEW_CONTROL2 * p_li, LEVELINFO * p_Level,
- ANIMATION_MODULE * p_am, int mix, int miy)
- {
- char text[128];
- int y = p_li->cSelected * 30;
- // int xs = p_li->rectList.top + TAB_Y + y - p_li->dx;
- int xp = 0;
- int xt = 0;
- int i;
- RECT r;
- RECT rtmp;
- int iCursor = 0;
- mi.x = mix;
- mi.y = miy;
- if (!p_li->cSelected || p_li->cSelected == 11 || p_li->cSelected == 19)
- return;
- r.left = 550;
- r.top = y + 2;
- r.right = r.left + (ddx2GetWidth(p_li->bDCn) - 550);
- r.bottom = r.top + 28;
- ddx2FillRect(p_li->bDCn, &r, 0);
- ddx2FillRect(p_li->bDCs, &r, 0);
- if (y - p_li->dx < 0)
- xp = (y - p_li->dx) * -1;
- if ((p_li->rectList.top + TAB_Y + y - p_li->dx + 30) >
- p_li->rectList.bottom + TAB_Y)
- xt =
- (p_li->rectList.top + TAB_Y + y - p_li->dx + 30) -
- (p_li->rectList.bottom + TAB_Y);
- ddx2BitBlt(HDC2DD, p_li->rectList.left + TAB_X,
- p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddx2GetWidth(p_li->bDCs),
- 30 - xp - xt, p_li->bDCs, 0, y + xp);
- //spracuj_spravy(0);
- am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- r.top = p_li->rectList.top + TAB_Y + y - p_li->dx + xp - 2;
- r.left = 665;
- r.right = r.left + 220;
- r.bottom = r.top + 27;
- rtmp.left = r.left;
- rtmp.top = r.top;
- rtmp.right = 220;
- rtmp.bottom = 27;
- while (!key[0]) {
- if (iCursor < 100)
- ddx2FillRect(HDC2DD, &r, RGB(63, 122, 163));
- else if (iCursor > 99 && iCursor < 200)
- ddx2FillRect(HDC2DD, &r, 0);
- else {
- iCursor = 0;
- ddx2FillRect(HDC2DD, &r, 0);
- }
- ddx2AddRectItem(&rline, rtmp, 0);
- iCursor += 4;
- Sleep(10);
- am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- if (key[K_F1] || key[K_F2] || key[K_F3] || key[K_F10] || key[K_PLUS]
- || key[K_MINUS]) {
- key[0] = 0;
- key[K_F1] = 0;
- key[K_F2] = 0;
- key[K_F3] = 0;
- key[K_F10] = 0;
- key[K_PLUS] = 0;
- key[K_MINUS] = 0;
- }
- }
- key[0] = 0;
- for (i = 0; i < POCET_KLAVES; i++)
- if (key[i]) {
- Key2String(i, text);
- key[i] = 0;
- break;
- }
- co2_List_Add_String(p_li, p_li->cSelected, 550, text, i, 0);
- CharMenuCheckMultyKyes2(p_li, i);
- ddx2BitBlt(HDC2DD, p_li->rectList.left + TAB_X, p_li->rectList.top + TAB_Y,
- ddx2GetWidth(p_li->bDCn), p_li->rectList.bottom - p_li->rectList.top,
- p_li->bDCn, 0, p_li->dx);
- ddx2BitBlt(HDC2DD, p_li->rectList.left + TAB_X,
- p_li->rectList.top + TAB_Y + y - p_li->dx + xp, ddx2GetWidth(p_li->bDCs),
- 30 - xp - xt, p_li->bDCs, 0, y + xp);
- }
- void SetMenuSettings2(CONTROL_LIST_ITEM2 * citem, int *hdcTabUse)
- {
- int i;
- if (hdcTabUse[0]) {
- setup.posouvat_kameru = co2_Check_Get_State(citem, CLIST_ITEMC, 1);
- setup.ovladani = co2_Check_Get_State(citem, CLIST_ITEMC, 2);
- setup.bugs_highlight = co2_Check_Get_State(citem, CLIST_ITEMC, 10);
- setup.items_highlight = co2_Check_Get_State(citem, CLIST_ITEMC, 11);
- setup.ovladani_rohy = co2_Check_Get_State(citem, CLIST_ITEMC, 12);
- setup.camera_intro = co2_Check_Get_State(citem, CLIST_ITEMC, 16);
- i = co2_Check_Get_State(citem, CLIST_ITEMC, 13);
- if (i)
- setup.ovladani_rohy_default = 0;
- else
- setup.ovladani_rohy_default = 1;
- setup.ovladani_rohy_smer = co2_Check_Get_State(citem, CLIST_ITEMC, 15);
- //setup.ovladani_pr_posun = co2_Check_Get_State(citem, CLIST_ITEMC, 16);
- setup.ovladani_rohy_rychlost =
- co2_Progres_Get(citem, CLIST_ITEMC, 0) / 10.0f;
- setup.p_kamera_radius = co2_Progres_Get(citem, CLIST_ITEMC, 1) / 2.0f;
- }
- if (hdcTabUse[1]) {
- co2_Combo_Drop_Get_Sel(citem, CLIST_ITEMC, 10, &setup.text_ostrost);
- setup.ditering = co2_Check_Get_State(citem, CLIST_ITEMC, 7);
- setup.mirror_effects = co2_Check_Get_State(citem, CLIST_ITEMC, 4);
- setup.animace_okoli = co2_Check_Get_State(citem, CLIST_ITEMC, 8);
- }
- if (hdcTabUse[2]) {
- setup.soundvolume = co2_Progres_Get(citem, CLIST_ITEMC, 4);
- setup.ambientvolume = co2_Progres_Get(citem, CLIST_ITEMC, 5);
- setup.musicvolume = co2_Progres_Get(citem, CLIST_ITEMC, 6);
- }
- if (hdcTabUse[3]) {
- setup.key[1] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 1);
- setup.key[2] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 2);
- setup.key[3] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 3);
- setup.key[4] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 4);
- setup.key[5] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 5);
- setup.key[6] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 6);
- setup.key[7] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 7);
- setup.key[8] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 8);
- setup.key[9] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 9);
- setup.key[10] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 10);
- setup.key[12] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 12);
- setup.key[13] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 13);
- setup.key[14] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 14);
- setup.key[15] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 15);
- setup.key[16] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 16);
- setup.key[17] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 17);
- setup.key[18] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 18);
- setup.key[20] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 20);
- setup.key[21] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 21);
- setup.key[22] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 22);
- setup.key[23] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 23);
- setup.key[24] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 24);
- setup.key[25] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 25);
- setup.key[26] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 26);
- setup.key[27] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 27);
- setup.key[28] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 28);
- setup.key[29] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 29);
- setup.key[30] = co2_List_Get_Value(citem, CLIST_ITEMC, 0, 30);
- }
- }
- void SetMenuSettingsS2(CONTROL_LIST_ITEM2 * citem, int *hdcTabUse)
- {
- if (hdcTabUse[2]) {
- setup.soundvolume = co2_Progres_Get(citem, CLIST_ITEMC, 4);
- setup.ambientvolume = co2_Progres_Get(citem, CLIST_ITEMC, 5);
- setup.musicvolume = co2_Progres_Get(citem, CLIST_ITEMC, 6);
- }
- }
- void ControlFullScreenCallback2(void *p_control)
- {
- GRAPH3D *p_grf = (p_ber->p_age)->graph_get();
- p_grf->fullscreen_toggle();
- }
- void InitTab3d2(CONTROL_LIST_ITEM2 * citem, int *hdcTab)
- {
- int i;
- //kprintf(1, "##settings_sharpness");
- co2_Set_Text_Right(hdcTab[1], "##settings_sharpness", 0, 285, 97);
- citem[42].p_combod = co2_Create_Combo_Drop(hdcTab[1], 300, 90, 10);
- citem[42].iTab = 1;
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-3.0", -3.0f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.75", -2.75f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.5", -2.5f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.25", -2.25f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-2.0", -2.0f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.75", -1.75f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.5", -1.5f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.25", -1.25f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-1.0", -1.0f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-0.75", -0.75f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-0.5", -0.5f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "-0.25", -0.25f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "0.0", 0.0f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+0.25", 0.25f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+0.5", 0.5f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+0.75", 0.75f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.0", 1.0f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.25", 1.25f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.5", 1.5f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+1.75", 1.75f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.0", 2.0f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.25", 2.25f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.5", 2.5f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+2.75", 2.75f);
- co2_Combo_Drop_Add_String(citem[42].p_combod, "+3.0", 3.0f);
- i = ftoi(((setup.text_ostrost + 3) * 100) / 25.0f);
- if (i > 24)
- i = 24;
- co2_Combo_Drop_Set_Sel(hdcTab[1], citem[42].p_combod, i);
- //kprintf(1, "##settings_dithering");
- citem[29].p_check =
- co2_Create_CheckBox(hdcTab[1], 300, 150, "##settings_dithering", 0, 7);
- citem[29].iTab = 1;
- co2_Check_Set_State(citem[29].p_check, hdcTab[1], setup.ditering, 1);
- //kprintf(1, "##settings_animations");
- citem[11].p_check = co2_Create_CheckBox(hdcTab[1], 300, 180, "##settings_draw_mirror", 0, 4);
- citem[11].iTab = 1;
- co2_Check_Set_State(citem[11].p_check, hdcTab[1], setup.mirror_effects, 1);
- citem[30].p_check =
- co2_Create_CheckBox(hdcTab[1], 300, 210, "##settings_animations", 0, 8);
- citem[30].iTab = 1;
- co2_Check_Set_State(citem[30].p_check, hdcTab[1], setup.animace_okoli, 1);
-
- citem[31].p_check = co2_Create_CheckBox(hdcTab[1], 300, 240,
- "##settings_fullscreen", 0, 5, ControlFullScreenCallback2);
- citem[31].iTab = 1;
- co2_Check_Set_State(citem[31].p_check, hdcTab[1], setup.fullscreen, 1);
- }
- void InitTabSound2(CONTROL_LIST_ITEM2 * citem, int *hdcTab)
- {
- co2_Set_Text_Right(hdcTab[2], "##settings_sound", 0, 260, 50);
- citem[21].p_prog = co2_Create_Progres(hdcTab[2], 310, 50, 0, 100, 4);
- citem[21].iTab = 2;
- co2_Progres_Set(citem[21].p_prog, hdcTab[2], setup.soundvolume);
- co2_Set_Text_Right(hdcTab[2], "##settings_ambient", 0, 260, 85);
- citem[22].p_prog = co2_Create_Progres(hdcTab[2], 310, 85, 0, 100, 5);
- citem[22].iTab = 2;
- co2_Progres_Set(citem[22].p_prog, hdcTab[2], setup.ambientvolume);
- co2_Set_Text_Right(hdcTab[2], "##settings_music", 0, 260, 120);
- citem[23].p_prog = co2_Create_Progres(hdcTab[2], 310, 120, 0, 100, 6);
- citem[23].iTab = 2;
- co2_Progres_Set(citem[23].p_prog, hdcTab[2], setup.musicvolume);
- /*co2_Set_Text(hdcTab[2], 260 - TAB_X, 350 - TAB_Y, "##settings_sound", 0);
- citem[21].p_prog = co2_Create_Progres(hdcTab[2], 345 - TAB_X, 352 - TAB_Y, 0, 100, 4);
- citem[21].iTab = 2;
- co2_Progres_Set(citem[21].p_prog, hdcTab[2], setup.soundvolume);
- co2_Set_Text(hdcTab[2], 150 - TAB_X, 385 - TAB_Y, "##settings_ambient", 0);
- citem[22].p_prog = co2_Create_Progres(hdcTab[2], 345 - TAB_X, 387 - TAB_Y, 0, 100, 5);
- citem[22].iTab = 2;
- co2_Progres_Set(citem[22].p_prog, hdcTab[2], setup.ambientvolume);
- co2_Set_Text(hdcTab[2], 242 - TAB_X, 420 - TAB_Y, "##settings_music", 0);
- citem[23].p_prog = co2_Create_Progres(hdcTab[2], 345 - TAB_X, 422 - TAB_Y, 0, 100, 6);
- citem[23].iTab = 2;
- co2_Progres_Set(citem[23].p_prog, hdcTab[2], setup.musicvolume); */
- }
- void InitTabControls2(CONTROL_LIST_ITEM2 * citem, int *hdcTab)
- {
- char ctext[256];
- citem[24].p_list = co2_Create_List(hdcTab[3], 25, 50, 800, 580, 0, 31, 0);
- citem[24].iTab = 3;
- co2_List_Add_String(citem[24].p_list, 0, 2, "##control_beatle", 0, 1);
- co2_List_Add_String(citem[24].p_list, 1, 2, "##control_forward", 0, 0);
- co2_List_Add_String(citem[24].p_list, 2, 2, "##control_back", 0, 0);
- co2_List_Add_String(citem[24].p_list, 3, 2, "##control_left", 0, 0);
- co2_List_Add_String(citem[24].p_list, 4, 2, "##control_right", 0, 0);
- co2_List_Add_String(citem[24].p_list, 5, 2, "##control_nextb", 0, 0);
- co2_List_Add_String(citem[24].p_list, 6, 2, "##control_b1", 0, 0);
- co2_List_Add_String(citem[24].p_list, 7, 2, "##control_b2", 0, 0);
- co2_List_Add_String(citem[24].p_list, 8, 2, "##control_b3", 0, 0);
- co2_List_Add_String(citem[24].p_list, 9, 2, "##control_b4", 0, 0);
- co2_List_Add_String(citem[24].p_list, 10, 2, "##control_b5", 0, 0);
- co2_List_Add_String(citem[24].p_list, 11, 2, "##control_camera", 0, 1);
- co2_List_Add_String(citem[24].p_list, 12, 2, "##control_crotation", 0, 0);
- co2_List_Add_String(citem[24].p_list, 13, 2, "##control_cmove", 0, 0);
- co2_List_Add_String(citem[24].p_list, 14, 2, "##control_czoomin", 0, 0);
- co2_List_Add_String(citem[24].p_list, 15, 2, "##control_czoomout", 0, 0);
- co2_List_Add_String(citem[24].p_list, 16, 2, "##control_cfastleft", 0, 0);
- co2_List_Add_String(citem[24].p_list, 17, 2, "##control_cfastright", 0, 0);
- co2_List_Add_String(citem[24].p_list, 18, 2, "##control_ccamera", 0, 0);
- co2_List_Add_String(citem[24].p_list, 19, 2, "##control_game", 0, 1);
- co2_List_Add_String(citem[24].p_list, 20, 2, "##control_gmenu", 0, 0);
- co2_List_Add_String(citem[24].p_list, 21, 2, "##control_grestart", 0, 0);
- co2_List_Add_String(citem[24].p_list, 22, 2, "##control_ginventory", 0, 0);
- //co2_List_Add_String(citem[24].p_list, 23, 2, "##control_gusepack", 0, 0);
- co2_List_Add_String(citem[24].p_list, 23, 2, "##control_gnexttrack", 0, 0);
- co2_List_Add_String(citem[24].p_list, 24, 2, "##control_gturnoffi", 0, 0);
- co2_List_Add_String(citem[24].p_list, 25, 2, "##control_gturnofft", 0, 0);
- co2_List_Add_String(citem[24].p_list, 26, 2, "##control_gscreenshot", 0, 0);
- co2_List_Add_String(citem[24].p_list, 27, 2, "##control_gtransparent", 0, 0);
- co2_List_Add_String(citem[24].p_list, 28, 2, "##control_ghighlight", 0, 0);
- co2_List_Add_String(citem[24].p_list, 29, 2, "##control_gdrawconn", 0, 0);
- co2_List_Add_String(citem[24].p_list, 30, 2, "##control_pause", 0, 0);
- Key2String(setup.key[1], ctext);
- co2_List_Add_String(citem[24].p_list, 1, 550, ctext, setup.key[1], 0);
- Key2String(setup.key[2], ctext);
- co2_List_Add_String(citem[24].p_list, 2, 550, ctext, setup.key[2], 0);
- Key2String(setup.key[3], ctext);
- co2_List_Add_String(citem[24].p_list, 3, 550, ctext, setup.key[3], 0);
- Key2String(setup.key[4], ctext);
- co2_List_Add_String(citem[24].p_list, 4, 550, ctext, setup.key[4], 0);
- Key2String(setup.key[5], ctext);
- co2_List_Add_String(citem[24].p_list, 5, 550, ctext, setup.key[5], 0);
- Key2String(setup.key[6], ctext);
- co2_List_Add_String(citem[24].p_list, 6, 550, ctext, setup.key[6], 0);
- Key2String(setup.key[7], ctext);
- co2_List_Add_String(citem[24].p_list, 7, 550, ctext, setup.key[7], 0);
- Key2String(setup.key[8], ctext);
- co2_List_Add_String(citem[24].p_list, 8, 550, ctext, setup.key[8], 0);
- Key2String(setup.key[9], ctext);
- co2_List_Add_String(citem[24].p_list, 9, 550, ctext, setup.key[9], 0);
- Key2String(setup.key[10], ctext);
- co2_List_Add_String(citem[24].p_list, 10, 550, ctext, setup.key[10], 0);
- Key2String(setup.key[12], ctext);
- co2_List_Add_String(citem[24].p_list, 12, 550, ctext, setup.key[12], 0);
- Key2String(setup.key[13], ctext);
- co2_List_Add_String(citem[24].p_list, 13, 550, ctext, setup.key[13], 0);
- Key2String(setup.key[14], ctext);
- co2_List_Add_String(citem[24].p_list, 14, 550, ctext, setup.key[14], 0);
- Key2String(setup.key[15], ctext);
- co2_List_Add_String(citem[24].p_list, 15, 550, ctext, setup.key[15], 0);
- Key2String(setup.key[16], ctext);
- co2_List_Add_String(citem[24].p_list, 16, 550, ctext, setup.key[16], 0);
- Key2String(setup.key[17], ctext);
- co2_List_Add_String(citem[24].p_list, 17, 550, ctext, setup.key[17], 0);
- Key2String(setup.key[18], ctext);
- co2_List_Add_String(citem[24].p_list, 18, 550, ctext, setup.key[18], 0);
- Key2String(setup.key[20], ctext);
- co2_List_Add_String(citem[24].p_list, 20, 550, ctext, setup.key[20], 0);
- Key2String(setup.key[21], ctext);
- co2_List_Add_String(citem[24].p_list, 21, 550, ctext, setup.key[21], 0);
- Key2String(setup.key[22], ctext);
- co2_List_Add_String(citem[24].p_list, 22, 550, ctext, setup.key[22], 0);
- /*Key2String(setup.key[23], ctext);
- co2_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0); */
- Key2String(setup.key[23], ctext);
- co2_List_Add_String(citem[24].p_list, 23, 550, ctext, setup.key[23], 0);
- Key2String(setup.key[24], ctext);
- co2_List_Add_String(citem[24].p_list, 24, 550, ctext, setup.key[24], 0);
- Key2String(setup.key[25], ctext);
- co2_List_Add_String(citem[24].p_list, 25, 550, ctext, setup.key[25], 0);
- Key2String(setup.key[26], ctext);
- co2_List_Add_String(citem[24].p_list, 26, 550, ctext, setup.key[26], 0);
- Key2String(setup.key[27], ctext);
- co2_List_Add_String(citem[24].p_list, 27, 550, ctext, setup.key[27], 0);
- Key2String(setup.key[28], ctext);
- co2_List_Add_String(citem[24].p_list, 28, 550, ctext, setup.key[28], 0);
- Key2String(setup.key[29], ctext);
- co2_List_Add_String(citem[24].p_list, 29, 550, ctext, setup.key[29], 0);
- Key2String(setup.key[30], ctext);
- co2_List_Add_String(citem[24].p_list, 30, 550, ctext, setup.key[30], 0);
- co2_List_Redraw(hdcTab[3], citem[24].p_list, 0);
- }
- void RunMenuSettings2(char *p_File_Name, AUDIO_DATA * p_ad,
- LEVELINFO * p_Level, ANIMATION_MODULE * p_am)
- {
- int mix, miy;
- RECT rTMP = { 0, 0, 1024, 768 };
- DWORD dwEplased = 0, dwStart, dwStop;
- int ActiveTab = 0;
- int hdcTab[TAB_NUM];
- int hdcTabUse[TAB_NUM];
- CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- DeviceHandle dh = 0;
- int sh = K_CHYBA;
- _3d_End_Draw();
- p_Level->bResetini = 0;
- p_Level->iCursor = 133;
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- _2d_Clear_RectLine(&rline);
- ddx2Init(200, RGB(255, 0, 255));
-
- dh = ddx2DeviceCreate(TRUE, 32);
- ddx2DeviceSetActive(dh);
- ddx2DeviceSetBackBufferSize(1024, 768);
- ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
- ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
- ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
- ddx2CleareSurface(DDX2_BACK_BUFFER);
- sh = ddx2LoadBitmap("settings.png", pBmpDir);
- LoadHelp("3dsettings_load.txt");
- ddx2FillRect(DDX2_BACK_BUFFER, &rTMP, RGB(255, 0, 255));
- ddx2SetRect(&rTMP, 1);
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- // Stop renderu hry
- //ddx2GameRender(FALSE);
- // - volat jako soucast hry (po vykreslni listi)
- //void ddx2RenderDevices(G_KONFIG *p_ber)
- // - volat pokud jede menu bez hry - maze obrazovku a kresli menu
- //void ddx2RenderujVse(G_KONFIG *p_ber)
- // flipovat musis sam vzdycky
- // volej ale v kazdem frame jen jednu tuto funkci (podle toho jesli
- // 2D grafika je soucasti hry nebo jede samostatne)
- _2d_Clear_RectLine(&rline);
- res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
- Load_ini();
- iCompositDC = ddx2FindFreeSurface();
- CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
- iFontDC = ddx2FindFreeSurface();
- FontDC = ddx2CreateSurface(1024, 768, iFontDC);
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- fn2_Set_Font(cFontDir[2]);
- fn2_Load_Bitmaps();
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][11] = -1;
- res[bind].iAnim[lastcmd][0] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[(int)in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- if (chdir(DATA_DIR)) {
- free((void *) res);
- return;
- }
- char dir[MAX_FILENAME];
- strcpy(dir, DATA_DIR);
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- CreateFontAnimations2(res, &lastcmd, 0, 0);
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer) {
- //ddx2DrawSurface(BackDC, res[i].iParam, 2);
- ddx2DrawDisplay(res[i].iParam, 0);
- }
- else {
- //ddx2DrawSurfaceColorKey(BackDC, res[i].iParam, 2, TRANSCOLOR );
- //ddx2DrawSurface(FontDC, res[i].iParam, 3);
- ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- for (i = 0; i < TAB_NUM; i++) {
- hdcTab[i] = ddx2CreateSurface(TAB_XRES, TAB_YRES, ddx2FindFreeSurface());
- if (hdcTab[i])
- ddx2BitBlt(hdcTab[i], 0, 0, TAB_XRES, TAB_YRES, HDC2DD, TAB_X, TAB_Y);
- hdcTabUse[i] = 0;
- }
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- if (!co2_Load_Graphic(0)) {
- kerror(1, "co2_Load_Graphic ... can't load controls!");
- }
- else {
- citem[0].bActive = 0;
- citem[1].bActive = 0;
- citem[3].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 50, "##settings_camera_mov", 0, 1);
- co2_Check_Set_State(citem[3].p_check, hdcTab[0], setup.posouvat_kameru,
- 1);
- citem[3].bActive = 1;
- citem[4].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 80, "##settings_b1_control", 0, 2);
- co2_Check_Set_State(citem[4].p_check, hdcTab[0], setup.ovladani, 1);
- citem[4].bActive = 1;
- citem[35].p_check = co2_Create_CheckBox(hdcTab[0], 25, 110, "##settings_beathe_vis_at_start", 0, 10);
- co2_Check_Set_State(citem[35].p_check, hdcTab[0], setup.bugs_highlight, 1);
- citem[35].bActive = 1;
- citem[36].p_check = co2_Create_CheckBox(hdcTab[0], 25, 140, "##settings_items_vis_at_start", 0, 11);
- co2_Check_Set_State(citem[36].p_check, hdcTab[0], setup.items_highlight, 1);
- citem[36].bActive = 1;
- citem[41].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 200, "##settings_camera_intro", 0,
- 16);
- co2_Check_Set_State(citem[41].p_check, hdcTab[0], setup.camera_intro, 1);
- citem[41].bActive = 1;
- citem[37].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 230, "##settings_camera_rect", 0,
- 12);
- co2_Check_Set_State(citem[37].p_check, hdcTab[0], setup.ovladani_rohy, 1);
- citem[37].bActive = 1;
- citem[38].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 260, "##settings_implicit_move", 0,
- 13);
- if (setup.ovladani_rohy_default)
- co2_Check_Set_State(citem[38].p_check, hdcTab[0], 0, 1);
- else
- co2_Check_Set_State(citem[38].p_check, hdcTab[0], 1, 1);
- citem[38].bActive = 1;
- citem[39].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 290, "##settings_imlicit_rot", 0,
- 14);
- if (setup.ovladani_rohy_default)
- co2_Check_Set_State(citem[39].p_check, hdcTab[0], 1, 1);
- else
- co2_Check_Set_State(citem[39].p_check, hdcTab[0], 0, 1);
- citem[39].bActive = 1;
- citem[40].p_check =
- co2_Create_CheckBox(hdcTab[0], 25, 320, "##settings_camera_swap", 0,
- 15);
- co2_Check_Set_State(citem[40].p_check, hdcTab[0],
- setup.ovladani_rohy_smer, 1);
- citem[40].bActive = 1;
- /*citem[41].p_check = co2_Create_CheckBox(hdcTab[0], 25, 350, "##setings_camera_move_cur", 0, 16);
- co2_Check_Set_State(citem[41].p_check, hdcTab[0], setup.ovladani_pr_posun, 1);
- citem[41].bActive = 1; */
- co2_Set_Text_Right(hdcTab[0], "##setings_camera_speed", 0, 450, 390);
- citem[42].p_prog = co2_Create_Progres(hdcTab[0], 500, 387, 0, 10, 0);
- co2_Progres_Set(citem[42].p_prog, hdcTab[0],
- ftoi(setup.ovladani_rohy_rychlost * 10));
- citem[42].bActive = 1;
- co2_Set_Text_Right(hdcTab[0], "##settings_trans_radius", 0, 450, 425);
- citem[7].p_prog = co2_Create_Progres(hdcTab[0], 500, 412, 1, 20, 1);
- co2_Progres_Set(citem[7].p_prog, hdcTab[0],
- ftoi(setup.p_kamera_radius * 2));
- citem[7].bActive = 1;
- /*if(!setup.posouvat_kameru)
- co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0); */
- if (!setup.ovladani_rohy) {
- co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 13);
- co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 14);
- co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 15);
- //co2_Check_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 16);
- co2_Progres_Disable(hdcTab[0], 0, 0, citem, CLIST_ITEMC, 0, 1,
- hdcTab[0]);
- }
- SetTab2(0, -1, citem, CLIST_ITEMC, hdcTab);
- hdcTabUse[0] = 1;
- /*if(!setup.posouvat_kameru)
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0); */
- if (!setup.ovladani_rohy) {
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
- //co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
- co2_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 0,
- HDC2DD);
- }
- }
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- //BEGIN_MENU:
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation2(&res[i], &ad, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound2(&res[i + 1], &ad, 2);
- }
- }
- mi.t1 = 0;
- mi.t2 = 0;
- mi.dx = 0;
- mi.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- p_Level->iCursor = 0;
- ddx2GameRender(FALSE);
- ddx2DeviceSetRender(TRUE);
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- mix = mi.x;
- miy = mi.y;
- mi.x = (int) ceil(mi.x * scale_factor_x());
- mi.y = (int) ceil(mi.y * scale_factor_y());
- dwStart = timeGetTime();
- //pohnul mysi
- if (mi.dx || mi.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop2(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation2(&res[i], &ad);
- lastabv = i;
- AddAnimation2(&res[i], &ad, 0);
- in = 1;
- bind = ChooseBidedAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- CheckAnimation2(&res[bind], &ad);
- AddAnimation2(&res[bind], &ad, 1);
- anbind = bind;
- mPlaySound2(&res[bind], &ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop2(&res[i]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[i].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop2(&res[anbind]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[anbind].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation2(&res[bind], &ad, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- mi.dx = 0;
- mi.dy = 0;
- }
- co2_Handle_Controls(citem, CLIST_ITEMC, mi.x - TAB_X, mi.y - TAB_Y,
- HDC2DD, TAB_X, TAB_Y);
- if(co2_Progres_Changed(citem, CLIST_ITEMC, 4))
- ad.Sound_Gain = co2_Progres_Get(citem, CLIST_ITEMC, 4) / 100.0f;
- if (co2_Progres_Changed(citem, CLIST_ITEMC, 5)) {
- float laf = ad.Ambient_Gain;
- ad.Ambient_Gain = co2_Progres_Get(citem, CLIST_ITEMC, 5) / 100.0f;
- adas_Set_Source_Gain(-1, LOOPING_TYPE, UNDEFINED_VALUE, ad.Ambient_Gain);
-
- if(laf < 0.05f && ad.Ambient_Gain >= 0.05f)
- {
- adas_Release_Source(-1, LOOPING_TYPE, UNDEFINED_VALUE);
- as_Start(p_Level->Environment.id, &ad, p_Level);
- }
- }
- if (co2_Progres_Changed(citem, CLIST_ITEMC, 6)) {
-
- float f = co2_Progres_Get(citem, CLIST_ITEMC, 6) / 100.0f;
- ogg_gain(f);
- ad.Music_Gain = f;
- if(f >= 0.05f && !ogg_playing())
- {
- ad.Music_Gain = f;
- ap_Stop_Song(&ad);
- ap_Play_Song(0,1,&ad);
- //adas_OGG_Set_Priority(p_Level->Base_Priority);
- //ap_Play_Song(0,0,&ad);
- }
- }
- //stlacil leve tlacitko
- if (mi.t1 && !click) {
- int iCheck = -1;
- LIST_VIEW_CONTROL2 *p_li;
- iCheck = co2_Check_Get_State_Change(citem, CLIST_ITEMC, 12);
- if (iCheck != -1) {
- if (!iCheck) {
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
- co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
- //co2_Check_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
- co2_Progres_Disable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0, 1,
- HDC2DD);
- }
- else {
- co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 13);
- co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 14);
- co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 15);
- //co2_Check_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 16);
- co2_Progres_Enable(HDC2DD, TAB_X, TAB_Y, citem, CLIST_ITEMC, 0);
- }
- }
- if (ActiveTab == 0 && !citem[39].bDisabled) {
- iCheck = co2_Check_Get_State_Change(citem, CLIST_ITEMC, 13);
- if (iCheck != -1 && iCheck == 1)
- co2_Check_Set_State(citem[39].p_check, HDC2DD, 0, 1);
- else if (iCheck != -1 && !iCheck)
- co2_Check_Set_State(citem[39].p_check, HDC2DD, 1, 1);
- iCheck = co2_Check_Get_State_Change(citem, CLIST_ITEMC, 14);
- if (iCheck != -1 && iCheck == 1)
- co2_Check_Set_State(citem[38].p_check, HDC2DD, 0, 1);
- else if (iCheck != -1 && !iCheck)
- co2_Check_Set_State(citem[38].p_check, HDC2DD, 1, 1);
- }
- if (co2_List_Get_Clck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
- float pos[3] = { 0, 0, 0 };
- ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
- SetCharMenu2(p_li, p_Level, p_am, mix, miy);
- }
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation2(&res[i], &ad, 0);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- mi.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT")) {
- float pos[3] = { 0, 0, 0 };
- ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
- key[K_ESC] = 1;
- }
- if (!strcmp(res[resid].cParam[1], "OK")) {
- float pos[3] = { 0, 0, 0 };
- ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
- SetMenuSettings2(citem, hdcTabUse);
- Save_ini();
- key[K_ESC] = 1;
- p_Level->bResetini = 1;
- }
- if (!strcmp(res[resid].cParam[1], "GAME") && ActiveTab) {
- SetTab2(0, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 0;
- hdcTabUse[0]++;
- }
- if (!strcmp(res[resid].cParam[1], "3D") && ActiveTab != 1) {
- if (!hdcTabUse[1])
- InitTab3d2(citem, hdcTab);
- SetTab2(1, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 1;
- hdcTabUse[1]++;
- }
- if (!strcmp(res[resid].cParam[1], "SOUND") && ActiveTab != 2) {
- if (!hdcTabUse[2])
- InitTabSound2(citem, hdcTab);
- SetTab2(2, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 2;
- hdcTabUse[2]++;
- }
- if (!strcmp(res[resid].cParam[1], "CONTROLS") && ActiveTab != 3) {
- if (!hdcTabUse[3])
- InitTabControls2(citem, hdcTab);
- SetTab2(3, ActiveTab, citem, CLIST_ITEMC, hdcTab);
- ActiveTab = 3;
- hdcTabUse[3]++;
- }
- resid = -1;
- if (key[K_ESC]) {
- for(i=0;i<lastcmd;i++) {
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1) {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- }
- goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation2(&res[i], &ad);
- AddAnimation2(&res[i], &ad, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- AnimationEvent2(NULL, 0, 0, dwStop);
- mi.x = mix;
- mi.y = miy;
- am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- }
- __QUIT:
- ddx2ReleaseBitmap(iCompositDC);
- ddx2ReleaseBitmap(iFontDC);
- // ddx2ReleaseBitmap(iBackDC);
- SetMenuSettingsS2(citem, hdcTabUse);
- Save_ini();
- fn2_Release_Font();
- StopAll2();
- co2_Handle_Release(citem, CLIST_ITEMC);
- co2_Release_Graphic();
- key[K_ESC] = 0;
- if (dh) {
- ddx2ReleaseBitmap(sh);
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(dh);
- ddx2Release();
- dh = 0;
- }
- FreeAnimations2(res, RES_NUM);
- free((void *) res);
- // fn2_Set_Font("font3d.pak");
- // fn2_Load_Bitmaps();
- // Start renderu hry
- ddx2GameRender(TRUE);
- }
- int FillListLoad2(LIST_VIEW_CONTROL2 * p_li, char *mask, char bAdd, char bLoad)
- {
- WCHAR wFile[128];
- int x = 0;
- int c = 0;
- LIST_ITEM_ *list;
- int isize;
- if (chdir(SAVE_DIR))
- return 0;
- FillStringList(mask, &list, &isize);
- if (!isize)
- return 0;
- for (c = 0; c < isize; c++) {
- ZeroMemory(wFile, 128 * sizeof(WCHAR));
- if (bLoad == 2) {
- if (!demo_Check_Owner(pPlayerProfile.cName, list[c].text, wFile))
- continue;
- }
- else if (!check_Save_Owner(list[c].text, wFile))
- continue;
- if (bAdd)
- co2_List_Add_StringWC2(p_li, x, 2, wFile, list[c].text, x, 0);
- x++;
- }
- free((void *) list);
- return x;
- }
- static void RunMenuLoadGameLoad2ResizeCallback(void)
- {
- ddx2DeviceSetScreenRec((int) ceil(scale_back_factor_x() * 299),
- (int) ceil(scale_back_factor_y() * 209),
- (int) ceil(scale_back_factor_x() * 444),
- (int) ceil(scale_back_factor_y() * 415));
- }
- int RunMenuLoadGameLoad2(char *p_File_Name, AUDIO_DATA * p_ad,
- LEVELINFO * p_Level, ANIMATION_MODULE * p_am, char bLoad, WCHAR * cText)
- {
- int iReturn = 0;
- int mix, miy;
- RECT rTMP = { 299, 209, 444, 415 };
- DWORD dwEplased = 0, dwStart, dwStop;
- CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- DeviceHandle dh = 0;
- int sh = K_CHYBA;
- _3d_End_Draw();
- //kprintf(1, "----------------- RunMenuLoadGameLoad2 ---------------------");
- p_Level->bResetini = 0;
- _2d_Clear_RectLine(&rline);
- p_Level->iCursor = 133;
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- p_Level->iCursor = 0;
- ddx2Init(200, RGB(255, 0, 255));
- dh = ddx2DeviceCreate(TRUE, 32);
- ddx2DeviceSetActive(dh);
- ddx2DeviceSetBackBufferSize(1024, 768);
- ddx2DeviceSetBackBufferRect(299, 209, 444, 415);
- ddx2DeviceSetTextRenderRec(0, 0, 444, 415);
- ddx2DeviceSetScreenRecCallback(RunMenuLoadGameLoad2ResizeCallback);
-
- ddx2DeviceSetRender(TRUE);
- ddx2CleareSurface(DDX2_BACK_BUFFER);
- sh = ddx2LoadBitmap("smallmenu.png", pBmpDir);
- ddx2SetRect(&rTMP, 1);
- ddx2GameRender(TRUE);
- res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
- iCompositDC = ddx2FindFreeSurface();
- CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
- iFontDC = ddx2FindFreeSurface();
- FontDC = ddx2CreateSurface(1024, 768, iFontDC);
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
- fn2_Set_Font(cFontDir[0]);
- fn2_Load_Bitmaps();
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][11] = -1;
- res[bind].iAnim[lastcmd][0] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[(int)in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- if (chdir(DATA_DIR)) {
- free((void *) res);
- return 0;
- }
- char dir[MAX_FILENAME];
- strcpy(dir, DATA_DIR);
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- CreateFontAnimations2(res, &lastcmd, 0, 0);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer)
- ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- else {
- ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iParam, 3);
- }
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- if (!co2_Load_Graphic(0))
- kprintf(1, "co2_Load_Graphic ... con't load controls!");
- else {
- RECT r;
- int xx;
- r.left = 299;
- r.top = 209;
- r.right = 743;
- r.bottom = 359;
- if (!bLoad) //save
- co2_Set_Text_Center(HDC2DD, "##menu_savegame", 0, r);
- else if (bLoad == 1) // load
- co2_Set_Text_Center(HDC2DD, "##menu_loadgame", 0, r);
- else //save demo
- co2_Set_Text_Center(HDC2DD, "##menu_savedemo", 0, r);
- fn2_Release_Font();
- fn2_Set_Font(cFontDir[2]);
- fn2_Load_Bitmaps();
- xx = FillListLoad2(NULL, "*", 0, bLoad);
- if (bLoad == 1) {
- if (xx < 6)
- xx = 6;
- citem[1].p_list = co2_Create_List(HDC2DD, 360, 320, 320, 185, 0, xx, 1);
- citem[1].bActive = 1;
- FillListLoad2(citem[1].p_list, "*", 1, bLoad);
- }
- else if (!bLoad) {
- if (xx < 5)
- xx = 5;
- citem[0].p_edit = co2_Create_Edit(HDC2DD, 373, 485, 0);
- citem[0].bActive = 1;
- citem[1].p_list = co2_Create_List(HDC2DD, 360, 320, 320, 150, 0, xx, 1);
- citem[1].bActive = 1;
- FillListLoad2(citem[1].p_list, "*", 1, bLoad);
- }
- else {
- xx = FillListLoad2(NULL, "*.dem", 0, bLoad);
- if (xx < 5)
- xx = 5;
- citem[0].p_edit = co2_Create_Edit(HDC2DD, 373, 485, 0);
- citem[0].bActive = 1;
- citem[1].p_list = co2_Create_List(HDC2DD, 360, 320, 320, 150, 0, xx, 1);
- citem[1].bActive = 1;
- FillListLoad2(citem[1].p_list, "*.dem", 1, bLoad);
- }
- co2_List_Redraw(HDC2DD, citem[1].p_list, 0);
- }
- //BEGIN_MENU:
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation2(&res[i], &ad, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound2(&res[i + 1], &ad, 2);
- }
- }
- mi.t1 = 0;
- mi.t2 = 0;
- mi.dx = 0;
- mi.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- mix = mi.x;
- miy = mi.y;
- mi.x = (int) ceil(mi.x * scale_factor_x());
- mi.y = (int) ceil(mi.y * scale_factor_y());
- dwStart = timeGetTime();
- //pohnul mysi
- if ((mi.dx || mi.dy) && !p_Level->bRestart && !p_Level->bReturnToMenu) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop2(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation2(&res[i], &ad);
- lastabv = i;
- AddAnimation2(&res[i], &ad, 0);
- in = 1;
- bind = ChooseBidedAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- CheckAnimation2(&res[bind], &ad);
- AddAnimation2(&res[bind], &ad, 1);
- anbind = bind;
- mPlaySound2(&res[bind], &ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop2(&res[i]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[i].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop2(&res[anbind]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[anbind].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation2(&res[bind], &ad, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- mi.dx = 0;
- mi.dy = 0;
- }
- if (!p_Level->bRestart && !p_Level->bReturnToMenu)
- co2_Handle_Controls(citem, CLIST_ITEMC, mi.x, mi.y, HDC2DD, 0, 0);
- //stlacil leve tlacitko
- if (mi.t1 && !click && !p_Level->bRestart && !p_Level->bReturnToMenu) {
- LIST_VIEW_CONTROL2 *p_li;
- if (co2_List_Get_Clck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
- if (p_li->cSelected != -1) {
- float pos[3] = { 0, 0, 0 };
- ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
- if (!bLoad || bLoad == 2)
- co2_Edit_Set_Text(citem[0].p_edit, p_li->pwText[p_li->cSelected],
- 1, HDC2DD, 0, 0);
- }
- }
- if (co2_List_Get_Dbclck(citem, CLIST_ITEMC, 0, &p_li) == 1) {
- float pos[3] = { 0, 0, 0 };
- ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
- if (p_li->cSelected != -1)
- if (p_li->pwText[p_li->cSelected]) {
- if (!bLoad || bLoad == 2)
- wcscpy(cText, citem[0].p_edit->wtext);
- else
- wcscpy(cText, p_li->pwText[p_li->cSelected]);
- if (!bLoad || bLoad == 2)
- iReturn++;
- key[K_ESC] = 1;
- }
- }
- //dostala se mys do akcni oblasti (OnClick)?
- if (!p_Level->bRestart && !p_Level->bReturnToMenu)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation2(&res[i], &ad, 0);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- mi.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- if (!strcmp(res[resid].cParam[1], "OK")) {
- if (!bLoad || bLoad == 2)
- wcscpy(cText, citem[0].p_edit->wtext);
- else if (citem[1].p_list->cClckSel != -1)
- if (citem[1].p_list->pwText[citem[1].p_list->cClckSel])
- wcscpy(cText,
- citem[1].p_list->pwText[citem[1].p_list->cClckSel]);
- if (wcslen(cText)) {
- char ccheck[] = "profiles";
- WCHAR wcheck[64];
- MultiByteToWideChar(CP_ACP, 0, ccheck, strlen(ccheck) + 1, wcheck,
- sizeof(wcheck) / sizeof(wcheck[0]));
- if (wcscasecmp(cText, wcheck)) {
- if (!bLoad || bLoad == 2)
- iReturn++;
- key[K_ESC] = 1;
- }
- }
- }
- if (!strcmp(res[resid].cParam[1], "EXIT") ||
- !strcmp(res[resid].cParam[1], "CANCEL")) {
- ZeroMemory(cText, 128 * sizeof(WCHAR));
- key[K_ESC] = 1;
- //break;
- }
- resid = -1;
- if (key[K_ESC]) {
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1)
- {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- //goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation2(&res[i], &ad);
- AddAnimation2(&res[i], &ad, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- AnimationEvent2(NULL, 0, 0, dwStop);
- mi.x = mix;
- mi.y = miy;
- if (iReturn) {
- char ccheck[256];
- ZeroMemory(ccheck, 256);
- if (!bLoad)
- lsi_Save_Exist(cText, ccheck);
- else
- demo_Exist(cText, ccheck);
- if (strlen(ccheck)) {
- if (!bLoad)
- p_Level->bRestart = 1;
- else
- p_Level->bReturnToMenu = 1;
- p_Level->iMessageBoxReturn = -1;
- key[K_ESC] = 0;
- iReturn = 0;
- }
- }
- if ((p_Level->bRestart || p_Level->bReturnToMenu) && mi.t1) {
- if (!p_Level->iMessageBoxReturn) {
- iReturn = 0;
- p_Level->bRestart = 0;
- p_Level->bReturnToMenu = 0;
- p_Level->iMessageBoxReturn = -1;
- }
- else if (p_Level->iMessageBoxReturn == 1) {
- iReturn = 1;
- key[K_ESC] = 1;
- p_Level->bRestart = 0;
- p_Level->bReturnToMenu = 0;
- p_Level->iMessageBoxReturn = -1;
- }
- mi.t1 = 0;
- }
- am_Flip(p_Level, p_am, 0, &rline, CLIST_ITEMC, 0, 0, 0);
- }
- //__QUIT:
- ddx2ReleaseBitmap(iCompositDC);
- ddx2ReleaseBitmap(iFontDC);
- fn2_Release_Font();
- StopAll2();
- co2_Handle_Release(citem, CLIST_ITEMC);
- co2_Release_Graphic();
- key[K_ESC] = 0;
- if (dh) {
- ddx2ReleaseBitmap(sh);
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(dh);
- ddx2Release();
- dh = 0;
- }
- FreeAnimations2(res, RES_NUM);
- free((void *) res);
- // fn2_Set_Font("font3d.pak");
- // fn2_Load_Bitmaps();
- ddx2GameRender(TRUE);
- p_Level->bRestart = 0;
- return iReturn;
- }
- int LoadHelp(char *c_file)
- {
- int c = 0, i = -1;
- char text[MAX_FILENAME];
- FILE *file;
- construct_path(text, MAX_FILENAME, 2, pBmpDir, c_file);
- file = fopen(text, "r");
- if (!file)
- return -1;
- while (!feof(file)) {
- memset(text, 0, 256);
- if (fgets(text, 256, file) && text[0]) {
- newline_cut(text);
- if (!c)
- i = ddx2LoadBitmap(text, pBmpDir);
- else
- ddx2LoadBitmap(text, pBmpDir);
- //kprintf(1, "%s - %d", text, t);
- c++;
- }
- }
- fclose(file);
- return i;
- }
- int DrawHelp(int iBmp, int iSurface, int *iHelpIndex)
- {
- int y, ty;
- RECT rect = { 10, 0, 776, 1000 };
- if (iSurface == -1)
- return 0;
- iHelpIndex[0] = 0;
- co2_Set_Text(iSurface, 10, 10, "##help_introduction_main", 1);
- y =
- co2_Set_Text_Formated_Rect(iSurface, 10, 60, "##help_introduction_h", 0,
- &rect) + 50;
- //BERUSKA/////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[1] = y;
- co2_Set_Text(iSurface, 10, y, "##help_beatle_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 3), ddx2GetHeight(iBmp + 3),
- iBmp + 3, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 3);
- y =
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_beatle_h", 0,
- &rect) + 50;
- //EXIT/////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[2] = y;
- co2_Set_Text(iSurface, 10, y, "##help_exit_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 4), ddx2GetHeight(iBmp + 4),
- iBmp + 4, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 4);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_exit_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 4) + 50;
- //ZED/////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[3] = y;
- co2_Set_Text(iSurface, 10, y, "##help_wall_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 15),
- ddx2GetHeight(iBmp + 15), iBmp + 15, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 15);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_wall_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 15) + 50;
- //SIKMINA/////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[4] = y;
- co2_Set_Text(iSurface, 10, y, "##help_up_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 8), ddx2GetHeight(iBmp + 8),
- iBmp + 8, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 8);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_up_h", 0, &rect);
- y += ddx2GetHeight(iBmp + 8) + 50;
- //BEDNA LEHKA /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[5] = y;
- co2_Set_Text(iSurface, 10, y, "##help_empty_box_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 1), ddx2GetHeight(iBmp + 1),
- iBmp + 1, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 1);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_empty_box_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 1) + 50;
- //BEDNA TEZKA /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[6] = y;
- co2_Set_Text(iSurface, 10, y, "##help_full_box_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 2), ddx2GetHeight(iBmp + 2),
- iBmp + 2, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 2);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_full_box_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 2) + 50;
- //BEDNA TNT /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[7] = y;
- co2_Set_Text(iSurface, 10, y, "##help_tnt_box_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 11),
- ddx2GetHeight(iBmp + 11), iBmp + 11, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 11);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_tnt_box_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 11) + 50;
- //KAMEN /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[8] = y;
- co2_Set_Text(iSurface, 10, y, "##help_rock_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 5), ddx2GetHeight(iBmp + 5),
- iBmp + 5, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 5);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_rock_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 5) + 50;
- //Tlacitko /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[9] = y;
- co2_Set_Text(iSurface, 10, y, "##help_button_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 10),
- ddx2GetHeight(iBmp + 10), iBmp + 10, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 10);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_button_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 10) + 50;
- //TELEPORT /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[10] = y;
- co2_Set_Text(iSurface, 10, y, "##help_teleport_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 9), ddx2GetHeight(iBmp + 9),
- iBmp + 9, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 9);
- ty = y + ddx2GetHeight(iBmp + 9) + 50;
- y =
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_teleport_h", 0,
- &rect) + 50;
- //TELEPORT NA TLACITKO/////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[11] = y;
- co2_Set_Text(iSurface, rect.left, y, "##help_teleport_button_main", 1);
- y += 50;
- y =
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y,
- "##help_teleport_button_h", 0, &rect);
- y = ty;
- //VYTAH /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[12] = y;
- co2_Set_Text(iSurface, 10, y, "##help_lift_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 12),
- ddx2GetHeight(iBmp + 12), iBmp + 12, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 12);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_lift_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 12) + 50;
- //VYTAH NA VAHU /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[13] = y;
- co2_Set_Text(iSurface, 10, y, "##help_lift_weight_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 17),
- ddx2GetHeight(iBmp + 17), iBmp + 17, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 17);
- ty = y + ddx2GetHeight(iBmp + 17) + 50;
- y =
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_lift_weight_h",
- 0, &rect);
- y += 50;
- //VYTAH NA TLACITKO /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[14] = y;
- co2_Set_Text(iSurface, 10, y, "##help_lift_button_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 18),
- ddx2GetHeight(iBmp + 18), iBmp + 18, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 18);
- ty = y + ddx2GetHeight(iBmp + 18) + 50;
- y =
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_lift_button_h",
- 0, &rect);
- y = ty;
- //VODA /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[15] = y;
- co2_Set_Text(iSurface, 10, y, "##help_water_main", 1);
- y += 50;
- rect.left = 10;
- y =
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_water_h", 0,
- &rect);
- y += 50;
- //PROPADLO /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[16] = y;
- co2_Set_Text(iSurface, 10, y, "##help_trap_door_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 7), ddx2GetHeight(iBmp + 7),
- iBmp + 7, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 7);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_trap_door_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 7) + 50;
- //SNORCHL /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[17] = y;
- co2_Set_Text(iSurface, 10, y, "##help_water_pipe_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 16),
- ddx2GetHeight(iBmp + 16), iBmp + 16, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 16);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_water_pipe_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 16) + 50;
- //JIDLO /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[18] = y;
- co2_Set_Text(iSurface, 10, y, "##help_hormonal_vitamine_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 13),
- ddx2GetHeight(iBmp + 13), iBmp + 13, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 13);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y,
- "##help_hormonal_vitamine_h", 0, &rect);
- y += ddx2GetHeight(iBmp + 13) + 50;
- //ZAVAZI /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[19] = y;
- co2_Set_Text(iSurface, 10, y, "##help_iron_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 14),
- ddx2GetHeight(iBmp + 14), iBmp + 14, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 14);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_iron_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 14) + 50;
- //KROMPAC /////////////////////////////////////////////////////////////////////////////////////////////////
- iHelpIndex[20] = y;
- co2_Set_Text(iSurface, 10, y, "##help_rock_axe_main", 1);
- y += 50;
- ddx2BitBlt(iSurface, 0, y, ddx2GetWidth(iBmp + 6), ddx2GetHeight(iBmp + 6),
- iBmp + 6, 0, 0);
- rect.left = 10 + ddx2GetWidth(iBmp + 6);
- co2_Set_Text_Formated_Rect(iSurface, rect.left, y, "##help_rock_axe_h", 0,
- &rect);
- y += ddx2GetHeight(iBmp + 6) + 50;
- return 1;
- }
- void RunMenuHelp2(char *p_File_Name, AUDIO_DATA * p_ad, LEVELINFO * p_Level,
- ANIMATION_MODULE * p_am)
- {
- int mix, miy;
- RECT rTMP = { 0, 0, 1024, 768 };
- DWORD dwEplased = 0, dwStart, dwStop;
- CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- DeviceHandle dh = 0;
- int sh = K_CHYBA;
- int sh1 = K_CHYBA;
- int sh2 = K_CHYBA;
- int iBmp;
- int iHelpIndex[23];
- int iComboSel = 0;
- int iComboActSel = 0;
- _3d_End_Draw();
- ZeroMemory(iHelpIndex, 23 * sizeof(int));
- _2d_Clear_RectLine(&rline);
- p_Level->iCursor = 133;
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- ddx2Init(200, RGB(255, 0, 255));
- dh = ddx2DeviceCreate(TRUE, 32);
- ddx2DeviceSetActive(dh);
-
- ddx2DeviceSetBackBufferSize(1024, 768);
- ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
- ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
- ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- ddx2CleareSurface(DDX2_BACK_BUFFER);
- sh = ddx2LoadBitmap("help_frame.png", pBmpDir);
- sh1 = ddx2LoadBitmap("set_back2-1.png", pBmpDir);
- sh2 = ddx2LoadBitmap("set_back1-1.png", pBmpDir);
- ddx2FillRect(DDX2_BACK_BUFFER, &rTMP, RGB(255, 0, 255));
- ddx2SetRect(&rTMP, 1);
-
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
- LoadHelp("helpbook.txt");
- iBmp = LoadHelp("helpload.txt");
- iCompositDC = ddx2FindFreeSurface();
- CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
- iFontDC = ddx2FindFreeSurface();
- FontDC = ddx2CreateSurface(1024, 768, iFontDC);
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
- fn2_Set_Font(cFontDir[2]);
- fn2_Load_Bitmaps();
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][11] = -1;
- res[bind].iAnim[lastcmd][0] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[(int)in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- if (chdir(DATA_DIR)) {
- free((void *) res);
- return;
- }
- char dir[MAX_FILENAME];
- strcpy(dir, DATA_DIR);
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- in = 0;
- //CreateFontAnimations2(res, &lastcmd);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- // if(!res[i].iLayer)
- ddx2DrawDisplay(res[i].iParam, 0);
- /* else
- ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR );
- ddx2DrawSurface(FontDC, res[i].iParam, 3);*/
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- if (!co2_Load_Graphic(1)) {
- kprintf(1, "co2_Load_Graphic ... con't load controls!");
- assert(0);
- }
- else {
- citem[0].p_combo = co2_Create_Combo(HDC2DD, 100, 67, 500, 0);
- citem[0].bActive = 1;
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_introduction_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_beatle_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_exit_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_wall_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_up_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_empty_box_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_full_box_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_tnt_box_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_rock_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_button_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_teleport_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_teleport_button_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_lift_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_lift_weight_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_lift_button_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_water_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_trap_door_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_water_pipe_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo,
- "##help_hormonal_vitamine_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_iron_mainc");
- co2_Combo_Add_StringWC(citem[0].p_combo, "##help_rock_axe_mainc");
- co2_Combo_Set_Params(citem[0].p_combo, 19);
- co2_Combo_Set_Sel(HDC2DD, citem[0].p_combo, 0);
- citem[1].p_list_v =
- co2_Create_List_View(HDC2DD, 100, 107, 828, 622, 0, 6800);
- citem[1].bActive = 1;
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- DrawHelp(iBmp, co2_Get_List_View_DC(citem[1].p_list_v), iHelpIndex);
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- co2_List_View_Redraw(HDC2DD, citem[1].p_list_v, 0);
- }
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation2(&res[i], &ad, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound2(&res[i + 1], &ad, 2);
- }
- }
- mi.t1 = 0;
- mi.t2 = 0;
- mi.dx = 0;
- mi.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- p_Level->iCursor = 0;
- ddx2GameRender(FALSE);
- ddx2DeviceSetRender(TRUE);
- spracuj_spravy(0);
- while (!key[K_ESC]) {
- mix = mi.x;
- miy = mi.y;
- mi.x = (int) ceil(mi.x * scale_factor_x());
- mi.y = (int) ceil(mi.y * scale_factor_y());
- dwStart = timeGetTime();
- //pohnul mysi
- if (mi.dx || mi.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- //spusteni animace v OnAbove
- if (i != lastabv) {
- if (in) {
- Stop2(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation2(&res[i], &ad);
- lastabv = i;
- AddAnimation2(&res[i], &ad, 0);
- in = 1;
- bind = ChooseBidedAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- CheckAnimation2(&res[bind], &ad);
- AddAnimation2(&res[bind], &ad, 1);
- anbind = bind;
- mPlaySound2(&res[bind], &ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop2(&res[i]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[i].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop2(&res[anbind]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[anbind].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation2(&res[bind], &ad, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- mi.dx = 0;
- mi.dy = 0;
- }
- co2_Handle_Controls(citem, CLIST_ITEMC, mi.x, mi.y, HDC2DD, 0, 0);
- iComboActSel = co2_Combo_Get_Sel_Not_Opend(citem, CLIST_ITEMC, 0);
- if (iComboActSel != iComboSel && iComboActSel != -1) {
- co2_Set_List_View_List_Pos(citem[1].p_list_v, iHelpIndex[iComboActSel],
- HDC2DD, 0, 0);
- iComboSel = iComboActSel;
- }
- //stlacil leve tlacitko
- if (mi.t1 && !click) {
- if (co2_Is_Button_Activated(citem, CLIST_ITEMC, 0)) {
- float pos[3] = { 0, 0, 0 };
- ap_Play_Sound(0,1,0,pos,54 + (rand()%3), NULL, &ad);
- key[K_ESC] = 1;
- p_Level->bResetini = 1;
- }
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation2(&res[i], &ad, 0);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- mi.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT")) {
- key[K_ESC] = 1;
- //break;
- }
- resid = -1;
- if (key[K_ESC]) {
- for(i=0;i<lastcmd;i++)
- if(res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1) {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation2(&res[i], &ad);
- AddAnimation2(&res[i], &ad, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- AnimationEvent2(NULL, 0, 0, dwStop);
- mi.x = mix;
- mi.y = miy;
- am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- }
- __QUIT:
- ddx2ReleaseBitmap(iCompositDC);
- ddx2ReleaseBitmap(iFontDC);
- fn2_Release_Font();
- StopAll2();
- co2_Handle_Release(citem, CLIST_ITEMC);
- co2_Release_Graphic();
- key[K_ESC] = 0;
- if (dh) {
- ddx2ReleaseBitmap(sh);
- ddx2ReleaseBitmap(sh1);
- ddx2ReleaseBitmap(sh2);
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(dh);
- ddx2Release();
- dh = 0;
- }
- FreeAnimations2(res, RES_NUM);
- free((void *) res);
- // fn2_Set_Font("font3d.pak");
- // fn2_Load_Bitmaps();
- // Start renderu hry
- ddx2GameRender(TRUE);
- }
- void GetSceneString(char *cscene)
- {
- if (iActualScene < 0 || iActualScene > 12)
- strcpy(cscene, "##scene_name_unknown");
- else
- sprintf(cscene, "##scene_name_%d", iActualScene);
- return;
- }
- void GetLevelTime(char *ctime, LEVELINFO * p_Level)
- {
- long iTime = (int) floor(p_Level->dwPlayTime / 1000.0f);
- int sec = iTime % 60;
- int min;
- int hour;
- char cmin[12];
- char csec[12];
- iTime = (int) floor(iTime / 60.0f);
- min = iTime % 60;
- iTime = (int) floor(iTime / 60.0f);
- hour = iTime % 60;
- if (sec < 10)
- sprintf(csec, "0%d", sec);
- else
- sprintf(csec, "%d", sec);
- if (min < 10)
- sprintf(cmin, "0%d", min);
- else
- sprintf(cmin, "%d", min);
- if (!min && !hour) {
- sprintf(ctime, "00:%d", sec);
- /*sprintf(ctime, "%d sekund", sec);
- if(sec < 2)
- strcat(ctime, "a");
- if(sec > 1 && sec < 5)
- strcat(ctime, "y"); */
- }
- else if (!hour)
- sprintf(ctime, "%s:%s", cmin, csec);
- else
- sprintf(ctime, "%d:%s:%s", hour, cmin, csec);
- }
- int LoadCList2(char *cFile)
- {
- int c = 0, i = -1;
- char text[MAX_FILENAME];
- FILE *file;
- construct_path(text, MAX_FILENAME, 2, pBmpDir, cFile);
- file = fopen(text, "r");
- if (!file)
- return -1;
- while (!feof(file)) {
- memset(text, 0, 256);
- if (fgets(text, 256, file) && text[0]) {
- newline_cut(text);
- if (!c)
- i = ddx2LoadBitmap(text, pBmpDir);
- else
- ddx2LoadBitmap(text, pBmpDir);
- c++;
- }
- }
- fclose(file);
- return i;
- }
- void RunMenuLevelStats2(char *p_File_Name, AUDIO_DATA * p_ad,
- LEVELINFO * p_Level, ANIMATION_MODULE * p_am)
- {
- int mix, miy;
- RECT rTMP = { 0, 0, 1024, 768 };
- DWORD dwEplased = 0, dwStart, dwStop;
- CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- DeviceHandle dh = 0;
- int sh = K_CHYBA;
- int ifdx = 0;
- _2d_Clear_RectLine(&rline);
- _2d_Add_RectItem(&rline, rTMP, 0);
- ddx2Init(200, RGB(255, 0, 255));
- dh = ddx2DeviceCreate(TRUE, 32);
- ddx2DeviceSetActive(dh);
- ddx2DeviceSetBackBufferSize(1024, 768);
- ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
- ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
- ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
-
- ddx2DeviceSetRender(TRUE);
- ddx2CleareSurface(DDX2_BACK_BUFFER);
- switch (iActualScene) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 7:
- sh = ddx2LoadBitmap("end_screen3.png", pBmpDir);
- ifdx = 2;
- break;
- case 5:
- case 8:
- sh = ddx2LoadBitmap("end_screen1.png", pBmpDir);
- ifdx = 0;
- break;
- case 0:
- case 6:
- case 9:
- case 10:
- case 11:
- sh = ddx2LoadBitmap("end_screen2.png", pBmpDir);
- ifdx = 1;
- break;
- case 12:
- sh = ddx2LoadBitmap("end_screen4.png", pBmpDir);
- ifdx = 3;
- break;
- default:
- sh = ddx2LoadBitmap("end_screen4.png", pBmpDir);
- ifdx = 3;
- break;
- }
- if (sh == -1) {
- kprintf(1, "RunMenuLevelStats2 ... sh == -1 !!!");
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(dh);
- ddx2Release();
- ddx2GameRender(TRUE);
- return;
- }
- ddx2SetRect(&rTMP, 1);
- ddx2GameRender(FALSE);
- res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
- iCompositDC = ddx2FindFreeSurface();
- CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
- iFontDC = ddx2FindFreeSurface();
- FontDC = ddx2CreateSurface(1024, 768, iFontDC);
- LoadCList2("load_bs.txt");
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
- fn2_Set_Font(cFontDir[3]);
- fn2_Load_Bitmaps();
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][11] = -1;
- res[bind].iAnim[lastcmd][0] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[(int)in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- if (chdir(DATA_DIR)) {
- free((void *) res);
- return;
- }
- char dir[MAX_FILENAME];
- strcpy(dir, DATA_DIR);
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- in = 0;
- //CreateFontAnimations2(res, &lastcmd, 0, 0);
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- //if(!res[i].iLayer)
- ddx2DrawDisplay(res[i].iParam, 0);
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- co2_Set_Text(HDC2DD, 50, 50, "##stats_scene", ifdx);
- co2_Set_Text(HDC2DD, 50, 80, "##stats_time", ifdx);
- co2_Set_Text(HDC2DD, 50, 110, "##stats_steps", ifdx);
- GetSceneString(dir);
- co2_Set_Text(HDC2DD, 250, 50, dir, ifdx);
- GetLevelTime(dir, p_Level);
- co2_Set_TextWC(HDC2DD, 250, 80, dir, ifdx);
- co2_Set_TextWC(HDC2DD, 250, 110, itoa(p_Level->iNumOfSteps, dir, 10), ifdx);
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation2(&res[i], &ad, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound2(&res[i + 1], &ad, 2);
- }
- }
- mi.t1 = 0;
- mi.t2 = 0;
- mi.dx = 0;
- mi.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC] && !key[K_ENTER]) {
- mix = mi.x;
- miy = mi.y;
- mi.x = (int) ceil(mi.x * scale_factor_x());
- mi.y = (int) ceil(mi.y * scale_factor_y());
- dwStart = timeGetTime();
- //pohnul mysi
- if (mi.dx || mi.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- //kprintf(1, "i = %d, lastabv = %d", i, lastabv);
- //spusteni animace v OnAbove
- if (i != lastabv) {
- //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);
- if (in) {
- Stop2(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation2(&res[i], &ad);
- lastabv = i;
- AddAnimation2(&res[i], &ad, 0);
- in = 1;
- bind = ChooseBidedAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- CheckAnimation2(&res[bind], &ad);
- AddAnimation2(&res[bind], &ad, 1);
- anbind = bind;
- mPlaySound2(&res[bind], &ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- //kprintf(1, "out mi = %d, %d", mi.x, mi.y);
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop2(&res[i]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[i].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop2(&res[anbind]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[anbind].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation2(&res[bind], &ad, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- mi.dx = 0;
- mi.dy = 0;
- }
- //stlacil leve tlacitko
- if (mi.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++) {
- if (res[i].iParam[0] == COM_ONCLICK) {
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) &&
- (mi.y <= res[i].iParam[4]))
- {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation2(&res[i], &ad, 0);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- }
- }
- mi.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click) {
- if (!anm[anmid].cmd) {
- click = 0;
- if (!strcmp(res[resid].cParam[1], "EXIT")) {
- key[K_ESC] = 1;
- //break;
- }
- resid = -1;
- if (key[K_ESC]) {
- goto __QUIT;
- }
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++) {
- if (res[i].iParam[0] == COM_RANDOMANIMATION) {
- if (rand() % 200 <= res[i].iParam[1] && strcmp(dir, res[i].cParam[0])) {
- CheckAnimation2(&res[i], &ad);
- AddAnimation2(&res[i], &ad, 0);
- }
- }
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- AnimationEvent2(NULL, 0, 0, dwStop);
- mi.x = mix;
- mi.y = miy;
- am_Flip(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- }
- __QUIT:
- ddx2ReleaseBitmap(iCompositDC);
- ddx2ReleaseBitmap(iFontDC);
- fn2_Release_Font();
- StopAll2();
- key[K_ESC] = 0;
- key[K_ENTER] = 0;
- if (dh) {
- ddx2ReleaseBitmap(sh);
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(dh);
- ddx2Release();
- dh = 0;
- }
- FreeAnimations2(res, RES_NUM);
- free((void *) res);
- // Start renderu hry
- ddx2GameRender(TRUE);
- }
- static void RunMenuTutorial2ResizeCallback(void)
- {
- ddx2DeviceSetScreenRec(ftoi(10 * scale_back_factor_x()),
- ftoi(200 * scale_back_factor_y()),
- ftoi(900 * scale_back_factor_x()),
- ftoi(450 * scale_back_factor_y()));
- }
- void RunMenuTutorial2(char *p_File_Name, AUDIO_DATA * p_ad,
- LEVELINFO * p_Level, ANIMATION_MODULE * p_am)
- {
- int mix, miy;
- RECT rTMP = { 0, 0, 1024, 768 };
- DWORD dwEplased = 0, dwStart, dwStop;
- CONTROL_LIST_ITEM2 citem[CLIST_ITEMC];
- int lastcmd, lastanm, i;
- CMD_LINE *res = NULL;
- int lastabv = -1;
- char in, click = 0;
- int anmid = -1, resid = -1, anbind = -1;
- int bind;
- DeviceHandle dh = 0;
- int ycorrection = 0;
- EDIT_TEXT ttext;
- ZeroMemory(&ttext, sizeof(EDIT_TEXT));
- p_Level->iCursor = 133;
- am_FlipA(p_Level, p_am, 1, &rline, CLIST_ITEMC, 0, 0, 0);
- p_Level->iCursor = 0;
- txt_trida(TEXT_MENU);
- kom_set_default_text_config(0, 0, 1, 0, 0, 1);
- txt_nahraj_texturu_z_func(p3DMDir, "tutor_frame.png", &ttext, 0, 1, NULL, bmp_nahraj);
- kom_ret_default_text_config();
- _2d_Clear_RectLine(&rline);
- ddx2Init(200, RGB(255, 0, 255));
- dh = ddx2DeviceCreate(FALSE, 32);
- if (!dh)
- return;
- ddx2DeviceSetActive(dh);
- ddx2DeviceSetBackBufferSize(1024, 768);
- ddx2DeviceSetBackBufferRect(10, 200, 900, 450);
- ddx2DeviceSetTextRenderRec(0, 0, 900, 450);
- ddx2DeviceSetScreenRecCallback(RunMenuTutorial2ResizeCallback);
- ddx2DeviceSetRender(TRUE);
- ddx2CleareSurface(DDX2_BACK_BUFFER);
- ddx2SetRect(&rTMP, 1);
- // Stop renderu hry
- ddx2GameRender(TRUE);
- res = (CMD_LINE *) mmalloc(RES_NUM * sizeof(CMD_LINE));
- iCompositDC = ddx2FindFreeSurface();
- CompositDC = ddx2CreateSurface(1024, 768, iCompositDC);
- iFontDC = ddx2FindFreeSurface();
- FontDC = ddx2CreateSurface(1024, 768, iFontDC);
- ZeroMemory(citem, CLIST_ITEMC * sizeof(CONTROL_LIST_ITEM2));
- fn2_Set_Font(cFontDir[2]);
- fn2_Load_Bitmaps();
- for (bind = 0; bind < RES_NUM; bind++) {
- for (lastcmd = 0; lastcmd < 200; lastcmd++) {
- res[bind].iAnim[lastcmd][11] = -1;
- res[bind].iAnim[lastcmd][0] = -1;
- }
- for (in = 0; in < 6; in++)
- res[bind].iParam[(int)in] = -1;
- res[bind].iLayer = 0;
- }
- lastcmd = 0;
- timercnt = 0;
- if (chdir(DATA_DIR)) {
- free((void *) res);
- return;
- }
- char dir[MAX_FILENAME];
- strcpy(dir, DATA_DIR);
- //natadhe skript menu
- LoadMenuScript(p_File_Name, res, &lastcmd);
- //lastcmd--;
- in = 0;
- {
- int ycor = 0;
- char tt[256];
- RECT rr = { 20, 210, 890, 758 };
- sprintf(tt, "##tutorial_%d", iActualLevel - 200);
- ycor = co2_Set_Text_Formated_Rect(HDC2DD, 20, 210, tt, 0, &rr);
- //ycor = (200 + ycor + 50) - 600;
- ycor = (ycor + 50) - 600;
- _2d_Clear_RectLine(&rline);
- rr.left = 10;
- rr.top = 200;
- rr.right = 910;
- rr.bottom = 460;
- ddx2AddRectItem(&rline, rr, 0);
- ycorrection = CreateFontAnimations2(res, &lastcmd, ycor, 1);
- //ycor = ftoi((ycor - 25) * s_factor[1]);
- //ycor = ycor - 50;
- //ycorrection = 650 + ycor;
- }
- // privede prikazy, ketere se maji provest na zacatku a, kresleni, flip,
- // animace na OnAbove
- for (i = 0; i < lastcmd; i++) {
- lastanm = 0;
- switch (res[i].iParam[0]) {
- case COM_DRAW:
- if (!res[i].iLayer)
- ddx2DrawDisplay(res[i].iParam, 0);
- else
- ddx2DrawDisplayColorKey(res[i].iParam, 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iParam, 3);
- break;
- case COM_RANDOMANIMATION:
- case COM_ONCLICK:
- case COM_ONABOVE:
- case COM_RUNANIMATION:
- case COM_BINDEXITANIMATION:
- case COM_BINDANIMATION:
- //nahrati animace k udalosti OnAbove
- LoadAnimationMenuScript(res, i, &lastanm);
- break;
- }
- }
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RUNANIMATION) {
- int iWave = AddAnimation2(&res[i], &ad, 0);
- if (iWave != -1) {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- anm[iWave].iWave = res[i + 1].iParam[5] =
- mPlaySound2(&res[i + 1], &ad, 2);
- }
- }
- mi.t1 = 0;
- mi.t2 = 0;
- mi.dx = 0;
- mi.dy = 0;
- anmid = -1;
- resid = -1;
- anbind = -1;
- bind = -1;
- lastabv = -1;
- in = 0;
- spracuj_spravy(0);
- while (!key[K_ESC] && !key[K_ENTER]) {
- mix = mi.x;
- miy = mi.y;
- mi.x = (int) ceil(mi.x * scale_factor_x());
- mi.y = (int) ceil(mi.y * scale_factor_y());
- dwStart = timeGetTime();
- //pohnul mysi
- if (mi.dx || mi.dy) {
- //dostala se mys do akcni oblasti (OnAbove)?
- if (!click)
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONABOVE) {
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- //kprintf(1, "i = %d, lastabv = %d", i, lastabv);
- //spusteni animace v OnAbove
- if (i != lastabv) {
- //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);
- if (in) {
- Stop2(&res[lastabv]);
- if (!res[lastabv].iLayer) {
- ddx2DrawDisplay(res[lastabv].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[lastabv].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[lastabv].iAnim[0], 3,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[lastabv].iAnim[0], 3);
- }
- }
- CheckAnimation2(&res[i], &ad);
- lastabv = i;
- AddAnimation2(&res[i], &ad, 0);
- in = 1;
- bind = ChooseBidedAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- CheckAnimation2(&res[bind], &ad);
- AddAnimation2(&res[bind], &ad, 1);
- anbind = bind;
- mPlaySound2(&res[bind], &ad, 0);
- }
- strcpy(dir, res[i].cParam[1]);
- }
- }
- else if (lastabv == i) {
- //kprintf(1, "out mi = %d, %d", mi.x, mi.y);
- // odesel z oblasti, ktera byla aktivni -> stop animace
- // a odznaceni oblasti
- Stop2(&res[i]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[i].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[i].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[i].iAnim[0], 0, TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[i].iAnim[0], 3);
- }
- bind = ChooseBidedExitAnimation2(res, i + 1, &ad);
- if (bind != -1) {
- int iAnim;
- if (anbind != -1) {
- Stop2(&res[anbind]);
- if (!res[i].iLayer) {
- ddx2DrawDisplay(res[anbind].iAnim[0], 0);
- ddx2DrawSurface(CompositDC, res[anbind].iAnim[0], 3);
- }
- else {
- ddx2DrawDisplayColorKey(res[anbind].iAnim[0], 0,
- TRANSCOLOR);
- ddx2DrawSurface(FontDC, res[anbind].iAnim[0], 3);
- }
- }
- iAnim = AddAnimation2(&res[bind], &ad, 1);
- if (iAnim != -1)
- anm[iAnim].iWave = mPlaySound2(&res[bind], &ad, 2);
- }
- lastabv = -1;
- anbind = -1;
- in = 0;
- strcpy(dir, "");
- }
- }
- mi.dx = 0;
- mi.dy = 0;
- }
- //stlacil leve tlacitko
- if (mi.t1 && !click) {
- //dostala se mys do akcni oblasti (OnClick)?
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_ONCLICK)
- if ((mi.x >= res[i].iParam[1]) &&
- (mi.x <= res[i].iParam[3]) &&
- (mi.y >= res[i].iParam[2]) && (mi.y <= res[i].iParam[4])) {
- if (res[i].iAnim[0][0] >= 0) {
- //pokud je animace, tak ji spust
- anmid = AddAnimation2(&res[i], &ad, 0);
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- }
- else {
- if (res[i + 1].iParam[0] == COM_BINDSOUND)
- mPlaySound2(&res[i + 1], &ad, 1);
- resid = i;
- click = 1;
- anmid = 31;
- }
- }
- mi.t1 = 0;
- }
- //provedeni akce po animaci menu
- if (click)
- if (!anm[anmid].cmd) {
- click = 0;
- //StopAll();
- if (!strcmp(res[resid].cParam[1], "EXIT")) {
- key[K_ESC] = 1;
- //break;
- }
- resid = -1;
- if (key[K_ESC]) {
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_BINDSOUND && res[i].iParam[5] != -1) {
- adas_Release_Source(PARTICULAR_SOUND_SOURCE, UNDEFINED_VALUE, res[i].iParam[5]);
- res[i].iParam[5] = -1;
- }
- goto __QUIT;
- }
- }
- //pokud prisel cas, tak provedu nahodne animace (podle jejich pravdepodobnosti)
- if (timercnt > 500) {
- timercnt = 0;
- for (i = 0; i < lastcmd; i++)
- if (res[i].iParam[0] == COM_RANDOMANIMATION)
- if (rand() % 200 <= res[i].iParam[1] &&
- strcmp(dir, res[i].cParam[0])) {
- CheckAnimation2(&res[i], &ad);
- AddAnimation2(&res[i], &ad, 0);
- }
- }
- dwStop = timeGetTime();
- dwEplased += dwStop - dwStart;
- AnimationEvent2(NULL, 0, 0, dwStop);
- mi.x = mix;
- mi.y = miy;
- am_Flip(p_Level, p_am, 0, &rline, CLIST_ITEMC, 1, ttext.text,
- ycorrection);
- }
- __QUIT:
- ddx2ReleaseBitmap(iCompositDC);
- ddx2ReleaseBitmap(iFontDC);
- fn2_Release_Font();
- StopAll2();
- key[K_ESC] = 0;
- key[K_ENTER] = 0;
- if (dh) {
- // ddx2ReleaseBitmap(sh);
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(dh);
- ddx2Release();
- dh = 0;
- }
- FreeAnimations2(res, RES_NUM);
- free((void *) res);
- // fn2_Set_Font("font3d.pak");
- // fn2_Load_Bitmaps();
- // Start renderu hry
- ddx2GameRender(TRUE);
- txt_zrus_texturu(&ttext);
- }
- void RunMenuLoadScreen2(void)
- {
- RECT r = { 0, 0, 891, 149 };
- int i = rand() % 49;
- char text[256];
- int sh, ty;
- sprintf(text, "##load_hint_%d", i);
- kprintf(1, "ddx2Init");
- ddx2Init(10000, RGB(255, 0, 255));
- iLoadScreenDevice = ddx2DeviceCreate(TRUE, 32);
- if (!iLoadScreenDevice)
- return;
- ddx2DeviceSetActive(iLoadScreenDevice);
- ddx2DeviceSetBackBufferSize(1024, 768);
- ddx2DeviceSetBackBufferRect(0, 0, 1024, 768);
- ddx2DeviceSetTextRenderRec(0, 0, 1024, 768);
- ddx2DeviceSetScreenRecCallback(ddx2ScreenResDefaultCallback);
- ddx2DeviceSetRender(TRUE);
- ddx2CleareSurface(DDX2_BACK_BUFFER);
- if (iActualScene < 13) {
- char text[256];
- sprintf(text, "scene%d.png", iActualScene);
- iLoadScreenBitmap = ddx2LoadBitmap(text, pBmpDir);
- }
- else
- iLoadScreenBitmap = ddx2LoadBitmap("LoadScreen.png", pBmpDir);
- ddx2SetRect(&iLoadScreenRect, 1);
- ddx2GameRender(FALSE);
- ddx2BitBltDisplay(0, 0, 1024, 768, iLoadScreenBitmap, 0, 0);
- if (iActualScene < 13) {
- fn2_Set_Font(cFontDir[2]);
- fn2_Load_Bitmaps();
- sh = ddx2CreateSurface(891, 149, ddx2FindFreeSurface());
- if (sh != K_CHYBA) {
- ty = co2_Set_Text_Formated_Rect(sh, 0, 0, text, 0, &r);
- ddx2TransparentBltDisplay(83,
- 33 + ftoi(((6 * b2_3d_font.iYPlus) - ty) / 2.0f), 891, 149, sh, 0, 0,
- 891, 149, TRANSCOLOR);
- ddx2ReleaseBitmap(sh);
- }
- fn2_Release_Font();
- }
- ddx2RenderujVse(p_ber);
- flip();
- }
- void RunMenuLoadScreenRelease(int iCount)
- {
- if (iLoadScreenDevice) {
- ddx2CleareSurfaceColor(DDX2_BACK_BUFFER, 0);
- for (int i = 0; i < iCount; i++) {
- ddx2RenderujVse(p_ber);
- flip();
- }
- ddx2ReleaseBitmap(iLoadScreenBitmap);
- ddx2DeviceDeaktivuj();
- ddx2DeviceRemove(iLoadScreenDevice);
- ddx2Release();
- iLoadScreenDevice = 0;
- }
- ddx2GameRender(TRUE);
- }
- static float ProgressStatus;
- static float ProgressPlus;
- void RunMenuLoadScreenInitBar(int iNumOfItems)
- {
- ProgressStatus = 0;
- ProgressPlus = 100.0f / (float) iNumOfItems;
- }
- void RunMenuLoadScreenAddProgress(float fPercent)
- {
- if (fPercent >= 0)
- ProgressStatus += fPercent;
- else
- ProgressStatus += ProgressPlus;
-
- if(ProgressStatus > 100.0f)
- ProgressStatus = 100.0f;
- }
- void RunMenuLoadScreenDrawProgress(int x, int y)
- {
- RECT r = { 0, 753, 0, 768 };
- int Width;
- Width = (int) ftoi((1024 * ProgressStatus) / 100.0f);
- r.right = Width;
- switch (iActualScene) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 7:
- ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(166, 200, 145));
- break;
- case 5:
- case 8:
- ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(224, 211, 188));
- break;
- case 0:
- case 10:
- case 11:
- ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(2, 25, 77));
- break;
- case 6:
- case 9:
- ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(170, 193, 245));
- break;
- case 12:
- ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(255, 196, 129));
- break;
- default:
- ddx2FillRect(DDX2_BACK_BUFFER, &r, RGB(255, 0, 0));
- break;
- }
- ddx2RenderujVse(p_ber);
- flip();
- }
|