comparison Game/MainMenu.cpp @ 2541:a902abdfc7f2

1. Renamed class Game to class Engine. 2. Separated game logic as state of FSM from game logic as engine. 3. Found out that many UI screen initializers were optimized away, intially they all returned newly created window as separate object like it is done in CharacterUI_Initialize.
author a.parshin
date Sun, 10 May 2015 01:29:11 +0200
parents
children c674d547cc7c
comparison
equal deleted inserted replaced
2540:abc6a9d079b9 2541:a902abdfc7f2
1 #include "Engine/Engine.h"
2 #include "Engine/Timer.h"
3 #include "Engine/Party.h"
4 #include "Engine/LOD.h"
5 #include "Engine/SaveLoad.h"
6 #include "Engine/Graphics/IRender.h"
7 #include "Engine/Graphics/Viewport.h"
8
9 #include "IO/Mouse.h"
10 #include "IO/Keyboard.h"
11
12 #include "GUI/GUIWindow.h"
13 #include "GUI/GUIButton.h"
14 #include "GUI/UI/UIPartyCreation.h"
15
16 #include "Media/Audio/AudioPlayer.h"
17
18 #include "Game/MainMenu.h"
19
20
21 //----- (00435748) --------------------------------------------------------
22 void MainMenu_EventLoop()
23 {
24 Player *pPlayer; // ebx@2
25 void *v3; // edi@21
26 signed int v4; // eax@29
27 // int v5; // ecx@29
28 // PLAYER_SKILL_TYPE v6; // edi@37
29 GUIWindow *pWindow; // eax@56
30 GUIButton *pButton; // eax@59
31 int v15; // edi@70
32 char v20; // dl@116
33 unsigned int v21; // eax@116
34 unsigned int v25; // eax@120
35 unsigned int v26; // ecx@127
36 // SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36
37 // signed int v41; // [sp-10h] [bp-20h]@29
38 int pParam; // [sp+4h] [bp-Ch]@3
39 UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
40 int pSex; // [sp+Ch] [bp-4h]@3
41
42 if (pMessageQueue_50CBD0->uNumMessages)
43 {
44 pPlayer = pParty->pPlayers.data();
45 do
46 {
47 int param2;
48 pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &param2);
49 //auto player = &pParty->pPlayers[pParam];
50
51 switch (pUIMessageType) // For buttons of window MainMenu
52 {
53 case UIMSG_MainMenu_ShowPartyCreationWnd:
54 GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0);
55 SetCurrentMenuID(MENU_NEWGAME);
56 break;
57 case UIMSG_MainMenu_ShowLoadWindow:
58 GUIWindow::Create(495, 227, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnLoad, 0);
59 SetCurrentMenuID(MENU_SAVELOAD);
60 break;
61 case UIMSG_ShowCredits:
62 GUIWindow::Create(495, 282, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnCredits, 0);
63 SetCurrentMenuID(MENU_CREDITS);
64 break;
65 case UIMSG_ExitToWindows:
66 GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0);
67 SetCurrentMenuID(MENU_EXIT_GAME);
68 break;
69 case UIMSG_PlayerCreation_SelectAttribute:
70 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
71 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
72 uPlayerCreationUI_SelectedCharacter = pParam;
73 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
74 break;
75 case UIMSG_PlayerCreation_VoicePrev:
76 pSex = pParty->pPlayers[pParam].GetSexByVoice();
77 do
78 {
79 if (pParty->pPlayers[pParam].uVoiceID == 0)
80 pParty->pPlayers[pParam].uVoiceID = 19;
81 else --pParty->pPlayers[pParam].uVoiceID;
82 } while (pParty->pPlayers[pParam].GetSexByVoice() != pSex);
83 pButton = pCreationUI_BtnPressLeft2[pParam];
84 GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1);
85 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
86 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0);
87 break;
88 case UIMSG_PlayerCreation_VoiceNext:
89 pSex = pParty->pPlayers[pParam].GetSexByVoice();
90 do
91 {
92 pParty->pPlayers[pParam].uVoiceID = (pParty->pPlayers[pParam].uVoiceID + 1) % 20;
93 } while (pParty->pPlayers[pParam].GetSexByVoice() != pSex);
94 pButton = pCreationUI_BtnPressRight2[pParam];
95 GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1);
96 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
97 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0);
98 break;
99 case UIMSG_PlayerCreation_FacePrev:
100 //pPlayer = &pParty->pPlayers[pParam];
101 if (!pParty->pPlayers[pParam].uCurrentFace)
102 pParty->pPlayers[pParam].uCurrentFace = 19;
103 else
104 pParty->pPlayers[pParam].uCurrentFace -= 1;
105 pParty->pPlayers[pParam].uVoiceID = pParty->pPlayers[pParam].uCurrentFace;
106 pParty->pPlayers[pParam].SetInitialStats();
107 pParty->pPlayers[pParam].SetSexByVoice();
108 pParty->pPlayers[pParam].RandomizeName();
109 v25 = pParam;
110 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
111 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
112 uPlayerCreationUI_SelectedCharacter = v25;
113 GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressLeft[v25], (char *)1);
114 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0.0, 0);
115 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0);
116 break;
117 case UIMSG_PlayerCreation_FaceNext:
118 //pPlayer = &pParty->pPlayers[pParam];
119 v20 = (char)((int)pParty->pPlayers[pParam].uCurrentFace + 1) % 20;
120 pParty->pPlayers[pParam].uCurrentFace = v20;
121 pParty->pPlayers[pParam].uVoiceID = v20;
122 pParty->pPlayers[pParam].SetInitialStats();
123 pParty->pPlayers[pParam].SetSexByVoice();
124 pParty->pPlayers[pParam].RandomizeName();
125 v21 = pParam;
126 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
127 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
128 uPlayerCreationUI_SelectedCharacter = v21;
129 GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressRight[v21], (char *)1);
130 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
131 pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0);
132 break;
133 case UIMSG_PlayerCreationClickPlus:
134 GUIWindow::Create(613, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnPlus, (char *)1);
135 pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
136 pAudioPlayer->PlaySound(SOUND_ClickMinus, 0, 0, -1, 0, 0, 0, 0);
137 break;
138 case UIMSG_PlayerCreationClickMinus:
139 GUIWindow::Create(523, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnMinus, (char *)1);
140 pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
141 pAudioPlayer->PlaySound(SOUND_ClickPlus, 0, 0, -1, 0, 0, 0, 0);
142 break;
143 case UIMSG_PlayerCreationSelectActiveSkill:
144 if (pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(3) == 37)
145 pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pParam + 4)] = 1;
146 pAudioPlayer->PlaySound(SOUND_ClickSkill, 0, 0, -1, 0, 0, 0, 0);
147 break;
148 case UIMSG_PlayerCreationSelectClass:
149 pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)pParam);
150 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0);
151 break;
152 case UIMSG_PlayerCreationClickOK:
153 GUIWindow::Create(580, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnOK, 0);
154 if (PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Choose4Skills())
155 GameUI_Footer_TimeLeft = GetTickCount() + 4000;
156 else
157 uGameState = GAME_STATE_STARTING_NEW_GAME;
158 break;
159 case UIMSG_PlayerCreationClickReset:
160 GUIWindow::Create(527, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnReset, 0);
161 pParty->Reset();
162 break;
163 case UIMSG_PlayerCreationRemoveUpSkill:
164 v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
165 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
166 if (pPlayer[pParam].GetSkillIdxByOrder(2) != 37)//37 - None(Нет)
167 pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(2)] = 0;
168 break;
169 case UIMSG_PlayerCreationRemoveDownSkill:
170 v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
171 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
172 if (pPlayer[pParam].GetSkillIdxByOrder(3) != 37)//37 - None(Нет)
173 pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(3)] = 0;
174 break;
175 case UIMSG_PlayerCreationChangeName:
176 pAudioPlayer->PlaySound(SOUND_ClickSkill, 0, 0, -1, 0, 0, 0, 0);
177 v3 = (void *)pParam;
178 uPlayerCreationUI_SelectedCharacter = pParam;
179 pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu);
180 pGUIWindow_CurrentMenu->ptr_1C = v3;
181 break;
182 case UIMSG_ChangeGameState:
183 uGameState = GAME_FINISHED;
184 break;
185 case UIMSG_ChangeCursor:
186 pMouse->SetCursorBitmap("MICON2");
187 break;
188 case UIMSG_3A:
189 SetCurrentMenuID(MENU_DebugBLVLevel);
190 break;
191 case UIMSG_LoadGame:
192 if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot])
193 break;
194 SetCurrentMenuID(MENU_LoadingProcInMainMenu);
195 break;
196 case UIMSG_SelectLoadSlot:
197 //main menu save/load wnd clicking on savegame lines
198 if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
199 pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE);
200 if (current_screen_type != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pParam + pSaveListPosition)
201 {
202 //load clicked line
203 v26 = pParam + pSaveListPosition;
204 if (dword_6BE138 == pParam + pSaveListPosition)
205 {
206 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0);
207 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0);
208 }
209 uLoadGameUI_SelectedSlot = v26;
210 dword_6BE138 = v26;
211 }
212 else
213 {
214 //typing in the line
215 pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu);
216 strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName);
217 pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer);
218 }
219 break;
220 case UIMSG_SaveLoadBtn:
221 GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0);
222 break;
223 case UIMSG_DownArrow:
224 ++pSaveListPosition;
225 if (pSaveListPosition >= pParam)
226 pSaveListPosition = pParam - 1;
227 if (pSaveListPosition < 1)
228 pSaveListPosition = 0;
229 pWindow = pGUIWindow_CurrentMenu;
230 GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, WINDOW_PressedButton2, (int)pBtnDownArrow, 0);
231 break;
232 case UIMSG_Cancel:
233 GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_LoadGame_CancelBtn, (int)pBtnCancel, 0);
234 break;
235 case UIMSG_ArrowUp:
236 --pSaveListPosition;
237 if (pSaveListPosition < 0)
238 pSaveListPosition = 0;
239 pWindow = pGUIWindow_CurrentMenu;
240 GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, WINDOW_PressedButton2, (int)pBtnArrowUp, 0);
241 break;
242 case UIMSG_AD:
243 GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0);
244 SetCurrentMenuID(MENU_LoadingProcInMainMenu);
245 break;
246 case UIMSG_AE:
247 GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0);
248 SetCurrentMenuID(MENU_DebugBLVLevel);
249 break;
250 case UIMSG_Escape:
251 if (pModalWindow)
252 {
253 ModalWindow_Release();
254 break;
255 }
256 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_4000))
257 break;
258 v15 = 1;
259 pMediaPlayer->bStopBeforeSchedule = 1;
260 viewparams->bRedrawGameUI = 1;
261 viewparams->field_48 = 1;
262 if (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_MMT_MAIN_MENU
263 || GetCurrentMenuID() == MENU_CREATEPARTY || GetCurrentMenuID() == MENU_NAMEPANELESC)
264 {
265 //if ( current_screen_type == SCREEN_VIDEO )
266 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag);
267 if (GetCurrentMenuID() == MENU_NAMEPANELESC) //из панели изменения имени
268 {
269 SetCurrentMenuID(MENU_CREATEPARTY);//в окно создания группы
270 break;
271 }
272 if (GetCurrentMenuID() == MENU_CREDITSPROC) //из окна Создатели
273 {
274 SetCurrentMenuID(MENU_CREDITSCLOSE);//в закрытие Создатели
275 break;
276 }
277 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0);
278 break;
279 }
280 if (GetCurrentMenuID() == MENU_CREDITSPROC && !current_screen_type)
281 {
282 //if ( current_screen_type == SCREEN_VIDEO )
283 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag);
284 if (GetCurrentMenuID() == MENU_NAMEPANELESC)
285 {
286 SetCurrentMenuID(MENU_CREATEPARTY);
287 break;
288 }
289 if (GetCurrentMenuID() == MENU_CREDITSPROC)
290 {
291 SetCurrentMenuID(MENU_CREDITSCLOSE);
292 break;
293 }
294 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0);
295 break;
296 }
297 if (current_screen_type == SCREEN_LOADGAME)
298 {
299 pIcons_LOD->RemoveTexturesPackFromTextureList();
300 //crt_deconstruct_ptr_6A0118();
301 pTexture_PCX.Release();
302 pTexture_PCX.Load("title.pcx", 0);
303 SetCurrentMenuID(MENU_MAIN);
304 v15 = 1;
305 pGUIWindow_CurrentMenu->Release();
306 pGUIWindow2->Release();
307 pGUIWindow2 = 0;
308 pEventTimer->Resume();
309 current_screen_type = SCREEN_GAME;
310 viewparams->bRedrawGameUI = v15;
311 break;
312 }
313 if (current_screen_type == SCREEN_VIDEO)
314 {
315 //pVideoPlayer->Unload();
316 }
317 else
318 {
319 if (current_screen_type != SCREEN_1B)
320 {
321 pGUIWindow_CurrentMenu->Release();
322 pGUIWindow2->Release();
323 pGUIWindow2 = 0;
324 pEventTimer->Resume();
325 current_screen_type = SCREEN_GAME;
326 viewparams->bRedrawGameUI = v15;
327 break;
328 }
329 //VideoPlayer::dtor();
330 }
331 break;
332 default:
333 break;
334 }
335 } while (pMessageQueue_50CBD0->uNumMessages);
336 }
337 }
338
339
340 //----- (004627B7) --------------------------------------------------------
341 void MainMenu_Loop()
342 {
343 GUIButton *pButton; // eax@27
344 unsigned int pControlParam; // ecx@35
345 unsigned int pY; // [sp-18h] [bp-54h]@39
346 Texture *pTexture; // [sp-14h] [bp-50h]@39
347 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11
348 MSG msg;
349
350 current_screen_type = SCREEN_GAME;
351
352 pGUIWindow2 = 0;
353 pAudioPlayer->StopChannels(-1, -1);
354 pMouse->RemoveHoldingItem();
355
356 pIcons_LOD->_inlined_sub2();
357
358 pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
359 Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
360 Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
361 Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
362 Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
363
364 pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0);
365 pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0);
366 pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0);
367 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0);
368
369 pTexture_PCX.Release();
370 pTexture_PCX.Load("title.pcx", 0);
371 SetCurrentMenuID(MENU_MAIN);
372 SetForegroundWindow(window->GetApiHandle());
373 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
374 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD)
375 {
376 POINT pt;
377 pMouse->GetCursorPos(&pt);
378 pWindow = pWindow_MainMenu;
379 if (GetCurrentMenuID() == MENU_SAVELOAD)
380 {
381 if (current_screen_type != SCREEN_LOADGAME)
382 {
383 pTexture_PCX.Release();
384 pTexture_PCX.Load("lsave640.pcx", 0);
385 pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
386 current_screen_type = SCREEN_LOADGAME;
387 LoadUI_Load(0);
388 }
389 pWindow = pGUIWindow_CurrentMenu;
390 }
391
392 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
393 {
394 if (msg.message == WM_QUIT)
395 Engine_DeinitializeAndTerminate(0);
396 TranslateMessage(&msg);
397 DispatchMessageW(&msg);
398 }
399
400 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
401 {
402 WaitMessage();
403 continue;
404 }
405
406 pRenderer->BeginScene();
407 pRenderer->DrawTextureNew(0, 0, &pTexture_PCX);
408
409 MainMenu_EventLoop();
410 GUI_UpdateWindows();
411
412 if (GetCurrentMenuID() != MENU_MAIN)
413 {
414 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
415 {
416 pIcons_LOD->RemoveTexturesPackFromTextureList();
417 pGUIWindow_CurrentMenu->Release();
418 pGUIWindow_CurrentMenu = 0;
419 current_screen_type = SCREEN_GAME;
420 viewparams->bRedrawGameUI = 1;
421 }
422 }
423 else
424 {
425 if (!pModalWindow)// ???
426 {
427 pButton = pWindow->pControlsHead;
428 for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext)
429 {
430 if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ
431 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW
432 && pWindow == pWindow_MainMenu)
433 {
434 pControlParam = pButton->msg_param;
435 switch (pControlParam) // backlight for buttons
436 {
437 case 0:
438 pTexture = pNew;
439 pY = 172;
440 break;
441 case 1:
442 pTexture = pLoad;
443 pY = 227;
444 break;
445 case 2:
446 pTexture = pCredits;
447 pY = 282;
448 break;
449 case 3:
450 pTexture = pExit;
451 pY = 337;
452 break;
453 }
454 pRenderer->DrawTextureIndexed(495, pY, pTexture);
455 }
456 }
457 }
458 }
459 pRenderer->EndScene();
460 pRenderer->Present();
461 }
462 MainMenu_EventLoop();
463 pRenderer->BeginScene();
464 GUI_UpdateWindows();
465 pRenderer->EndScene();
466 pRenderer->Present();
467 pTexture_PCX.Release();
468 if (pGUIWindow2)
469 {
470 pGUIWindow2->Release();
471 pGUIWindow2 = 0;
472 }
473 pWindow_MainMenu->Release();
474 pIcons_LOD->RemoveTexturesPackFromTextureList();
475 }