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"
|
2312
|
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
|
|
171 int v10; // ecx@36
|
|
172 int v11; // ecx@37
|
|
173 unsigned int pX;
|
|
174 unsigned int pY; // [sp-18h] [bp-54h]@39
|
|
175 Texture *pTexture; // [sp-14h] [bp-50h]@39
|
|
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
|
|
186 //Media::Player *p = new Media::Player;//
|
|
187 //Media::ITrack *track = p->LoadTrack(L"Sounds\\New_Sounds/Stronghold_Theme.mp3");
|
|
188 //track->Play();
|
|
189
|
2290
|
190 pMouse->RemoveHoldingItem();//
|
|
191
|
|
192 pIcons_LOD->_inlined_sub2();
|
|
193
|
|
194 pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
|
2308
|
195 //Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
|
2295
|
196
|
|
197 sprintf(pContainerName, "data\\New_Icons/%s", "mm6_button_oval.png");
|
2308
|
198 Texture* MMT_MM6 = LoadPNG(pContainerName);
|
2295
|
199
|
|
200
|
2290
|
201 Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
|
|
202 Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
|
|
203 Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
|
|
204 Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
|
|
205
|
2308
|
206 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
|
207 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);
|
|
208 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);
|
|
209 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);
|
|
210 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);
|
|
211
|
|
212 pTexture_PCX.Release();
|
|
213
|
|
214 sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
|
|
215 pTexture_PCX.LoadPCXFile(pContainerName, 0);
|
|
216 SetCurrentMenuID(MENU_MMT_MAIN_MENU);
|
|
217 SetForegroundWindow(window->GetApiHandle());
|
|
218 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
|
|
219 while (GetCurrentMenuID() == MENU_MMT_MAIN_MENU )
|
|
220 {
|
|
221 POINT cursor;
|
|
222 pMouse->GetCursorPos(&cursor);
|
|
223
|
|
224 for (MSG msg; PeekMessageW(&msg, 0, 0, 0, PM_REMOVE);)
|
|
225 {
|
|
226 if (msg.message == WM_QUIT)
|
|
227 Game_DeinitializeAndTerminate(0);
|
|
228 TranslateMessage(&msg);
|
|
229 DispatchMessageW(&msg);
|
|
230 }
|
|
231
|
|
232 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
|
|
233 {
|
|
234 WaitMessage();
|
|
235 continue;
|
|
236 }
|
|
237
|
|
238 pRenderer->BeginScene();
|
|
239 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
|
|
240
|
|
241 MMT_MenuMessageProc();
|
|
242 GUI_UpdateWindows();
|
|
243
|
|
244 if ( !pModalWindow )// ???
|
|
245 {
|
|
246 pButton = pWindow_MMT_MainMenu->pControlsHead;
|
|
247 for ( pButton = pWindow_MMT_MainMenu->pControlsHead; pButton; pButton = pButton->pNext )
|
|
248 {
|
|
249 if ( cursor.x >= (signed int)pButton->uX && cursor.x <= (signed int)pButton->uZ
|
|
250 && cursor.y >= (signed int)pButton->uY && cursor.y <= (signed int)pButton->uW )
|
|
251 {
|
|
252 pControlParam = pButton->msg_param;
|
|
253 switch (pControlParam) //
|
|
254 {
|
|
255 case 0:
|
|
256 pTexture = MMT_MM6;
|
2308
|
257 pX = 0;
|
|
258 pY = 0;
|
2290
|
259 break;
|
|
260 case 1:
|
|
261 pTexture = MMT_MM7;
|
|
262 pX = window->GetWidth() - (window->GetWidth() / 4);
|
|
263 pY = window->GetHeight() / 4;
|
|
264 break;
|
|
265 case 2:
|
|
266 pTexture = MMT_MM8;
|
|
267 pX = window->GetWidth() - (window->GetWidth() / 4);
|
|
268 pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
|
|
269 break;
|
|
270 case 3:
|
|
271 pTexture = MMT_Continue;
|
|
272 pX = (window->GetWidth() / 4) - 100;
|
|
273 pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
|
|
274 break;
|
|
275 case 4:
|
|
276 pTexture = MMT_Exit;
|
|
277 pX = window->GetWidth() - 130;
|
|
278 pY = window->GetHeight() - 35;
|
|
279 break;
|
|
280 }
|
|
281 pRenderer->DrawTextureIndexed(pX, pY, pTexture); //
|
|
282 }
|
|
283 }
|
|
284 }
|
|
285 //}
|
|
286 pRenderer->EndScene();
|
|
287 pRenderer->Present();
|
|
288 }
|
|
289 MMT_MenuMessageProc();
|
|
290 pRenderer->BeginScene();
|
|
291 GUI_UpdateWindows();
|
|
292 pRenderer->EndScene();
|
|
293 pRenderer->Present();
|
|
294 pTexture_PCX.Release();
|
|
295 if ( pGUIWindow2 )
|
|
296 {
|
|
297 pGUIWindow2->Release();
|
|
298 pGUIWindow2 = 0;
|
|
299 }
|
|
300 pWindow_MMT_MainMenu->Release();
|
|
301 pIcons_LOD->RemoveTexturesPackFromTextureList();
|
|
302 }
|
|
303
|
|
304 void MMT_MenuMessageProc()
|
|
305 {
|
|
306 int pParam;
|
|
307 int pParam2;
|
|
308 UIMessageType pUIMessageType;
|
|
309
|
|
310 if ( pMessageQueue_50CBD0->uNumMessages )
|
|
311 {
|
|
312 do
|
|
313 {
|
|
314
|
|
315 pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &pParam2);
|
|
316
|
|
317 switch (pUIMessageType)
|
|
318 {
|
|
319 case UIMSG_MMT_MainMenu_MM7: // 7
|
|
320 //GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0);
|
|
321 ShowMM7IntroVideo_and_LoadingScreen();
|
|
322 SetCurrentMenuID(MENU_MAIN);
|
|
323 break;
|
|
324
|
|
325 default:
|
|
326 break;
|
|
327 }
|
|
328 }
|
|
329 while ( pMessageQueue_50CBD0->uNumMessages );
|
|
330 }
|
|
331 }
|
|
332 void DrawMMTCopyrightWindow()
|
|
333 {
|
|
334 GUIWindow Dst; // [sp+8h] [bp-54h]@1
|
|
335
|
|
336 memset(&Dst, 0, 0x54u);
|
|
337 Dst.uFrameWidth = 624;
|
|
338 Dst.uFrameHeight = 256;
|
|
339 Dst.uFrameX = 8;
|
|
340 Dst.uFrameY = 30;
|
|
341 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight("Text Verification: Here we can write an explanation of the project", &Dst, 24, 0)
|
|
342 + 2 * LOBYTE(pFontSmallnum->uFontHeight)
|
|
343 + 24;
|
|
344 Dst.uFrameY = 470 - Dst.uFrameHeight;
|
|
345 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
|
|
346 Dst.uFrameW = 469;
|
|
347 //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
|
|
348 Dst.DrawMessageBox(0);
|
|
349
|
|
350 Dst.uFrameWidth -= 24;
|
|
351 Dst.uFrameX += 12;
|
|
352 Dst.uFrameY += 12;
|
|
353 Dst.uFrameHeight -= 12;
|
|
354 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
|
|
355 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
|
|
356 Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, "Text Verification: Here we can write an explanation of the project", 3);
|
|
357 } |