Mercurial > mm7
comparison GUI/UI/UIMainMenu.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 | 87e5590d034b |
children | ac16f4a3a91e |
comparison
equal
deleted
inserted
replaced
2550:fb42e2662c38 | 2551:4008b2f34be0 |
---|---|
1 #define _CRTDBG_MAP_ALLOC | 1 #define _CRTDBG_MAP_ALLOC |
2 #define _CRT_SECURE_NO_WARNINGS | |
2 #include <stdlib.h> | 3 #include <stdlib.h> |
3 #include <crtdbg.h> | 4 #include <crtdbg.h> |
4 | 5 |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 | |
7 #include "Engine/Engine.h" | 6 #include "Engine/Engine.h" |
8 | 7 #include "Engine/LOD.h" |
9 #include "..\../IO/Mouse.h" | 8 #include "Engine/MMT.h" |
10 #include "..\../IO/Keyboard.h" | 9 #include "Engine/texts.h" |
11 | 10 #include "Engine/Graphics/IRender.h" |
12 #include "..\../GUI/GUIWindow.h" | 11 #include "Engine/Graphics/Viewport.h" |
13 #include "..\../GUI/GUIFont.h" | 12 #include "Engine/Graphics/PaletteManager.h" |
14 #include "..\../Media/Audio/AudioPlayer.h" | 13 #include "Engine/Tables/IconFrameTable.h" |
15 #include "..\../Engine/Graphics/Render.h" | 14 |
16 #include "..\../Engine/LOD.h" | 15 #include "IO/Mouse.h" |
17 #include "..\../Engine/Graphics/PaletteManager.h" | 16 #include "IO/Keyboard.h" |
18 #include "..\../Engine/Tables/IconFrameTable.h" | 17 |
19 #include "..\../Engine/texts.h" | 18 #include "GUI/UI/UIMainMenu.h" |
20 #include "..\../Engine/MMT.h" | 19 #include "GUI/GUIFont.h" |
20 | |
21 #include "Media/Audio/AudioPlayer.h" | |
21 | 22 |
22 #include "Game/Game.h" | 23 #include "Game/Game.h" |
23 #include "Game/MainMenu.h" | 24 #include "Game/MainMenu.h" |
25 | |
26 | |
27 | |
28 GUIButton *pMainMenu_BtnExit = nullptr; | |
29 GUIButton *pMainMenu_BtnCredits = nullptr; | |
30 GUIButton *pMainMenu_BtnLoad = nullptr; | |
31 GUIButton *pMainMenu_BtnNew = nullptr; | |
32 | |
33 | |
34 | |
35 GUIWindow_MainMenu::GUIWindow_MainMenu() : | |
36 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr) | |
37 { | |
38 // ----------------------------------- | |
39 // 004627B7 void MainMenu_Loop -- part | |
40 Texture *pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); | |
41 Texture *pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); | |
42 Texture *pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | |
43 Texture *pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | |
44 | |
45 pMainMenu_BtnNew = CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); | |
46 pMainMenu_BtnLoad = CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); | |
47 pMainMenu_BtnCredits = CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); | |
48 pMainMenu_BtnExit = CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); | |
49 } | |
50 | |
51 | |
52 void GUIWindow_MainMenu::Update() | |
53 { | |
54 // ----------------------------------- | |
55 // 004627B7 void MainMenu_Loop -- part | |
56 POINT pt; | |
57 pMouse->GetCursorPos(&pt); | |
58 GUIWindow *pWindow = this;//pWindow_MainMenu; | |
59 if (GetCurrentMenuID() == MENU_SAVELOAD) | |
60 pWindow = pGUIWindow_CurrentMenu; | |
61 | |
62 | |
63 if (GetCurrentMenuID() == MENU_MAIN) | |
64 { | |
65 Texture *pTexture = nullptr; | |
66 if (!pModalWindow)// ??? | |
67 { | |
68 auto pButton = pWindow->pControlsHead; | |
69 for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) | |
70 { | |
71 if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ | |
72 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW | |
73 && pWindow == pWindow_MainMenu) | |
74 { | |
75 auto pControlParam = pButton->msg_param; | |
76 int pY = 0; | |
77 switch (pControlParam) // backlight for buttons | |
78 { | |
79 case 0: | |
80 pTexture = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); | |
81 pY = 172; | |
82 break; | |
83 case 1: | |
84 pTexture = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); | |
85 pY = 227; | |
86 break; | |
87 case 2: | |
88 pTexture = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | |
89 pY = 282; | |
90 break; | |
91 case 3: | |
92 pTexture = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | |
93 pY = 337; | |
94 break; | |
95 } | |
96 pRenderer->DrawTextureIndexed(495, pY, pTexture); | |
97 } | |
98 } | |
99 } | |
100 } | |
101 } | |
24 | 102 |
25 | 103 |
26 //----- (0041B578) -------------------------------------------------------- | 104 //----- (0041B578) -------------------------------------------------------- |
27 void MainMenuUI_LoadFontsAndSomeStuff() | 105 void MainMenuUI_LoadFontsAndSomeStuff() |
28 { | 106 { |