From 264f30ae14d8e942a89f2770fb4d448e49367814 Mon Sep 17 00:00:00 2001 From: Ilya Orlov Date: Thu, 5 Jul 2018 10:23:03 +0400 Subject: [PATCH] xrCore, xrRender, xrEngine, xrGame: initial SDL2 porting --- .gitignore | 16 +- src/Layers/xrRender/D3DXRenderBase.h | 4 +- src/Layers/xrRender/HW.cpp | 72 +++-- src/Layers/xrRender/HW.h | 40 +-- src/Layers/xrRenderDX10/dx10HW.cpp | 17 +- src/Layers/xrRenderGL/glHW.cpp | 43 +-- src/Layers/xrRenderPC_GL/packages.config | 5 + src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj | 12 + .../xrRenderPC_GL/xrRender_GL.vcxproj.filters | 6 + src/Layers/xrRenderPC_R1/packages.config | 5 + src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj | 12 + .../xrRenderPC_R1/xrRender_R1.vcxproj.filters | 6 + src/Layers/xrRenderPC_R2/packages.config | 5 + src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj | 12 + .../xrRenderPC_R2/xrRender_R2.vcxproj.filters | 6 + src/Layers/xrRenderPC_R3/packages.config | 5 + src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj | 12 + .../xrRenderPC_R3/xrRender_R3.vcxproj.filters | 6 + src/Layers/xrRenderPC_R4/packages.config | 5 + src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj | 12 + .../xrRenderPC_R4/xrRender_R4.vcxproj.filters | 6 + src/xrCDB/packages.config | 5 + src/xrCDB/xrCDB.vcxproj | 12 + src/xrCDB/xrCDB.vcxproj.filters | 6 + src/xrCore/packages.config | 5 + src/xrCore/xrCore.vcxproj | 10 + src/xrCore/xrCore.vcxproj.filters | 4 + src/xrEngine/Device_Initialize.cpp | 49 ++-- src/xrEngine/Device_create.cpp | 7 +- src/xrEngine/Device_destroy.cpp | 6 +- src/xrEngine/IInputReceiver.cpp | 2 +- src/xrEngine/Render.h | 5 +- src/xrEngine/Text_Console.cpp | 2 +- src/xrEngine/XR_IOConsole.cpp | 4 +- src/xrEngine/device.cpp | 88 ++++-- src/xrEngine/device.h | 30 ++- src/xrEngine/edit_actions.cpp | 2 +- src/xrEngine/packages.config | 5 + src/xrEngine/x_ray.cpp | 4 +- src/xrEngine/xrEngine.vcxproj | 12 + src/xrEngine/xrEngine.vcxproj.filters | 6 + src/xrEngine/xr_input.cpp | 253 +++++++----------- src/xrEngine/xr_input.h | 10 +- src/xrGame/ActorInput.cpp | 6 +- src/xrGame/IKFoot.cpp | 2 +- src/xrGame/MainMenu.cpp | 3 +- src/xrGame/UICursor.cpp | 12 +- src/xrGame/ik/IKLimb.cpp | 4 +- src/xrGame/packages.config | 5 + src/xrGame/xrGame.vcxproj | 12 + src/xrGame/xrGame.vcxproj.filters | 6 + src/xrGame/xr_level_controller.cpp | 64 +++-- src/xrPhysics/packages.config | 5 + src/xrPhysics/xrPhysics.vcxproj | 12 + src/xrPhysics/xrPhysics.vcxproj.filters | 6 + src/xr_3da/xr_3da.vcxproj | 2 + src/xr_3da/xr_3da.vcxproj.filters | 3 + 57 files changed, 587 insertions(+), 389 deletions(-) create mode 100644 src/Layers/xrRenderPC_GL/packages.config create mode 100644 src/Layers/xrRenderPC_R1/packages.config create mode 100644 src/Layers/xrRenderPC_R2/packages.config create mode 100644 src/Layers/xrRenderPC_R3/packages.config create mode 100644 src/Layers/xrRenderPC_R4/packages.config create mode 100644 src/xrCDB/packages.config create mode 100644 src/xrCore/packages.config create mode 100644 src/xrEngine/packages.config create mode 100644 src/xrGame/packages.config create mode 100644 src/xrPhysics/packages.config diff --git a/.gitignore b/.gitignore index 066def7d0a3..1d6808a4d72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1 @@ -# exclude all dot files except .git, appveyor and travis files -.* -!.git* -!.appveyor* -!.travis.yml - -# exclude binaries and temporary files -bin/ -bin_plugs/ -intermediate/ -intermediate_plugs/ -lib/ -*.aps -*.user -*.PVS-Studio.* +src/packages diff --git a/src/Layers/xrRender/D3DXRenderBase.h b/src/Layers/xrRender/D3DXRenderBase.h index 1ff80280f39..9d6ff18e243 100644 --- a/src/Layers/xrRender/D3DXRenderBase.h +++ b/src/Layers/xrRender/D3DXRenderBase.h @@ -186,11 +186,11 @@ class D3DXRenderBase : public IRender, public pureFrame virtual void OnDeviceDestroy(bool bKeepTextures) override; virtual void ValidateHW() override; virtual void DestroyHW() override; - virtual void Reset(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override; + virtual void Reset(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override; // Init virtual void SetupStates() override; virtual void OnDeviceCreate(const char* shName) override; - virtual void Create(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool) override; + virtual void Create(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool) override; virtual void SetupGPU(bool bForceGPU_SW, bool bForceGPU_NonPure, bool bForceGPU_REF) override; // Overdraw virtual void overdrawBegin() override; diff --git a/src/Layers/xrRender/HW.cpp b/src/Layers/xrRender/HW.cpp index 2d55d5ba024..bb20b5f226d 100644 --- a/src/Layers/xrRender/HW.cpp +++ b/src/Layers/xrRender/HW.cpp @@ -36,7 +36,7 @@ void CHW::DestroyD3D() _RELEASE(pD3D); } -void CHW::CreateDevice(HWND m_hWnd, bool move_window) +void CHW::CreateDevice(SDL_Window* m_sdlWnd, bool move_window) { m_move_window = move_window; CreateD3D(); @@ -136,7 +136,22 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) // Windoze P.SwapEffect = bWindowed ? D3DSWAPEFFECT_COPY : D3DSWAPEFFECT_DISCARD; - P.hDeviceWindow = m_hWnd; + + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWindowWMInfo(m_sdlWnd, &info)) + { + switch (info.subsystem) + { + case SDL_SYSWM_WINDOWS: + P.hDeviceWindow = info.info.win.window; + break; + default: break; + } + } + else + Log("Couldn't get window information: %s", SDL_GetError()); + P.Windowed = bWindowed; // Depth/stencil @@ -158,13 +173,13 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) // Create the device const auto GPU = selectGPU(); - auto result = HW.pD3D->CreateDevice(DevAdapter, m_DriverType, m_hWnd, + auto result = HW.pD3D->CreateDevice(DevAdapter, m_DriverType, P.hDeviceWindow, GPU | D3DCREATE_MULTITHREADED, //. ? locks at present &P, &pDevice); if (FAILED(result)) { - result = HW.pD3D->CreateDevice(DevAdapter, m_DriverType, m_hWnd, + result = HW.pD3D->CreateDevice(DevAdapter, m_DriverType, P.hDeviceWindow, GPU | D3DCREATE_MULTITHREADED, //. ? locks at present &P, &pDevice); } @@ -199,7 +214,7 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) Msg("* Texture memory: %d M", memory / (1024 * 1024)); Msg("* DDI-level: %2.1f", float(D3DXGetDriverLevel(pDevice)) / 100.f); - updateWindowProps(m_hWnd); + updateWindowProps(m_sdlWnd); fill_vid_mode_list(this); } @@ -225,7 +240,7 @@ void CHW::DestroyDevice() ////////////////////////////////////////////////////////////////////// // Resetting device ////////////////////////////////////////////////////////////////////// -void CHW::Reset(HWND hwnd) +void CHW::Reset(SDL_Window* m_sdlWnd) { #ifdef DEBUG _RELEASE(dwDebugSB); @@ -270,8 +285,8 @@ void CHW::Reset(HWND hwnd) R_CHK(pDevice->CreateStateBlock(D3DSBT_ALL, &dwDebugSB)); #endif - updateWindowProps(hwnd); - ShowWindow(hwnd, SW_SHOWNORMAL); + updateWindowProps(m_sdlWnd); + SDL_ShowWindow(m_sdlWnd); } D3DFORMAT CHW::selectDepthStencil(D3DFORMAT fTarget) @@ -451,7 +466,7 @@ BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage) return TRUE; } -void CHW::updateWindowProps(HWND m_hWnd) +void CHW::updateWindowProps(SDL_Window *m_sdlWnd) { bool bWindowed = !psDeviceFlags.is(rsFullscreen); @@ -464,11 +479,8 @@ void CHW::updateWindowProps(HWND m_hWnd) { if (m_move_window) { - const bool drawBorders = strstr(Core.Params, "-draw_borders"); - dwWindowStyle = WS_VISIBLE; - if (drawBorders) - dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX; - SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle); + if(NULL != strstr(Core.Params, "-draw_borders")) + SDL_SetWindowBordered(m_sdlWnd, SDL_TRUE); // When moving from fullscreen to windowed mode, it is important to // adjust the window size after recreating the device rather than // beforehand to ensure that you get the window size you want. For @@ -478,47 +490,29 @@ void CHW::updateWindowProps(HWND m_hWnd) // changed to 1024x768, because windows cannot be larger than the // desktop. - RECT m_rcWindowBounds; - float fYOffset = 0.f; bool centerScreen = false; if (GEnv.isDedicatedServer || strstr(Core.Params, "-center_screen")) centerScreen = true; + SDL_SetWindowSize(m_sdlWnd, DevPP.BackBufferWidth, DevPP.BackBufferHeight); + if (centerScreen) { - RECT DesktopRect; - - GetClientRect(GetDesktopWindow(), &DesktopRect); - - SetRect(&m_rcWindowBounds, - (DesktopRect.right - DevPP.BackBufferWidth) / 2, - (DesktopRect.bottom - DevPP.BackBufferHeight) / 2, - (DesktopRect.right + DevPP.BackBufferWidth) / 2, - (DesktopRect.bottom + DevPP.BackBufferHeight) / 2); + SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } else { - if (drawBorders) - fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar - SetRect(&m_rcWindowBounds, 0, 0, DevPP.BackBufferWidth, DevPP.BackBufferHeight); - }; - - AdjustWindowRect(&m_rcWindowBounds, dwWindowStyle, FALSE); - - SetWindowPos(m_hWnd, HWND_NOTOPMOST, - m_rcWindowBounds.left, m_rcWindowBounds.top + fYOffset, - m_rcWindowBounds.right - m_rcWindowBounds.left, - m_rcWindowBounds.bottom - m_rcWindowBounds.top, - SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME); + SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED); + } } } else { - SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle = WS_POPUP | WS_VISIBLE); + SDL_ShowWindow(m_sdlWnd); } if (!GEnv.isDedicatedServer) - SetForegroundWindow(m_hWnd); + SDL_SetWindowGrab(m_sdlWnd, SDL_TRUE); } struct uniqueRenderingMode diff --git a/src/Layers/xrRender/HW.h b/src/Layers/xrRender/HW.h index 4e7d5007ef6..1d7194de6eb 100644 --- a/src/Layers/xrRender/HW.h +++ b/src/Layers/xrRender/HW.h @@ -2,6 +2,8 @@ #include "HWCaps.h" #include "xrCore/ModuleLookup.hpp" +#include "SDL.h" +#include "SDL_syswm.h" #if !defined(_MAYA_EXPORT) && !defined(USE_OGL) #include "stats_manager.h" @@ -23,11 +25,11 @@ class CHW void DestroyD3D(); #endif // !USE_OGL - void CreateDevice(HWND hw, bool move_window); + void CreateDevice(SDL_Window* m_sdlWnd, bool move_window); void DestroyDevice(); - void Reset(HWND hw); + void Reset(SDL_Window* m_sdlWnd); #ifndef USE_OGL void selectResolution(u32& dwWidth, u32& dwHeight, BOOL bWindowed); @@ -38,10 +40,10 @@ class CHW BOOL support(D3DFORMAT fmt, DWORD type, DWORD usage); #endif // !USE_OGL - void updateWindowProps(HWND hw); + void updateWindowProps(SDL_Window* m_sdlWnd); #ifdef DEBUG #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) - void Validate(void) {}; + void Validate(void){}; #else // USE_DX10 void Validate(void) { @@ -71,11 +73,11 @@ class CHW HGLRC m_hRC; #elif defined(USE_DX11) public: - IDXGIFactory1* m_pFactory = nullptr; - IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent - ID3D11Device* pDevice = nullptr; // combine with DX9 pDevice via typedef - ID3D11DeviceContext* pContext = nullptr; // combine with DX9 pDevice via typedef - IDXGISwapChain* m_pSwapChain = nullptr; + IDXGIFactory1* m_pFactory = nullptr; + IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent + ID3D11Device* pDevice = nullptr; // combine with DX9 pDevice via typedef + ID3D11DeviceContext* pContext = nullptr; // combine with DX9 pDevice via typedef + IDXGISwapChain* m_pSwapChain = nullptr; ID3D11RenderTargetView* pBaseRT = nullptr; // combine with DX9 pBaseRT via typedef ID3D11DepthStencilView* pBaseZB = nullptr; @@ -86,13 +88,13 @@ class CHW D3D_FEATURE_LEVEL FeatureLevel; #elif defined(USE_DX10) public: - IDXGIFactory1* m_pFactory = nullptr; - IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent - ID3D10Device1* pDevice1 = nullptr; // combine with DX9 pDevice via typedef - ID3D10Device* pDevice = nullptr; // combine with DX9 pDevice via typedef - ID3D10Device1* pContext1 = nullptr; // combine with DX9 pDevice via typedef - ID3D10Device* pContext = nullptr; // combine with DX9 pDevice via typedef - IDXGISwapChain* m_pSwapChain = nullptr; + IDXGIFactory1* m_pFactory = nullptr; + IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent + ID3D10Device1* pDevice1 = nullptr; // combine with DX9 pDevice via typedef + ID3D10Device* pDevice = nullptr; // combine with DX9 pDevice via typedef + ID3D10Device1* pContext1 = nullptr; // combine with DX9 pDevice via typedef + ID3D10Device* pContext = nullptr; // combine with DX9 pDevice via typedef + IDXGISwapChain* m_pSwapChain = nullptr; ID3D10RenderTargetView* pBaseRT = nullptr; // combine with DX9 pBaseRT via typedef ID3D10DepthStencilView* pBaseZB = nullptr; @@ -109,8 +111,8 @@ class CHW XRay::Module hD3D = nullptr; public: - IDirect3D9* pD3D = nullptr; // D3D - IDirect3DDevice9* pDevice = nullptr; // render device + IDirect3D9* pD3D = nullptr; // D3D + IDirect3DDevice9* pDevice = nullptr; // render device IDirect3DSurface9* pBaseRT = nullptr; IDirect3DSurface9* pBaseZB = nullptr; @@ -142,7 +144,7 @@ class CHW HRESULT Present(UINT SyncInterval, UINT Flags); #endif // USE_OGL - int maxRefreshRate = 200; //ECO_RENDER add + int maxRefreshRate = 200; // ECO_RENDER add private: bool m_move_window = true; diff --git a/src/Layers/xrRenderDX10/dx10HW.cpp b/src/Layers/xrRenderDX10/dx10HW.cpp index e325fa4e36c..69c5855e01e 100644 --- a/src/Layers/xrRenderDX10/dx10HW.cpp +++ b/src/Layers/xrRenderDX10/dx10HW.cpp @@ -64,7 +64,7 @@ void CHW::DestroyD3D() _RELEASE(m_pFactory); } -void CHW::CreateDevice(HWND m_hWnd, bool move_window) +void CHW::CreateDevice(SDL_Window* hWnd, bool move_window) { m_move_window = move_window; CreateD3D(); @@ -110,7 +110,20 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) // Windoze sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - sd.OutputWindow = m_hWnd; + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWindowWMInfo(m_sdlWnd, &info)) + { + switch (info.subsystem) + { + case SDL_SYSWM_WINDOWS: + sd.OutputWindow = info.info.win.window; + break; + default: break; + } + } + else + Log("Couldn't get window information: %s", SDL_GetError()); sd.Windowed = bWindowed; // Depth/stencil (DX10 don't need this?) diff --git a/src/Layers/xrRenderGL/glHW.cpp b/src/Layers/xrRenderGL/glHW.cpp index 5dfd82d49c6..5a3ad9cbf99 100644 --- a/src/Layers/xrRenderGL/glHW.cpp +++ b/src/Layers/xrRenderGL/glHW.cpp @@ -179,9 +179,9 @@ void CHW::Reset(HWND hwnd) ShowWindow(hwnd, SW_SHOWNORMAL); } -void CHW::updateWindowProps(HWND m_hWnd) +void CHW::updateWindowProps(SDL_Window* m_sdlWnd) { - const bool bWindowed = !psDeviceFlags.is(rsFullscreen); + bool bWindowed = !psDeviceFlags.is(rsFullscreen); u32 dwWindowStyle = 0; // Set window properties depending on what mode were in. @@ -189,11 +189,8 @@ void CHW::updateWindowProps(HWND m_hWnd) { if (m_move_window) { - const bool drawBorders = strstr(Core.Params, "-draw_borders"); - dwWindowStyle = WS_VISIBLE; - if (drawBorders) - dwWindowStyle |= WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX; - SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle); + if (NULL != strstr(Core.Params, "-draw_borders")) + SDL_SetWindowBordered(m_sdlWnd, SDL_TRUE); // When moving from fullscreen to windowed mode, it is important to // adjust the window size after recreating the device rather than // beforehand to ensure that you get the window size you want. For @@ -203,45 +200,29 @@ void CHW::updateWindowProps(HWND m_hWnd) // changed to 1024x768, because windows cannot be larger than the // desktop. - RECT m_rcWindowBounds; - float fYOffset = 0.f; bool centerScreen = false; - if (strstr(Core.Params, "-center_screen")) + if (GEnv.isDedicatedServer || strstr(Core.Params, "-center_screen")) centerScreen = true; + SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]); + if (centerScreen) { - RECT DesktopRect; - GetClientRect(GetDesktopWindow(), &DesktopRect); - - SetRect(&m_rcWindowBounds, - (DesktopRect.right - psCurrentVidMode[0]) / 2, - (DesktopRect.bottom - psCurrentVidMode[1]) / 2, - (DesktopRect.right + psCurrentVidMode[0]) / 2, - (DesktopRect.bottom + psCurrentVidMode[1]) / 2); + SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } else { - if (drawBorders) - fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar - SetRect(&m_rcWindowBounds, 0, 0, psCurrentVidMode[0], psCurrentVidMode[1]); + SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED); } - - AdjustWindowRect(&m_rcWindowBounds, dwWindowStyle, FALSE); - - SetWindowPos(m_hWnd, HWND_NOTOPMOST, - m_rcWindowBounds.left, m_rcWindowBounds.top + fYOffset, - m_rcWindowBounds.right - m_rcWindowBounds.left, - m_rcWindowBounds.bottom - m_rcWindowBounds.top, - SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_DRAWFRAME); } } else { - SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle = WS_POPUP | WS_VISIBLE); + SDL_ShowWindow(m_sdlWnd); } - SetForegroundWindow(m_hWnd); + if (!GEnv.isDedicatedServer) + SDL_SetWindowGrab(m_sdlWnd, SDL_TRUE); } struct uniqueRenderingMode diff --git a/src/Layers/xrRenderPC_GL/packages.config b/src/Layers/xrRenderPC_GL/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/Layers/xrRenderPC_GL/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj b/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj index 9dc041b5d5a..1cf4fd647a2 100644 --- a/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj +++ b/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj @@ -492,7 +492,19 @@ {1daec516-e52c-4a3c-a4da-ae3553e6e0f8} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters b/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters index 0eb68fc93fd..7ce248277c7 100644 --- a/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters +++ b/src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters @@ -1113,4 +1113,10 @@ Interface implementations\MSAARender + + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R1/packages.config b/src/Layers/xrRenderPC_R1/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/Layers/xrRenderPC_R1/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj b/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj index 884909e7d6c..a47a87b4850 100644 --- a/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj +++ b/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj @@ -475,12 +475,24 @@ {61d4856f-fa82-4f02-bb88-909ddfb1fe74} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj.filters b/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj.filters index e97f665a584..9224934507f 100644 --- a/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj.filters +++ b/src/Layers/xrRenderPC_R1/xrRender_R1.vcxproj.filters @@ -960,4 +960,10 @@ + + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R2/packages.config b/src/Layers/xrRenderPC_R2/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/Layers/xrRenderPC_R2/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj b/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj index 67ec9c239c4..ac05faee057 100644 --- a/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj +++ b/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj @@ -522,7 +522,19 @@ {61d4856f-fa82-4f02-bb88-909ddfb1fe74} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj.filters b/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj.filters index 036a2604891..e2532efaeb3 100644 --- a/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj.filters +++ b/src/Layers/xrRenderPC_R2/xrRender_R2.vcxproj.filters @@ -1104,4 +1104,10 @@ + + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R3/packages.config b/src/Layers/xrRenderPC_R3/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/Layers/xrRenderPC_R3/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj b/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj index 71eb2460acd..794416e3b01 100644 --- a/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj +++ b/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj @@ -570,7 +570,19 @@ {61d4856f-fa82-4f02-bb88-909ddfb1fe74} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj.filters b/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj.filters index 3d42967de7a..f9eec142752 100644 --- a/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj.filters +++ b/src/Layers/xrRenderPC_R3/xrRender_R3.vcxproj.filters @@ -1278,4 +1278,10 @@ Core_Target + + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R4/packages.config b/src/Layers/xrRenderPC_R4/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/Layers/xrRenderPC_R4/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj index 64217edcafe..ba7028a583d 100644 --- a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj +++ b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj @@ -581,7 +581,19 @@ {61d4856f-fa82-4f02-bb88-909ddfb1fe74} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters index eaa1d0d2a6f..10d1e54224f 100644 --- a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters +++ b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters @@ -1314,4 +1314,10 @@ Shading templates + + + + + + \ No newline at end of file diff --git a/src/xrCDB/packages.config b/src/xrCDB/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/xrCDB/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/xrCDB/xrCDB.vcxproj b/src/xrCDB/xrCDB.vcxproj index 871be9898f4..8703512bbe9 100644 --- a/src/xrCDB/xrCDB.vcxproj +++ b/src/xrCDB/xrCDB.vcxproj @@ -190,12 +190,24 @@ {7885cf3c-ee04-4c67-9467-1fbf9a36b037} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/xrCDB/xrCDB.vcxproj.filters b/src/xrCDB/xrCDB.vcxproj.filters index 8940b81b726..d0e3e3d57b1 100644 --- a/src/xrCDB/xrCDB.vcxproj.filters +++ b/src/xrCDB/xrCDB.vcxproj.filters @@ -84,4 +84,10 @@ Kernel + + + + + + \ No newline at end of file diff --git a/src/xrCore/packages.config b/src/xrCore/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/xrCore/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/xrCore/xrCore.vcxproj b/src/xrCore/xrCore.vcxproj index d2069755fc9..293a08cc420 100644 --- a/src/xrCore/xrCore.vcxproj +++ b/src/xrCore/xrCore.vcxproj @@ -398,6 +398,7 @@ + @@ -418,10 +419,19 @@ + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/xrCore/xrCore.vcxproj.filters b/src/xrCore/xrCore.vcxproj.filters index 574d58ec0ea..54b5fc46d0a 100644 --- a/src/xrCore/xrCore.vcxproj.filters +++ b/src/xrCore/xrCore.vcxproj.filters @@ -692,5 +692,9 @@ Debug core\DxErr + + + + \ No newline at end of file diff --git a/src/xrEngine/Device_Initialize.cpp b/src/xrEngine/Device_Initialize.cpp index 8069cc73945..764a5554049 100644 --- a/src/xrEngine/Device_Initialize.cpp +++ b/src/xrEngine/Device_Initialize.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "xr_3da/resource.h" +#include #include "Include/editor/ide.hpp" #include "engine_impl.hpp" @@ -25,8 +26,8 @@ void CRenderDevice::initialize_weather_editor() m_editor_initialize(m_editor, m_engine); VERIFY(m_editor); - m_hWnd = m_editor->view_handle(); - VERIFY(m_hWnd != INVALID_HANDLE_VALUE); + //m_hWnd = m_editor->view_handle(); + VERIFY(m_sdlWnd != INVALID_HANDLE_VALUE); GEnv.isEditor = true; } @@ -40,29 +41,33 @@ void CRenderDevice::Initialize() if (strstr(Core.Params, "-weather")) initialize_weather_editor(); - // Unless a substitute hWnd has been specified, create a window to render into - if (!m_hWnd) + if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { - const char* wndclass = "_XRAY_1.6"; - // Register the windows class - HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(0); - WNDCLASS wndClass = {0, WndProc, 0, 0, hInstance, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)), - LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, wndclass}; - RegisterClass(&wndClass); - // Set the window's initial style - m_dwWindowStyle = WS_BORDER | WS_DLGFRAME; - // Set the window's initial width - RECT rc; - SetRect(&rc, 0, 0, 640, 480); - AdjustWindowRect(&rc, m_dwWindowStyle, FALSE); - // Create the render window - m_hWnd = CreateWindowEx(WS_EX_TOPMOST, wndclass, "S.T.A.L.K.E.R.: Call of Pripyat", m_dwWindowStyle, - CW_USEDEFAULT, CW_USEDEFAULT, (rc.right - rc.left), (rc.bottom - rc.top), 0L, 0, hInstance, 0L); + Log("Unable to initialize SDL: %s", SDL_GetError()); + } + + if (!m_sdlWnd) + { + m_sdlWnd = SDL_CreateWindow("S.T.A.L.K.E.R.: Call of Pripyat", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + 640, 480, SDL_WINDOW_BORDERLESS); + + if (!m_sdlWnd) + Log("Unable to create window: %s", SDL_GetError()); + + m_sdlRndr = SDL_CreateRenderer(m_sdlWnd, -1, SDL_RENDERER_ACCELERATED); + + SDL_RenderClear(m_sdlRndr); + SDL_RenderPresent(m_sdlRndr); } // Save window properties - m_dwWindowStyle = GetWindowLong(m_hWnd, GWL_STYLE); - GetWindowRect(m_hWnd, &m_rcWindowBounds); - GetClientRect(m_hWnd, &m_rcWindowClient); + + m_dwWindowStyle = SDL_GetWindowFlags(m_sdlWnd); + if (SDL_GetDisplayBounds(0, &m_rcWindowBounds) != 0) + { + Log("SDL_GetDisplayBounds failed: %s", SDL_GetError()); + } + + //GetClientRect(m_hWnd, &m_rcWindowClient); } void CRenderDevice::DumpStatistics(IGameFont& font, IPerformanceAlert* alert) diff --git a/src/xrEngine/Device_create.cpp b/src/xrEngine/Device_create.cpp index 17479ba92d8..0ae1b715c15 100644 --- a/src/xrEngine/Device_create.cpp +++ b/src/xrEngine/Device_create.cpp @@ -2,6 +2,9 @@ #include "Include/xrRender/DrawUtils.h" #include "Render.h" #include "xrCDB/xrXRC.h" +#include +#include + extern XRCDB_API BOOL* cdb_bDebug; @@ -35,9 +38,7 @@ void CRenderDevice::Create() fFOV = 90.f; fASPECT = 1.f; const bool noEd = !editor(); - GEnv.Render->Create(m_hWnd, dwWidth, dwHeight, fWidth_2, fHeight_2, noEd); - GetWindowRect(m_hWnd, &m_rcWindowBounds); - GetClientRect(m_hWnd, &m_rcWindowClient); + GEnv.Render->Create(m_sdlWnd, dwWidth, dwHeight, fWidth_2, fHeight_2, noEd); Memory.mem_compact(); b_is_Ready = TRUE; _SetupStates(); diff --git a/src/xrEngine/Device_destroy.cpp b/src/xrEngine/Device_destroy.cpp index 6369084da0a..37b5e2c6b64 100644 --- a/src/xrEngine/Device_destroy.cpp +++ b/src/xrEngine/Device_destroy.cpp @@ -4,6 +4,8 @@ #include "IGame_Persistent.h" #include "XR_IOConsole.h" #include "xr_input.h" +#include +#include void CRenderDevice::Destroy() { @@ -43,9 +45,7 @@ void CRenderDevice::Reset(bool precache) const auto tm_start = TimerAsync(); - GEnv.Render->Reset(m_hWnd, dwWidth, dwHeight, fWidth_2, fHeight_2); - GetWindowRect(m_hWnd, &m_rcWindowBounds); - GetClientRect(m_hWnd, &m_rcWindowClient); + GEnv.Render->Reset(m_sdlWnd, dwWidth, dwHeight, fWidth_2, fHeight_2); if (g_pGamePersistent) g_pGamePersistent->Environment().bNeed_re_create_env = true; diff --git a/src/xrEngine/IInputReceiver.cpp b/src/xrEngine/IInputReceiver.cpp index 17a9b0d88bf..62542fc410e 100644 --- a/src/xrEngine/IInputReceiver.cpp +++ b/src/xrEngine/IInputReceiver.cpp @@ -56,7 +56,7 @@ void IInputReceiver::IR_GetMousePosReal(HWND hwnd, Ivector2& p) if (hwnd) ScreenToClient(hwnd, (LPPOINT)&p); } -void IInputReceiver::IR_GetMousePosReal(Ivector2& p) { IR_GetMousePosReal(RDEVICE.m_hWnd, p); } +void IInputReceiver::IR_GetMousePosReal(Ivector2& p) { /*IR_GetMousePosReal(RDEVICE.m_sdlWnd, p)*/; } void IInputReceiver::IR_GetMousePosIndependent(Fvector2& f) { Ivector2 p; diff --git a/src/xrEngine/Render.h b/src/xrEngine/Render.h index 790c95e146c..dc615a9cc1b 100644 --- a/src/xrEngine/Render.h +++ b/src/xrEngine/Render.h @@ -5,6 +5,7 @@ #include "vis_common.h" #include "Include/xrRender/FactoryPtr.h" #include "xrCore/xr_resource.h" +#include "SDL.h" class IUIShader; typedef FactoryPtr wm_shader; @@ -397,11 +398,11 @@ class ENGINE_API IRender virtual void OnDeviceDestroy(bool bKeepTextures) = 0; virtual void ValidateHW() = 0; virtual void DestroyHW() = 0; - virtual void Reset(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) = 0; + virtual void Reset(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) = 0; // Init virtual void SetupStates() = 0; virtual void OnDeviceCreate(LPCSTR shName) = 0; - virtual void Create(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool) = 0; + virtual void Create(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool) = 0; virtual void SetupGPU(bool bForceGPU_SW, bool bForceGPU_NonPure, bool bForceGPU_REF) = 0; // Overdraw virtual void overdrawBegin() = 0; diff --git a/src/xrEngine/Text_Console.cpp b/src/xrEngine/Text_Console.cpp index 4dfd8778bc1..6308ead8df1 100644 --- a/src/xrEngine/Text_Console.cpp +++ b/src/xrEngine/Text_Console.cpp @@ -140,7 +140,7 @@ void CTextConsole::Initialize() { inherited::Initialize(); - m_pMainWnd = &Device.m_hWnd; + //m_pMainWnd = &Device.m_hWnd; m_dwLastUpdateTime = Device.dwTimeGlobal; m_last_time = Device.dwTimeGlobal; diff --git a/src/xrEngine/XR_IOConsole.cpp b/src/xrEngine/XR_IOConsole.cpp index a4eab19e3d3..d4a30a7aa6b 100644 --- a/src/xrEngine/XR_IOConsole.cpp +++ b/src/xrEngine/XR_IOConsole.cpp @@ -614,8 +614,6 @@ void CConsole::Show() Device.seqFrame.Add(this); } -extern CInput* pInput; - void CConsole::Hide() { if (!bVisible || g_pGamePersistent && GEnv.isDedicatedServer) @@ -624,7 +622,7 @@ void CConsole::Hide() // if ( g_pGameLevel || // ( g_pGamePersistent && g_pGamePersistent->m_pMainMenu && g_pGamePersistent->m_pMainMenu->IsActive() )) - if (pInput->get_exclusive_mode()) + //if (pInput->get_exclusive_mode()) { SetCursorPos(m_mouse_pos.x, m_mouse_pos.y); } diff --git a/src/xrEngine/device.cpp b/src/xrEngine/device.cpp index 10b81afeada..5d3f54a623f 100644 --- a/src/xrEngine/device.cpp +++ b/src/xrEngine/device.cpp @@ -10,6 +10,7 @@ #define MMNOMIXER #define MMNOJOY #include +#include #pragma warning(pop) #include "x_ray.h" @@ -95,9 +96,8 @@ void CRenderDevice::End(void) CheckPrivilegySlowdown(); if (g_pGamePersistent->GameType() == 1) // haCk { - WINDOWINFO wi; - GetWindowInfo(m_hWnd, &wi); - if (wi.dwWindowStatus != WS_ACTIVECAPTION) + Uint32 flags = SDL_GetWindowFlags(m_sdlWnd); + if (flags & SDL_WINDOW_INPUT_GRABBED) Pause(TRUE, TRUE, TRUE, "application start"); } } @@ -271,7 +271,7 @@ void CRenderDevice::on_idle() mViewSaved = mView; mProjectSaved = mProject; - //renderProcessFrame.Set(); // allow render thread to do its job + // renderProcessFrame.Set(); // allow render thread to do its job syncProcessFrame.Set(); // allow secondary thread to do its job const auto frameEndTime = TimerGlobal.GetElapsed_ms(); @@ -308,7 +308,7 @@ void CRenderDevice::on_idle() Sleep(updateDelta - frameTime); syncFrameDone.Wait(); // wait until secondary thread finish its job - //renderFrameDone.Wait(); // wait until render thread finish its job + // renderFrameDone.Wait(); // wait until render thread finish its job if (!b_is_Active) Sleep(1); @@ -329,18 +329,55 @@ void CRenderDevice::message_loop() return; } - MSG msg; - PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); - while (msg.message != WM_QUIT) + + SDL_PumpEvents(); + /* + SDL_Event event; + + SDL_PeepEvents(&event, 16, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT); + while (SDL_QUIT != event.type) { - if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) + if (SDL_PeepEvents(&event, 16, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - continue; + switch (event.type) + { + case SDL_KEYDOWN: continue; + case SDL_WINDOWEVENT: + switch (event.window.event) + { + case SDL_WINDOWEVENT_MOVED: + case SDL_WINDOWEVENT_SIZE_CHANGED: + case SDL_WINDOWEVENT_MAXIMIZED: + SDL_Log("Window %d moved to %d,%d", event.window.windowID, event.window.data1, event.window.data2); + continue; + case SDL_WINDOWEVENT_CLOSE: + event.type = SDL_QUIT; + SDL_PeepEvents(&event, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT); + continue; +#if SDL_VERSION_ATLEAST(2, 0, 5) + case SDL_WINDOWEVENT_TAKE_FOCUS: + if (editor()) + { + Device.b_is_Active = TRUE; + continue; + } + OnWM_Activate(event.window.data1, event.window.data2); + SDL_Log("Window %d is offered a focus", event.window.windowID); + continue; +#endif + default: SDL_Log("Window %d got unknown event %d", event.window.windowID, event.window.event); continue; + } + continue; + default: Log("Recieve window %d event", event.type); continue; + } } + on_idle(); } + */ + while (true) + on_idle(); + } void CRenderDevice::Run() @@ -362,19 +399,19 @@ void CRenderDevice::Run() // Start all threads mt_bMustExit = FALSE; thread_spawn(SecondaryThreadProc, "X-RAY Secondary thread", 0, this); - //thread_spawn(RenderThreadProc, "X-RAY Render thread", 0, this); + // thread_spawn(RenderThreadProc, "X-RAY Render thread", 0, this); // Message cycle seqAppStart.Process(); GEnv.Render->ClearTarget(); splash::hide(); - ShowWindow(m_hWnd, SW_SHOWNORMAL); + SDL_ShowWindow(m_sdlWnd); pInput->ClipCursor(true); message_loop(); seqAppEnd.Process(); // Stop Balance-Thread mt_bMustExit = TRUE; - //renderProcessFrame.Set(); - //renderThreadExit.Wait(); + // renderProcessFrame.Set(); + // renderThreadExit.Wait(); syncProcessFrame.Set(); syncThreadExit.Wait(); @@ -448,12 +485,11 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason) if (bOn) { if (!Paused()) - bShowPauseString = - editor() ? FALSE : + bShowPauseString = editor() ? FALSE : #ifdef DEBUG - !xr_strcmp(reason, "li_pause_key_no_clip") ? FALSE : + !xr_strcmp(reason, "li_pause_key_no_clip") ? FALSE : #endif // DEBUG - TRUE; + TRUE; if (bTimer && (!g_pGamePersistent || g_pGamePersistent->CanBePaused())) { g_pauseMngr().Pause(TRUE); @@ -535,16 +571,10 @@ CRenderDevice* get_device() { return &Device; } u32 script_time_global() { return Device.dwTimeGlobal; } u32 script_time_global_async() { return Device.TimerAsync_MMT(); } -SCRIPT_EXPORT(Device, (), -{ +SCRIPT_EXPORT(Device, (), { using namespace luabind; - module(luaState) - [ - def("time_global", &script_time_global), - def("time_global_async", &script_time_global_async), - def("device", &get_device), - def("is_enough_address_space_available", &is_enough_address_space_available) - ]; + module(luaState)[def("time_global", &script_time_global), def("time_global_async", &script_time_global_async), + def("device", &get_device), def("is_enough_address_space_available", &is_enough_address_space_available)]; }); CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false), b_need_user_input(false) {} diff --git a/src/xrEngine/device.h b/src/xrEngine/device.h index 40cf29b1453..938e4d4b78c 100644 --- a/src/xrEngine/device.h +++ b/src/xrEngine/device.h @@ -25,6 +25,7 @@ #include "Include/editor/interfaces.hpp" #include "Include/xrRender/FactoryPtr.h" #include "Render.h" +#include class engine_impl; @@ -62,10 +63,10 @@ class ENGINE_API CRenderDeviceData u32 dwHeight; // Real application window resolution - RECT m_rcWindowBounds; + SDL_Rect m_rcWindowBounds; - // Real game window resolution - RECT m_rcWindowClient; + // Real game window resolution + SDL_Rect m_rcWindowClient; u32 dwPrecacheFrame; BOOL b_is_Ready; @@ -117,7 +118,8 @@ class ENGINE_API CRenderDeviceData MessageRegistry seqFrame; MessageRegistry seqResolutionChanged; - HWND m_hWnd; + SDL_Window* m_sdlWnd; + // HWND m_hWnd; }; class ENGINE_API CRenderDeviceBase : public IRenderDevice, public CRenderDeviceData @@ -135,18 +137,19 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase class ENGINE_API CSecondVPParams //--#SM+#-- +SecondVP+ { bool isActive; // Флаг активации рендера во второй вьюпорт - u8 frameDelay; // На каком кадре с момента прошлого рендера во второй вьюпорт мы начнём новый - //(не может быть меньше 2 - каждый второй кадр, чем больше тем более низкий FPS во втором вьюпорте) - + u8 frameDelay; // На каком кадре с момента прошлого рендера во второй вьюпорт мы начнём новый + //(не может быть меньше 2 - каждый второй кадр, чем больше тем более низкий FPS во втором + //вьюпорте) + public: bool isCamReady; // Флаг готовности камеры (FOV, позиция, и т.п) к рендеру второго вьюпорта IC bool IsSVPActive() { return isActive; } IC void SetSVPActive(bool bState) { isActive = bState; } - bool IsSVPFrame(); + bool IsSVPFrame(); IC u8 GetSVPFrameDelay() { return frameDelay; } - void SetSVPFrameDelay(u8 iDelay) + void SetSVPFrameDelay(u8 iDelay) { frameDelay = iDelay; clamp(frameDelay, 2, u8(-1)); @@ -163,6 +166,8 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase public: // HWND m_hWnd; + SDL_Window* m_sdlWnd; + SDL_Renderer* m_sdlRndr; LRESULT MsgProc(HWND, UINT, WPARAM, LPARAM); // u32 dwFrame; @@ -202,16 +207,15 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase MessageRegistry seqFrameMT; MessageRegistry seqDeviceReset; xr_vector> seqParallel; - CSecondVPParams m_SecondViewport; //--#SM+#-- +SecondVP+ + CSecondVPParams m_SecondViewport; //--#SM+#-- +SecondVP+ Fmatrix mInvFullTransform; CRenderDevice() - : m_dwWindowStyle(0), fWidth_2(0), fHeight_2(0), - m_editor_module(nullptr), m_editor_initialize(nullptr), + : m_dwWindowStyle(0), fWidth_2(0), fHeight_2(0), m_editor_module(nullptr), m_editor_initialize(nullptr), m_editor_finalize(nullptr), m_editor(nullptr), m_engine(nullptr) { - m_hWnd = NULL; + m_sdlWnd = NULL; b_is_Active = FALSE; b_is_Ready = FALSE; Timer.Start(); diff --git a/src/xrEngine/edit_actions.cpp b/src/xrEngine/edit_actions.cpp index 29f6b92a247..9d965b0e01a 100644 --- a/src/xrEngine/edit_actions.cpp +++ b/src/xrEngine/edit_actions.cpp @@ -76,7 +76,7 @@ void type_pair::on_key_press(line_edit_control* const control) static _locale_t current_locale = _create_locale(LC_ALL, ""); - if (pInput->get_dik_name(m_dik, buff, sizeof(buff))) + if (pInput->get_key_name(m_dik, buff, sizeof(buff))) { if (_isalpha_l(buff[0], current_locale) || buff[0] == char(-1)) // "я" = -1 { diff --git a/src/xrEngine/packages.config b/src/xrEngine/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/xrEngine/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index 3c59166c9a3..2ea6a67e408 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -133,9 +133,11 @@ CApplication::CApplication() loadingScreen = nullptr; } +extern CInput* pInput; + CApplication::~CApplication() { - Console->Hide(); + //Console->Hide(); // font xr_delete(pFontSystem); diff --git a/src/xrEngine/xrEngine.vcxproj b/src/xrEngine/xrEngine.vcxproj index 77f3bc4deef..b6b76f4fe2f 100644 --- a/src/xrEngine/xrEngine.vcxproj +++ b/src/xrEngine/xrEngine.vcxproj @@ -445,12 +445,24 @@ {98d24a3d-7666-4c11-9d6e-b10393ce8cba} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/xrEngine/xrEngine.vcxproj.filters b/src/xrEngine/xrEngine.vcxproj.filters index 74b42cdaa96..d7427889889 100644 --- a/src/xrEngine/xrEngine.vcxproj.filters +++ b/src/xrEngine/xrEngine.vcxproj.filters @@ -900,4 +900,10 @@ + + + + + + \ No newline at end of file diff --git a/src/xrEngine/xr_input.cpp b/src/xrEngine/xr_input.cpp index 68924c839fc..838a98f12ea 100644 --- a/src/xrEngine/xr_input.cpp +++ b/src/xrEngine/xr_input.cpp @@ -21,7 +21,6 @@ float stop_vibration_time = flt_max; #define MOUSEBUFFERSIZE 64 #define KEYBOARDBUFFERSIZE 64 -#define _KEYDOWN(name, key) (name[key] & 0x80) static bool g_exclusive = true; static void on_error_dialog(bool before) @@ -43,39 +42,22 @@ CInput::CInput(BOOL bExclusive, int deviceForInit) g_exclusive = !!bExclusive; Log("Starting INPUT device..."); - pDI = NULL; pMouse = NULL; - pKeyboard = NULL; //=====================Mouse mouse_property.mouse_dt = 25; - ZeroMemory(mouseState, sizeof(mouseState)); ZeroMemory(KBState, sizeof(KBState)); ZeroMemory(timeStamp, sizeof(timeStamp)); ZeroMemory(timeSave, sizeof(timeStamp)); ZeroMemory(offs, sizeof(offs)); - //===================== Dummy pack - iCapture(&dummyController); - - if (!pDI) - CHK_DX(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&pDI, NULL)); - - //. u32 kb_input_flags = ((bExclusive)?DISCL_EXCLUSIVE:DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND; - u32 kb_input_flags = ((bExclusive) ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND; - - //. u32 mouse_input_flags = ((bExclusive)?DISCL_EXCLUSIVE:DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND | DISCL_NOWINKEY, - u32 mouse_input_flags = ((bExclusive) ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND | DISCL_NOWINKEY; - - // KEYBOARD - if (deviceForInit & keyboard_device_key) - CHK_DX(CreateInputDevice(&pKeyboard, GUID_SysKeyboard, &c_dfDIKeyboard, kb_input_flags, KEYBOARDBUFFERSIZE)); - - // MOUSE - if (deviceForInit & mouse_device_key) - CHK_DX(CreateInputDevice(&pMouse, GUID_SysMouse, &c_dfDIMouse2, mouse_input_flags, MOUSEBUFFERSIZE)); + //if (SDL_Init(SDL_INIT_EVERYTHING) != 0) + //{ + // Log("Unable to initialize SDL: %s", SDL_GetError()); + //} + xrDebug::SetDialogHandler(on_error_dialog); @@ -102,13 +84,8 @@ CInput::~CInput(void) _RELEASE(pMouse); } - if (pKeyboard) - { - pKeyboard->Unacquire(); - _RELEASE(pKeyboard); - } - _SHOW_REF("Input: ", pDI); + //SDL_Quit(); _RELEASE(pDI); } @@ -128,16 +105,16 @@ HRESULT CInput::CreateInputDevice( // reported. CHK_DX((*device)->SetDataFormat(pdidDataFormat)); -// Set the cooperativity level to let DirectInput know how this device -// should interact with the system and with other DirectInput applications. - if (!Device.editor()) - { - HRESULT _hr = (*device)->SetCooperativeLevel(RDEVICE.m_hWnd, dwFlags); - if (FAILED(_hr) && (_hr == E_NOTIMPL)) - Msg("! INPUT: Can't set coop level. Emulation???"); - else - R_CHK(_hr); - } + // Set the cooperativity level to let DirectInput know how this device + // should interact with the system and with other DirectInput applications. + //if (!Device.editor()) + //{ + // HRESULT _hr = (*device)->SetCooperativeLevel(RDEVICE.m_sdlWnd, dwFlags); + // if (FAILED(_hr) && (_hr == E_NOTIMPL)) + // Msg("! INPUT: Can't set coop level. Emulation???"); + // else + // R_CHK(_hr); + //} // setup the buffer size for the keyboard data DIPROPDWORD dipdw; @@ -163,8 +140,6 @@ void CInput::SetAllAcquire(BOOL bAcquire) { if (pMouse) bAcquire ? pMouse->Acquire() : pMouse->Unacquire(); - if (pKeyboard) - bAcquire ? pKeyboard->Acquire() : pKeyboard->Unacquire(); } void CInput::SetMouseAcquire(BOOL bAcquire) @@ -172,98 +147,45 @@ void CInput::SetMouseAcquire(BOOL bAcquire) if (pMouse) bAcquire ? pMouse->Acquire() : pMouse->Unacquire(); } -void CInput::SetKBDAcquire(BOOL bAcquire) -{ - if (pKeyboard) - bAcquire ? pKeyboard->Acquire() : pKeyboard->Unacquire(); -} +void CInput::SetKBDAcquire(BOOL bAcquire) {} //----------------------------------------------------------------------- -BOOL b_altF4 = FALSE; -void CInput::KeyUpdate() +void CInput::KeyUpdate(SDL_Event* event) { - if (b_altF4) - return; - - HRESULT hr; - DWORD dwElements = KEYBOARDBUFFERSIZE; - DIDEVICEOBJECTDATA od[KEYBOARDBUFFERSIZE]; - DWORD key = 0; - - VERIFY(pKeyboard); - - hr = pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0); - if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED)) - { - hr = pKeyboard->Acquire(); - if (hr != S_OK) - return; - - hr = pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0); - if (hr != S_OK) - return; - } - bool b_dik_pause_was_pressed = false; - for (u32 idx = 0; idx < dwElements; idx++) - { - if (od[idx].dwOfs == DIK_PAUSE) - { - if (od[idx].dwData & 0x80) - b_dik_pause_was_pressed = true; - if (b_dik_pause_was_pressed && !(od[idx].dwData & 0x80)) - { - od[idx].uAppData = 666; - continue; // skip one-frame pause key on-off switch - } - } - KBState[od[idx].dwOfs] = od[idx].dwData & 0x80; + if (SDL_SCANCODE_PAUSE == event->key.keysym.scancode) + { + if (SDL_KEYDOWN == event->key.type) + b_dik_pause_was_pressed = true; } #ifndef _EDITOR bool b_alt_tab = false; - if (!b_altF4 && KBState[DIK_F4] && (KBState[DIK_RMENU] || KBState[DIK_LMENU])) - { - b_altF4 = TRUE; - Engine.Event.Defer("KERNEL:disconnect"); - Engine.Event.Defer("KERNEL:quit"); - } - -#endif - if (b_altF4) - return; - -#ifndef _EDITOR if (Device.dwPrecacheFrame == 0) #endif { - for (u32 i = 0; i < dwElements; i++) - { - if (od[i].uAppData == 666) // ignored action - continue; + const Uint8* state = SDL_GetKeyboardState(NULL); - key = od[i].dwOfs; - if (od[i].dwData & 0x80) - cbStack.back()->IR_OnKeyboardPress(key); - else - { - cbStack.back()->IR_OnKeyboardRelease(key); + if (SDL_KEYDOWN == event->key.type) + cbStack.back()->IR_OnKeyboardPress(event->key.keysym.scancode); + else if (SDL_KEYUP == event->key.type) + { + cbStack.back()->IR_OnKeyboardRelease(event->key.keysym.scancode); #ifndef _EDITOR - if (key == DIK_TAB && (iGetAsyncKeyState(DIK_RMENU) || iGetAsyncKeyState(DIK_LMENU))) - b_alt_tab = true; + if (SDL_SCANCODE_TAB == event->key.keysym.scancode && KMOD_ALT == SDL_GetModState()) + b_alt_tab = true; #endif - } } for (u32 i = 0; i < COUNT_KB_BUTTONS; i++) - if (KBState[i]) + if (state[i]) cbStack.back()->IR_OnKeyboardHold(i); } #ifndef _EDITOR if (b_alt_tab) - SendMessage(Device.m_hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); + SDL_MinimizeWindow(Device.m_sdlWnd); #endif /* #ifndef _EDITOR @@ -302,28 +224,18 @@ void CInput::KeyUpdate() #endif */ } -bool CInput::get_dik_name(int dik, LPSTR dest_str, int dest_sz) -{ - DIPROPSTRING keyname; - keyname.diph.dwSize = sizeof(DIPROPSTRING); - keyname.diph.dwHeaderSize = sizeof(DIPROPHEADER); - keyname.diph.dwObj = static_cast(dik); - keyname.diph.dwHow = DIPH_BYOFFSET; - HRESULT hr = pKeyboard->GetProperty(DIPROP_KEYNAME, &keyname.diph); - if (FAILED(hr)) - return false; - const wchar_t* wct = keyname.wsz; - if (0 == wcslen(wct)) - return false; - - int cnt = WideCharToMultiByte(CP_ACP, 0, keyname.wsz, -1, dest_str, dest_sz, NULL, NULL); - if (cnt == -1) +bool CInput::get_key_name(int dik, LPSTR dest_str, int dest_sz) +{ + const char* keyname = SDL_GetKeyName(dik); + if (0 == strlen(keyname)) { - Msg("! cant convert dik_name for dik[%d], prop=[%S]", dik, keyname.wsz); + Msg("! cant convert dik_name for dik[%d]", dik); return false; } - return (cnt != -1); + strcpy_s(dest_str, dest_sz, keyname); + + return true; } #define MOUSE_1 (0xED + 100) @@ -347,16 +259,21 @@ void CInput::ClipCursor(bool clip) { if (clip) { - ::ClipCursor(&Device.m_rcWindowClient); - while (ShowCursor(FALSE) >= 0) {} + SDL_RenderSetClipRect(Device.m_sdlRndr, &Device.m_rcWindowClient); + while (ShowCursor(FALSE) >= 0) + { + } } else { ::ClipCursor(nullptr); - while (ShowCursor(TRUE) <= 0) {} + while (ShowCursor(TRUE) <= 0) + { + } } } +// void CInput::MouseUpdate(SDL_Event *event) void CInput::MouseUpdate() { HRESULT hr; @@ -511,8 +428,7 @@ void CInput::MouseUpdate() DIMOUSESTATE2 MouseState; hr = pMouse->GetDeviceState(sizeof(MouseState), &MouseState); - auto RecheckMouseButtonFunc = [&](int i) - { + auto RecheckMouseButtonFunc = [&](int i) { if (MouseState.rgbButtons[i] & 0x80 && mouseState[i] == FALSE) { mouseState[i] = TRUE; @@ -533,8 +449,7 @@ void CInput::MouseUpdate() } //-Giperion - auto isButtonOnHold = [&](int i) - { + auto isButtonOnHold = [&](int i) { if (mouseState[i] && mouse_prev[i]) cbStack.back()->IR_OnMouseHold(i); }; @@ -565,8 +480,6 @@ void CInput::iCapture(IInputReceiver* p) VERIFY(p); if (pMouse) MouseUpdate(); - if (pKeyboard) - KeyUpdate(); // change focus if (!cbStack.empty()) @@ -632,13 +545,51 @@ void CInput::OnAppDeactivate(void) void CInput::OnFrame(void) { + SDL_Event event; + stats.FrameStart(); stats.FrameTime.Begin(); dwCurTime = RDEVICE.TimerAsync_MMT(); - if (pKeyboard) - KeyUpdate(); - if (pMouse) - MouseUpdate(); + + while (SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_KEYDOWN: + case SDL_KEYUP: KeyUpdate(&event); continue; + + case SDL_MOUSEMOTION: + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEWHEEL: + // MouseUpdate(&event); + //MouseUpdate(); + continue; + case SDL_WINDOWEVENT: + switch (event.window.event) + { + case SDL_WINDOWEVENT_CLOSE: + event.type = SDL_QUIT; + SDL_PushEvent(&event); + continue; + case SDL_WINDOWEVENT_ENTER: +#if SDL_VERSION_ATLEAST(2, 0, 5) + case SDL_WINDOWEVENT_TAKE_FOCUS: + RDEVICE.OnWM_Activate(event.window.data1, event.window.data2); + continue; +#endif + default: SDL_Log("Window %d got unknown event %d", event.window.windowID, event.window.event); continue; + } + continue; + case SDL_QUIT: + Engine.Event.Defer("KERNEL:disconnect"); + Engine.Event.Defer("KERNEL:quit"); + break; + + default: continue; + } + } + stats.FrameTime.End(); stats.FrameEnd(); } @@ -651,25 +602,13 @@ IInputReceiver* CInput::CurrentIR() return NULL; } -void CInput::unacquire() -{ - pKeyboard->Unacquire(); - pMouse->Unacquire(); -} +void CInput::unacquire() { if (pMouse) pMouse->Unacquire(); } void CInput::acquire(const bool& exclusive) { - pKeyboard->SetCooperativeLevel( - Device.editor() ? Device.editor()->main_handle() : - RDEVICE.m_hWnd, - (exclusive ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND); - pKeyboard->Acquire(); - - pMouse->SetCooperativeLevel( - Device.editor() ? Device.editor()->main_handle() : - RDEVICE.m_hWnd, - (exclusive ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND | DISCL_NOWINKEY); - pMouse->Acquire(); + //pMouse->SetCooperativeLevel(Device.editor() ? Device.editor()->main_handle() : RDEVICE.m_sdlWnd, + // (exclusive ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND | DISCL_NOWINKEY); + //pMouse->Acquire(); } void CInput::exclusive_mode(const bool& exclusive) diff --git a/src/xrEngine/xr_input.h b/src/xrEngine/xr_input.h index 45b55b09d9b..9f7b5343883 100644 --- a/src/xrEngine/xr_input.h +++ b/src/xrEngine/xr_input.h @@ -3,6 +3,7 @@ #define DIRECTINPUT_VERSION 0x0800 #include +#include class ENGINE_API IInputReceiver; @@ -52,7 +53,6 @@ class ENGINE_API CInput BENCH_SEC_SCRAMBLEMEMBER1 LPDIRECTINPUT8 pDI; // The DInput object LPDIRECTINPUTDEVICE8 pMouse; // The DIDevice7 interface - LPDIRECTINPUTDEVICE8 pKeyboard; // The DIDevice7 interface //---------------------- u32 timeStamp[COUNT_MOUSE_AXIS]; u32 timeSave[COUNT_MOUSE_AXIS]; @@ -61,15 +61,15 @@ class ENGINE_API CInput //---------------------- BOOL KBState[COUNT_KB_BUTTONS]; - HRESULT CreateInputDevice( LPDIRECTINPUTDEVICE8* device, GUID guidDevice, const DIDATAFORMAT* pdidDataFormat, u32 dwFlags, u32 buf_size); - // xr_stack cbStack; + xr_vector cbStack; + //void MouseUpdate(SDL_Event *event); void MouseUpdate(); - void KeyUpdate(); + void KeyUpdate(SDL_Event *event); InputStatistics stats; @@ -105,7 +105,7 @@ class ENGINE_API CInput IC bool get_exclusive_mode(); void unacquire(); void acquire(const bool& exclusive); - bool get_dik_name(int dik, LPSTR dest, int dest_sz); + bool get_key_name(int dik, LPSTR dest, int dest_sz); void feedback(u16 s1, u16 s2, float time); }; diff --git a/src/xrGame/ActorInput.cpp b/src/xrGame/ActorInput.cpp index 2b554ba88a3..bd88a9750ea 100644 --- a/src/xrGame/ActorInput.cpp +++ b/src/xrGame/ActorInput.cpp @@ -37,7 +37,7 @@ extern u32 hud_adj_mode; void CActor::IR_OnKeyboardPress(int cmd) { - if (hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) return; if (Remote()) @@ -219,7 +219,7 @@ void CActor::IR_OnMouseWheel(int direction) void CActor::IR_OnKeyboardRelease(int cmd) { - if (hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) return; if (Remote()) @@ -254,7 +254,7 @@ void CActor::IR_OnKeyboardRelease(int cmd) void CActor::IR_OnKeyboardHold(int cmd) { - if (hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) return; if (Remote() || !g_Alive()) diff --git a/src/xrGame/IKFoot.cpp b/src/xrGame/IKFoot.cpp index 3c28c3481d8..aab89cb869a 100644 --- a/src/xrGame/IKFoot.cpp +++ b/src/xrGame/IKFoot.cpp @@ -281,7 +281,7 @@ ik_goal_matrix::e_collide_state CIKFoot::rotate( clamp(s, 0.f, 1.f); float angle = asinf(-s); VERIFY(_valid(angle)); - clamp(angle, -M_PI / 6, M_PI / 6); + clamp(angle, -M_PI / 6, M_PI / 6); ik_goal_matrix::e_collide_state cl_state = ik_goal_matrix::cl_undefined; if (!fis_zero(s)) { diff --git a/src/xrGame/MainMenu.cpp b/src/xrGame/MainMenu.cpp index 27d88868b0a..54a4d3b8bd5 100644 --- a/src/xrGame/MainMenu.cpp +++ b/src/xrGame/MainMenu.cpp @@ -9,6 +9,7 @@ #include "ui\UITextureMaster.h" #include "ui\UIXmlInit.h" #include +#include #include "ui\UIBtnHint.h" #include "UICursor.h" #include "xrGameSpy/GameSpy_Full.h" @@ -343,7 +344,7 @@ void CMainMenu::IR_OnKeyboardPress(int dik) Console->Show(); return; } - if (DIK_F12 == dik) + if (SDL_SCANCODE_F12 == dik) { GEnv.Render->Screenshot(); return; diff --git a/src/xrGame/UICursor.cpp b/src/xrGame/UICursor.cpp index 77a73ad8091..cf5070da432 100644 --- a/src/xrGame/UICursor.cpp +++ b/src/xrGame/UICursor.cpp @@ -107,8 +107,8 @@ void CUICursor::UpdateCursorPosition(int _dx, int _dy) { Ivector2 pti; IInputReceiver::IR_GetMousePosReal(pti); - vPos.x = (float)pti.x * (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.right); - vPos.y = (float)pti.y * (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.bottom); + vPos.x = (float)pti.x * (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.w); + vPos.y = (float)pti.y * (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.h); } else { @@ -124,9 +124,9 @@ void CUICursor::SetUICursorPosition(Fvector2 pos) { vPos = pos; POINT p; - p.x = iFloor(vPos.x / (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.right)); - p.y = iFloor(vPos.y / (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.bottom)); - if (m_b_use_win_cursor) - ClientToScreen(Device.m_hWnd, (LPPOINT)&p); + p.x = iFloor(vPos.x / (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.w)); + p.y = iFloor(vPos.y / (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.h)); + //if (m_b_use_win_cursor) + // ClientToScreen(Device.m_hWnd, (LPPOINT)&p); SetCursorPos(p.x, p.y); } diff --git a/src/xrGame/ik/IKLimb.cpp b/src/xrGame/ik/IKLimb.cpp index e3ea0413922..10d7fd35b6a 100644 --- a/src/xrGame/ik/IKLimb.cpp +++ b/src/xrGame/ik/IKLimb.cpp @@ -265,8 +265,8 @@ IC void set_limits(float& min, float& max, SJointLimit& l) max = -l.limit.x; min += M_PI; max += M_PI; - clamp(min, 0.f, 2 * M_PI); - clamp(max, 0.f, 2 * M_PI); + clamp(min, 0.f, 2 * M_PI); + clamp(max, 0.f, 2 * M_PI); } IC void free_limits(float& min, float& max) diff --git a/src/xrGame/packages.config b/src/xrGame/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/xrGame/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/xrGame/xrGame.vcxproj b/src/xrGame/xrGame.vcxproj index bf553e6a043..515b00c572d 100644 --- a/src/xrGame/xrGame.vcxproj +++ b/src/xrGame/xrGame.vcxproj @@ -3839,12 +3839,24 @@ {ccd4afae-aa10-42c6-a452-fdee497ccdf1} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/xrGame/xrGame.vcxproj.filters b/src/xrGame/xrGame.vcxproj.filters index 17d827622d6..870d092c18c 100644 --- a/src/xrGame/xrGame.vcxproj.filters +++ b/src/xrGame/xrGame.vcxproj.filters @@ -10230,4 +10230,10 @@ Core\Client\Objects\items & weapons\Explosives + + + + + + \ No newline at end of file diff --git a/src/xrGame/xr_level_controller.cpp b/src/xrGame/xr_level_controller.cpp index 6650d7bdc01..5d6c9c09b4b 100644 --- a/src/xrGame/xr_level_controller.cpp +++ b/src/xrGame/xr_level_controller.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include +#include #include "xrEngine/xr_ioconsole.h" #include "xrEngine/xr_input.h" #include "xrEngine/xr_ioc_cmd.h" @@ -49,32 +50,41 @@ _action actions[] = {{"left", kLEFT, _both}, {"right", kRIGHT, _both}, {"up", kU {NULL, kLASTACTION, _both}}; -_keyboard keyboards[] = {{"kESCAPE", DIK_ESCAPE}, {"k1", DIK_1}, {"k2", DIK_2}, {"k3", DIK_3}, {"k4", DIK_4}, - {"k5", DIK_5}, {"k6", DIK_6}, {"k7", DIK_7}, {"k8", DIK_8}, {"k9", DIK_9}, {"k0", DIK_0}, {"kMINUS", DIK_MINUS}, - {"kEQUALS", DIK_EQUALS}, {"kBACK", DIK_BACK}, {"kTAB", DIK_TAB}, {"kQ", DIK_Q}, {"kW", DIK_W}, {"kE", DIK_E}, - {"kR", DIK_R}, {"kT", DIK_T}, {"kY", DIK_Y}, {"kU", DIK_U}, {"kI", DIK_I}, {"kO", DIK_O}, {"kP", DIK_P}, - {"kLBRACKET", DIK_LBRACKET}, {"kRBRACKET", DIK_RBRACKET}, {"kRETURN", DIK_RETURN}, {"kLCONTROL", DIK_LCONTROL}, - {"kA", DIK_A}, {"kS", DIK_S}, {"kD", DIK_D}, {"kF", DIK_F}, {"kG", DIK_G}, {"kH", DIK_H}, {"kJ", DIK_J}, - {"kK", DIK_K}, {"kL", DIK_L}, {"kSEMICOLON", DIK_SEMICOLON}, {"kAPOSTROPHE", DIK_APOSTROPHE}, {"kGRAVE", DIK_GRAVE}, - {"kLSHIFT", DIK_LSHIFT}, {"kBACKSLASH", DIK_BACKSLASH}, {"kZ", DIK_Z}, {"kX", DIK_X}, {"kC", DIK_C}, {"kV", DIK_V}, - {"kB", DIK_B}, {"kN", DIK_N}, {"kM", DIK_M}, {"kCOMMA", DIK_COMMA}, {"kPERIOD", DIK_PERIOD}, {"kSLASH", DIK_SLASH}, - {"kRSHIFT", DIK_RSHIFT}, {"kMULTIPLY", DIK_MULTIPLY}, {"kLMENU", DIK_LMENU}, {"kSPACE", DIK_SPACE}, - {"kCAPITAL", DIK_CAPITAL}, {"kF1", DIK_F1}, {"kF2", DIK_F2}, {"kF3", DIK_F3}, {"kF4", DIK_F4}, {"kF5", DIK_F5}, - {"kF6", DIK_F6}, {"kF7", DIK_F7}, {"kF8", DIK_F8}, {"kF9", DIK_F9}, {"kF10", DIK_F10}, {"kNUMLOCK", DIK_NUMLOCK}, - {"kSCROLL", DIK_SCROLL}, {"kNUMPAD7", DIK_NUMPAD7}, {"kNUMPAD8", DIK_NUMPAD8}, {"kNUMPAD9", DIK_NUMPAD9}, - {"kSUBTRACT", DIK_SUBTRACT}, {"kNUMPAD4", DIK_NUMPAD4}, {"kNUMPAD5", DIK_NUMPAD5}, {"kNUMPAD6", DIK_NUMPAD6}, - {"kADD", DIK_ADD}, {"kNUMPAD1", DIK_NUMPAD1}, {"kNUMPAD2", DIK_NUMPAD2}, {"kNUMPAD3", DIK_NUMPAD3}, - {"kNUMPAD0", DIK_NUMPAD0}, {"kDECIMAL", DIK_DECIMAL}, {"kF11", DIK_F11}, {"kF12", DIK_F12}, {"kF13", DIK_F13}, - {"kF14", DIK_F14}, {"kF15", DIK_F15}, {"kKANA", DIK_KANA}, {"kCONVERT", DIK_CONVERT}, {"kNOCONVERT", DIK_NOCONVERT}, - {"kYEN", DIK_YEN}, {"kNUMPADEQUALS", DIK_NUMPADEQUALS}, {"kCIRCUMFLEX", DIK_CIRCUMFLEX}, {"kAT", DIK_AT}, - {"kCOLON", DIK_COLON}, {"kUNDERLINE", DIK_UNDERLINE}, {"kKANJI", DIK_KANJI}, {"kSTOP", DIK_STOP}, {"kAX", DIK_AX}, - {"kUNLABELED", DIK_UNLABELED}, {"kNUMPADENTER", DIK_NUMPADENTER}, {"kRCONTROL", DIK_RCONTROL}, - {"kNUMPADCOMMA", DIK_NUMPADCOMMA}, {"kDIVIDE", DIK_DIVIDE}, {"kSYSRQ", DIK_SYSRQ}, {"kRMENU", DIK_RMENU}, - {"kHOME", DIK_HOME}, {"kUP", DIK_UP}, {"kPRIOR", DIK_PRIOR}, {"kLEFT", DIK_LEFT}, {"kRIGHT", DIK_RIGHT}, - {"kEND", DIK_END}, {"kDOWN", DIK_DOWN}, {"kNEXT", DIK_NEXT}, {"kINSERT", DIK_INSERT}, {"kDELETE", DIK_DELETE}, - {"kLWIN", DIK_LWIN}, {"kRWIN", DIK_RWIN}, {"kAPPS", DIK_APPS}, {"kPAUSE", DIK_PAUSE}, {"mouse1", MOUSE_1}, - {"mouse2", MOUSE_2}, {"mouse3", MOUSE_3}, {"mouse4", MOUSE_4}, {"mouse5", MOUSE_5}, {"mouse6", MOUSE_6}, - {"mouse7", MOUSE_7}, {"mouse8", MOUSE_8}, {NULL, 0}}; +_keyboard keyboards[] = {{"kESCAPE", SDL_SCANCODE_ESCAPE}, {"k1", SDL_SCANCODE_1}, {"k2", SDL_SCANCODE_2}, + {"k3", SDL_SCANCODE_3}, {"k4", SDL_SCANCODE_4}, {"k5", SDL_SCANCODE_5}, {"k6", SDL_SCANCODE_6}, + {"k7", SDL_SCANCODE_7}, {"k8", SDL_SCANCODE_8}, {"k9", SDL_SCANCODE_9}, {"k0", SDL_SCANCODE_0}, + {"kMINUS", SDL_SCANCODE_MINUS}, {"kEQUALS", SDL_SCANCODE_EQUALS}, {"kBACK", SDL_SCANCODE_BACKSPACE}, + {"kTAB", SDL_SCANCODE_TAB}, {"kQ", SDL_SCANCODE_Q}, {"kW", SDL_SCANCODE_W}, {"kE", SDL_SCANCODE_E}, + {"kR", SDL_SCANCODE_R}, {"kT", SDL_SCANCODE_T}, {"kY", SDL_SCANCODE_Y}, {"kU", SDL_SCANCODE_U}, + {"kI", SDL_SCANCODE_I}, {"kO", SDL_SCANCODE_O}, {"kP", SDL_SCANCODE_P}, {"kLBRACKET", SDL_SCANCODE_LEFTBRACKET}, + {"kRBRACKET", SDL_SCANCODE_RIGHTBRACKET}, {"kRETURN", SDL_SCANCODE_RETURN}, {"kLCONTROL", SDL_SCANCODE_LCTRL}, + {"kA", SDL_SCANCODE_A}, {"kS", SDL_SCANCODE_S}, {"kD", SDL_SCANCODE_D}, {"kF", SDL_SCANCODE_F}, + {"kG", SDL_SCANCODE_G}, {"kH", SDL_SCANCODE_H}, {"kJ", SDL_SCANCODE_J}, {"kK", SDL_SCANCODE_K}, + {"kL", SDL_SCANCODE_L}, {"kSEMICOLON", SDL_SCANCODE_SEMICOLON}, {"kAPOSTROPHE", SDL_SCANCODE_APOSTROPHE}, + {"kGRAVE", SDL_SCANCODE_GRAVE}, {"kLSHIFT", SDL_SCANCODE_LSHIFT}, {"kBACKSLASH", SDL_SCANCODE_BACKSLASH}, + {"kZ", SDL_SCANCODE_Z}, {"kX", SDL_SCANCODE_X}, {"kC", SDL_SCANCODE_C}, {"kV", SDL_SCANCODE_V}, + {"kB", SDL_SCANCODE_B}, {"kN", SDL_SCANCODE_N}, {"kM", SDL_SCANCODE_M}, {"kCOMMA", SDL_SCANCODE_COMMA}, + {"kPERIOD", SDL_SCANCODE_PERIOD}, {"kSLASH", SDL_SCANCODE_SLASH}, {"kRSHIFT", SDL_SCANCODE_RSHIFT}, + {"kMULTIPLY", SDL_SCANCODE_KP_MULTIPLY}, {"kLMENU", SDL_SCANCODE_LALT}, {"kSPACE", SDL_SCANCODE_SPACE}, + {"kCAPITAL", SDL_SCANCODE_CAPSLOCK}, {"kF1", SDL_SCANCODE_F1}, {"kF2", SDL_SCANCODE_F2}, {"kF3", SDL_SCANCODE_F3}, + {"kF4", SDL_SCANCODE_F4}, {"kF5", SDL_SCANCODE_F5}, {"kF6", SDL_SCANCODE_F6}, {"kF7", SDL_SCANCODE_F7}, + {"kF8", SDL_SCANCODE_F8}, {"kF9", SDL_SCANCODE_F9}, {"kF10", SDL_SCANCODE_F10}, + {"kNUMLOCK", SDL_SCANCODE_NUMLOCKCLEAR}, {"kSCROLL", SDL_SCANCODE_SCROLLLOCK}, {"kNUMPAD7", SDL_SCANCODE_KP_7}, + {"kNUMPAD8", SDL_SCANCODE_KP_8}, {"kNUMPAD9", SDL_SCANCODE_KP_9}, {"kSUBTRACT", SDL_SCANCODE_KP_MINUS}, + {"kNUMPAD4", SDL_SCANCODE_KP_4}, {"kNUMPAD5", SDL_SCANCODE_KP_5}, {"kNUMPAD6", SDL_SCANCODE_KP_6}, + {"kADD", SDL_SCANCODE_KP_PLUS}, {"kNUMPAD1", SDL_SCANCODE_KP_1}, {"kNUMPAD2", SDL_SCANCODE_KP_2}, + {"kNUMPAD3", SDL_SCANCODE_KP_3}, {"kNUMPAD0", SDL_SCANCODE_KP_0}, {"kDECIMAL", SDL_SCANCODE_KP_DECIMAL}, + {"kF11", SDL_SCANCODE_F11}, {"kF12", SDL_SCANCODE_F12}, {"kF13", SDL_SCANCODE_F13}, {"kF14", SDL_SCANCODE_F14}, + {"kF15", SDL_SCANCODE_F15}, {"kNUMPADEQUALS", SDL_SCANCODE_KP_EQUALS}, {"kCIRCUMFLEX", SDL_SCANCODE_GRAVE}, + {"kAT", SDL_SCANCODE_KP_AT}, {"kCOLON", SDL_SCANCODE_KP_COLON}, {"kSTOP", SDL_SCANCODE_STOP}, + {"kRCONTROL", SDL_SCANCODE_RCTRL}, {"kNUMPADCOMMA", SDL_SCANCODE_KP_COMMA}, {"kDIVIDE", SDL_SCANCODE_KP_DIVIDE}, + {"kSYSRQ", SDL_SCANCODE_SYSREQ}, {"kRMENU", SDL_SCANCODE_RALT}, {"kHOME", SDL_SCANCODE_HOME}, + {"kUP", SDL_SCANCODE_UP}, {"kPRIOR", SDL_SCANCODE_PRIOR}, {"kLEFT", SDL_SCANCODE_LEFT}, + {"kRIGHT", SDL_SCANCODE_RIGHT}, {"kEND", SDL_SCANCODE_END}, {"kDOWN", SDL_SCANCODE_DOWN}, + {"kNEXT", SDL_SCANCODE_AUDIONEXT}, {"kINSERT", SDL_SCANCODE_INSERT}, {"kDELETE", SDL_SCANCODE_DELETE}, + {"kLWIN", SDL_SCANCODE_LGUI}, {"kRWIN", SDL_SCANCODE_RGUI}, {"kAPPS", SDL_SCANCODE_APPLICATION}, + {"kPAUSE", SDL_SCANCODE_PAUSE}, {"mouse1", MOUSE_1}, {"mouse2", MOUSE_2}, {"mouse3", MOUSE_3}, {"mouse4", MOUSE_4}, + {"mouse5", MOUSE_5}, {"mouse6", MOUSE_6}, {"mouse7", MOUSE_7}, {"mouse8", MOUSE_8}, {NULL, 0}}; void initialize_bindings() { @@ -113,7 +123,7 @@ void remap_keys() { buff[0] = 0; _keyboard& kb = keyboards[idx]; - bool res = pInput->get_dik_name(kb.dik, buff, sizeof(buff)); + bool res = pInput->get_key_name(kb.dik, buff, sizeof(buff)); if (res) kb.key_local_name = buff; else diff --git a/src/xrPhysics/packages.config b/src/xrPhysics/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/xrPhysics/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/xrPhysics/xrPhysics.vcxproj b/src/xrPhysics/xrPhysics.vcxproj index b7800f41b71..e968aceb71c 100644 --- a/src/xrPhysics/xrPhysics.vcxproj +++ b/src/xrPhysics/xrPhysics.vcxproj @@ -329,12 +329,24 @@ {1bf75feb-87dd-486c-880b-227987d191c2} + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/xrPhysics/xrPhysics.vcxproj.filters b/src/xrPhysics/xrPhysics.vcxproj.filters index c0d6ff1b696..e562a40116f 100644 --- a/src/xrPhysics/xrPhysics.vcxproj.filters +++ b/src/xrPhysics/xrPhysics.vcxproj.filters @@ -594,4 +594,10 @@ physics\damage_receiver + + + + + + \ No newline at end of file diff --git a/src/xr_3da/xr_3da.vcxproj b/src/xr_3da/xr_3da.vcxproj index 4a2df84272e..ef31910daa2 100644 --- a/src/xr_3da/xr_3da.vcxproj +++ b/src/xr_3da/xr_3da.vcxproj @@ -89,9 +89,11 @@ true stdcpp17 + Disabled $(OutDir)$(ProjectName).pdb + true as-invoker-manifest-part.xml %(AdditionalManifestFiles) diff --git a/src/xr_3da/xr_3da.vcxproj.filters b/src/xr_3da/xr_3da.vcxproj.filters index 6b7e444c5d4..dddc93be7f7 100644 --- a/src/xr_3da/xr_3da.vcxproj.filters +++ b/src/xr_3da/xr_3da.vcxproj.filters @@ -29,4 +29,7 @@ resources + + + \ No newline at end of file