Mercurial > mm7
diff Game/MainMenu.cpp @ 2544:c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
author | a.parshin |
---|---|
date | Mon, 11 May 2015 09:51:04 +0200 |
parents | a902abdfc7f2 |
children | fed97f15d1e1 |
line wrap: on
line diff
--- a/Game/MainMenu.cpp Sun May 10 03:21:14 2015 +0200 +++ b/Game/MainMenu.cpp Mon May 11 09:51:04 2015 +0200 @@ -18,6 +18,15 @@ #include "Game/MainMenu.h" +GUIButton *pMainMenu_BtnExit = nullptr; +GUIButton *pMainMenu_BtnCredits = nullptr; +GUIButton *pMainMenu_BtnLoad = nullptr; +GUIButton *pMainMenu_BtnNew = nullptr; + +RGBTexture main_menu_background; + + + //----- (00435748) -------------------------------------------------------- void MainMenu_EventLoop() { @@ -51,19 +60,19 @@ switch (pUIMessageType) // For buttons of window MainMenu { case UIMSG_MainMenu_ShowPartyCreationWnd: - GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); + new OnButtonClick2(495, 172, 0, 0, (int)pMainMenu_BtnNew, 0); SetCurrentMenuID(MENU_NEWGAME); break; case UIMSG_MainMenu_ShowLoadWindow: - GUIWindow::Create(495, 227, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnLoad, 0); + new OnButtonClick2(495, 227, 0, 0, (int)pMainMenu_BtnLoad, 0); SetCurrentMenuID(MENU_SAVELOAD); break; case UIMSG_ShowCredits: - GUIWindow::Create(495, 282, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnCredits, 0); + new OnButtonClick2(495, 282, 0, 0, (int)pMainMenu_BtnCredits, 0); SetCurrentMenuID(MENU_CREDITS); break; case UIMSG_ExitToWindows: - GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); + new OnButtonClick2(495, 337, 0, 0, (int)pMainMenu_BtnExit, 0); SetCurrentMenuID(MENU_EXIT_GAME); break; case UIMSG_PlayerCreation_SelectAttribute: @@ -81,7 +90,7 @@ else --pParty->pPlayers[pParam].uVoiceID; } while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); pButton = pCreationUI_BtnPressLeft2[pParam]; - GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); + new OnButtonClick(pButton->uX, pButton->uY, 0, 0, (int)pButton, (char *)1); pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); break; @@ -92,7 +101,7 @@ pParty->pPlayers[pParam].uVoiceID = (pParty->pPlayers[pParam].uVoiceID + 1) % 20; } while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); pButton = pCreationUI_BtnPressRight2[pParam]; - GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); + new OnButtonClick(pButton->uX, pButton->uY, 0, 0, (int)pButton, (char *)1); pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); break; @@ -110,7 +119,7 @@ pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; uPlayerCreationUI_SelectedCharacter = v25; - GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressLeft[v25], (char *)1); + new OnButtonClick(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, (int)pCreationUI_BtnPressLeft[v25], (char *)1); pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0.0, 0); pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); break; @@ -126,17 +135,17 @@ pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; uPlayerCreationUI_SelectedCharacter = v21; - GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressRight[v21], (char *)1); + new OnButtonClick(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (int)pCreationUI_BtnPressRight[v21], (char *)1); pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); break; case UIMSG_PlayerCreationClickPlus: - GUIWindow::Create(613, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnPlus, (char *)1); + new OnButtonClick2(613, 393, 0, 0, (int)pPlayerCreationUI_BtnPlus, (char *)1); pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); pAudioPlayer->PlaySound(SOUND_ClickMinus, 0, 0, -1, 0, 0, 0, 0); break; case UIMSG_PlayerCreationClickMinus: - GUIWindow::Create(523, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnMinus, (char *)1); + new OnButtonClick2(523, 393, 0, 0, (int)pPlayerCreationUI_BtnMinus, (char *)1); pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); pAudioPlayer->PlaySound(SOUND_ClickPlus, 0, 0, -1, 0, 0, 0, 0); break; @@ -150,14 +159,14 @@ pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); break; case UIMSG_PlayerCreationClickOK: - GUIWindow::Create(580, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnOK, 0); + new OnButtonClick2(580, 431, 0, 0, (int)pPlayerCreationUI_BtnOK, 0); if (PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Choose4Skills()) GameUI_Footer_TimeLeft = GetTickCount() + 4000; else uGameState = GAME_STATE_STARTING_NEW_GAME; break; case UIMSG_PlayerCreationClickReset: - GUIWindow::Create(527, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnReset, 0); + new OnButtonClick2(527, 431, 0, 0, (int)pPlayerCreationUI_BtnReset, 0); pParty->Reset(); break; case UIMSG_PlayerCreationRemoveUpSkill: @@ -218,7 +227,7 @@ } break; case UIMSG_SaveLoadBtn: - GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0); + new OnSaveLoad(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnLoadSlot, 0); break; case UIMSG_DownArrow: ++pSaveListPosition; @@ -227,24 +236,24 @@ if (pSaveListPosition < 1) pSaveListPosition = 0; pWindow = pGUIWindow_CurrentMenu; - GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, WINDOW_PressedButton2, (int)pBtnDownArrow, 0); + new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, (int)pBtnDownArrow, 0); break; case UIMSG_Cancel: - GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_LoadGame_CancelBtn, (int)pBtnCancel, 0); + new OnCancel3(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, (int)pBtnCancel, 0); break; case UIMSG_ArrowUp: --pSaveListPosition; if (pSaveListPosition < 0) pSaveListPosition = 0; pWindow = pGUIWindow_CurrentMenu; - GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, WINDOW_PressedButton2, (int)pBtnArrowUp, 0); + new OnButtonClick2(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, (int)pBtnArrowUp, 0); break; case UIMSG_AD: - GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); + new OnButtonClick2(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (int)pMainMenu_BtnNew, 0); SetCurrentMenuID(MENU_LoadingProcInMainMenu); break; case UIMSG_AE: - GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); + new OnButtonClick2(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (int)pMainMenu_BtnExit, 0); SetCurrentMenuID(MENU_DebugBLVLevel); break; case UIMSG_Escape: @@ -298,8 +307,8 @@ { pIcons_LOD->RemoveTexturesPackFromTextureList(); //crt_deconstruct_ptr_6A0118(); - pTexture_PCX.Release(); - pTexture_PCX.Load("title.pcx", 0); + main_menu_background.Release(); + main_menu_background.Load("title.pcx", 0); SetCurrentMenuID(MENU_MAIN); v15 = 1; pGUIWindow_CurrentMenu->Release(); @@ -355,7 +364,7 @@ pIcons_LOD->_inlined_sub2(); - pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); + pWindow_MainMenu = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); @@ -366,8 +375,8 @@ pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); - pTexture_PCX.Release(); - pTexture_PCX.Load("title.pcx", 0); + main_menu_background.Release(); + main_menu_background.Load("title.pcx", 0); SetCurrentMenuID(MENU_MAIN); SetForegroundWindow(window->GetApiHandle()); SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); @@ -380,9 +389,9 @@ { if (current_screen_type != SCREEN_LOADGAME) { - pTexture_PCX.Release(); - pTexture_PCX.Load("lsave640.pcx", 0); - pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); + main_menu_background.Release(); + main_menu_background.Load("lsave640.pcx", 0); + pGUIWindow2 = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); current_screen_type = SCREEN_LOADGAME; LoadUI_Load(0); } @@ -404,7 +413,7 @@ } pRenderer->BeginScene(); - pRenderer->DrawTextureNew(0, 0, &pTexture_PCX); + pRenderer->DrawTextureNew(0, 0, &main_menu_background); MainMenu_EventLoop(); GUI_UpdateWindows(); @@ -464,7 +473,7 @@ GUI_UpdateWindows(); pRenderer->EndScene(); pRenderer->Present(); - pTexture_PCX.Release(); + main_menu_background.Release(); if (pGUIWindow2) { pGUIWindow2->Release();