Mercurial > mm7
comparison Game/MainMenu.cpp @ 2552:ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
author | a.parshin |
---|---|
date | Wed, 13 May 2015 01:33:20 +0200 |
parents | 4008b2f34be0 |
children | 48708da03b7f |
comparison
equal
deleted
inserted
replaced
2551:4008b2f34be0 | 2552:ac16f4a3a91e |
---|---|
15 #include "GUI/GUIButton.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 #include "Game/MainMenuLoad.h" | |
20 | 21 |
21 | 22 |
22 RGBTexture main_menu_background; | 23 RGBTexture main_menu_background; |
23 | 24 |
24 | 25 |
59 new OnButtonClick2(495, 172, 0, 0, (int)pMainMenu_BtnNew, 0); | 60 new OnButtonClick2(495, 172, 0, 0, (int)pMainMenu_BtnNew, 0); |
60 SetCurrentMenuID(MENU_NEWGAME); | 61 SetCurrentMenuID(MENU_NEWGAME); |
61 break; | 62 break; |
62 case UIMSG_MainMenu_ShowLoadWindow: | 63 case UIMSG_MainMenu_ShowLoadWindow: |
63 new OnButtonClick2(495, 227, 0, 0, (int)pMainMenu_BtnLoad, 0); | 64 new OnButtonClick2(495, 227, 0, 0, (int)pMainMenu_BtnLoad, 0); |
64 SetCurrentMenuID(MENU_SAVELOAD); | 65 //SetCurrentMenuID(MENU_SAVELOAD); |
66 MainMenuLoad_Loop(); | |
65 break; | 67 break; |
66 case UIMSG_ShowCredits: | 68 case UIMSG_ShowCredits: |
67 new OnButtonClick2(495, 282, 0, 0, (int)pMainMenu_BtnCredits, 0); | 69 new OnButtonClick2(495, 282, 0, 0, (int)pMainMenu_BtnCredits, 0); |
68 SetCurrentMenuID(MENU_CREDITS); | 70 SetCurrentMenuID(MENU_CREDITS); |
69 break; | 71 break; |
188 uGameState = GAME_FINISHED; | 190 uGameState = GAME_FINISHED; |
189 break; | 191 break; |
190 case UIMSG_ChangeCursor: | 192 case UIMSG_ChangeCursor: |
191 pMouse->SetCursorBitmap("MICON2"); | 193 pMouse->SetCursorBitmap("MICON2"); |
192 break; | 194 break; |
193 case UIMSG_3A: | 195 case UIMSG_DebugBlv: |
196 __debugbreak();//some debugging tool | |
194 SetCurrentMenuID(MENU_DebugBLVLevel); | 197 SetCurrentMenuID(MENU_DebugBLVLevel); |
195 break; | 198 break; |
196 case UIMSG_LoadGame: | 199 /*case UIMSG_LoadGame: |
197 if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot]) | 200 if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot]) |
198 break; | 201 break; |
199 SetCurrentMenuID(MENU_LoadingProcInMainMenu); | 202 SetCurrentMenuID(MENU_LoadingProcInMainMenu); |
200 break; | 203 break; |
201 case UIMSG_SelectLoadSlot: | 204 case UIMSG_SelectLoadSlot: |
231 pSaveListPosition = pParam - 1; | 234 pSaveListPosition = pParam - 1; |
232 if (pSaveListPosition < 1) | 235 if (pSaveListPosition < 1) |
233 pSaveListPosition = 0; | 236 pSaveListPosition = 0; |
234 pWindow = pGUIWindow_CurrentMenu; | 237 pWindow = pGUIWindow_CurrentMenu; |
235 new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, (int)pBtnDownArrow, 0); | 238 new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, (int)pBtnDownArrow, 0); |
236 break; | 239 break;*/ |
237 case UIMSG_Cancel: | 240 case UIMSG_Cancel: |
238 new OnCancel3(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnCancel, 0); | 241 new OnCancel3(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnCancel, 0); |
239 break; | 242 break; |
240 case UIMSG_ArrowUp: | 243 /*case UIMSG_ArrowUp: |
241 --pSaveListPosition; | 244 --pSaveListPosition; |
242 if (pSaveListPosition < 0) | 245 if (pSaveListPosition < 0) |
243 pSaveListPosition = 0; | 246 pSaveListPosition = 0; |
244 pWindow = pGUIWindow_CurrentMenu; | 247 pWindow = pGUIWindow_CurrentMenu; |
245 new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, (int)pBtnArrowUp, 0); | 248 new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, (int)pBtnArrowUp, 0); |
246 break; | 249 break;*/ |
247 case UIMSG_AD: | 250 case UIMSG_AD: |
251 __debugbreak();//some debugging tool | |
248 new OnButtonClick2(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (int)pMainMenu_BtnNew, 0); | 252 new OnButtonClick2(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (int)pMainMenu_BtnNew, 0); |
249 SetCurrentMenuID(MENU_LoadingProcInMainMenu); | 253 SetCurrentMenuID(MENU_LoadingProcInMainMenu); |
250 break; | 254 break; |
251 case UIMSG_AE: | 255 case UIMSG_DebugBlv2: |
256 __debugbreak();//some debugging tool | |
252 new OnButtonClick2(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (int)pMainMenu_BtnExit, 0); | 257 new OnButtonClick2(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (int)pMainMenu_BtnExit, 0); |
253 SetCurrentMenuID(MENU_DebugBLVLevel); | 258 SetCurrentMenuID(MENU_DebugBLVLevel); |
254 break; | 259 break; |
255 case UIMSG_Escape: | 260 case UIMSG_Escape: |
256 if (pModalWindow) | 261 if (pModalWindow) |
281 break; | 286 break; |
282 } | 287 } |
283 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); | 288 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); |
284 break; | 289 break; |
285 } | 290 } |
286 if (GetCurrentMenuID() == MENU_CREDITSPROC && !current_screen_type) | 291 if (GetCurrentMenuID() == MENU_CREDITSPROC && current_screen_type == SCREEN_GAME) |
287 { | 292 { |
288 //if ( current_screen_type == SCREEN_VIDEO ) | 293 //if ( current_screen_type == SCREEN_VIDEO ) |
289 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); | 294 //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); |
290 if (GetCurrentMenuID() == MENU_NAMEPANELESC) | 295 if (GetCurrentMenuID() == MENU_NAMEPANELESC) |
291 { | 296 { |
298 break; | 303 break; |
299 } | 304 } |
300 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); | 305 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); |
301 break; | 306 break; |
302 } | 307 } |
303 if (current_screen_type == SCREEN_LOADGAME) | 308 /*if (current_screen_type == SCREEN_LOADGAME) |
304 { | 309 { |
305 pIcons_LOD->RemoveTexturesPackFromTextureList(); | 310 pIcons_LOD->RemoveTexturesPackFromTextureList(); |
306 //crt_deconstruct_ptr_6A0118(); | 311 //crt_deconstruct_ptr_6A0118(); |
307 main_menu_background.Release(); | 312 main_menu_background.Release(); |
308 main_menu_background.Load("title.pcx", 0); | 313 main_menu_background.Load("title.pcx", 0); |
313 pGUIWindow2 = 0; | 318 pGUIWindow2 = 0; |
314 pEventTimer->Resume(); | 319 pEventTimer->Resume(); |
315 current_screen_type = SCREEN_GAME; | 320 current_screen_type = SCREEN_GAME; |
316 viewparams->bRedrawGameUI = v15; | 321 viewparams->bRedrawGameUI = v15; |
317 break; | 322 break; |
318 } | 323 }*/ |
319 if (current_screen_type == SCREEN_VIDEO) | 324 if (current_screen_type == SCREEN_VIDEO) |
320 { | 325 { |
321 //pVideoPlayer->Unload(); | 326 //pVideoPlayer->Unload(); |
322 } | 327 } |
323 else | 328 else |
324 { | 329 { |
325 if (current_screen_type != SCREEN_1B) | 330 if (current_screen_type != SCREEN_1B) |
326 { | 331 { // MENU_CREDITSCLOSE for example |
327 pGUIWindow_CurrentMenu->Release(); | 332 if (pGUIWindow_CurrentMenu) |
328 pGUIWindow2->Release(); | 333 { |
329 pGUIWindow2 = 0; | 334 pGUIWindow_CurrentMenu->Release(); |
335 pGUIWindow_CurrentMenu = nullptr; | |
336 } | |
337 if (pGUIWindow2) | |
338 { | |
339 pGUIWindow2->Release(); | |
340 pGUIWindow2 = 0; | |
341 } | |
330 pEventTimer->Resume(); | 342 pEventTimer->Resume(); |
331 current_screen_type = SCREEN_GAME; | 343 current_screen_type = SCREEN_GAME; |
332 viewparams->bRedrawGameUI = v15; | 344 viewparams->bRedrawGameUI = v15; |
333 break; | 345 break; |
334 } | 346 } |
366 main_menu_background.Release(); | 378 main_menu_background.Release(); |
367 main_menu_background.Load("title.pcx", 0); | 379 main_menu_background.Load("title.pcx", 0); |
368 SetCurrentMenuID(MENU_MAIN); | 380 SetCurrentMenuID(MENU_MAIN); |
369 SetForegroundWindow(window->GetApiHandle()); | 381 SetForegroundWindow(window->GetApiHandle()); |
370 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); | 382 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); |
371 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) | 383 |
384 //while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) | |
385 while (GetCurrentMenuID() == MENU_MAIN) | |
372 { | 386 { |
373 POINT pt; | 387 POINT pt; |
374 pMouse->GetCursorPos(&pt); | 388 pMouse->GetCursorPos(&pt); |
375 pWindow = pWindow_MainMenu; | 389 pWindow = pWindow_MainMenu; |
376 if (GetCurrentMenuID() == MENU_SAVELOAD) | 390 /*if (GetCurrentMenuID() == MENU_SAVELOAD) |
377 { | 391 { |
378 if (current_screen_type != SCREEN_LOADGAME) | 392 if (current_screen_type != SCREEN_LOADGAME) |
379 { | 393 { |
380 main_menu_background.Release(); | 394 main_menu_background.Release(); |
381 main_menu_background.Load("lsave640.pcx", 0); | 395 main_menu_background.Load("lsave640.pcx", 0); |
383 | 397 |
384 //LoadUI_Load(0); | 398 //LoadUI_Load(0); |
385 pGUIWindow_CurrentMenu = new GUIWindow_Load(false); | 399 pGUIWindow_CurrentMenu = new GUIWindow_Load(false); |
386 } | 400 } |
387 pWindow = pGUIWindow_CurrentMenu; | 401 pWindow = pGUIWindow_CurrentMenu; |
388 } | 402 }*/ |
389 | 403 |
390 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) | 404 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) |
391 { | 405 { |
392 if (msg.message == WM_QUIT) | 406 if (msg.message == WM_QUIT) |
393 Engine_DeinitializeAndTerminate(0); | 407 Engine_DeinitializeAndTerminate(0); |
415 pRenderer->BeginScene(); | 429 pRenderer->BeginScene(); |
416 GUI_UpdateWindows(); | 430 GUI_UpdateWindows(); |
417 pRenderer->EndScene(); | 431 pRenderer->EndScene(); |
418 pRenderer->Present(); | 432 pRenderer->Present(); |
419 main_menu_background.Release(); | 433 main_menu_background.Release(); |
420 if (pGUIWindow2) | 434 /*if (pGUIWindow2) |
421 { | 435 { |
422 pGUIWindow2->Release(); | 436 pGUIWindow2->Release(); |
423 pGUIWindow2 = 0; | 437 pGUIWindow2 = 0; |
424 } | 438 }*/ |
425 pWindow_MainMenu->Release(); | 439 pWindow_MainMenu->Release(); |
426 pIcons_LOD->RemoveTexturesPackFromTextureList(); | 440 pIcons_LOD->RemoveTexturesPackFromTextureList(); |
427 } | 441 } |