Mercurial > mm7
diff GUI/UI/UICharacter.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 | bacf9809126a |
line wrap: on
line diff
--- a/GUI/UI/UICharacter.cpp Sat May 09 12:55:58 2015 +0200 +++ b/GUI/UI/UICharacter.cpp Sun May 10 01:29:11 2015 +0200 @@ -4,10 +4,11 @@ #define _CRT_SECURE_NO_WARNINGS #include <algorithm> + +#include "Engine/Engine.h" + #include "UICharacter.h" -#include "..\../Engine/MM7.h" #include "..\../Engine/MapInfo.h" -#include "..\../Engine/Game.h" #include "..\../GUI/GUIWindow.h" #include "..\../GUI/GUIFont.h" #include "..\../GUI/GUIProgressBar.h" @@ -22,7 +23,7 @@ #include "..\../Engine/texts.h" #include "..\../IO/Mouse.h" -#include "..\../Engine/mm7_data.h" + int bRingsShownInCharScreen; // 5118E0 @@ -386,10 +387,8 @@ PLAYER_SKILL_MIND, PLAYER_SKILL_BODY, PLAYER_SKILL_LIGHT, PLAYER_SKILL_DARK}; //----- (00421626) -------------------------------------------------------- -GUIWindow *CharacterUI_Initialize(unsigned int _this) +GUIWindow *CharacterUI_Initialize(enum CURRENT_SCREEN screen) { - GUIWindow *pWindow; // edi@3 - ++pIcons_LOD->uTexturePacksCount; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; @@ -398,51 +397,52 @@ pAudioPlayer->StopChannels(-1, -1); bRingsShownInCharScreen = false; CharacterUI_LoadPaperdollTextures(); - pCurrentScreen = _this; + current_screen_type = screen; - pWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CharacterRecord, uActiveCharacter, 0); - pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308, + auto wnd = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CharacterRecord, uActiveCharacter, 0); + pCharacterScreen_StatsBtn = wnd->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308, pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureWidth, pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureHeight, 1, 0, UIMSG_ClickStatsBtn, 0, 'S', pGlobalTXT_LocalizationStrings[216],// Stats pIcons_LOD->GetTexture(papredoll_dbrds[10]), pIcons_LOD->GetTexture(papredoll_dbrds[9]), 0); - pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308, + pCharacterScreen_SkillsBtn = wnd->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308, pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureWidth, pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureHeight, 1, 0, UIMSG_ClickSkillsBtn, 0, 'K', pGlobalTXT_LocalizationStrings[205],//Skills pIcons_LOD->GetTexture(papredoll_dbrds[8]), pIcons_LOD->GetTexture(papredoll_dbrds[7]), 0); - pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308, + pCharacterScreen_InventoryBtn = wnd->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308, pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureWidth, pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureHeight, 1, 0, UIMSG_ClickInventoryBtn, 0, 'I', pGlobalTXT_LocalizationStrings[120], //Inventory pIcons_LOD->GetTexture(papredoll_dbrds[6]), pIcons_LOD->GetTexture(papredoll_dbrds[5]), 0); - pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308, + pCharacterScreen_AwardsBtn = wnd->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308, pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureWidth, pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureHeight, 1, 0, UIMSG_ClickAwardsBtn, 0, 'A', pGlobalTXT_LocalizationStrings[22], //Awards pIcons_LOD->GetTexture(papredoll_dbrds[4]), pIcons_LOD->GetTexture(papredoll_dbrds[3]), 0); - pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308, + pCharacterScreen_ExitBtn = wnd->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308, pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureWidth, pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureHeight, 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit pIcons_LOD->GetTexture(papredoll_dbrds[2]), pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0); - pWindow->CreateButton(0, 0, 476, 345, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0); - pCharacterScreen_DetalizBtn = pWindow->CreateButton(600, 300, 30, 30, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0); - pCharacterScreen_DollBtn = pWindow->CreateButton(476, 0, 164, 345, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0); + wnd->CreateButton(0, 0, 476, 345, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0); + pCharacterScreen_DetalizBtn = wnd->CreateButton(600, 300, 30, 30, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0); + pCharacterScreen_DollBtn = wnd->CreateButton(476, 0, 164, 345, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0); - pWindow->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); - pWindow->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); - pWindow->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); - pWindow->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + wnd->CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + wnd->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + wnd->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + wnd->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); - pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); + wnd->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); FillAwardsData(); - return pWindow; + + return wnd; } //----- (004219BE) -------------------------------------------------------- @@ -454,7 +454,7 @@ pAudioPlayer->StopChannels(-1, -1); bRingsShownInCharScreen = 0; CharacterUI_LoadPaperdollTextures(); - pCurrentScreen = SCREEN_CASTING; + current_screen_type = SCREEN_CASTING; CS_inventory_window = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell_InInventory, (int)this, 0); pCharacterScreen_ExitBtn = CS_inventory_window->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0, pGlobalTXT_LocalizationStrings[79], // Close @@ -1546,7 +1546,7 @@ } else { - if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].IsIdentified() || pCurrentScreen != SCREEN_HOUSE) + if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].IsIdentified() || current_screen_type != SCREEN_HOUSE) { if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].IsBroken()) pRenderer->DrawTransparentRedShade(uCellX, uCellY, pTexture);