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