Mercurial > mm7
diff GUI/UI/UiGame.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 | c7264ab7132f |
children | c674d547cc7c |
line wrap: on
line diff
--- a/GUI/UI/UiGame.cpp Sat May 09 12:55:58 2015 +0200 +++ b/GUI/UI/UiGame.cpp Sun May 10 01:29:11 2015 +0200 @@ -3,18 +3,17 @@ #include <crtdbg.h> #define _CRT_SECURE_NO_WARNINGS + +#include "Engine/Engine.h" + #include "..\../Engine/Events.h" #include "..\../Engine/Graphics/Texture.h" -#include "..\../Engine/MM7.h" -#include "..\../Engine/ErrorHandling.h" #include "..\../IO/Mouse.h" #include "..\../IO/Keyboard.h" -#include "..\../Engine/mm7_data.h" #include "..\../Engine/Graphics/Vis.h" #include "..\../Engine/MapInfo.h" -#include "..\../Engine/Game.h" #include "..\../GUI/GUIWindow.h" #include "..\../GUI/GUIFont.h" #include "..\../Engine/Party.h" @@ -68,7 +67,7 @@ player->PlaySound(SPEECH_NoRoom, 0); } - if (pCurrentScreen == SCREEN_GAME) + if (current_screen_type == SCREEN_GAME) { viewparams->bRedrawGameUI = true; if ( uActiveCharacter != uPlayerID ) @@ -79,18 +78,18 @@ uActiveCharacter = uPlayerID; return; } - pGUIWindow_CurrentMenu = CharacterUI_Initialize(7); + pGUIWindow_CurrentMenu = CharacterUI_Initialize(SCREEN_CHARACTERS); return; } - if ( pCurrentScreen == SCREEN_SPELL_BOOK ) + if ( current_screen_type == SCREEN_SPELL_BOOK ) return; - if ( pCurrentScreen == SCREEN_CHEST ) + if ( current_screen_type == SCREEN_CHEST ) { viewparams->bRedrawGameUI = true; if ( uActiveCharacter == uPlayerID ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = SCREEN_CHEST_INVENTORY; + current_screen_type = SCREEN_CHEST_INVENTORY; uActiveCharacter = uPlayerID; return; } @@ -99,14 +98,14 @@ uActiveCharacter = uPlayerID; return; } - if ( pCurrentScreen != SCREEN_HOUSE ) + if ( current_screen_type != SCREEN_HOUSE ) { - if ( pCurrentScreen == SCREEN_E ) + if ( current_screen_type == SCREEN_E ) { uActiveCharacter = uPlayerID; return; } - if ( pCurrentScreen != SCREEN_CHEST_INVENTORY ) + if ( current_screen_type != SCREEN_CHEST_INVENTORY ) { viewparams->bRedrawGameUI = true; uActiveCharacter = uPlayerID; @@ -118,7 +117,7 @@ if ( uActiveCharacter == uPlayerID ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = SCREEN_CHEST_INVENTORY; + current_screen_type = SCREEN_CHEST_INVENTORY; uActiveCharacter = uPlayerID; return; } @@ -139,12 +138,10 @@ { __debugbreak(); // fix indexing pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pGUIWindow_CurrentMenu = CharacterUI_Initialize(14); + pGUIWindow_CurrentMenu = CharacterUI_Initialize(SCREEN_E); return; } } -// 4E28F8: using guessed type int pCurrentScreen; -// F8B19C: using guessed type int dword_F8B19C; //----- (00416B01) -------------------------------------------------------- void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText @@ -974,7 +971,7 @@ static bool byte_50697C = false; // 50697C byte_50697C = !byte_50697C; - if ( byte_50697C && pCurrentScreen != SCREEN_REST ) + if ( byte_50697C && current_screen_type != SCREEN_REST ) { if (bFlashQuestBook) pRenderer->DrawTextureIndexedAlpha(493, 355, pIcons_LOD->GetTexture(uTextureID_ib_td1_A)); if (bFlashAutonotesBook) pRenderer->DrawTextureIndexedAlpha(527, 353, pIcons_LOD->GetTexture(uTextureID_ib_td2_A)); @@ -1176,13 +1173,13 @@ pMouse->GetClickPos(&pX, &pY); if ( pX < 0 || pX > window->GetWidth() - 1 || pY < 0 || pY > window->GetHeight() - 1 ) return; - if ( pCurrentScreen == SCREEN_GAME ) + if ( current_screen_type == SCREEN_GAME ) { if ( pX <= (window->GetWidth() - 1) * 0.73125 && pY <= (window->GetHeight() - 1) * 0.73125 ) { //if ( pRenderer->pRenderD3D ) // inlined mm8::4C1E01 { - pickedObjectPID = pGame->pVisInstance->get_picked_object_zbuf_val(); + pickedObjectPID = pEngine->pVisInstance->get_picked_object_zbuf_val(); if ( pX < (unsigned int)pViewport->uScreen_TL_X || pX > (unsigned int)pViewport->uScreen_BR_X || pY < (unsigned int)pViewport->uScreen_TL_Y || pY > (unsigned int)pViewport->uScreen_BR_Y ) pickedObjectPID = -1; @@ -1383,7 +1380,7 @@ } //The game never gets to this point even in the original. It's also bugged(neither branch displays anything). //TODO fix these and move them up before the window check loop. - if ( pCurrentScreen == SCREEN_CHEST ) + if ( current_screen_type == SCREEN_CHEST ) { Chest::ChestUI_WritePointedObjectStatusString(); if ( uLastPointedObjectID != 0 ) @@ -1394,7 +1391,7 @@ uLastPointedObjectID = 0; return; } - else if ( pCurrentScreen == SCREEN_HOUSE ) + else if ( current_screen_type == SCREEN_HOUSE ) { if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0) @@ -1541,7 +1538,7 @@ //++v1; } //while ( v1 < 14 ); - if (pCurrentScreen == SCREEN_GAME || pCurrentScreen == SCREEN_NPC_DIALOGUE) + if (current_screen_type == SCREEN_GAME || current_screen_type == SCREEN_NPC_DIALOGUE) { if (pParty->FlyActive()) { @@ -2023,17 +2020,17 @@ //----- (00441498) -------------------------------------------------------- void GameUI_DrawTorchlightAndWizardEye() { - if (pCurrentScreen == SCREEN_GAME - || pCurrentScreen == SCREEN_MENU - || pCurrentScreen == SCREEN_OPTIONS - || pCurrentScreen == SCREEN_REST - || pCurrentScreen == SCREEN_SPELL_BOOK - || pCurrentScreen == SCREEN_CHEST - || pCurrentScreen == SCREEN_SAVEGAME - || pCurrentScreen == SCREEN_LOADGAME - || pCurrentScreen == SCREEN_CHEST_INVENTORY - || pCurrentScreen == SCREEN_BOOKS - || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) + if (current_screen_type == SCREEN_GAME + || current_screen_type == SCREEN_MENU + || current_screen_type == SCREEN_OPTIONS + || current_screen_type == SCREEN_REST + || current_screen_type == SCREEN_SPELL_BOOK + || current_screen_type == SCREEN_CHEST + || current_screen_type == SCREEN_SAVEGAME + || current_screen_type == SCREEN_LOADGAME + || current_screen_type == SCREEN_CHEST_INVENTORY + || current_screen_type == SCREEN_BOOKS + || current_screen_type == SCREEN_BRANCHLESS_NPC_DIALOG ) { if (pParty->TorchlightActive()) { @@ -2047,7 +2044,7 @@ } } } -// 4E28F8: using guessed type int pCurrentScreen; +// 4E28F8: using guessed type int current_screen_type; //----- (00491F87) --------------------------------------------------------