3D_menus.cpp 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889
  1. //------------------------------------------------------------------------------------------------
  2. // version 0.0.1
  3. //------------------------------------------------------------------------------------------------
  4. #include <math.h>
  5. #include <wchar.h>
  6. #include <assert.h>
  7. #include "font.h"
  8. #include "3d_all.h"
  9. #include "Berusky3d_kofola_interface.h"
  10. #include "Berusky3d_light.h"
  11. #include "3D_graphic.h"
  12. #include "Object.h"
  13. #include "menu_script.h"
  14. #include "controls.h"
  15. #include "2D_graphic.h"
  16. #include "Menu2.h"
  17. #include "animationk.h"
  18. #include "3D_menus.h"
  19. #include "load_level.h"
  20. #include "menu_def.h"
  21. extern ANIMATION_MODULE am;
  22. extern AUDIO_DATA ad;
  23. extern _3D_DATA _3dd;
  24. extern G_KONFIG ber;
  25. extern _3D_CURSOR _3dCur;
  26. extern B2_FONT b2_3d_font;
  27. extern int cameraflag;
  28. HINT_STATE sHint;
  29. KUK_STATE sKuk;
  30. EDIT_TEXT sIndikace[3];
  31. extern char pBmpDir[MAX_FILENAME];
  32. extern char p3DMDir[MAX_FILENAME];
  33. extern char pDataDir[MAX_FILENAME];
  34. typedef struct
  35. {
  36. float vfLocation[4];
  37. int iTexture;
  38. int iNextFrame;
  39. int iTimeToNextFrame;
  40. char cCleanDrawLine;
  41. float fScale;
  42. } _3D_ANIMATION_FRAME;
  43. typedef struct __3D_ANIMATION
  44. {
  45. _3D_ANIMATION_FRAME _3dFrame[32];
  46. int iLastFrame;
  47. int iActFrame;
  48. int iTimeCounter;
  49. char bStop;
  50. int iID;
  51. int *pFlag;
  52. struct __3D_ANIMATION *pNext;
  53. struct __3D_ANIMATION *pPrevious;
  54. } _3D_ANIMATION;
  55. typedef struct __3D_DRAW_LIST
  56. {
  57. float vfLocation[4];
  58. int iTexture;
  59. int iOwnerID;
  60. struct __3D_DRAW_LIST *pNext;
  61. struct __3D_DRAW_LIST *pPrevious;
  62. } _3D_DRAW_LIST;
  63. typedef struct
  64. {
  65. _3D_ANIMATION _3DAnimation[32];
  66. _3D_DRAW_LIST *pFDrawList;
  67. _3D_DRAW_LIST *pLDrawList;
  68. _3D_ANIMATION *pFAnimation;
  69. _3D_ANIMATION *pLAnimation;
  70. int iLastID;
  71. char bMenuButton;
  72. int iMenuButtonID;
  73. char bItem;
  74. int iInvIndex;
  75. int iItemIndex;
  76. int iItemID;
  77. int iCibuleID;
  78. char bLastMenuItem;
  79. int iLastMenuItemID;
  80. int iLastIsIn;
  81. } _3D_ANIMATION_STRUCTURE;
  82. _3D_ANIMATION_STRUCTURE _3DAnimationStruct;
  83. extern AUDIO_DATA ad;
  84. HINT_TEXTURE pHintTexture[26];
  85. HINT_TEXTURE pMessageTexture[8];
  86. #define HINT_SCALE 1.0f
  87. //888888888888888888888888888888888888888888
  88. //extern int menu_texture;
  89. //888888888888888888888888888888888888888888
  90. void _3d_Stop_Animation(int iID, char cCleanDrawLine);
  91. void _3d_RemoveIDFromDrawList(int iID);
  92. void _3d_Obsluha_Game_Menu(char *bCursor, int *Cursor_Time_Out, LEVELINFO * p_Level, int demo);
  93. void _3d_Start_Settings(void);
  94. void _3d_Draw_Hint(void);
  95. void _3d_Draw_Indikace(LEVELINFO * p_Level);
  96. int gl_Inventory_Item_To_Object(LEVELINFO * p_Level, int Item, char bDec);
  97. void _3d_CleanDrawList(void)
  98. {
  99. _3D_DRAW_LIST *pDrawList = _3DAnimationStruct.pFDrawList;
  100. _3D_DRAW_LIST *pNDrawList;
  101. if (!pDrawList)
  102. return;
  103. _3DAnimationStruct.pLDrawList = NULL;
  104. while (pDrawList) {
  105. pNDrawList = pDrawList->pNext;
  106. free((void *) pDrawList);
  107. pDrawList = pNDrawList;
  108. }
  109. _3DAnimationStruct.pFDrawList = NULL;
  110. }
  111. void _3d_CleanAnimationList(void)
  112. {
  113. _3D_ANIMATION *pAnim = _3DAnimationStruct.pFAnimation;
  114. _3D_ANIMATION *pNAnim;
  115. if (!pAnim)
  116. return;
  117. _3DAnimationStruct.pLAnimation = NULL;
  118. while (pAnim) {
  119. pNAnim = pAnim->pNext;
  120. if (pAnim->pFlag)
  121. *pAnim->pFlag = 1;
  122. _3d_RemoveIDFromDrawList(pAnim->iID);
  123. free((void *) pAnim);
  124. pAnim = pNAnim;
  125. }
  126. _3DAnimationStruct.pFAnimation = NULL;
  127. }
  128. void _3d_RemoveDrawListItem(_3D_DRAW_LIST * pItem)
  129. {
  130. if (!pItem->pPrevious)
  131. _3DAnimationStruct.pFDrawList = pItem->pNext;
  132. else
  133. pItem->pPrevious->pNext = pItem->pNext;
  134. if (!pItem->pNext)
  135. _3DAnimationStruct.pLDrawList = pItem->pPrevious;
  136. else
  137. pItem->pNext->pPrevious = pItem->pPrevious;
  138. free((void *) pItem);
  139. }
  140. void _3d_AddItemToDrawList(_3D_ANIMATION_FRAME * pFrame, int iOwnerID)
  141. {
  142. _3D_DRAW_LIST *pLDrawList = _3DAnimationStruct.pLDrawList;
  143. _3D_DRAW_LIST *pDrawList = (_3D_DRAW_LIST *) mmalloc(sizeof(_3D_DRAW_LIST));
  144. if (!pLDrawList) {
  145. _3DAnimationStruct.pFDrawList = pDrawList;
  146. _3DAnimationStruct.pLDrawList = pDrawList;
  147. pDrawList->pPrevious = NULL;
  148. }
  149. else {
  150. pDrawList->pPrevious = pLDrawList;
  151. pLDrawList->pNext = pDrawList;
  152. }
  153. // kprintf(1, "%d - pridano do draw listu ....", pFrame->iTexture);
  154. pDrawList->iOwnerID = iOwnerID;
  155. pDrawList->iTexture = pFrame->iTexture;
  156. memcpy((void *) pDrawList->vfLocation, (void *) pFrame->vfLocation, 4 * sizeof(float));
  157. pDrawList->pNext = NULL;
  158. _3DAnimationStruct.pLDrawList = pDrawList;
  159. }
  160. void _3d_RemoveIDFromDrawList(int iID)
  161. {
  162. _3D_DRAW_LIST *pItem = _3DAnimationStruct.pFDrawList;
  163. _3D_DRAW_LIST *pNextItem;
  164. while (pItem) {
  165. pNextItem = pItem->pNext;
  166. if (pItem->iOwnerID == iID)
  167. _3d_RemoveDrawListItem(pItem);
  168. pItem = pNextItem;
  169. }
  170. }
  171. //------------------------------------------------------------------------------------------------
  172. // provede animaci
  173. //------------------------------------------------------------------------------------------------
  174. void _3d_Animation(_3D_ANIMATION * p3DAnim, int iTime)
  175. {
  176. _3D_ANIMATION_DRAW:
  177. if (iTime >= 0) {
  178. if (p3DAnim->_3dFrame[p3DAnim->iActFrame].cCleanDrawLine)
  179. _3d_RemoveIDFromDrawList(p3DAnim->iID);
  180. if (p3DAnim->_3dFrame[p3DAnim->iActFrame].iNextFrame == -1) {
  181. p3DAnim->bStop = 1;
  182. return;
  183. }
  184. iTime -= p3DAnim->_3dFrame[p3DAnim->iActFrame].iTimeToNextFrame;
  185. p3DAnim->iActFrame = p3DAnim->_3dFrame[p3DAnim->iActFrame].iNextFrame;
  186. }
  187. while (iTime > 0) {
  188. if (p3DAnim->_3dFrame[p3DAnim->iActFrame].iNextFrame == -1) {
  189. _3d_AddItemToDrawList(&p3DAnim->_3dFrame[p3DAnim->iActFrame], p3DAnim->iID);
  190. p3DAnim->bStop = 1;
  191. break;
  192. }
  193. iTime -= p3DAnim->_3dFrame[p3DAnim->iActFrame].iTimeToNextFrame;
  194. if (iTime > (p3DAnim->_3dFrame[p3DAnim->_3dFrame[p3DAnim->iActFrame].iNextFrame].iTimeToNextFrame / 2.0f))
  195. {
  196. _3d_AddItemToDrawList(&p3DAnim->_3dFrame[p3DAnim->iActFrame], p3DAnim->iID);
  197. p3DAnim->iActFrame = p3DAnim->_3dFrame[p3DAnim->iActFrame].iNextFrame;
  198. }
  199. else if (!p3DAnim->_3dFrame[p3DAnim->iActFrame].iTimeToNextFrame)
  200. break;
  201. }
  202. iTime = 0;
  203. _3d_AddItemToDrawList(&p3DAnim->_3dFrame[p3DAnim->iActFrame], p3DAnim->iID);
  204. if (!p3DAnim->_3dFrame[p3DAnim->iActFrame].iTimeToNextFrame)
  205. goto _3D_ANIMATION_DRAW;
  206. if (p3DAnim->_3dFrame[p3DAnim->iActFrame].iNextFrame == -1) {
  207. _3d_AddItemToDrawList(&p3DAnim->_3dFrame[p3DAnim->iActFrame], p3DAnim->iID);
  208. p3DAnim->bStop = 1;
  209. return;
  210. }
  211. }
  212. int _3d_Start_Animation(int iIndex, float *vfLocation, int *pFlag)
  213. {
  214. int i;
  215. _3D_ANIMATION *pL3DAnim = _3DAnimationStruct.pLAnimation;
  216. _3D_ANIMATION *p3DAnim = (_3D_ANIMATION *) mmalloc(sizeof(_3D_ANIMATION));
  217. memcpy((void *) p3DAnim, (void *) &_3DAnimationStruct._3DAnimation[iIndex], sizeof(_3D_ANIMATION));
  218. if (!pL3DAnim) {
  219. _3DAnimationStruct.pFAnimation = p3DAnim;
  220. _3DAnimationStruct.pLAnimation = p3DAnim;
  221. p3DAnim->pPrevious = NULL;
  222. }
  223. else {
  224. p3DAnim->pPrevious = pL3DAnim;
  225. pL3DAnim->pNext = p3DAnim;
  226. }
  227. p3DAnim->bStop = 0;
  228. p3DAnim->iID = _3DAnimationStruct.iLastID;
  229. _3DAnimationStruct.iLastID++;
  230. p3DAnim->iActFrame = 0;
  231. p3DAnim->iTimeCounter = 0;
  232. p3DAnim->pNext = NULL;
  233. p3DAnim->pFlag = pFlag;
  234. _3DAnimationStruct.pLAnimation = p3DAnim;
  235. if (vfLocation) {
  236. for (i = 0; i < p3DAnim->iLastFrame; i++) {
  237. memcpy((void *) p3DAnim->_3dFrame[i].vfLocation, (void *) vfLocation, 4 * sizeof(float));
  238. }
  239. }
  240. _3d_Animation(p3DAnim, -1);
  241. return 1;
  242. }
  243. void _3d_Stop_Animation(int iID, char cCleanDrawLine)
  244. {
  245. _3D_ANIMATION *p3DAnim = _3DAnimationStruct.pFAnimation;
  246. if (!p3DAnim)
  247. return;
  248. while (p3DAnim) {
  249. if (p3DAnim->iID == iID) {
  250. if (cCleanDrawLine)
  251. _3d_RemoveIDFromDrawList(iID);
  252. if (!p3DAnim->pPrevious)
  253. _3DAnimationStruct.pFAnimation = p3DAnim->pNext;
  254. else
  255. p3DAnim->pPrevious->pNext = p3DAnim->pNext;
  256. if (!p3DAnim->pNext)
  257. _3DAnimationStruct.pLAnimation = p3DAnim->pPrevious;
  258. else
  259. p3DAnim->pNext->pPrevious = p3DAnim->pPrevious;
  260. if (p3DAnim->pFlag)
  261. *p3DAnim->pFlag = 1;
  262. free((void *) p3DAnim);
  263. return;
  264. }
  265. p3DAnim = p3DAnim->pNext;
  266. }
  267. }
  268. void _3d_Draw_3DAnimations(void)
  269. {
  270. _3D_DRAW_LIST *pItem = _3DAnimationStruct.pFDrawList;
  271. if (!pItem)
  272. return;
  273. while (pItem) {
  274. float p[4];
  275. p[0] = pItem->vfLocation[0] * scale_back_factor_x();
  276. p[1] = pItem->vfLocation[1] * scale_back_factor_y();
  277. p[2] = pItem->vfLocation[2] * scale_back_factor_x();
  278. p[3] = pItem->vfLocation[3] * scale_back_factor_y();
  279. _3d_Draw_Box(pItem->iTexture, p);
  280. pItem = pItem->pNext;
  281. }
  282. }
  283. //------------------------------------------------------------------------------------------------
  284. // provede animace
  285. //------------------------------------------------------------------------------------------------
  286. void _3d_AnimationEvent(void)
  287. {
  288. _3D_ANIMATION_STRUCTURE *p3DAnimationStruct = &_3DAnimationStruct;
  289. _3D_ANIMATION *p3DAnim = p3DAnimationStruct->pFAnimation;
  290. _3D_ANIMATION *p3DNAnim;
  291. DWORD e = ber.TimeLastFrame;
  292. while (p3DAnim) {
  293. p3DAnim->iTimeCounter += e;
  294. p3DNAnim = p3DAnim->pNext;
  295. if (p3DAnim->bStop) {
  296. _3d_Stop_Animation(p3DAnim->iID,
  297. p3DAnim->_3dFrame[p3DAnim->iLastFrame - 1].cCleanDrawLine);
  298. }
  299. else {
  300. if (p3DAnim->iTimeCounter >
  301. p3DAnim->_3dFrame[p3DAnim->iActFrame].iTimeToNextFrame) {
  302. _3d_Animation(p3DAnim, p3DAnim->iTimeCounter);
  303. p3DAnim->iTimeCounter = 0;
  304. }
  305. }
  306. p3DAnim = p3DNAnim;
  307. }
  308. }
  309. //------------------------------------------------------------------------------------------------
  310. // naparsuje radek animace
  311. //------------------------------------------------------------------------------------------------
  312. void Parse_3DAnimLine(FILE * file, _3D_ANIMATION_FRAME * pFrame)
  313. {
  314. char text[MAX_FILENAME], expression[MAX_FILENAME];
  315. int p = 0, r = 0;
  316. if(!fgets(text, MAX_FILENAME, file))
  317. return;
  318. while (p != -1) {
  319. p = Find_Next_Expresion(text, p, expression);
  320. if (p != -1)
  321. switch (r) {
  322. case 1:
  323. pFrame->iTexture = atoi(expression);
  324. break;
  325. case 2:
  326. case 3:
  327. case 4:
  328. case 5:
  329. pFrame->vfLocation[r - 2] = (float) atof(expression);
  330. break;
  331. case 6:
  332. pFrame->iTimeToNextFrame = atoi(expression);
  333. break;
  334. case 7:
  335. pFrame->iNextFrame = atoi(expression);
  336. break;
  337. case 8:
  338. pFrame->cCleanDrawLine = (char) atoi(expression);
  339. break;
  340. case 9:
  341. pFrame->fScale = (float) atof(expression);
  342. break;
  343. }
  344. r++;
  345. }
  346. }
  347. void _3d_Add_To_OpenMenuAnim(_3D_ANIMATION * p3DAnim)
  348. {
  349. int i;
  350. p3DAnim->_3dFrame[p3DAnim->iLastFrame - 1].iNextFrame = p3DAnim->iLastFrame;
  351. for (i = 16; i < 22; i++) {
  352. p3DAnim->_3dFrame[p3DAnim->iLastFrame].cCleanDrawLine = 0;
  353. p3DAnim->_3dFrame[p3DAnim->iLastFrame].fScale = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].fScale;
  354. p3DAnim->_3dFrame[p3DAnim->iLastFrame].iNextFrame = p3DAnim->iLastFrame + 1;
  355. p3DAnim->_3dFrame[p3DAnim->iLastFrame].iTexture = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].iTexture;
  356. p3DAnim->_3dFrame[p3DAnim->iLastFrame].iTimeToNextFrame = 0;
  357. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[0] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[0];
  358. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[1] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[1];
  359. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[2] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[2];
  360. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[3] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[3];
  361. p3DAnim->iLastFrame++;
  362. }
  363. p3DAnim->_3dFrame[p3DAnim->iLastFrame].cCleanDrawLine = 0;
  364. p3DAnim->_3dFrame[p3DAnim->iLastFrame].fScale = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].fScale;
  365. p3DAnim->_3dFrame[p3DAnim->iLastFrame].iNextFrame = -1;
  366. p3DAnim->_3dFrame[p3DAnim->iLastFrame].iTexture = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].iTexture;
  367. p3DAnim->_3dFrame[p3DAnim->iLastFrame].iTimeToNextFrame = 50;
  368. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[0] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[0];
  369. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[1] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[1];
  370. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[2] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[2];
  371. p3DAnim->_3dFrame[p3DAnim->iLastFrame].vfLocation[3] = _3DAnimationStruct._3DAnimation[i]._3dFrame[0].vfLocation[3];
  372. p3DAnim->iLastFrame++;
  373. }
  374. void _3d_Load_Animations(void)
  375. {
  376. _3D_ANIMATION_FRAME *pFrame;
  377. _3D_ANIMATION *p3DAnim;
  378. FILE *pFile = NULL, *pListFile = NULL;
  379. char text[MAX_FILENAME];
  380. char filename[MAX_FILENAME];
  381. int i = 0, j;
  382. construct_path(filename, MAX_FILENAME, 2, pDataDir, "3DAnimations.dat");
  383. pListFile = fopen(filename, "r");
  384. if (pListFile) {
  385. while (!feof(pListFile)) {
  386. if (!fgets(text, MAX_FILENAME, pListFile) || !text[0])
  387. break;
  388. else
  389. newline_cut(text);
  390. construct_path(filename, MAX_FILENAME, 2, pDataDir, text);
  391. pFile = fopen(filename, "r");
  392. if (pFile) {
  393. p3DAnim = &_3DAnimationStruct._3DAnimation[i];
  394. j = 0;
  395. while (!feof(pFile)) {
  396. pFrame = &p3DAnim->_3dFrame[j];
  397. Parse_3DAnimLine(pFile, pFrame);
  398. if (i >= 16 && i < 23) {
  399. float dx;
  400. pFrame->iTexture += MENU_ANIMATION_CORECTION;
  401. dx = ((pFrame->vfLocation[2] - pFrame->vfLocation[0]) - (_3dd.p_sysramtexture[pFrame->iTexture].tx * pFrame->fScale)) / 2.0f;
  402. pFrame->vfLocation[0] += dx;
  403. pFrame->vfLocation[2] = pFrame->vfLocation[0] + (_3dd.p_sysramtexture[pFrame->iTexture].x * pFrame->fScale);
  404. pFrame->vfLocation[3] = pFrame->vfLocation[1] + _3dd.p_sysramtexture[pFrame->iTexture].y * pFrame->fScale;
  405. }
  406. j++;
  407. }
  408. p3DAnim->bStop = 0;
  409. p3DAnim->iActFrame = 0;
  410. p3DAnim->iLastFrame = j - 1;
  411. p3DAnim->iID = i;
  412. i++;
  413. fclose(pFile);
  414. strcpy(text, "");
  415. }
  416. else
  417. kprintf(1, "Nenalezen 3danimacni soubor %s", text);
  418. }
  419. _3d_Add_To_OpenMenuAnim(&_3DAnimationStruct._3DAnimation[14]);
  420. fclose(pListFile);
  421. }
  422. else {
  423. kprintf(1, "Nenalezen soubor se seznamem 3d animaci!");
  424. }
  425. _3DAnimationStruct.pFDrawList = NULL;
  426. _3DAnimationStruct.pLDrawList = NULL;
  427. _3DAnimationStruct.pFAnimation = NULL;
  428. _3DAnimationStruct.pLAnimation = NULL;
  429. _3DAnimationStruct.bMenuButton = 0;
  430. _3DAnimationStruct.bItem = 0;
  431. _3DAnimationStruct.iItemID = -1;
  432. _3DAnimationStruct.iItemIndex = -1;
  433. _3DAnimationStruct.iInvIndex = -1;
  434. _3DAnimationStruct.iCibuleID = -1;
  435. _3DAnimationStruct.bLastMenuItem = 0;
  436. _3DAnimationStruct.iLastMenuItemID = -1;
  437. _3DAnimationStruct.iLastIsIn = -1;
  438. }
  439. void _3d_Draw_Item(float *pos, int iBackPack, int iItem, LEVELINFO * p_Level,
  440. char bAnimate)
  441. {
  442. if (p_Level->Actual_Item == -1)
  443. return;
  444. if (bAnimate) {
  445. if (!iBackPack)
  446. iBackPack += p_Level->Level[p_Level->Actual_Item]->p_Object->SubClass;
  447. else
  448. iBackPack += 4;
  449. if (_3DAnimationStruct.bItem &&
  450. _3DAnimationStruct.iItemIndex == iBackPack &&
  451. _3DAnimationStruct.iInvIndex == iItem)
  452. return;
  453. else
  454. if (_3DAnimationStruct.bItem &&
  455. (_3DAnimationStruct.iItemIndex != iBackPack ||
  456. _3DAnimationStruct.iInvIndex != iItem))
  457. _3d_Stop_Animation(_3DAnimationStruct.iItemID, 1);
  458. _3d_Start_Animation(iBackPack + 1, pos, NULL);
  459. _3DAnimationStruct.iItemID = _3DAnimationStruct.iLastID - 1;
  460. _3DAnimationStruct.iItemIndex = iBackPack;
  461. _3DAnimationStruct.iInvIndex = iItem;
  462. _3DAnimationStruct.bItem = 1;
  463. }
  464. else
  465. switch (iBackPack) {
  466. case 0:
  467. _3d_Draw_Box(26 + (6 * p_Level->Level[p_Level->Actual_Item]->p_Object->SubClass), pos);
  468. break;
  469. case 4:
  470. _3d_Draw_Box(56, pos);
  471. break;
  472. case 7:
  473. _3d_Draw_Box(68, pos);
  474. break;
  475. case 8:
  476. _3d_Draw_Box(62, pos);
  477. break;
  478. }
  479. }
  480. void _3d_Animate_Item(float *pos, int iItem, LEVELINFO * p_Level)
  481. {
  482. int m = 0;
  483. int i;
  484. for (i = 0; i < 16; i++) {
  485. if (i != 3 && i != 5)
  486. m += p_Level->Level[p_Level->Actual_Item]->p_Back_Pack->item[i];
  487. if (m > iItem)
  488. break;
  489. }
  490. _3d_Draw_Item(pos, i, iItem, p_Level, 1);
  491. }
  492. //------------------------------------------------------------------------------------------------
  493. // kresli inventorar
  494. //------------------------------------------------------------------------------------------------
  495. int _3d_Draw_Invertory(LEVELINFO * p_Level, int act_item, char bCursor)
  496. {
  497. char bAnimated = 0;
  498. float pos[4];
  499. int ret = -1, i, c, m = 0;
  500. _3d_Draw_Inventory();
  501. if (p_Level->Actual_Item == -1)
  502. return ret;
  503. for (i = 0; i < 16; i++)
  504. if (i != 3 && i != 5)
  505. for (c = 0;
  506. c < p_Level->Level[p_Level->Actual_Item]->p_Back_Pack->item[i]; c++) {
  507. switch (m) {
  508. case 0:
  509. pos[0] = 68 * scale_back_factor_x();
  510. pos[1] = 696 * scale_back_factor_y();
  511. pos[2] = 100 * scale_back_factor_x();
  512. pos[3] = 728 * scale_back_factor_y();
  513. _3d_Draw_Item(pos, i, act_item, p_Level, 0);
  514. m++;
  515. break;
  516. case 1:
  517. pos[0] = 114 * scale_back_factor_x();
  518. pos[1] = 726 * scale_back_factor_y();
  519. pos[2] = 146 * scale_back_factor_x();
  520. pos[3] = 758 * scale_back_factor_y();
  521. _3d_Draw_Item(pos, i, act_item, p_Level, 0);
  522. m++;
  523. break;
  524. case 2:
  525. pos[0] = 167 * scale_back_factor_x();
  526. pos[1] = 726 * scale_back_factor_y();
  527. pos[2] = 199 * scale_back_factor_x();
  528. pos[3] = 758 * scale_back_factor_y();
  529. _3d_Draw_Item(pos, i, act_item, p_Level, 0);
  530. m++;
  531. break;
  532. case 3:
  533. pos[0] = 221 * scale_back_factor_x();
  534. pos[1] = 726 * scale_back_factor_y();
  535. pos[2] = 254 * scale_back_factor_x();
  536. pos[3] = 758 * scale_back_factor_y();
  537. _3d_Draw_Item(pos, i, act_item, p_Level, 0);
  538. m++;
  539. break;
  540. }
  541. }
  542. m = 0;
  543. if (bCursor) {
  544. for (i = 0; i < 16; i++)
  545. if (i != 3 && i != 5)
  546. m += p_Level->Level[p_Level->Actual_Item]->p_Back_Pack->item[i];
  547. if (m > 0)
  548. if ((mi.x >= 67 * scale_back_factor_x())
  549. && (mi.x <= 101 * scale_back_factor_x())
  550. && (mi.y >= 696 * scale_back_factor_y())
  551. && (mi.y <= 728 * scale_back_factor_y())) {
  552. bAnimated = 1;
  553. pos[0] = 68 * scale_back_factor_x();
  554. pos[1] = 696 * scale_back_factor_y();
  555. pos[2] = 100 * scale_back_factor_x();
  556. pos[3] = 728 * scale_back_factor_y();
  557. _3d_Animate_Item(pos, 0, p_Level);
  558. if (mi.t1)
  559. ret = 0;
  560. _3d_Display_Hint_Inventory(p_Level,
  561. p_Level->Level[p_Level->Actual_Item],
  562. 0, 68, 696);
  563. }
  564. if (m > 1)
  565. if ((mi.x >= 114 * scale_back_factor_x())
  566. && (mi.x <= 146 * scale_back_factor_x())
  567. && (mi.y >= 725 * scale_back_factor_y())
  568. && (mi.y <= 759 * scale_back_factor_y())) {
  569. bAnimated = 1;
  570. pos[0] = 114 * scale_back_factor_x();
  571. pos[1] = 726 * scale_back_factor_y();
  572. pos[2] = 146 * scale_back_factor_x();
  573. pos[3] = 758 * scale_back_factor_y();
  574. _3d_Animate_Item(pos, 1, p_Level);
  575. if (mi.t1)
  576. ret = 1;
  577. _3d_Display_Hint_Inventory(p_Level,
  578. p_Level->Level[p_Level->Actual_Item],
  579. 1, 114, 726);
  580. }
  581. if (m > 2)
  582. if ((mi.x >= 167 * scale_back_factor_x())
  583. && (mi.x <= 199 * scale_back_factor_x())
  584. && (mi.y >= 725 * scale_back_factor_y())
  585. && (mi.y <= 759 * scale_back_factor_y())) {
  586. bAnimated = 1;
  587. pos[0] = 167 * scale_back_factor_x();
  588. pos[1] = 726 * scale_back_factor_y();
  589. pos[2] = 199 * scale_back_factor_x();
  590. pos[3] = 758 * scale_back_factor_y();
  591. _3d_Animate_Item(pos, 2, p_Level);
  592. if (mi.t1)
  593. ret = 2;
  594. _3d_Display_Hint_Inventory(p_Level, p_Level->Level[p_Level->Actual_Item], 2, 167, 726);
  595. }
  596. if (m > 3)
  597. if ((mi.x >= 221 * scale_back_factor_x())
  598. && (mi.x <= 254 * scale_back_factor_x())
  599. && (mi.y >= 725 * scale_back_factor_y())
  600. && (mi.y <= 759 * scale_back_factor_y())) {
  601. bAnimated = 1;
  602. pos[0] = 221 * scale_back_factor_x();
  603. pos[1] = 726 * scale_back_factor_y();
  604. pos[2] = 254 * scale_back_factor_x();
  605. pos[3] = 758 * scale_back_factor_y();
  606. _3d_Animate_Item(pos, 3, p_Level);
  607. if (mi.t1)
  608. ret = 3;
  609. _3d_Display_Hint_Inventory(p_Level, p_Level->Level[p_Level->Actual_Item], 3, 221, 726);
  610. }
  611. }
  612. else {
  613. if (!act_item) {
  614. bAnimated = 1;
  615. pos[0] = 68 * scale_back_factor_x();
  616. pos[1] = 696 * scale_back_factor_y();
  617. pos[2] = 100 * scale_back_factor_x();
  618. pos[3] = 728 * scale_back_factor_y();
  619. _3d_Animate_Item(pos, 0, p_Level);
  620. }
  621. if (act_item == 1) {
  622. bAnimated = 1;
  623. pos[0] = 114 * scale_back_factor_x();
  624. pos[1] = 726 * scale_back_factor_y();
  625. pos[2] = 146 * scale_back_factor_x();
  626. pos[3] = 758 * scale_back_factor_y();
  627. _3d_Animate_Item(pos, 1, p_Level);
  628. }
  629. if (act_item == 2) {
  630. bAnimated = 1;
  631. pos[0] = 167 * scale_back_factor_x();
  632. pos[1] = 726 * scale_back_factor_y();
  633. pos[2] = 199 * scale_back_factor_x();
  634. pos[3] = 758 * scale_back_factor_y();
  635. _3d_Animate_Item(pos, 2, p_Level);
  636. }
  637. if (act_item == 3) {
  638. bAnimated = 1;
  639. pos[0] = 221 * scale_back_factor_x();
  640. pos[1] = 726 * scale_back_factor_y();
  641. pos[2] = 254 * scale_back_factor_x();
  642. pos[3] = 758 * scale_back_factor_y();
  643. _3d_Animate_Item(pos, 3, p_Level);
  644. }
  645. }
  646. if (!bAnimated && _3DAnimationStruct.bItem) {
  647. _3DAnimationStruct.bItem = 0;
  648. _3d_Stop_Animation(_3DAnimationStruct.iItemID, 1);
  649. _3DAnimationStruct.iItemID = -1;
  650. _3DAnimationStruct.iItemIndex = -1;
  651. sHint.bHint = 0;
  652. }
  653. return ret;
  654. }
  655. //------------------------------------------------------------------------------------------------
  656. // spocte vzdalenost dvou bodu
  657. //------------------------------------------------------------------------------------------------
  658. float _3d_Count_Distance(float *a, float *b)
  659. {
  660. return ((float) sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1])));
  661. }
  662. void _3d_Stop_Menu_Select(void)
  663. {
  664. if (_3DAnimationStruct.bMenuButton) {
  665. _3DAnimationStruct.bMenuButton = 0;
  666. _3d_Stop_Animation(_3DAnimationStruct.iMenuButtonID, 1);
  667. }
  668. }
  669. int _3d_Check_Menu_Select(char bCursor, LEVELINFO * p_Level)
  670. {
  671. if (p_Level->bMenuRunning)
  672. return 0;
  673. if ((mi.x >= 960 * scale_back_factor_x())
  674. && (mi.x <= 1019 * scale_back_factor_x())
  675. && (mi.y >= 95 * scale_back_factor_y())
  676. && (mi.y <= 111 * scale_back_factor_y()) && bCursor) {
  677. if (!_3DAnimationStruct.bMenuButton) {
  678. _3DAnimationStruct.bMenuButton = 1;
  679. _3d_Start_Animation(0, NULL, NULL);
  680. _3DAnimationStruct.iMenuButtonID = _3DAnimationStruct.iLastID - 1;
  681. }
  682. return 1;
  683. }
  684. else {
  685. if (_3DAnimationStruct.bMenuButton) {
  686. _3DAnimationStruct.bMenuButton = 0;
  687. _3d_Stop_Animation(_3DAnimationStruct.iMenuButtonID, 1);
  688. }
  689. return 0;
  690. }
  691. }
  692. //------------------------------------------------------------------------------------------------
  693. // zkontroluje, zda je oznacen nejakej brouk
  694. //------------------------------------------------------------------------------------------------
  695. int _3d_Check_Beatle_Select(void)
  696. {
  697. float c[2], m[2];
  698. m[0] = (float) mi.x;
  699. m[1] = (float) mi.y;
  700. c[0] = 194 * scale_back_factor_x();
  701. c[1] = 57 * scale_back_factor_y();
  702. if (_3d_Count_Distance(c, m) <= 32 * scale_back_factor_x())
  703. return 0;
  704. c[0] = 279 * scale_back_factor_x();
  705. c[1] = 58 * scale_back_factor_y();
  706. if (_3d_Count_Distance(c, m) <= 32 * scale_back_factor_x())
  707. return 1;
  708. c[0] = 439 * scale_back_factor_x();
  709. c[1] = 88 * scale_back_factor_y();
  710. if (_3d_Count_Distance(c, m) <= 32 * scale_back_factor_x())
  711. return 2;
  712. c[0] = 529 * scale_back_factor_x();
  713. c[1] = 89 * scale_back_factor_y();
  714. if (_3d_Count_Distance(c, m) <= 32 * scale_back_factor_x())
  715. return 3;
  716. c[0] = 617 * scale_back_factor_x();
  717. c[1] = 88 * scale_back_factor_y();
  718. if (_3d_Count_Distance(c, m) <= 32 * scale_back_factor_x())
  719. return 4;
  720. c[0] = 777 * scale_back_factor_x();
  721. c[1] = 74 * scale_back_factor_y();
  722. if (_3d_Count_Distance(c, m) <= 32 * scale_back_factor_x())
  723. return 5;
  724. return -1;
  725. }
  726. int _3d_Is_There_Beetle(int SubClass, LEVELINFO * p_Level)
  727. {
  728. int i;
  729. for (i = 0; i < 6; i++)
  730. if (p_Level->Beetle[i] == SubClass)
  731. return i;
  732. return -1;
  733. }
  734. int _3d_Is_Selected(int SubClass, LEVELINFO * p_Level)
  735. {
  736. if (p_Level->Beetle[(int)p_Level->Beetle_Index] == SubClass)
  737. return 1;
  738. else
  739. return 0;
  740. }
  741. //------------------------------------------------------------------------------------------------
  742. // draws top ledge
  743. //------------------------------------------------------------------------------------------------
  744. void _3d_Draw_Top_Ledge(LEVELINFO * p_Level, char bCursor)
  745. {
  746. float cx, cy;
  747. float pos[4];
  748. cx = (float) mi.x + _3dCur.iaddx;
  749. cy = (float) mi.y + _3dCur.iaddy;
  750. //zluta beruska
  751. pos[0] = 162 * scale_back_factor_x();
  752. pos[1] = 25 * scale_back_factor_y();
  753. pos[2] = 226 * scale_back_factor_x();
  754. pos[3] = 89 * scale_back_factor_y();
  755. if (_3d_Is_Selected(0, p_Level))
  756. _3d_Draw_Box(6, pos);
  757. else if (_3d_Is_There_Beetle(0, p_Level) == -1)
  758. _3d_Draw_Box(4, pos);
  759. else
  760. _3d_Draw_Box(5, pos);
  761. //hneda beruska
  762. pos[0] = 247 * scale_back_factor_x();
  763. pos[1] = 26 * scale_back_factor_y();
  764. pos[2] = 311 * scale_back_factor_x();
  765. pos[3] = 90 * scale_back_factor_y();
  766. if (_3d_Is_Selected(1, p_Level))
  767. _3d_Draw_Box(9, pos);
  768. else if (_3d_Is_There_Beetle(1, p_Level) == -1)
  769. _3d_Draw_Box(7, pos);
  770. else
  771. _3d_Draw_Box(8, pos);
  772. //cervena beruska
  773. pos[0] = 407 * scale_back_factor_x();
  774. pos[1] = 56 * scale_back_factor_y();
  775. pos[2] = 471 * scale_back_factor_x();
  776. pos[3] = 120 * scale_back_factor_y();
  777. if (_3d_Is_Selected(2, p_Level))
  778. _3d_Draw_Box(12, pos);
  779. else if (_3d_Is_There_Beetle(2, p_Level) == -1)
  780. _3d_Draw_Box(10, pos);
  781. else
  782. _3d_Draw_Box(11, pos);
  783. //modra beruska
  784. pos[0] = 497 * scale_back_factor_x();
  785. pos[1] = 57 * scale_back_factor_y();
  786. pos[2] = 561 * scale_back_factor_x();
  787. pos[3] = 121 * scale_back_factor_y();
  788. if (_3d_Is_Selected(3, p_Level))
  789. _3d_Draw_Box(15, pos);
  790. else if (_3d_Is_There_Beetle(3, p_Level) == -1)
  791. _3d_Draw_Box(13, pos);
  792. else
  793. _3d_Draw_Box(14, pos);
  794. //zelena beruska
  795. pos[0] = 585 * scale_back_factor_x();
  796. pos[1] = 56 * scale_back_factor_y();
  797. pos[2] = 649 * scale_back_factor_x();
  798. pos[3] = 120 * scale_back_factor_y();
  799. if (_3d_Is_Selected(4, p_Level))
  800. _3d_Draw_Box(18, pos);
  801. else if (_3d_Is_There_Beetle(4, p_Level) == -1)
  802. _3d_Draw_Box(16, pos);
  803. else
  804. _3d_Draw_Box(17, pos);
  805. //vodomerka beruska
  806. pos[0] = 745 * scale_back_factor_x();
  807. pos[1] = 42 * scale_back_factor_y();
  808. pos[2] = 809 * scale_back_factor_x();
  809. pos[3] = 106 * scale_back_factor_y();
  810. if (cx > pos[0] && cx < pos[2] && cy > pos[1] && cy < pos[3] && !p_Level->bMenuRunning)
  811. _3d_Draw_Box(21, pos);
  812. else
  813. _3d_Draw_Box(20, pos);
  814. }
  815. void _3d_Draw_Top_Ledge(void)
  816. {
  817. float pos[4];
  818. pos[0] = 0;
  819. pos[1] = 0;
  820. pos[2] = 1024 * scale_back_factor_x();
  821. pos[3] = 128 * scale_back_factor_y();
  822. _3d_Draw_Box(1, pos);
  823. pos[0] = 0;
  824. pos[1] = 128 * scale_back_factor_y();
  825. pos[2] = 1024 * scale_back_factor_x();
  826. pos[3] = 192 * scale_back_factor_y();
  827. _3d_Draw_Box(2, pos);
  828. pos[0] = 896 * scale_back_factor_x();
  829. pos[1] = 192 * scale_back_factor_y();
  830. pos[2] = 1024 * scale_back_factor_x();
  831. pos[3] = 320 * scale_back_factor_y();
  832. _3d_Draw_Box(3, pos);
  833. pos[0] = 960 * scale_back_factor_x();
  834. pos[1] = 320 * scale_back_factor_y();
  835. pos[2] = 1024 * scale_back_factor_x();
  836. pos[3] = 352 * scale_back_factor_y();
  837. _3d_Draw_Box(104, pos);
  838. }
  839. void _3d_Draw_Inventory(void)
  840. {
  841. float pos[4];
  842. pos[0] = 0;
  843. pos[1] = 704 * scale_back_factor_y();
  844. pos[2] = 256 * scale_back_factor_x();
  845. pos[3] = 768 * scale_back_factor_y();
  846. _3d_Draw_Box(22, pos);
  847. pos[0] = 256 * scale_back_factor_x();
  848. pos[1] = 704 * scale_back_factor_y();
  849. pos[2] = 288 * scale_back_factor_x();
  850. pos[3] = 768 * scale_back_factor_y();
  851. _3d_Draw_Box(105, pos);
  852. pos[0] = 0;
  853. pos[1] = 671 * scale_back_factor_y();
  854. pos[2] = 128 * scale_back_factor_x();
  855. pos[3] = 704 * scale_back_factor_y();
  856. _3d_Draw_Box(23, pos);
  857. pos[0] = 128 * scale_back_factor_x();
  858. pos[1] = 671 * scale_back_factor_y();
  859. pos[2] = 160 * scale_back_factor_x();
  860. pos[3] = 704 * scale_back_factor_y();
  861. _3d_Draw_Box(24, pos);
  862. pos[0] = 0;
  863. pos[1] = 607 * scale_back_factor_y();
  864. pos[2] = 32 * scale_back_factor_x();
  865. pos[3] = 671 * scale_back_factor_y();
  866. _3d_Draw_Box(106, pos);
  867. }
  868. void _3d_Draw_MenusB(LEVELINFO * p_Level, int act_item, char *bCursor,
  869. int bTutor, int bTText, int ty)
  870. {
  871. float pos[4];
  872. if (p_Level->bTopLedge) {
  873. _3d_Draw_Top_Ledge();
  874. _3d_Draw_Top_Ledge(p_Level, *bCursor);
  875. }
  876. if (p_Level->bInventory) {
  877. _3d_Draw_Invertory(p_Level, act_item, *bCursor);
  878. }
  879. _3d_AnimationEvent();
  880. _3d_Draw_3DAnimations();
  881. if (bTutor) {
  882. _3d_Set_Smooth();
  883. pos[0] = 10 * scale_back_factor_x();
  884. pos[1] = 200 * scale_back_factor_y();
  885. pos[2] = 1034 * scale_back_factor_x();
  886. pos[3] = (ty * scale_back_factor_y());
  887. glBindTexture(GL_TEXTURE_2D, bTText);
  888. glBegin(GL_TRIANGLE_STRIP);
  889. glTexCoord2d(0, 1);
  890. glVertex2d(pos[0], pos[1]);
  891. glTexCoord2d(0, 0);
  892. glVertex2d(pos[0], pos[3]);
  893. glTexCoord2d(1, 1);
  894. glVertex2d(pos[2], pos[1]);
  895. glTexCoord2d(1, 0);
  896. glVertex2d(pos[2], pos[3]);
  897. glEnd();
  898. _3d_Set_Mask();
  899. }
  900. }
  901. void _3d_Start_Kuk(void)
  902. {
  903. sKuk.y = randf() * (640 * scale_back_factor_y());
  904. sKuk.x = (float) SCREEN_XRES;
  905. sKuk.bKUK = 1;
  906. sKuk.iState = 0;
  907. sKuk.Speed = 600.0f;
  908. sKuk.dwTCounter = 0;
  909. }
  910. void _3d_Process_Kuk(void)
  911. {
  912. float pos[4];
  913. float f = sKuk.Speed * (ber.TimeLastFrame / 1000.0f);
  914. switch (sKuk.iState) {
  915. case 0:
  916. sKuk.x -= f;
  917. if (sKuk.x < (SCREEN_XRES - (128 * scale_back_factor_x()))) {
  918. sKuk.x = (SCREEN_XRES - (128 * scale_back_factor_x()));
  919. sKuk.iState = 1;
  920. }
  921. break;
  922. case 1:
  923. sKuk.dwTCounter += ber.TimeLastFrame;
  924. if (sKuk.dwTCounter > 1000)
  925. sKuk.iState = 2;
  926. break;
  927. case 2:
  928. sKuk.x += f;
  929. if (sKuk.x > SCREEN_XRES) {
  930. sKuk.bKUK = 0;
  931. sKuk.iState = 3;
  932. }
  933. break;
  934. }
  935. pos[0] = sKuk.x;
  936. pos[1] = sKuk.y;
  937. pos[2] = sKuk.x + (128 * scale_back_factor_x());
  938. pos[3] = sKuk.y + (128 * scale_back_factor_y());
  939. //kprintf(1, "%f, %f, %f, %f", pos[0], pos[1], pos[2], pos[3]);
  940. glBindTexture(GL_TEXTURE_2D, sKuk.text.text);
  941. glBegin(GL_TRIANGLE_STRIP);
  942. glTexCoord2d(0, 1);
  943. glVertex2d(pos[0], pos[1]);
  944. glTexCoord2d(0, 0);
  945. glVertex2d(pos[0], pos[3]);
  946. glTexCoord2d(1, 1);
  947. glVertex2d(pos[2], pos[1]);
  948. glTexCoord2d(1, 0);
  949. glVertex2d(pos[2], pos[3]);
  950. glEnd();
  951. }
  952. //------------------------------------------------------------------------------------------------
  953. // draws all 3d menus in game to the surface
  954. //------------------------------------------------------------------------------------------------
  955. void _3d_Draw_Menus(char *bCursor, int *Cursor_Time_Out,
  956. LEVELINFO * p_Level, int act_item, int *p_Return, int demo)
  957. {
  958. float pos[4];
  959. if ((mi.dx || mi.dy) && cameraflag == -1) {
  960. (*bCursor) = 1;
  961. (*Cursor_Time_Out) = 0;
  962. mi.dx = 0;
  963. mi.dy = 0;
  964. }
  965. _3d_Begin_Draw();
  966. if (p_Level->bTopLedge) {
  967. _3d_Draw_Top_Ledge();
  968. _3d_Draw_Top_Ledge(p_Level, *bCursor);
  969. p_Return[1] = _3d_Check_Menu_Select(*bCursor, p_Level);
  970. if (p_Return[1]) {
  971. (*bCursor) = 1;
  972. (*Cursor_Time_Out) = 0;
  973. }
  974. }
  975. if (p_Level->bInventory) {
  976. p_Return[0] = _3d_Draw_Invertory(p_Level, act_item, *bCursor);
  977. if (p_Level->bMenuRunning == 2 && !p_Level->bRestart && !p_Level->bReturnToMenu)
  978. _3d_Obsluha_Game_Menu(bCursor, Cursor_Time_Out, p_Level, demo);
  979. _3d_AnimationEvent();
  980. }
  981. else
  982. p_Return[0] = -1;
  983. _3d_Draw_3DAnimations();
  984. _3d_Draw_Indikace(p_Level);
  985. if (!sKuk.bKUK) {
  986. if (!(rand() % 100000))
  987. _3d_Start_Kuk();
  988. }
  989. else if (sKuk.bKUK)
  990. _3d_Process_Kuk();
  991. if (sHint.bHint) {
  992. _3d_Set_Smooth();
  993. _3d_Draw_Hint();
  994. sHint.dwTCounter += ber.TimeLastFrame;
  995. if (sHint.dwTCounter > 5000)
  996. sHint.bHint = 0;
  997. }
  998. if (p_Level->bRestart) {
  999. (*bCursor) = 1;
  1000. (*Cursor_Time_Out) = 0;
  1001. p_Level->iMessageBoxReturn = _3d_Draw_MessageBox(4);
  1002. }
  1003. if (p_Level->bReturnToMenu) {
  1004. (*bCursor) = 1;
  1005. (*Cursor_Time_Out) = 0;
  1006. p_Level->iMessageBoxReturn = _3d_Draw_MessageBox(6);
  1007. }
  1008. if (*bCursor) {
  1009. if (!p_Level->iCursor) {
  1010. pos[0] = (float) mi.x + _3dCur.iaddx;
  1011. pos[1] = (float) mi.y + _3dCur.iaddy;
  1012. pos[2] = (float) mi.x + _3dCur.idx + _3dCur.iaddx;
  1013. pos[3] = (float) mi.y + _3dCur.idy + _3dCur.iaddy;
  1014. }
  1015. else {
  1016. pos[0] = (float) mi.x;
  1017. pos[1] = (float) mi.y;
  1018. pos[2] = (float) mi.x + 32;
  1019. pos[3] = (float) mi.y + 32;
  1020. }
  1021. _3d_Set_Smooth();
  1022. _3d_Draw_Box(p_Level->iCursor, pos);
  1023. }
  1024. _3d_End_Draw();
  1025. flip();
  1026. return;
  1027. }
  1028. void _3d_Run_Cibule(void)
  1029. {
  1030. _3d_Start_Animation(15, NULL, NULL);
  1031. _3DAnimationStruct.iCibuleID = _3DAnimationStruct.iLastID - 1;
  1032. }
  1033. int _3d_Animete_Menu_Item(int iAnimation, int IsInID)
  1034. {
  1035. if (mi.t1) {
  1036. _3d_Stop_Animation(_3DAnimationStruct.iLastMenuItemID, 1);
  1037. mi.t1 = 0;
  1038. return 1;
  1039. }
  1040. else if (_3DAnimationStruct.bLastMenuItem) {
  1041. if (_3DAnimationStruct.iLastIsIn == IsInID)
  1042. return 0;
  1043. else {
  1044. _3d_Stop_Animation(_3DAnimationStruct.iLastMenuItemID, 1);
  1045. _3d_RemoveIDFromDrawList(_3DAnimationStruct.iLastMenuItemID);
  1046. _3d_Start_Animation(iAnimation, NULL, NULL);
  1047. _3DAnimationStruct.bLastMenuItem = 1;
  1048. _3DAnimationStruct.iLastMenuItemID = _3DAnimationStruct.iLastID - 1;
  1049. return 0;
  1050. }
  1051. }
  1052. else {
  1053. _3d_Start_Animation(iAnimation, NULL, NULL);
  1054. _3DAnimationStruct.bLastMenuItem = 1;
  1055. _3DAnimationStruct.iLastMenuItemID = _3DAnimationStruct.iLastID - 1;
  1056. return 0;
  1057. }
  1058. return 0;
  1059. }
  1060. void _3d_Cancel_Menu(LEVELINFO * p_Level)
  1061. {
  1062. if (_3DAnimationStruct.bLastMenuItem) {
  1063. _3d_Stop_Animation(_3DAnimationStruct.iLastMenuItemID, 1);
  1064. _3DAnimationStruct.iLastMenuItemID = -1;
  1065. _3DAnimationStruct.bLastMenuItem = 0;
  1066. }
  1067. _3d_CleanAnimationList();
  1068. _3d_CleanDrawList();
  1069. p_Level->bMenuRunning = 0;
  1070. _3d_Release_From_Video(107);
  1071. fn_Release_3d_Textures();
  1072. p_Level->bInventory = p_Level->bLInventory;
  1073. p_Level->bTopLedge = p_Level->bLastTopLedge;
  1074. }
  1075. void _3d_Cancel_Animations(LEVELINFO * p_Level)
  1076. {
  1077. if (_3DAnimationStruct.bLastMenuItem) {
  1078. _3d_Stop_Animation(_3DAnimationStruct.iLastMenuItemID, 1);
  1079. _3DAnimationStruct.iLastMenuItemID = -1;
  1080. _3DAnimationStruct.bLastMenuItem = 0;
  1081. }
  1082. _3d_CleanAnimationList();
  1083. _3d_CleanDrawList();
  1084. }
  1085. int _3d_HitRect(int iAnimation)
  1086. {
  1087. _3D_ANIMATION *p_an = &_3DAnimationStruct._3DAnimation[iAnimation];
  1088. if (mi.x > p_an->_3dFrame[0].vfLocation[0] * scale_back_factor_x() &&
  1089. mi.x < p_an->_3dFrame[0].vfLocation[0] * scale_back_factor_x() + (_3dd.p_sysramtexture[p_an->_3dFrame[0].iTexture].tx * scale_back_factor_x() * p_an->_3dFrame[0].fScale) &&
  1090. mi.y > p_an->_3dFrame[0].vfLocation[1] * scale_back_factor_y() &&
  1091. mi.y < p_an->_3dFrame[0].vfLocation[1] * scale_back_factor_y() + (_3dd.p_sysramtexture[p_an->_3dFrame[0].iTexture].ty * scale_back_factor_y() * p_an->_3dFrame[0].fScale))
  1092. return 1;
  1093. else
  1094. return 0;
  1095. }
  1096. void _3d_Obsluha_Game_Menu(char *bCursor, int *Cursor_Time_Out,
  1097. LEVELINFO * p_Level, int demo)
  1098. {
  1099. int bIsIn = 0;
  1100. (*bCursor) = 1;
  1101. (*Cursor_Time_Out) = 0;
  1102. spracuj_spravy(0);
  1103. if (key[K_ESC]) {
  1104. key[K_ESC] = 0;
  1105. _3d_Cancel_Menu(p_Level);
  1106. return;
  1107. }
  1108. //mainmenu
  1109. if (_3d_HitRect(16)) {
  1110. bIsIn = 1;
  1111. if (_3d_Animete_Menu_Item(16, 1)) {
  1112. float pos[3] = { 0, 0, 0 };
  1113. int rnd = rand() % 3;
  1114. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1115. p_Level->bReturnToMenu = 1;
  1116. p_Level->iMessageBoxReturn = -1;
  1117. p_Level->bCancelMenu = 0;
  1118. }
  1119. _3DAnimationStruct.iLastIsIn = 1;
  1120. return;
  1121. }
  1122. //restart level
  1123. if (_3d_HitRect(17)) {
  1124. bIsIn = 1;
  1125. if (_3d_Animete_Menu_Item(17, 2)) {
  1126. float pos[3] = { 0, 0, 0 };
  1127. int rnd = rand() % 3;
  1128. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1129. p_Level->bRestart = 1;
  1130. p_Level->iMessageBoxReturn = -1;
  1131. p_Level->bCancelMenu = 0;
  1132. }
  1133. _3DAnimationStruct.iLastIsIn = 2;
  1134. return;
  1135. }
  1136. //settings
  1137. if (_3d_HitRect(18)) {
  1138. bIsIn = 1;
  1139. if (_3d_Animete_Menu_Item(18, 4)) {
  1140. int rnd = rand() % 3;
  1141. float pos[3] = { 0, 0, 0 };
  1142. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1143. RunMenuSettings2("Mmsettings3D.txt", NULL, p_Level, &am);
  1144. }
  1145. _3DAnimationStruct.iLastIsIn = 4;
  1146. return;
  1147. }
  1148. //record demo
  1149. if (_3d_HitRect(19) && !demo) {
  1150. bIsIn = 1;
  1151. if (_3d_Animete_Menu_Item(19, 5)) {
  1152. int rnd = rand() % 3;
  1153. float pos[3] = { 0, 0, 0 };
  1154. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1155. p_Level->bSaveDemo = 1;
  1156. _3d_Cancel_Menu(p_Level);
  1157. }
  1158. _3DAnimationStruct.iLastIsIn = 5;
  1159. return;
  1160. }
  1161. if (_3d_HitRect(20)) {
  1162. bIsIn = 1;
  1163. if (_3d_Animete_Menu_Item(20, 6)) {
  1164. float pos[3] = { 0, 0, 0 };
  1165. int rnd = rand() % 3;
  1166. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1167. _3d_Cancel_Menu(p_Level);
  1168. }
  1169. _3DAnimationStruct.iLastIsIn = 6;
  1170. return;
  1171. }
  1172. //loadgame
  1173. if (_3d_HitRect(21) && !demo) {
  1174. bIsIn = 1;
  1175. if (_3d_Animete_Menu_Item(21, 7)) {
  1176. WCHAR cText[128];
  1177. float pos[3] = { 0, 0, 0 };
  1178. int rnd = rand() % 3;
  1179. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1180. ZeroMemory(cText, 128);
  1181. RunMenuLoadGameLoad2("Mmload_game_load3d.txt", NULL, p_Level, &am, 1, cText);
  1182. if (wcslen(cText)) {
  1183. _3d_Cancel_Menu(p_Level);
  1184. p_Level->Level_Exit = 4;
  1185. p_Level->lLevel_Exitc = 0;
  1186. //TODO <----------------------- cText = jmeno levelu na load
  1187. ZeroMemory(p_Level->cLevelName, 64);
  1188. lsi_Save_Exist(cText, p_Level->cLevelName);
  1189. //WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, cText, wcslen(cText), p_Level->cLevelName, 63, NULL, NULL);
  1190. }
  1191. }
  1192. _3DAnimationStruct.iLastIsIn = 7;
  1193. return;
  1194. }
  1195. //savegame
  1196. if (_3d_HitRect(22) && !demo) {
  1197. bIsIn = 1;
  1198. if (_3d_Animete_Menu_Item(22, 8)) {
  1199. WCHAR cText[128];
  1200. float pos[3] = { 0, 0, 0 };
  1201. int rnd = rand() % 3;
  1202. ap_Play_Sound(0,1,0, pos, rnd + 23, NULL, &ad);
  1203. ZeroMemory(cText, 128);
  1204. RunMenuLoadGameLoad2("Mmload_game_loads3d.txt",
  1205. p_Level->p_ad, p_Level, &am, 0, cText);
  1206. if (wcslen(cText))
  1207. lsi_Save_Level(cText, p_Level);
  1208. }
  1209. _3DAnimationStruct.iLastIsIn = 8;
  1210. return;
  1211. }
  1212. if (!bIsIn && _3DAnimationStruct.bLastMenuItem) {
  1213. _3d_Stop_Animation(_3DAnimationStruct.iLastMenuItemID, 1);
  1214. _3d_RemoveIDFromDrawList(_3DAnimationStruct.iLastMenuItemID);
  1215. _3DAnimationStruct.iLastMenuItemID = -1;
  1216. _3DAnimationStruct.bLastMenuItem = 0;
  1217. }
  1218. }
  1219. void _3d_Start_Settings(void)
  1220. {
  1221. ddxLoadBitmap("settings.png", pBmpDir);
  1222. }
  1223. int _3d_BackPack2Hint(int idx)
  1224. {
  1225. switch (idx) {
  1226. case 0:
  1227. return 20;
  1228. case 3:
  1229. return 21;
  1230. case 5:
  1231. return 22;
  1232. case 4:
  1233. return 23;
  1234. case 7:
  1235. return 24;
  1236. case 8:
  1237. return 25;
  1238. }
  1239. kprintf(1, "_3d_BackPack2Hint vraci -1");
  1240. return -1;
  1241. }
  1242. int _3d_Mesh2Hint(LEVELINFO * p_Level, int mesh)
  1243. {
  1244. OBJECTDESC *pObj;
  1245. int i;
  1246. for (i = 0; i < p_Level->Size_of_Level; i++)
  1247. if (p_Level->Level[i])
  1248. if (p_Level->Level[i]->Index_Of_Game_Mesh == mesh) {
  1249. pObj = p_Level->Level[i]->p_Object;
  1250. if (pObj->Class == 2)
  1251. return 1;
  1252. if (pObj->Class == 19)
  1253. return 2;
  1254. if (pObj->Class == 1)
  1255. return 3;
  1256. if (pObj->Class == 4)
  1257. return 4;
  1258. if (pObj->Class == 5 && pObj->SubClass == 1)
  1259. return 5;
  1260. if (pObj->Class == 5 && !pObj->SubClass)
  1261. return 6;
  1262. if (pObj->Class == 5 && pObj->SubClass == 3)
  1263. return 7;
  1264. if (pObj->Class == 6 && !pObj->SubClass)
  1265. return 8;
  1266. if (pObj->Class == 6 && pObj->SubClass)
  1267. return 9;
  1268. if (pObj->Class == 7)
  1269. return 10;
  1270. if (pObj->Class == 9 && !pObj->SubClass)
  1271. return 11;
  1272. if (pObj->Class == 9 && pObj->SubClass)
  1273. return 12;
  1274. if (pObj->Class == 10)
  1275. return 13;
  1276. if (pObj->Class == 11 && !pObj->SubClass)
  1277. return 14;
  1278. if (pObj->Class == 11 && pObj->SubClass == 1)
  1279. return 15;
  1280. if (pObj->Class == 11 && pObj->SubClass == 3)
  1281. return 16;
  1282. if (pObj->Class == 12)
  1283. return 17;
  1284. if (pObj->Class == 15)
  1285. return 18;
  1286. if (pObj->Class == 16)
  1287. return 19;
  1288. if (pObj->Class == 13 && !pObj->SubClass)
  1289. return 20;
  1290. if (pObj->Class == 13 && pObj->SubClass == 3)
  1291. return 21;
  1292. if (pObj->Class == 13 && pObj->SubClass == 5)
  1293. return 22;
  1294. if (pObj->Class == 13 && pObj->SubClass == 4)
  1295. return 23;
  1296. if (pObj->Class == 13 && pObj->SubClass == 7)
  1297. return 24;
  1298. if (pObj->Class == 13 && pObj->SubClass == 8)
  1299. return 25;
  1300. kprintf(1, "Nenalezena Trida: Class == %d, Sub == %d", pObj->Class,
  1301. pObj->SubClass);
  1302. return -1;
  1303. }
  1304. kprintf(1, "Nenalezen Prvek : mesh == %d", mesh);
  1305. return -1;
  1306. }
  1307. void _3d_Draw_Hint(void)
  1308. {
  1309. float pos[4];
  1310. pos[0] = sHint.x - (6 * scale_back_factor_x());
  1311. pos[1] = sHint.y - (6 * scale_back_factor_y());
  1312. pos[2] = (sHint.x - (6 * scale_back_factor_x())) + (((pHintTexture[sHint.iHint].tx + 12) * HINT_SCALE) * scale_back_factor_x());
  1313. pos[3] = (sHint.y - (6 * scale_back_factor_y())) + (((pHintTexture[sHint.iHint].ty + 12) * HINT_SCALE) * scale_back_factor_y());
  1314. glBindTexture(GL_TEXTURE_2D, pHintTexture[0].text.text);
  1315. glBegin(GL_TRIANGLE_STRIP);
  1316. glTexCoord2d(0, 1);
  1317. glVertex2d(pos[0], pos[1]);
  1318. glTexCoord2d(0, 0);
  1319. glVertex2d(pos[0], pos[3]);
  1320. glTexCoord2d(1, 1);
  1321. glVertex2d(pos[2], pos[1]);
  1322. glTexCoord2d(1, 0);
  1323. glVertex2d(pos[2], pos[3]);
  1324. glEnd();
  1325. pos[0] = sHint.x;
  1326. pos[1] = sHint.y;
  1327. pos[2] = sHint.x + (pHintTexture[sHint.iHint].x * HINT_SCALE * scale_back_factor_x());
  1328. pos[3] = sHint.y + (pHintTexture[sHint.iHint].y * HINT_SCALE * scale_back_factor_y());
  1329. glBindTexture(GL_TEXTURE_2D, pHintTexture[sHint.iHint].text.text);
  1330. glBegin(GL_TRIANGLE_STRIP);
  1331. glTexCoord2d(0, 1);
  1332. glVertex2d(pos[0], pos[1]);
  1333. glTexCoord2d(0, 0);
  1334. glVertex2d(pos[0], pos[3]);
  1335. glTexCoord2d(1, 1);
  1336. glVertex2d(pos[2], pos[1]);
  1337. glTexCoord2d(1, 0);
  1338. glVertex2d(pos[2], pos[3]);
  1339. glEnd();
  1340. }
  1341. void _3d_Display_Hint(LEVELINFO * p_Level)
  1342. {
  1343. int iHint;
  1344. int bmesh = kom_get_mesh_mys(12);
  1345. if (bmesh == -1) {
  1346. kprintf(1, "Hint = kom_get_mesh_mys() == -1");
  1347. return;
  1348. }
  1349. iHint = _3d_Mesh2Hint(p_Level, bmesh);
  1350. if (iHint == -1) {
  1351. kprintf(1, "Hint = _3d_Mesh2Hint() == -1");
  1352. return;
  1353. }
  1354. sHint.iHint = iHint;
  1355. sHint.x = (float) mi.x + _3dCur.idx + _3dCur.iaddx;
  1356. sHint.y = (float) mi.y + _3dCur.idy + _3dCur.iaddy;
  1357. if (sHint.y + (pHintTexture[sHint.iHint].ty * HINT_SCALE * scale_back_factor_y()) > SCREEN_YRES - 25)
  1358. sHint.y = (float)(SCREEN_YRES - (pHintTexture[sHint.iHint].ty * HINT_SCALE * scale_back_factor_y()) - 25);
  1359. if (sHint.x + (pHintTexture[sHint.iHint].tx * HINT_SCALE * scale_back_factor_x()) > SCREEN_XRES - 25)
  1360. sHint.x = (float) (SCREEN_XRES - (pHintTexture[sHint.iHint].tx * HINT_SCALE * scale_back_factor_x()) - 25);
  1361. sHint.bHint = 1;
  1362. sHint.dwTCounter = 0;
  1363. }
  1364. void _3d_Display_Hint_Inventory(LEVELINFO * p_Level, ITEMDESC * pItem,
  1365. int idx, int x, int y)
  1366. {
  1367. int obj;
  1368. int iHint;
  1369. obj = gl_Inventory_Item_To_Object(p_Level, idx, 0);
  1370. if (obj >= p_Level->Count_Of_Objects) {
  1371. kprintf(1, "nepodarilo se prelozit index inventoraze na objekt!");
  1372. return;
  1373. }
  1374. iHint = _3d_BackPack2Hint(p_Level->Object[obj].SubClass);
  1375. if (iHint == -1)
  1376. return;
  1377. sHint.iHint = iHint;
  1378. sHint.x = x * scale_back_factor_x();
  1379. sHint.y = (y - 32) * scale_back_factor_y();
  1380. if (sHint.x + (pHintTexture[sHint.iHint].tx * HINT_SCALE * scale_back_factor_x()) > SCREEN_XRES - 25)
  1381. sHint.x =(float) (SCREEN_XRES - (pHintTexture[sHint.iHint].tx * HINT_SCALE * scale_back_factor_x()) - 25);
  1382. sHint.bHint = 1;
  1383. sHint.dwTCounter = 0;
  1384. }
  1385. void _3d_Nahraj_Kuk(void)
  1386. {
  1387. txt_trida(TEXT_MENU);
  1388. kom_set_default_text_config(0, 0, 1, 0, 0, 1);
  1389. txt_nahraj_texturu_z_func(p3DMDir, "brouk1.png", &sKuk.text, 0, 1, NULL, bmp_nahraj);
  1390. kom_ret_default_text_config();
  1391. }
  1392. void _3d_Release_Kuk(void)
  1393. {
  1394. txt_zrus_texturu(&sKuk.text);
  1395. }
  1396. void _3d_Draw_Indikace(LEVELINFO * p_Level)
  1397. {
  1398. float pos[4];
  1399. if (p_Level->bSaveDemo) {
  1400. pos[0] = 960 * scale_back_factor_x();
  1401. pos[1] = 704 * scale_back_factor_y();
  1402. pos[2] = 1024 * scale_back_factor_x();
  1403. pos[3] = 768 * scale_back_factor_y();
  1404. glBindTexture(GL_TEXTURE_2D, sIndikace[0].text);
  1405. glBegin(GL_TRIANGLE_STRIP);
  1406. glTexCoord2d(0, 1);
  1407. glVertex2d(pos[0], pos[1]);
  1408. glTexCoord2d(0, 0);
  1409. glVertex2d(pos[0], pos[3]);
  1410. glTexCoord2d(1, 1);
  1411. glVertex2d(pos[2], pos[1]);
  1412. glTexCoord2d(1, 0);
  1413. glVertex2d(pos[2], pos[3]);
  1414. glEnd();
  1415. }
  1416. if (p_Level->Item_Lock) {
  1417. pos[0] = 896 * scale_back_factor_x();
  1418. pos[1] = 704 * scale_back_factor_y();
  1419. pos[2] = 960 * scale_back_factor_x();
  1420. pos[3] = 768 * scale_back_factor_y();
  1421. glBindTexture(GL_TEXTURE_2D, sIndikace[2].text);
  1422. glBegin(GL_TRIANGLE_STRIP);
  1423. glTexCoord2d(0, 1);
  1424. glVertex2d(pos[0], pos[1]);
  1425. glTexCoord2d(0, 0);
  1426. glVertex2d(pos[0], pos[3]);
  1427. glTexCoord2d(1, 1);
  1428. glVertex2d(pos[2], pos[1]);
  1429. glTexCoord2d(1, 0);
  1430. glVertex2d(pos[2], pos[3]);
  1431. glEnd();
  1432. }
  1433. if (p_Level->Actual_Item == -1)
  1434. return;
  1435. if (p_Level->Level[p_Level->Actual_Item]->p_Back_Pack->Strength > 2) {
  1436. pos[0] = 832 * scale_back_factor_x();
  1437. pos[1] = 704 * scale_back_factor_y();
  1438. pos[2] = 896 * scale_back_factor_x();
  1439. pos[3] = 768 * scale_back_factor_y();
  1440. glBindTexture(GL_TEXTURE_2D, sIndikace[1].text);
  1441. glBegin(GL_TRIANGLE_STRIP);
  1442. glTexCoord2d(0, 1);
  1443. glVertex2d(pos[0], pos[1]);
  1444. glTexCoord2d(0, 0);
  1445. glVertex2d(pos[0], pos[3]);
  1446. glTexCoord2d(1, 1);
  1447. glVertex2d(pos[2], pos[1]);
  1448. glTexCoord2d(1, 0);
  1449. glVertex2d(pos[2], pos[3]);
  1450. glEnd();
  1451. }
  1452. }
  1453. int _3d_Draw_MessageBox(int iMessage)
  1454. {
  1455. int ret = 0;
  1456. float pos[4];
  1457. float x = (1024 - (pMessageTexture[iMessage].tx + 12)) / 2.0f;
  1458. float y = (768 - ((pMessageTexture[iMessage].ty * 3) + 12)) / 2.0f;
  1459. float dx;
  1460. float dy;
  1461. float f;
  1462. pos[0] = (x - 6) * scale_back_factor_x();
  1463. pos[1] = (y - 6) * scale_back_factor_y();
  1464. pos[2] = (x - 6) * scale_back_factor_x() + (((pMessageTexture[iMessage].tx + 12) * HINT_SCALE) * scale_back_factor_x());
  1465. pos[3] = (y - 6) * scale_back_factor_y() + ((((pMessageTexture[iMessage].ty * 3) + 12) * HINT_SCALE) * scale_back_factor_y());
  1466. dx = (pMessageTexture[iMessage].tx + 12) / 2.0f;
  1467. dy = pMessageTexture[iMessage].ty * 2.0f;
  1468. glBindTexture(GL_TEXTURE_2D, pHintTexture[0].text.text);
  1469. glBegin(GL_TRIANGLE_STRIP);
  1470. glTexCoord2d(0, 1);
  1471. glVertex2d(pos[0], pos[1]);
  1472. glTexCoord2d(0, 0);
  1473. glVertex2d(pos[0], pos[3]);
  1474. glTexCoord2d(1, 1);
  1475. glVertex2d(pos[2], pos[1]);
  1476. glTexCoord2d(1, 0);
  1477. glVertex2d(pos[2], pos[3]);
  1478. glEnd();
  1479. pos[0] = x * scale_back_factor_x();
  1480. pos[1] = y * scale_back_factor_y();
  1481. pos[2] = (x + (pMessageTexture[iMessage].x * HINT_SCALE)) * scale_back_factor_x();
  1482. pos[3] = (y + (pMessageTexture[iMessage].y * HINT_SCALE)) * scale_back_factor_y();
  1483. glBindTexture(GL_TEXTURE_2D, pMessageTexture[iMessage].text.text);
  1484. glBegin(GL_TRIANGLE_STRIP);
  1485. glTexCoord2d(0, 1);
  1486. glVertex2d(pos[0], pos[1]);
  1487. glTexCoord2d(0, 0);
  1488. glVertex2d(pos[0], pos[3]);
  1489. glTexCoord2d(1, 1);
  1490. glVertex2d(pos[2], pos[1]);
  1491. glTexCoord2d(1, 0);
  1492. glVertex2d(pos[2], pos[3]);
  1493. glEnd();
  1494. f = x + dx - pMessageTexture[0].tx - 10;
  1495. pos[0] = f * scale_back_factor_x();
  1496. pos[1] = (y + dy) * scale_back_factor_y();
  1497. pos[2] = (f + (pMessageTexture[0].x * HINT_SCALE)) * scale_back_factor_x();
  1498. pos[3] = (y + dy + (pMessageTexture[0].y * HINT_SCALE)) * scale_back_factor_y();
  1499. ret = -1;
  1500. if (mi.x >= pos[0]
  1501. && mi.x <= pos[0] + (pMessageTexture[1].tx * scale_back_factor_x())
  1502. && mi.y >= pos[1]
  1503. && mi.y <= pos[1] + (pMessageTexture[1].ty * scale_back_factor_y())) {
  1504. glBindTexture(GL_TEXTURE_2D, pMessageTexture[1].text.text);
  1505. ret = 1;
  1506. }
  1507. else
  1508. glBindTexture(GL_TEXTURE_2D, pMessageTexture[0].text.text);
  1509. glBegin(GL_TRIANGLE_STRIP);
  1510. glTexCoord2d(0, 1);
  1511. glVertex2d(pos[0], pos[1]);
  1512. glTexCoord2d(0, 0);
  1513. glVertex2d(pos[0], pos[3]);
  1514. glTexCoord2d(1, 1);
  1515. glVertex2d(pos[2], pos[1]);
  1516. glTexCoord2d(1, 0);
  1517. glVertex2d(pos[2], pos[3]);
  1518. glEnd();
  1519. f = x + dx + 10;
  1520. pos[0] = f * scale_back_factor_x();
  1521. pos[1] = (y + dy) * scale_back_factor_y();
  1522. pos[2] = (f + (pMessageTexture[2].x * HINT_SCALE)) * scale_back_factor_x();
  1523. pos[3] = (y + dy + (pMessageTexture[2].y * HINT_SCALE)) * scale_back_factor_y();
  1524. if (mi.x >= pos[0]
  1525. && mi.x <= pos[0] + (pMessageTexture[1].tx * scale_back_factor_x())
  1526. && mi.y >= pos[1]
  1527. && mi.y <= pos[1] + (pMessageTexture[1].ty * scale_back_factor_y()))
  1528. {
  1529. glBindTexture(GL_TEXTURE_2D, pMessageTexture[3].text.text);
  1530. ret = 0;
  1531. }
  1532. else
  1533. glBindTexture(GL_TEXTURE_2D, pMessageTexture[2].text.text);
  1534. glBegin(GL_TRIANGLE_STRIP);
  1535. glTexCoord2d(0, 1);
  1536. glVertex2d(pos[0], pos[1]);
  1537. glTexCoord2d(0, 0);
  1538. glVertex2d(pos[0], pos[3]);
  1539. glTexCoord2d(1, 1);
  1540. glVertex2d(pos[2], pos[1]);
  1541. glTexCoord2d(1, 0);
  1542. glVertex2d(pos[2], pos[3]);
  1543. glEnd();
  1544. if (key[K_ESC]) {
  1545. key[K_ESC] = 0;
  1546. mi.t1 = 1;
  1547. ret = 0;
  1548. }
  1549. if (key[K_ENTER]) {
  1550. key[K_ENTER] = 0;
  1551. mi.t1 = 1;
  1552. ret = 1;
  1553. }
  1554. return ret;
  1555. }