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