Mercurial > mm7
comparison Game/MainMenu.cpp @ 2551:4008b2f34be0
MainMenu rendering moved from event loop to respective window class
author | a.parshin |
---|---|
date | Tue, 12 May 2015 12:03:30 +0200 |
parents | fed97f15d1e1 |
children | ac16f4a3a91e |
comparison
equal
deleted
inserted
replaced
2550:fb42e2662c38 | 2551:4008b2f34be0 |
---|---|
7 #include "Engine/Graphics/Viewport.h" | 7 #include "Engine/Graphics/Viewport.h" |
8 | 8 |
9 #include "IO/Mouse.h" | 9 #include "IO/Mouse.h" |
10 #include "IO/Keyboard.h" | 10 #include "IO/Keyboard.h" |
11 | 11 |
12 #include "GUI/GUIWindow.h" | 12 #include "GUI/UI/UIMainMenu.h" |
13 #include "GUI/GUIButton.h" | |
14 #include "GUI/UI/UIPartyCreation.h" | 13 #include "GUI/UI/UIPartyCreation.h" |
15 #include "GUI/UI/UISaveLoad.h" | 14 #include "GUI/UI/UISaveLoad.h" |
15 #include "GUI/GUIButton.h" | |
16 | 16 |
17 #include "Media/Audio/AudioPlayer.h" | 17 #include "Media/Audio/AudioPlayer.h" |
18 | 18 |
19 #include "Game/MainMenu.h" | 19 #include "Game/MainMenu.h" |
20 | 20 |
21 | |
22 GUIButton *pMainMenu_BtnExit = nullptr; | |
23 GUIButton *pMainMenu_BtnCredits = nullptr; | |
24 GUIButton *pMainMenu_BtnLoad = nullptr; | |
25 GUIButton *pMainMenu_BtnNew = nullptr; | |
26 | 21 |
27 RGBTexture main_menu_background; | 22 RGBTexture main_menu_background; |
28 | 23 |
29 | 24 |
30 | 25 |
364 pAudioPlayer->StopChannels(-1, -1); | 359 pAudioPlayer->StopChannels(-1, -1); |
365 pMouse->RemoveHoldingItem(); | 360 pMouse->RemoveHoldingItem(); |
366 | 361 |
367 pIcons_LOD->_inlined_sub2(); | 362 pIcons_LOD->_inlined_sub2(); |
368 | 363 |
369 pWindow_MainMenu = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); | 364 pWindow_MainMenu = new GUIWindow_MainMenu(); |
370 Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); | |
371 Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); | |
372 Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | |
373 Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | |
374 | |
375 pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); | |
376 pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); | |
377 pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); | |
378 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); | |
379 | 365 |
380 main_menu_background.Release(); | 366 main_menu_background.Release(); |
381 main_menu_background.Load("title.pcx", 0); | 367 main_menu_background.Load("title.pcx", 0); |
382 SetCurrentMenuID(MENU_MAIN); | 368 SetCurrentMenuID(MENU_MAIN); |
383 SetForegroundWindow(window->GetApiHandle()); | 369 SetForegroundWindow(window->GetApiHandle()); |
419 pRenderer->DrawTextureNew(0, 0, &main_menu_background); | 405 pRenderer->DrawTextureNew(0, 0, &main_menu_background); |
420 | 406 |
421 MainMenu_EventLoop(); | 407 MainMenu_EventLoop(); |
422 GUI_UpdateWindows(); | 408 GUI_UpdateWindows(); |
423 | 409 |
424 if (GetCurrentMenuID() != MENU_MAIN) | |
425 { | |
426 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) | |
427 { | |
428 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
429 pGUIWindow_CurrentMenu->Release(); | |
430 pGUIWindow_CurrentMenu = 0; | |
431 current_screen_type = SCREEN_GAME; | |
432 viewparams->bRedrawGameUI = 1; | |
433 } | |
434 } | |
435 else | |
436 { | |
437 if (!pModalWindow)// ??? | |
438 { | |
439 pButton = pWindow->pControlsHead; | |
440 for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) | |
441 { | |
442 if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ | |
443 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW | |
444 && pWindow == pWindow_MainMenu) | |
445 { | |
446 pControlParam = pButton->msg_param; | |
447 switch (pControlParam) // backlight for buttons | |
448 { | |
449 case 0: | |
450 pTexture = pNew; | |
451 pY = 172; | |
452 break; | |
453 case 1: | |
454 pTexture = pLoad; | |
455 pY = 227; | |
456 break; | |
457 case 2: | |
458 pTexture = pCredits; | |
459 pY = 282; | |
460 break; | |
461 case 3: | |
462 pTexture = pExit; | |
463 pY = 337; | |
464 break; | |
465 } | |
466 pRenderer->DrawTextureIndexed(495, pY, pTexture); | |
467 } | |
468 } | |
469 } | |
470 } | |
471 pRenderer->EndScene(); | 410 pRenderer->EndScene(); |
472 pRenderer->Present(); | 411 pRenderer->Present(); |
473 } | 412 } |
413 | |
474 MainMenu_EventLoop(); | 414 MainMenu_EventLoop(); |
475 pRenderer->BeginScene(); | 415 pRenderer->BeginScene(); |
476 GUI_UpdateWindows(); | 416 GUI_UpdateWindows(); |
477 pRenderer->EndScene(); | 417 pRenderer->EndScene(); |
478 pRenderer->Present(); | 418 pRenderer->Present(); |