comparison Game/MainMenu.cpp @ 2572:d87bfbd3bb3b

Step towards unification of Texture and RGBTexture (class Image)
author a.parshin
date Sat, 05 Mar 2016 01:51:54 +0200
parents f9bdfe26d03d
children dd36326a9994
comparison
equal deleted inserted replaced
2571:cf29f444ddd7 2572:d87bfbd3bb3b
1 #include "Engine/Engine.h" 1 #include "Engine/Engine.h"
2 #include "Engine/AssetsManager.h"
2 #include "Engine/Timer.h" 3 #include "Engine/Timer.h"
3 #include "Engine/Party.h" 4 #include "Engine/Party.h"
4 #include "Engine/LOD.h" 5 #include "Engine/LOD.h"
5 #include "Engine/SaveLoad.h" 6 #include "Engine/SaveLoad.h"
7 #include "Engine/texts.h"
6 #include "Engine/Graphics/IRender.h" 8 #include "Engine/Graphics/IRender.h"
7 #include "Engine/Graphics/Viewport.h" 9 #include "Engine/Graphics/Viewport.h"
8 10
9 #include "IO/Mouse.h" 11 #include "IO/Mouse.h"
10 #include "IO/Keyboard.h" 12 #include "IO/Keyboard.h"
11 13
12 #include "GUI/UI/UIMainMenu.h" 14 #include "GUI/UI/UIMainMenu.h"
13 #include "GUI/UI/UIPartyCreation.h" 15 #include "GUI/UI/UIPartyCreation.h"
14 #include "GUI/UI/UISaveLoad.h" 16 #include "GUI/UI/UISaveLoad.h"
15 #include "GUI/GUIButton.h" 17 #include "GUI/GUIButton.h"
18 #include "GUI/GUIFont.h"
16 19
17 #include "Media/Audio/AudioPlayer.h" 20 #include "Media/Audio/AudioPlayer.h"
18 #include "Media/Audio/AIL.h" 21 #include "Media/Audio/AIL.h"
19 22
20 #include "Game/MainMenu.h" 23 #include "Game/MainMenu.h"
21 #include "Game/MainMenuLoad.h" 24 #include "Game/MainMenuLoad.h"
22 25
23 26
24 RGBTexture main_menu_background; 27 Image *main_menu_bg = nullptr;
28 Image *main_menu_background = nullptr;
25 29
26 30
27 31
28 //----- (00435748) -------------------------------------------------------- 32 //----- (00435748) --------------------------------------------------------
29 void MainMenu_EventLoop() 33 void MainMenu_EventLoop()
365 Texture *pTexture; // [sp-14h] [bp-50h]@39 369 Texture *pTexture; // [sp-14h] [bp-50h]@39
366 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 370 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11
367 MSG msg; 371 MSG msg;
368 372
369 373
374 pAudioPlayer->StopChannels(-1, -1);
375 if (!bNoSound && pAudioPlayer)
376 pAudioPlayer->PlayMusicTrack(MUSIC_MainMenu);
370 377
371 if (first_initialization) 378 if (first_initialization)
372 { 379 {
373 first_initialization = false; 380 first_initialization = false;
374 381
375 RGBTexture tex; // [sp+Ch] [bp-30h]@1 382 if (!main_menu_bg)
376 tex.Load("mm6title.pcx", 2); 383 main_menu_bg = assets->GetImage_PCXFromIconsLOD(L"mm6title.pcx");
377 384
378 pRenderer->ResetUIClipRect(); 385 pRenderer->ResetUIClipRect();
379 pRenderer->BeginScene();
380 {
381 pRenderer->DrawTextureNew(0, 0, &tex);
382 }
383 pRenderer->EndScene();
384 pRenderer->Present();
385
386 tex.Release();
387
388 MainMenuUI_LoadFontsAndSomeStuff();
389
390 pRenderer->BeginScene(); 386 pRenderer->BeginScene();
391 { 387 {
392 DrawMM7CopyrightWindow(); 388 DrawMM7CopyrightWindow();
393 } 389 }
394 pRenderer->EndScene(); 390 pRenderer->EndScene();
396 392
397 #ifdef NDEBUG 393 #ifdef NDEBUG
398 Sleep(1500); // let the copyright window stay for a while 394 Sleep(1500); // let the copyright window stay for a while
399 #endif 395 #endif
400 396
401 if (!bNoSound && pAudioPlayer->hAILRedbook)
402 {
403 unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8
404 unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8
405
406 pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
407 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
408 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS);
409 AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
410 }
411
412 SecondaryInitialization(); 397 SecondaryInitialization();
413 FinalInitialization(); 398 FinalInitialization();
414 } 399 }
415 400
416 401
417 current_screen_type = SCREEN_GAME; 402 current_screen_type = SCREEN_GAME;
418 403
419 pGUIWindow2 = 0; 404 pGUIWindow2 = 0;
420 pAudioPlayer->StopChannels(-1, -1);
421 pMouse->RemoveHoldingItem();
422
423 pIcons_LOD->_inlined_sub2();
424 405
425 pWindow_MainMenu = new GUIWindow_MainMenu(); 406 pWindow_MainMenu = new GUIWindow_MainMenu();
426 407
427 main_menu_background.Release();
428 main_menu_background.Load("title.pcx", 0);
429 SetCurrentMenuID(MENU_MAIN); 408 SetCurrentMenuID(MENU_MAIN);
430 SetForegroundWindow(window->GetApiHandle()); 409 SetForegroundWindow(window->GetApiHandle());
431 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); 410 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
432 411
433 //while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD)
434 while (GetCurrentMenuID() == MENU_MAIN) 412 while (GetCurrentMenuID() == MENU_MAIN)
435 { 413 {
436 POINT pt; 414 POINT pt;
437 pMouse->GetCursorPos(&pt); 415 pMouse->GetCursorPos(&pt);
438 pWindow = pWindow_MainMenu; 416 pWindow = pWindow_MainMenu;
439 /*if (GetCurrentMenuID() == MENU_SAVELOAD)
440 {
441 if (current_screen_type != SCREEN_LOADGAME)
442 {
443 main_menu_background.Release();
444 main_menu_background.Load("lsave640.pcx", 0);
445 pGUIWindow2 = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0);
446
447 //LoadUI_Load(0);
448 pGUIWindow_CurrentMenu = new GUIWindow_Load(false);
449 }
450 pWindow = pGUIWindow_CurrentMenu;
451 }*/
452 417
453 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) 418 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
454 { 419 {
455 if (msg.message == WM_QUIT) 420 if (msg.message == WM_QUIT)
456 Engine_DeinitializeAndTerminate(0); 421 Engine_DeinitializeAndTerminate(0);
462 { 427 {
463 WaitMessage(); 428 WaitMessage();
464 continue; 429 continue;
465 } 430 }
466 431
432 if (!main_menu_background)
433 main_menu_background = assets->GetImage_PCXFromIconsLOD(L"title.pcx");
434
467 pRenderer->BeginScene(); 435 pRenderer->BeginScene();
468 { 436 {
469 pRenderer->DrawTextureNew(0, 0, &main_menu_background); 437 pRenderer->DrawTextureNew(0, 0, main_menu_background);
470 438
471 MainMenu_EventLoop(); 439 MainMenu_EventLoop();
472 GUI_UpdateWindows(); 440 GUI_UpdateWindows();
473 } 441 }
474 pRenderer->EndScene(); 442 pRenderer->EndScene();
481 GUI_UpdateWindows(); 449 GUI_UpdateWindows();
482 } 450 }
483 pRenderer->EndScene(); 451 pRenderer->EndScene();
484 pRenderer->Present(); 452 pRenderer->Present();
485 453
486 main_menu_background.Release(); 454 main_menu_background->Release();
487 /*if (pGUIWindow2) 455 main_menu_background = nullptr;
488 { 456
489 pGUIWindow2->Release();
490 pGUIWindow2 = 0;
491 }*/
492 pWindow_MainMenu->Release(); 457 pWindow_MainMenu->Release();
493 pWindow_MainMenu = nullptr; 458 pWindow_MainMenu = nullptr;
494
495 pIcons_LOD->RemoveTexturesPackFromTextureList();
496 } 459 }
460
461
462
463 //----- (00415485) --------------------------------------------------------
464 void DrawMM7CopyrightWindow()
465 {
466 pRenderer->DrawTextureNew(0, 0, main_menu_bg);
467
468 GUIWindow Dst; // [sp+8h] [bp-54h]@1
469
470 memset(&Dst, 0, sizeof(Dst));
471 Dst.uFrameWidth = 624;
472 Dst.uFrameHeight = 256;
473 Dst.uFrameX = 8;
474 Dst.uFrameY = 30; // c 1999 The 3DO Company.
475 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
476 + 2 * LOBYTE(pFontSmallnum->uFontHeight)
477 + 24;
478 Dst.uFrameY = 470 - Dst.uFrameHeight;
479 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
480 Dst.uFrameW = 469;
481 //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
482 Dst.DrawMessageBox(0);
483
484 Dst.uFrameWidth -= 24;
485 Dst.uFrameX += 12;
486 Dst.uFrameY += 12;
487 Dst.uFrameHeight -= 12;
488 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
489 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
490 Dst.DrawTitleText(pFontSmallnum, 0, 12, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3);
491 }