Mercurial > mm7
diff GUI/GUIWindow.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 | 9ec6b8be16fe |
children | bacf9809126a |
line wrap: on
line diff
--- a/GUI/GUIWindow.cpp Sat May 09 12:55:58 2015 +0200 +++ b/GUI/GUIWindow.cpp Sun May 10 01:29:11 2015 +0200 @@ -3,7 +3,7 @@ #include <crtdbg.h> #define _CRT_SECURE_NO_WARNINGS -#include "Engine/ErrorHandling.h" +#include "Engine/Engine.h" #include "GUIWindow.h" #include "GUIFont.h" @@ -23,7 +23,6 @@ #include "Engine/Awards.h" #include "Engine/Objects/Chest.h" #include "Engine/Graphics/Outdoor.h" -#include "Engine/Game.h" #include "Engine/Tables/IconFrameTable.h" #include "Engine/Objects/Actor.h" @@ -258,7 +257,7 @@ case WINDOW_GreetingNPC: { pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = pMainScreenNum; + current_screen_type = prev_screen_type; pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED); break; } @@ -275,7 +274,7 @@ if ( bFlipOnExit ) { pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (stru_5C6E00->uIntegerPi + pParty->sRotationY); - pGame->pIndoorCameraD3D->sRotationY = pParty->sRotationY; + pEngine->pIndoorCameraD3D->sRotationY = pParty->sRotationY; } pParty->uFlags |= 2u; break; @@ -286,7 +285,7 @@ pTexture_outside->Release(); pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = pMainScreenNum; + current_screen_type = prev_screen_type; break; } case WINDOW_SpellBook: @@ -305,7 +304,7 @@ pTexture_outside->Release(); pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = pMainScreenNum; + current_screen_type = prev_screen_type; break; } case WINDOW_Dialogue: @@ -316,7 +315,7 @@ pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = pMainScreenNum; + current_screen_type = prev_screen_type; break; } case WINDOW_null: @@ -375,7 +374,7 @@ pAudioPlayer->StopChannels(-1, -1); InitializeBookFonts(); this->CreateButton(475, 445, 158, 34, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close - pCurrentScreen = SCREEN_BOOKS; + current_screen_type = SCREEN_BOOKS; full_num_items_in_book = 0; books_primary_item_per_page = 0; books_page_number = 0; @@ -896,7 +895,7 @@ v4 = (char *)pDialogueNPCCount - 1; pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[(signed int)v4]); - if ( pCurrentScreen == SCREEN_E ) + if ( current_screen_type == SCREEN_E ) { CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) @@ -1438,8 +1437,8 @@ break; } case WINDOW_Dialogue: { - pMainScreenNum = pCurrentScreen; - pCurrentScreen = SCREEN_NPC_DIALOGUE; + prev_screen_type = current_screen_type; + current_screen_type = SCREEN_NPC_DIALOGUE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit" pIcons_LOD->GetTexture(uExitCancelTextureId), 0); if ( pWindow->par1C != 1 ) @@ -1530,8 +1529,8 @@ } case WINDOW_ChangeLocation: { - pMainScreenNum = pCurrentScreen; - pCurrentScreen = SCREEN_CHANGE_LOCATION; + prev_screen_type = current_screen_type; + current_screen_type = SCREEN_CHANGE_LOCATION; pBtn_ExitCancel = pWindow->CreateButton( 566, 445, 75, 33, 1, 0, UIMSG_CHANGE_LOCATION_ClickCencelBtn, 0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//Остаться в этой области pBtn_YES = pWindow->CreateButton( 486, 445, 75, 33, 1, 0, UIMSG_OnTravelByFoot, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0); pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', pWindow->Hint, 0, 0, 0); @@ -1544,9 +1543,9 @@ break; } case WINDOW_GreetingNPC: {// окно приветствия НПС - pMainScreenNum = pCurrentScreen; + prev_screen_type = current_screen_type; pKeyActionMap->EnterText(0, 15, pWindow); - pCurrentScreen = SCREEN_BRANCHLESS_NPC_DIALOG; + current_screen_type = SCREEN_BRANCHLESS_NPC_DIALOG; break; } @@ -1563,7 +1562,7 @@ } if (eWindowType == WINDOW_HouseInterior) { - pCurrentScreen = SCREEN_HOUSE; + current_screen_type = SCREEN_HOUSE; pBtn_ExitCancel = pWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[80],//Выйти из здания pIcons_LOD->GetTexture(uExitCancelTextureId), 0); for ( v26 = 0; v26 < uNumDialogueNPCPortraits; ++v26 ) @@ -1597,8 +1596,8 @@ { if (eWindowType == WINDOW_Transition) { - pMainScreenNum = pCurrentScreen; - pCurrentScreen = SCREEN_INPUT_BLV; + prev_screen_type = current_screen_type; + current_screen_type = SCREEN_INPUT_BLV; pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//Отмена pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0); pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, pWindow->Hint, 0); @@ -1630,7 +1629,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);//Выбрать цель ++pIcons_LOD->uTexturePacksCount; pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = SCREEN_CASTING; + current_screen_type = SCREEN_CASTING; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; } @@ -1748,11 +1747,11 @@ } case WINDOW_Chest: { - if ( pCurrentScreen == SCREEN_CHEST ) + if ( current_screen_type == SCREEN_CHEST ) { Chest::DrawChestUI(pWindow->par1C); } - else if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) + else if ( current_screen_type == SCREEN_CHEST_INVENTORY ) { pRenderer->ClearZBuffer(0, 479); draw_leather(); @@ -1829,7 +1828,7 @@ pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0); pEventTimer->Resume(); ptr_507BD0->Release(); - pCurrentScreen = SCREEN_GAME; + current_screen_type = SCREEN_GAME; viewparams->bRedrawGameUI = true; continue; } @@ -1851,7 +1850,7 @@ ItemGen2.Reset(); pWindow->Release(); pEventTimer->Resume(); - pCurrentScreen = 0; + current_screen_type = SCREEN_GAME; viewparams->bRedrawGameUI = true; v26 = atoi(pKeyActionMap->pPressedKeysBuffer); if ( v26 > 0 ) @@ -1957,7 +1956,7 @@ if ( pHint && pHint != (char *)1 ) pButton->DrawLabel(pHint, pFontCreate, 0, 0); pWindow->Release(); - if (pCurrentScreen == SCREEN_SAVEGAME) + if (current_screen_type == SCREEN_SAVEGAME) pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveGame, 0, 0); else pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); @@ -2042,7 +2041,7 @@ ItemGen2.Reset(); pWindow->Release(); pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; + current_screen_type = SCREEN_GAME; viewparams->bRedrawGameUI = 1; v39 = atoi(pKeyActionMap->pPressedKeysBuffer); if ( v39 > 0 ) @@ -2105,15 +2104,15 @@ Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3); } -int modal_window_prev_screen; +enum CURRENT_SCREEN modal_window_prev_screen_type; //----- (004141CA) -------------------------------------------------------- void ModalWindow(const char *pStrHint, UIMessageType OnRelease_message) { pEventTimer->Pause(); - modal_window_prev_screen = pCurrentScreen; + modal_window_prev_screen_type = current_screen_type; pModalWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_ModalWindow, OnRelease_message, pStrHint); - pCurrentScreen = SCREEN_MODAL_WINDOW; + current_screen_type = SCREEN_MODAL_WINDOW; } //----- (0041420D) -------------------------------------------------------- @@ -2140,7 +2139,7 @@ pModalWindow->Release(); pModalWindow = nullptr; - pCurrentScreen = modal_window_prev_screen; + current_screen_type = modal_window_prev_screen_type; pEventTimer->Resume(); } @@ -2587,7 +2586,7 @@ } -// 4E28F8: using guessed type int pCurrentScreen; +// 4E28F8: using guessed type int current_screen_type; //----- (0040F82D) -------------------------------------------------------- void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue) @@ -2684,7 +2683,7 @@ if (uActiveCharacter) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); if (!dword_7241C8) - pGame->Draw(); + pEngine->Draw(); dword_7241C8 = 0; return; } @@ -2794,7 +2793,7 @@ } } if (!dword_7241C8) - pGame->Draw(); + pEngine->Draw(); dword_7241C8 = 0; }