Interface.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #define INITGUID
  2. #include "Hunt.h"
  3. #include "stdio.h"
  4. typedef struct _TMenuSet {
  5. int x0, y0;
  6. int Count;
  7. char Item[32][32];
  8. } TMenuSet;
  9. TMenuSet Options[3];
  10. char HMLtxt[3][12];
  11. char CKtxt[2][16];
  12. char Restxt[8][24];
  13. char Textxt[3][12];
  14. char Ontxt[2][12];
  15. char Systxt[2][12];
  16. int CurPlayer = -1;
  17. int MaxDino, AreaMax, LoadCount;
  18. #define REGLISTX 320
  19. #define REGLISTY 370
  20. BOOL NEWPLAYER = FALSE;
  21. int MapVKKey(int k)
  22. {
  23. if (k==VK_LBUTTON) return 124;
  24. if (k==VK_RBUTTON) return 125;
  25. return MapVirtualKey(k , 0);
  26. }
  27. POINT p;
  28. int OptMode = 0;
  29. int OptLine = 0;
  30. void wait_mouse_release()
  31. {
  32. while (GetAsyncKeyState(VK_RBUTTON) & 0x80000000);
  33. while (GetAsyncKeyState(VK_LBUTTON) & 0x80000000);
  34. }
  35. int GetTextW(HDC hdc, LPSTR s)
  36. {
  37. SIZE sz;
  38. GetTextExtentPoint(hdc, s, strlen(s), &sz);
  39. return sz.cx;
  40. }
  41. void PrintText(LPSTR s, int x, int y, int rgb)
  42. {
  43. HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcCMain,hbmpVideoBuf);
  44. SetBkMode(hdcCMain, TRANSPARENT);
  45. SetTextColor(hdcCMain, 0x00000000);
  46. TextOut(hdcCMain, x+1, y+1, s, strlen(s));
  47. SetTextColor(hdcCMain, rgb);
  48. TextOut(hdcCMain, x, y, s, strlen(s));
  49. SelectObject(hdcCMain,hbmpOld);
  50. }
  51. void DoHalt(LPSTR Mess)
  52. {
  53. AudioStop();
  54. Audio_Shutdown();
  55. ShutDown3DHardware();
  56. EnableWindow(hwndMain, FALSE);
  57. if (strlen(Mess)) {
  58. PrintLog("ABNORMAL_HALT: ");
  59. PrintLog(Mess);
  60. PrintLog("\n");
  61. MessageBox(NULL, Mess, "Carnivores Termination", IDOK | MB_SYSTEMMODAL | MB_ICONEXCLAMATION);
  62. }
  63. CloseLog();
  64. TerminateProcess(GetCurrentProcess(), 0);
  65. }
  66. void WaitRetrace()
  67. {
  68. BOOL bv = FALSE;
  69. if (DirectActive)
  70. while (!bv) lpDD->GetVerticalBlankStatus(&bv);
  71. }
  72. void Wait(int time)
  73. {
  74. unsigned int t = timeGetTime() + time;
  75. while (t>timeGetTime()) ;
  76. }
  77. //#define loadww 210
  78. //#define loadwh 106
  79. char loadtxt[128];
  80. TPicture LoadWall;
  81. void UpdateLoadingWindow()
  82. {
  83. HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcCMain, hbmpVideoBuf);
  84. HFONT hfntOld = (HFONT)SelectObject(hdcCMain, fnt_Small);
  85. for (int y=0; y<LoadWall.H/2; y++)
  86. memcpy( (WORD*)lpVideoBuf + y*1024,
  87. LoadWall.lpImage + y*LoadWall.W,
  88. LoadWall.W*2);
  89. if (LoadCount)
  90. for (int y=0; y<LoadWall.H/2; y++)
  91. memcpy( (WORD*)lpVideoBuf + y*1024,
  92. LoadWall.lpImage + (y+LoadWall.H/2)*LoadWall.W,
  93. (LoadWall.W*LoadCount/8)*2);
  94. //FillMemory(lpVideoBuf, 1024*loadwh*2, 1);
  95. /*
  96. SetBkMode(hdcCMain, TRANSPARENT);
  97. SetTextColor(hdcCMain, 0x000000);
  98. TextOut(hdcCMain, 19, LoadWall.H/2-22, loadtxt, strlen(loadtxt) );
  99. SetTextColor(hdcCMain, 0xB0B070);
  100. TextOut(hdcCMain, 18, LoadWall.H/2-23, loadtxt, strlen(loadtxt) );
  101. */
  102. BitBlt(hdcMain,0,0,LoadWall.W,LoadWall.H/2, hdcCMain,0,0, SRCCOPY);
  103. SelectObject(hdcCMain,hfntOld);
  104. SelectObject(hdcCMain,hbmpOld);
  105. }
  106. void StartLoading()
  107. {
  108. LoadPictureTGA(LoadWall, "HUNTDAT\\MENU\\loading.tga");
  109. SetWindowPos(hwndMain, HWND_TOP, (GetSystemMetrics(SM_CXSCREEN) - LoadWall.W)/2,
  110. (GetSystemMetrics(SM_CYSCREEN) - LoadWall.H/2)/2, LoadWall.W, LoadWall.H/2,
  111. SWP_SHOWWINDOW);
  112. }
  113. void EndLoading()
  114. {
  115. FillMemory(lpVideoBuf, 1024*768*2, 0);
  116. _HeapFree(Heap, 0, (void*)LoadWall.lpImage);
  117. }
  118. void PrintLoad(char *t)
  119. {
  120. strcpy(loadtxt, t);
  121. LoadCount++;
  122. UpdateLoadingWindow();
  123. }
  124. void SetVideoMode(int W, int H)
  125. {
  126. WinW = W;
  127. WinH = H;
  128. WinEX = WinW - 1;
  129. WinEY = WinH - 1;
  130. VideoCX = WinW / 2;
  131. VideoCY = WinH / 2;
  132. CameraW = (float)VideoCX*1.25f;
  133. CameraH = CameraW * (WinH * 1.3333f / WinW);
  134. SetWindowPos(hwndMain, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
  135. SetCursorPos(VideoCX, VideoCY);
  136. LoDetailSky =(W>400);
  137. SetCursor(hcArrow);
  138. while (ShowCursor(FALSE)>=0) ;
  139. }