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
|
|
75 Texture *ConvertPNG(const char *name)
|
|
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
|
|
88 char header[8]; // 8 is the maximum size that can be checked
|
|
89
|
|
90 /* open file and test for it being a png */
|
|
91 FILE *fp = fopen(name, "rb");
|
|
92 if (!fp)
|
|
93 Log::Warning(L"[read_png_file] File %s could not be opened for reading", name);
|
|
94 fread(header, 1, 8, fp);
|
|
95 //if (png_sig_cmp(header, 0, 8))
|
|
96 //Log::Warning(L"[read_png_file] File %s is not recognized as a PNG file", pContainerName);
|
|
97 /* initialize stuff */
|
|
98 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
|
99
|
|
100 if (!png_ptr)
|
|
101 abort_("[read_png_file] png_create_read_struct failed");
|
|
102
|
|
103 info_ptr = png_create_info_struct(png_ptr);
|
|
104 if (!info_ptr)
|
|
105 abort_("[read_png_file] png_create_info_struct failed");
|
|
106
|
|
107 if (setjmp(png_jmpbuf(png_ptr)))
|
|
108 abort_("[read_png_file] Error during init_io");
|
|
109
|
|
110 png_init_io(png_ptr, fp);
|
|
111 png_set_sig_bytes(png_ptr, 8);
|
|
112
|
|
113 png_read_info(png_ptr, info_ptr);
|
|
114
|
|
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);
|
|
122
|
|
123
|
|
124 /* read file */
|
|
125 if (setjmp(png_jmpbuf(png_ptr)))
|
|
126 abort_("[read_png_file] Error during read_image");
|
|
127
|
|
128 row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
|
|
129 for (y=0; y<height; y++)
|
|
130 row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
|
|
131 unsigned __int16 * pl = (unsigned __int16 *)row_pointers;
|
|
132 png_read_image(png_ptr, row_pointers);
|
|
133
|
|
134 fclose(fp);
|
|
135 tex = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending"));//не знаю как зачистить
|
|
136 tex->uTextureHeight = height;
|
|
137 tex->uTextureWidth = width;
|
|
138 tex->uSizeOfMaxLevelOfDetail = png_get_rowbytes(png_ptr, info_ptr);
|
|
139 tex->uTextureSize = png_get_rowbytes(png_ptr, info_ptr);
|
|
140 tex->uDecompressedSize = png_get_rowbytes(png_ptr, info_ptr);
|
|
141
|
|
142 for (y=0; y<height; y++)
|
|
143 {
|
|
144 for (x=0; x<width; x++)
|
|
145 {
|
|
146 if ( pl )
|
|
147 tex->pPalette16[i] = Color16(LOBYTE(pl), BYTE1(pl), BYTE2(pl));
|
|
148 i++;
|
|
149 pl++;
|
|
150 }
|
|
151 }
|
|
152 return tex;
|
|
153 }
|
|
154
|
2290
|
155 void MMT_MainMenu_Loop()
|
|
156 {
|
|
157 GUIButton *pButton; // eax@27
|
|
158 unsigned int pControlParam; // ecx@35
|
|
159 int v10; // ecx@36
|
|
160 int v11; // ecx@37
|
|
161 unsigned int pX;
|
|
162 unsigned int pY; // [sp-18h] [bp-54h]@39
|
|
163 Texture *pTexture; // [sp-14h] [bp-50h]@39
|
|
164 GUIButton *pButton2; // [sp+0h] [bp-3Ch]@27
|
2295
|
165 char pContainerName[64];
|
|
166
|
|
167
|
2290
|
168
|
|
169 pCurrentScreen = SCREEN_GAME;
|
|
170
|
|
171 pGUIWindow2 = 0;
|
|
172 pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал
|
|
173 pMouse->RemoveHoldingItem();//избавить курсор от вещи
|
|
174
|
|
175 pIcons_LOD->_inlined_sub2();
|
|
176
|
|
177 pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
|
2299
|
178 Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
|
2295
|
179
|
|
180 sprintf(pContainerName, "data\\New_Icons/%s", "mm6_button_oval.png");
|
2299
|
181 //Texture* MMT_MM6 = ConvertPNG(pContainerName);
|
2295
|
182
|
|
183
|
2290
|
184 Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
|
|
185 Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
|
|
186 Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
|
|
187 Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
|
|
188
|
|
189 pMMT_MainMenu_BtnMM6 = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() / 4, MMT_MM6->uTextureWidth, MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6, 0, 0, "", MMT_MM6, 0);
|
|
190 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);
|
|
191 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);
|
|
192 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);
|
|
193 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);
|
|
194
|
|
195 pTexture_PCX.Release();
|
|
196
|
|
197 sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
|
|
198 pTexture_PCX.LoadPCXFile(pContainerName, 0);
|
|
199 SetCurrentMenuID(MENU_MMT_MAIN_MENU);
|
|
200 SetForegroundWindow(window->GetApiHandle());
|
|
201 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
|
|
202 while (GetCurrentMenuID() == MENU_MMT_MAIN_MENU )
|
|
203 {
|
|
204 POINT cursor;
|
|
205 pMouse->GetCursorPos(&cursor);
|
|
206
|
|
207 for (MSG msg; PeekMessageW(&msg, 0, 0, 0, PM_REMOVE);)
|
|
208 {
|
|
209 if (msg.message == WM_QUIT)
|
|
210 Game_DeinitializeAndTerminate(0);
|
|
211 TranslateMessage(&msg);
|
|
212 DispatchMessageW(&msg);
|
|
213 }
|
|
214
|
|
215 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
|
|
216 {
|
|
217 WaitMessage();
|
|
218 continue;
|
|
219 }
|
|
220
|
|
221 pRenderer->BeginScene();
|
|
222 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
|
|
223
|
|
224 MMT_MenuMessageProc();
|
|
225 GUI_UpdateWindows();
|
|
226
|
|
227 if ( !pModalWindow )// ???
|
|
228 {
|
|
229 pButton = pWindow_MMT_MainMenu->pControlsHead;
|
|
230 for ( pButton = pWindow_MMT_MainMenu->pControlsHead; pButton; pButton = pButton->pNext )
|
|
231 {
|
|
232 if ( cursor.x >= (signed int)pButton->uX && cursor.x <= (signed int)pButton->uZ
|
|
233 && cursor.y >= (signed int)pButton->uY && cursor.y <= (signed int)pButton->uW )
|
|
234 {
|
|
235 pControlParam = pButton->msg_param;
|
|
236 switch (pControlParam) // подсветка кнопок
|
|
237 {
|
|
238 case 0:
|
|
239 pTexture = MMT_MM6;
|
|
240 pX = (window->GetWidth() / 4) - 100;
|
|
241 pY = window->GetHeight() / 4;
|
|
242 break;
|
|
243 case 1:
|
|
244 pTexture = MMT_MM7;
|
|
245 pX = window->GetWidth() - (window->GetWidth() / 4);
|
|
246 pY = window->GetHeight() / 4;
|
|
247 break;
|
|
248 case 2:
|
|
249 pTexture = MMT_MM8;
|
|
250 pX = window->GetWidth() - (window->GetWidth() / 4);
|
|
251 pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
|
|
252 break;
|
|
253 case 3:
|
|
254 pTexture = MMT_Continue;
|
|
255 pX = (window->GetWidth() / 4) - 100;
|
|
256 pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
|
|
257 break;
|
|
258 case 4:
|
|
259 pTexture = MMT_Exit;
|
|
260 pX = window->GetWidth() - 130;
|
|
261 pY = window->GetHeight() - 35;
|
|
262 break;
|
|
263 }
|
|
264 pRenderer->DrawTextureIndexed(pX, pY, pTexture); //подсветка кнопок
|
|
265 }
|
|
266 }
|
|
267 }
|
|
268 //}
|
|
269 pRenderer->EndScene();
|
|
270 pRenderer->Present();
|
|
271 }
|
|
272 MMT_MenuMessageProc();
|
|
273 pRenderer->BeginScene();
|
|
274 GUI_UpdateWindows();
|
|
275 pRenderer->EndScene();
|
|
276 pRenderer->Present();
|
|
277 pTexture_PCX.Release();
|
|
278 if ( pGUIWindow2 )
|
|
279 {
|
|
280 pGUIWindow2->Release();
|
|
281 pGUIWindow2 = 0;
|
|
282 }
|
|
283 pWindow_MMT_MainMenu->Release();
|
|
284 pIcons_LOD->RemoveTexturesPackFromTextureList();
|
|
285 }
|
|
286
|
|
287 void MMT_MenuMessageProc()
|
|
288 {
|
|
289 int pParam;
|
|
290 int pParam2;
|
|
291 UIMessageType pUIMessageType;
|
|
292
|
|
293 if ( pMessageQueue_50CBD0->uNumMessages )
|
|
294 {
|
|
295 do
|
|
296 {
|
|
297
|
|
298 pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &pParam2);
|
|
299
|
|
300 switch (pUIMessageType)
|
|
301 {
|
|
302 case UIMSG_MMT_MainMenu_MM7: //кнопка игры ММ7
|
|
303 //GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0);
|
|
304 ShowMM7IntroVideo_and_LoadingScreen();
|
|
305 SetCurrentMenuID(MENU_MAIN);
|
|
306 break;
|
|
307
|
|
308 default:
|
|
309 break;
|
|
310 }
|
|
311 }
|
|
312 while ( pMessageQueue_50CBD0->uNumMessages );
|
|
313 }
|
|
314 }
|
|
315 void DrawMMTCopyrightWindow()
|
|
316 {
|
|
317 GUIWindow Dst; // [sp+8h] [bp-54h]@1
|
|
318
|
|
319 memset(&Dst, 0, 0x54u);
|
|
320 Dst.uFrameWidth = 624;
|
|
321 Dst.uFrameHeight = 256;
|
|
322 Dst.uFrameX = 8;
|
|
323 Dst.uFrameY = 30;
|
|
324 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight("Text Verification: Here we can write an explanation of the project", &Dst, 24, 0)
|
|
325 + 2 * LOBYTE(pFontSmallnum->uFontHeight)
|
|
326 + 24;
|
|
327 Dst.uFrameY = 470 - Dst.uFrameHeight;
|
|
328 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
|
|
329 Dst.uFrameW = 469;
|
|
330 //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
|
|
331 Dst.DrawMessageBox(0);
|
|
332
|
|
333 Dst.uFrameWidth -= 24;
|
|
334 Dst.uFrameX += 12;
|
|
335 Dst.uFrameY += 12;
|
|
336 Dst.uFrameHeight -= 12;
|
|
337 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
|
|
338 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
|
|
339 Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, "Text Verification: Here we can write an explanation of the project", 3);
|
|
340 } |