2290
|
1 #define _CRT_SECURE_NO_WARNINGS
|
|
2
|
|
3 #include "MMT.h"
|
|
4 #include "GUIWindow.h"
|
|
5 #include "mm7_unsorted_subs.h"
|
|
6 #include "mm7_data.h"
|
|
7 #include "AudioPlayer.h"
|
|
8 #include "Mouse.h"
|
|
9 #include "LOD.h"
|
|
10 #include "Render.h"
|
|
11 #include "VideoPlayer.h"
|
|
12 #include "CShow.h"
|
|
13 #include "GUIFont.h"
|
2295
|
14 #include "lib/libpng/png.h"
|
2290
|
15
|
|
16 void ShowLogoVideo()
|
|
17 {
|
|
18 RGBTexture tex; // [sp+Ch] [bp-30h]@1
|
|
19 //unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8
|
|
20 //unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8
|
|
21
|
|
22 pVideoPlayer->bStopBeforeSchedule = false;
|
|
23 pVideoPlayer->pResetflag = 0;
|
|
24 bGameoverLoop = 1;
|
|
25 if (!bNoVideo)
|
|
26 {
|
|
27 pRenderer->PresentBlackScreen();
|
|
28 PlayFullscreenMovie(MOVIE_3DOLogo, true);
|
|
29 if ( !pVideoPlayer->bStopBeforeSchedule )
|
|
30 {
|
|
31 PlayFullscreenMovie(MOVIE_NWCLogo, true);
|
|
32 if ( !pVideoPlayer->bStopBeforeSchedule )
|
|
33 PlayFullscreenMovie(MOVIE_JVC, true);
|
|
34 }
|
|
35 }
|
|
36 char pContainerName[64];
|
|
37
|
|
38 sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
|
|
39 tex.LoadPCXFile(pContainerName, 0);
|
|
40
|
|
41 pRenderer->BeginScene();
|
|
42 pRenderer->DrawTextureRGB(0, 0, &tex);
|
|
43 free(tex.pPixels);
|
|
44 tex.pPixels = 0;
|
|
45 MainMenuUI_LoadFontsAndSomeStuff();
|
|
46 DrawMMTCopyrightWindow();
|
|
47
|
|
48 pRenderer->EndScene();
|
|
49 pRenderer->Present();
|
|
50
|
|
51 #ifndef _DEBUG
|
|
52 Sleep(1500); // let the copyright window stay for a while
|
|
53 #endif
|
|
54
|
|
55 /*if (!bNoSound && pAudioPlayer->hAILRedbook )
|
|
56 {
|
|
57 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
|
|
58 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
|
59 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS);
|
|
60 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
|
|
61 } */
|
|
62 bGameoverLoop = 0;
|
|
63 }
|
|
64
|
2295
|
65 void abort_(const char * s, ...)
|
|
66 {
|
|
67 va_list args;
|
|
68 va_start(args, s);
|
|
69 vfprintf(stderr, s, args);
|
|
70 fprintf(stderr, "\n");
|
|
71 va_end(args);
|
|
72 abort();
|
|
73 }
|
|
74
|
2308
|
75 Texture *LoadPNG(const char *name)
|
2295
|
76 {
|
|
77 int x, y;
|
|
78 int width, height;
|
|
79 png_byte color_type;
|
|
80 png_byte bit_depth;
|
|
81 png_structp png_ptr;
|
|
82 png_infop info_ptr;
|
|
83 int number_of_passes;
|
|
84 png_bytep * row_pointers;
|
|
85 uint i = 0;
|
|
86 Texture *tex;
|
|
87
|
2308
|
88 char header[8]; // 8 is the maximum size that can be checked
|
2295
|
89
|
2308
|
90 /* open file and test for it being a png */
|
|
91 FILE *fp = fopen(name, "rb");
|
|
92 if (!fp)
|
|
93 abort_("[read_png_file] File %s could not be opened for reading", name);
|
|
94 fread(header, 1, 8, fp);
|
|
95 if (png_sig_cmp((png_bytep)header, 0, 8))
|
|
96 abort_("[read_png_file] File %s is not recognized as a PNG file", name);
|
|
97 /* initialize stuff */
|
|
98 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
2295
|
99
|
2308
|
100 if (!png_ptr)
|
|
101 abort_("[read_png_file] png_create_read_struct failed");
|
|
102 info_ptr = png_create_info_struct(png_ptr);
|
|
103 if (!info_ptr)
|
|
104 abort_("[read_png_file] png_create_info_struct failed");
|
2295
|
105
|
2308
|
106 if (setjmp(png_jmpbuf(png_ptr)))
|
|
107 abort_("[read_png_file] Error during init_io");
|
2295
|
108
|
2308
|
109 png_init_io(png_ptr, fp);
|
|
110 png_set_sig_bytes(png_ptr, 8);
|
2295
|
111
|
2308
|
112 png_read_info(png_ptr, info_ptr);
|
2295
|
113
|
2308
|
114 width = png_get_image_width(png_ptr, info_ptr);
|
|
115 height = png_get_image_height(png_ptr, info_ptr);
|
|
116 color_type = png_get_color_type(png_ptr, info_ptr);
|
|
117 bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
|
118
|
|
119 number_of_passes = png_set_interlace_handling(png_ptr);
|
|
120 png_read_update_info(png_ptr, info_ptr);
|
2295
|
121
|
2308
|
122 /* read file */
|
|
123 if (setjmp(png_jmpbuf(png_ptr)))
|
|
124 abort_("[read_png_file] Error during read_image");
|
|
125 row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
|
|
126 for (y=0; y<height; y++)
|
|
127 row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
|
2295
|
128
|
2308
|
129 png_read_image(png_ptr, row_pointers);
|
2295
|
130
|
2308
|
131 fclose(fp);
|
2295
|
132
|
2308
|
133 tex = new Texture;
|
|
134 tex->uTextureHeight = height;
|
|
135 tex->uTextureWidth = width;
|
|
136 tex->uSizeOfMaxLevelOfDetail = png_get_rowbytes(png_ptr, info_ptr);
|
|
137 tex->uTextureSize = png_get_rowbytes(png_ptr, info_ptr);
|
|
138 tex->uDecompressedSize = png_get_rowbytes(png_ptr, info_ptr);
|
|
139 tex->pPalette16 = (unsigned __int16 *) malloc(sizeof(unsigned __int16) * width * height);
|
|
140 tex->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *) malloc(sizeof(unsigned __int8) * width * height);
|
2295
|
141
|
2308
|
142 for (y=0; y<height; y++)
|
|
143 {
|
|
144 png_byte* row = row_pointers[y];
|
|
145 for (x=0; x<width; x++)
|
|
146 {
|
|
147 png_byte* ptr = &(row[x*4]);
|
|
148 //Log::Warning(L"Pixel at position [ %d - %d ] has RGBA values: %d - %d - %d - %d\n",
|
|
149 // x, y, ptr[0], ptr[1], ptr[2], ptr[3]);
|
|
150 png_byte tmp = ptr[2];
|
|
151 ptr[2] = ptr[0];
|
|
152 ptr[0] = ptr[3];
|
|
153 ptr[3] = 255 - tmp;
|
|
154 tex->pPalette16[i] = Color16(ptr[0], ptr[1], ptr[2]);
|
|
155 tex->pLevelOfDetail0_prolly_alpha_mask[i] = ptr[3];
|
|
156 i++;
|
|
157 }
|
|
158 }
|
|
159 //Ritor1: temporarily stopped, needed change RGBTexture structure/Пока приостановлено в связи с необходимостью внести изменения в структуру(создать)RGBTexture
|
|
160 /*for (int i = 0; i < width * height; ++i)
|
|
161 tex->pPalette16[i] = 0x7FF;
|
|
162 memset(tex->pLevelOfDetail0_prolly_alpha_mask, 1, sizeof(unsigned __int8) * width * height);*/
|
|
163 return tex;
|
2295
|
164 }
|
|
165
|
2290
|
166 void MMT_MainMenu_Loop()
|
|
167 {
|
|
168 GUIButton *pButton; // eax@27
|
|
169 unsigned int pControlParam; // ecx@35
|
|
170 int v10; // ecx@36
|
|
171 int v11; // ecx@37
|
|
172 unsigned int pX;
|
|
173 unsigned int pY; // [sp-18h] [bp-54h]@39
|
|
174 Texture *pTexture; // [sp-14h] [bp-50h]@39
|
|
175 GUIButton *pButton2; // [sp+0h] [bp-3Ch]@27
|
2295
|
176 char pContainerName[64];
|
|
177
|
|
178
|
2290
|
179
|
|
180 pCurrentScreen = SCREEN_GAME;
|
|
181
|
|
182 pGUIWindow2 = 0;
|
|
183 pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал
|
|
184 pMouse->RemoveHoldingItem();//избавить курсор от вещи
|
|
185
|
|
186 pIcons_LOD->_inlined_sub2();
|
|
187
|
|
188 pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
|
2308
|
189 //Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
|
2295
|
190
|
|
191 sprintf(pContainerName, "data\\New_Icons/%s", "mm6_button_oval.png");
|
2308
|
192 Texture* MMT_MM6 = LoadPNG(pContainerName);
|
2295
|
193
|
|
194
|
2290
|
195 Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
|
|
196 Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
|
|
197 Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
|
|
198 Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
|
|
199
|
2308
|
200 pMMT_MainMenu_BtnMM6 = pWindow_MMT_MainMenu->CreateButton(0, 0, MMT_MM6->uTextureWidth, MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6, 0, 0, "", MMT_MM6, 0);
|
2290
|
201 pMMT_MainMenu_BtnMM7 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() / 4, MMT_MM7->uTextureWidth, MMT_MM7->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM7, 1, 0, "", MMT_MM7, 0);
|
|
202 pMMT_MainMenu_BtnMM8 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_MM8->uTextureWidth, MMT_MM8->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM8, 2, 0, "", MMT_MM8, 0);
|
|
203 pMMT_MainMenu_BtnContinue = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_Continue->uTextureWidth, MMT_Continue->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_Continue, 3, 0, "", MMT_Continue, 0);
|
|
204 pMMT_MainMenu_BtnExit = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - 130, window->GetHeight() - 35, MMT_Exit->uTextureWidth, MMT_Exit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 4, 0, "", MMT_Exit, 0);
|
|
205
|
|
206 pTexture_PCX.Release();
|
|
207
|
|
208 sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
|
|
209 pTexture_PCX.LoadPCXFile(pContainerName, 0);
|
|
210 SetCurrentMenuID(MENU_MMT_MAIN_MENU);
|
|
211 SetForegroundWindow(window->GetApiHandle());
|
|
212 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
|
|
213 while (GetCurrentMenuID() == MENU_MMT_MAIN_MENU )
|
|
214 {
|
|
215 POINT cursor;
|
|
216 pMouse->GetCursorPos(&cursor);
|
|
217
|
|
218 for (MSG msg; PeekMessageW(&msg, 0, 0, 0, PM_REMOVE);)
|
|
219 {
|
|
220 if (msg.message == WM_QUIT)
|
|
221 Game_DeinitializeAndTerminate(0);
|
|
222 TranslateMessage(&msg);
|
|
223 DispatchMessageW(&msg);
|
|
224 }
|
|
225
|
|
226 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
|
|
227 {
|
|
228 WaitMessage();
|
|
229 continue;
|
|
230 }
|
|
231
|
|
232 pRenderer->BeginScene();
|
|
233 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
|
|
234
|
|
235 MMT_MenuMessageProc();
|
|
236 GUI_UpdateWindows();
|
|
237
|
|
238 if ( !pModalWindow )// ???
|
|
239 {
|
|
240 pButton = pWindow_MMT_MainMenu->pControlsHead;
|
|
241 for ( pButton = pWindow_MMT_MainMenu->pControlsHead; pButton; pButton = pButton->pNext )
|
|
242 {
|
|
243 if ( cursor.x >= (signed int)pButton->uX && cursor.x <= (signed int)pButton->uZ
|
|
244 && cursor.y >= (signed int)pButton->uY && cursor.y <= (signed int)pButton->uW )
|
|
245 {
|
|
246 pControlParam = pButton->msg_param;
|
|
247 switch (pControlParam) // подсветка кнопок
|
|
248 {
|
|
249 case 0:
|
|
250 pTexture = MMT_MM6;
|
2308
|
251 pX = 0;
|
|
252 pY = 0;
|
2290
|
253 break;
|
|
254 case 1:
|
|
255 pTexture = MMT_MM7;
|
|
256 pX = window->GetWidth() - (window->GetWidth() / 4);
|
|
257 pY = window->GetHeight() / 4;
|
|
258 break;
|
|
259 case 2:
|
|
260 pTexture = MMT_MM8;
|
|
261 pX = window->GetWidth() - (window->GetWidth() / 4);
|
|
262 pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
|
|
263 break;
|
|
264 case 3:
|
|
265 pTexture = MMT_Continue;
|
|
266 pX = (window->GetWidth() / 4) - 100;
|
|
267 pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
|
|
268 break;
|
|
269 case 4:
|
|
270 pTexture = MMT_Exit;
|
|
271 pX = window->GetWidth() - 130;
|
|
272 pY = window->GetHeight() - 35;
|
|
273 break;
|
|
274 }
|
|
275 pRenderer->DrawTextureIndexed(pX, pY, pTexture); //подсветка кнопок
|
|
276 }
|
|
277 }
|
|
278 }
|
|
279 //}
|
|
280 pRenderer->EndScene();
|
|
281 pRenderer->Present();
|
|
282 }
|
|
283 MMT_MenuMessageProc();
|
|
284 pRenderer->BeginScene();
|
|
285 GUI_UpdateWindows();
|
|
286 pRenderer->EndScene();
|
|
287 pRenderer->Present();
|
|
288 pTexture_PCX.Release();
|
|
289 if ( pGUIWindow2 )
|
|
290 {
|
|
291 pGUIWindow2->Release();
|
|
292 pGUIWindow2 = 0;
|
|
293 }
|
|
294 pWindow_MMT_MainMenu->Release();
|
|
295 pIcons_LOD->RemoveTexturesPackFromTextureList();
|
|
296 }
|
|
297
|
|
298 void MMT_MenuMessageProc()
|
|
299 {
|
|
300 int pParam;
|
|
301 int pParam2;
|
|
302 UIMessageType pUIMessageType;
|
|
303
|
|
304 if ( pMessageQueue_50CBD0->uNumMessages )
|
|
305 {
|
|
306 do
|
|
307 {
|
|
308
|
|
309 pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &pParam2);
|
|
310
|
|
311 switch (pUIMessageType)
|
|
312 {
|
|
313 case UIMSG_MMT_MainMenu_MM7: //кнопка игры ММ7
|
|
314 //GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0);
|
|
315 ShowMM7IntroVideo_and_LoadingScreen();
|
|
316 SetCurrentMenuID(MENU_MAIN);
|
|
317 break;
|
|
318
|
|
319 default:
|
|
320 break;
|
|
321 }
|
|
322 }
|
|
323 while ( pMessageQueue_50CBD0->uNumMessages );
|
|
324 }
|
|
325 }
|
|
326 void DrawMMTCopyrightWindow()
|
|
327 {
|
|
328 GUIWindow Dst; // [sp+8h] [bp-54h]@1
|
|
329
|
|
330 memset(&Dst, 0, 0x54u);
|
|
331 Dst.uFrameWidth = 624;
|
|
332 Dst.uFrameHeight = 256;
|
|
333 Dst.uFrameX = 8;
|
|
334 Dst.uFrameY = 30;
|
|
335 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight("Text Verification: Here we can write an explanation of the project", &Dst, 24, 0)
|
|
336 + 2 * LOBYTE(pFontSmallnum->uFontHeight)
|
|
337 + 24;
|
|
338 Dst.uFrameY = 470 - Dst.uFrameHeight;
|
|
339 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
|
|
340 Dst.uFrameW = 469;
|
|
341 //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
|
|
342 Dst.DrawMessageBox(0);
|
|
343
|
|
344 Dst.uFrameWidth -= 24;
|
|
345 Dst.uFrameX += 12;
|
|
346 Dst.uFrameY += 12;
|
|
347 Dst.uFrameHeight -= 12;
|
|
348 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
|
|
349 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
|
|
350 Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, "Text Verification: Here we can write an explanation of the project", 3);
|
|
351 } |