changeset 2402:8cee51ce4382

included directx 11
author Ritor1
date Mon, 14 Jul 2014 10:03:44 +0600
parents ecd1dd95ec49
children 069018761f96
files Build/Visual Studio 2010/World of Might and Magic.vcxproj Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters CastSpellInfo.cpp DirectX11.cpp DirectX11.h GUIWindow.cpp GUIWindow.h Game.cpp Indoor.cpp Keyboard.cpp Mouse.cpp NPC.cpp OSWindow.cpp Party.cpp Player.cpp Render.h UI/Books/UIMapBook.cpp UI/UIArena.cpp UI/UIGuilds.cpp UI/UIHouses.cpp UI/UIPartyCreation.cpp UI/UIPopup.cpp UI/UISaveLoad.cpp UI/UiGame.cpp Viewport.cpp _deleted.cpp mm7_2.cpp mm7_4.cpp
diffstat 28 files changed, 341 insertions(+), 205 deletions(-) [+]
line wrap: on
line diff
--- a/Build/Visual Studio 2010/World of Might and Magic.vcxproj	Thu Jul 10 01:48:39 2014 +0200
+++ b/Build/Visual Studio 2010/World of Might and Magic.vcxproj	Mon Jul 14 10:03:44 2014 +0600
@@ -99,6 +99,7 @@
     <ClCompile Include="..\..\CShow.cpp" />
     <ClCompile Include="..\..\DecalBuilder.cpp" />
     <ClCompile Include="..\..\DecorationList.cpp" />
+    <ClCompile Include="..\..\DirectX11.cpp" />
     <ClCompile Include="..\..\Events.cpp" />
     <ClCompile Include="..\..\FrameTableInc.cpp" />
     <ClCompile Include="..\..\Game.cpp" />
@@ -265,6 +266,7 @@
     <ClInclude Include="..\..\CShow.h" />
     <ClInclude Include="..\..\DecalBuilder.h" />
     <ClInclude Include="..\..\DecorationList.h" />
+    <ClInclude Include="..\..\DirectX11.h" />
     <ClInclude Include="..\..\ErrorHandling.h" />
     <ClInclude Include="..\..\Events.h" />
     <ClInclude Include="..\..\Events2D.h" />
--- a/Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters	Thu Jul 10 01:48:39 2014 +0200
+++ b/Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters	Mon Jul 14 10:03:44 2014 +0600
@@ -532,6 +532,7 @@
     <ClInclude Include="..\..\UI\UIArena.h">
       <Filter>UI</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\DirectX11.h" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="lib">
@@ -964,6 +965,7 @@
     <ClCompile Include="..\..\UI\UIArena.cpp">
       <Filter>UI</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\DirectX11.cpp" />
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="..\..\NewUI\Core\UIControlModule.swig">
--- a/CastSpellInfo.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/CastSpellInfo.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -1702,7 +1702,7 @@
           continue;
         }
         town_portal_caster_id = pCastSpell->uPlayerID;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastTownPortal, 0, 0);
         spell_sound_flag = true;
         break;
       }
@@ -1718,7 +1718,7 @@
         if ( pPlayer->sMana >= (signed int)uRequiredMana )
         {
           pEventTimer->Pause();
-          pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastLloydsBeacon, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastLloydsBeacon, 0, 0);
           lloyds_beacon_spell_level = (signed int)(604800 * spell_level);
           _506348_current_lloyd_playerid = pCastSpell->uPlayerID;
           ::uRequiredMana = uRequiredMana;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DirectX11.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -0,0 +1,105 @@
+#define WIN32_LEAN_AND_MEAN
+
+#include "DirectX11.h"
+
+HRESULT D3D11::InitDevice()
+{
+  HRESULT hr = S_OK;
+  RECT rc;
+  GetClientRect( g_hWnd, &rc );
+  UINT width = rc.right - rc.left;           // получаем ширину
+  UINT height = rc.bottom - rc.top;          // и высоту окна
+  UINT createDeviceFlags = 0;
+  D3D_DRIVER_TYPE driverTypes[] =
+  {
+    D3D_DRIVER_TYPE_HARDWARE,
+    D3D_DRIVER_TYPE_WARP,
+    D3D_DRIVER_TYPE_REFERENCE,
+  };
+  UINT numDriverTypes = ARRAYSIZE( driverTypes );
+
+ // Тут мы создаем список поддерживаемых версий DirectX
+  D3D_FEATURE_LEVEL featureLevels[] =
+  {
+    D3D_FEATURE_LEVEL_11_0,
+    D3D_FEATURE_LEVEL_10_1,
+    D3D_FEATURE_LEVEL_10_0,
+  };
+  UINT numFeatureLevels = ARRAYSIZE( featureLevels );
+
+  // Сейчас мы создадим устройства DirectX. Для начала заполним структуру,
+  // которая описывает свойства переднего буфера и привязывает его к нашему окну.
+  DXGI_SWAP_CHAIN_DESC sd;            // Структура, описывающая цепь связи (Swap Chain)
+  ZeroMemory( &sd, sizeof( sd ) );    // очищаем ее
+  sd.BufferCount = 1;                               // у нас один задний буфер
+  sd.BufferDesc.Width = width;                     // ширина буфера
+  sd.BufferDesc.Height = height;                          // высота буфера
+  sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;      // формат пикселя в буфере
+  sd.BufferDesc.RefreshRate.Numerator = 75;         // частота обновления экрана
+  sd.BufferDesc.RefreshRate.Denominator = 1;
+  sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // назначение буфера - задний буфер
+  sd.OutputWindow = g_hWnd;                               // привязываем к нашему окну
+  sd.SampleDesc.Count = 1;
+  sd.SampleDesc.Quality = 0;
+  sd.Windowed = TRUE;                               // не полноэкранный режим
+
+  for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )
+  {
+    g_driverType = driverTypes[driverTypeIndex];
+    hr = D3D11CreateDeviceAndSwapChain ( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext );
+    if (SUCCEEDED(hr)) // Если устройства созданы успешно, то выходим из цикла
+      break;
+  }
+  if (FAILED(hr)) return hr;
+
+  // Теперь создаем задний буфер. Обратите внимание, в SDK
+  // RenderTargetOutput - это передний буфер, а RenderTargetView - задний.
+  ID3D11Texture2D* pBackBuffer = NULL;
+  hr = g_pSwapChain->GetBuffer( 0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer );
+  if (FAILED(hr)) return hr;
+
+  // интерфейс g_pd3dDevice будет использоваться для создания остальных объектов
+  hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );
+  pBackBuffer->Release();
+  if (FAILED(hr)) return hr;
+
+  // Подключаем объект заднего буфера к контексту устройства
+  g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );
+
+  // Настройка вьюпорта
+  D3D11_VIEWPORT vp;
+  vp.Width = (FLOAT)width;
+  vp.Height = (FLOAT)height;
+  vp.MinDepth = 0.0f;
+  vp.MaxDepth = 1.0f;
+  vp.TopLeftX = 0;
+  vp.TopLeftY = 0;
+
+  // Подключаем вьюпорт к контексту устройства
+  g_pImmediateContext->RSSetViewports (1, &vp);
+
+  return S_OK;
+}
+
+//--------------------------------------------------------------------------------------
+// Удалить все созданные объекты
+//--------------------------------------------------------------------------------------
+void D3D11::CleanupDevice()
+{
+  // Сначала отключим контекст устройства, потом отпустим объекты.
+  if( g_pImmediateContext ) g_pImmediateContext->ClearState();
+
+  //  удалеям объекты в порядке, обратном тому, в котором создавали.
+  if( g_pRenderTargetView ) g_pRenderTargetView->Release();
+
+  if( g_pSwapChain ) g_pSwapChain->Release();
+
+  if( g_pImmediateContext ) g_pImmediateContext->Release();
+
+  if( g_pd3dDevice ) g_pd3dDevice->Release();
+}
+
+void Render()
+{
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DirectX11.h	Mon Jul 14 10:03:44 2014 +0600
@@ -0,0 +1,31 @@
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include <MMSystem.h>
+
+#include <d3d11.h>
+#pragma comment(lib, "d3d11.lib")
+#pragma comment(lib, "winmm.lib")
+
+class D3D11
+{
+  HINSTANCE               g_hInst;
+  HWND                    g_hWnd;
+  D3D_DRIVER_TYPE         g_driverType;   //Этот параметр указывает, производить вычисления в видеокарте или в центральном процессоре. 
+  D3D_FEATURE_LEVEL       g_featureLevel; //параметр, указывающий, какую версию DirectX поддерживает наша видеокарта.
+  ID3D11Device*           g_pd3dDevice;
+  ID3D11DeviceContext*    g_pImmediateContext;
+  IDXGISwapChain*         g_pSwapChain;
+  ID3D11RenderTargetView* g_pRenderTargetView;
+
+
+public:
+
+  D3D11():
+  g_hInst(NULL), g_hWnd(NULL), g_driverType(D3D_DRIVER_TYPE_NULL), g_featureLevel(D3D_FEATURE_LEVEL_11_0),
+  g_pd3dDevice(NULL), g_pImmediateContext(NULL), g_pSwapChain(NULL), g_pRenderTargetView(NULL){}
+
+  HRESULT InitDevice();      // Инициализация устройств DirectX
+  void CleanupDevice();      // Удаление созданнных устройств DirectX
+  void Render();             // Функция рисования
+};
--- a/GUIWindow.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/GUIWindow.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -170,7 +170,7 @@
 	{
 	  if ( result->uHotkey == v3 )
 	  {
-		pMessageQueue_50CBD0->AddMessage(result->msg, result->msg_param, 0);
+		pMessageQueue_50CBD0->AddGUIMessage(result->msg, result->msg_param, 0);
 		return result;
 	  }
 	}
@@ -1837,7 +1837,7 @@
           continue;
         }
         pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
         continue;
       }
       case WINDOW_Transition:
@@ -1878,7 +1878,7 @@
         if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
         {
           pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-          pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0);
           pEventTimer->Resume();
           ptr_507BD0->Release();
           pCurrentScreen = SCREEN_GAME;
@@ -2010,9 +2010,9 @@
           pButton->DrawLabel(pHint, pFontCreate, 0, 0);
         pWindow->Release();
         if (pCurrentScreen == SCREEN_SAVEGAME)
-          pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveGame, 0, 0);
         else
-          pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0);
         continue;
       }
       case WINDOW_LoadGame_CancelBtn:
@@ -2025,7 +2025,7 @@
         if ( pWindow->Hint && pWindow->Hint != (char *)1 )
           pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
         pWindow->Release();
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
         continue;
       }
       case WINDOW_CloseRestWindowBtn:
@@ -2039,7 +2039,7 @@
         if ( pHint && pHint != (char *)1 )
           pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0);
         pWindow->Release();
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
         continue;
       }
       case WINDOW_ExitCharacterWindow:
@@ -2054,7 +2054,7 @@
           pButton->DrawLabel(pHint, pFontCreate, 0, 0);
         pWindow->Release();
         pNumMessages = pMessageQueue_50CBD0->uNumMessages;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
         continue;
       }
       case WINDOW_RestWindow:
@@ -2187,7 +2187,7 @@
 //----- (0041426F) --------------------------------------------------------
 void ModalWindow_Release()
 {
-  pMessageQueue_50CBD0->AddMessage((UIMessageType)pModalWindow->par1C, 0, 0);
+  pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)pModalWindow->par1C, 0, 0);
 
   pModalWindow->Release();
   pModalWindow = nullptr;
--- a/GUIWindow.h	Thu Jul 10 01:48:39 2014 +0200
+++ b/GUIWindow.h	Mon Jul 14 10:03:44 2014 +0600
@@ -438,7 +438,7 @@
 
 
 
-#define AddMessage(msg, param, a4) AddMessageImpl((msg), (param), (a4), __FILE__, __LINE__)
+#define AddGUIMessage(msg, param, a4) AddMessageImpl((msg), (param), (a4), __FILE__, __LINE__)
 /*  250 */
 #pragma pack(push, 1)
 struct GUIMessageQueue
--- a/Game.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Game.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -1504,8 +1504,8 @@
             v10 = pSaveListPosition + uMessageParam;
             if ( dword_6BE138 == pSaveListPosition + uMessageParam )
             {
-              pMessageQueue_50CBD0->AddMessage(UIMSG_SaveLoadBtn, 0, 0);
-              pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0);
             }
             uLoadGameUI_SelectedSlot = v10;
             dword_6BE138 = v10;
@@ -2948,7 +2948,7 @@
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
             ++pMessageQueue_50CBD0->uNumMessages;
           }*/
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
           continue;
 
         case UIMSG_OnCastTownPortal:
@@ -2996,7 +2996,7 @@
           continue;
         case UIMSG_CloseAfterInstallBeacon:
           dword_50CDC8 = 1;
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
@@ -3047,7 +3047,7 @@
               pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
               pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
             }
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
             pBooksWindow->Release();
             pGUIWindow_CurrentMenu->Release();
             pBooksWindow = 0;
@@ -3134,7 +3134,7 @@
                     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                     ++pMessageQueue_50CBD0->uNumMessages;
                   }*/
-                  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+                  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
                   continue;
                 }
                 v63 = 210;
@@ -3576,7 +3576,7 @@
                   *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                   ++pMessageQueue_50CBD0->uNumMessages;
                 }*/
-                pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+                pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
                 ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2);// "Encounter!"
                 pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0);
                 continue;
@@ -3733,8 +3733,8 @@
                     dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1;
                     ++dword_50C9E8;
                   }*/
-                  pMessageQueue_50C9E8->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
-                //  pMessageQueue_50CBD0->AddMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
+                  pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
+                //  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1);
                 }
                 else
                 {
@@ -3835,7 +3835,7 @@
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
           ++pMessageQueue_50CBD0->uNumMessages;*/
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
           continue;
         case UIMSG_ClickAwardScrollBar:
           books_page_number = 1;
@@ -4060,7 +4060,7 @@
           v115 = pMessageQueue_50CBD0->uNumMessages;
           if ( !pMessageQueue_50CBD0->uNumMessages )
           {
-            pMessageQueue_50CBD0->AddMessage(UIMSG_MouseLeftClickInScreen, 0, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0);
             /*if ( (signed int)v115 < 40 )
             //goto LABEL_769;
             {
@@ -4075,7 +4075,7 @@
           if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
           {
             pMessageQueue_50CBD0->uNumMessages = 1;
-            pMessageQueue_50CBD0->AddMessage(UIMSG_MouseLeftClickInScreen, 0, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0);
             /*v115 = v0;
             pMessageQueue_50CBD0->uNumMessages = v0;
             pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen;
@@ -4087,7 +4087,7 @@
           }
           v115 = 0;
           pMessageQueue_50CBD0->uNumMessages = 0;
-          pMessageQueue_50CBD0->AddMessage(UIMSG_MouseLeftClickInScreen, 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0);
           /*if ( (signed int)v115 < 40 )
             //goto LABEL_769;
           {
@@ -4208,7 +4208,7 @@
       *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
     }*/
-    pMessageQueue_50CBD0->AddMessage((UIMessageType)dword_50C9DC, (int)ptr_50C9E0, 0);
+    pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)dword_50C9DC, (int)ptr_50C9E0, 0);
     dword_50C9DC = 0;
   }
   else
@@ -4225,7 +4225,7 @@
           *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
           ++pMessageQueue_50CBD0->uNumMessages;
         }*/
-        pMessageQueue_50CBD0->AddMessage((UIMessageType)_50C9D0_AfterEnchClickEventId, _50C9D4_AfterEnchClickEventSecondParam, 0);
+        pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)_50C9D0_AfterEnchClickEventId, _50C9D4_AfterEnchClickEventSecondParam, 0);
         _50C9D0_AfterEnchClickEventId = 0;
         _50C9D4_AfterEnchClickEventSecondParam = 0;
         _50C9D8_AfterEnchClickEventTimeout = 0;
@@ -4421,8 +4421,8 @@
               v26 = pParam + pSaveListPosition;
               if ( dword_6BE138 == pParam + pSaveListPosition )
               {
-                pMessageQueue_50CBD0->AddMessage(UIMSG_SaveLoadBtn, 0, 0);
-                pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0);
+                pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0);
+                pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0);
               }
               uLoadGameUI_SelectedSlot = v26;
               dword_6BE138 = v26;
@@ -4492,7 +4492,7 @@
               SetCurrentMenuID(MENU_CREDITSCLOSE);//в закрытие Создатели
               break;
             }
-            pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0);
             break;
           }
           if ( GetCurrentMenuID() == MENU_CREDITSPROC && !pCurrentScreen )
@@ -4509,7 +4509,7 @@
               SetCurrentMenuID(MENU_CREDITSCLOSE);
               break;
             }
-            pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0);
             break;
           }
           if ( pCurrentScreen == SCREEN_LOADGAME )
--- a/Indoor.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Indoor.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -4677,7 +4677,7 @@
         {
           Actor::AI_FaceObject(v17, 4, 0, 0);
           if ( pActors[v17].sNPC_ID )
-            pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v17, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_StartNPCDialogue, v17, 0);
           else
           {
             if ( pNPCStats->pGroups_copy[pActors[v17].uGroup] )
--- a/Keyboard.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Keyboard.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -529,7 +529,7 @@
     {
       if (pCurrentScreen == SCREEN_GAME)
       {
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Game_Action, 0, 0);
         continue;
       }
       if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG )
@@ -550,7 +550,7 @@
           }
           pMessageQueue_50CBD0->uNumMessages = 0;
         }
-        //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        //pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
       }
     }
   }*/
@@ -761,11 +761,11 @@
                  spell_price > pPlayers[uActiveCharacter]->sMana) )
             {
               pPartyActionQueue = pPartyActionQueue;
-              pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0);
               break;
             }
             else
-              pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0);
+              pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0);
             break;
           case INPUT_Attack:
             if (pCurrentScreen != SCREEN_GAME)
@@ -775,12 +775,12 @@
               pTurnEngine->field_18 |= TE_FLAG_8;
               break;
             }
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0);
             break;
           case INPUT_EventTrigger:
             if (pCurrentScreen == SCREEN_GAME)
             {
-              pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Game_Action, 0, 0);
               break;
             }
             if ( pCurrentScreen == SCREEN_NPC_DIALOGUE )
@@ -799,14 +799,14 @@
                 }
                 break;
               }
-              pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
             }
             break;
           case INPUT_CharCycle:
             if ( pCurrentScreen == SCREEN_SPELL_BOOK  )
               break;
 
-            pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0);
+            pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CycleCharacters, 0, 0);
             break;
           case INPUT_LookUp:
             if ( pEventTimer->bPaused )
@@ -847,10 +847,10 @@
             }
             break;
           case INPUT_ZoomIn:
-              pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0);
+              pMessageQueue_50C9E8->AddGUIMessage(UIMSG_ClickZoomOutBtn, 0, 0);
             break;
           case INPUT_ZoomOut:
-              pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0);
+              pMessageQueue_50C9E8->AddGUIMessage(UIMSG_ClickZoomInBtn, 0, 0);
             break;
           case INPUT_AlwaysRun:
             bAlwaysRun = bAlwaysRun == 0;
--- a/Mouse.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Mouse.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -473,7 +473,7 @@
                 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
                 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
               }
-              pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0);
               return;
             }
             continue;
@@ -489,7 +489,7 @@
                 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
                 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
               }
-              pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0);
               return;
             }
             continue;
@@ -505,7 +505,7 @@
                 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
                 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
               }
-              pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0);
               return;
             }
             continue;
@@ -534,7 +534,7 @@
       *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
     }*/
-    pMessageQueue_50CBD0->AddMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0);
 
     if ( pParty->bTurnBasedModeOn == 1 )
     {
@@ -621,7 +621,7 @@
           }
           while ( v13 );
         }
-        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
         break;
       }
       case VK_RIGHT:
@@ -652,7 +652,7 @@
           }
           while ( v10 );
         }
-        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
         break;
       }
       case VK_DOWN:
@@ -676,7 +676,7 @@
           }
           while ( v20 );
         }
-        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
         return true;
       }
       case VK_SELECT:
@@ -744,7 +744,7 @@
           }
           while ( v25 );
         }
-        pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
         return true;
       }
       case VK_NEXT:
--- a/NPC.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/NPC.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -1442,7 +1442,7 @@
             }
             pPlayers[uActiveCharacter]->PlaySound(SPEECH_85, 0);
           }
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
@@ -1497,7 +1497,7 @@
                 pCurrentNPCInfo->evt_F = 0;
               break;
           }
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
@@ -1561,7 +1561,7 @@
   PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C);
   dialog_menu_id = HOUSE_DIALOGUE_MAIN;
 
-  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
   /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
   {
     pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
@@ -1987,7 +1987,7 @@
 
     case GateMaster:
     {
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
       dword_50C9DC = 195;
       ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID);
     }
--- a/OSWindow.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/OSWindow.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -236,7 +236,7 @@
         }
         if ( wparam == VK_ESCAPE )
         {
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
           return 0;
         }
         if ( wparam <= VK_HOME )
--- a/Party.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Party.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -861,7 +861,7 @@
     }
     if ( dword_506F14 == 2 )
     {
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
     }
   }
   else
--- a/Player.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Player.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -4316,7 +4316,7 @@
 
     if ( pGUIWindow_CurrentMenu && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null)
     {
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
     }
     if ( v73 )
     {
@@ -4612,7 +4612,7 @@
 //           pMouse->RemoveHoldingItem();
 //           return;
 //         }
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
       }
       if ( v73 )
       {
@@ -4665,11 +4665,11 @@
     else
     {
       pMouse->RemoveHoldingItem();
-      pMessageQueue_50C9E8->AddMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1);
+      pMessageQueue_50C9E8->AddGUIMessage(UIMSG_SpellScrollUse, scroll_id, player_num - 1);
       if ( pCurrentScreen && pGUIWindow_CurrentMenu
         && (pGUIWindow_CurrentMenu->eWindowType != WINDOW_null))
       {
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
       }
     }
     return;
@@ -4728,7 +4728,7 @@
           pMouse->RemoveHoldingItem();
           return;
         }
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
       }
 //       if ( v73 )                                                v73 is always 0 at this point
 //       {
--- a/Render.h	Thu Jul 10 01:48:39 2014 +0200
+++ b/Render.h	Mon Jul 14 10:03:44 2014 +0600
@@ -391,58 +391,102 @@
   void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
   void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode);
 
+  public:
+    int *pActiveZBuffer;
+    IDirectDraw4 *pDirectDraw4;
+    IDirectDrawSurface4 *pFrontBuffer4;
+    IDirectDrawSurface4 *pBackBuffer4;
+    void        *pTargetSurface;
+    unsigned int uTargetSurfacePitch;
+    unsigned int bUseColoredLights;
+    unsigned int bTinting;
+    unsigned int bUsingSpecular;
+    uint32_t uFogColor;
+    unsigned int pHDWaterBitmapIDs[7];
+    int hd_water_current_frame;
+    int hd_water_tile_id;
+    void (*pBeforePresentFunction)();
+    uint32_t bFogEnabled;
+    RenderBillboardD3D pBillboardRenderListD3D[1000];
+    unsigned int uNumBillboardsToDraw;
 
-  protected: unsigned int uDesiredDirect3DDevice;
-  protected: int raster_clip_x;
-  protected: int raster_clip_y;    // clipping rect for raster ops
-  protected: int raster_clip_z;    //    like RasterLine2D for (mini)map
-  protected: int raster_clip_w;
-  public: int *pActiveZBuffer;
-  protected: int *pDefaultZBuffer;
-  protected: OSWindow *window;
-  protected: unsigned int bWindowMode;
-  protected: RenderD3D *pRenderD3D;
-  public: IDirectDraw4 *pDirectDraw4;
-  public: IDirectDrawSurface4 *pFrontBuffer4;
-  public: IDirectDrawSurface4 *pBackBuffer4;
-  protected: DDPIXELFORMAT ddpfPrimarySuface;
-  protected: unsigned int uTargetRBits;
-  protected: unsigned int uTargetGBits;
-  protected: unsigned int uTargetBBits;
-  protected: unsigned int uTargetRMask;
-  protected: unsigned int uTargetGMask;
-  protected: unsigned int uTargetBMask;
-  protected: unsigned int uNumSceneBegins;
-  protected: unsigned __int32 *pTargetSurface_unaligned;
-  public: void        *pTargetSurface;
-  public: unsigned int uTargetSurfacePitch;
-  protected: unsigned int uClipY;
-  protected: unsigned int uClipX;
-  protected: unsigned int uClipW;
-  protected: unsigned int uClipZ;
-  protected: unsigned int bClip;
-  protected: unsigned int uNumD3DSceneBegins;
-  protected: int using_software_screen_buffer;
-  protected: RenderHWLContainer pD3DBitmaps;
-  protected: RenderHWLContainer pD3DSprites;
-  public: unsigned int bUseColoredLights;
-  protected: unsigned int bRequiredTextureStagesAvailable;
-  public: unsigned int bTinting;
-  protected: unsigned int uLevelOfDetail;
-  protected: unsigned int uMaxDeviceTextureDim;
-  protected: unsigned int uMinDeviceTextureDim;
-  public: unsigned int bUsingSpecular;
-  public: uint32_t uFogColor;
-  public: unsigned int pHDWaterBitmapIDs[7];
-  public: int hd_water_current_frame;
-  public: int hd_water_tile_id;
-  public: void (*pBeforePresentFunction)();
-  public: uint32_t bFogEnabled;
-  public: RenderBillboardD3D pBillboardRenderListD3D[1000];
-  public: unsigned int uNumBillboardsToDraw;
+    inline void WritePixel16(int x, int y, unsigned __int16 color)
+    {
+      if (ddpfPrimarySuface.dwRGBBitCount == 32)
+      {
+        auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch;
+        *p = Color32(color);
+      }
+      else if (ddpfPrimarySuface.dwRGBBitCount == 16)
+      {
+        auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch;
+        *p = color;
+      }
+      else __debugbreak();
+    }
 
+    inline unsigned __int16 ReadPixel16(int x, int y)
+    {
+      if (ddpfPrimarySuface.dwRGBBitCount == 32)
+      {
+        auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch;
+        return Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
+      }
+      else if (ddpfPrimarySuface.dwRGBBitCount == 16)
+      {
+        auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch;
+        return *p;
+      }
+      else __debugbreak();
+    }
+
+    inline void ToggleTint()          {bTinting = !bTinting;}
+    inline void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;}
+
+    inline unsigned int GetRenderWidth() {return window->GetWidth();}
+    inline unsigned int GetRenderHeight() {return window->GetHeight();}
+
+    inline void Sub01()
+    {
+      if (pRenderD3D && !bWindowMode)
+        _49FD3A_fullscreen();
+    }
+
+    friend void Present_NoColorKey();
 
   protected:
+    unsigned int uDesiredDirect3DDevice;
+    int raster_clip_x;
+    int raster_clip_y;    // clipping rect for raster ops
+    int raster_clip_z;    //    like RasterLine2D for (mini)map
+    int raster_clip_w;
+    int *pDefaultZBuffer;
+    OSWindow *window;
+    unsigned int bWindowMode;
+    RenderD3D *pRenderD3D;
+    DDPIXELFORMAT ddpfPrimarySuface;
+    unsigned int uTargetRBits;
+    unsigned int uTargetGBits;
+    unsigned int uTargetBBits;
+    unsigned int uTargetRMask;
+    unsigned int uTargetGMask;
+    unsigned int uTargetBMask;
+    unsigned int uNumSceneBegins;
+    unsigned __int32 *pTargetSurface_unaligned;
+    unsigned int uClipY;
+    unsigned int uClipX;
+    unsigned int uClipW;
+    unsigned int uClipZ;
+    unsigned int bClip;
+    unsigned int uNumD3DSceneBegins;
+    int using_software_screen_buffer;
+    RenderHWLContainer pD3DBitmaps;
+    RenderHWLContainer pD3DSprites;
+    unsigned int bRequiredTextureStagesAvailable;
+    unsigned int uLevelOfDetail;
+    unsigned int uMaxDeviceTextureDim;
+    unsigned int uMinDeviceTextureDim;
+
     void DoRenderBillboards_D3D();
     void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1);
     void DrawBorderTiles(struct Polygon *poly);
@@ -463,52 +507,6 @@
     unsigned int GetParentBillboardID(unsigned int uBillboardID);
     unsigned int GetBillboardDrawListSize();
 
-  public:
-  inline void WritePixel16(int x, int y, unsigned __int16 color)
-  {
-    if (ddpfPrimarySuface.dwRGBBitCount == 32)
-    {
-      auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch;
-      *p = Color32(color);
-    }
-    else if (ddpfPrimarySuface.dwRGBBitCount == 16)
-    {
-      auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch;
-      *p = color;
-    }
-    else __debugbreak();
-  }
-
-  inline unsigned __int16 ReadPixel16(int x, int y)
-  {
-    if (ddpfPrimarySuface.dwRGBBitCount == 32)
-    {
-      auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch;
-      return Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
-    }
-    else if (ddpfPrimarySuface.dwRGBBitCount == 16)
-    {
-      auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch;
-      return *p;
-    }
-    else __debugbreak();
-  }
-
-
-  inline void ToggleTint()          {bTinting = !bTinting;}
-  inline void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;}
-
-  inline unsigned int GetRenderWidth() {return window->GetWidth();}
-  inline unsigned int GetRenderHeight() {return window->GetHeight();}
-
-  inline void Sub01()
-  {
-    if (pRenderD3D && !bWindowMode)
-      _49FD3A_fullscreen();
-  }
-
-  friend void Present_NoColorKey();
-
   //int windowed_mode_width;
   //int windowed_mode_height;
 };
--- a/UI/Books/UIMapBook.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/Books/UIMapBook.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -182,7 +182,7 @@
     }
   }
   if ( byte_506360 )
-    pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
   return BeaconID;
 }
 
--- a/UI/UIArena.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UIArena.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -182,7 +182,7 @@
     *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
     ++pMessageQueue_50CBD0->uNumMessages;
   }*/
-  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
   //v2 = pParty->pPlayers.data();
   for ( uint i = 0; i < 4; i++ )
   {
--- a/UI/UIGuilds.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UIGuilds.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -228,7 +228,7 @@
       }
     }
   }
-  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
   return;
 }
 //----- (004BC8D5) --------------------------------------------------------
--- a/UI/UIHouses.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UIHouses.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -1291,7 +1291,7 @@
     }
     case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT:
     {
-      pMessageQueue_50CBD0->AddMessage(UIMSG_PlayArcomage, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_PlayArcomage, 0, 0);
       dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT;
       break;
     }
@@ -1536,7 +1536,7 @@
       {
         ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//"У вас не хватает золота"
         PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
         return;
       }
 
@@ -1606,7 +1606,7 @@
           sqrt(3.1415926);
         while ( HouseDialogPressCloseBtn() )
           ;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
         return;
       }
       else
@@ -1731,7 +1731,7 @@
         v2 = atoi(pKeyActionMap->pPressedKeysBuffer);
         if ( v1 <= 0 )
         {
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
           return;
         }
         if ( v1 > pParty->uNumGold )
@@ -1751,7 +1751,7 @@
       if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
       {
         window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       }
       break;
     }
@@ -1805,7 +1805,7 @@
         takes_sum = entered_sum;
         if ( !entered_sum )
         {
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
           return;
         }
         if ( entered_sum > pParty->uNumGold )
@@ -1821,13 +1821,13 @@
             pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
         }
         window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
         return;
       }
       if (window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
       {
         window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       }
       return;
     }
@@ -1860,13 +1860,13 @@
           }
         }
         window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
         return;
       }
       if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
       {
         window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       }
       return;
     }
@@ -2062,14 +2062,14 @@
         pMessageQueue_50CBD0->pMessages[0].param = (int)window_SpeakInHouse->ptr_1C;//107
         pMessageQueue_50CBD0->pMessages[0].field_8 = 1;
         ++pMessageQueue_50CBD0->uNumMessages;*/
-        pMessageQueue_50CBD0->AddMessage(UIMSG_RentRoom, (int)window_SpeakInHouse->ptr_1C, 1);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_RentRoom, (int)window_SpeakInHouse->ptr_1C, 1);
         window_SpeakInHouse->Release();
         window_SpeakInHouse = 0;
         return;
       }
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//У вас не хватает золота
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       break;
     }
 
@@ -2143,7 +2143,7 @@
         ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2);//Вы уже купили еду!
         if ( uActiveCharacter )
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
         return;
       }
       if ( pParty->uNumGold >= pPriceFood )
@@ -2151,12 +2151,12 @@
         Party::TakeGold(pPriceFood);
         pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
         PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
         return;
       }
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);  // "You don't have enough gold"
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       break;
     }
 
@@ -2284,7 +2284,7 @@
     {
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//"У вас не хватает золота"
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       return;
     }
     Party::TakeGold(pPrice);
@@ -2303,7 +2303,7 @@
       pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
       pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       return;
     }
     if ( (unsigned int)pPlayers[uActiveCharacter]->pConditions[Condition_Zombie] | v35 )
@@ -2316,7 +2316,7 @@
         pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
         pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
         pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
         return;
       }
       pPlayers[uActiveCharacter]->uPrevFace = pPlayers[uActiveCharacter]->uCurrentFace;
@@ -2333,7 +2333,7 @@
     pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
     pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
     pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
-    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
     return;
   }
   //---------------------------------------------------
@@ -2388,12 +2388,12 @@
       ++byte_F8B1EF[uActiveCharacter];
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_83, 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2); // "Thank You!"
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       return;
     }
     ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//"У вас не хватает золота"
     PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
     return;
   }
   //------------------------------------------------
@@ -2607,12 +2607,12 @@
             sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[430], pPlayers[uActiveCharacter]->pName, pPlayers[uActiveCharacter]->uLevel, pPlayers[uActiveCharacter]->uLevel / 10 + 5);// 
                                                 // "%s is now Level %lu and has earned %lu Skill Points!"
             ShowStatusBarString(pTmpBuf.data(), 2);
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
             return;
           }
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
           PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)4);
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
           return;
         }
         sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1);// 
@@ -2628,7 +2628,7 @@
       }
       training_dialog_window.DrawTitleText(pFontArrus, 0, v36, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)3);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       return;
     }
   }
@@ -2836,7 +2836,7 @@
   {
     v5 = 0;
   }
-  pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5);
+  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, v5);
   return; // void func
 }
 
--- a/UI/UIPartyCreation.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UIPartyCreation.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -568,7 +568,7 @@
             && uMouseY >= (signed int)pControlsHead->uY && uMouseY <= (signed int)pControlsHead->uW )//mouse movement
         {
           pControlParam = pControlsHead->uControlParam;
-          pMessageQueue_50CBD0->AddMessage((UIMessageType)pControlsHead->field_1C, pControlParam, 0);
+          pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)pControlsHead->field_1C, pControlParam, 0);
           v1 = 0;
         }
         pControlsHead = pControlsHead->pNext;
--- a/UI/UIPopup.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UIPopup.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -1866,7 +1866,7 @@
       pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(pOut_y);
       pPlayers[uActiveCharacter]->ReceiveDamage(rand() % 11 + 10, DMGT_FIRE);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
       v39.z = pParty->vPosition.z + pParty->sEyelevel;
       v39.x = pParty->vPosition.x;
       v39.y = pParty->vPosition.y;
@@ -1891,7 +1891,7 @@
       pPlayers[uActiveCharacter]->ReceiveDamage(rand() % 71 + 30, DMGT_FIRE);
       pPlayers[uActiveCharacter]->ItemsEnchant(1);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
 
       v39.z = pParty->vPosition.z + pParty->sEyelevel;
       v39.x = pParty->vPosition.x;
@@ -1918,7 +1918,7 @@
       pPlayers[uActiveCharacter]->ItemsEnchant(5);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
 
       v39.z = pParty->vPosition.z + pParty->sEyelevel;
       v39.x = pParty->vPosition.x;
@@ -1945,7 +1945,7 @@
       pPlayers[uActiveCharacter]->ItemsEnchant(0);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
 
       v39.z = pParty->vPosition.z + pParty->sEyelevel;
       v39.x = pParty->vPosition.x;
--- a/UI/UISaveLoad.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UISaveLoad.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -96,7 +96,7 @@
   {
     pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
     strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, pKeyActionMap->pPressedKeysBuffer);
-    pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveGame, 0, 0);
   }
   else
   {
--- a/UI/UiGame.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/UI/UiGame.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -1327,7 +1327,7 @@
             {
               pMessageType1 = (UIMessageType)pButton->field_1C;
               if ( pMessageType1 )
-                pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0);
+                pMessageQueue_50CBD0->AddGUIMessage(pMessageType1, pButton->msg_param, 0);
               GameUI_SetFooterString(pButton->pButtonName);
               uLastPointedObjectID = 1;
               return;
@@ -1346,7 +1346,7 @@
               {
                 pMessageType2 = (UIMessageType)pButton->field_1C;
                 if ( pMessageType2 != 0 )
-                  pMessageQueue_50CBD0->AddMessage(pMessageType2, pButton->msg_param, 0);
+                  pMessageQueue_50CBD0->AddGUIMessage(pMessageType2, pButton->msg_param, 0);
                 GameUI_SetFooterString(pButton->pButtonName); // for character name
                 uLastPointedObjectID = 1;
                 return;
@@ -1452,7 +1452,7 @@
           }
           else
           {
-            pMessageQueue_50CBD0->AddMessage(pMessageType3, pButton->msg_param, 0);
+            pMessageQueue_50CBD0->AddGUIMessage(pMessageType3, pButton->msg_param, 0);
           }
           uLastPointedObjectID = 1;
           return;
@@ -1471,7 +1471,7 @@
           {
             pMessageType2 = (UIMessageType)pButton->field_1C;
             if ( pMessageType2 != 0 )
-              pMessageQueue_50CBD0->AddMessage(pMessageType2, pButton->msg_param, 0);
+              pMessageQueue_50CBD0->AddGUIMessage(pMessageType2, pButton->msg_param, 0);
             GameUI_SetFooterString(pButton->pButtonName); // for character name
             uLastPointedObjectID = 1;
             return;
--- a/Viewport.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/Viewport.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -470,7 +470,7 @@
           }
           return;
         }
-        pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, mon_id, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_StartNPCDialogue, mon_id, 0);
         return;
       }
       if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT )
@@ -478,7 +478,7 @@
         pTurnEngine->field_18 |= TE_FLAG_8;
         return;
       }
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0);
     }
     else
     {
@@ -488,7 +488,7 @@
         return;
       }
       if ( uActiveCharacter && sub_427769_isSpellQuickCastableOnShiftClick(pPlayers[uActiveCharacter]->uQuickSpell))
-        pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0);
+        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0);
     }
     return;
   }
--- a/_deleted.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/_deleted.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -12468,7 +12468,7 @@
         //}
         if ( wParam == VK_ESCAPE )
         {
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
+          pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
           return 0;
         }
         if ( wParam <= VK_HOME )
--- a/mm7_2.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/mm7_2.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -64,8 +64,6 @@
 #include "MMT.h"
 #include "Registry.h"
 
-//#include "lib/lua/lua.h"
-
 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam);
 int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4);
 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive);
@@ -283,11 +281,11 @@
     {
       pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit;
     }*/
-    pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0);
   }
   else
   {
-    pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0);
+    pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0);
     /*if ( (signed int)result < 40 )
     {
       pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5;
--- a/mm7_4.cpp	Thu Jul 10 01:48:39 2014 +0200
+++ b/mm7_4.cpp	Mon Jul 14 10:03:44 2014 +0600
@@ -2129,7 +2129,7 @@
       pParty->hirelingScrollPosition = 0;
       pParty->CountHirelings();
       dword_591084 = 0;
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       dword_7241C8 = 0;
       return;
     }
@@ -2167,7 +2167,7 @@
       strcpy(v13, speakingNPC->pName);
       pParty->hirelingScrollPosition = 0;
       pParty->CountHirelings();
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       if ( sDialogue_SpeakingActorNPC_ID >= 0 )
         pDialogue_SpeakingActor->uAIState = Removed;
       if ( uActiveCharacter )
@@ -2185,7 +2185,7 @@
     {
       if ( speakingNPC->uProfession != GateMaster )
         speakingNPC->bHasUsedTheAbility = 1;
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
     }
     else
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!"
@@ -2211,7 +2211,7 @@
       pParty->hirelingScrollPosition = 0;
       pParty->CountHirelings();
       dword_591084 = 0;
-      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
       dword_7241C8 = 0;
       return;
     }