diff --git a/.travis.yml b/.travis.yml index 109630eeee9..f75a682dbef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ os: - linux before_script: - g++ --version - - sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev + - sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev liblockfile-dev libfreeimage-dev - sudo apt-get install cmake lua5.1-dev libssl-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev - mkdir bin - cd bin diff --git a/appveyor.yml b/appveyor.yml index 28d3c8bf3cf..79e1f6baf31 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,8 +12,14 @@ configuration: platform: - x64 - x86 +cache: +- packages -> **\packages.config before_build: -- cmd: git submodule update --init --recursive +- cmd: >- + nuget restore src\engine.sln + + git submodule update --init --recursive + build: project: src/engine.sln parallel: true diff --git a/src/.gitignore b/src/.gitignore index 7121891a08d..c161bcbb958 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,5 +1,6 @@ # exclude binaries and temporary files ipch/ +packages/ # User-specific files *.suo diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d73dd225fa1..9f602efae34 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ add_subdirectory(Layers) add_subdirectory(xrAICore) add_subdirectory(xrCDB) add_subdirectory(xrCore) -#add_subdirectory(xrEngine) +add_subdirectory(xrEngine) #add_subdirectory(xrGame) #add_subdirectory(xrNetServer) add_subdirectory(xrParticles) diff --git a/src/Common/Common.hpp b/src/Common/Common.hpp index c8f9c4b9b66..cd8b44db774 100644 --- a/src/Common/Common.hpp +++ b/src/Common/Common.hpp @@ -5,3 +5,11 @@ #include "Common/CommonImportExport.inl" #include "Common/FSMacros.hpp" #include "Include/xrAPI/xrAPI.h" + +#if __has_include() +#include +#endif + +#if __has_include() +#include +#endif diff --git a/src/Common/PlatformLinux.inl b/src/Common/PlatformLinux.inl index b82ac5930b4..d981ba5157e 100644 --- a/src/Common/PlatformLinux.inl +++ b/src/Common/PlatformLinux.inl @@ -50,11 +50,27 @@ #define __pragma(...) _Pragma(#__VA_ARGS__) #define __declspec(x) #define CALLBACK +#define TEXT(x) strdup(x) + +inline char* _strlwr_l(char* str, locale_t loc) +{ +//TODO +} + +inline char* _strupr_l(char* str, locale_t loc) +{ +//TODO +} + +#define VOID void +#define HKL void* +#define ActivateKeyboardLayout(x, y) {} +#define ScreenToClient(hwnd, p) {} #define __except(X) catch(X) /* -static inline long InterlockedExchange(volatile long *val, long new_val) +static inline long InterlockedExchange(volatile long* val, long new_val) { long old_val; do { @@ -75,11 +91,11 @@ inline void Sleep(int ms) } inline void _splitpath ( - const char *path, // Path Input - char *drive, // Drive : Output - char *dir, // Directory : Output - char *fname, // Filename : Output - char *ext // Extension : Output + const char* path, // Path Input + char* drive, // Drive : Output + char* dir, // Directory : Output + char* fname, // Filename : Output + char* ext // Extension : Output ){} inline unsigned long GetLastError() @@ -94,28 +110,34 @@ inline int GetExceptionCode() #define xr_unlink unlink -typedef char BOOL; +#include +typedef int32_t BOOL; +typedef uint8_t BYTE; +typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef int32_t LONG; +#ifndef _LIBRAW_TYPES_H +typedef int64_t INT64; +typedef uint64_t UINT64; +#endif + typedef char* LPSTR; typedef char* PSTR; typedef char* LPTSTR; typedef const char* LPCSTR; typedef const char* LPCTSTR; -typedef unsigned char BYTE; typedef unsigned char* LPBYTE; typedef unsigned int UINT; typedef int INT; -typedef long LONG; typedef unsigned long ULONG; typedef unsigned long& ULONG_PTR; typedef long long int LARGE_INTEGER; typedef unsigned long long int ULARGE_INTEGER; -typedef unsigned short WORD; typedef unsigned short* LPWORD; -typedef unsigned long DWORD; typedef unsigned long* LPDWORD; -typedef const void *LPCVOID; -typedef long long int *PLARGE_INTEGER; +typedef const void* LPCVOID; +typedef long long int* PLARGE_INTEGER; typedef wchar_t WCHAR; @@ -131,6 +153,28 @@ typedef struct { WORD cbSize; } WAVEFORMATEX, *LPWAVEFORMATEX; +typedef struct tagSTICKYKEYS +{ + DWORD cbSize; + DWORD dwFlags; +} STICKYKEYS, *LPSTICKYKEYS; + +typedef struct tagFILTERKEYS +{ + UINT cbSize; + DWORD dwFlags; + DWORD iWaitMSec; + DWORD iDelayMSec; + DWORD iRepeatMSec; + DWORD iBounceMSec; +} FILTERKEYS, *LPFILTERKEYS; + +typedef struct tagTOGGLEKEYS +{ + DWORD cbSize; + DWORD dwFlags; +} TOGGLEKEYS, *LPTOGGLEKEYS; + typedef struct _EXCEPTION_POINTERS { } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; @@ -145,18 +189,16 @@ typedef long LONG_PTR; #endif // XR_X64 typedef int HANDLE; -typedef void *HMODULE; -typedef void *LPVOID; +typedef void* HMODULE; +typedef void* LPVOID; typedef UINT_PTR WPARAM; typedef LONG_PTR LPARAM; typedef long HRESULT; typedef long LRESULT; typedef long _W64; -//typedef void *HWND; -typedef SDL_Window *HWND; -typedef void *HDC; -//typedef void *HGLRC; -typedef SDL_GLContext HGLRC; +//typedef void* HWND; +typedef SDL_Window* HWND; +typedef void* HDC; typedef float FLOAT; typedef unsigned char UINT8; @@ -172,10 +214,15 @@ typedef struct tagPOINT { long y; } POINT, *PPOINT, *LPPOINT; +#define DWORD_PTR UINT_PTR #define WM_USER 0x0400 +#define WA_INACTIVE 0 +#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16)) +#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF)) -#define TRUE 1 -#define FALSE 0 + +#define TRUE true +#define FALSE false #define NONE 0 #define CONST const @@ -196,9 +243,12 @@ typedef dirent DirEntryType; #define strcmpi stricmp #define lstrcpy strcpy #define stricmp strcasecmp -#define strncpy_s(dest, size, source, num) strncpy(dest, source, num) -#define strcpy_s(dest, num, source) strcpy(dest, source) +#define strupr SDL_strupr +#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num)) +#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source)) +#define strcat_s(dest, num, source) (dest == strcat(dest, source)) #define _vsnprintf vsnprintf +#define vsprintf_s(dest, size, format, args) vsprintf(dest, format, args) #define _alloca alloca #define _snprintf snprintf #define sprintf_s(buffer, buffer_size, stringbuffer, ...) sprintf(buffer, stringbuffer, ##__VA_ARGS__) @@ -241,7 +291,11 @@ inline int _filelength(int fd) #define __max(a, b) std::max(a, b) #define __min(a, b) std::min(a, b) -#define xr_itoa SDL_itoa +#define itoa SDL_itoa +#define _itoa_s(value, buffer, radix) SDL_itoa(value, buffer, radix) +#define _locale_t locale_t +#define _isalpha_l isalpha_l +#define _create_locale(category, arg) newlocale(category, arg, (locale_t) 0) #define ZeroMemory(p, sz) memset((p), 0, (sz)) #define CopyMemory(d, s, n) memcpy(d, s, n) @@ -256,4 +310,7 @@ inline int _filelength(int fd) #define _MAX_DRIVE 3 #define _MAX_DIR 256 #define _MAX_FNAME 256 -#define _MAX_EXT 256 \ No newline at end of file +#define _MAX_EXT 256 + +#define SEM_FAILCRITICALERRORS 1 +#define SetErrorMode(x) {} diff --git a/src/Common/PlatformWindows.inl b/src/Common/PlatformWindows.inl index 54c1b0a0f01..06dc2f3888e 100644 --- a/src/Common/PlatformWindows.inl +++ b/src/Common/PlatformWindows.inl @@ -1,7 +1,6 @@ #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define IDIRECTPLAY2_OR_GREATER // ? -#define DIRECTINPUT_VERSION 0x0800 // #ifndef _WIN32_WINNT // Request Windows 7 functionality diff --git a/src/Include/editor/engine.hpp b/src/Include/editor/engine.hpp index e9337e76a86..f39f3fb3d31 100644 --- a/src/Include/editor/engine.hpp +++ b/src/Include/editor/engine.hpp @@ -25,6 +25,7 @@ class engine_base virtual void pause(bool const& value) = 0; virtual void capture_input(bool const& value) = 0; virtual void disconnect() = 0; + virtual bool quit_requested() const = 0; // shared_str support virtual void value(LPCSTR value, shared_str& result) = 0; virtual LPCSTR value(shared_str const& value) = 0; diff --git a/src/Layers/xrRender/D3DXRenderBase.h b/src/Layers/xrRender/D3DXRenderBase.h index 1ff80280f39..53c14675e2f 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) 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..48c113a4e14 100644 --- a/src/Layers/xrRender/HW.cpp +++ b/src/Layers/xrRender/HW.cpp @@ -5,11 +5,6 @@ #include "xrEngine/XR_IOConsole.h" #include "xrCore/xr_token.h" -extern ENGINE_API xr_vector AvailableVideoModes; - -void fill_vid_mode_list(CHW* _hw); -void free_vid_mode_list(); - CHW HW; CHW::CHW() {} @@ -36,14 +31,11 @@ void CHW::DestroyD3D() _RELEASE(pD3D); } -void CHW::CreateDevice(HWND m_hWnd, bool move_window) +void CHW::CreateDevice(SDL_Window* m_sdlWnd) { - m_move_window = move_window; CreateD3D(); - bool bWindowed = !psDeviceFlags.is(rsFullscreen); - if (GEnv.isDedicatedServer) - bWindowed = true; + const bool bWindowed = !psDeviceFlags.is(rsFullscreen); m_DriverType = Caps.bForceGPU_REF ? D3DDEVTYPE_REF : D3DDEVTYPE_HAL; @@ -109,9 +101,9 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) fDepth = selectDepthStencil(fTarget); } - if ((D3DFMT_UNKNOWN == fTarget) || (D3DFMT_UNKNOWN == fTarget)) + if (D3DFMT_UNKNOWN == fTarget || D3DFMT_UNKNOWN == fDepth) { - Msg("Failed to initialize graphics hardware.\n" + Log("Failed to initialize graphics hardware.\n" "Please try to restart the game.\n" "Can not find matching format for back buffer."); FlushLog(); @@ -124,7 +116,8 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) D3DPRESENT_PARAMETERS& P = DevPP; ZeroMemory(&P, sizeof(P)); - selectResolution(P.BackBufferWidth, P.BackBufferHeight, bWindowed); + DevPP.BackBufferWidth = Device.dwWidth; + DevPP.BackBufferHeight = Device.dwHeight; // Back buffer P.BackBufferFormat = fTarget; @@ -136,7 +129,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: ", SDL_GetError()); + P.Windowed = bWindowed; // Depth/stencil @@ -146,25 +154,19 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) // Refresh rate if (bWindowed) - { P.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - P.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - } else - { P.PresentationInterval = selectPresentInterval(); // Vsync (R1\R2) - P.FullScreen_RefreshRateInHz = selectRefresh(P.BackBufferWidth, P.BackBufferHeight, fTarget); - } // 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); } @@ -198,9 +200,6 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) u32 memory = pDevice->GetAvailableTextureMem(); Msg("* Texture memory: %d M", memory / (1024 * 1024)); Msg("* DDI-level: %2.1f", float(D3DXGetDriverLevel(pDevice)) / 100.f); - - updateWindowProps(m_hWnd); - fill_vid_mode_list(this); } void CHW::DestroyDevice() @@ -218,14 +217,12 @@ void CHW::DestroyDevice() _RELEASE(HW.pDevice); DestroyD3D(); - - free_vid_mode_list(); } ////////////////////////////////////////////////////////////////////// // Resetting device ////////////////////////////////////////////////////////////////////// -void CHW::Reset(HWND hwnd) +void CHW::Reset() { #ifdef DEBUG _RELEASE(dwDebugSB); @@ -235,24 +232,17 @@ void CHW::Reset(HWND hwnd) _RELEASE(pBaseZB); _RELEASE(pBaseRT); - bool bWindowed = true; - if (!GEnv.isDedicatedServer) - bWindowed = !psDeviceFlags.is(rsFullscreen); + const bool bWindowed = !psDeviceFlags.is(rsFullscreen); - selectResolution(DevPP.BackBufferWidth, DevPP.BackBufferHeight, bWindowed); + DevPP.BackBufferWidth = Device.dwWidth; + DevPP.BackBufferHeight = Device.dwHeight; // Windoze DevPP.SwapEffect = bWindowed ? D3DSWAPEFFECT_COPY : D3DSWAPEFFECT_DISCARD; DevPP.Windowed = bWindowed; if (!bWindowed) - { DevPP.PresentationInterval = selectPresentInterval(); // Vsync (R1\R2) - DevPP.FullScreen_RefreshRateInHz = selectRefresh(DevPP.BackBufferWidth, DevPP.BackBufferHeight, Caps.fTarget); - } else - { DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - } while (true) { @@ -269,9 +259,6 @@ void CHW::Reset(HWND hwnd) #ifdef DEBUG R_CHK(pDevice->CreateStateBlock(D3DSBT_ALL, &dwDebugSB)); #endif - - updateWindowProps(hwnd); - ShowWindow(hwnd, SW_SHOWNORMAL); } D3DFORMAT CHW::selectDepthStencil(D3DFORMAT fTarget) @@ -301,38 +288,6 @@ D3DFORMAT CHW::selectDepthStencil(D3DFORMAT fTarget) return D3DFMT_UNKNOWN; } -void CHW::selectResolution(u32& dwWidth, u32& dwHeight, BOOL bWindowed) -{ - fill_vid_mode_list(this); - - if (GEnv.isDedicatedServer) - { - dwWidth = 640; - dwHeight = 480; - return; - } - - if (bWindowed) - { - dwWidth = psCurrentVidMode[0]; - dwHeight = psCurrentVidMode[1]; - } - else // check - { - string64 buff; - xr_sprintf(buff, sizeof(buff), "%dx%d", psCurrentVidMode[0], psCurrentVidMode[1]); - - if (_ParseItem(buff, AvailableVideoModes.data()) == u32(-1)) // not found - { // select safe - xr_sprintf(buff, sizeof(buff), "vid_mode %s", AvailableVideoModes[0].name); - Console->Execute(buff); - } - - dwWidth = psCurrentVidMode[0]; - dwHeight = psCurrentVidMode[1]; - } -} - u32 CHW::selectPresentInterval() { D3DCAPS9 caps; @@ -421,28 +376,6 @@ u32 CHW::selectGPU() return D3DCREATE_SOFTWARE_VERTEXPROCESSING; } -u32 CHW::selectRefresh(u32 dwWidth, u32 dwHeight, D3DFORMAT fmt) -{ - if (psDeviceFlags.is(rsRefresh60hz)) - return D3DPRESENT_RATE_DEFAULT; - - auto selected = D3DPRESENT_RATE_DEFAULT; - const auto count = pD3D->GetAdapterModeCount(DevAdapter, fmt); - for (u32 I = 0; I < count; I++) - { - D3DDISPLAYMODE Mode; - pD3D->EnumAdapterModes(DevAdapter, fmt, I, &Mode); - if (Mode.Width == dwWidth && Mode.Height == dwHeight) - { - //if (Mode.RefreshRate > selected) - // selected = Mode.RefreshRate; - if (Mode.RefreshRate <= maxRefreshRate && Mode.RefreshRate>selected) - selected = Mode.RefreshRate; //ECO_RENDER modif. - } - } - return selected; -} - BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage) { auto result = pD3D->CheckDeviceFormat(DevAdapter, m_DriverType, Caps.fTarget, usage, (D3DRESOURCETYPE)type, fmt); @@ -450,123 +383,3 @@ BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage) return FALSE; return TRUE; } - -void CHW::updateWindowProps(HWND m_hWnd) -{ - bool bWindowed = !psDeviceFlags.is(rsFullscreen); - - if (GEnv.isDedicatedServer) - bWindowed = true; - - u32 dwWindowStyle = 0; - // Set window properties depending on what mode were in. - if (bWindowed) - { - 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); - // 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 - // example, when switching from 640x480 fullscreen to windowed with - // a 1000x600 window on a 1024x768 desktop, it is impossible to set - // the window size to 1000x600 until after the display mode has - // 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; - - 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); - } - 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); - } - } - else - { - SetWindowLong(m_hWnd, GWL_STYLE, dwWindowStyle = WS_POPUP | WS_VISIBLE); - } - - if (!GEnv.isDedicatedServer) - SetForegroundWindow(m_hWnd); -} - -struct uniqueRenderingMode -{ - uniqueRenderingMode(pcstr v) : value(v) {} - pcstr value; - bool operator()(const xr_token other) const { return !xr_stricmp(value, other.name);} -}; - -void free_vid_mode_list() -{ - for (auto& mode : AvailableVideoModes) - xr_free(mode.name); - AvailableVideoModes.clear(); -} - -void fill_vid_mode_list(CHW* _hw) -{ - if (!AvailableVideoModes.empty()) - return; - - xr_vector displayModes; - - // Get the number of display modes available - const auto cnt = _hw->pD3D->GetAdapterModeCount(_hw->DevAdapter, _hw->Caps.fTarget); - - // Get the list of display modes - displayModes.resize(cnt); - for (auto i = 0; i < cnt; ++i) - _hw->pD3D->EnumAdapterModes(_hw->DevAdapter, _hw->Caps.fTarget, i, &displayModes[i]); - - int i = 0; - auto& AVM = AvailableVideoModes; - for (const auto& it : displayModes) - { - string32 str; - - xr_sprintf(str, sizeof(str), "%dx%d", it.Width, it.Height); - - if (AVM.cend() != std::find_if(AVM.cbegin(), AVM.cend(), uniqueRenderingMode(str))) - continue; - - AVM.emplace_back(xr_token(xr_strdup(str), i)); - ++i; - } - AVM.emplace_back(xr_token(nullptr, -1)); - - Msg("Available video modes[%d]:", AVM.size()); - for (const auto& mode : AVM) - Msg("[%s]", mode.name); -} diff --git a/src/Layers/xrRender/HW.h b/src/Layers/xrRender/HW.h index 4e7d5007ef6..d59ea6e0001 100644 --- a/src/Layers/xrRender/HW.h +++ b/src/Layers/xrRender/HW.h @@ -23,25 +23,22 @@ class CHW void DestroyD3D(); #endif // !USE_OGL - void CreateDevice(HWND hw, bool move_window); + void CreateDevice(SDL_Window* m_sdlWnd); void DestroyDevice(); - void Reset(HWND hw); + void Reset(); #ifndef USE_OGL - void selectResolution(u32& dwWidth, u32& dwHeight, BOOL bWindowed); D3DFORMAT selectDepthStencil(D3DFORMAT); u32 selectPresentInterval(); u32 selectGPU(); - u32 selectRefresh(u32 dwWidth, u32 dwHeight, D3DFORMAT fmt); BOOL support(D3DFORMAT fmt, DWORD type, DWORD usage); #endif // !USE_OGL - void updateWindowProps(HWND hw); #ifdef DEBUG #if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL) - void Validate(void) {}; + void Validate(void){}; #else // USE_DX10 void Validate(void) { @@ -66,16 +63,16 @@ class CHW CHWCaps Caps; - HWND m_hWnd; + SDL_Window* m_hWnd; HDC m_hDC; - HGLRC m_hRC; + SDL_GLContext 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 +83,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 +106,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; @@ -129,8 +126,6 @@ class CHW void UpdateViews(); #endif #if defined(USE_DX10) || defined(USE_DX11) - DXGI_RATIONAL selectRefresh(u32 dwWidth, u32 dwHeight, DXGI_FORMAT fmt); - virtual void OnAppActivate(); virtual void OnAppDeactivate(); #endif // USE_DX10 @@ -141,11 +136,6 @@ class CHW void ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil); HRESULT Present(UINT SyncInterval, UINT Flags); #endif // USE_OGL - - int maxRefreshRate = 200; //ECO_RENDER add - -private: - bool m_move_window = true; }; extern ECORE_API CHW HW; diff --git a/src/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index 36095bc9a66..1b736ac3342 100644 --- a/src/Layers/xrRender/r__dsgraph_build.cpp +++ b/src/Layers/xrRender/r__dsgraph_build.cpp @@ -804,7 +804,7 @@ void D3DXRenderBase::DestroyHW() HW.DestroyDevice(); } -void D3DXRenderBase::Reset(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) +void D3DXRenderBase::Reset(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) { #if defined(DEBUG) && !defined(USE_OGL) _SHOW_REF("*ref -CRenderDevice::ResetTotal: DeviceREF:", HW.pDevice); @@ -812,7 +812,7 @@ void D3DXRenderBase::Reset(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth Resources->reset_begin(); Memory.mem_compact(); - HW.Reset(hWnd); + HW.Reset(); #if defined(USE_OGL) dwWidth = psCurrentVidMode[0]; @@ -901,9 +901,9 @@ void D3DXRenderBase::OnDeviceCreate(const char* shName) } } -void D3DXRenderBase::Create(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool move_window) +void D3DXRenderBase::Create(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) { - HW.CreateDevice(hWnd, move_window); + HW.CreateDevice(hWnd); #if defined(USE_OGL) dwWidth = psCurrentVidMode[0]; dwHeight = psCurrentVidMode[1]; diff --git a/src/Layers/xrRenderDX10/dx10HW.cpp b/src/Layers/xrRenderDX10/dx10HW.cpp index e325fa4e36c..17de8b5b09e 100644 --- a/src/Layers/xrRenderDX10/dx10HW.cpp +++ b/src/Layers/xrRenderDX10/dx10HW.cpp @@ -8,11 +8,6 @@ #include "StateManager/dx10SamplerStateCache.h" #include "StateManager/dx10StateCache.h" -extern ENGINE_API xr_vector AvailableVideoModes; - -void fill_vid_mode_list(CHW* _hw); -void free_vid_mode_list(); - CHW HW; CHW::CHW() @@ -64,12 +59,11 @@ void CHW::DestroyD3D() _RELEASE(m_pFactory); } -void CHW::CreateDevice(HWND m_hWnd, bool move_window) +void CHW::CreateDevice(SDL_Window* m_sdlWnd) { - m_move_window = move_window; CreateD3D(); - bool bWindowed = !psDeviceFlags.is(rsFullscreen); + const bool bWindowed = !psDeviceFlags.is(rsFullscreen); m_DriverType = Caps.bForceGPU_REF ? D3D_DRIVER_TYPE_REFERENCE : D3D_DRIVER_TYPE_HARDWARE; @@ -94,7 +88,8 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) DXGI_SWAP_CHAIN_DESC& sd = m_ChainDesc; ZeroMemory(&sd, sizeof(sd)); - selectResolution(sd.BufferDesc.Width, sd.BufferDesc.Height, bWindowed); + sd.BufferDesc.Width = Device.dwWidth; + sd.BufferDesc.Height = Device.dwHeight; // Back buffer //. P.BackBufferWidth = dwWidth; @@ -109,8 +104,29 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) sd.SampleDesc.Quality = 0; // Windoze + /* XXX: + Probably the reason of weird tearing + glitches reported by Shoker in windowed + mode with VSync enabled. + XXX: Fix this windoze stuff!!! + */ 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: ", SDL_GetError()); + sd.Windowed = bWindowed; // Depth/stencil (DX10 don't need this?) @@ -118,23 +134,12 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) //P.AutoDepthStencilFormat = fDepth; //P.Flags = 0; //. D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL; - // Refresh rate - if (bWindowed) - { - sd.BufferDesc.RefreshRate.Numerator = 60; - sd.BufferDesc.RefreshRate.Denominator = 1; - } - else - { - sd.BufferDesc.RefreshRate = selectRefresh(sd.BufferDesc.Width, sd.BufferDesc.Height, sd.BufferDesc.Format); - } - // Additional set up sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; UINT createDeviceFlags = 0; #ifdef DEBUG -// createDeviceFlags |= D3Dxx_CREATE_DEVICE_DEBUG; + // createDeviceFlags |= D3Dxx_CREATE_DEVICE_DEBUG; #endif HRESULT R; #ifdef USE_DX11 @@ -182,10 +187,6 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) const auto memory = Desc.DedicatedVideoMemory; Msg("* Texture memory: %d M", memory / (1024 * 1024)); //Msg("* DDI-level: %2.1f", float(D3DXGetDriverLevel(pDevice)) / 100.f); -#ifndef _EDITOR - updateWindowProps(m_hWnd); - fill_vid_mode_list(this); -#endif } void CHW::DestroyDevice() @@ -220,28 +221,21 @@ void CHW::DestroyDevice() _RELEASE(HW.pDevice); DestroyD3D(); - - free_vid_mode_list(); } ////////////////////////////////////////////////////////////////////// // Resetting device ////////////////////////////////////////////////////////////////////// -void CHW::Reset(HWND hwnd) +void CHW::Reset() { DXGI_SWAP_CHAIN_DESC& cd = m_ChainDesc; - BOOL bWindowed = !psDeviceFlags.is(rsFullscreen); + const bool bWindowed = !psDeviceFlags.is(rsFullscreen); cd.Windowed = bWindowed; m_pSwapChain->SetFullscreenState(!bWindowed, NULL); DXGI_MODE_DESC& desc = m_ChainDesc.BufferDesc; - selectResolution(desc.Width, desc.Height, bWindowed); - if (bWindowed) - { - desc.RefreshRate.Numerator = 60; - desc.RefreshRate.Denominator = 1; - } - else - desc.RefreshRate = selectRefresh(desc.Width, desc.Height, desc.Format); + desc.Width = Device.dwWidth; + desc.Height = Device.dwHeight; + CHK_DX(m_pSwapChain->ResizeTarget(&desc)); _SHOW_REF("refCount:pBaseZB", pBaseZB); @@ -251,9 +245,6 @@ void CHW::Reset(HWND hwnd) CHK_DX(m_pSwapChain->ResizeBuffers( cd.BufferCount, desc.Width, desc.Height, desc.Format, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH)); UpdateViews(); - - updateWindowProps(hwnd); - ShowWindow(hwnd, SW_SHOWNORMAL); } D3DFORMAT CHW::selectDepthStencil(D3DFORMAT /*fTarget*/) @@ -263,75 +254,6 @@ D3DFORMAT CHW::selectDepthStencil(D3DFORMAT /*fTarget*/) return D3DFMT_D24S8; } -void CHW::selectResolution(u32& dwWidth, u32& dwHeight, BOOL bWindowed) -{ - fill_vid_mode_list(this); - - if (bWindowed) - { - dwWidth = psCurrentVidMode[0]; - dwHeight = psCurrentVidMode[1]; - } - else // check - { - string64 buff; - xr_sprintf(buff, sizeof(buff), "%dx%d", psCurrentVidMode[0], psCurrentVidMode[1]); - - if (_ParseItem(buff, AvailableVideoModes.data()) == u32(-1)) // not found - { // select safe - xr_sprintf(buff, sizeof(buff), "vid_mode %s", AvailableVideoModes[0].name); - Console->Execute(buff); - } - - dwWidth = psCurrentVidMode[0]; - dwHeight = psCurrentVidMode[1]; - } -} - -DXGI_RATIONAL CHW::selectRefresh(u32 dwWidth, u32 dwHeight, DXGI_FORMAT fmt) -{ - if (psDeviceFlags.is(rsRefresh60hz)) - return DXGI_RATIONAL({ 60, 1 }); - - xr_vector modes; - - IDXGIOutput* pOutput; - m_pAdapter->EnumOutputs(0, &pOutput); - VERIFY(pOutput); - - UINT num = 0; - DXGI_FORMAT format = fmt; - UINT flags = 0; - - // Get the number of display modes available - pOutput->GetDisplayModeList(format, flags, &num, nullptr); - - // Get the list of display modes - modes.resize(num); - pOutput->GetDisplayModeList(format, flags, &num, &modes.front()); - - _RELEASE(pOutput); - - float CurrentFreq = 60.0f; - DXGI_RATIONAL res = { 60, 1 }; - - for (auto &i : modes) - { - if ((i.Width == dwWidth) && (i.Height == dwHeight)) - { - VERIFY(i.RefreshRate.Denominator); - float TempFreq = float(i.RefreshRate.Numerator) / float(i.RefreshRate.Denominator); - if (TempFreq > CurrentFreq) - { - CurrentFreq = TempFreq; - res = i.RefreshRate; - } - } - } - - return res; -} - BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage) { // TODO: DX10: implement stub for this code. @@ -339,131 +261,6 @@ BOOL CHW::support(D3DFORMAT fmt, DWORD type, DWORD usage) return TRUE; } -void CHW::updateWindowProps(HWND m_hWnd) -{ - bool bWindowed = !psDeviceFlags.is(rsFullscreen); - - u32 dwWindowStyle = 0; - // Set window properties depending on what mode were in. - if (bWindowed) - { - 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); - // 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 - // example, when switching from 640x480 fullscreen to windowed with - // a 1000x600 window on a 1024x768 desktop, it is impossible to set - // the window size to 1000x600 until after the display mode has - // 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")) - centerScreen = true; - - if (centerScreen) - { - RECT DesktopRect; - GetClientRect(GetDesktopWindow(), &DesktopRect); - - SetRect(&m_rcWindowBounds, - (DesktopRect.right - m_ChainDesc.BufferDesc.Width) / 2, - (DesktopRect.bottom - m_ChainDesc.BufferDesc.Height) / 2, - (DesktopRect.right + m_ChainDesc.BufferDesc.Width) / 2, - (DesktopRect.bottom + m_ChainDesc.BufferDesc.Height) / 2); - } - else - { - if (drawBorders) - fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar - SetRect(&m_rcWindowBounds, 0, 0, m_ChainDesc.BufferDesc.Width, m_ChainDesc.BufferDesc.Height); - }; - - 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); - } - - SetForegroundWindow(m_hWnd); -} - -struct uniqueRenderingMode -{ - uniqueRenderingMode(pcstr v) : value(v) {} - pcstr value; - bool operator()(const xr_token other) const { return !xr_stricmp(value, other.name); } -}; - -void free_vid_mode_list() -{ - for (auto& mode : AvailableVideoModes) - xr_free(mode.name); - AvailableVideoModes.clear(); -} - -void fill_vid_mode_list(CHW* _hw) -{ - if (!AvailableVideoModes.empty()) - return; - - xr_vector displayModes; - - IDXGIOutput* pOutput; - //_hw->m_pSwapChain->GetContainingOutput(&pOutput); - _hw->m_pAdapter->EnumOutputs(0, &pOutput); - VERIFY(pOutput); - - UINT cnt = 0; - DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; - UINT flags = 0; - - // Get the number of display modes available - pOutput->GetDisplayModeList(format, flags, &cnt, nullptr); - - // Get the list of display modes - displayModes.resize(cnt); - pOutput->GetDisplayModeList(format, flags, &cnt, displayModes.data()); - - _RELEASE(pOutput); - - int i = 0; - auto& AVM = AvailableVideoModes; - for (const auto& it : displayModes) - { - string32 str; - - xr_sprintf(str, sizeof(str), "%dx%d", it.Width, it.Height); - - if (AVM.cend() != std::find_if(AVM.cbegin(), AVM.cend(), uniqueRenderingMode(str))) - continue; - - AVM.emplace_back(xr_token(xr_strdup(str), i)); - ++i; - } - AVM.emplace_back(xr_token(nullptr, -1)); - - Msg("Available video modes[%d]:", AVM.size()); - for (const auto& mode : AVM) - Msg("[%s]", mode.name); -} - void CHW::UpdateViews() { DXGI_SWAP_CHAIN_DESC& sd = m_ChainDesc; diff --git a/src/Layers/xrRenderGL/glHW.cpp b/src/Layers/xrRenderGL/glHW.cpp index 5dfd82d49c6..0181165c11d 100644 --- a/src/Layers/xrRenderGL/glHW.cpp +++ b/src/Layers/xrRenderGL/glHW.cpp @@ -10,106 +10,59 @@ #include "Include/xrAPI/xrAPI.h" #include "xrCore/xr_token.h" -extern ENGINE_API xr_vector AvailableVideoModes; - -void fill_vid_mode_list(CHW* _hw); -void free_vid_mode_list(); - CHW HW; -void CALLBACK OnDebugCallback(GLenum /*source*/, GLenum /*type*/, GLuint id, GLenum severity, - GLsizei /*length*/, const GLchar* message, const void* /*userParam*/) +void CALLBACK OnDebugCallback(GLenum /*source*/, GLenum /*type*/, GLuint id, GLenum severity, GLsizei /*length*/, + const GLchar* message, const void* /*userParam*/) { if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) Log(message, id); } -CHW::CHW() : - pDevice(this), - pContext(this), - m_pSwapChain(this), - pBaseRT(0), - pBaseZB(0), - pPP(0), - pFB(0), - m_hWnd(nullptr), - m_hDC(nullptr), - m_hRC(nullptr), - m_move_window(true) {} +CHW::CHW() + : pDevice(this), pContext(this), m_pSwapChain(this), pBaseRT(0), pBaseZB(0), pPP(0), pFB(0), m_hWnd(nullptr), + m_hDC(nullptr), m_hRC(nullptr) +{ +} CHW::~CHW() {} ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// -void CHW::CreateDevice(HWND hWnd, bool move_window) +void CHW::CreateDevice(SDL_Window* hWnd) { m_hWnd = hWnd; - m_move_window = move_window; R_ASSERT(m_hWnd); - PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | - PFD_SUPPORT_OPENGL | - PFD_DOUBLEBUFFER, // Flags - PFD_TYPE_RGBA, // The kind of framebuffer. RGBA or palette. - 32, // Color depth of the framebuffer. - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 24, // Number of bits for the depthbuffer - 8, // Number of bits for the stencilbuffer - 0, // Number of Aux buffers in the framebuffer. - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - // Get the device context - m_hDC = GetDC(m_hWnd); - if (m_hDC == nullptr) - { - Msg("Could not get device context."); - return; - } - // Choose the closest pixel format - int iPixelFormat = ChoosePixelFormat(m_hDC, &pfd); - if (iPixelFormat == 0) - { - Msg("No pixel format found."); - return; - } - + SDL_DisplayMode mode; + SDL_GetWindowDisplayMode(m_hWnd, &mode); + mode.format = SDL_PIXELFORMAT_RGBA8888; // Apply the pixel format to the device context - if (!SetPixelFormat(m_hDC, iPixelFormat, &pfd)) - { - Msg("Could not set pixel format."); - return; - } + SDL_SetWindowDisplayMode(m_hWnd, &mode); // Create the context - m_hRC = wglCreateContext(m_hDC); + m_hRC = SDL_GL_CreateContext(m_hWnd); if (m_hRC == nullptr) { - Msg("Could not create drawing context."); + Msg("Could not create drawing context: %s", SDL_GetError()); return; } // Make the new context the current context for this thread // NOTE: This assumes the thread calling Create() is the only // thread that will use the context. - if (!wglMakeCurrent(m_hDC, m_hRC)) + if (SDL_GL_MakeCurrent(m_hWnd, m_hRC) != 0) { - Msg("Could not make context current."); + Msg("Could not make context current. %s", SDL_GetError()); return; } + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + // Initialize OpenGL Extension Wrangler if (glewInit() != GLEW_OK) { @@ -118,8 +71,8 @@ void CHW::CreateDevice(HWND hWnd, bool move_window) } #ifdef DEBUG - CHK_GL(glEnable(GL_DEBUG_OUTPUT)); - CHK_GL(glDebugMessageCallback((GLDEBUGPROC)OnDebugCallback, nullptr)); + CHK_GL(glEnable(GL_DEBUG_OUTPUT)); + CHK_GL(glDebugMessageCallback((GLDEBUGPROC)OnDebugCallback, nullptr)); #endif // DEBUG // Clip control ensures compatibility with D3D device coordinates. @@ -128,44 +81,26 @@ void CHW::CreateDevice(HWND hWnd, bool move_window) // Create render target and depth-stencil views here UpdateViews(); - -#ifndef _EDITOR - updateWindowProps(m_hWnd); - fill_vid_mode_list(this); -#endif } void CHW::DestroyDevice() { if (m_hRC) { - if (!wglMakeCurrent(nullptr, nullptr)) - Msg("Could not release drawing context."); + if (SDL_GL_MakeCurrent(nullptr, nullptr) != 0) + Msg("Could not release drawing context: %s", SDL_GetError()); - if (!wglDeleteContext(m_hRC)) - Msg("Could not delete context."); + SDL_GL_DeleteContext(m_hRC); m_hRC = nullptr; } - - if (m_hDC) - { - if (!ReleaseDC(m_hWnd, m_hDC)) - Msg("Could not release device context."); - - m_hDC = nullptr; - } - - free_vid_mode_list(); } ////////////////////////////////////////////////////////////////////// // Resetting device ////////////////////////////////////////////////////////////////////// -void CHW::Reset(HWND hwnd) +void CHW::Reset() { - BOOL bWindowed = !psDeviceFlags.is(rsFullscreen); - CHK_GL(glDeleteProgramPipelines(1, &pPP)); CHK_GL(glDeleteFramebuffers(1, &pFB)); CHK_GL(glDeleteFramebuffers(1, &pCFB)); @@ -174,119 +109,6 @@ void CHW::Reset(HWND hwnd) CHK_GL(glDeleteTextures(1, &pBaseZB)); UpdateViews(); - - updateWindowProps(hwnd); - ShowWindow(hwnd, SW_SHOWNORMAL); -} - -void CHW::updateWindowProps(HWND m_hWnd) -{ - const bool bWindowed = !psDeviceFlags.is(rsFullscreen); - - u32 dwWindowStyle = 0; - // Set window properties depending on what mode were in. - if (bWindowed) - { - 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); - // 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 - // example, when switching from 640x480 fullscreen to windowed with - // a 1000x600 window on a 1024x768 desktop, it is impossible to set - // the window size to 1000x600 until after the display mode has - // 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")) - centerScreen = true; - - 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); - } - else - { - if (drawBorders) - fYOffset = GetSystemMetrics(SM_CYCAPTION); // size of the window title bar - SetRect(&m_rcWindowBounds, 0, 0, psCurrentVidMode[0], psCurrentVidMode[1]); - } - - 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); - } - - SetForegroundWindow(m_hWnd); -} - -struct uniqueRenderingMode -{ - uniqueRenderingMode(pcstr v) : value(v) {} - pcstr value; - bool operator()(const xr_token other) const { return !xr_stricmp(value, other.name); } -}; - -void free_vid_mode_list() -{ - for (auto& mode : AvailableVideoModes) - xr_free(mode.name); - AvailableVideoModes.clear(); -} - -void fill_vid_mode_list(CHW* /*_hw*/) -{ - if (!AvailableVideoModes.empty()) - return; - - DWORD iModeNum = 0; - DEVMODE dmi; - ZeroMemory(&dmi, sizeof dmi); - dmi.dmSize = sizeof dmi; - - int i = 0; - auto& AVM = AvailableVideoModes; - while (EnumDisplaySettings(nullptr, iModeNum++, &dmi) != 0) - { - string32 str; - - xr_sprintf(str, sizeof(str), "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight); - - if (AVM.cend() != find_if(AVM.cbegin(), AVM.cend(), uniqueRenderingMode(str))) - continue; - - AVM.emplace_back(xr_token(xr_strdup(str), i)); - ++i; - } - AVM.emplace_back(xr_token(nullptr, -1)); - - Msg("Available video modes[%d]:", AVM.size()); - for (const auto& mode : AVM) - Msg("[%s]", mode.name); } void CHW::UpdateViews() @@ -310,7 +132,6 @@ void CHW::UpdateViews() CHK_GL(glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, psCurrentVidMode[0], psCurrentVidMode[1])); } - void CHW::ClearRenderTargetView(GLuint pRenderTargetView, const FLOAT ColorRGBA[4]) { if (pRenderTargetView == 0) @@ -341,7 +162,6 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT if (ClearFlags & D3D_CLEAR_STENCIL) mask |= (u32)GL_STENCIL_BUFFER_BIT; - glPushAttrib(mask); if (ClearFlags & D3D_CLEAR_DEPTH) { @@ -360,5 +180,6 @@ void CHW::ClearDepthStencilView(GLuint pDepthStencilView, UINT ClearFlags, FLOAT HRESULT CHW::Present(UINT /*SyncInterval*/, UINT /*Flags*/) { RImplementation.Target->phase_flip(); - return SwapBuffers(m_hDC) ? S_OK : E_FAIL; + SDL_GL_SwapWindow(m_hWnd); + return S_OK; } diff --git a/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp b/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp index 9b098d3d93f..ff7c5436cc5 100644 --- a/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp +++ b/src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp @@ -248,14 +248,14 @@ SPS* CResourceManager::_CreatePS(LPCSTR _name) { string_path name; strcpy_s(name, _name); - if (0 == GEnv.Render->m_MSAASample) strcat(name, "_0"); - if (1 == GEnv.Render->m_MSAASample) strcat(name, "_1"); - if (2 == GEnv.Render->m_MSAASample) strcat(name, "_2"); - if (3 == GEnv.Render->m_MSAASample) strcat(name, "_3"); - if (4 == GEnv.Render->m_MSAASample) strcat(name, "_4"); - if (5 == GEnv.Render->m_MSAASample) strcat(name, "_5"); - if (6 == GEnv.Render->m_MSAASample) strcat(name, "_6"); - if (7 == GEnv.Render->m_MSAASample) strcat(name, "_7"); + if (0 == GEnv.Render->m_MSAASample) xr_strcat(name, "_0"); + if (1 == GEnv.Render->m_MSAASample) xr_strcat(name, "_1"); + if (2 == GEnv.Render->m_MSAASample) xr_strcat(name, "_2"); + if (3 == GEnv.Render->m_MSAASample) xr_strcat(name, "_3"); + if (4 == GEnv.Render->m_MSAASample) xr_strcat(name, "_4"); + if (5 == GEnv.Render->m_MSAASample) xr_strcat(name, "_5"); + if (6 == GEnv.Render->m_MSAASample) xr_strcat(name, "_6"); + if (7 == GEnv.Render->m_MSAASample) xr_strcat(name, "_7"); LPSTR N = LPSTR(name); map_PS::iterator I = m_ps.find(N); if (I != m_ps.end()) return I->second; diff --git a/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp b/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp index 2b83ee30635..210e7e397bd 100644 --- a/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp +++ b/src/Layers/xrRenderPC_GL/gl_rendertarget.cpp @@ -785,7 +785,7 @@ CRenderTarget::CRenderTarget() for (int it1 = 0; it1 < TEX_jitter_count - 1; it1++) { string_path name; - sprintf(name, "%s%d",r2_jitter, it1); + xr_sprintf(name, "%s%d", r2_jitter, it1); CHK_GL (glBindTexture(GL_TEXTURE_2D, t_noise_surf[it1])); CHK_GL (glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, TEX_jitter, TEX_jitter)); t_noise[it1] = RImplementation.Resources->_CreateTexture(name); @@ -821,7 +821,7 @@ CRenderTarget::CRenderTarget() // generate HBAO jitter texture (last) int it = TEX_jitter_count - 1; string_path name; - sprintf(name, "%s%d",r2_jitter, it); + xr_sprintf(name, "%s%d", r2_jitter, it); CHK_GL (glBindTexture(GL_TEXTURE_2D, t_noise_surf[it])); CHK_GL (glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, TEX_jitter, TEX_jitter)); t_noise[it] = RImplementation.Resources->_CreateTexture(name); 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/stdafx.h b/src/Layers/xrRenderPC_GL/stdafx.h index 0141ef8c23d..a1379cf097b 100644 --- a/src/Layers/xrRenderPC_GL/stdafx.h +++ b/src/Layers/xrRenderPC_GL/stdafx.h @@ -10,10 +10,9 @@ #define GLEW_STATIC #include -#include -#include -#include -#include +#include "SDL_opengl.h" +#include +#include "SDL_opengl_glext.h" #include "Layers/xrRender/xrD3DDefs.h" #include "Layers/xrRender/Debug/dxPixEventWrapper.h" @@ -38,8 +37,8 @@ #include "xrEngine/Render.h" #include "Common/_d3d_extensions.h" #include "xrEngine/IGame_Level.h" -#include "Layers/xrRender/blenders/blender.h" -#include "Layers/xrRender/blenders/blender_clsid.h" +#include "Layers/xrRender/blenders/Blender.h" +#include "Layers/xrRender/blenders/Blender_CLSID.h" #include "Layers/xrRender/xrRender_console.h" #include "rgl.h" 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/FStaticRender_RenderTarget.cpp b/src/Layers/xrRenderPC_R1/FStaticRender_RenderTarget.cpp index a56fb0f90bc..c748f4504b9 100644 --- a/src/Layers/xrRenderPC_R1/FStaticRender_RenderTarget.cpp +++ b/src/Layers/xrRenderPC_R1/FStaticRender_RenderTarget.cpp @@ -229,13 +229,12 @@ BOOL CRenderTarget::Perform() (frame_distort == (Device.dwFrame - 1))); } -#include #define SHOW(a) Log(#a, a); #define SHOWX(a) Msg("%s %x", #a, a); void CRenderTarget::Begin() { /* - if (g_pGameLevel->IR_GetKeyState(DIK_LSHIFT)) + if (g_pGameLevel->IR_GetKeyState(SDL_SCANCODE_LSHIFT)) { Msg ("[%5d]------------------------",Device.dwFrame); SHOW (param_blur) 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/editors/ActorEditor/stdafx.cpp b/src/editors/ActorEditor/stdafx.cpp index 2abb7cc2621..3be77690a09 100644 --- a/src/editors/ActorEditor/stdafx.cpp +++ b/src/editors/ActorEditor/stdafx.cpp @@ -12,7 +12,6 @@ #pragma comment(lib, "xrCoreB.lib") #pragma comment(lib, "xrSoundB.lib") -#pragma comment(lib, "dinputB.lib") #pragma comment(lib, "freeimageB.lib") //#pragma comment(lib,"d3d9.lib") #pragma comment(lib, "dxtB.lib") diff --git a/src/editors/ActorEditor/stdafx.h b/src/editors/ActorEditor/stdafx.h index c2d123c6fea..5aad6d24d19 100644 --- a/src/editors/ActorEditor/stdafx.h +++ b/src/editors/ActorEditor/stdafx.h @@ -12,7 +12,6 @@ #define O_SEQUENTIAL 0 #endif -#define DIRECTINPUT_VERSION 0x0800 #define R_R1 1 #define R_R2 2 @@ -91,7 +90,6 @@ DEFINE_VECTOR(ListItem*, ListItemsVec, ListItemsIt); #include #include #include "Layers/xrRender/xrD3dDefs.h" -#include #include // some user components diff --git a/src/editors/ECore/guid.cpp b/src/editors/ECore/guid.cpp index da4bbd33c55..b05184d895c 100644 --- a/src/editors/ECore/guid.cpp +++ b/src/editors/ECore/guid.cpp @@ -1,4 +1,3 @@ #pragma hdrstop #define INITGUID -#include diff --git a/src/editors/ECore/stdafx.cpp b/src/editors/ECore/stdafx.cpp index 1a59b56106b..539e79ccc9e 100644 --- a/src/editors/ECore/stdafx.cpp +++ b/src/editors/ECore/stdafx.cpp @@ -4,7 +4,6 @@ // external dependencies #define INITGUID -#include #ifndef _ECOREB #pragma comment(lib, "xrECoreB.lib") @@ -15,7 +14,6 @@ #pragma comment(lib, "xrCoreB.lib") #pragma comment(lib, "xrSoundB.lib") -#pragma comment(lib, "dinput8B.lib") #pragma comment(lib, "freeimageB.lib") //#pragma comment(lib,"d3d9.lib") #pragma comment(lib, "dxtB.lib") diff --git a/src/editors/ECore/stdafx.h b/src/editors/ECore/stdafx.h index d50ebde0fae..865abfe5111 100644 --- a/src/editors/ECore/stdafx.h +++ b/src/editors/ECore/stdafx.h @@ -12,7 +12,6 @@ #define O_SEQUENTIAL 0 #endif -#define DIRECTINPUT_VERSION 0x0800 #define R_R1 1 #define R_R2 2 @@ -132,7 +131,6 @@ DEFINE_VECTOR(ListItem*, ListItemsVec, ListItemsIt); #include #include "Layers/xrRender/xrD3dDefs.h" -#include //#include // some user components diff --git a/src/editors/LevelEditor/stdafx.cpp b/src/editors/LevelEditor/stdafx.cpp index e9e5e70c4e6..afb64388d9b 100644 --- a/src/editors/LevelEditor/stdafx.cpp +++ b/src/editors/LevelEditor/stdafx.cpp @@ -12,7 +12,6 @@ #pragma comment(lib, "xrCoreB.lib") #pragma comment(lib, "xrSoundB.lib") -#pragma comment(lib, "dinputB.lib") #pragma comment(lib, "freeimageB.lib") //#pragma comment(lib,"d3d9.lib") #pragma comment(lib, "dxtB.lib") diff --git a/src/editors/LevelEditor/stdafx.h b/src/editors/LevelEditor/stdafx.h index 2cbc5083b14..742685a23d1 100644 --- a/src/editors/LevelEditor/stdafx.h +++ b/src/editors/LevelEditor/stdafx.h @@ -12,7 +12,6 @@ #define O_SEQUENTIAL 0 #endif -#define DIRECTINPUT_VERSION 0x0800 #define R_R1 1 #define R_R2 2 @@ -93,7 +92,6 @@ DEFINE_VECTOR(ListItem*, ListItemsVec, ListItemsIt); #include #include #include "Layers/xrRender/xrD3dDefs.h" -#include #include // some user components diff --git a/src/editors/ParticleEditor/stdafx.cpp b/src/editors/ParticleEditor/stdafx.cpp index c0001e4af88..ef57a5ab67c 100644 --- a/src/editors/ParticleEditor/stdafx.cpp +++ b/src/editors/ParticleEditor/stdafx.cpp @@ -12,7 +12,6 @@ #pragma comment(lib, "xrCoreB.lib") #pragma comment(lib, "xrSoundB.lib") -#pragma comment(lib, "dinputB.lib") #pragma comment(lib, "freeimageB.lib") //#pragma comment(lib,"d3d9.lib") #pragma comment(lib, "dxtB.lib") diff --git a/src/editors/ParticleEditor/stdafx.h b/src/editors/ParticleEditor/stdafx.h index c5956137ceb..f00abe13c8e 100644 --- a/src/editors/ParticleEditor/stdafx.h +++ b/src/editors/ParticleEditor/stdafx.h @@ -18,7 +18,6 @@ #define O_SEQUENTIAL 0 #endif -#define DIRECTINPUT_VERSION 0x0800 #define R_R1 1 #define R_R2 2 @@ -99,7 +98,6 @@ DEFINE_VECTOR(ListItem*, ListItemsVec, ListItemsIt); #include #include #include "Layers/xrRender/xrD3DDefs.h" -#include #include // some user components diff --git a/src/editors/ShaderEditor/stdafx.cpp b/src/editors/ShaderEditor/stdafx.cpp index c0001e4af88..ef57a5ab67c 100644 --- a/src/editors/ShaderEditor/stdafx.cpp +++ b/src/editors/ShaderEditor/stdafx.cpp @@ -12,7 +12,6 @@ #pragma comment(lib, "xrCoreB.lib") #pragma comment(lib, "xrSoundB.lib") -#pragma comment(lib, "dinputB.lib") #pragma comment(lib, "freeimageB.lib") //#pragma comment(lib,"d3d9.lib") #pragma comment(lib, "dxtB.lib") diff --git a/src/editors/ShaderEditor/stdafx.h b/src/editors/ShaderEditor/stdafx.h index bc434f7cef8..387a91fd73e 100644 --- a/src/editors/ShaderEditor/stdafx.h +++ b/src/editors/ShaderEditor/stdafx.h @@ -12,7 +12,6 @@ #define O_SEQUENTIAL 0 #endif -#define DIRECTINPUT_VERSION 0x0800 #define R_R1 1 #define R_R2 2 @@ -90,7 +89,6 @@ DEFINE_VECTOR(ListItem*, ListItemsVec, ListItemsIt); #include #include #include "Layers/xrRender/xrD3DDefs.h" -#include #include // some user components diff --git a/src/editors/xrEditor/entry_point.cpp b/src/editors/xrEditor/entry_point.cpp index 90bb3e30e48..c8f006dfdf9 100644 --- a/src/editors/xrEditor/entry_point.cpp +++ b/src/editors/xrEditor/entry_point.cpp @@ -6,7 +6,6 @@ #include "xrEngine/XR_IOConsole.h" #include "xrEngine/xr_ioc_cmd.h" - using namespace XRay; using namespace XRay::Editor; using namespace XRay::Editor::Controls; @@ -25,11 +24,11 @@ void UIThreadProc(void*) Core.Initialize("OpenXRayEditor", LogCallback(ELogCallback, windowIDE->Log().Handle.ToPointer()), true); #ifdef XR_X64 - Device.m_hWnd = (HWND)windowIDE->View().GetViewHandle().ToInt64(); + Device.m_sdlWnd = (SDL_Window*)windowIDE->View().GetViewHandle().ToInt64(); #else - Device.m_hWnd = (HWND)windowIDE->View().GetViewHandle().ToInt32(); + Device.m_sdlWnd = (SDL_Window*)windowIDE->View().GetViewHandle().ToInt32(); #endif - VERIFY(Device.m_hWnd != INVALID_HANDLE_VALUE); + VERIFY(Device.m_sdlWnd != nullptr); UICreated.Set(); ReadyToShowUI.Wait(); @@ -117,4 +116,4 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int) FATAL("stack overflow"); } return 0; -} \ No newline at end of file +} diff --git a/src/editors/xrEditor/packages.config b/src/editors/xrEditor/packages.config new file mode 100644 index 00000000000..94957f1a022 --- /dev/null +++ b/src/editors/xrEditor/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/editors/xrEditor/xrEditor.vcxproj b/src/editors/xrEditor/xrEditor.vcxproj index 9261d6057d3..31d43c5104c 100644 --- a/src/editors/xrEditor/xrEditor.vcxproj +++ b/src/editors/xrEditor/xrEditor.vcxproj @@ -96,7 +96,19 @@ + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + \ No newline at end of file diff --git a/src/editors/xrEditor/xrEditor.vcxproj.filters b/src/editors/xrEditor/xrEditor.vcxproj.filters index 744231c5ef2..b1b1c43c7d4 100644 --- a/src/editors/xrEditor/xrEditor.vcxproj.filters +++ b/src/editors/xrEditor/xrEditor.vcxproj.filters @@ -7,4 +7,10 @@ + + + + + + \ No newline at end of file diff --git a/src/editors/xrWeatherEditor/entry_point.cpp b/src/editors/xrWeatherEditor/entry_point.cpp index 69a3d6f700c..205762e95f0 100644 --- a/src/editors/xrWeatherEditor/entry_point.cpp +++ b/src/editors/xrWeatherEditor/entry_point.cpp @@ -55,7 +55,7 @@ private ref class window_ide_final : public editor::window_ide { m_engine->on_idle(); impl->on_idle(); - } while (m_engine&&!PeekMessage(&message, HWND(0), 0, 0, 0)); + } while (m_engine && !m_engine->quit_requested() && !PeekMessage(&message, HWND(0), 0, 0, 0)); impl->on_idle_end(); } diff --git a/src/utils/xrDXT/NormalMapGen.cpp b/src/utils/xrDXT/NormalMapGen.cpp index 594e529c15d..2c7ca270976 100644 --- a/src/utils/xrDXT/NormalMapGen.cpp +++ b/src/utils/xrDXT/NormalMapGen.cpp @@ -651,12 +651,12 @@ int DXTCompressBump( fmt0.type = STextureParams::ttImage; fmt0.fmt = STextureParams::tfDXT5; string256 out_name1; - strcpy(out_name1, out_name); + xr_strcpy(out_name1, out_name); if (strext(out_name1)) { *strext(out_name1) = 0; } - strcat(out_name1, "#.dds"); + xr_strcat(out_name1, "#.dds"); res |= DXTCompressImage(out_name1, T_normal_1D, w, h, pitch, &fmt0, depth); free(T_height_pf); free(T_normal_1D); diff --git a/src/utils/xrLC_Light/CMakeLists.txt b/src/utils/xrLC_Light/CMakeLists.txt new file mode 100644 index 00000000000..03e99a7f170 --- /dev/null +++ b/src/utils/xrLC_Light/CMakeLists.txt @@ -0,0 +1,23 @@ +project(xrLC_Light) + +list(APPEND DIRS + "." + ) + +add_dir("${DIRS}") + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../.. + ${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/include + ) + +list(APPEND ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../Shader_xrLC.h") +list(APPEND ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../xrEngine/xrLoadSurface.cpp") +#list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.cpp") +#list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./LevelCompilerLoggerWindow.hpp") + +add_definitions(-D_USRDLL -DLEVEL_COMPILER -D_USE_MATH_DEFINES -DXRLC_LIGHT_EXPORTS -DFORCE_NO_EXCEPTIONS -DNO_XR_VDECLARATOR) +add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES}) + +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") +target_link_libraries(${PROJECT_NAME} xrCore xrCDB zlib xrLCUtil) diff --git a/src/xrCDB/CMakeLists.txt b/src/xrCDB/CMakeLists.txt index 0b0aefc7489..9b9ffc42154 100644 --- a/src/xrCDB/CMakeLists.txt +++ b/src/xrCDB/CMakeLists.txt @@ -6,7 +6,7 @@ list(APPEND DIRS add_dir("${DIRS}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include /usr/include/SDL2) add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES}) 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/CMakeLists.txt b/src/xrCore/CMakeLists.txt index 6d7c0398aaf..f6574b9e12b 100644 --- a/src/xrCore/CMakeLists.txt +++ b/src/xrCore/CMakeLists.txt @@ -16,16 +16,18 @@ list(APPEND DIRS add_dir("${DIRS}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/pugixml/src ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/pugixml/src + ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include + ${SDL_INCLUDE_DIR} +) add_definitions(-DXRCORE_EXPORTS) add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES}) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") #this is a temporary solution until find_package will not be fixed -set(CRYPTO_LIBRARY crypto++) -set(PUGIXML_LIBRARY pugixml) set(TBB_LIBRARIES tbb tbbmalloc_proxy tbbmalloc) -set(SDL2_LIB SDL2) -target_link_libraries(${PROJECT_NAME} ${SDL2_LIB} ${LZO_LIBRARY} ${CRYPTO_LIBRARY} ${PUGIXML_LIBRARY} ${TBB_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} ${SDL_LIBRARIES} ${LZO_LIBRARY} ${CRYPTO++_LIBRARIES} ${PUGIXML_LIBRARY} ${TBB_LIBRARIES}) diff --git a/src/xrCore/Debug/DXGetErrorDescription.inl b/src/xrCore/Debug/DXGetErrorDescription.inl index 3b5bb9df6e1..89e20f1e4f6 100644 --- a/src/xrCore/Debug/DXGetErrorDescription.inl +++ b/src/xrCore/Debug/DXGetErrorDescription.inl @@ -143,73 +143,6 @@ switch (hr) CHK_ERR(DDERR_NODRIVERSUPPORT, "The driver does not enumerate display mode refresh rates.") CHK_ERR(DDERR_DEVICEDOESNTOWNSURFACE, "Surfaces created by one direct draw device cannot be used directly by another direct draw device.") - - // ------------------------------------------------------------- - // dinput.h error codes - // ------------------------------------------------------------- - //CHK_ERR(DI_OK, "DI_OK") - //CHK_ERR(DI_NOTATTACHED, "DI_NOTATTACHED") - //CHK_ERR(DI_BUFFEROVERFLOW, "DI_BUFFEROVERFLOW") - //CHK_ERR(DI_PROPNOEFFECT, "DI_PROPNOEFFECT") - //CHK_ERR(DI_NOEFFECT, "DI_NOEFFECT") - //CHK_ERR(DI_POLLEDDEVICE, "DI_POLLEDDEVICE") - //CHK_ERR(DI_DOWNLOADSKIPPED, "DI_DOWNLOADSKIPPED") - //CHK_ERR(DI_EFFECTRESTARTED, "DI_EFFECTRESTARTED") - //CHK_ERR(DI_SETTINGSNOTSAVED_ACCESSDENIED, "DI_SETTINGSNOTSAVED_ACCESSDENIED") - //CHK_ERR(DI_SETTINGSNOTSAVED_DISKFULL, "DI_SETTINGSNOTSAVED_DISKFULL") - //CHK_ERR(DI_TRUNCATED, "DI_TRUNCATED") - //CHK_ERR(DI_TRUNCATEDANDRESTARTED, "DI_TRUNCATEDANDRESTARTED") - //CHK_ERR(DI_WRITEPROTECT, "DI_WRITEPROTECT") - CHK_ERR(DIERR_OLDDIRECTINPUTVERSION, "The application requires a newer version of DirectInput.") - //CHK_ERR(DIERR_GENERIC, "DIERR_GENERIC") - //CHK_ERR(DIERR_OLDDIRECTINPUTVERSION, "DIERR_OLDDIRECTINPUTVERSION") - CHK_ERR(DIERR_BETADIRECTINPUTVERSION, "The application was written for an unsupported prerelease version of DirectInput.") - CHK_ERR(DIERR_BADDRIVERVER, "The object could not be created due to an incompatible driver version or mismatched or incomplete driver components.") - //CHK_ERR(DIERR_DEVICENOTREG, "DIERR_DEVICENOTREG") - //CHK_ERR(DIERR_NOTFOUND, "The requested object does not exist.") - //CHK_ERR(DIERR_OBJECTNOTFOUND, "DIERR_OBJECTNOTFOUND") - //CHK_ERR(DIERR_INVALIDPARAM, "DIERR_INVALIDPARAM") - //CHK_ERR(DIERR_NOINTERFACE, "DIERR_NOINTERFACE") - //CHK_ERR(DIERR_GENERIC, "DIERR_GENERIC") - //CHK_ERR(DIERR_OUTOFMEMORY, "DIERR_OUTOFMEMORY") - //CHK_ERR(DIERR_UNSUPPORTED, "DIERR_UNSUPPORTED") - CHK_ERR(DIERR_NOTINITIALIZED, "This object has not been initialized") - CHK_ERR(DIERR_ALREADYINITIALIZED, "This object is already initialized") - //CHK_ERR(DIERR_NOAGGREGATION, "DIERR_NOAGGREGATION") - //CHK_ERR(DIERR_OTHERAPPHASPRIO, "DIERR_OTHERAPPHASPRIO") - CHK_ERR(DIERR_INPUTLOST, "Access to the device has been lost. It must be re-acquired.") - CHK_ERR(DIERR_ACQUIRED, "The operation cannot be performed while the device is acquired.") - CHK_ERR(DIERR_NOTACQUIRED, "The operation cannot be performed unless the device is acquired.") - //CHK_ERR(DIERR_READONLY, "DIERR_READONLY") - //CHK_ERR(DIERR_HANDLEEXISTS, "DIERR_HANDLEEXISTS") - CHK_ERR(DIERR_INSUFFICIENTPRIVS, "Unable to IDirectInputJoyConfig_Acquire because the user does not have sufficient privileges to change the joystick configuration. & An invalid media type was specified") - CHK_ERR(DIERR_DEVICEFULL, "The device is full. & An invalid media subtype was specified.") - CHK_ERR(DIERR_MOREDATA, "Not all the requested information fit into the buffer. & This object can only be created as an aggregated object.") - CHK_ERR(DIERR_NOTDOWNLOADED, "The effect is not downloaded. & The enumerator has become invalid.") - CHK_ERR(DIERR_HASEFFECTS, "The device cannot be reinitialized because there are still effects attached to it. & At least one of the pins involved in the operation is already connected.") - CHK_ERR(DIERR_NOTEXCLUSIVEACQUIRED, "The operation cannot be performed unless the device is acquired in DISCL_EXCLUSIVE mode. & This operation cannot be performed because the filter is active.") - CHK_ERR(DIERR_INCOMPLETEEFFECT, "The effect could not be downloaded because essential information is missing. For example, no axes have been associated with the effect, or no type-specific information has been created. & One of the specified pins supports no media types.") - CHK_ERR(DIERR_NOTBUFFERED, "Attempted to read buffered device data from a device that is not buffered. & There is no common media type between these pins.") - CHK_ERR(DIERR_EFFECTPLAYING, "An attempt was made to modify parameters of an effect while it is playing. Not all hardware devices support altering the parameters of an effect while it is playing. & Two pins of the same direction cannot be connected together.") - CHK_ERR(DIERR_UNPLUGGED, "The operation could not be completed because the device is not plugged in. & The operation cannot be performed because the pins are not connected.") - CHK_ERR(DIERR_REPORTFULL, "SendDeviceData failed because more information was requested to be sent than can be sent to the device. Some devices have restrictions on how much data can be sent to them. (For example, there might be a limit on the number of buttons that can be pressed at once.) & No sample buffer allocator is available.") - CHK_ERR(DIERR_MAPFILEFAIL, "A mapper file function failed because reading or writing the user or IHV settings file failed. & A run-time error occurred.") - - // ------------------------------------------------------------- - // dinputd.h error codes - // ------------------------------------------------------------- - CHK_ERR(DIERR_NOMOREITEMS, "No more items.") - CHK_ERR(DIERR_DRIVERFIRST, "Device driver-specific codes. Unless the specific driver has been precisely identified, no meaning should be attributed to these values other than that the driver originated the error.") - CHK_ERR(DIERR_DRIVERFIRST+1, "DIERR_DRIVERFIRST+1") - CHK_ERR(DIERR_DRIVERFIRST+2, "DIERR_DRIVERFIRST+2") - CHK_ERR(DIERR_DRIVERFIRST+3, "DIERR_DRIVERFIRST+3") - CHK_ERR(DIERR_DRIVERFIRST+4, "DIERR_DRIVERFIRST+4") - CHK_ERR(DIERR_DRIVERFIRST+5, "DIERR_DRIVERFIRST+5") - CHK_ERR(DIERR_DRIVERLAST, "Device installer errors.") - CHK_ERR(DIERR_INVALIDCLASSINSTALLER, "Registry entry or DLL for class installer invalid or class installer not found.") - CHK_ERR(DIERR_CANCELLED, "The user cancelled the install operation. & The stream already has allocated samples and the surface doesn't match the sample format.") - CHK_ERR(DIERR_BADINF, "The INF file for the selected device could not be found or is invalid or is damaged. & The specified purpose ID can't be used for the call.") - // ------------------------------------------------------------- // d3d9.h error codes // ------------------------------------------------------------- diff --git a/src/xrCore/Debug/DXGetErrorString.inl b/src/xrCore/Debug/DXGetErrorString.inl index 73e3b33d138..e1bb9241015 100644 --- a/src/xrCore/Debug/DXGetErrorString.inl +++ b/src/xrCore/Debug/DXGetErrorString.inl @@ -3048,73 +3048,6 @@ switch (hr) CHK_ERRA(DDERR_NODRIVERSUPPORT) CHK_ERRA(DDERR_DEVICEDOESNTOWNSURFACE) - // ------------------------------------------------------------- - // dinput.h error codes - // ------------------------------------------------------------- - //CHK_ERRA(DI_OK) - //CHK_ERRA(DI_NOTATTACHED) - //CHK_ERRA(DI_BUFFEROVERFLOW) - //CHK_ERRA(DI_PROPNOEFFECT) - //CHK_ERRA(DI_NOEFFECT) - //CHK_ERRA(DI_POLLEDDEVICE) - //CHK_ERRA(DI_DOWNLOADSKIPPED) - //CHK_ERRA(DI_EFFECTRESTARTED) - //CHK_ERRA(DI_SETTINGSNOTSAVED_ACCESSDENIED) - //CHK_ERRA(DI_SETTINGSNOTSAVED_DISKFULL) - //CHK_ERRA(DI_TRUNCATED) - //CHK_ERRA(DI_TRUNCATEDANDRESTARTED) - //CHK_ERRA(DI_WRITEPROTECT) - CHK_ERR(DIERR_INSUFFICIENTPRIVS, "DIERR_INSUFFICIENTPRIVS & VFW_E_INVALIDMEDIATYPE") - CHK_ERR(DIERR_DEVICEFULL, "DIERR_DEVICEFULL & VFW_E_INVALIDSUBTYPE & DMO_E_INVALIDSTREAMINDEX") - CHK_ERR(DIERR_MOREDATA, "DIERR_MOREDATA & VFW_E_NEED_OWNER & DMO_E_INVALIDTYPE") - CHK_ERR(DIERR_NOTDOWNLOADED, "DIERR_NOTDOWNLOADED & VFW_E_ENUM_OUT_OF_SYNC & DMO_E_TYPE_NOT_SET") - CHK_ERR(DIERR_HASEFFECTS, "DIERR_HASEFFECTS & VFW_E_ALREADY_CONNECTED & DMO_E_NOTACCEPTING") - CHK_ERR(DIERR_NOTEXCLUSIVEACQUIRED, "DIERR_NOTEXCLUSIVEACQUIRED & VFW_E_FILTER_ACTIVE & DMO_E_TYPE_NOT_ACCEPTED") - CHK_ERR(DIERR_INCOMPLETEEFFECT, "DIERR_INCOMPLETEEFFECT & VFW_E_NO_TYPES & DMO_E_NO_MORE_ITEMS") - CHK_ERR(DIERR_NOTBUFFERED, "DIERR_NOTBUFFERED & VFW_E_NO_ACCEPTABLE_TYPES") - CHK_ERR(DIERR_EFFECTPLAYING, "DIERR_EFFECTPLAYING & VFW_E_INVALID_DIRECTION") - CHK_ERR(DIERR_UNPLUGGED, "DIERR_UNPLUGGED & VFW_E_NOT_CONNECTED") - CHK_ERR(DIERR_REPORTFULL, "DIERR_REPORTFULL & VFW_E_NO_ALLOCATOR") - CHK_ERR(DIERR_MAPFILEFAIL, "DIERR_MAPFILEFAIL & VFW_E_RUNTIME_ERROR") - //CHK_ERRA(DIERR_OLDDIRECTINPUTVERSION) - //CHK_ERRA(DIERR_GENERIC) - //CHK_ERRA(DIERR_OLDDIRECTINPUTVERSION) - //CHK_ERRA(DIERR_BETADIRECTINPUTVERSION) - //CHK_ERRA(DIERR_BADDRIVERVER) - //CHK_ERRA(DIERR_DEVICENOTREG) - //CHK_ERRA(DIERR_NOTFOUND) - //CHK_ERRA(DIERR_OBJECTNOTFOUND) - //CHK_ERRA(DIERR_INVALIDPARAM) - //CHK_ERRA(DIERR_NOINTERFACE) - //CHK_ERRA(DIERR_GENERIC) - //CHK_ERRA(DIERR_OUTOFMEMORY) - //CHK_ERRA(DIERR_UNSUPPORTED) - //CHK_ERRA(DIERR_NOTINITIALIZED) - //CHK_ERRA(DIERR_ALREADYINITIALIZED) - //CHK_ERRA(DIERR_NOAGGREGATION) - //CHK_ERRA(DIERR_OTHERAPPHASPRIO) - //CHK_ERRA(DIERR_INPUTLOST) - //CHK_ERRA(DIERR_ACQUIRED) - //CHK_ERRA(DIERR_NOTACQUIRED) - //CHK_ERRA(DIERR_READONLY) - //CHK_ERRA(DIERR_HANDLEEXISTS) - - - // ------------------------------------------------------------- - // dinputd.h error - // ------------------------------------------------------------- - //CHK_ERRA(DIERR_NOMOREITEMS) - CHK_ERRA(DIERR_DRIVERFIRST) - CHK_ERR(DIERR_DRIVERFIRST+1, "DIERR_DRIVERFIRST+1") - CHK_ERR(DIERR_DRIVERFIRST+2, "DIERR_DRIVERFIRST+2") - CHK_ERR(DIERR_DRIVERFIRST+3, "DIERR_DRIVERFIRST+3") - CHK_ERR(DIERR_DRIVERFIRST+4, "DIERR_DRIVERFIRST+4") - CHK_ERR(DIERR_DRIVERFIRST+5, "DIERR_DRIVERFIRST+5") - CHK_ERRA(DIERR_DRIVERLAST) - CHK_ERR(DIERR_INVALIDCLASSINSTALLER, "DIERR_INVALIDCLASSINSTALLER") - CHK_ERR(DIERR_CANCELLED, "DIERR_CANCELLED & MS_E_SAMPLEALLOC") - CHK_ERRA(DIERR_BADINF) - // ------------------------------------------------------------- // d3d9.h error codes // ------------------------------------------------------------- diff --git a/src/xrCore/Debug/dxerr.cpp b/src/xrCore/Debug/dxerr.cpp index 8bb164d6436..16c631327e0 100644 --- a/src/xrCore/Debug/dxerr.cpp +++ b/src/xrCore/Debug/dxerr.cpp @@ -21,11 +21,6 @@ #include #include #include -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x800 -#endif -#include -#include #endif #define XAUDIO2_E_INVALID_CALL 0x88960001 diff --git a/src/xrCore/Text/MbHelpers.cpp b/src/xrCore/Text/MbHelpers.cpp index e6a8d8ef232..840f5f5b672 100644 --- a/src/xrCore/Text/MbHelpers.cpp +++ b/src/xrCore/Text/MbHelpers.cpp @@ -1,5 +1,8 @@ #include "stdafx.h" #include "MbHelpers.h" +#include + +// XXX: use c++11 functions and kill that DUMP_CONVERSION!!!11 #define BITS1_MASK 0x80 // 10000000b #define BITS2_MASK 0xC0 // 11000000b @@ -127,3 +130,21 @@ u16 mbhMulti2Wide(wchar_t* WideStr, wchar_t* WidePos, u16 WideStrSize, const cha WideStr[0] = dpos; return dpos; } + +xr_string StringFromUTF8(const char* in, const std::locale& locale /*= std::locale("")*/) +{ + using wcvt = std::wstring_convert, wchar_t>; + auto wstr = wcvt{}.from_bytes(in); + xr_string result(wstr.size(), '\0'); + std::use_facet>(locale).narrow(wstr.data(), wstr.data() + wstr.size(), '?', &result[0]); + return result; +} + +xr_string StringToUTF8(const char* in, const std::locale& locale /*= std::locale("")*/) +{ + using wcvt = std::wstring_convert, wchar_t>; + std::wstring wstr(xr_strlen(in), L'\0'); + std::use_facet>(locale).widen(in, in + xr_strlen(in), &wstr[0]); + std::string result = wcvt{}.to_bytes(wstr.data(), wstr.data() + wstr.size()); + return result.data(); +} diff --git a/src/xrCore/Text/MbHelpers.h b/src/xrCore/Text/MbHelpers.h index e42605a75ae..0d43239ab20 100644 --- a/src/xrCore/Text/MbHelpers.h +++ b/src/xrCore/Text/MbHelpers.h @@ -1,6 +1,9 @@ #pragma once #include "xrCore/xrCore.h" +// XXX: rename this file to StringConversion.hpp +// XXX: use c++11 functions + #define MAX_MB_CHARS 4096 XRCORE_API u16 mbhMulti2Wide(wchar_t* WideStr, wchar_t* WidePos, u16 WideStrSize, const char* MultiStr); @@ -27,3 +30,6 @@ IC bool IsAlphaCharacter(wchar_t wc) ((wc >= 0x0061) && (wc <= 0x007A)) || ((wc >= 0xFF10) && (wc <= 0xFF19)) || ((wc >= 0xFF21) && (wc <= 0xFF3A)) || ((wc >= 0xFF41) && (wc <= 0xFF5A))); } + +XRCORE_API xr_string StringFromUTF8(const char* string, const std::locale& locale = std::locale("")); +XRCORE_API xr_string StringToUTF8(const char* string, const std::locale& locale = std::locale("")); diff --git a/src/xrCore/_math.h b/src/xrCore/_math.h index 9477f433293..25837a14b1a 100644 --- a/src/xrCore/_math.h +++ b/src/xrCore/_math.h @@ -40,3 +40,8 @@ extern XRCORE_API void _initialize_cpu_thread(); using thread_t = void(void*); extern XRCORE_API void thread_name(const char* name); extern XRCORE_API void thread_spawn(thread_t* entry, const char* name, unsigned stack, void* arglist); + +#if defined(LINUX) +void QueryPerformanceCounter(PLARGE_INTEGER result); +DWORD timeGetTime(); +#endif diff --git a/src/xrCore/_std_extensions.h b/src/xrCore/_std_extensions.h index c70adbcb45d..040ed140569 100644 --- a/src/xrCore/_std_extensions.h +++ b/src/xrCore/_std_extensions.h @@ -59,7 +59,7 @@ IC int xr_sprintf(char* dest, size_t sizeOfBuffer, const char* format, ...) #endif // _EDITOR #if defined(LINUX) -IC int vsnprintf_s( char *buffer, size_t size, size_t count, const char *format, va_list list) +IC int vsnprintf_s(char* buffer, size_t size, size_t count, const char* format, va_list list) { //TODO add bound check return vsnprintf(buffer, size, format, list); @@ -165,7 +165,9 @@ inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCST { va_list args; va_start(args, format_string); - return vsprintf_s(destination, buffer_size, format_string, args); + const int result = vsprintf_s(destination, buffer_size, format_string, args); + va_end(args); + return result; } template @@ -173,7 +175,9 @@ inline int __cdecl xr_sprintf(char (&destination)[count], LPCSTR format_string, { va_list args; va_start(args, format_string); - return vsprintf_s(destination, count, format_string, args); + const int result = vsprintf_s(destination, count, format_string, args); + va_end(args); + return result; } #else // #ifndef MASTER_GOLD @@ -201,7 +205,9 @@ inline int __cdecl xr_sprintf(LPSTR destination, size_t const buffer_size, LPCST { va_list args; va_start(args, format_string); - return vsnprintf_s(destination, buffer_size, buffer_size - 1, format_string, args); + const int result = vsnprintf_s(destination, buffer_size, buffer_size - 1, format_string, args); + va_end(args); + return result; } template @@ -209,18 +215,20 @@ inline int __cdecl xr_sprintf(char (&destination)[count], LPCSTR format_string, { va_list args; va_start(args, format_string); - return vsnprintf_s(destination, count, count - 1, format_string, args); + const int result = vsnprintf_s(destination, count, count - 1, format_string, args); + va_end(args); + return result; } #endif // #ifndef MASTER_GOLD template -inline int xr_strcpy(char (&destination)[count], LPCSTR source) +inline int xr_strcpy(char(&destination)[count], LPCSTR source) { return xr_strcpy(destination, count, source); } template -inline int xr_strcat(char (&destination)[count], LPCSTR source) +inline int xr_strcat(char(&destination)[count], LPCSTR source) { return xr_strcat(destination, count, source); } diff --git a/src/xrCore/os_clipboard.cpp b/src/xrCore/os_clipboard.cpp index 92fe290ee42..eba586f8554 100644 --- a/src/xrCore/os_clipboard.cpp +++ b/src/xrCore/os_clipboard.cpp @@ -3,95 +3,92 @@ // Created : 21.02.2008 // Author : Evgeniy Sokolov // Description : os clipboard class implementation +// +// Modified : 24.07.2018 +// Modified by : Xottab_DUTY //////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #pragma hdrstop + #include "os_clipboard.h" #include "xrCore/_std_extensions.h" -void os_clipboard::copy_to_clipboard(LPCSTR buf) +void os_clipboard::copy_to_clipboard(pcstr buf) { -#if defined(WINDOWS) - if (!OpenClipboard(0)) - return; - u32 handle_size = (xr_strlen(buf) + 1) * sizeof(char); - HGLOBAL handle = GlobalAlloc(GHND, handle_size); - if (!handle) + if (SDL_SetClipboardText(buf) < 0) { - CloseClipboard(); - return; + Msg("! Failed to copy text to the clipboard: %s", SDL_GetError()); + Log(buf); } - - char* memory = (char*)GlobalLock(handle); - xr_strcpy(memory, handle_size, buf); - GlobalUnlock(handle); - EmptyClipboard(); - SetClipboardData(CF_TEXT, handle); - CloseClipboard(); -#endif } -void os_clipboard::paste_from_clipboard(LPSTR buffer, u32 const& buffer_size) +void os_clipboard::paste_from_clipboard(pstr buffer, size_t buffer_size) { VERIFY(buffer); VERIFY(buffer_size > 0); -#if defined(WINDOWS) - if (!OpenClipboard(0)) + + if (!SDL_HasClipboardText()) return; - HGLOBAL hmem = GetClipboardData(CF_TEXT); - if (!hmem) + char* clipData = SDL_GetClipboardText(); + + if (!clipData) + { + Msg("! Failed to paste text from the clipboard: %s", SDL_GetError()); return; + } + + strncpy_s(buffer, buffer_size, clipData, buffer_size - 1); - LPCSTR clipdata = (LPCSTR)GlobalLock(hmem); - strncpy_s(buffer, buffer_size, clipdata, buffer_size - 1); - buffer[buffer_size - 1] = 0; - for (u32 i = 0; i < strlen(buffer); ++i) + for (size_t i = 0; i < xr_strlen(buffer); ++i) { - char c = buffer[i]; - if (((isprint(c) == 0) && (c != char(-1))) || c == '\t' || c == '\n') // "я" = -1 + const char c = buffer[i]; + if (isprint(c) == 0 && c != char(-1) || c == '\t' || c == '\n') // "я" = -1 { buffer[i] = ' '; } } - GlobalUnlock(hmem); - CloseClipboard(); -#endif + SDL_free(clipData); } -void os_clipboard::update_clipboard(LPCSTR string) +void os_clipboard::update_clipboard(pcstr string) { -#if defined(WINDOWS) - if (!OpenClipboard(0)) + if (!string) + { + Log("! Why are you trying to copy nullptr to the clipboard?!"); + return; + } + + if (!SDL_HasClipboardText()) + { + copy_to_clipboard(string); return; + } + + char* clipData = SDL_GetClipboardText(); - HGLOBAL handle = GetClipboardData(CF_TEXT); - if (!handle) + if (!clipData) { - CloseClipboard(); + DEBUG_BREAK; + Msg("! Failed to get text from the clipboard: %s", SDL_GetError()); + Log("! Falling back to copy_to_clipboard()"); copy_to_clipboard(string); return; } - LPSTR memory = (LPSTR)GlobalLock(handle); - int memory_length = (int)strlen(memory); - int string_length = (int)strlen(string); - int buffer_size = (memory_length + string_length + 1) * sizeof(char); -#ifndef _EDITOR - LPSTR buffer = (LPSTR)_alloca(buffer_size); -#else // #ifndef _EDITOR - LPSTR buffer = (LPSTR)xr_alloc(buffer_size); -#endif // #ifndef _EDITOR - xr_strcpy(buffer, buffer_size, memory); - GlobalUnlock(handle); - - xr_strcat(buffer, buffer_size, string); - CloseClipboard(); + const size_t clipLength = xr_strlen(clipData); + const size_t stringLength = xr_strlen(string); + + const size_t bufferSize = (clipLength + stringLength + 1) * sizeof(char); + + pstr buffer = (pstr)_alloca(bufferSize); + + xr_strcpy(buffer, bufferSize, clipData); // copy the clipboard + xr_strcat(buffer, bufferSize, string); // copy the new string + + SDL_free(clipData); + copy_to_clipboard(buffer); -#ifdef _EDITOR - xr_free(buffer); -#endif // #ifdef _EDITOR -#endif } diff --git a/src/xrCore/os_clipboard.h b/src/xrCore/os_clipboard.h index d97f5165650..4b6750c1b29 100644 --- a/src/xrCore/os_clipboard.h +++ b/src/xrCore/os_clipboard.h @@ -11,9 +11,9 @@ namespace os_clipboard { -XRCORE_API void copy_to_clipboard(LPCSTR buf); -XRCORE_API void paste_from_clipboard(LPSTR buf, u32 const& buf_size); -XRCORE_API void update_clipboard(LPCSTR str); +XRCORE_API void copy_to_clipboard(pcstr buf); +XRCORE_API void paste_from_clipboard(pstr buf, size_t buf_size); +XRCORE_API void update_clipboard(pcstr str); } // namespace os_clipboard #endif // OS_CLIPBOARD_H_INCLUDED 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.cpp b/src/xrCore/xrCore.cpp index 33c05fc6000..87dac172ae6 100644 --- a/src/xrCore/xrCore.cpp +++ b/src/xrCore/xrCore.cpp @@ -52,6 +52,107 @@ void PrintCI() #endif } +void SDLLogOutput(void* /*userdata*/, + int category, + SDL_LogPriority priority, + const char* message) +{ + pcstr from; + switch (category) + { + case SDL_LOG_CATEGORY_APPLICATION: + from = "application"; + break; + + case SDL_LOG_CATEGORY_ERROR: + from = "error"; + break; + + case SDL_LOG_CATEGORY_ASSERT: + from = "assert"; + break; + + case SDL_LOG_CATEGORY_SYSTEM: + from = "system"; + break; + + case SDL_LOG_CATEGORY_AUDIO: + from = "audio"; + break; + + case SDL_LOG_CATEGORY_VIDEO: + from = "video"; + break; + + case SDL_LOG_CATEGORY_RENDER: + from = "render"; + break; + + case SDL_LOG_CATEGORY_INPUT: + from = "input"; + break; + + case SDL_LOG_CATEGORY_TEST: + from = "test"; + break; + + case SDL_LOG_CATEGORY_CUSTOM: + from = "custom"; + break; + + default: + from = "unknown"; + break; + } + + char mark; + pcstr type; + switch (priority) + { + case SDL_LOG_PRIORITY_VERBOSE: + mark = '%'; + type = "verbose"; + break; + + case SDL_LOG_PRIORITY_DEBUG: + mark = '#'; + type = "debug"; + break; + + case SDL_LOG_PRIORITY_INFO: + mark = '='; + type = "info"; + break; + + case SDL_LOG_PRIORITY_WARN: + mark = '~'; + type = "warn"; + break; + + case SDL_LOG_PRIORITY_ERROR: + mark = '!'; + type = "error"; + break; + + case SDL_LOG_PRIORITY_CRITICAL: + mark = '$'; + type = "critical"; + break; + + default: + mark = ' '; + type = "unknown"; + break; + } + + constexpr pcstr format = "%c [sdl][%s][%s]: %s"; + const size_t size = sizeof(mark) + sizeof(from) + sizeof(type) + sizeof(format) + sizeof(message); + pstr buf = (pstr)_alloca(size); + + xr_sprintf(buf, size, format, mark, from, type, message); + Log(buf); +} + void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pcstr fs_fname, bool plugin) { xr_strcpy(ApplicationName, _ApplicationName); @@ -106,6 +207,7 @@ void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pc Memory._initialize(); + SDL_LogSetOutputFunction(SDLLogOutput, nullptr); Msg("%s %s build %d, %s\n", "OpenXRay", GetBuildConfiguration(), buildId, buildDate); PrintCI(); Msg("command line %s\n", Params); 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/xrCore/xrDebug.cpp b/src/xrCore/xrDebug.cpp index 9f880fe84bc..eec030d7fbb 100644 --- a/src/xrCore/xrDebug.cpp +++ b/src/xrCore/xrDebug.cpp @@ -58,11 +58,11 @@ static BOOL bException = FALSE; #endif #if defined XR_X64 -# define MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64 +#define MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64 #elif defined XR_X86 -# define MACHINE_TYPE IMAGE_FILE_MACHINE_I386 +#define MACHINE_TYPE IMAGE_FILE_MACHINE_I386 #else -# error CPU architecture is not supported. +#error CPU architecture is not supported. #endif namespace @@ -92,6 +92,101 @@ ICN void* GetInstructionPtr() } } +// XXX: Probably rename this to AssertionResult? +enum MessageBoxResult +{ + resultUndefined = -1, + resultContinue = 0, + resultTryAgain = 1, + resultCancel = 2 +}; + +constexpr SDL_MessageBoxButtonData buttons[] = +{ + /* .flags, .buttonid, .text */ + { 0, resultContinue, "Continue" }, + { 0, resultTryAgain, "Try again" }, + { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT | + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, + resultCancel, "Cancel" } +}; + +SDL_MessageBoxData messageboxdata = +{ + SDL_MESSAGEBOX_ERROR, + nullptr, + "Fatal error", + "Vse clomalocb, tashite novyy dvizhok", + SDL_arraysize(buttons), + buttons, + nullptr +}; + +int xrDebug::ShowMessage(pcstr title, pcstr message, bool simple) +{ +#ifdef WINDOWS // because Windows default Message box is fancy + HWND hwnd = nullptr; + + if (applicationWindow) + { + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWindowWMInfo(applicationWindow, &info)) + { + switch (info.subsystem) + { + case SDL_SYSWM_WINDOWS: + hwnd = info.info.win.window; + break; + default: break; + } + } + } + + if (simple) + return MessageBox(hwnd, message, title, MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); + + const int result = MessageBox(hwnd, message, title, + MB_CANCELTRYCONTINUE | MB_ICONERROR | MB_SYSTEMMODAL); + + switch (result) + { + case IDCANCEL: return resultCancel; + case IDTRYAGAIN: return resultTryAgain; + case IDCONTINUE: return resultContinue; + default: return resultUndefined; + } +#else + if (simple) + return SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, applicationWindow); + + messageboxdata.window = applicationWindow; + messageboxdata.title = title; + messageboxdata.message = message; + int button = resultUndefined; + SDL_ShowMessageBox(&messageboxdata, &button); + return button; +#endif +} + +SDL_AssertState SDLAssertionHandler(const SDL_AssertData* data, + void* /*userdata*/) +{ + if (data->always_ignore) + return SDL_ASSERTION_ALWAYS_IGNORE; + + constexpr pcstr desc = "SDL2 assert triggered"; + bool alwaysIgnore = false; + xrDebug::Fail(alwaysIgnore, {data->filename, data->linenum, data->function}, data->condition, desc); + + if (alwaysIgnore) + return SDL_ASSERTION_ALWAYS_IGNORE; + + // XXX: change Fail return type from void to 'enum MessageBoxResult' + return SDL_ASSERTION_IGNORE; +} + +SDL_Window* xrDebug::applicationWindow = nullptr; xrDebug::UnhandledExceptionFilter xrDebug::PrevFilter = nullptr; xrDebug::OutOfMemoryCallbackFunc xrDebug::OutOfMemoryCallback = nullptr; xrDebug::CrashHandler xrDebug::OnCrash = nullptr; @@ -103,9 +198,9 @@ bool xrDebug::symEngineInitialized = false; Lock xrDebug::dbgHelpLock; #if defined(WINDOWS) -void xrDebug::SetBugReportFile(const char* fileName) { strcpy_s(BugReportFile, fileName); } +void xrDebug::SetBugReportFile(const char* fileName) { xr_strcpy(BugReportFile, fileName); } #elif defined(LINUX) -void xrDebug::SetBugReportFile(const char* fileName) { strcpy_s(BugReportFile, 0, fileName); } +void xrDebug::SetBugReportFile(const char* fileName) { xr_strcpy(BugReportFile, 0, fileName); } #endif #if defined(WINDOWS) @@ -245,7 +340,7 @@ xr_vector xrDebug::BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesC stackFrame.AddrFrame.Mode = AddrModeFlat; stackFrame.AddrFrame.Offset = threadCtx->Ebp; #else -# error CPU architecture is not supported. +#error CPU architecture is not supported. #endif while (GetNextStackFrameString(&stackFrame, threadCtx, frameStr) && traceResult.size() <= maxFramesCount) @@ -280,44 +375,44 @@ void xrDebug::LogStackTrace(const char* header) #endif // defined(WINDOWS) -void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const char* expr, const char* desc, - const char* arg1, const char* arg2) +void xrDebug::GatherInfo(char* assertionInfo, size_t bufferSize, const ErrorLocation& loc, const char* expr, + const char* desc, const char* arg1, const char* arg2) { char* buffer = assertionInfo; if (!expr) expr = ""; bool extendedDesc = desc && strchr(desc, '\n'); pcstr prefix = "[error] "; - buffer += sprintf(buffer, "\nFATAL ERROR\n\n"); - buffer += sprintf(buffer, "%sExpression : %s\n", prefix, expr); - buffer += sprintf(buffer, "%sFunction : %s\n", prefix, loc.Function); - buffer += sprintf(buffer, "%sFile : %s\n", prefix, loc.File); - buffer += sprintf(buffer, "%sLine : %d\n", prefix, loc.Line); + buffer += xr_sprintf(buffer, bufferSize, "\nFATAL ERROR\n\n"); + buffer += xr_sprintf(buffer, bufferSize, "%sExpression : %s\n", prefix, expr); + buffer += xr_sprintf(buffer, bufferSize, "%sFunction : %s\n", prefix, loc.Function); + buffer += xr_sprintf(buffer, bufferSize, "%sFile : %s\n", prefix, loc.File); + buffer += xr_sprintf(buffer, bufferSize, "%sLine : %d\n", prefix, loc.Line); if (extendedDesc) { - buffer += sprintf(buffer, "\n%s\n", desc); + buffer += xr_sprintf(buffer, bufferSize, "\n%s\n", desc); if (arg1) { - buffer += sprintf(buffer, "%s\n", arg1); + buffer += xr_sprintf(buffer, bufferSize, "%s\n", arg1); if (arg2) - buffer += sprintf(buffer, "%s\n", arg2); + buffer += xr_sprintf(buffer, bufferSize, "%s\n", arg2); } } else { - buffer += sprintf(buffer, "%sDescription : %s\n", prefix, desc); + buffer += xr_sprintf(buffer, bufferSize, "%sDescription : %s\n", prefix, desc); if (arg1) { if (arg2) { - buffer += sprintf(buffer, "%sArgument 0 : %s\n", prefix, arg1); - buffer += sprintf(buffer, "%sArgument 1 : %s\n", prefix, arg2); + buffer += xr_sprintf(buffer, bufferSize, "%sArgument 0 : %s\n", prefix, arg1); + buffer += xr_sprintf(buffer, bufferSize, "%sArgument 1 : %s\n", prefix, arg2); } else - buffer += sprintf(buffer, "%sArguments : %s\n", prefix, arg1); + buffer += xr_sprintf(buffer, bufferSize, "%sArguments : %s\n", prefix, arg1); } } - buffer += sprintf(buffer, "\n"); + buffer += xr_sprintf(buffer, bufferSize, "\n"); if (shared_str_initialized) { Log(assertionInfo); @@ -331,7 +426,7 @@ void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const ch if (shared_str_initialized) Log("stack trace:\n"); #ifdef USE_OWN_ERROR_MESSAGE_WINDOW - buffer += sprintf(buffer, "stack trace:\n\n"); + buffer += xr_sprintf(buffer, bufferSize, "stack trace:\n\n"); #endif // USE_OWN_ERROR_MESSAGE_WINDOW xr_vector stackTrace = BuildStackTrace(); for (size_t i = 2; i < stackTrace.size(); i++) @@ -339,7 +434,7 @@ void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const ch if (shared_str_initialized) Log(stackTrace[i].c_str()); #ifdef USE_OWN_ERROR_MESSAGE_WINDOW - buffer += sprintf(buffer, "%s\n", stackTrace[i].c_str()); + buffer += xr_sprintf(buffer, bufferSize, "%s\n", stackTrace[i].c_str()); #endif // USE_OWN_ERROR_MESSAGE_WINDOW } if (shared_str_initialized) @@ -375,9 +470,10 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp lock.Enter(); ErrorAfterDialog = true; string4096 assertionInfo; - GatherInfo(assertionInfo, loc, expr, desc, arg1, arg2); + auto size = sizeof(assertionInfo); + GatherInfo(assertionInfo, sizeof(assertionInfo), loc, expr, desc, arg1, arg2); #ifdef USE_OWN_ERROR_MESSAGE_WINDOW - strcat(assertionInfo, + xr_strcat(assertionInfo, "\r\n" "Press CANCEL to abort execution\r\n" "Press TRY AGAIN to continue execution\r\n" @@ -389,25 +485,29 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp if (OnDialog) OnDialog(true); FlushLog(); -#if defined(WINDOWS) if (Core.PluginMode) - MessageBox(NULL, assertionInfo, "X-Ray error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); + ShowMessage("X-Ray error", assertionInfo); else { #ifdef USE_OWN_ERROR_MESSAGE_WINDOW - int result = MessageBox(NULL, assertionInfo, "Fatal error", - MB_CANCELTRYCONTINUE | MB_ICONERROR | MB_SYSTEMMODAL); - switch (result) + switch (ShowMessage("Fatal error", assertionInfo, false)) { - case IDCANCEL: + case resultUndefined: + xr_strcat(assertionInfo, SDL_GetError()); + [[fallthrough]]; + + case resultCancel: #ifdef USE_BUG_TRAP BT_SetUserMessage(assertionInfo); #endif DEBUG_BREAK; break; - case IDTRYAGAIN: ErrorAfterDialog = false; + + case resultTryAgain: + ErrorAfterDialog = false; break; - case IDCONTINUE: + + case resultContinue: ErrorAfterDialog = false; ignoreAlways = true; break; @@ -420,7 +520,6 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp DEBUG_BREAK; #endif } -#endif if (OnDialog) OnDialog(false); @@ -436,8 +535,8 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp void xrDebug::DoExit(const std::string& message) { FlushLog(); + ShowMessage("Error", message.c_str()); #if defined(WINDOWS) - MessageBox(NULL, message.c_str(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); TerminateProcess(GetCurrentProcess(), 1); #endif } @@ -491,13 +590,13 @@ void WINAPI xrDebug::PreErrorHandler(INT_PTR) string256 currentDir; _getcwd(currentDir, sizeof(currentDir)); string256 relDir; - strcpy_s(relDir, logDir); + xr_strcpy(relDir, logDir); strconcat(sizeof(logDir), logDir, currentDir, "\\", relDir); } } __except (EXCEPTION_EXECUTE_HANDLER) { - strcpy_s(logDir, "logs"); + xr_strcpy(logDir, "logs"); } string_path temp; strconcat(sizeof(temp), temp, logDir, log_name()); @@ -564,7 +663,7 @@ void xrDebug::SaveMiniDump(EXCEPTION_POINTERS *exPtrs) string64 dateStr; timestamp(dateStr); string_path dumpPath; - sprintf(dumpPath, "%s_%s_%s.mdmp", Core.ApplicationName, Core.UserName, dateStr); + xr_sprintf(dumpPath, sizeof(dumpPath), "%s_%s_%s.mdmp", Core.ApplicationName, Core.UserName, dateStr); __try { if (FS.path_exist("$logs$")) @@ -573,8 +672,8 @@ void xrDebug::SaveMiniDump(EXCEPTION_POINTERS *exPtrs) __except (EXCEPTION_EXECUTE_HANDLER) { string_path temp; - strcpy_s(temp, dumpPath); - sprintf(dumpPath, "logs/%s", temp); + xr_strcpy(temp, dumpPath); + xr_sprintf(dumpPath, sizeof(dumpPath), "logs/%s", temp); } WriteMiniDump(MINIDUMP_TYPE(MiniDumpFilterMemory | MiniDumpScanMemory), dumpPath, GetCurrentThreadId(), exPtrs); #endif @@ -594,7 +693,7 @@ void xrDebug::FormatLastError(char* buffer, const size_t& bufferSize) FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, lastErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msg, 0, nullptr); // XXX nitrocaster: check buffer overflow - sprintf(buffer, "[error][%8d]: %s", lastErr, (char*)msg); + xr_sprintf(buffer, bufferSize, "[error][%8d]: %s", lastErr, (char*)msg); LocalFree(msg); #endif } @@ -618,7 +717,7 @@ LONG WINAPI xrDebug::UnhandledFilter(EXCEPTION_POINTERS* exPtrs) { if (shared_str_initialized) Log(stackTrace[i].c_str()); - sprintf(buffer, "%s\r\n", stackTrace[i].c_str()); + xr_sprintf(buffer, sizeof(buffer), "%s\r\n", stackTrace[i].c_str()); #ifdef DEBUG if (!IsDebuggerPresent()) os_clipboard::update_clipboard(buffer); @@ -628,7 +727,7 @@ LONG WINAPI xrDebug::UnhandledFilter(EXCEPTION_POINTERS* exPtrs) { if (shared_str_initialized) Msg("\n%s", errMsg); - strcat(errMsg, "\r\n"); + xr_strcat(errMsg, "\r\n"); #ifdef DEBUG if (!IsDebuggerPresent()) os_clipboard::update_clipboard(buffer); @@ -646,10 +745,9 @@ LONG WINAPI xrDebug::UnhandledFilter(EXCEPTION_POINTERS* exPtrs) { if (OnDialog) OnDialog(true); - MessageBox(NULL, - "Fatal error occurred\n\n" - "Press OK to abort program execution", - "Fatal error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); + constexpr pcstr msg = "Fatal error occurred\n\n" + "Press OK to abort program execution"; + ShowMessage("Fatal error", msg); } #endif ReportFault(exPtrs, 0); @@ -671,11 +769,11 @@ void _terminate() #if defined(WINDOWS) if (strstr(GetCommandLine(), "-silent_error_mode")) exit(-1); +#endif string4096 assertionInfo; xrDebug::GatherInfo(assertionInfo, DEBUG_INFO, nullptr, "Unexpected application termination"); - strcat(assertionInfo, "Press OK to abort execution\r\n"); - MessageBox(GetTopWindow(NULL), assertionInfo, "Fatal Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); -#endif + xr_strcat(assertionInfo, "Press OK to abort execution\r\n"); + xrDebug::ShowMessage("Fatal Error", assertionInfo); exit(-1); } #endif // USE_BUG_TRAP @@ -754,6 +852,7 @@ void xrDebug::Initialize(const bool& dedicated) *BugReportFile = 0; OnThreadSpawn(); SetupExceptionHandler(dedicated); + SDL_SetAssertionHandler(SDLAssertionHandler, nullptr); // exception handler to all "unhandled" exceptions #if defined(WINDOWS) PrevFilter = ::SetUnhandledExceptionFilter(UnhandledFilter); diff --git a/src/xrCore/xrDebug.h b/src/xrCore/xrDebug.h index c4417fcdafc..754305cab6f 100644 --- a/src/xrCore/xrDebug.h +++ b/src/xrCore/xrDebug.h @@ -14,6 +14,7 @@ #pragma warning(pop) #endif +struct SDL_Window; class ErrorLocation { public: @@ -46,6 +47,7 @@ class XRCORE_API xrDebug using UnhandledExceptionFilter = LONG(WINAPI*)(EXCEPTION_POINTERS* exPtrs); private: + static SDL_Window* applicationWindow; static UnhandledExceptionFilter PrevFilter; static OutOfMemoryCallbackFunc OutOfMemoryCallback; static CrashHandler OnCrash; @@ -58,6 +60,9 @@ class XRCORE_API xrDebug static void Initialize(const bool& dedicated); static void Destroy(); static void OnThreadSpawn(); + + static SDL_Window* GetApplicationWindow() { return applicationWindow; } + static void SetApplicationWindow(SDL_Window* window) { applicationWindow = window; } static OutOfMemoryCallbackFunc GetOutOfMemoryCallback() { return OutOfMemoryCallback; } static void SetOutOfMemoryCallback(OutOfMemoryCallbackFunc cb) { OutOfMemoryCallback = cb; } static CrashHandler GetCrashHandler() { return OnCrash; } @@ -66,8 +71,8 @@ class XRCORE_API xrDebug static void SetDialogHandler(DialogHandler handler) { OnDialog = handler; } static const char* ErrorToString(long code); static void SetBugReportFile(const char* fileName); - static void GatherInfo(char* assertionInfo, const ErrorLocation& loc, const char* expr, const char* desc, - const char* arg1 = nullptr, const char* arg2 = nullptr); + static void GatherInfo(char* assertionInfo, size_t bufferSize, const ErrorLocation& loc, const char* expr, + const char* desc, const char* arg1 = nullptr, const char* arg2 = nullptr); static void Fatal(const ErrorLocation& loc, const char* format, ...); static void Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* expr, long hresult, const char* arg1 = nullptr, const char* arg2 = nullptr); @@ -77,6 +82,8 @@ class XRCORE_API xrDebug const char* arg1 = nullptr, const char* arg2 = nullptr); static void DoExit(const std::string& message); + static int ShowMessage(pcstr title, pcstr message, bool simple = true); + static void LogStackTrace(const char* header); static xr_vector BuildStackTrace(u16 maxFramesCount = 512); private: diff --git a/src/xrEngine/CMakeLists.txt b/src/xrEngine/CMakeLists.txt index 686cce9df07..a14da09df53 100644 --- a/src/xrEngine/CMakeLists.txt +++ b/src/xrEngine/CMakeLists.txt @@ -9,16 +9,21 @@ add_dir("${DIRS}") include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/OpenAutomate/inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/FreeImage/Dist/x64 ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include - /usr/include/SDL2 + ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind + ${SDL_INCLUDE_DIR} ) +list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./tntQAVI.cpp") list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./editor_environment_manager_properties.cpp") -#list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./xr_cda.h") +list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./Text_Console.cpp") +list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./Text_Console_WndProc.cpp") + +list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./tntQAVI.h") +list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./Text_Console.h") add_definitions(-DENGINE_BUILD) add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES}) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") -target_link_libraries(${PROJECT_NAME} xrCore luabind xrAPI xrSound xrScriptEngine luajit theora ${OGG_LIBRARIES} xrNetServer xrCDB xrPhysics openal) +target_link_libraries(${PROJECT_NAME} xrCore luabind xrAPI xrSound xrScriptEngine luajit theora ${OGG_LIBRARIES} xrCDB xrPhysics openal lockfile ${SDL_LIBRARIES}) diff --git a/src/xrEngine/Device_Initialize.cpp b/src/xrEngine/Device_Initialize.cpp index 8069cc73945..b3349a4583b 100644 --- a/src/xrEngine/Device_Initialize.cpp +++ b/src/xrEngine/Device_Initialize.cpp @@ -1,13 +1,13 @@ #include "stdafx.h" -#include "xr_3da/resource.h" #include "Include/editor/ide.hpp" #include "engine_impl.hpp" +#include "xr_input.h" #include "GameFont.h" #include "PerformanceAlert.hpp" #include "xrCore/ModuleLookup.hpp" -extern LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +SDL_HitTestResult WindowHitTest(SDL_Window* win, const SDL_Point* area, void* data); void CRenderDevice::initialize_weather_editor() { @@ -25,8 +25,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_sdlWnd = SDL_CreateWindowFrom(m_editor->view_handle()); + R_ASSERT3(m_sdlWnd, "Unable to create SDL window from editor", SDL_GetError()); GEnv.isEditor = true; } @@ -37,32 +37,23 @@ void CRenderDevice::Initialize() TimerGlobal.Start(); TimerMM.Start(); + R_ASSERT3(SDL_Init(SDL_INIT_VIDEO) == 0, "Unable to initialize SDL", SDL_GetError()); + 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 (!m_sdlWnd) { - 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); + const Uint32 flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN | + SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL; + + m_sdlWnd = SDL_CreateWindow("S.T.A.L.K.E.R.: Call of Pripyat", 0, 0, 640, 480, flags); + + R_ASSERT3(m_sdlWnd, "Unable to create SDL window", SDL_GetError()); + SDL_SetWindowHitTest(m_sdlWnd, WindowHitTest, nullptr); + SDL_SetWindowMinimumSize(m_sdlWnd, 256, 192); + xrDebug::SetApplicationWindow(m_sdlWnd); } - // Save window properties - m_dwWindowStyle = GetWindowLong(m_hWnd, GWL_STYLE); - GetWindowRect(m_hWnd, &m_rcWindowBounds); - GetClientRect(m_hWnd, &m_rcWindowClient); } void CRenderDevice::DumpStatistics(IGameFont& font, IPerformanceAlert* alert) @@ -73,3 +64,45 @@ void CRenderDevice::DumpStatistics(IGameFont& font, IPerformanceAlert* alert) if (alert && stats.fFPS < 30) alert->Print(font, "FPS < 30: %3.1f", stats.fFPS); } + +SDL_HitTestResult WindowHitTest(SDL_Window* /*window*/, const SDL_Point* area, void* /*data*/) +{ + if (pInput->InputIsGrabbed()) + return SDL_HITTEST_NORMAL; + + const auto& rect = Device.m_rcWindowClient; + + // size of additional interactive area (in pixels) + constexpr int hit = 15; + + const bool leftSide = area->x <= rect.x + hit; + const bool topSide = area->y <= rect.y + hit; + const bool bottomSide = area->y >= rect.h - hit; + const bool rightSide = area->x >= rect.w - hit; + + if (leftSide && topSide) + return SDL_HITTEST_RESIZE_TOPLEFT; + + if (rightSide && topSide) + return SDL_HITTEST_RESIZE_TOPRIGHT; + + if (rightSide && bottomSide) + return SDL_HITTEST_RESIZE_BOTTOMRIGHT; + + if (leftSide && bottomSide) + return SDL_HITTEST_RESIZE_BOTTOMLEFT; + + if (topSide) + return SDL_HITTEST_RESIZE_TOP; + + if (rightSide) + return SDL_HITTEST_RESIZE_RIGHT; + + if (bottomSide) + return SDL_HITTEST_RESIZE_BOTTOM; + + if (leftSide) + return SDL_HITTEST_RESIZE_LEFT; + + return SDL_HITTEST_DRAGGABLE; +} diff --git a/src/xrEngine/Device_create.cpp b/src/xrEngine/Device_create.cpp index 17479ba92d8..4a8166a566e 100644 --- a/src/xrEngine/Device_create.cpp +++ b/src/xrEngine/Device_create.cpp @@ -1,10 +1,27 @@ #include "stdafx.h" #include "Include/xrRender/DrawUtils.h" #include "Render.h" +#include "xrCore/xr_token.h" #include "xrCDB/xrXRC.h" +#include "XR_IOConsole.h" + +extern u32 Vid_SelectedMonitor; +extern u32 Vid_SelectedRefreshRate; +extern xr_vector VidMonitorsToken; +extern xr_vector VidModesToken; +extern xr_vector VidRefreshRateToken; extern XRCDB_API BOOL* cdb_bDebug; +void FillMonitorsToken(); +void FreeMonitorsToken(); + +void FillVidModesToken(u32 monitorID); +void FreeVidModesToken(); + +void FillRefreshRateToken(); +void FreeRefreshRateToken(); + void CRenderDevice::_SetupStates() { // General Render States @@ -22,6 +39,7 @@ void CRenderDevice::Create() { if (b_is_Ready) return; // prevent double call + Statistic = new CStats(); bool gpuSW = !!strstr(Core.Params, "-gpu_sw"); bool gpuNonPure = !!strstr(Core.Params, "-gpu_nopure"); @@ -34,12 +52,17 @@ void CRenderDevice::Create() #endif 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); + + if (GEnv.isDedicatedServer || editor()) + psDeviceFlags.set(rsFullscreen, false); + + FillVidModesToken(Vid_SelectedMonitor); + UpdateWindowProps(!psDeviceFlags.is(rsFullscreen)); + GEnv.Render->Create(m_sdlWnd, dwWidth, dwHeight, fWidth_2, fHeight_2); + Memory.mem_compact(); b_is_Ready = TRUE; + _SetupStates(); string_path fname; FS.update_path(fname, "$game_data$", "shaders.xr"); @@ -48,3 +71,237 @@ void CRenderDevice::Create() dwFrame = 0; PreCache(0, false, false); } + +void CRenderDevice::UpdateWindowProps(const bool windowed) +{ + SelectResolution(windowed); + + if (windowed) + { + // Get the maximal available resolution (penultimate token in VidModesToken) + u32 width, height; + sscanf(VidModesToken[VidModesToken.size() - 2].name, "%dx%d", &width, &height); + + const bool drawBorders = strstr(Core.Params, "-draw_borders"); + + bool maximalResolution = false; + if (b_is_Ready && !drawBorders && psCurrentVidMode[0] == width && psCurrentVidMode[1] == height) + maximalResolution = true; + + // Set SDL_WINDOW_FULLSCREEN_DESKTOP if maximal resolution is selected + SDL_SetWindowFullscreen(m_sdlWnd, maximalResolution ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); + SDL_SetWindowSize(m_sdlWnd, psCurrentVidMode[0], psCurrentVidMode[1]); + SDL_SetWindowBordered(m_sdlWnd, drawBorders ? SDL_TRUE : SDL_FALSE); + } + else + { + SDL_SetWindowFullscreen(m_sdlWnd, SDL_WINDOW_FULLSCREEN); + + // XXX: fix monitor selection + // it appears to be buggy + SDL_Rect rect; + SDL_GetDisplayBounds(Vid_SelectedMonitor, &rect); + SDL_SetWindowPosition(m_sdlWnd, rect.x, rect.y); + SDL_DisplayMode mode; + SDL_GetWindowDisplayMode(m_sdlWnd, &mode); + mode.w = psCurrentVidMode[0]; + mode.h = psCurrentVidMode[1]; + mode.refresh_rate = Vid_SelectedRefreshRate; + SDL_SetWindowDisplayMode(m_sdlWnd, &mode); + } + + UpdateWindowRects(); + SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT); +} + + +void CRenderDevice::UpdateWindowRects() +{ + m_rcWindowClient.x = 0; + m_rcWindowClient.y = 0; + SDL_GetWindowSize(m_sdlWnd, &m_rcWindowClient.w, &m_rcWindowClient.h); + + SDL_GetWindowPosition(m_sdlWnd, &m_rcWindowBounds.x, &m_rcWindowBounds.y); + SDL_GetWindowSize(m_sdlWnd, &m_rcWindowBounds.w, &m_rcWindowBounds.h); + m_rcWindowBounds.w += m_rcWindowBounds.x; + m_rcWindowBounds.h += m_rcWindowBounds.y; + +#if SDL_VERSION_ATLEAST(2,0,5) + // Do we need code below? + int top, left, bottom, right; + SDL_GetWindowBordersSize(m_sdlWnd, &top, &left, &bottom, &right); + m_rcWindowBounds.x -= left; + m_rcWindowBounds.y -= top; + m_rcWindowBounds.w += right; + m_rcWindowBounds.h += bottom; + // XXX: check if we need this code when SDL_GetWindowBordersSize + // will be available for Windows +#endif +} + +void CRenderDevice::SelectResolution(const bool windowed) +{ + // Dedicated server hardcoded resolution + // XXX: to be removed + if (GEnv.isDedicatedServer) + { + dwWidth = psCurrentVidMode[0] = 640; + dwHeight = psCurrentVidMode[1] = 480; + } + else if (windowed) + { + dwWidth = psCurrentVidMode[0]; + dwHeight = psCurrentVidMode[1]; + } + else // check + { + string32 buff; + xr_sprintf(buff, sizeof(buff), "%dx%d", psCurrentVidMode[0], psCurrentVidMode[1]); + + if (_ParseItem(buff, VidModesToken.data()) == u32(-1)) // not found + { // select safe + SDL_DisplayMode current; + SDL_GetCurrentDisplayMode(Vid_SelectedMonitor, ¤t); + current.w = psCurrentVidMode[0]; + current.h = psCurrentVidMode[1]; + + SDL_DisplayMode closest; + if (SDL_GetClosestDisplayMode(Vid_SelectedMonitor, ¤t, &closest)) + xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", closest.w, closest.h); + else + xr_sprintf(buff, sizeof(buff), "vid_mode %s", VidModesToken.back()); + + Console->Execute(buff); + } + + dwWidth = psCurrentVidMode[0]; + dwHeight = psCurrentVidMode[1]; + } +} + +struct uniqueRenderingMode +{ + uniqueRenderingMode(pcstr v) : value(v) {} + pcstr value; + bool operator()(const xr_token& other) const + { + return !xr_stricmp(value, other.name); + } +}; + +void FillMonitorsToken() +{ + auto& monitors = VidMonitorsToken; + + if (!monitors.empty()) + FreeMonitorsToken(); + + int displayCount = SDL_GetNumVideoDisplays(); + R_ASSERT3(displayCount > 0, "Failed to find display", SDL_GetError()); + monitors.reserve(displayCount + 1); + + for (int i = 0; i < displayCount; ++i) + { + string512 buf; + xr_sprintf(buf, sizeof(buf), "%d. %s", i + 1, SDL_GetDisplayName(i)); + monitors.emplace_back(xr_strdup(buf), i); + } + + monitors.emplace_back(nullptr, -1); +} + +void FillVidModesToken(u32 monitorID) +{ + auto& modes = VidModesToken; + auto& rates = VidRefreshRateToken; + + if (!modes.empty()) + FreeVidModesToken(); + + if (!rates.empty()) + FreeRefreshRateToken(); + + int modeCount = SDL_GetNumDisplayModes(monitorID); + R_ASSERT3(modeCount > 0, "Failed to find display modes", SDL_GetError()); + modes.reserve(modeCount + 1); + + Msg("Available video modes[%d]:", modes.size()); + + SDL_DisplayMode displayMode; + for (int i = modeCount - 1; i >= 0; --i) + { + R_ASSERT3(SDL_GetDisplayMode(monitorID, i, &displayMode) == 0, "Failed to find specified display mode", SDL_GetError()); + + string16 str; + xr_sprintf(str, sizeof(str), "%dx%d", displayMode.w, displayMode.h); + + if (modes.cend() == std::find_if(modes.cbegin(), modes.cend(), uniqueRenderingMode(str))) + { + modes.emplace_back(xr_strdup(str), i); + Msg("[%s]", str); + } + + // For the first time we can fill refresh rate token here + if (displayMode.w == psCurrentVidMode[0] && displayMode.h == psCurrentVidMode[1]) + { + xr_itoa(displayMode.refresh_rate, str, 10); + + rates.emplace_back(xr_strdup(str), displayMode.refresh_rate); + } + } + + modes.emplace_back(nullptr, -1); + rates.emplace_back(nullptr, -1); +} + +void FillRefreshRateToken() +{ + auto& rates = VidRefreshRateToken; + + if (!rates.empty()) + FreeRefreshRateToken(); + + int modeCount = SDL_GetNumDisplayModes(Vid_SelectedMonitor); + R_ASSERT3(modeCount > 0, "Failed to find display modes", SDL_GetError()); + + SDL_DisplayMode displayMode; + for (int i = modeCount - 1; i >= 0; --i) + { + R_ASSERT3(SDL_GetDisplayMode(Vid_SelectedMonitor, i, &displayMode) == 0, "Failed to find specified display mode", + SDL_GetError()); + + if (displayMode.w != psCurrentVidMode[0] || displayMode.h != psCurrentVidMode[1]) + continue; + + string16 buff; + xr_itoa(displayMode.refresh_rate, buff, 10); + + rates.emplace_back(xr_strdup(buff), displayMode.refresh_rate); + } + + rates.emplace_back(nullptr, -1); +} + +void FreeMonitorsToken() +{ + for (auto& monitor : VidMonitorsToken) + xr_free(monitor.name); + + VidMonitorsToken.clear(); +} + +void FreeVidModesToken() +{ + for (auto& mode : VidModesToken) + xr_free(mode.name); + + VidModesToken.clear(); +} + +void FreeRefreshRateToken() +{ + for (auto& rate : VidRefreshRateToken) + xr_free(rate.name); + + VidRefreshRateToken.clear(); +} diff --git a/src/xrEngine/Device_destroy.cpp b/src/xrEngine/Device_destroy.cpp index 6369084da0a..52ef71f3b8c 100644 --- a/src/xrEngine/Device_destroy.cpp +++ b/src/xrEngine/Device_destroy.cpp @@ -5,12 +5,15 @@ #include "XR_IOConsole.h" #include "xr_input.h" +extern void FreeMonitorsToken(); +extern void FreeVidModesToken(); +extern void FreeRefreshRateToken(); + void CRenderDevice::Destroy() { if (!b_is_Ready) return; Log("Destroying Direct3D..."); - pInput->ClipCursor(false); GEnv.Render->ValidateHW(); GEnv.DU->OnDeviceDestroy(); b_is_Ready = false; @@ -19,6 +22,9 @@ void CRenderDevice::Destroy() GEnv.Render->OnDeviceDestroy(false); Memory.mem_compact(); GEnv.Render->DestroyHW(); + FreeRefreshRateToken(); + FreeVidModesToken(); + FreeMonitorsToken(); seqRender.Clear(); seqAppActivate.Clear(); seqAppDeactivate.Clear(); @@ -29,6 +35,9 @@ void CRenderDevice::Destroy() seqDeviceReset.Clear(); seqParallel.clear(); xr_delete(Statistic); + + SDL_DestroyWindow(m_sdlWnd); + SDL_Quit(); } #include "IGame_Level.h" @@ -39,13 +48,12 @@ void CRenderDevice::Reset(bool precache) { const auto dwWidth_before = dwWidth; const auto dwHeight_before = dwHeight; - pInput->ClipCursor(false); + pInput->GrabInput(false); 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); + UpdateWindowProps(!psDeviceFlags.is(rsFullscreen)); + GEnv.Render->Reset(m_sdlWnd, dwWidth, dwHeight, fWidth_2, fHeight_2); if (g_pGamePersistent) g_pGamePersistent->Environment().bNeed_re_create_env = true; @@ -65,5 +73,5 @@ void CRenderDevice::Reset(bool precache) seqResolutionChanged.Process(); if (!GEnv.isDedicatedServer) - pInput->ClipCursor(true); + pInput->GrabInput(true); } diff --git a/src/xrEngine/Device_wndproc.cpp b/src/xrEngine/Device_wndproc.cpp index cbd147ca663..9a1940b775f 100644 --- a/src/xrEngine/Device_wndproc.cpp +++ b/src/xrEngine/Device_wndproc.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" +#if defined(WINDOWS) bool CRenderDevice::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result) { switch (uMsg) @@ -53,6 +54,7 @@ bool CRenderDevice::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara return (false); } + //----------------------------------------------------------------------------- // Name: WndProc() // Desc: Static msg handler which passes messages to the application class. @@ -65,3 +67,4 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return (DefWindowProc(hWnd, uMsg, wParam, lParam)); } +#endif diff --git a/src/xrEngine/EngineAPI.cpp b/src/xrEngine/EngineAPI.cpp index f894961b513..2db17959dda 100644 --- a/src/xrEngine/EngineAPI.cpp +++ b/src/xrEngine/EngineAPI.cpp @@ -9,7 +9,8 @@ #include "xrCore/ModuleLookup.hpp" #include "xrCore/xr_token.h" -extern xr_vector vid_quality_token; +extern void FillMonitorsToken(); +extern xr_vector VidQualityToken; ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -35,14 +36,18 @@ CEngineAPI::CEngineAPI() CEngineAPI::~CEngineAPI() { - vid_quality_token.clear(); + VidQualityToken.clear(); } bool is_enough_address_space_available() { +#if defined(WINDOWS) SYSTEM_INFO system_info; GetSystemInfo(&system_info); return (*(u32*)&system_info.lpMaximumApplicationAddress) > 0x90000000; +#else + return TRUE; // In linux allocated memory limited only by pointer size +#endif } void CEngineAPI::SetupCurrentRenderer() @@ -122,13 +127,13 @@ void CEngineAPI::InitializeRenderers() SetupCurrentRenderer(); if (GEnv.SetupCurrentRenderer == nullptr - && vid_quality_token[0].id != -1) + && VidQualityToken[0].id != -1) { // if engine failed to load renderer // but there is at least one available // then try again string32 buf; - xr_sprintf(buf, "renderer %s", vid_quality_token[0].name); + xr_sprintf(buf, "renderer %s", VidQualityToken[0].name); Console->Execute(buf); // Second attempt @@ -155,6 +160,8 @@ void CEngineAPI::InitializeRenderers() if (GEnv.CurrentRenderer != 1) hRenderR1->close();*/ + + FillMonitorsToken(); } void CEngineAPI::Initialize(void) @@ -208,7 +215,7 @@ void CEngineAPI::Destroy(void) void CEngineAPI::CreateRendererList() { - if (!vid_quality_token.empty()) + if (!VidQualityToken.empty()) return; hRenderR1 = XRay::LoadModule("xrRender_R1"); @@ -216,8 +223,8 @@ void CEngineAPI::CreateRendererList() if (GEnv.isDedicatedServer) { R_ASSERT2(hRenderR1->IsLoaded(), "Dedicated server needs xrRender_R1 to work"); - vid_quality_token.emplace_back(xr_token("renderer_r1", 0)); - vid_quality_token.emplace_back(xr_token(nullptr, -1)); + VidQualityToken.emplace_back("renderer_r1", 0); + VidQualityToken.emplace_back(nullptr, -1); return; } @@ -232,25 +239,25 @@ void CEngineAPI::CreateRendererList() // Restore error handling SetErrorMode(0); - auto& modes = vid_quality_token; + auto& modes = VidQualityToken; if (hRenderR1->IsLoaded()) { - modes.emplace_back(xr_token("renderer_r1", 0)); + modes.emplace_back("renderer_r1", 0); } if (hRenderR2->IsLoaded()) { - modes.emplace_back(xr_token("renderer_r2a", 1)); - modes.emplace_back(xr_token("renderer_r2", 2)); + modes.emplace_back("renderer_r2a", 1); + modes.emplace_back("renderer_r2", 2); if (GEnv.CheckR2 && GEnv.CheckR2()) - modes.emplace_back(xr_token("renderer_r2.5", 3)); + modes.emplace_back("renderer_r2.5", 3); } if (hRenderR3->IsLoaded()) { if (GEnv.CheckR3 && GEnv.CheckR3()) - modes.emplace_back(xr_token("renderer_r3", 4)); + modes.emplace_back("renderer_r3", 4); else hRenderR3->Close(); } @@ -258,7 +265,7 @@ void CEngineAPI::CreateRendererList() if (hRenderR4->IsLoaded()) { if (GEnv.CheckR4 && GEnv.CheckR4()) - modes.emplace_back(xr_token("renderer_r4", 5)); + modes.emplace_back("renderer_r4", 5); else hRenderR4->Close(); } @@ -266,11 +273,11 @@ void CEngineAPI::CreateRendererList() if (hRenderRGL->IsLoaded()) { if (GEnv.CheckRGL && GEnv.CheckRGL()) - modes.emplace_back(xr_token("renderer_gl", 6)); + modes.emplace_back("renderer_gl", 6); else hRenderRGL->Close(); } - modes.emplace_back(xr_token(nullptr, -1)); + modes.emplace_back(nullptr, -1); Msg("Available render modes[%d]:", modes.size()); for (const auto& mode : modes) diff --git a/src/xrEngine/Environment.cpp b/src/xrEngine/Environment.cpp index af8bbcf0482..d0a238c85c8 100644 --- a/src/xrEngine/Environment.cpp +++ b/src/xrEngine/Environment.cpp @@ -469,7 +469,7 @@ void CEnvironment::OnFrame() return; #endif - // if (pInput->iGetAsyncKeyState(DIK_O)) SetWeatherFX("surge_day"); + // if (pInput->iGetAsyncKeyState(SDL_SCANCODE_O)) SetWeatherFX("surge_day"); float current_weight; lerp(current_weight); diff --git a/src/xrEngine/FDemoRecord.cpp b/src/xrEngine/FDemoRecord.cpp index 41738896563..d552a20d52d 100644 --- a/src/xrEngine/FDemoRecord.cpp +++ b/src/xrEngine/FDemoRecord.cpp @@ -307,7 +307,7 @@ BOOL CDemoRecord::ProcessCam(SCamEffectorInfo& info) } else { - if (IR_GetKeyState(DIK_F1)) + if (IR_GetKeyState(SDL_SCANCODE_F1)) { pApp->pFontSystem->SetColor(color_rgba(255, 0, 0, 255)); pApp->pFontSystem->SetAligment(CGameFont::alCenter); @@ -337,17 +337,17 @@ BOOL CDemoRecord::ProcessCam(SCamEffectorInfo& info) float speed = m_fSpeed1, ang_speed = m_fAngSpeed1; - if (IR_GetKeyState(DIK_LSHIFT)) + if (IR_GetKeyState(SDL_SCANCODE_LSHIFT)) { speed = m_fSpeed0; ang_speed = m_fAngSpeed0; } - else if (IR_GetKeyState(DIK_LALT)) + else if (IR_GetKeyState(SDL_SCANCODE_LALT)) { speed = m_fSpeed2; ang_speed = m_fAngSpeed2; } - else if (IR_GetKeyState(DIK_LCONTROL)) + else if (IR_GetKeyState(SDL_SCANCODE_LCTRL)) { speed = m_fSpeed3; ang_speed = m_fAngSpeed3; @@ -402,7 +402,7 @@ BOOL CDemoRecord::ProcessCam(SCamEffectorInfo& info) void CDemoRecord::IR_OnKeyboardPress(int dik) { - if (dik == DIK_MULTIPLY) + if (dik == SDL_SCANCODE_KP_MULTIPLY) m_b_redirect_input_to_level = !m_b_redirect_input_to_level; if (m_b_redirect_input_to_level) @@ -410,21 +410,21 @@ void CDemoRecord::IR_OnKeyboardPress(int dik) g_pGameLevel->IR_OnKeyboardPress(dik); return; } - if (dik == DIK_GRAVE) + if (dik == SDL_SCANCODE_GRAVE) Console->Show(); - if (dik == DIK_SPACE) + if (dik == SDL_SCANCODE_SPACE) RecordKey(); - if (dik == DIK_BACK) + if (dik == SDL_SCANCODE_BACKSPACE) MakeCubemap(); - if (dik == DIK_F11) - MakeLevelMapScreenshot(IR_GetKeyState(DIK_LCONTROL)); - if (dik == DIK_F12) + if (dik == SDL_SCANCODE_F11) + MakeLevelMapScreenshot(IR_GetKeyState(SDL_SCANCODE_LCTRL)); + if (dik == SDL_SCANCODE_F12) MakeScreenshot(); - if (dik == DIK_ESCAPE) + if (dik == SDL_SCANCODE_ESCAPE) fLifeTime = -1; #ifdef DEBUG // ndef MASTER_GOLD // Xottab_DUTY: Teleport to demo cam in Debug configuration - if (dik == DIK_RETURN) + if (dik == SDL_SCANCODE_RETURN) { if (g_pGameLevel->CurrentEntity()) { @@ -434,7 +434,7 @@ void CDemoRecord::IR_OnKeyboardPress(int dik) } #endif - if (dik == DIK_PAUSE) + if (dik == SDL_SCANCODE_PAUSE) Device.Pause(!Device.Paused(), TRUE, TRUE, "demo_record"); } @@ -457,41 +457,41 @@ void CDemoRecord::IR_OnKeyboardHold(int dik) switch (dik) { - case DIK_A: - case DIK_NUMPAD1: - case DIK_LEFT: + case SDL_SCANCODE_A: + case SDL_SCANCODE_KP_1: + case SDL_SCANCODE_LEFT: vT_delta.x -= 1.0f; break; // Slide Left - case DIK_D: - case DIK_NUMPAD3: - case DIK_RIGHT: + case SDL_SCANCODE_D: + case SDL_SCANCODE_KP_3: + case SDL_SCANCODE_RIGHT: vT_delta.x += 1.0f; break; // Slide Right - case DIK_S: + case SDL_SCANCODE_S: vT_delta.y -= 1.0f; break; // Slide Down - case DIK_W: + case SDL_SCANCODE_W: vT_delta.y += 1.0f; break; // Slide Up // rotate - case DIK_NUMPAD2: + case SDL_SCANCODE_KP_2: vR_delta.x -= 1.0f; break; // Pitch Down - case DIK_NUMPAD8: + case SDL_SCANCODE_KP_8: vR_delta.x += 1.0f; break; // Pitch Up - case DIK_E: - case DIK_NUMPAD6: + case SDL_SCANCODE_E: + case SDL_SCANCODE_KP_6: vR_delta.y += 1.0f; break; // Turn Left - case DIK_Q: - case DIK_NUMPAD4: + case SDL_SCANCODE_Q: + case SDL_SCANCODE_KP_4: vR_delta.y -= 1.0f; break; // Turn Right - case DIK_NUMPAD9: + case SDL_SCANCODE_KP_9: vR_delta.z -= 2.0f; break; // Turn Right - case DIK_NUMPAD7: + case SDL_SCANCODE_KP_7: vR_delta.z += 2.0f; break; // Turn Right } diff --git a/src/xrEngine/Feel_Touch.cpp b/src/xrEngine/Feel_Touch.cpp index 6c3d997bf24..a01e135bdaa 100644 --- a/src/xrEngine/Feel_Touch.cpp +++ b/src/xrEngine/Feel_Touch.cpp @@ -7,7 +7,7 @@ using namespace Feel; Touch::Touch() : pure_relcase(&Touch::feel_touch_relcase) {} Touch::~Touch() {} bool Touch::feel_touch_contact(IGameObject* O) { return true; } -void Touch::feel_touch_deny(IGameObject* O, /*DWORD*/ unsigned long T) +void Touch::feel_touch_deny(IGameObject* O, DWORD T) { DenyTouch D; D.O = O; diff --git a/src/xrEngine/IGame_Persistent.h b/src/xrEngine/IGame_Persistent.h index d0154d5e49d..5937007dfd7 100644 --- a/src/xrEngine/IGame_Persistent.h +++ b/src/xrEngine/IGame_Persistent.h @@ -152,7 +152,7 @@ class IMainMenu public: virtual ~IMainMenu(){}; virtual void Activate(bool bActive) = 0; - virtual bool IsActive() = 0; + virtual bool IsActive() const = 0; virtual bool CanSkipSceneRendering() = 0; virtual void DestroyInternal(bool bForce) = 0; }; diff --git a/src/xrEngine/IInputReceiver.cpp b/src/xrEngine/IInputReceiver.cpp index 17a9b0d88bf..d28a3150714 100644 --- a/src/xrEngine/IInputReceiver.cpp +++ b/src/xrEngine/IInputReceiver.cpp @@ -32,8 +32,8 @@ void IInputReceiver::IR_OnDeactivate(void) for (i = 0; i < CInput::COUNT_MOUSE_BUTTONS; i++) if (IR_GetBtnState(i)) IR_OnMouseRelease(i); - IR_OnMouseStop(DIMOFS_X, 0); - IR_OnMouseStop(DIMOFS_Y, 0); + //IR_OnMouseStop(DIMOFS_X, 0); + //IR_OnMouseStop(DIMOFS_Y, 0); } void IInputReceiver::IR_OnActivate(void) {} @@ -49,14 +49,16 @@ BOOL IInputReceiver::IR_GetBtnState(int btn) return pInput->iGetAsyncBtnState(btn); } -void IInputReceiver::IR_GetMousePosScreen(Ivector2& p) { GetCursorPos((LPPOINT)&p); } -void IInputReceiver::IR_GetMousePosReal(HWND hwnd, Ivector2& p) +void IInputReceiver::IR_GetMousePosScreen(Ivector2& p) +{ + SDL_GetMouseState(&p.x, &p.y); +} + +void IInputReceiver::IR_GetMousePosReal(SDL_Window* m_sdlWnd, Ivector2& p) { IR_GetMousePosScreen(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/IInputReceiver.h b/src/xrEngine/IInputReceiver.h index da727dd9e74..a4a24e7f883 100644 --- a/src/xrEngine/IInputReceiver.h +++ b/src/xrEngine/IInputReceiver.h @@ -6,18 +6,21 @@ #ifndef IINPUTRECEIVERH #define IINPUTRECEIVERH #include "xrCore/_flags.h" +#include "xrGame/xr_level_controller.h" // fwd. decl. -template struct _vector2; +template +struct _vector2; using Fvector2 = _vector2; using Ivector2 = _vector2; class ENGINE_API IInputReceiver { public: + virtual ~IInputReceiver() = default; static void IR_GetLastMouseDelta(Ivector2& p); static void IR_GetMousePosScreen(Ivector2& p); - static void IR_GetMousePosReal(HWND hwnd, Ivector2& p); + static void IR_GetMousePosReal(SDL_Window* m_sdlWnd, Ivector2& p); static void IR_GetMousePosReal(Ivector2& p); static void IR_GetMousePosIndependent(Fvector2& f); static void IR_GetMousePosIndependentCrop(Fvector2& f); @@ -29,16 +32,16 @@ class ENGINE_API IInputReceiver virtual void IR_OnDeactivate(void); virtual void IR_OnActivate(void); - virtual void IR_OnMousePress(int /*btn*/) {}; - virtual void IR_OnMouseRelease(int /*btn*/) {}; - virtual void IR_OnMouseHold(int /*btn*/) {}; - virtual void IR_OnMouseWheel(int /*direction*/) {}; - virtual void IR_OnMouseMove(int /*x*/, int /*y*/) {}; - virtual void IR_OnMouseStop(int /*x*/, int /*y*/) {}; + virtual void IR_OnMousePress(int /*btn*/) {} + virtual void IR_OnMouseRelease(int /*btn*/) {} + virtual void IR_OnMouseHold(int /*btn*/) {} + virtual void IR_OnMouseWheel(int /*x*/, int /*y*/) {} + virtual void IR_OnMouseMove(int /*x*/, int /*y*/) {} + virtual void IR_OnMouseStop(int /*x*/, int /*y*/) {} - virtual void IR_OnKeyboardPress(int /*dik*/) {}; - virtual void IR_OnKeyboardRelease(int /*dik*/) {}; - virtual void IR_OnKeyboardHold(int /*dik*/) {}; + virtual void IR_OnKeyboardPress(int /*dik*/) {} + virtual void IR_OnKeyboardRelease(int /*dik*/) {} + virtual void IR_OnKeyboardHold(int /*dik*/) {} }; ENGINE_API extern float psMouseSens; diff --git a/src/xrEngine/IObjectPhysicsCollision.h b/src/xrEngine/IObjectPhysicsCollision.h index 960f3008471..2aa43372be3 100644 --- a/src/xrEngine/IObjectPhysicsCollision.h +++ b/src/xrEngine/IObjectPhysicsCollision.h @@ -2,9 +2,11 @@ class IPhysicsShell; class IPhysicsElement; +#if defined(WINDOWS) xr_pure_interface IObjectPhysicsCollision { public: virtual const IPhysicsShell* physics_shell() const = 0; virtual const IPhysicsElement* physics_character() const = 0; // depricated }; +#endif diff --git a/src/xrEngine/IPHdebug.h b/src/xrEngine/IPHdebug.h index 754bf7055ea..d47677f9390 100644 --- a/src/xrEngine/IPHdebug.h +++ b/src/xrEngine/IPHdebug.h @@ -1,5 +1,8 @@ #pragma once +#include "xrCore/_types.h" + +#if defined(WINDOWS) xr_pure_interface IPhDebugRender { virtual void open_cashed_draw() = 0; @@ -8,3 +11,4 @@ xr_pure_interface IPhDebugRender }; extern ENGINE_API IPhDebugRender* ph_debug_render; +#endif diff --git a/src/xrEngine/Render.h b/src/xrEngine/Render.h index 790c95e146c..aa573c9496d 100644 --- a/src/xrEngine/Render.h +++ b/src/xrEngine/Render.h @@ -397,11 +397,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) = 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..4ba5d3a6e49 100644 --- a/src/xrEngine/Text_Console.cpp +++ b/src/xrEngine/Text_Console.cpp @@ -104,9 +104,9 @@ void CTextConsole::CreateLogWnd() lf.lfUnderline = 0; lf.lfStrikeOut = 0; lf.lfCharSet = DEFAULT_CHARSET; - lf.lfOutPrecision = OUT_STRING_PRECIS; + lf.lfOutPrecision = OUT_TT_PRECIS; lf.lfClipPrecision = CLIP_STROKE_PRECIS; - lf.lfQuality = DRAFT_QUALITY; + lf.lfQuality = CLEARTYPE_NATURAL_QUALITY; lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS; xr_sprintf(lf.lfFaceName, sizeof(lf.lfFaceName), ""); @@ -140,7 +140,20 @@ void CTextConsole::Initialize() { inherited::Initialize(); - m_pMainWnd = &Device.m_hWnd; + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWindowWMInfo(Device.m_sdlWnd, &info)) + { + switch (info.subsystem) + { + case SDL_SYSWM_WINDOWS: + m_pMainWnd = &info.info.win.window; + break; + default: break; + } + } + else + Log("Couldn't get window information: %s", SDL_GetError()); m_dwLastUpdateTime = Device.dwTimeGlobal; m_last_time = Device.dwTimeGlobal; diff --git a/src/xrEngine/Text_Console_WndProc.cpp b/src/xrEngine/Text_Console_WndProc.cpp index ec15a25ca82..fb5a4f40385 100644 --- a/src/xrEngine/Text_Console_WndProc.cpp +++ b/src/xrEngine/Text_Console_WndProc.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "Text_Console.h" +#if defined(WINDOWS) LRESULT CALLBACK TextConsole_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) @@ -51,3 +52,4 @@ LRESULT CALLBACK TextConsole_LogWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA } return DefWindowProc(hWnd, uMsg, wParam, lParam); } +#endif diff --git a/src/xrEngine/XR_IOConsole.cpp b/src/xrEngine/XR_IOConsole.cpp index a4eab19e3d3..94b0a28137b 100644 --- a/src/xrEngine/XR_IOConsole.cpp +++ b/src/xrEngine/XR_IOConsole.cpp @@ -601,7 +601,7 @@ void CConsole::Show() } bVisible = true; - GetCursorPos(&m_mouse_pos); + SDL_GetGlobalMouseState((int *) &m_mouse_pos.x, (int *) &m_mouse_pos.y); // Replace with SDL_GetMouseState in case retrieve window-relative coordinates ec().clear_states(); scroll_delta = 0; @@ -624,9 +624,9 @@ void CConsole::Hide() // if ( g_pGameLevel || // ( g_pGamePersistent && g_pGamePersistent->m_pMainMenu && g_pGamePersistent->m_pMainMenu->IsActive() )) - if (pInput->get_exclusive_mode()) + if (pInput->IsExclusiveMode()) { - SetCursorPos(m_mouse_pos.x, m_mouse_pos.y); + SDL_WarpMouseGlobal(m_mouse_pos.x, m_mouse_pos.y); // Replace with SDL_WarpMouseInWindow in case set window-relative coordinates } bVisible = false; diff --git a/src/xrEngine/XR_IOConsole_callback.cpp b/src/xrEngine/XR_IOConsole_callback.cpp index f58a9dfc9da..4199c52cc48 100644 --- a/src/xrEngine/XR_IOConsole_callback.cpp +++ b/src/xrEngine/XR_IOConsole_callback.cpp @@ -14,33 +14,33 @@ void CConsole::Register_callbacks() { - ec().assign_callback(DIK_PRIOR, text_editor::ks_free, Callback(this, &CConsole::Prev_log)); - ec().assign_callback(DIK_NEXT, text_editor::ks_free, Callback(this, &CConsole::Next_log)); - ec().assign_callback(DIK_PRIOR, text_editor::ks_Ctrl, Callback(this, &CConsole::Begin_log)); - ec().assign_callback(DIK_NEXT, text_editor::ks_Ctrl, Callback(this, &CConsole::End_log)); + ec().assign_callback(SDL_SCANCODE_PAGEUP, text_editor::ks_free, Callback(this, &CConsole::Prev_log)); + ec().assign_callback(SDL_SCANCODE_PAGEDOWN, text_editor::ks_free, Callback(this, &CConsole::Next_log)); + ec().assign_callback(SDL_SCANCODE_PAGEUP, text_editor::ks_Ctrl, Callback(this, &CConsole::Begin_log)); + ec().assign_callback(SDL_SCANCODE_PAGEDOWN, text_editor::ks_Ctrl, Callback(this, &CConsole::End_log)); - ec().assign_callback(DIK_TAB, text_editor::ks_free, Callback(this, &CConsole::Find_cmd)); - ec().assign_callback(DIK_TAB, text_editor::ks_Shift, Callback(this, &CConsole::Find_cmd_back)); - ec().assign_callback(DIK_TAB, text_editor::ks_Alt, Callback(this, &CConsole::GamePause)); + ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_free, Callback(this, &CConsole::Find_cmd)); + ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_Shift, Callback(this, &CConsole::Find_cmd_back)); + ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_Alt, Callback(this, &CConsole::GamePause)); - ec().assign_callback(DIK_UP, text_editor::ks_free, Callback(this, &CConsole::Prev_tip)); - ec().assign_callback(DIK_DOWN, text_editor::ks_free, Callback(this, &CConsole::Next_tip)); - ec().assign_callback(DIK_UP, text_editor::ks_Ctrl, Callback(this, &CConsole::Prev_cmd)); - ec().assign_callback(DIK_DOWN, text_editor::ks_Ctrl, Callback(this, &CConsole::Next_cmd)); + ec().assign_callback(SDL_SCANCODE_UP, text_editor::ks_free, Callback(this, &CConsole::Prev_tip)); + ec().assign_callback(SDL_SCANCODE_DOWN, text_editor::ks_free, Callback(this, &CConsole::Next_tip)); + ec().assign_callback(SDL_SCANCODE_UP, text_editor::ks_Ctrl, Callback(this, &CConsole::Prev_cmd)); + ec().assign_callback(SDL_SCANCODE_DOWN, text_editor::ks_Ctrl, Callback(this, &CConsole::Next_cmd)); - ec().assign_callback(DIK_HOME, text_editor::ks_Alt, Callback(this, &CConsole::Begin_tips)); - ec().assign_callback(DIK_END, text_editor::ks_Alt, Callback(this, &CConsole::End_tips)); - ec().assign_callback(DIK_PRIOR, text_editor::ks_Alt, Callback(this, &CConsole::PageUp_tips)); - ec().assign_callback(DIK_NEXT, text_editor::ks_Alt, Callback(this, &CConsole::PageDown_tips)); + ec().assign_callback(SDL_SCANCODE_HOME, text_editor::ks_Alt, Callback(this, &CConsole::Begin_tips)); + ec().assign_callback(SDL_SCANCODE_END, text_editor::ks_Alt, Callback(this, &CConsole::End_tips)); + ec().assign_callback(SDL_SCANCODE_PAGEUP, text_editor::ks_Alt, Callback(this, &CConsole::PageUp_tips)); + ec().assign_callback(SDL_SCANCODE_PAGEDOWN, text_editor::ks_Alt, Callback(this, &CConsole::PageDown_tips)); - ec().assign_callback(DIK_RETURN, text_editor::ks_free, Callback(this, &CConsole::Execute_cmd)); - ec().assign_callback(DIK_NUMPADENTER, text_editor::ks_free, Callback(this, &CConsole::Execute_cmd)); + ec().assign_callback(SDL_SCANCODE_RETURN, text_editor::ks_free, Callback(this, &CConsole::Execute_cmd)); + ec().assign_callback(SDL_SCANCODE_KP_ENTER, text_editor::ks_free, Callback(this, &CConsole::Execute_cmd)); - ec().assign_callback(DIK_ESCAPE, text_editor::ks_free, Callback(this, &CConsole::Hide_cmd_esc)); - ec().assign_callback(DIK_GRAVE, text_editor::ks_free, Callback(this, &CConsole::Hide_cmd)); + ec().assign_callback(SDL_SCANCODE_ESCAPE, text_editor::ks_free, Callback(this, &CConsole::Hide_cmd_esc)); + ec().assign_callback(SDL_SCANCODE_GRAVE, text_editor::ks_free, Callback(this, &CConsole::Hide_cmd)); } -void CConsole::Prev_log() // DIK_PRIOR=PAGE_UP +void CConsole::Prev_log() // SDL_SCANCODE_PRIOR=PAGE_UP { scroll_delta++; if (scroll_delta > int(LogFile.size()) - 1) @@ -49,7 +49,7 @@ void CConsole::Prev_log() // DIK_PRIOR=PAGE_UP } } -void CConsole::Next_log() // DIK_NEXT=PAGE_DOWN +void CConsole::Next_log() // SDL_SCANCODE_NEXT=PAGE_DOWN { scroll_delta--; if (scroll_delta < 0) @@ -68,7 +68,7 @@ void CConsole::End_log() // PAGE_DOWN+Ctrl scroll_delta = 0; } -void CConsole::Find_cmd() // DIK_TAB +void CConsole::Find_cmd() // SDL_SCANCODE_TAB { shared_str out_str; @@ -79,7 +79,7 @@ void CConsole::Find_cmd() // DIK_TAB } } -void CConsole::Find_cmd_back() // DIK_TAB+shift +void CConsole::Find_cmd_back() // SDL_SCANCODE_TAB+shift { LPCSTR edt = ec().str_edit(); LPCSTR radmin_cmd_name = "ra "; @@ -101,19 +101,19 @@ void CConsole::Find_cmd_back() // DIK_TAB+shift } } -void CConsole::Prev_cmd() // DIK_UP + Ctrl +void CConsole::Prev_cmd() // SDL_SCANCODE_UP + Ctrl { prev_cmd_history_idx(); SelectCommand(); } -void CConsole::Next_cmd() // DIK_DOWN + Ctrl +void CConsole::Next_cmd() // SDL_SCANCODE_DOWN + Ctrl { next_cmd_history_idx(); SelectCommand(); } -void CConsole::Prev_tip() // DIK_UP +void CConsole::Prev_tip() // SDL_SCANCODE_UP { if (xr_strlen(ec().str_edit()) == 0) { @@ -124,7 +124,7 @@ void CConsole::Prev_tip() // DIK_UP prev_selected_tip(); } -void CConsole::Next_tip() // DIK_DOWN + Ctrl +void CConsole::Next_tip() // SDL_SCANCODE_DOWN + Ctrl { if (xr_strlen(ec().str_edit()) == 0) { @@ -160,7 +160,7 @@ void CConsole::PageDown_tips() check_next_selected_tip(); } -void CConsole::Execute_cmd() // DIK_RETURN, DIK_NUMPADENTER +void CConsole::Execute_cmd() // SDL_SCANCODE_RETURN, SDL_SCANCODE_KP_ENTER { if (0 <= m_select_tip && m_select_tip < (int)m_tips.size()) { diff --git a/src/xrEngine/device.cpp b/src/xrEngine/device.cpp index 10b81afeada..e1b523f7098 100644 --- a/src/xrEngine/device.cpp +++ b/src/xrEngine/device.cpp @@ -9,7 +9,9 @@ #define MMNOAUX #define MMNOMIXER #define MMNOJOY +#if defined(WINDOWS) #include +#endif #pragma warning(pop) #include "x_ray.h" @@ -25,6 +27,7 @@ #include "xrSASH.h" #include "IGame_Persistent.h" #include "xrScriptEngine/ScriptExporter.hpp" +#include "XR_IOConsole.h" #include "xr_input.h" #include "splash.h" @@ -95,9 +98,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_FOCUS) Pause(TRUE, TRUE, TRUE, "application start"); } } @@ -227,9 +229,9 @@ void CRenderDevice::on_idle() } if (psDeviceFlags.test(rsStatistic)) - g_bEnableStatGather = TRUE; // XXX: why not use either rsStatistic or g_bEnableStatGather? + g_bEnableStatGather = true; // XXX: why not use either rsStatistic or g_bEnableStatGather? else - g_bEnableStatGather = FALSE; + g_bEnableStatGather = false; if (g_loading_events.size()) { @@ -271,7 +273,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 +310,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,17 +331,74 @@ void CRenderDevice::message_loop() return; } - MSG msg; - PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); - while (msg.message != WM_QUIT) + SDL_Event event; + + SDL_PumpEvents(); + SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_SYSWMEVENT); + + while (SDL_QUIT != event.type) { - if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) + if (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_SYSWMEVENT)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - continue; + switch (event.type) + { + case SDL_WINDOWEVENT: + { + switch (event.window.event) + { + case SDL_WINDOWEVENT_MOVED: + UpdateWindowRects(); + break; + + case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_SIZE_CHANGED: + { + if (!psDeviceFlags.is(rsFullscreen)) + { + if (psCurrentVidMode[0] == event.window.data1 && psCurrentVidMode[1] == event.window.data2) + break; // we don't need to reset device if resolution wasn't really changed + + string32 buff; + xr_sprintf(buff, sizeof(buff), "vid_mode %dx%d", event.window.data1, event.window.data2); + Console->Execute(buff); + Reset(); + } + else + UpdateWindowRects(); + + break; + } + + case SDL_WINDOWEVENT_SHOWN: + case SDL_WINDOWEVENT_FOCUS_GAINED: + case SDL_WINDOWEVENT_RESTORED: + case SDL_WINDOWEVENT_MAXIMIZED: + OnWM_Activate(1, event.window.data2); + break; + + case SDL_WINDOWEVENT_HIDDEN: + case SDL_WINDOWEVENT_FOCUS_LOST: + case SDL_WINDOWEVENT_MINIMIZED: + OnWM_Activate(0, event.window.data2); + break; + + case SDL_WINDOWEVENT_ENTER: + SDL_ShowCursor(SDL_FALSE); + break; + + case SDL_WINDOWEVENT_LEAVE: + SDL_ShowCursor(SDL_TRUE); + break; + + case SDL_WINDOWEVENT_CLOSE: + event.type = SDL_QUIT; + } + } + } } + on_idle(); + SDL_PumpEvents(); } } @@ -362,19 +421,24 @@ 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); - pInput->ClipCursor(true); + if (GEnv.isDedicatedServer || strstr(Core.Params, "-center_screen")) + SDL_SetWindowPosition(m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + SDL_HideWindow(m_sdlWnd); + SDL_FlushEvents(SDL_WINDOWEVENT, SDL_SYSWMEVENT); + SDL_ShowWindow(m_sdlWnd); + SDL_RaiseWindow(m_sdlWnd); + pInput->GrabInput(true); message_loop(); seqAppEnd.Process(); // Stop Balance-Thread mt_bMustExit = TRUE; - //renderProcessFrame.Set(); - //renderThreadExit.Wait(); + // renderProcessFrame.Set(); + // renderThreadExit.Wait(); syncProcessFrame.Set(); syncThreadExit.Wait(); @@ -448,18 +512,19 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason) if (bOn) { if (!Paused()) - bShowPauseString = - editor() ? FALSE : + { + bShowPauseString = editor() ? FALSE : TRUE; #ifdef DEBUG - !xr_strcmp(reason, "li_pause_key_no_clip") ? FALSE : -#endif // DEBUG - TRUE; + if (xr_strcmp(reason, "li_pause_key_no_clip") == 0) + bShowPauseString = FALSE; +#endif + } if (bTimer && (!g_pGamePersistent || g_pGamePersistent->CanBePaused())) { - g_pauseMngr().Pause(TRUE); + g_pauseMngr().Pause(true); #ifdef DEBUG - if (!xr_strcmp(reason, "li_pause_key_no_clip")) - TimerGlobal.Pause(FALSE); + if (xr_strcmp(reason, "li_pause_key_no_clip") == 0) + TimerGlobal.Pause(false); #endif } if (bSound && GEnv.Sound) @@ -470,7 +535,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason) if (bTimer && g_pauseMngr().Paused()) { fTimeDelta = EPS_S + EPS_S; - g_pauseMngr().Pause(FALSE); + g_pauseMngr().Pause(false); } if (bSound) { @@ -493,10 +558,11 @@ void CRenderDevice::OnWM_Activate(WPARAM wParam, LPARAM /*lParam*/) const BOOL fMinimized = (BOOL)HIWORD(wParam); const BOOL isWndActive = (fActive != WA_INACTIVE && !fMinimized) ? TRUE : FALSE; + if (!editor() && !GEnv.isDedicatedServer && isWndActive) - pInput->ClipCursor(true); + pInput->GrabInput(true); else - pInput->ClipCursor(false); + pInput->GrabInput(false); extern int ps_always_active; const BOOL isGameActive = ps_always_active || isWndActive; diff --git a/src/xrEngine/device.h b/src/xrEngine/device.h index 40cf29b1453..4d1ca110219 100644 --- a/src/xrEngine/device.h +++ b/src/xrEngine/device.h @@ -62,10 +62,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 +117,7 @@ class ENGINE_API CRenderDeviceData MessageRegistry seqFrame; MessageRegistry seqResolutionChanged; - HWND m_hWnd; + SDL_Window* m_sdlWnd; }; class ENGINE_API CRenderDeviceBase : public IRenderDevice, public CRenderDeviceData @@ -135,18 +135,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)); @@ -155,14 +156,13 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase private: // Main objects used for creating and rendering the 3D scene - u32 m_dwWindowStyle; CTimer TimerMM; RenderDeviceStatictics stats; void _SetupStates(); public: - // HWND m_hWnd; + SDL_Window* m_sdlWnd; LRESULT MsgProc(HWND, UINT, WPARAM, LPARAM); // u32 dwFrame; @@ -202,16 +202,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), + : 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(); @@ -251,6 +250,10 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase void Destroy(void); void Reset(bool precache = true); + void UpdateWindowProps(const bool windowed); + void UpdateWindowRects(); + void SelectResolution(const bool windowed); + void Initialize(void); void ShutDown(void); virtual const RenderDeviceStatictics& GetStats() const override { return stats; } diff --git a/src/xrEngine/edit_actions.cpp b/src/xrEngine/edit_actions.cpp index 29f6b92a247..1b80895f18a 100644 --- a/src/xrEngine/edit_actions.cpp +++ b/src/xrEngine/edit_actions.cpp @@ -9,7 +9,7 @@ #include "edit_actions.h" #include "line_edit_control.h" #include "xr_input.h" -#include +#include "xrCore/Text/MbHelpers.h" namespace text_editor { @@ -45,9 +45,9 @@ void callback_base::on_key_press(line_edit_control* const control) // ------------------------------------------------------------------------------------------------- -type_pair::type_pair(u32 dik, char c, char c_shift, bool b_translate) { init(dik, c, c_shift, b_translate); } +type_pair::type_pair(int dik, char c, char c_shift, bool b_translate) { init(dik, c, c_shift, b_translate); } type_pair::~type_pair() {} -void type_pair::init(u32 dik, char c, char c_shift, bool b_translate) +void type_pair::init(int dik, char c, char c_shift, bool b_translate) { m_translate = b_translate; m_dik = dik; @@ -62,33 +62,27 @@ void type_pair::on_key_press(line_edit_control* const control) { c = m_char; char c_shift = m_char_shift; - string128 buff; - buff[0] = 0; - /* - //setlocale( LC_ALL, "" ); // User-default - - // The following 3 lines looks useless - - LPSTR loc; - STRCONCAT ( loc, ".", xr_itoa( GetACP(), code_page, 10 ) ); - setlocale ( LC_ALL, loc );*/ - - static _locale_t current_locale = _create_locale(LC_ALL, ""); - - if (pInput->get_dik_name(m_dik, buff, sizeof(buff))) + SDL_Event event; + while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_TEXTINPUT, SDL_TEXTINPUT)) { - if (_isalpha_l(buff[0], current_locale) || buff[0] == char(-1)) // "я" = -1 + switch (event.type) { - _strlwr_l(buff, current_locale); - c = buff[0]; - _strupr_l(buff, current_locale); - c_shift = buff[0]; + case SDL_TEXTINPUT: + { + const std::locale locale(""); + auto str = StringFromUTF8(event.text.text, locale); + + if (std::isalpha(str[0], locale) || str[0] == char(-1)) // "я" = -1 + { + c = std::tolower(str[0], locale); + c_shift = std::toupper(str[0], locale); + } + break; + } } } - // setlocale( LC_ALL, "C" ); // restore to ANSI - if (control->get_key_state(ks_Shift) != control->get_key_state(ks_CapsLock)) { c = c_shift; diff --git a/src/xrEngine/edit_actions.h b/src/xrEngine/edit_actions.h index 214711d8eae..6a5d3061e71 100644 --- a/src/xrEngine/edit_actions.h +++ b/src/xrEngine/edit_actions.h @@ -9,6 +9,7 @@ #define EDIT_ACTIONS_H_INCLUDED #include "Common/Noncopyable.hpp" +#include "line_edit_control.h" namespace text_editor { @@ -51,13 +52,13 @@ class callback_base : public base class type_pair : public base { public: - type_pair(u32 dik, char c, char c_shift, bool b_translate); + type_pair(int dik, char c, char c_shift, bool b_translate); virtual ~type_pair(); - void init(u32 dik, char c, char c_shift, bool b_translate); + void init(int dik, char c, char c_shift, bool b_translate); virtual void on_key_press(line_edit_control* const control); private: - u32 m_dik; + int m_dik; bool m_translate; char m_char; char m_char_shift; diff --git a/src/xrEngine/editor_environment_detail.cpp b/src/xrEngine/editor_environment_detail.cpp index f1ea1a48c16..ab16255c261 100644 --- a/src/xrEngine/editor_environment_detail.cpp +++ b/src/xrEngine/editor_environment_detail.cpp @@ -9,14 +9,16 @@ #include "stdafx.h" #include "editor_environment_detail.hpp" +#ifdef _WIN32 #include #pragma comment(lib, "shlwapi.lib") - +#endif using editor::environment::detail::logical_string_predicate; static HRESULT AnsiToUnicode(pcstr pszA, LPVOID buffer, u32 const& buffer_size) { +#if defined(WINDOWS) VERIFY(pszA); VERIFY(buffer); VERIFY(buffer_size); @@ -28,10 +30,14 @@ static HRESULT AnsiToUnicode(pcstr pszA, LPVOID buffer, u32 const& buffer_size) return (NOERROR); return (HRESULT_FROM_WIN32(GetLastError())); +#else + return 0; +#endif } bool logical_string_predicate::operator()(pcstr const& first, pcstr const& second) const { +#if defined(WINDOWS) u32 buffer_size0 = (xr_strlen(first) + 1) * 2; LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); AnsiToUnicode(first, (LPVOID)buffer0, buffer_size0); @@ -41,10 +47,14 @@ bool logical_string_predicate::operator()(pcstr const& first, pcstr const& secon AnsiToUnicode(second, (LPVOID)buffer1, buffer_size1); return (StrCmpLogicalW(buffer0, buffer1) < 0); +#else + return false; +#endif } bool logical_string_predicate::operator()(shared_str const& first, shared_str const& second) const { +#if defined(WINDOWS) u32 buffer_size0 = (first.size() + 1) * 2; LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); AnsiToUnicode(first.c_str(), (LPVOID)buffer0, buffer_size0); @@ -54,6 +64,9 @@ bool logical_string_predicate::operator()(shared_str const& first, shared_str co AnsiToUnicode(second.c_str(), (LPVOID)buffer1, buffer_size1); return (StrCmpLogicalW(buffer0, buffer1) < 0); +#else + return false; +#endif } shared_str editor::environment::detail::real_path(pcstr folder, pcstr path) diff --git a/src/xrEngine/engine_impl.cpp b/src/xrEngine/engine_impl.cpp index f74d7331d20..61bcb576741 100644 --- a/src/xrEngine/engine_impl.cpp +++ b/src/xrEngine/engine_impl.cpp @@ -31,7 +31,11 @@ bool engine_impl::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, return (Device.on_message(hWnd, uMsg, wParam, lParam, result)); } -void engine_impl::on_idle() { Device.on_idle(); } +void engine_impl::on_idle() +{ + SDL_PumpEvents(); + Device.on_idle(); +} void engine_impl::on_resize() { if (Console) @@ -60,6 +64,12 @@ void engine_impl::capture_input(bool const& value) } void engine_impl::disconnect() { Console->Execute("quit"); } + +bool engine_impl::quit_requested() const +{ + return SDL_QuitRequested(); +} + void engine_impl::value(LPCSTR value, shared_str& result) { result = value; } LPCSTR engine_impl::value(shared_str const& value) { return (value.c_str()); } void engine_impl::weather(LPCSTR value) diff --git a/src/xrEngine/engine_impl.hpp b/src/xrEngine/engine_impl.hpp index 23c0c439950..853e06d3063 100644 --- a/src/xrEngine/engine_impl.hpp +++ b/src/xrEngine/engine_impl.hpp @@ -24,6 +24,7 @@ class engine_impl : public XRay::Editor::engine_base virtual void pause(bool const& value); virtual void capture_input(bool const& value); virtual void disconnect(); + bool quit_requested() const override; virtual void value(LPCSTR value, shared_str& result); virtual LPCSTR value(shared_str const& value); diff --git a/src/xrEngine/line_edit_control.cpp b/src/xrEngine/line_edit_control.cpp index 7e8adc728d5..627b9b24d89 100644 --- a/src/xrEngine/line_edit_control.cpp +++ b/src/xrEngine/line_edit_control.cpp @@ -72,7 +72,7 @@ line_edit_control::line_edit_control(u32 str_buffer_size) m_buf2 = nullptr; m_buf3 = nullptr; - for (u32 i = 0; i < DIK_COUNT; ++i) + for (u32 i = 0; i < SDL_NUM_SCANCODES; ++i) m_actions[i] = nullptr; init(str_buffer_size); @@ -97,40 +97,17 @@ line_edit_control::~line_edit_control() delete_data(actions); } -static inline bool get_caps_lock_state() -{ -#if 0 - static bool first_time = true; - static bool is_windows_vista_or_later = false; - if (first_time) - { - first_time = false; - OSVERSIONINFO version_info; - ZeroMemory(&version_info, sizeof(version_info)); - version_info.dwOSVersionInfoSize = sizeof(version_info); - GetVersionEx(&version_info); - is_windows_vista_or_later = version_info.dwMajorVersion >= 6; - } - - if (is_windows_vista_or_later) - return !!(GetKeyState(VK_CAPITAL) & 1); - else -#else // #if 0 - return false; -#endif // #if 0 -} - void line_edit_control::update_key_states() { m_key_state.zero(); - set_key_state(ks_LShift, !!pInput->iGetAsyncKeyState(DIK_LSHIFT)); - set_key_state(ks_RShift, !!pInput->iGetAsyncKeyState(DIK_RSHIFT)); - set_key_state(ks_LCtrl, !!pInput->iGetAsyncKeyState(DIK_LCONTROL)); - set_key_state(ks_RCtrl, !!pInput->iGetAsyncKeyState(DIK_RCONTROL)); - set_key_state(ks_LAlt, !!pInput->iGetAsyncKeyState(DIK_LALT)); - set_key_state(ks_RAlt, !!pInput->iGetAsyncKeyState(DIK_RALT)); - set_key_state(ks_CapsLock, text_editor::get_caps_lock_state()); + set_key_state(ks_LShift, pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)); + set_key_state(ks_RShift, pInput->iGetAsyncKeyState(SDL_SCANCODE_RSHIFT)); + set_key_state(ks_LCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL)); + set_key_state(ks_RCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_RCTRL)); + set_key_state(ks_LAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)); + set_key_state(ks_RAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT)); + set_key_state(ks_CapsLock, SDL_GetModState() & KMOD_CAPS); } void line_edit_control::clear_states() @@ -190,7 +167,7 @@ void line_edit_control::init(u32 str_buffer_size, init_mode mode) clear_states(); - for (u32 i = 0; i < DIK_COUNT; ++i) + for (u32 i = 0; i < SDL_NUM_SCANCODES; ++i) { xr_delete(m_actions[i]); m_actions[i] = nullptr; @@ -198,167 +175,167 @@ void line_edit_control::init(u32 str_buffer_size, init_mode mode) if (mode == im_read_only) { - assign_callback(DIK_A, ks_Ctrl, Callback(this, &line_edit_control::select_all_buf)); - assign_callback(DIK_C, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); - assign_callback(DIK_INSERT, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); - - assign_callback(DIK_HOME, ks_free, Callback(this, &line_edit_control::move_pos_home)); - assign_callback(DIK_END, ks_free, Callback(this, &line_edit_control::move_pos_end)); - assign_callback(DIK_LEFT, ks_free, Callback(this, &line_edit_control::move_pos_left)); - assign_callback(DIK_RIGHT, ks_free, Callback(this, &line_edit_control::move_pos_right)); - assign_callback(DIK_LEFT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_left_word)); - assign_callback(DIK_RIGHT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_right_word)); + assign_callback(SDL_SCANCODE_A, ks_Ctrl, Callback(this, &line_edit_control::select_all_buf)); + assign_callback(SDL_SCANCODE_C, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); + assign_callback(SDL_SCANCODE_INSERT, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); + + assign_callback(SDL_SCANCODE_HOME, ks_free, Callback(this, &line_edit_control::move_pos_home)); + assign_callback(SDL_SCANCODE_END, ks_free, Callback(this, &line_edit_control::move_pos_end)); + assign_callback(SDL_SCANCODE_LEFT, ks_free, Callback(this, &line_edit_control::move_pos_left)); + assign_callback(SDL_SCANCODE_RIGHT, ks_free, Callback(this, &line_edit_control::move_pos_right)); + assign_callback(SDL_SCANCODE_LEFT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_left_word)); + assign_callback(SDL_SCANCODE_RIGHT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_right_word)); } else { assign_char_pairs(mode); - assign_callback(DIK_INSERT, ks_free, Callback(this, &line_edit_control::flip_insert_mode)); - assign_callback(DIK_A, ks_Ctrl, Callback(this, &line_edit_control::select_all_buf)); - assign_callback(DIK_Z, ks_Ctrl, Callback(this, &line_edit_control::undo_buf)); + assign_callback(SDL_SCANCODE_INSERT, ks_free, Callback(this, &line_edit_control::flip_insert_mode)); + assign_callback(SDL_SCANCODE_A, ks_Ctrl, Callback(this, &line_edit_control::select_all_buf)); + assign_callback(SDL_SCANCODE_Z, ks_Ctrl, Callback(this, &line_edit_control::undo_buf)); - assign_callback(DIK_C, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); - assign_callback(DIK_V, ks_Ctrl, Callback(this, &line_edit_control::paste_from_clipboard)); - assign_callback(DIK_X, ks_Ctrl, Callback(this, &line_edit_control::cut_to_clipboard)); + assign_callback(SDL_SCANCODE_C, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); + assign_callback(SDL_SCANCODE_V, ks_Ctrl, Callback(this, &line_edit_control::paste_from_clipboard)); + assign_callback(SDL_SCANCODE_X, ks_Ctrl, Callback(this, &line_edit_control::cut_to_clipboard)); - assign_callback(DIK_INSERT, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); - assign_callback(DIK_INSERT, ks_Shift, Callback(this, &line_edit_control::paste_from_clipboard)); - assign_callback(DIK_DELETE, ks_Shift, Callback(this, &line_edit_control::cut_to_clipboard)); + assign_callback(SDL_SCANCODE_INSERT, ks_Ctrl, Callback(this, &line_edit_control::copy_to_clipboard)); + assign_callback(SDL_SCANCODE_INSERT, ks_Shift, Callback(this, &line_edit_control::paste_from_clipboard)); + assign_callback(SDL_SCANCODE_DELETE, ks_Shift, Callback(this, &line_edit_control::cut_to_clipboard)); - assign_callback(DIK_HOME, ks_free, Callback(this, &line_edit_control::move_pos_home)); - assign_callback(DIK_END, ks_free, Callback(this, &line_edit_control::move_pos_end)); - assign_callback(DIK_LEFT, ks_free, Callback(this, &line_edit_control::move_pos_left)); - assign_callback(DIK_RIGHT, ks_free, Callback(this, &line_edit_control::move_pos_right)); - assign_callback(DIK_LEFT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_left_word)); - assign_callback(DIK_RIGHT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_right_word)); + assign_callback(SDL_SCANCODE_HOME, ks_free, Callback(this, &line_edit_control::move_pos_home)); + assign_callback(SDL_SCANCODE_END, ks_free, Callback(this, &line_edit_control::move_pos_end)); + assign_callback(SDL_SCANCODE_LEFT, ks_free, Callback(this, &line_edit_control::move_pos_left)); + assign_callback(SDL_SCANCODE_RIGHT, ks_free, Callback(this, &line_edit_control::move_pos_right)); + assign_callback(SDL_SCANCODE_LEFT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_left_word)); + assign_callback(SDL_SCANCODE_RIGHT, ks_Ctrl, Callback(this, &line_edit_control::move_pos_right_word)); - assign_callback(DIK_BACK, ks_free, Callback(this, &line_edit_control::delete_selected_back)); - assign_callback(DIK_DELETE, ks_free, Callback(this, &line_edit_control::delete_selected_forward)); - assign_callback(DIK_BACK, ks_Ctrl, Callback(this, &line_edit_control::delete_word_back)); - assign_callback(DIK_DELETE, ks_Ctrl, Callback(this, &line_edit_control::delete_word_forward)); + assign_callback(SDL_SCANCODE_BACKSPACE, ks_free, Callback(this, &line_edit_control::delete_selected_back)); + assign_callback(SDL_SCANCODE_DELETE, ks_free, Callback(this, &line_edit_control::delete_selected_forward)); + assign_callback(SDL_SCANCODE_BACKSPACE, ks_Ctrl, Callback(this, &line_edit_control::delete_word_back)); + assign_callback(SDL_SCANCODE_DELETE, ks_Ctrl, Callback(this, &line_edit_control::delete_word_forward)); - assign_callback(DIK_LSHIFT, ks_Ctrl, Callback(this, &line_edit_control::SwitchKL)); - assign_callback(DIK_LSHIFT, ks_Alt, Callback(this, &line_edit_control::SwitchKL)); + assign_callback(SDL_SCANCODE_LSHIFT, ks_Ctrl, Callback(this, &line_edit_control::SwitchKL)); + assign_callback(SDL_SCANCODE_LSHIFT, ks_Alt, Callback(this, &line_edit_control::SwitchKL)); } // if mode - create_key_state(DIK_LSHIFT, ks_LShift); - create_key_state(DIK_RSHIFT, ks_RShift); - create_key_state(DIK_LCONTROL, ks_LCtrl); - create_key_state(DIK_RCONTROL, ks_RCtrl); - create_key_state(DIK_LALT, ks_LAlt); - create_key_state(DIK_RALT, ks_RAlt); + create_key_state(SDL_SCANCODE_LSHIFT, ks_LShift); + create_key_state(SDL_SCANCODE_RSHIFT, ks_RShift); + create_key_state(SDL_SCANCODE_LCTRL, ks_LCtrl); + create_key_state(SDL_SCANCODE_RCTRL, ks_RCtrl); + create_key_state(SDL_SCANCODE_LALT, ks_LAlt); + create_key_state(SDL_SCANCODE_RALT, ks_RAlt); } void line_edit_control::assign_char_pairs(init_mode mode) { - create_char_pair(DIK_NUMPAD0, '0', '0'); - create_char_pair(DIK_NUMPAD1, '1', '1'); - create_char_pair(DIK_NUMPAD2, '2', '2'); - create_char_pair(DIK_NUMPAD3, '3', '3'); - create_char_pair(DIK_NUMPAD4, '4', '4'); - create_char_pair(DIK_NUMPAD5, '5', '5'); - create_char_pair(DIK_NUMPAD6, '6', '6'); - create_char_pair(DIK_NUMPAD7, '7', '7'); - create_char_pair(DIK_NUMPAD8, '8', '8'); - create_char_pair(DIK_NUMPAD9, '9', '9'); + create_char_pair(SDL_SCANCODE_KP_0, '0', '0'); + create_char_pair(SDL_SCANCODE_KP_1, '1', '1'); + create_char_pair(SDL_SCANCODE_KP_2, '2', '2'); + create_char_pair(SDL_SCANCODE_KP_3, '3', '3'); + create_char_pair(SDL_SCANCODE_KP_4, '4', '4'); + create_char_pair(SDL_SCANCODE_KP_5, '5', '5'); + create_char_pair(SDL_SCANCODE_KP_6, '6', '6'); + create_char_pair(SDL_SCANCODE_KP_7, '7', '7'); + create_char_pair(SDL_SCANCODE_KP_8, '8', '8'); + create_char_pair(SDL_SCANCODE_KP_9, '9', '9'); if (mode == im_number_only) { - create_char_pair(DIK_0, '0', '0'); - create_char_pair(DIK_1, '1', '1'); - create_char_pair(DIK_2, '2', '2'); - create_char_pair(DIK_3, '3', '3'); - create_char_pair(DIK_4, '4', '4'); - create_char_pair(DIK_5, '5', '5'); - create_char_pair(DIK_6, '6', '6'); - create_char_pair(DIK_7, '7', '7'); - create_char_pair(DIK_8, '8', '8'); - create_char_pair(DIK_9, '9', '9'); - create_char_pair(DIK_NUMPADMINUS, '-', '-'); - create_char_pair(DIK_MINUS, '-', '-'); - create_char_pair(DIK_NUMPADPLUS, '+', '+'); - create_char_pair(DIK_EQUALS, '+', '+'); + create_char_pair(SDL_SCANCODE_0, '0', '0'); + create_char_pair(SDL_SCANCODE_1, '1', '1'); + create_char_pair(SDL_SCANCODE_2, '2', '2'); + create_char_pair(SDL_SCANCODE_3, '3', '3'); + create_char_pair(SDL_SCANCODE_4, '4', '4'); + create_char_pair(SDL_SCANCODE_5, '5', '5'); + create_char_pair(SDL_SCANCODE_6, '6', '6'); + create_char_pair(SDL_SCANCODE_7, '7', '7'); + create_char_pair(SDL_SCANCODE_8, '8', '8'); + create_char_pair(SDL_SCANCODE_9, '9', '9'); + create_char_pair(SDL_SCANCODE_KP_MINUS, '-', '-'); + create_char_pair(SDL_SCANCODE_MINUS, '-', '-'); + create_char_pair(SDL_SCANCODE_KP_PLUS, '+', '+'); + create_char_pair(SDL_SCANCODE_EQUALS, '+', '+'); return; } if (mode != im_file_name_mode) { - create_char_pair(DIK_0, '0', ')', true); - create_char_pair(DIK_1, '1', '!', true); - create_char_pair(DIK_2, '2', '@', true); - create_char_pair(DIK_3, '3', '#', true); - create_char_pair(DIK_4, '4', '$', true); - create_char_pair(DIK_5, '5', '%', true); - create_char_pair(DIK_6, '6', '^', true); - create_char_pair(DIK_7, '7', '&', true); - create_char_pair(DIK_8, '8', '*', true); - create_char_pair(DIK_9, '9', '(', true); - - create_char_pair(DIK_BACKSLASH, '\\', '|', true); - create_char_pair(DIK_LBRACKET, '[', '{', true); - create_char_pair(DIK_RBRACKET, ']', '}', true); - create_char_pair(DIK_APOSTROPHE, '\'', '\"', true); - create_char_pair(DIK_COMMA, ',', '<', true); - create_char_pair(DIK_PERIOD, '.', '>', true); - create_char_pair(DIK_EQUALS, '=', '+', true); - create_char_pair(DIK_SEMICOLON, ';', ':', true); - create_char_pair(DIK_SLASH, '/', '?', true); - - create_char_pair(DIK_NUMPADSTAR, '*', '*'); - create_char_pair(DIK_NUMPADSLASH, '/', '/'); + create_char_pair(SDL_SCANCODE_0, '0', ')', true); + create_char_pair(SDL_SCANCODE_1, '1', '!', true); + create_char_pair(SDL_SCANCODE_2, '2', '@', true); + create_char_pair(SDL_SCANCODE_3, '3', '#', true); + create_char_pair(SDL_SCANCODE_4, '4', '$', true); + create_char_pair(SDL_SCANCODE_5, '5', '%', true); + create_char_pair(SDL_SCANCODE_6, '6', '^', true); + create_char_pair(SDL_SCANCODE_7, '7', '&', true); + create_char_pair(SDL_SCANCODE_8, '8', '*', true); + create_char_pair(SDL_SCANCODE_9, '9', '(', true); + + create_char_pair(SDL_SCANCODE_BACKSLASH, '\\', '|', true); + create_char_pair(SDL_SCANCODE_LEFTBRACKET, '[', '{', true); + create_char_pair(SDL_SCANCODE_RIGHTBRACKET, ']', '}', true); + create_char_pair(SDL_SCANCODE_APOSTROPHE, '\'', '\"', true); + create_char_pair(SDL_SCANCODE_COMMA, ',', '<', true); + create_char_pair(SDL_SCANCODE_PERIOD, '.', '>', true); + create_char_pair(SDL_SCANCODE_EQUALS, '=', '+', true); + create_char_pair(SDL_SCANCODE_SEMICOLON, ';', ':', true); + create_char_pair(SDL_SCANCODE_SLASH, '/', '?', true); + + create_char_pair(SDL_SCANCODE_KP_MULTIPLY, '*', '*'); + create_char_pair(SDL_SCANCODE_KP_DIVIDE, '/', '/'); } else { - create_char_pair(DIK_0, '0', '0'); - create_char_pair(DIK_1, '1', '1'); - create_char_pair(DIK_2, '2', '2'); - create_char_pair(DIK_3, '3', '3'); - create_char_pair(DIK_4, '4', '4'); - create_char_pair(DIK_5, '5', '5'); - create_char_pair(DIK_6, '6', '6'); - create_char_pair(DIK_7, '7', '7'); - create_char_pair(DIK_8, '8', '8'); - create_char_pair(DIK_9, '9', '9'); + create_char_pair(SDL_SCANCODE_0, '0', '0'); + create_char_pair(SDL_SCANCODE_1, '1', '1'); + create_char_pair(SDL_SCANCODE_2, '2', '2'); + create_char_pair(SDL_SCANCODE_3, '3', '3'); + create_char_pair(SDL_SCANCODE_4, '4', '4'); + create_char_pair(SDL_SCANCODE_5, '5', '5'); + create_char_pair(SDL_SCANCODE_6, '6', '6'); + create_char_pair(SDL_SCANCODE_7, '7', '7'); + create_char_pair(SDL_SCANCODE_8, '8', '8'); + create_char_pair(SDL_SCANCODE_9, '9', '9'); } - create_char_pair(DIK_NUMPADMINUS, '-', '-'); - create_char_pair(DIK_NUMPADPLUS, '+', '+'); - create_char_pair(DIK_NUMPADPERIOD, '.', '.'); - - create_char_pair(DIK_MINUS, '-', '_', true); - create_char_pair(DIK_SPACE, ' ', ' '); - create_char_pair(DIK_GRAVE, '`', '~', true); - - create_char_pair(DIK_A, 'a', 'A', true); - create_char_pair(DIK_B, 'b', 'B', true); - create_char_pair(DIK_C, 'c', 'C', true); - create_char_pair(DIK_D, 'd', 'D', true); - create_char_pair(DIK_E, 'e', 'E', true); - create_char_pair(DIK_F, 'f', 'F', true); - create_char_pair(DIK_G, 'g', 'G', true); - create_char_pair(DIK_H, 'h', 'H', true); - create_char_pair(DIK_I, 'i', 'I', true); - create_char_pair(DIK_J, 'j', 'J', true); - create_char_pair(DIK_K, 'k', 'K', true); - create_char_pair(DIK_L, 'l', 'L', true); - create_char_pair(DIK_M, 'm', 'M', true); - create_char_pair(DIK_N, 'n', 'N', true); - create_char_pair(DIK_O, 'o', 'O', true); - create_char_pair(DIK_P, 'p', 'P', true); - create_char_pair(DIK_Q, 'q', 'Q', true); - create_char_pair(DIK_R, 'r', 'R', true); - create_char_pair(DIK_S, 's', 'S', true); - create_char_pair(DIK_T, 't', 'T', true); - create_char_pair(DIK_U, 'u', 'U', true); - create_char_pair(DIK_V, 'v', 'V', true); - create_char_pair(DIK_W, 'w', 'W', true); - create_char_pair(DIK_X, 'x', 'X', true); - create_char_pair(DIK_Y, 'y', 'Y', true); - create_char_pair(DIK_Z, 'z', 'Z', true); + create_char_pair(SDL_SCANCODE_KP_MINUS, '-', '-'); + create_char_pair(SDL_SCANCODE_KP_PLUS, '+', '+'); + create_char_pair(SDL_SCANCODE_KP_PERIOD, '.', '.'); + + create_char_pair(SDL_SCANCODE_MINUS, '-', '_', true); + create_char_pair(SDL_SCANCODE_SPACE, ' ', ' '); + create_char_pair(SDL_SCANCODE_GRAVE, '`', '~', true); + + create_char_pair(SDL_SCANCODE_A, 'a', 'A', true); + create_char_pair(SDL_SCANCODE_B, 'b', 'B', true); + create_char_pair(SDL_SCANCODE_C, 'c', 'C', true); + create_char_pair(SDL_SCANCODE_D, 'd', 'D', true); + create_char_pair(SDL_SCANCODE_E, 'e', 'E', true); + create_char_pair(SDL_SCANCODE_F, 'f', 'F', true); + create_char_pair(SDL_SCANCODE_G, 'g', 'G', true); + create_char_pair(SDL_SCANCODE_H, 'h', 'H', true); + create_char_pair(SDL_SCANCODE_I, 'i', 'I', true); + create_char_pair(SDL_SCANCODE_J, 'j', 'J', true); + create_char_pair(SDL_SCANCODE_K, 'k', 'K', true); + create_char_pair(SDL_SCANCODE_L, 'l', 'L', true); + create_char_pair(SDL_SCANCODE_M, 'm', 'M', true); + create_char_pair(SDL_SCANCODE_N, 'n', 'N', true); + create_char_pair(SDL_SCANCODE_O, 'o', 'O', true); + create_char_pair(SDL_SCANCODE_P, 'p', 'P', true); + create_char_pair(SDL_SCANCODE_Q, 'q', 'Q', true); + create_char_pair(SDL_SCANCODE_R, 'r', 'R', true); + create_char_pair(SDL_SCANCODE_S, 's', 'S', true); + create_char_pair(SDL_SCANCODE_T, 't', 'T', true); + create_char_pair(SDL_SCANCODE_U, 'u', 'U', true); + create_char_pair(SDL_SCANCODE_V, 'v', 'V', true); + create_char_pair(SDL_SCANCODE_W, 'w', 'W', true); + create_char_pair(SDL_SCANCODE_X, 'x', 'X', true); + create_char_pair(SDL_SCANCODE_Y, 'y', 'Y', true); + create_char_pair(SDL_SCANCODE_Z, 'z', 'Z', true); } -void line_edit_control::create_key_state(u32 const dik, key_state state) +void line_edit_control::create_key_state(int const dik, key_state state) { Base* prev = m_actions[dik]; // if ( m_actions[dik] ) @@ -368,7 +345,7 @@ void line_edit_control::create_key_state(u32 const dik, key_state state) m_actions[dik] = new text_editor::key_state_base(state, prev); } -void line_edit_control::create_char_pair(u32 const dik, char c, char c_shift, bool translate) +void line_edit_control::create_char_pair(int const dik, char c, char c_shift, bool translate) { if (m_actions[dik]) { @@ -378,9 +355,9 @@ void line_edit_control::create_char_pair(u32 const dik, char c, char c_shift, bo m_actions[dik] = new text_editor::type_pair(dik, c, c_shift, translate); } -void line_edit_control::assign_callback(u32 const dik, key_state state, Callback const& callback) +void line_edit_control::assign_callback(int const dik, key_state state, Callback const& callback) { - VERIFY(dik < DIK_COUNT); + VERIFY(dik < SDL_NUM_SCANCODES); Base* prev_action = m_actions[dik]; m_actions[dik] = new text_editor::callback_base(callback, state); m_actions[dik]->on_assign(prev_action); @@ -406,7 +383,7 @@ void line_edit_control::set_edit(pcstr str) void line_edit_control::on_key_press(int dik) { - if (DIK_COUNT <= dik) + if (SDL_NUM_SCANCODES <= dik) { return; } @@ -426,7 +403,7 @@ void line_edit_control::on_key_press(int dik) m_actions[dik]->on_key_press(this); } // =========== - if (dik == DIK_LCONTROL || dik == DIK_RCONTROL) + if (dik == SDL_SCANCODE_LCTRL || dik == SDL_SCANCODE_RCTRL) { m_mark = false; } @@ -456,13 +433,13 @@ void line_edit_control::on_key_hold(int dik) update_bufs(); switch (dik) { - case DIK_TAB: - case DIK_LSHIFT: - case DIK_RSHIFT: - case DIK_LCONTROL: - case DIK_RCONTROL: - case DIK_LALT: - case DIK_RALT: return; break; + case SDL_SCANCODE_TAB: + case SDL_SCANCODE_LSHIFT: + case SDL_SCANCODE_RSHIFT: + case SDL_SCANCODE_LCTRL: + case SDL_SCANCODE_RCTRL: + case SDL_SCANCODE_LALT: + case SDL_SCANCODE_RALT: return; break; } if (m_repeat_mode && m_last_key_time > 5.0f * g_console_sensitive) @@ -491,7 +468,7 @@ void line_edit_control::on_frame() { update_key_states(); - u32 fr_time = Device.dwTimeContinual; + const auto fr_time = Device.dwTimeContinual; float dt = (fr_time - m_last_frame_time) * 0.001f; if (dt > 0.06666f) { @@ -739,7 +716,16 @@ void line_edit_control::compute_positions() } void line_edit_control::clamp_cur_pos() { clamp(m_cur_pos, 0, (int)xr_strlen(m_edit_str)); } -void line_edit_control::SwitchKL() { ActivateKeyboardLayout((HKL)HKL_NEXT, 0); } +void line_edit_control::SwitchKL() +{ +#ifdef WINDOWS + // XXX: do we even need this? + // Check if SDL_HINT_GRAB_KEYBOARD works + // and enable in case if we will need this + if (false && pInput->IsExclusiveMode()) + ActivateKeyboardLayout((HKL)HKL_NEXT, 0); +#endif +} // ------------------------------------------------------------------------------------------------- void remove_spaces(pstr str) @@ -777,7 +763,6 @@ void remove_spaces(pstr str) --i; if (i < str_size) - strncpy_s(str, str_size, new_str, i); } diff --git a/src/xrEngine/line_edit_control.h b/src/xrEngine/line_edit_control.h index 351a3fc08e2..f8af017f8c6 100644 --- a/src/xrEngine/line_edit_control.h +++ b/src/xrEngine/line_edit_control.h @@ -60,7 +60,7 @@ class ENGINE_API line_edit_control void on_key_release(int dik); void on_frame(); - void assign_callback(u32 const dik, key_state state, Callback const& callback); + void assign_callback(int const dik, key_state state, Callback const& callback); void insert_character(char c); @@ -106,8 +106,8 @@ class ENGINE_API line_edit_control void xr_stdcall SwitchKL(); void assign_char_pairs(init_mode mode); - void create_key_state(u32 const dik, key_state state); - void create_char_pair(u32 const dik, char c, char c_shift, bool translate = false); + void create_key_state(int const dik, key_state state); + void create_char_pair(int const dik, char c, char c_shift, bool translate = false); void clear_inserted(); bool empty_inserted(); @@ -119,11 +119,7 @@ class ENGINE_API line_edit_control void clamp_cur_pos(); private: - enum - { - DIK_COUNT = 256 - }; - Base* m_actions[DIK_COUNT]; + Base* m_actions[SDL_NUM_SCANCODES]; char* m_edit_str; char* m_undo_buf; diff --git a/src/xrEngine/line_editor.cpp b/src/xrEngine/line_editor.cpp index 6d2a4540892..1f9c803736c 100644 --- a/src/xrEngine/line_editor.cpp +++ b/src/xrEngine/line_editor.cpp @@ -10,8 +10,15 @@ namespace text_editor { -line_editor::line_editor(u32 str_buffer_size) : m_control(str_buffer_size) {} -line_editor::~line_editor() {} +line_editor::line_editor(u32 str_buffer_size) : m_control(str_buffer_size) +{ + SDL_StartTextInput(); +} +line_editor::~line_editor() +{ + SDL_StopTextInput(); +} + void line_editor::on_frame() { m_control.on_frame(); } void line_editor::IR_OnKeyboardPress(int dik) { m_control.on_key_press(dik); } void line_editor::IR_OnKeyboardHold(int dik) { m_control.on_key_hold(dik); } diff --git a/src/xrEngine/main.cpp b/src/xrEngine/main.cpp index 0b0a39c5233..e257941a59c 100644 --- a/src/xrEngine/main.cpp +++ b/src/xrEngine/main.cpp @@ -2,7 +2,11 @@ #include "stdafx.h" #include "main.h" +#if defined(WINDOWS) #include +#elif defined(LINUX) +#include +#endif #include #include "IGame_Persistent.h" @@ -14,7 +18,12 @@ #include "LightAnimLibrary.h" #include "xrCDB/ISpatial.h" +#if defined(WINDOWS) #include "Text_Console.h" +#elif defined(LINUX) +#define CTextConsole CConsole +#pragma todo("Implement text console or it's alternative") +#endif #include "xrSASH.h" #include "xr_ioc_cmd.h" @@ -101,7 +110,7 @@ ENGINE_API void InitConsole() ENGINE_API void InitInput() { - bool captureInput = !strstr(Core.Params, "-i"); + bool captureInput = !strstr(Core.Params, "-i") && !GEnv.isEditor; pInput = new CInput(captureInput); } @@ -128,6 +137,9 @@ ENGINE_API void destroyEngine() { Device.Destroy(); Engine.Destroy(); +#if defined(LINUX) + lockfile_remove("/var/lock/stalker-cop.lock"); +#endif } void execUserScript() @@ -209,9 +221,15 @@ ENGINE_API int RunApplication() #ifdef NO_MULTI_INSTANCES if (!GEnv.isDedicatedServer) { +#if defined(WINDOWS) CreateMutex(nullptr, TRUE, "Local\\STALKER-COP"); if (GetLastError() == ERROR_ALREADY_EXISTS) return 2; +#elif defined(LINUX) + int lock_res = lockfile_create("/var/lock/stalker-cop.lock", 0, L_PID); + if(L_ERROR == lock_res) + return 2; +#endif } #endif *g_sLaunchOnExit_app = 0; @@ -264,6 +282,7 @@ ENGINE_API int RunApplication() // check for need to execute something external if (/*xr_strlen(g_sLaunchOnExit_params) && */ xr_strlen(g_sLaunchOnExit_app)) { +#if defined(WINDOWS) // CreateProcess need to return results to next two structures STARTUPINFO si = {}; si.cb = sizeof(si); @@ -271,6 +290,7 @@ ENGINE_API int RunApplication() // We use CreateProcess to setup working folder pcstr tempDir = xr_strlen(g_sLaunchWorkingFolder) ? g_sLaunchWorkingFolder : nullptr; CreateProcess(g_sLaunchOnExit_app, g_sLaunchOnExit_params, nullptr, nullptr, FALSE, 0, nullptr, tempDir, &si, &pi); +#endif } return 0; } 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/phdebug.cpp b/src/xrEngine/phdebug.cpp index a13ddf4c335..4d0acd8f863 100644 --- a/src/xrEngine/phdebug.cpp +++ b/src/xrEngine/phdebug.cpp @@ -2,4 +2,6 @@ #include "IPHdebug.h" +#if defined(WINDOWS) IPhDebugRender* ph_debug_render = 0; +#endif diff --git a/src/xrEngine/splash.cpp b/src/xrEngine/splash.cpp index 99a92b431e4..cc6f264e9e9 100644 --- a/src/xrEngine/splash.cpp +++ b/src/xrEngine/splash.cpp @@ -8,12 +8,14 @@ static INT_PTR CALLBACK LogoWndProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { +#if defined(WINDOWS) case WM_DESTROY: break; case WM_CLOSE: DestroyWindow(hw); break; case WM_COMMAND: if (LOWORD(wp) == IDCANCEL) DestroyWindow(hw); break; +#endif default: return false; } return true; @@ -25,7 +27,7 @@ void show(const bool topmost) { if (logoWindow) return; - +#if defined(WINDOWS) logoWindow = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_STARTUP), nullptr, LogoWndProc); const HWND logoPicture = GetDlgItem(logoWindow, IDC_STATIC_LOGO); RECT logoRect; @@ -34,13 +36,16 @@ void show(const bool topmost) SetWindowPos(logoWindow, prevWindow, 0, 0, logoRect.right - logoRect.left, logoRect.bottom - logoRect.top, SWP_NOMOVE | SWP_SHOWWINDOW); UpdateWindow(logoWindow); +#endif } void hide() { if (logoWindow != nullptr) { +#if defined(WINDOWS) DestroyWindow(logoWindow); +#endif logoWindow = nullptr; } } diff --git a/src/xrEngine/stdafx.h b/src/xrEngine/stdafx.h index c400d046729..9918412ecca 100644 --- a/src/xrEngine/stdafx.h +++ b/src/xrEngine/stdafx.h @@ -28,12 +28,11 @@ #include "xrCDB/xrXRC.h" -#include "xrSound/sound.h" +#include "xrSound/Sound.h" extern ENGINE_API CInifile* pGameIni; #pragma comment(lib, "winmm.lib") -#pragma comment(lib, "dinput8.lib") #pragma comment(lib, "dxguid.lib") // XXX: move to script engine headers #ifndef DEBUG diff --git a/src/xrEngine/tntQAVI.h b/src/xrEngine/tntQAVI.h index a74e097eeae..839f0e8a641 100644 --- a/src/xrEngine/tntQAVI.h +++ b/src/xrEngine/tntQAVI.h @@ -3,8 +3,10 @@ #include +#if defined(WINDOWS) #include "vfw.h" #include "mmsystem.h" +#endif // replaced with standard AVIIF_KEYFRAME // rr #define AVIINDEX_ISKEYFRAME 0x10 // ключевой кадр diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index 48804933e02..27c5336bb4c 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -133,6 +133,8 @@ CApplication::CApplication() loadingScreen = nullptr; } +extern CInput* pInput; + CApplication::~CApplication() { Console->Hide(); @@ -157,12 +159,14 @@ void CApplication::OnEvent(EVENT E, u64 P1, u64 P2) { if (E == eQuit) { - if (pInput != NULL) - pInput->ClipCursor(false); + if (pInput != nullptr) + pInput->GrabInput(false); g_SASH.EndBenchmark(); - PostQuitMessage(0); + SDL_Event event; + event.type = SDL_QUIT; + SDL_PeepEvents(&event, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT); for (u32 i = 0; i < Levels.size(); i++) { @@ -196,8 +200,8 @@ void CApplication::OnEvent(EVENT E, u64 P1, u64 P2) } else if (E == eDisconnect) { - if (pInput != NULL && TRUE == Engine.Event.Peek("KERNEL:quit")) - pInput->ClipCursor(false); + if (pInput != nullptr && TRUE == Engine.Event.Peek("KERNEL:quit")) + pInput->GrabInput(false); if (g_pGameLevel) { 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..38ca83a7278 100644 --- a/src/xrEngine/xr_input.cpp +++ b/src/xrEngine/xr_input.cpp @@ -6,6 +6,7 @@ #include "Include/editor/ide.hpp" #include "GameFont.h" #include "PerformanceAlert.hpp" +#include "xrCore/Text/MbHelpers.h" #ifndef _EDITOR #include "xr_input_xinput.h" @@ -19,137 +20,49 @@ ENGINE_API Flags32 psMouseInvert = {FALSE}; 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) { - if (!pInput || !g_exclusive || Device.editor()) + if (!pInput || !pInput->IsExclusiveMode() || Device.editor()) return; if (before) - { - pInput->unacquire(); - return; - } - - pInput->acquire(true); + pInput->GrabInput(false); + else + pInput->GrabInput(true); } -CInput::CInput(BOOL bExclusive, int deviceForInit) +CInput::CInput(const bool exclusive) { - g_exclusive = !!bExclusive; + exclusiveInput = exclusive; Log("Starting INPUT device..."); - pDI = NULL; - pMouse = NULL; - pKeyboard = NULL; - - //=====================Mouse - mouse_property.mouse_dt = 25; + MouseDelta = 25; ZeroMemory(mouseState, sizeof(mouseState)); - ZeroMemory(KBState, sizeof(KBState)); - ZeroMemory(timeStamp, sizeof(timeStamp)); - ZeroMemory(timeSave, sizeof(timeStamp)); + ZeroMemory(keyboardState, sizeof(keyboardState)); + ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp)); 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)); - xrDebug::SetDialogHandler(on_error_dialog); -#ifdef ENGINE_BUILD + SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1"); + SDL_StopTextInput(); // sanity + Device.seqAppActivate.Add(this); Device.seqAppDeactivate.Add(this, REG_PRIORITY_HIGH); Device.seqFrame.Add(this, REG_PRIORITY_HIGH); -#endif } -CInput::~CInput(void) +CInput::~CInput() { -#ifdef ENGINE_BUILD + GrabInput(false); Device.seqFrame.Remove(this); Device.seqAppDeactivate.Remove(this); Device.seqAppActivate.Remove(this); -#endif - //_______________________ - - // Unacquire and release the device's interfaces - if (pMouse) - { - pMouse->Unacquire(); - _RELEASE(pMouse); - } - - if (pKeyboard) - { - pKeyboard->Unacquire(); - _RELEASE(pKeyboard); - } - - _SHOW_REF("Input: ", pDI); - _RELEASE(pDI); -} - -//----------------------------------------------------------------------------- -// Name: CreateInputDevice() -// Desc: Create a DirectInput device. -//----------------------------------------------------------------------------- -HRESULT CInput::CreateInputDevice( - LPDIRECTINPUTDEVICE8* device, GUID guidDevice, const DIDATAFORMAT* pdidDataFormat, u32 dwFlags, u32 buf_size) -{ - // Obtain an interface to the input device - //. CHK_DX( pDI->CreateDeviceEx( guidDevice, IID_IDirectInputDevice8, (void**)device, NULL ) ); - CHK_DX(pDI->CreateDevice(guidDevice, /*IID_IDirectInputDevice8,*/ device, NULL)); - - // Set the device data format. Note: a data format specifies which - // controls on a device we are interested in, and how they should be - // 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); - } - - // setup the buffer size for the keyboard data - DIPROPDWORD dipdw; - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = buf_size; - - CHK_DX((*device)->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)); - - return S_OK; } //----------------------------------------------------------------------- @@ -159,414 +72,206 @@ void CInput::DumpStatistics(IGameFont& font, IPerformanceAlert* alert) font.OutNext("*** INPUT: %2.2fms", pInput->GetStats().FrameTime.result); } -void CInput::SetAllAcquire(BOOL bAcquire) -{ - if (pMouse) - bAcquire ? pMouse->Acquire() : pMouse->Unacquire(); - if (pKeyboard) - bAcquire ? pKeyboard->Acquire() : pKeyboard->Unacquire(); -} - -void CInput::SetMouseAcquire(BOOL bAcquire) -{ - if (pMouse) - bAcquire ? pMouse->Acquire() : pMouse->Unacquire(); -} -void CInput::SetKBDAcquire(BOOL bAcquire) -{ - if (pKeyboard) - bAcquire ? pKeyboard->Acquire() : pKeyboard->Unacquire(); -} -//----------------------------------------------------------------------- -BOOL b_altF4 = FALSE; -void CInput::KeyUpdate() +void CInput::MouseUpdate() { - if (b_altF4) - return; + SDL_PumpEvents(); - HRESULT hr; - DWORD dwElements = KEYBOARDBUFFERSIZE; - DIDEVICEOBJECTDATA od[KEYBOARDBUFFERSIZE]; - DWORD key = 0; + bool mouse_prev[COUNT_MOUSE_BUTTONS]; - 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; + mouse_prev[0] = mouseState[0]; + mouse_prev[1] = mouseState[1]; + mouse_prev[2] = mouseState[2]; + mouse_prev[3] = mouseState[3]; + mouse_prev[4] = mouseState[4]; + mouse_prev[5] = mouseState[5]; + mouse_prev[6] = mouseState[6]; + mouse_prev[7] = mouseState[7]; - hr = pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0); - if (hr != S_OK) - return; - } + bool mouseMoved = false; + offs[0] = offs[1] = offs[2] = 0; - bool b_dik_pause_was_pressed = false; - for (u32 idx = 0; idx < dwElements; idx++) + SDL_Event event; + while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEWHEEL)) { - if (od[idx].dwOfs == DIK_PAUSE) + switch (event.type) { - 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 - } + case SDL_MOUSEMOTION: + mouseMoved = true; + mouseTimeStamp[0] = dwCurTime + event.motion.timestamp; + mouseTimeStamp[1] = dwCurTime + event.motion.timestamp; + offs[0] += event.motion.xrel; + offs[1] += event.motion.yrel; + break; + case SDL_MOUSEBUTTONUP: + mouseState[event.button.button - 1] = false; + cbStack.back()->IR_OnMouseRelease(event.button.button - 1); + break; + case SDL_MOUSEBUTTONDOWN: + mouseState[event.button.button - 1] = true; + cbStack.back()->IR_OnMousePress(event.button.button - 1); + break; + case SDL_MOUSEWHEEL: + mouseMoved = true; + mouseTimeStamp[2] = dwCurTime + event.wheel.timestamp; + mouseTimeStamp[3] = dwCurTime + event.wheel.timestamp; + offs[2] += event.wheel.y; + offs[3] += event.wheel.x; + break; } - KBState[od[idx].dwOfs] = od[idx].dwData & 0x80; } -#ifndef _EDITOR - bool b_alt_tab = false; + auto isButtonOnHold = [&](int i) + { + if (mouseState[i] && mouse_prev[i]) + cbStack.back()->IR_OnMouseHold(i); + }; + + isButtonOnHold(0); + isButtonOnHold(1); + isButtonOnHold(2); + isButtonOnHold(3); + isButtonOnHold(4); + isButtonOnHold(5); + isButtonOnHold(6); + isButtonOnHold(7); - if (!b_altF4 && KBState[DIK_F4] && (KBState[DIK_RMENU] || KBState[DIK_LMENU])) + if (mouseMoved) { - b_altF4 = TRUE; - Engine.Event.Defer("KERNEL:disconnect"); - Engine.Event.Defer("KERNEL:quit"); + if (offs[0] || offs[1]) + cbStack.back()->IR_OnMouseMove(offs[0], offs[1]); + if (offs[2] || offs[3]) + cbStack.back()->IR_OnMouseWheel(offs[2], offs[3]); } + else + { + if (mouseTimeStamp[1] && dwCurTime - mouseTimeStamp[1] >= MouseDelta) + cbStack.back()->IR_OnMouseStop(0, mouseTimeStamp[1] = 0); + if (mouseTimeStamp[0] && dwCurTime - mouseTimeStamp[0] >= MouseDelta) + cbStack.back()->IR_OnMouseStop(0, mouseTimeStamp[0] = 0); + } +} -#endif - if (b_altF4) - return; +void CInput::KeyUpdate() +{ + SDL_PumpEvents(); -#ifndef _EDITOR - if (Device.dwPrecacheFrame == 0) -#endif + SDL_Event event; + while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYDOWN, SDL_KEYUP)) { - for (u32 i = 0; i < dwElements; i++) + switch (event.type) { - if (od[i].uAppData == 666) // ignored action + case SDL_KEYDOWN: + if (event.key.repeat) continue; + keyboardState[event.key.keysym.scancode] = true; + cbStack.back()->IR_OnKeyboardPress(event.key.keysym.scancode); + break; - key = od[i].dwOfs; - if (od[i].dwData & 0x80) - cbStack.back()->IR_OnKeyboardPress(key); - else - { - cbStack.back()->IR_OnKeyboardRelease(key); -#ifndef _EDITOR - if (key == DIK_TAB && (iGetAsyncKeyState(DIK_RMENU) || iGetAsyncKeyState(DIK_LMENU))) - b_alt_tab = true; -#endif - } + case SDL_KEYUP: + keyboardState[event.key.keysym.scancode] = false; + cbStack.back()->IR_OnKeyboardRelease(event.key.keysym.scancode); + break; } - - for (u32 i = 0; i < COUNT_KB_BUTTONS; i++) - if (KBState[i]) - cbStack.back()->IR_OnKeyboardHold(i); } -#ifndef _EDITOR - if (b_alt_tab) - SendMessage(Device.m_hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); -#endif - /* - #ifndef _EDITOR - //update xinput if exist - for( DWORD iUserIndex=0; iUserIndexIR_OnMousePress(0); - else - cbStack.back()->IR_OnMouseRelease(0); - } - int dx,dy; - dx = iFloor(g_GamePads[iUserIndex].fThumbRX*6); - dy = iFloor(g_GamePads[iUserIndex].fThumbRY*6); - if(dx || dy) - cbStack.back()->IR_OnMouseMove ( dx, dy ); - } + for (u32 i = 0; i < COUNT_KB_BUTTONS; ++i) + if (keyboardState[i]) + cbStack.back()->IR_OnKeyboardHold(i); +} - if(Device.fTimeGlobal > stop_vibration_time) +pcstr KeyToMouseButtonName(const int dik) +{ + switch (dik) { - stop_vibration_time = flt_max; - set_vibration (0, 0); + case MOUSE_1: return "Left mouse"; + case MOUSE_2: return "Right mouse"; + case MOUSE_3: return "Center mouse"; + case MOUSE_4: return "Fourth mouse"; + case MOUSE_5: return "Fifth mouse"; + case MOUSE_6: return "Sixth mouse"; + case MOUSE_7: return "Seventh mouse"; + case MOUSE_8: return "Eighth mouse"; + default: return "Unknown mouse"; } - //xinput - #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) + xr_string keyname; + + if (dik < SDL_NUM_SCANCODES) + keyname = StringFromUTF8(SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)dik))); + else + keyname = KeyToMouseButtonName(dik); + + if (keyname.empty()) { - Msg("! cant convert dik_name for dik[%d], prop=[%S]", dik, keyname.wsz); - return false; + if (dik == SDL_SCANCODE_UNKNOWN) + keyname = "Unknown"; + else + { + Msg("! Can't convert dik_name for dik[%d]", dik); + return false; + } } - return (cnt != -1); -} -#define MOUSE_1 (0xED + 100) -#define MOUSE_8 (0xED + 107) + xr_strcpy(dest_str, dest_sz, keyname.c_str()); + return true; +} -BOOL CInput::iGetAsyncKeyState(int dik) +bool CInput::iGetAsyncKeyState(int dik) { if (dik < COUNT_KB_BUTTONS) - return !!KBState[dik]; - else if (dik >= MOUSE_1 && dik <= MOUSE_8) + return keyboardState[dik]; + + if (dik >= MOUSE_1 && dik <= MOUSE_8) { - int mk = dik - MOUSE_1; + const int mk = dik - MOUSE_1; return iGetAsyncBtnState(mk); } - else - return FALSE; // unknown key ??? + + // unknown key ??? + return false; } -BOOL CInput::iGetAsyncBtnState(int btn) { return !!mouseState[btn]; } -void CInput::ClipCursor(bool clip) +bool CInput::iGetAsyncBtnState(int btn) +{ + return mouseState[btn]; +} + +void CInput::ClipCursor(const bool clip) { if (clip) { - ::ClipCursor(&Device.m_rcWindowClient); - while (ShowCursor(FALSE) >= 0) {} + SDL_ShowCursor(SDL_TRUE); + SDL_SetRelativeMouseMode(SDL_TRUE); } else { - ::ClipCursor(nullptr); - while (ShowCursor(TRUE) <= 0) {} + SDL_ShowCursor(SDL_FALSE); + SDL_SetRelativeMouseMode(SDL_FALSE); } } -void CInput::MouseUpdate() +void CInput::GrabInput(const bool grab) { - HRESULT hr; - DWORD dwElements = MOUSEBUFFERSIZE; - DIDEVICEOBJECTDATA od[MOUSEBUFFERSIZE]; - - VERIFY(pMouse); - - hr = pMouse->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0); - if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED)) - { - hr = pMouse->Acquire(); - if (hr != S_OK) - return; - hr = pMouse->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), &od[0], &dwElements, 0); - if (hr != S_OK) - return; - }; - -#ifndef _EDITOR - if (Device.dwPrecacheFrame) - return; -#endif - BOOL mouse_prev[COUNT_MOUSE_BUTTONS]; - - mouse_prev[0] = mouseState[0]; - mouse_prev[1] = mouseState[1]; - mouse_prev[2] = mouseState[2]; - mouse_prev[3] = mouseState[3]; - mouse_prev[4] = mouseState[4]; - mouse_prev[5] = mouseState[5]; - mouse_prev[6] = mouseState[6]; - mouse_prev[7] = mouseState[7]; - - offs[0] = offs[1] = offs[2] = 0; - for (u32 i = 0; i < dwElements; i++) - { - switch (od[i].dwOfs) - { - case DIMOFS_X: - offs[0] += od[i].dwData; - timeStamp[0] = od[i].dwTimeStamp; - break; - case DIMOFS_Y: - offs[1] += od[i].dwData; - timeStamp[1] = od[i].dwTimeStamp; - break; - case DIMOFS_Z: - offs[2] += od[i].dwData; - timeStamp[2] = od[i].dwTimeStamp; - break; - case DIMOFS_BUTTON0: - if (od[i].dwData & 0x80) - { - mouseState[0] = TRUE; - cbStack.back()->IR_OnMousePress(0); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[0] = FALSE; - cbStack.back()->IR_OnMouseRelease(0); - } - break; - case DIMOFS_BUTTON1: - if (od[i].dwData & 0x80) - { - mouseState[1] = TRUE; - cbStack.back()->IR_OnMousePress(1); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[1] = FALSE; - cbStack.back()->IR_OnMouseRelease(1); - } - break; - case DIMOFS_BUTTON2: - if (od[i].dwData & 0x80) - { - mouseState[2] = TRUE; - cbStack.back()->IR_OnMousePress(2); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[2] = FALSE; - cbStack.back()->IR_OnMouseRelease(2); - } - break; - case DIMOFS_BUTTON3: - if (od[i].dwData & 0x80) - { - mouseState[3] = TRUE; - cbStack.back()->IR_OnKeyboardPress(0xED + 103); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[3] = FALSE; - cbStack.back()->IR_OnKeyboardRelease(0xED + 103); - } - break; - case DIMOFS_BUTTON4: - if (od[i].dwData & 0x80) - { - mouseState[4] = TRUE; - cbStack.back()->IR_OnKeyboardPress(0xED + 104); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[4] = FALSE; - cbStack.back()->IR_OnKeyboardRelease(0xED + 104); - } - break; - case DIMOFS_BUTTON5: - if (od[i].dwData & 0x80) - { - mouseState[5] = TRUE; - cbStack.back()->IR_OnKeyboardPress(0xED + 105); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[5] = FALSE; - cbStack.back()->IR_OnKeyboardRelease(0xED + 105); - } - break; - case DIMOFS_BUTTON6: - if (od[i].dwData & 0x80) - { - mouseState[6] = TRUE; - cbStack.back()->IR_OnKeyboardPress(0xED + 106); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[6] = FALSE; - cbStack.back()->IR_OnKeyboardRelease(0xED + 106); - } - break; - case DIMOFS_BUTTON7: - if (od[i].dwData & 0x80) - { - mouseState[7] = TRUE; - cbStack.back()->IR_OnKeyboardPress(0xED + 107); - } - if (!(od[i].dwData & 0x80)) - { - mouseState[7] = FALSE; - cbStack.back()->IR_OnKeyboardRelease(0xED + 107); - } - break; - } - } - - // Giperion: double check mouse buttons state - DIMOUSESTATE2 MouseState; - hr = pMouse->GetDeviceState(sizeof(MouseState), &MouseState); - - auto RecheckMouseButtonFunc = [&](int i) - { - if (MouseState.rgbButtons[i] & 0x80 && mouseState[i] == FALSE) - { - mouseState[i] = TRUE; - cbStack.back()->IR_OnMousePress(i); - } - else if (!(MouseState.rgbButtons[i] & 0x80) && mouseState[i] == TRUE) - { - mouseState[i] = FALSE; - cbStack.back()->IR_OnMouseRelease(i); - } - }; + ClipCursor(grab); - if (hr == S_OK) - { - RecheckMouseButtonFunc(0); - RecheckMouseButtonFunc(1); - RecheckMouseButtonFunc(2); - } - //-Giperion + if (IsExclusiveMode()) + SDL_SetWindowGrab(Device.m_sdlWnd, grab ? SDL_TRUE : SDL_FALSE); - auto isButtonOnHold = [&](int i) - { - if (mouseState[i] && mouse_prev[i]) - cbStack.back()->IR_OnMouseHold(i); - }; + inputGrabbed = grab; - isButtonOnHold(0); - isButtonOnHold(1); - isButtonOnHold(2); +} - if (dwElements) - { - if (offs[0] || offs[1]) - cbStack.back()->IR_OnMouseMove(offs[0], offs[1]); - if (offs[2]) - cbStack.back()->IR_OnMouseWheel(offs[2]); - } - else - { - if (timeStamp[1] && ((dwCurTime - timeStamp[1]) >= mouse_property.mouse_dt)) - cbStack.back()->IR_OnMouseStop(DIMOFS_Y, timeStamp[1] = 0); - if (timeStamp[0] && ((dwCurTime - timeStamp[0]) >= mouse_property.mouse_dt)) - cbStack.back()->IR_OnMouseStop(DIMOFS_X, timeStamp[0] = 0); - } +bool CInput::InputIsGrabbed() const +{ + return inputGrabbed; } -//------------------------------------------------------- void CInput::iCapture(IInputReceiver* p) { VERIFY(p); - if (pMouse) - MouseUpdate(); - if (pKeyboard) - KeyUpdate(); // change focus if (!cbStack.empty()) @@ -575,8 +280,7 @@ void CInput::iCapture(IInputReceiver* p) cbStack.back()->IR_OnActivate(); // prepare for _new_ controller - ZeroMemory(timeStamp, sizeof(timeStamp)); - ZeroMemory(timeSave, sizeof(timeStamp)); + ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp)); ZeroMemory(offs, sizeof(offs)); } @@ -586,8 +290,7 @@ void CInput::iRelease(IInputReceiver* p) { cbStack.back()->IR_OnDeactivate(); cbStack.pop_back(); - IInputReceiver* ir = cbStack.back(); - ir->IR_OnActivate(); + cbStack.back()->IR_OnActivate(); } else { @@ -609,11 +312,9 @@ void CInput::OnAppActivate(void) if (CurrentIR()) CurrentIR()->IR_OnActivate(); - SetAllAcquire(true); ZeroMemory(mouseState, sizeof(mouseState)); - ZeroMemory(KBState, sizeof(KBState)); - ZeroMemory(timeStamp, sizeof(timeStamp)); - ZeroMemory(timeSave, sizeof(timeStamp)); + ZeroMemory(keyboardState, sizeof(keyboardState)); + ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp)); ZeroMemory(offs, sizeof(offs)); } @@ -622,11 +323,9 @@ void CInput::OnAppDeactivate(void) if (CurrentIR()) CurrentIR()->IR_OnDeactivate(); - SetAllAcquire(false); ZeroMemory(mouseState, sizeof(mouseState)); - ZeroMemory(KBState, sizeof(KBState)); - ZeroMemory(timeStamp, sizeof(timeStamp)); - ZeroMemory(timeSave, sizeof(timeStamp)); + ZeroMemory(keyboardState, sizeof(keyboardState)); + ZeroMemory(mouseTimeStamp, sizeof(mouseTimeStamp)); ZeroMemory(offs, sizeof(offs)); } @@ -635,10 +334,13 @@ void CInput::OnFrame(void) stats.FrameStart(); stats.FrameTime.Begin(); dwCurTime = RDEVICE.TimerAsync_MMT(); - if (pKeyboard) + + if (Device.dwPrecacheFrame == 0) + { KeyUpdate(); - if (pMouse) MouseUpdate(); + } + stats.FrameTime.End(); stats.FrameEnd(); } @@ -647,38 +349,18 @@ IInputReceiver* CInput::CurrentIR() { if (cbStack.size()) return cbStack.back(); - else - return NULL; + return nullptr; } -void CInput::unacquire() +void CInput::ExclusiveMode(const bool exclusive) { - pKeyboard->Unacquire(); - pMouse->Unacquire(); + GrabInput(false); + exclusiveInput = exclusive; + GrabInput(true); } -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(); -} +bool CInput::IsExclusiveMode() const { return exclusiveInput; } -void CInput::exclusive_mode(const bool& exclusive) -{ - g_exclusive = exclusive; - unacquire(); - acquire(exclusive); -} -bool CInput::get_exclusive_mode() { return g_exclusive; } void CInput::feedback(u16 s1, u16 s2, float time) { stop_vibration_time = RDEVICE.fTimeGlobal + time; diff --git a/src/xrEngine/xr_input.h b/src/xrEngine/xr_input.h index 45b55b09d9b..f268d572813 100644 --- a/src/xrEngine/xr_input.h +++ b/src/xrEngine/xr_input.h @@ -1,45 +1,54 @@ #ifndef __XR_INPUT__ #define __XR_INPUT__ -#define DIRECTINPUT_VERSION 0x0800 -#include +// SDL_NUM_SCANCODES - max vavue in SDL_SCANCODE_* enum +#define MOUSE_1 (SDL_NUM_SCANCODES + SDL_BUTTON_LEFT) +#define MOUSE_2 (SDL_NUM_SCANCODES + SDL_BUTTON_RIGHT) +#define MOUSE_3 (SDL_NUM_SCANCODES + SDL_BUTTON_MIDDLE) -class ENGINE_API IInputReceiver; +#define MOUSE_4 (SDL_NUM_SCANCODES + SDL_BUTTON_X1) +#define MOUSE_5 (SDL_NUM_SCANCODES + SDL_BUTTON_X2) +#define MOUSE_6 (SDL_NUM_SCANCODES + 6) +#define MOUSE_7 (SDL_NUM_SCANCODES + 7) +#define MOUSE_8 (SDL_NUM_SCANCODES + 8) + +constexpr int MouseButtonToKey[] = { MOUSE_1, MOUSE_3, MOUSE_2, MOUSE_4, MOUSE_5, MOUSE_6, MOUSE_7, MOUSE_8 }; + +inline int KeyToMouseButton(const int dik, const bool fromZero = true) +{ + int i = 0; + if (!fromZero) + ++i; -//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -//описание класса -const int mouse_device_key = 1; -const int keyboard_device_key = 2; -const int all_device_key = mouse_device_key | keyboard_device_key; -const int default_key = mouse_device_key | keyboard_device_key; + switch (dik) + { + case MOUSE_1: return 0 + i; + case MOUSE_2: return 1 + i; + case MOUSE_3: return 2 + i; + case MOUSE_4: return 3 + i; + case MOUSE_5: return 4 + i; + case MOUSE_6: return 5 + i; + case MOUSE_7: return 6 + i; + case MOUSE_8: return 7 + i; + default: return dik - SDL_NUM_SCANCODES + i; + } +} + +class ENGINE_API IInputReceiver; class ENGINE_API CInput -#ifndef M_BORLAND : public pureFrame, public pureAppActivate, public pureAppDeactivate -#endif { public: enum { COUNT_MOUSE_BUTTONS = 8, - COUNT_MOUSE_AXIS = 3, - COUNT_KB_BUTTONS = 256 - }; - struct sxr_mouse - { - DIDEVCAPS capabilities; - DIDEVICEINSTANCE deviceInfo; - DIDEVICEOBJECTINSTANCE objectInfo; - u32 mouse_dt; - }; - struct sxr_key - { - DIDEVCAPS capabilities; - DIDEVICEINSTANCE deviceInfo; - DIDEVICEOBJECTINSTANCE objectInfo; + COUNT_MOUSE_AXIS = 4, + COUNT_KB_BUTTONS = SDL_NUM_SCANCODES }; + struct InputStatistics { CStatTimer FrameTime; @@ -50,61 +59,51 @@ class ENGINE_API CInput private: 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]; - int offs[COUNT_MOUSE_AXIS]; - BOOL mouseState[COUNT_MOUSE_BUTTONS]; - //---------------------- - BOOL KBState[COUNT_KB_BUTTONS]; + u32 mouseTimeStamp[COUNT_MOUSE_AXIS]; + + int offs[COUNT_MOUSE_AXIS]; - HRESULT CreateInputDevice( - LPDIRECTINPUTDEVICE8* device, GUID guidDevice, const DIDATAFORMAT* pdidDataFormat, u32 dwFlags, u32 buf_size); + bool mouseState[COUNT_MOUSE_BUTTONS]; + bool keyboardState[COUNT_KB_BUTTONS]; - // xr_stack cbStack; xr_vector cbStack; void MouseUpdate(); void KeyUpdate(); InputStatistics stats; + bool exclusiveInput; + bool inputGrabbed; public: - sxr_mouse mouse_property; - sxr_key key_property; u32 dwCurTime; + u32 MouseDelta; const InputStatistics& GetStats() const { return stats; } void DumpStatistics(class IGameFont& font, class IPerformanceAlert* alert); - void SetAllAcquire(BOOL bAcquire = TRUE); - void SetMouseAcquire(BOOL bAcquire); - void SetKBDAcquire(BOOL bAcquire); void iCapture(IInputReceiver* pc); void iRelease(IInputReceiver* pc); - BOOL iGetAsyncKeyState(int dik); - BOOL iGetAsyncBtnState(int btn); + bool iGetAsyncKeyState(int dik); + bool iGetAsyncBtnState(int btn); void iGetLastMouseDelta(Ivector2& p) { p.set(offs[0], offs[1]); } - void ClipCursor(bool clip); + void ClipCursor(const bool clip); + void GrabInput(const bool grab); + bool InputIsGrabbed() const; - CInput(BOOL bExclusive = true, int deviceForInit = default_key); + CInput(const bool exclusive = true); ~CInput(); - virtual void OnFrame(void); - virtual void OnAppActivate(void); - virtual void OnAppDeactivate(void); + virtual void OnFrame(); + virtual void OnAppActivate(); + virtual void OnAppDeactivate(); IInputReceiver* CurrentIR(); public: - void exclusive_mode(const bool& exclusive); - IC bool get_exclusive_mode(); - void unacquire(); - void acquire(const bool& exclusive); + void ExclusiveMode(const bool exclusive); + bool IsExclusiveMode() const; bool get_dik_name(int dik, LPSTR dest, int dest_sz); void feedback(u16 s1, u16 s2, float time); diff --git a/src/xrEngine/xr_ioc_cmd.cpp b/src/xrEngine/xr_ioc_cmd.cpp index 17cc1700f65..b7c580ec7ee 100644 --- a/src/xrEngine/xr_ioc_cmd.cpp +++ b/src/xrEngine/xr_ioc_cmd.cpp @@ -14,8 +14,14 @@ #include "xr_object.h" #include "xr_object_list.h" -ENGINE_API xr_vector AvailableVideoModes; -xr_vector vid_quality_token; +extern void FillVidModesToken(u32 monitorID); +extern void FillRefreshRateToken(); +ENGINE_API u32 Vid_SelectedMonitor = 0; +ENGINE_API u32 Vid_SelectedRefreshRate = 60; +ENGINE_API xr_vector VidMonitorsToken; +ENGINE_API xr_vector VidModesToken; +ENGINE_API xr_vector VidRefreshRateToken; +xr_vector VidQualityToken; const xr_token vid_bpp_token[] = {{"16", 16}, {"32", 32}, {0, 0}}; @@ -206,9 +212,10 @@ class CCC_SaveCFG : public IConsole_Command xr_strcat(cfg_full_name, ".ltx"); BOOL b_allow = TRUE; +#if defined(WINDOWS) if (FS.exist(cfg_full_name)) b_allow = SetFileAttributes(cfg_full_name, FILE_ATTRIBUTE_NORMAL); - +#endif if (b_allow) { IWriter* F = FS.w_open(cfg_full_name); @@ -370,7 +377,7 @@ class CCC_VID_Reset : public IConsole_Command }; class CCC_VidMode : public CCC_Token { - u32 _dummy; + u32 _dummy = 0; public: CCC_VidMode(LPCSTR N) : CCC_Token(N, &_dummy, NULL) { bEmptyArgsHandled = FALSE; }; @@ -382,6 +389,7 @@ class CCC_VidMode : public CCC_Token { psCurrentVidMode[0] = _w; psCurrentVidMode[1] = _h; + FillRefreshRateToken(); } else { @@ -390,7 +398,7 @@ class CCC_VidMode : public CCC_Token } } virtual void Status(TStatus& S) { xr_sprintf(S, sizeof(S), "%dx%d", psCurrentVidMode[0], psCurrentVidMode[1]); } - const xr_token* GetToken() noexcept override { return AvailableVideoModes.data(); } + const xr_token* GetToken() noexcept override { return VidModesToken.data(); } virtual void Info(TInfo& I) { xr_strcpy(I, sizeof(I), "change screen resolution WxH"); } virtual void fill_tips(vecTips& tips, u32 mode) { @@ -422,6 +430,30 @@ class CCC_VidMode : public CCC_Token } }; //----------------------------------------------------------------------- +class CCC_VidMonitor : public CCC_Token +{ +public: + CCC_VidMonitor(pcstr name) : CCC_Token(name, &Vid_SelectedMonitor, nullptr) + { + bEmptyArgsHandled = false; + } + + void Execute(pcstr args) override + { + CCC_Token::Execute(args); + FillVidModesToken(Vid_SelectedMonitor); + } + + const xr_token* GetToken() noexcept override { return VidMonitorsToken.data(); } +}; +//----------------------------------------------------------------------- +class CCC_VidRefresh : public CCC_Token +{ +public: + CCC_VidRefresh(pcstr name) : CCC_Token(name, &Vid_SelectedRefreshRate, nullptr) { bEmptyArgsHandled = false; } + const xr_token* GetToken() noexcept override { return VidRefreshRateToken.data(); } +}; +//----------------------------------------------------------------------- class CCC_SND_Restart : public IConsole_Command { public: @@ -512,7 +544,7 @@ class CCC_r2 : public CCC_Token virtual ~CCC_r2() {} virtual void Execute(LPCSTR args) { - tokens = vid_quality_token.data(); + tokens = VidQualityToken.data(); inherited::Execute(args); // 0 - r1 @@ -534,13 +566,13 @@ class CCC_r2 : public CCC_Token virtual void Save(IWriter* F) { // fill_render_mode_list (); - tokens = vid_quality_token.data(); + tokens = VidQualityToken.data(); inherited::Save(F); } const xr_token* GetToken() noexcept override { - tokens = vid_quality_token.data(); + tokens = VidQualityToken.data(); return inherited::GetToken(); } }; @@ -610,7 +642,7 @@ class CCC_ExclusiveMode : public IConsole_Command else InvalidSyntax(); - pInput->exclusive_mode(value); + pInput->ExclusiveMode(value); } virtual void Save(IWriter* F) {} @@ -625,6 +657,16 @@ class ENGINE_API CCC_HideConsole : public IConsole_Command virtual void Info(TInfo& I) { xr_sprintf(I, sizeof(I), "hide console"); } }; +class CCC_CenterScreen : public IConsole_Command +{ +public: + CCC_CenterScreen(pcstr name) : IConsole_Command(name) { bEmptyArgsHandled = true; } + void Execute(pcstr args) override + { + SDL_SetWindowPosition(Device.m_sdlWnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + } +}; + ENGINE_API float psHUD_FOV = 0.45f; // extern int psSkeletonUpdate; @@ -645,6 +687,7 @@ extern int ps_rs_loading_stages; ENGINE_API int ps_always_active = 0; ENGINE_API int ps_r__Supersample = 1; + void CCC_Register() { // General @@ -716,6 +759,8 @@ void CCC_Register() // General video control CMD1(CCC_VidMode, "vid_mode"); + CMD1(CCC_VidMonitor, "vid_monitor"); + CMD1(CCC_VidRefresh, "vid_refresh") #ifdef DEBUG CMD3(CCC_Token, "vid_bpp", &psCurrentBPP, vid_bpp_token); @@ -752,6 +797,7 @@ void CCC_Register() CMD2(CCC_Float, "cam_inert", &psCamInert); CMD2(CCC_Float, "cam_slide_inert", &psCamSlideInert); + CMD1(CCC_CenterScreen, "center_screen"); CMD4(CCC_Integer, "always_active", &ps_always_active, 0, 1); CMD1(CCC_r2, "renderer"); diff --git a/src/xrEngine/xr_ioc_cmd.h b/src/xrEngine/xr_ioc_cmd.h index be61a9e7085..739ef24db58 100644 --- a/src/xrEngine/xr_ioc_cmd.h +++ b/src/xrEngine/xr_ioc_cmd.h @@ -157,7 +157,12 @@ class ENGINE_API CCC_Token : public IConsole_Command virtual void Execute(LPCSTR args) { - const xr_token* tok = tokens; + const xr_token* tok = GetToken(); + if (!tok) + { + Msg("! token [%s] is null", cName); + return; + } while (tok->name) { if (xr_stricmp(tok->name, args) == 0) @@ -172,7 +177,7 @@ class ENGINE_API CCC_Token : public IConsole_Command } virtual void Status(TStatus& S) { - const xr_token* tok = tokens; + const xr_token* tok = GetToken(); while (tok->name) { if (tok->id == (int)(*value)) @@ -188,7 +193,7 @@ class ENGINE_API CCC_Token : public IConsole_Command virtual void Info(TInfo& I) { I[0] = 0; - const xr_token* tok = tokens; + const xr_token* tok = GetToken(); while (tok->name) { if (I[0]) diff --git a/src/xrGame/Actor.h b/src/xrGame/Actor.h index 3601bffa4d5..0f748333c09 100644 --- a/src/xrGame/Actor.h +++ b/src/xrGame/Actor.h @@ -431,7 +431,7 @@ class CActor : public CEntityAlive, virtual void IR_OnKeyboardPress(int dik); virtual void IR_OnKeyboardRelease(int dik); virtual void IR_OnKeyboardHold(int dik); - virtual void IR_OnMouseWheel(int direction); + virtual void IR_OnMouseWheel(int x, int y); virtual float GetLookFactor(); public: diff --git a/src/xrGame/ActorInput.cpp b/src/xrGame/ActorInput.cpp index 2b554ba88a3..dd133a62e09 100644 --- a/src/xrGame/ActorInput.cpp +++ b/src/xrGame/ActorInput.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "Actor.h" #include "Torch.h" #include "trade.h" @@ -37,7 +36,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()) @@ -200,18 +199,18 @@ void CActor::IR_OnKeyboardPress(int cmd) } } -void CActor::IR_OnMouseWheel(int direction) +void CActor::IR_OnMouseWheel(int x, int y) { if (hud_adj_mode) { - g_player_hud->tune(Ivector().set(0, 0, direction)); + g_player_hud->tune(Ivector().set(0, 0, x)); return; } - if (inventory().Action((direction > 0) ? (u16)kWPN_ZOOM_DEC : (u16)kWPN_ZOOM_INC, CMD_START)) + if (inventory().Action((x > 0) ? (u16)kWPN_ZOOM_DEC : (u16)kWPN_ZOOM_INC, CMD_START)) return; - if (direction > 0) + if (x > 0) OnNextWeaponSlot(); else OnPrevWeaponSlot(); @@ -219,7 +218,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 +253,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()) @@ -469,7 +468,7 @@ void CActor::ActorUse() if (object) element = (u16)RQ.element; - if (object && Level().IR_GetKeyState(DIK_LSHIFT)) + if (object && Level().IR_GetKeyState(SDL_SCANCODE_LSHIFT)) { bool b_allow = !!pSettings->line_exist("ph_capture_visuals", object->cNameVisual()); if (b_allow && !character_physics_support()->movement()->PHCapture()) @@ -660,9 +659,9 @@ void CActor::NoClipFly(int cmd) Fvector cur_pos; // = Position(); cur_pos.set(0, 0, 0); float scale = 1.0f; - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) scale = 0.25f; - else if (pInput->iGetAsyncKeyState(DIK_LMENU)) + else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)) scale = 4.0f; switch (cmd) diff --git a/src/xrGame/CameraLook.cpp b/src/xrGame/CameraLook.cpp index b6212ad5252..a1a202d9ce8 100644 --- a/src/xrGame/CameraLook.cpp +++ b/src/xrGame/CameraLook.cpp @@ -85,7 +85,7 @@ void CCameraLook::OnActivate(CCameraBase* old_cam) #include "visual_memory_manager.h" #include "actor_memory.h" -int cam_dik = DIK_LSHIFT; +int cam_dik = SDL_SCANCODE_LSHIFT; Fvector CCameraLook2::m_cam_offset; void CCameraLook2::OnActivate(CCameraBase* old_cam) { CCameraLook::OnActivate(old_cam); } 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/Level.h b/src/xrGame/Level.h index c68a6cc9534..81f5e6555c6 100644 --- a/src/xrGame/Level.h +++ b/src/xrGame/Level.h @@ -298,7 +298,7 @@ class CLevel : public IGame_Level, public IPureClient virtual void IR_OnMouseHold(int btn); virtual void IR_OnMouseMove(int, int); virtual void IR_OnMouseStop(int, int); - virtual void IR_OnMouseWheel(int direction); + virtual void IR_OnMouseWheel(int x, int y); virtual void IR_OnActivate(void); int get_RPID(LPCSTR name); // Game diff --git a/src/xrGame/Level_input.cpp b/src/xrGame/Level_input.cpp index f2b076a2651..3fd6d6a7cc1 100644 --- a/src/xrGame/Level_input.cpp +++ b/src/xrGame/Level_input.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "xrEngine/XR_IOConsole.h" #include "entity_alive.h" #include "game_sv_single.h" @@ -44,7 +43,7 @@ extern float g_fTimeFactor; #define CURRENT_ENTITY() (game ? ((GameID() == eGameIDSingle) ? CurrentEntity() : CurrentControlEntity()) : NULL) -void CLevel::IR_OnMouseWheel(int direction) +void CLevel::IR_OnMouseWheel(int x, int y) { if (g_bDisableAllInput) return; @@ -52,10 +51,10 @@ void CLevel::IR_OnMouseWheel(int direction) #ifdef INPUT_CALLBACKS /* avo: script callback */ if (g_actor) - g_actor->callback(GameObject::eMouseWheel)(direction); + g_actor->callback(GameObject::eMouseWheel)(x); /* avo: end */ #endif - if (CurrentGameUI()->IR_UIOnMouseWheel(direction)) + if (CurrentGameUI()->IR_UIOnMouseWheel(x, y)) return; if (Device.Paused() #ifdef DEBUG @@ -68,15 +67,13 @@ void CLevel::IR_OnMouseWheel(int direction) { IInputReceiver* IR = smart_cast(smart_cast(CURRENT_ENTITY())); if (IR) - IR->IR_OnMouseWheel(direction); + IR->IR_OnMouseWheel(x, y); } } -static int mouse_button_2_key[] = {MOUSE_1, MOUSE_2, MOUSE_3}; - -void CLevel::IR_OnMousePress(int btn) { IR_OnKeyboardPress(mouse_button_2_key[btn]); } -void CLevel::IR_OnMouseRelease(int btn) { IR_OnKeyboardRelease(mouse_button_2_key[btn]); } -void CLevel::IR_OnMouseHold(int btn) { IR_OnKeyboardHold(mouse_button_2_key[btn]); } +void CLevel::IR_OnMousePress(int btn) {IR_OnKeyboardPress(MouseButtonToKey[btn]); } +void CLevel::IR_OnMouseRelease(int btn) {IR_OnKeyboardRelease(MouseButtonToKey[btn]); } +void CLevel::IR_OnMouseHold(int btn) {IR_OnKeyboardHold(MouseButtonToKey[btn]); } void CLevel::IR_OnMouseMove(int dx, int dy) { if (g_bDisableAllInput) @@ -120,7 +117,7 @@ void CLevel::IR_OnKeyboardPress(int key) if (Device.dwPrecacheFrame) return; - if (Device.editor() && (pInput->iGetAsyncKeyState(DIK_LALT) || pInput->iGetAsyncKeyState(DIK_RALT))) + if (Device.editor() && (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT))) return; bool b_ui_exist = !!CurrentGameUI(); @@ -224,7 +221,7 @@ void CLevel::IR_OnKeyboardPress(int key) #ifndef MASTER_GOLD switch (key) { - case DIK_F7: + case SDL_SCANCODE_F7: { if (GameID() != eGameIDSingle) return; @@ -236,7 +233,7 @@ void CLevel::IR_OnKeyboardPress(int key) Send(net_packet, net_flags(TRUE)); return; } - case DIK_DIVIDE: + case SDL_SCANCODE_KP_DIVIDE: { if (!Server) break; @@ -252,7 +249,7 @@ void CLevel::IR_OnKeyboardPress(int key) break; } - case DIK_MULTIPLY: + case SDL_SCANCODE_KP_MULTIPLY: { if (!Server) break; @@ -268,7 +265,7 @@ void CLevel::IR_OnKeyboardPress(int key) break; } #ifdef DEBUG - case DIK_SUBTRACT: + case SDL_SCANCODE_KP_MINUS: { if (!Server) break; @@ -281,14 +278,14 @@ void CLevel::IR_OnKeyboardPress(int key) break; } #endif // DEBUG - case DIK_NUMPAD5: + case SDL_SCANCODE_KP_5: { if (GameID() != eGameIDSingle) { Msg("For this game type Demo Record is disabled."); /// return; }; - if (!pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (!pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { Console->Hide(); Console->Execute("demo_record 1"); @@ -299,12 +296,12 @@ void CLevel::IR_OnKeyboardPress(int key) #ifdef DEBUG // Lain: added TEMP!!! - case DIK_UP: + case SDL_SCANCODE_UP: { g_separate_factor /= 0.9f; break; } - case DIK_DOWN: + case SDL_SCANCODE_DOWN: { g_separate_factor *= 0.9f; if (g_separate_factor < 0.1f) @@ -313,7 +310,7 @@ void CLevel::IR_OnKeyboardPress(int key) } break; } - case DIK_LEFT: + case SDL_SCANCODE_LEFT: { g_separate_radius *= 0.9f; if (g_separate_radius < 0) @@ -322,29 +319,29 @@ void CLevel::IR_OnKeyboardPress(int key) } break; } - case DIK_RIGHT: + case SDL_SCANCODE_RIGHT: { g_separate_radius /= 0.9f; break; } - case DIK_RETURN: + case SDL_SCANCODE_RETURN: { bDebug = !bDebug; return; } - case DIK_BACK: + case SDL_SCANCODE_BACKSPACE: if (GameID() == eGameIDSingle) GEnv.DRender->NextSceneMode(); // HW.Caps.SceneMode = (HW.Caps.SceneMode+1)%3; return; - case DIK_F4: + case SDL_SCANCODE_F4: { - if (pInput->iGetAsyncKeyState(DIK_LALT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)) break; - if (pInput->iGetAsyncKeyState(DIK_RALT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT)) break; bool bOk = false; @@ -413,7 +410,7 @@ void CLevel::IR_OnKeyboardPress(int key) return; } // Lain: added - case DIK_F5: + case SDL_SCANCODE_F5: { if (CBaseMonster* pBM = smart_cast(CurrentEntity())) { @@ -427,7 +424,7 @@ void CLevel::IR_OnKeyboardPress(int key) if (GameID() != eGameIDSingle) break; - if (pInput->iGetAsyncKeyState(DIK_LALT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)) { if (smart_cast(CurrentEntity())) try_change_current_entity(); @@ -440,7 +437,7 @@ void CLevel::IR_OnKeyboardPress(int key) /**/ #endif #ifdef DEBUG - case DIK_F9: + case SDL_SCANCODE_F9: { // if (!ai().get_alife()) // break; @@ -448,7 +445,7 @@ void CLevel::IR_OnKeyboardPress(int key) break; } return; -// case DIK_F10:{ +// case SDL_SCANCODE_F10:{ // ai().level_graph().set_dest_point(); // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) @@ -463,7 +460,7 @@ void CLevel::IR_OnKeyboardPress(int key) // functor(0,false); // } // return; -// case DIK_F11: +// case SDL_SCANCODE_F11: // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; @@ -544,7 +541,7 @@ void CLevel::IR_OnKeyboardHold(int key) #ifdef DEBUG // Lain: added - if (key == DIK_UP) + if (key == SDL_SCANCODE_UP) { static u32 time = Device.dwTimeGlobal; if (Device.dwTimeGlobal - time > 20) @@ -556,7 +553,7 @@ void CLevel::IR_OnKeyboardHold(int key) } } } - else if (key == DIK_DOWN) + else if (key == SDL_SCANCODE_DOWN) { static u32 time = Device.dwTimeGlobal; if (Device.dwTimeGlobal - time > 20) @@ -612,7 +609,9 @@ void CLevel::IR_OnActivate() case kACCEL: case kL_LOOKOUT: case kR_LOOKOUT: - case kWPN_FIRE: { IR_OnKeyboardPress(i); + case kWPN_FIRE: + { + IR_OnKeyboardPress(i); } break; }; diff --git a/src/xrGame/MainMenu.cpp b/src/xrGame/MainMenu.cpp index 27d88868b0a..f43aeb3b6ce 100644 --- a/src/xrGame/MainMenu.cpp +++ b/src/xrGame/MainMenu.cpp @@ -8,7 +8,6 @@ #include "xr_Level_controller.h" #include "ui\UITextureMaster.h" #include "ui\UIXmlInit.h" -#include #include "ui\UIBtnHint.h" #include "UICursor.h" #include "xrGameSpy/GameSpy_Full.h" @@ -36,6 +35,7 @@ #include "profile_store.h" #include "stats_submitter.h" #include "atlas_submit_queue.h" +#include "xrEngine/xr_input.h" // fwd. decl. extern ENGINE_API BOOL bShowPauseString; @@ -296,16 +296,16 @@ bool CMainMenu::ReloadUI() return true; } -bool CMainMenu::IsActive() { return !!m_Flags.test(flActive); } +bool CMainMenu::IsActive() const { return m_Flags.test(flActive); } bool CMainMenu::CanSkipSceneRendering() { return IsActive() && !m_Flags.test(flGameSaveScreenshot); } + // IInputReceiver -static int mouse_button_2_key[] = {MOUSE_1, MOUSE_2, MOUSE_3}; void CMainMenu::IR_OnMousePress(int btn) { if (!IsActive()) return; - IR_OnKeyboardPress(mouse_button_2_key[btn]); + IR_OnKeyboardPress(MouseButtonToKey[btn]); }; void CMainMenu::IR_OnMouseRelease(int btn) @@ -313,7 +313,7 @@ void CMainMenu::IR_OnMouseRelease(int btn) if (!IsActive()) return; - IR_OnKeyboardRelease(mouse_button_2_key[btn]); + IR_OnKeyboardRelease(MouseButtonToKey[btn]); }; void CMainMenu::IR_OnMouseHold(int btn) @@ -321,7 +321,7 @@ void CMainMenu::IR_OnMouseHold(int btn) if (!IsActive()) return; - IR_OnKeyboardHold(mouse_button_2_key[btn]); + IR_OnKeyboardHold(MouseButtonToKey[btn]); }; void CMainMenu::IR_OnMouseMove(int x, int y) @@ -333,6 +333,7 @@ void CMainMenu::IR_OnMouseMove(int x, int y) void CMainMenu::IR_OnMouseStop(int x, int y){}; +bool IWantMyMouseBackScreamed = false; void CMainMenu::IR_OnKeyboardPress(int dik) { if (!IsActive()) @@ -343,7 +344,16 @@ void CMainMenu::IR_OnKeyboardPress(int dik) Console->Show(); return; } - if (DIK_F12 == dik) + + if ((pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT)) + && (pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RGUI))) + { + IWantMyMouseBackScreamed = true; + pInput->GrabInput(false); + SDL_SetWindowOpacity(Device.m_sdlWnd, 0.9f); + } + + if (SDL_SCANCODE_F12 == dik) { GEnv.Render->Screenshot(); return; @@ -357,6 +367,14 @@ void CMainMenu::IR_OnKeyboardRelease(int dik) if (!IsActive()) return; + if (IWantMyMouseBackScreamed) + { + IWantMyMouseBackScreamed = false; + pInput->GrabInput(true); + SDL_SetWindowOpacity(Device.m_sdlWnd, 1.f); + } + + CDialogHolder::IR_UIOnKeyboardRelease(dik); }; @@ -368,12 +386,12 @@ void CMainMenu::IR_OnKeyboardHold(int dik) CDialogHolder::IR_UIOnKeyboardHold(dik); }; -void CMainMenu::IR_OnMouseWheel(int direction) +void CMainMenu::IR_OnMouseWheel(int x, int y) { if (!IsActive()) return; - CDialogHolder::IR_UIOnMouseWheel(direction); + CDialogHolder::IR_UIOnMouseWheel(x, y); } bool CMainMenu::OnRenderPPUI_query() { return IsActive() && !m_Flags.test(flGameSaveScreenshot) && b_shniaganeed_pp; } diff --git a/src/xrGame/MainMenu.h b/src/xrGame/MainMenu.h index 672826a4112..6209fad4e20 100644 --- a/src/xrGame/MainMenu.h +++ b/src/xrGame/MainMenu.h @@ -49,7 +49,6 @@ class CMainMenu : public IMainMenu, public CDialogHolder, public CUIWndCallback, public CDeviceResetNotifier - { CUIDialogWnd* m_startDialog; @@ -136,7 +135,7 @@ class CMainMenu : public IMainMenu, virtual ~CMainMenu(); virtual void Activate(bool bActive); - virtual bool IsActive(); + bool IsActive() const override; virtual bool CanSkipSceneRendering(); virtual bool IgnorePause() { return true; } @@ -150,7 +149,7 @@ class CMainMenu : public IMainMenu, virtual void IR_OnKeyboardRelease(int dik); virtual void IR_OnKeyboardHold(int dik); - virtual void IR_OnMouseWheel(int direction); + virtual void IR_OnMouseWheel(int x, int y); bool OnRenderPPUI_query(); void OnRenderPPUI_main(); diff --git a/src/xrGame/StdAfx.h b/src/xrGame/StdAfx.h index cb93962019f..646d6b00b93 100644 --- a/src/xrGame/StdAfx.h +++ b/src/xrGame/StdAfx.h @@ -13,7 +13,6 @@ //#include // ~440 - but it has no include guard! Perhaps that's intentional? #include #include // ~360 -#include // Only ~60, heavy enough to warrant including in pch #include "luabind/luabind.hpp" // luabind/*, almost 5000 #include "xrServerEntities/smart_cast.h" // a lot #include "xrScriptEngine/script_space_forward.hpp" // ~765 // XXX: See to it this goes to pch_script diff --git a/src/xrGame/UICursor.cpp b/src/xrGame/UICursor.cpp index 77a73ad8091..c5f4cd751a8 100644 --- a/src/xrGame/UICursor.cpp +++ b/src/xrGame/UICursor.cpp @@ -55,9 +55,14 @@ void CUICursor::InitInternal() m_static->SetWndSize(sz); m_static->SetStretchTexture(true); - u32 screen_size_x = GetSystemMetrics(SM_CXSCREEN); - u32 screen_size_y = GetSystemMetrics(SM_CYSCREEN); - m_b_use_win_cursor = (screen_size_y >= Device.dwHeight && screen_size_x >= Device.dwWidth); + SDL_Rect display; + R_ASSERT3(SDL_GetDisplayBounds(0, &display) == 0, "SDL_GetDisplayBounds display failed: ", SDL_GetError()); + + const u32 screen_size_x = display.w - display.x; + const u32 screen_size_y = display.h - display.y; + m_b_use_win_cursor = screen_size_y >= Device.dwHeight && screen_size_x >= Device.dwWidth; + if (m_b_use_win_cursor) // sanity + Device.UpdateWindowRects(); } //-------------------------------------------------------------------- @@ -107,8 +112,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 +129,8 @@ 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); - SetCursorPos(p.x, p.y); + 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)); + + SDL_WarpMouseInWindow(Device.m_sdlWnd, p.x, p.y); } diff --git a/src/xrGame/UIDialogHolder.cpp b/src/xrGame/UIDialogHolder.cpp index 2a433e636df..ddb62619ccd 100644 --- a/src/xrGame/UIDialogHolder.cpp +++ b/src/xrGame/UIDialogHolder.cpp @@ -339,7 +339,7 @@ bool CDialogHolder::IR_UIOnKeyboardHold(int dik) return true; } -bool CDialogHolder::IR_UIOnMouseWheel(int direction) +bool CDialogHolder::IR_UIOnMouseWheel(int x, int y) { CUIDialogWnd* TIR = TopInputReceiver(); if (!TIR) @@ -349,7 +349,18 @@ bool CDialogHolder::IR_UIOnMouseWheel(int direction) Fvector2 pos = GetUICursor().GetCursorPosition(); - TIR->OnMouseAction(pos.x, pos.y, (direction > 0) ? WINDOW_MOUSE_WHEEL_UP : WINDOW_MOUSE_WHEEL_DOWN); + // Vertical scroll is in higher priority + EUIMessages wheelMessage; + if (x > 0) + wheelMessage = WINDOW_MOUSE_WHEEL_UP; + else if (x < 0) + wheelMessage = WINDOW_MOUSE_WHEEL_DOWN; + else if (y > 0) + wheelMessage = WINDOW_MOUSE_WHEEL_RIGHT; + else + wheelMessage = WINDOW_MOUSE_WHEEL_LEFT; + + TIR->OnMouseAction(pos.x, pos.y, wheelMessage); return true; } diff --git a/src/xrGame/UIDialogHolder.h b/src/xrGame/UIDialogHolder.h index 14588da6d88..c0a13f4f04e 100644 --- a/src/xrGame/UIDialogHolder.h +++ b/src/xrGame/UIDialogHolder.h @@ -61,6 +61,6 @@ class CDialogHolder : public pureFrame virtual bool IR_UIOnKeyboardPress(int dik); virtual bool IR_UIOnKeyboardRelease(int dik); virtual bool IR_UIOnMouseMove(int dx, int dy); - virtual bool IR_UIOnMouseWheel(int direction); + virtual bool IR_UIOnMouseWheel(int x, int y); virtual bool IR_UIOnKeyboardHold(int dik); }; diff --git a/src/xrGame/UIGameCTA.cpp b/src/xrGame/UIGameCTA.cpp index 66f78ab3098..958db266dd5 100644 --- a/src/xrGame/UIGameCTA.cpp +++ b/src/xrGame/UIGameCTA.cpp @@ -1,8 +1,6 @@ #include "stdafx.h" #include "UIGameCTA.h" -#include - #include "UITeamPanels.h" #include "game_cl_base.h" @@ -784,7 +782,7 @@ bool CUIGameCTA::IR_UIOnKeyboardPress(int dik) switch (dik) { - case DIK_CAPSLOCK: + case SDL_SCANCODE_CAPSLOCK: { if (m_game) { @@ -822,7 +820,7 @@ bool CUIGameCTA::IR_UIOnKeyboardRelease(int dik) switch (dik) { - case DIK_CAPSLOCK: + case SDL_SCANCODE_CAPSLOCK: { if (m_game) { diff --git a/src/xrGame/UIGameMP.cpp b/src/xrGame/UIGameMP.cpp index bbaa0bfaefc..a8ae6b409dc 100644 --- a/src/xrGame/UIGameMP.cpp +++ b/src/xrGame/UIGameMP.cpp @@ -25,8 +25,6 @@ void UIGameMP::ShowDemoPlayControl() GetUICursor().SetUICursorPosition(m_pDemoPlayControl->GetLastCursorPos()); } -#include - bool UIGameMP::IR_UIOnKeyboardPress(int dik) { if (is_binded(kCROUCH, dik) && Level().IsDemoPlay()) @@ -35,7 +33,7 @@ bool UIGameMP::IR_UIOnKeyboardPress(int dik) return true; } #ifdef DEBUG - if (dik == DIK_T) + if (dik == SDL_SCANCODE_T) { m_game->AddRewardTask(0); // mp_award_massacre } diff --git a/src/xrGame/UIGameTDM.cpp b/src/xrGame/UIGameTDM.cpp index 49085adebe7..331059bd725 100644 --- a/src/xrGame/UIGameTDM.cpp +++ b/src/xrGame/UIGameTDM.cpp @@ -6,7 +6,6 @@ #include "game_cl_TeamDeathmatch.h" #include "ui/TeamInfo.h" -#include #include "Common/object_broker.h" @@ -82,7 +81,7 @@ bool CUIGameTDM::IR_UIOnKeyboardPress(int dik) { switch (dik) { - case DIK_CAPSLOCK: + case SDL_SCANCODE_CAPSLOCK: { if (m_game) { @@ -102,7 +101,7 @@ bool CUIGameTDM::IR_UIOnKeyboardRelease(int dik) { switch (dik) { - case DIK_CAPSLOCK: + case SDL_SCANCODE_CAPSLOCK: { if (m_game) { diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp b/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp index 6ffc665cfb2..72185e99842 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp @@ -21,9 +21,6 @@ #include "ActorCondition.h" #include "PHDestroyable.h" #include "CharacterPhysicsSupport.h" -#ifdef DEBUG -#include -#endif // DEBUG namespace detail { @@ -859,11 +856,11 @@ void CAI_Bloodsucker::debug_on_key(int key) { switch (key) { - case DIK_MINUS: + case SDL_SCANCODE_MINUS: Actor()->cam_Active()->Move(Random.randI(2) ? kRIGHT : kLEFT, PI_DIV_2); // set_alien_control(true); break; - case DIK_EQUALS: + case SDL_SCANCODE_EQUALS: Actor()->cam_Active()->Move(Random.randI(2) ? kUP : kDOWN, PI_DIV_2); // set_alien_control(false); break; diff --git a/src/xrGame/ai/monsters/controller/controller.cpp b/src/xrGame/ai/monsters/controller/controller.cpp index bb652c04767..ed06f04f4fd 100644 --- a/src/xrGame/ai/monsters/controller/controller.cpp +++ b/src/xrGame/ai/monsters/controller/controller.cpp @@ -34,10 +34,6 @@ #include "ai/Monsters/Controller/controller_psy_hit.h" #include "ai/Monsters/monster_cover_manager.h" -#ifdef _DEBUG -#include -#endif - const u32 _pmt_psy_attack_delay = 2000; const float _pmt_psy_attack_min_angle = deg(5); @@ -767,7 +763,7 @@ void CController::debug_on_key(int key) { switch (key) { - case DIK_MINUS: + case SDL_SCANCODE_MINUS: // m_sound_aura_left_channel.play_at_pos(Level().CurrentEntity(), Fvector().set(-1.f, 0.f, 1.f), sm_2D); // m_sound_aura_right_channel.play_at_pos(Level().CurrentEntity(), Fvector().set(1.f, 0.f, 1.f), sm_2D); @@ -790,7 +786,7 @@ void CController::debug_on_key(int key) //} break; - case DIK_EQUALS: + case SDL_SCANCODE_EQUALS: P2.set(Actor()->Position()); DBG().level_info(this).remove_item(1); DBG().level_info(this).add_item(P2, 0.5f, COLOR_GREEN, 1); diff --git a/src/xrGame/ai/monsters/dog/dog.cpp b/src/xrGame/ai/monsters/dog/dog.cpp index 1a3d35bfb12..8c87702dd4b 100644 --- a/src/xrGame/ai/monsters/dog/dog.cpp +++ b/src/xrGame/ai/monsters/dog/dog.cpp @@ -16,10 +16,6 @@ #include "xrAICore/Navigation/ai_object_location.h" #include "Actor.h" -#ifdef _DEBUG -#include -#endif - CAI_Dog::CAI_Dog() { StateMan = new CStateManagerDog(this); @@ -430,20 +426,20 @@ void CAI_Dog::debug_on_key(int key) switch (key) { - case DIK_1: + case SDL_SCANCODE_1: Msg("Ohhhhhhhhhhhhhhh! Here it is!"); // strafe left // com_man().seq_run(skel->ID_Cycle_Safe("stand_turn_ls_0")); break; - case DIK_2: + case SDL_SCANCODE_2: // strafe right com_man().seq_run(skel->ID_Cycle_Safe("stand_turn_ls_0")); break; - case DIK_3: + case SDL_SCANCODE_3: // threaten com_man().seq_run(skel->ID_Cycle_Safe("stand_threaten_0")); break; - case DIK_0: Msg("Ohhhhhhhhhhhhhhh! Here it is!"); break; + case SDL_SCANCODE_0: Msg("Ohhhhhhhhhhhhhhh! Here it is!"); break; } } #endif diff --git a/src/xrGame/ai/monsters/pseudodog/pseudodog.cpp b/src/xrGame/ai/monsters/pseudodog/pseudodog.cpp index a75030d3e9b..d21bb1164f4 100644 --- a/src/xrGame/ai/monsters/pseudodog/pseudodog.cpp +++ b/src/xrGame/ai/monsters/pseudodog/pseudodog.cpp @@ -10,7 +10,6 @@ #include "ai/monsters/control_movement_base.h" #ifdef _DEBUG -#include #include "xrAICore/Navigation/ai_object_location.h" #include "level_debug.h" #include "xrAICore/Navigation/level_graph.h" diff --git a/src/xrGame/ai/monsters/snork/snork.cpp b/src/xrGame/ai/monsters/snork/snork.cpp index 4ed98b2b879..a9c2fca0f31 100644 --- a/src/xrGame/ai/monsters/snork/snork.cpp +++ b/src/xrGame/ai/monsters/snork/snork.cpp @@ -10,7 +10,6 @@ #include "ai/monsters/control_movement_base.h" #include "PHMovementControl.h" #ifdef _DEBUG -#include #include "Actor.h" #include "xrAICore/Navigation/ai_object_location.h" #include "level_debug.h" @@ -315,7 +314,7 @@ void CSnork::debug_on_key(int key) switch (key) { - case DIK_1: m_target_node = actor->ai_location().level_vertex_id(); + case SDL_SCANCODE_1: m_target_node = actor->ai_location().level_vertex_id(); } } #endif diff --git a/src/xrGame/ai/monsters/zombie/zombie.cpp b/src/xrGame/ai/monsters/zombie/zombie.cpp index 323a8eaaf32..7e263f2a49d 100644 --- a/src/xrGame/ai/monsters/zombie/zombie.cpp +++ b/src/xrGame/ai/monsters/zombie/zombie.cpp @@ -9,10 +9,6 @@ #include "ai/monsters/control_animation_base.h" #include "ai/monsters/control_movement_base.h" -#ifdef _DEBUG -#include -#endif - CZombie::CZombie() { StateMan = new CStateManagerZombie(this); @@ -229,10 +225,10 @@ void CZombie::debug_on_key(int key) { switch (key) { - case DIK_MINUS: { fake_death_fall_down(); + case SDL_SCANCODE_MINUS: { fake_death_fall_down(); } break; - case DIK_EQUALS: { fake_death_stand_up(); + case SDL_SCANCODE_EQUALS: { fake_death_stand_up(); } break; } diff --git a/src/xrGame/attachable_item.cpp b/src/xrGame/attachable_item.cpp index c1c25755330..edff3556c76 100644 --- a/src/xrGame/attachable_item.cpp +++ b/src/xrGame/attachable_item.cpp @@ -136,15 +136,15 @@ void attach_adjust_mode_keyb(int dik) if (!CAttachableItem::m_dbgItem) return; - bool b_move = !!(pInput->iGetAsyncKeyState(DIK_LSHIFT)); - bool b_rot = !!(pInput->iGetAsyncKeyState(DIK_LMENU)); + bool b_move = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)); + bool b_rot = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)); int axis = -1; - if (pInput->iGetAsyncKeyState(DIK_Z)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_Z)) axis = 0; - else if (pInput->iGetAsyncKeyState(DIK_X)) + else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_X)) axis = 1; - if (pInput->iGetAsyncKeyState(DIK_C)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_C)) axis = 2; if (!b_move && !b_rot) @@ -152,7 +152,7 @@ void attach_adjust_mode_keyb(int dik) switch (dik) { - case DIK_LEFT: + case SDL_SCANCODE_LEFT: { if (b_move) CAttachableItem::mov(axis, ATT_ITEM_MOVE_CURR); @@ -160,7 +160,7 @@ void attach_adjust_mode_keyb(int dik) CAttachableItem::rot(axis, ATT_ITEM_ROT_CURR); } break; - case DIK_RIGHT: + case SDL_SCANCODE_RIGHT: { if (b_move) CAttachableItem::mov(axis, -ATT_ITEM_MOVE_CURR); @@ -168,7 +168,7 @@ void attach_adjust_mode_keyb(int dik) CAttachableItem::rot(axis, -ATT_ITEM_ROT_CURR); } break; - case DIK_PRIOR: + case SDL_SCANCODE_PAGEUP: { if (b_move) ATT_ITEM_MOVE_CURR += ATT_ITEM_MOVE_STEP; @@ -176,7 +176,7 @@ void attach_adjust_mode_keyb(int dik) ATT_ITEM_ROT_CURR += ATT_ITEM_ROT_STEP; } break; - case DIK_NEXT: + case SDL_SCANCODE_PAGEDOWN: { if (b_move) ATT_ITEM_MOVE_CURR -= ATT_ITEM_MOVE_STEP; diff --git a/src/xrGame/game_cl_deathmatch.cpp b/src/xrGame/game_cl_deathmatch.cpp index 9635c90b4db..c9235a54291 100644 --- a/src/xrGame/game_cl_deathmatch.cpp +++ b/src/xrGame/game_cl_deathmatch.cpp @@ -12,7 +12,6 @@ #include "ui/UIMapDesc.h" #include "ui/UIMessageBoxEx.h" #include "ui/UIVote.h" -#include "dinput.h" #include "gamepersistent.h" #include "string_table.h" #include "map_manager.h" diff --git a/src/xrGame/game_cl_mp.cpp b/src/xrGame/game_cl_mp.cpp index 3afd52dba5d..81711d07590 100644 --- a/src/xrGame/game_cl_mp.cpp +++ b/src/xrGame/game_cl_mp.cpp @@ -5,7 +5,6 @@ #include "Actor.h" #include "ExplosiveItem.h" #include "Level.h" -#include #include "CustomZone.h" #include "game_base_kill_type.h" #include "game_base_menu_events.h" 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/key_binding_registrator_script.cpp b/src/xrGame/key_binding_registrator_script.cpp index 73ceb3fa6ef..51b949eb4fa 100644 --- a/src/xrGame/key_binding_registrator_script.cpp +++ b/src/xrGame/key_binding_registrator_script.cpp @@ -1,85 +1,360 @@ #include "pch_script.h" -#include #include "xr_level_controller.h" #include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; static int dik_to_bind(int dik) { return get_binded_action(dik); } -SCRIPT_EXPORT(KeyBindings, (), { - class EnumGameActions - { - }; - class KeyBindingRegistrator - { - }; - module(luaState)[def("dik_to_bind", &dik_to_bind), +SCRIPT_EXPORT(KeyBindings, (), +{ + class EnumGameActions {}; + class KeyBindingRegistrator {}; + + module(luaState) + [ + def("dik_to_bind", &dik_to_bind), class_("key_bindings") - .enum_("commands")[value("kFWD", int(kFWD)), value("kBACK", int(kBACK)), value("kL_STRAFE", int(kL_STRAFE)), - value("kR_STRAFE", int(kR_STRAFE)), value("kL_LOOKOUT", int(kL_LOOKOUT)), - value("kR_LOOKOUT", int(kR_LOOKOUT)), value("kLEFT", int(kLEFT)), value("kRIGHT", int(kRIGHT)), - value("kUP", int(kUP)), value("kDOWN", int(kDOWN)), value("kJUMP", int(kJUMP)), - value("kCROUCH", int(kCROUCH)), value("kACCEL", int(kACCEL)), value("kCAM_1", int(kCAM_1)), - value("kCAM_2", int(kCAM_2)), value("kCAM_3", int(kCAM_3)), value("kCAM_ZOOM_IN", int(kCAM_ZOOM_IN)), - value("kCAM_ZOOM_OUT", int(kCAM_ZOOM_OUT)), value("kTORCH", int(kTORCH)), - value("kNIGHT_VISION", int(kNIGHT_VISION)), value("kWPN_1", int(kWPN_1)), value("kWPN_2", int(kWPN_2)), - value("kWPN_3", int(kWPN_3)), value("kWPN_4", int(kWPN_4)), value("kWPN_5", int(kWPN_5)), - value("kWPN_6", int(kWPN_6)), value("kWPN_NEXT", int(kWPN_NEXT)), value("kWPN_FIRE", int(kWPN_FIRE)), - value("kWPN_RELOAD", int(kWPN_RELOAD)), value("kWPN_ZOOM", int(kWPN_ZOOM)), - value("kWPN_FUNC", int(kWPN_FUNC)), value("kUSE", int(kUSE)), value("kDROP", int(kDROP)), - value("kSCORES", int(kSCORES)), value("kCHAT", int(kCHAT)), value("kSCREENSHOT", int(kSCREENSHOT)), - value("kQUIT", int(kQUIT)), value("kCONSOLE", int(kCONSOLE)), value("kINVENTORY", int(kINVENTORY)), - value("kBUY", int(kBUY)), value("kSKIN", int(kSKIN)), value("kTEAM", int(kTEAM))], + .enum_("commands") + [ + value("kFWD", int(kFWD)), + value("kBACK", int(kBACK)), + value("kL_STRAFE", int(kL_STRAFE)), + value("kR_STRAFE", int(kR_STRAFE)), + value("kL_LOOKOUT", int(kL_LOOKOUT)), + value("kR_LOOKOUT", int(kR_LOOKOUT)), + value("kLEFT", int(kLEFT)), + value("kRIGHT", int(kRIGHT)), + value("kUP", int(kUP)), + value("kDOWN", int(kDOWN)), + value("kJUMP", int(kJUMP)), + value("kCROUCH", int(kCROUCH)), + value("kACCEL", int(kACCEL)), + value("kCAM_1", int(kCAM_1)), + value("kCAM_2", int(kCAM_2)), + value("kCAM_3", int(kCAM_3)), + value("kCAM_ZOOM_IN", int(kCAM_ZOOM_IN)), + value("kCAM_ZOOM_OUT", int(kCAM_ZOOM_OUT)), + value("kTORCH", int(kTORCH)), + value("kNIGHT_VISION", int(kNIGHT_VISION)), + value("kWPN_1", int(kWPN_1)), + value("kWPN_2", int(kWPN_2)), + value("kWPN_3", int(kWPN_3)), + value("kWPN_4", int(kWPN_4)), + value("kWPN_5", int(kWPN_5)), + value("kWPN_6", int(kWPN_6)), + value("kWPN_NEXT", int(kWPN_NEXT)), + value("kWPN_FIRE", int(kWPN_FIRE)), + value("kWPN_RELOAD", int(kWPN_RELOAD)), + value("kWPN_ZOOM", int(kWPN_ZOOM)), + value("kWPN_FUNC", int(kWPN_FUNC)), + value("kUSE", int(kUSE)), + value("kDROP", int(kDROP)), + value("kSCORES", int(kSCORES)), + value("kCHAT", int(kCHAT)), + value("kSCREENSHOT", int(kSCREENSHOT)), + value("kQUIT", int(kQUIT)), + value("kCONSOLE", int(kCONSOLE)), + value("kINVENTORY", int(kINVENTORY)), + value("kBUY", int(kBUY)), + value("kSKIN", int(kSKIN)), + value("kTEAM", int(kTEAM)) + ], + class_("DIK_keys") - .enum_("dik_keys")[value("DIK_ESCAPE", int(DIK_ESCAPE)), value("DIK_2", int(DIK_2)), - value("DIK_4", int(DIK_4)), value("DIK_6", int(DIK_6)), value("DIK_8", int(DIK_8)), - value("DIK_0", int(DIK_0)), value("DIK_EQUALS", int(DIK_EQUALS)), value("DIK_TAB", int(DIK_TAB)), - value("DIK_W", int(DIK_W)), value("DIK_R", int(DIK_R)), value("DIK_Y", int(DIK_Y)), - value("DIK_I", int(DIK_I)), value("DIK_P", int(DIK_P)), value("DIK_RBRACKET", int(DIK_RBRACKET)), - value("DIK_LCONTROL", int(DIK_LCONTROL)), value("DIK_S", int(DIK_S)), value("DIK_F", int(DIK_F)), - value("DIK_H", int(DIK_H)), value("DIK_K", int(DIK_K)), value("DIK_SEMICOLON", int(DIK_SEMICOLON)), - value("DIK_GRAVE", int(DIK_GRAVE)), value("DIK_BACKSLASH", int(DIK_BACKSLASH)), - value("DIK_X", int(DIK_X)), value("DIK_V", int(DIK_V)), value("DIK_N", int(DIK_N)), - value("DIK_COMMA", int(DIK_COMMA)), value("DIK_SLASH", int(DIK_SLASH)), - value("DIK_MULTIPLY", int(DIK_MULTIPLY)), value("DIK_SPACE", int(DIK_SPACE)), - value("DIK_F1", int(DIK_F1)), value("DIK_F3", int(DIK_F3)), value("DIK_F5", int(DIK_F5)), - value("DIK_F7", int(DIK_F7)), value("DIK_F9", int(DIK_F9)), value("DIK_NUMLOCK", int(DIK_NUMLOCK)), - value("DIK_NUMPAD7", int(DIK_NUMPAD7)), value("DIK_NUMPAD9", int(DIK_NUMPAD9)), - value("DIK_NUMPAD4", int(DIK_NUMPAD4)), value("DIK_NUMPAD6", int(DIK_NUMPAD6)), - value("DIK_NUMPAD1", int(DIK_NUMPAD1)), value("DIK_NUMPAD3", int(DIK_NUMPAD3)), - value("DIK_DECIMAL", int(DIK_DECIMAL)), value("DIK_F12", int(DIK_F12)), value("DIK_F14", int(DIK_F14)), - value("DIK_KANA", int(DIK_KANA)), value("DIK_NOCONVERT", int(DIK_NOCONVERT)), - value("DIK_NUMPADEQUALS", int(DIK_NUMPADEQUALS)), value("DIK_AT", int(DIK_AT)), - value("DIK_UNDERLINE", int(DIK_UNDERLINE)), value("DIK_STOP", int(DIK_STOP)), - value("DIK_UNLABELED", int(DIK_UNLABELED)), value("DIK_RCONTROL", int(DIK_RCONTROL)), - value("DIK_DIVIDE", int(DIK_DIVIDE)), value("DIK_RMENU", int(DIK_RMENU)), value("DIK_UP", int(DIK_UP)), - value("DIK_LEFT", int(DIK_LEFT)), value("DIK_END", int(DIK_END)), value("DIK_NEXT", int(DIK_NEXT)), - value("DIK_DELETE", int(DIK_DELETE)), value("DIK_RWIN", int(DIK_RWIN)), - value("DIK_PAUSE", int(DIK_PAUSE)), value("MOUSE_2", int(MOUSE_2)), value("DIK_1", int(DIK_1)), - value("DIK_3", int(DIK_3)), value("DIK_5", int(DIK_5)), value("DIK_7", int(DIK_7)), - value("DIK_9", int(DIK_9)), value("DIK_MINUS", int(DIK_MINUS)), value("DIK_BACK", int(DIK_BACK)), - value("DIK_Q", int(DIK_Q)), value("DIK_E", int(DIK_E)), value("DIK_T", int(DIK_T)), - value("DIK_U", int(DIK_U)), value("DIK_O", int(DIK_O)), value("DIK_LBRACKET", int(DIK_LBRACKET)), - value("DIK_RETURN", int(DIK_RETURN)), value("DIK_A", int(DIK_A)), value("DIK_D", int(DIK_D)), - value("DIK_G", int(DIK_G)), value("DIK_J", int(DIK_J)), value("DIK_L", int(DIK_L)), - value("DIK_APOSTROPHE", int(DIK_APOSTROPHE)), value("DIK_LSHIFT", int(DIK_LSHIFT)), - value("DIK_Z", int(DIK_Z)), value("DIK_C", int(DIK_C)), value("DIK_B", int(DIK_B)), - value("DIK_M", int(DIK_M)), value("DIK_PERIOD", int(DIK_PERIOD)), value("DIK_RSHIFT", int(DIK_RSHIFT)), - value("DIK_LMENU", int(DIK_LMENU)), value("DIK_CAPITAL", int(DIK_CAPITAL)), - value("DIK_F2", int(DIK_F2)), value("DIK_F4", int(DIK_F4)), value("DIK_F6", int(DIK_F6)), - value("DIK_F8", int(DIK_F8)), value("DIK_F10", int(DIK_F10)), value("DIK_SCROLL", int(DIK_SCROLL)), - value("DIK_NUMPAD8", int(DIK_NUMPAD8)), value("DIK_SUBTRACT", int(DIK_SUBTRACT)), - value("DIK_NUMPAD5", int(DIK_NUMPAD5)), value("DIK_ADD", int(DIK_ADD)), - value("DIK_NUMPAD2", int(DIK_NUMPAD2)), value("DIK_NUMPAD0", int(DIK_NUMPAD0)), - value("DIK_F11", int(DIK_F11)), value("DIK_F13", int(DIK_F13)), value("DIK_F15", int(DIK_F15)), - value("DIK_CONVERT", int(DIK_CONVERT)), value("DIK_YEN", int(DIK_YEN)), - value("DIK_CIRCUMFLEX", int(DIK_CIRCUMFLEX)), value("DIK_COLON", int(DIK_COLON)), - value("DIK_KANJI", int(DIK_KANJI)), value("DIK_AX", int(DIK_AX)), - value("DIK_NUMPADENTER", int(DIK_NUMPADENTER)), value("DIK_NUMPADCOMMA", int(DIK_NUMPADCOMMA)), - value("DIK_SYSRQ", int(DIK_SYSRQ)), value("DIK_HOME", int(DIK_HOME)), - value("DIK_PRIOR", int(DIK_PRIOR)), value("DIK_RIGHT", int(DIK_RIGHT)), - value("DIK_DOWN", int(DIK_DOWN)), value("DIK_INSERT", int(DIK_INSERT)), - value("DIK_LWIN", int(DIK_LWIN)), value("DIK_APPS", int(DIK_APPS)), value("MOUSE_1", int(MOUSE_1)), - value("MOUSE_3", int(MOUSE_3)), value("DIK_RETURN", int(DIK_RETURN)), - value("DIK_NUMPADENTER", int(DIK_NUMPADENTER))]]; + .enum_("dik_keys") + [ + value("MOUSE_1", int(MOUSE_1)), + value("MOUSE_2", int(MOUSE_2)), + value("MOUSE_3", int(MOUSE_3)), + value("MOUSE_4", int(MOUSE_4)), + value("MOUSE_5", int(MOUSE_5)), + value("MOUSE_6", int(MOUSE_6)), + value("MOUSE_7", int(MOUSE_7)), + value("MOUSE_8", int(MOUSE_8)), + + value("DIK_UNKNOWN", int(SDL_SCANCODE_UNKNOWN)), + + value("DIK_A", int(SDL_SCANCODE_A)), + value("DIK_B", int(SDL_SCANCODE_B)), + value("DIK_C", int(SDL_SCANCODE_C)), + value("DIK_D", int(SDL_SCANCODE_D)), + value("DIK_E", int(SDL_SCANCODE_E)), + value("DIK_F", int(SDL_SCANCODE_F)), + value("DIK_G", int(SDL_SCANCODE_G)), + value("DIK_H", int(SDL_SCANCODE_H)), + value("DIK_I", int(SDL_SCANCODE_I)), + value("DIK_J", int(SDL_SCANCODE_J)), + value("DIK_K", int(SDL_SCANCODE_K)), + value("DIK_L", int(SDL_SCANCODE_L)), + value("DIK_M", int(SDL_SCANCODE_M)), + value("DIK_N", int(SDL_SCANCODE_N)), + value("DIK_O", int(SDL_SCANCODE_O)), + value("DIK_P", int(SDL_SCANCODE_P)), + value("DIK_Q", int(SDL_SCANCODE_Q)), + value("DIK_R", int(SDL_SCANCODE_R)), + value("DIK_S", int(SDL_SCANCODE_S)), + value("DIK_T", int(SDL_SCANCODE_T)), + value("DIK_U", int(SDL_SCANCODE_U)), + value("DIK_V", int(SDL_SCANCODE_V)), + value("DIK_W", int(SDL_SCANCODE_W)), + value("DIK_X", int(SDL_SCANCODE_X)), + value("DIK_Y", int(SDL_SCANCODE_Y)), + value("DIK_Z", int(SDL_SCANCODE_Z)), + + value("DIK_1", int(SDL_SCANCODE_1)), + value("DIK_2", int(SDL_SCANCODE_2)), + value("DIK_3", int(SDL_SCANCODE_3)), + value("DIK_4", int(SDL_SCANCODE_4)), + value("DIK_5", int(SDL_SCANCODE_5)), + value("DIK_6", int(SDL_SCANCODE_6)), + value("DIK_7", int(SDL_SCANCODE_7)), + value("DIK_8", int(SDL_SCANCODE_8)), + value("DIK_9", int(SDL_SCANCODE_9)), + value("DIK_0", int(SDL_SCANCODE_0)), + + value("DIK_RETURN", int(SDL_SCANCODE_RETURN)), + value("DIK_ESCAPE", int(SDL_SCANCODE_ESCAPE)), + value("DIK_BACK", int(SDL_SCANCODE_BACKSPACE)), + value("DIK_TAB", int(SDL_SCANCODE_TAB)), + value("DIK_SPACE", int(SDL_SCANCODE_SPACE)), + + value("DIK_MINUS", int(SDL_SCANCODE_MINUS)), + value("DIK_EQUALS", int(SDL_SCANCODE_EQUALS)), + value("DIK_LBRACKET", int(SDL_SCANCODE_LEFTBRACKET)), + value("DIK_RBRACKET", int(SDL_SCANCODE_RIGHTBRACKET)), + value("DIK_BACKSLASH", int(SDL_SCANCODE_BACKSLASH)), + value("DIK_NONUSHASH", int(SDL_SCANCODE_NONUSHASH)), + + value("DIK_SEMICOLON", int(SDL_SCANCODE_SEMICOLON)), + value("DIK_APOSTROPHE", int(SDL_SCANCODE_APOSTROPHE)), + value("DIK_GRAVE", int(SDL_SCANCODE_GRAVE)), + value("DIK_COMMA", int(SDL_SCANCODE_COMMA)), + value("DIK_PERIOD", int(SDL_SCANCODE_PERIOD)), + value("DIK_SLASH", int(SDL_SCANCODE_SLASH)), + + value("DIK_CAPITAL", int(SDL_SCANCODE_CAPSLOCK)), + + value("DIK_F1", int(SDL_SCANCODE_F1)), + value("DIK_F2", int(SDL_SCANCODE_F2)), + value("DIK_F3", int(SDL_SCANCODE_F3)), + value("DIK_F4", int(SDL_SCANCODE_F4)), + value("DIK_F5", int(SDL_SCANCODE_F5)), + value("DIK_F6", int(SDL_SCANCODE_F6)), + value("DIK_F7", int(SDL_SCANCODE_F7)), + value("DIK_F8", int(SDL_SCANCODE_F8)), + value("DIK_F9", int(SDL_SCANCODE_F9)), + value("DIK_F10", int(SDL_SCANCODE_F10)), + value("DIK_F11", int(SDL_SCANCODE_F11)), + value("DIK_F12", int(SDL_SCANCODE_F12)), + + value("DIK_PRINTSCREEN", int(SDL_SCANCODE_PRINTSCREEN)), + value("DIK_SCROLL", int(SDL_SCANCODE_SCROLLLOCK)), + value("DIK_PAUSE", int(SDL_SCANCODE_PAUSE)), + value("DIK_INSERT", int(SDL_SCANCODE_INSERT)), + + value("DIK_HOME", int(SDL_SCANCODE_HOME)), + value("DIK_PGDN", int(SDL_SCANCODE_PAGEUP)), + value("DIK_DELETE", int(SDL_SCANCODE_DELETE)), + value("DIK_END", int(SDL_SCANCODE_END)), + value("DIK_PGUP", int(SDL_SCANCODE_PAGEDOWN)), + + value("DIK_RIGHT", int(SDL_SCANCODE_RIGHT)), + value("DIK_LEFT", int(SDL_SCANCODE_LEFT)), + value("DIK_DOWN", int(SDL_SCANCODE_DOWN)), + value("DIK_UP", int(SDL_SCANCODE_UP)), + + value("DIK_NUMLOCK", int(SDL_SCANCODE_NUMLOCKCLEAR)), + + value("DIK_DIVIDE", int(SDL_SCANCODE_KP_DIVIDE)), + value("DIK_MULTIPLY", int(SDL_SCANCODE_KP_MULTIPLY)), + value("DIK_SUBTRACT", int(SDL_SCANCODE_KP_MINUS)), + value("DIK_ADD", int(SDL_SCANCODE_KP_PLUS)), + value("DIK_NUMPADENTER", int(SDL_SCANCODE_KP_ENTER)), + + value("DIK_NUMPAD1", int(SDL_SCANCODE_KP_1)), + value("DIK_NUMPAD2", int(SDL_SCANCODE_KP_2)), + value("DIK_NUMPAD3", int(SDL_SCANCODE_KP_3)), + value("DIK_NUMPAD4", int(SDL_SCANCODE_KP_4)), + value("DIK_NUMPAD5", int(SDL_SCANCODE_KP_5)), + value("DIK_NUMPAD6", int(SDL_SCANCODE_KP_6)), + value("DIK_NUMPAD7", int(SDL_SCANCODE_KP_7)), + value("DIK_NUMPAD8", int(SDL_SCANCODE_KP_8)), + value("DIK_NUMPAD9", int(SDL_SCANCODE_KP_9)), + value("DIK_NUMPAD0", int(SDL_SCANCODE_KP_0)), + + value("DIK_NUMPADPERIOD", int(SDL_SCANCODE_KP_PERIOD)), + value("DIK_NONUSBACKSLASH", int(SDL_SCANCODE_NONUSBACKSLASH)), + value("DIK_APPLICATION", int(SDL_SCANCODE_APPLICATION)), + value("DIK_POWER", int(SDL_SCANCODE_POWER)), + value("DIK_NUMPADEQUALS", int(SDL_SCANCODE_KP_EQUALS)), + + value("DIK_F13", int(SDL_SCANCODE_F13)), + value("DIK_F14", int(SDL_SCANCODE_F14)), + value("DIK_F15", int(SDL_SCANCODE_F15)), + value("DIK_F16", int(SDL_SCANCODE_F16)), + value("DIK_F17", int(SDL_SCANCODE_F17)), + value("DIK_F18", int(SDL_SCANCODE_F18)), + value("DIK_F19", int(SDL_SCANCODE_F19)), + value("DIK_F20", int(SDL_SCANCODE_F20)), + value("DIK_F21", int(SDL_SCANCODE_F21)), + value("DIK_F22", int(SDL_SCANCODE_F22)), + value("DIK_F23", int(SDL_SCANCODE_F23)), + value("DIK_F24", int(SDL_SCANCODE_F24)), + + value("DIK_EXECUTE", int(SDL_SCANCODE_EXECUTE)), + value("DIK_HELP", int(SDL_SCANCODE_HELP)), + value("DIK_MENU", int(SDL_SCANCODE_MENU)), + + value("DIK_SELECT", int(SDL_SCANCODE_SELECT)), + value("DIK_STOP", int(SDL_SCANCODE_STOP)), + + value("DIK_REDO", int(SDL_SCANCODE_AGAIN)), + value("DIK_UNDO", int(SDL_SCANCODE_UNDO)), + + value("DIK_CUT", int(SDL_SCANCODE_CUT)), + value("DIK_COPY", int(SDL_SCANCODE_COPY)), + value("DIK_PASTE", int(SDL_SCANCODE_PASTE)), + + value("DIK_FIND", int(SDL_SCANCODE_FIND)), + + value("DIK_MUTE", int(SDL_SCANCODE_MUTE)), + value("DIK_VOLUMEUP", int(SDL_SCANCODE_VOLUMEUP)), + value("DIK_VOLUMEDOWN", int(SDL_SCANCODE_VOLUMEDOWN)), + + value("DIK_NUMPADCOMMA", int(SDL_SCANCODE_KP_COMMA)), + value("DIK_NUMPADEQUALSAS400", int(SDL_SCANCODE_KP_EQUALSAS400)), + + value("DIK_INTERNATIONAL1", int(SDL_SCANCODE_INTERNATIONAL1)), // Give a better name? + value("DIK_INTERNATIONAL2", int(SDL_SCANCODE_INTERNATIONAL2)), // Give a better name? + value("DIK_YEN", int(SDL_SCANCODE_INTERNATIONAL3)), + value("DIK_INTERNATIONAL4", int(SDL_SCANCODE_INTERNATIONAL4)), // Give a better name? + value("DIK_INTERNATIONAL5", int(SDL_SCANCODE_INTERNATIONAL5)), // Give a better name? + value("DIK_INTERNATIONAL6", int(SDL_SCANCODE_INTERNATIONAL6)), // Give a better name? + value("DIK_INTERNATIONAL7", int(SDL_SCANCODE_INTERNATIONAL7)), // Give a better name? + value("DIK_INTERNATIONAL8", int(SDL_SCANCODE_INTERNATIONAL8)), // Give a better name? + value("DIK_INTERNATIONAL9", int(SDL_SCANCODE_INTERNATIONAL9)), // Give a better name? + + value("DIK_HANGUL", int(SDL_SCANCODE_LANG1)), + value("DIK_HANJA", int(SDL_SCANCODE_LANG2)), + value("DIK_KATAKANA", int(SDL_SCANCODE_LANG3)), + value("DIK_HIRAGANA", int(SDL_SCANCODE_LANG4)), + value("DIK_ZENHANKAKU", int(SDL_SCANCODE_LANG5)), + value("DIK_LANG6", int(SDL_SCANCODE_LANG6)), // Give a better name? + value("DIK_LANG7", int(SDL_SCANCODE_LANG7)), // Give a better name? + value("DIK_LANG8", int(SDL_SCANCODE_LANG8)), // Give a better name? + value("DIK_LANG9", int(SDL_SCANCODE_LANG9)), // Give a better name? + + value("DIK_ALTERASE", int(SDL_SCANCODE_ALTERASE)), + value("DIK_CANCEL", int(SDL_SCANCODE_CANCEL)), + value("DIK_CLEAR", int(SDL_SCANCODE_CLEAR)), + value("DIK_PRIOR", int(SDL_SCANCODE_PRIOR)), + value("DIK_RETURN2", int(SDL_SCANCODE_RETURN2)), + value("DIK_SEPARATOR", int(SDL_SCANCODE_SEPARATOR)), + value("DIK_OUT", int(SDL_SCANCODE_OUT)), + value("DIK_OPER", int(SDL_SCANCODE_OPER)), + value("DIK_CLEARAGAIN", int(SDL_SCANCODE_CLEARAGAIN)), + value("DIK_CRSEL", int(SDL_SCANCODE_CRSEL)), + value("DIK_EXSEL", int(SDL_SCANCODE_EXSEL)), + + value("DIK_NUMPAD_00", int(SDL_SCANCODE_KP_00)), + value("DIK_NUMPAD_000", int(SDL_SCANCODE_KP_000)), + value("DIK_THOUSANDSSEPARATOR", int(SDL_SCANCODE_THOUSANDSSEPARATOR)), + value("DIK_DECIMALSEPARATOR", int(SDL_SCANCODE_DECIMALSEPARATOR)), + value("DIK_CURRENCYUNIT", int(SDL_SCANCODE_CURRENCYUNIT)), + value("DIK_CURRENCYSUBUNIT", int(SDL_SCANCODE_CURRENCYSUBUNIT)), + value("DIK_NUMPAD_LEFTPAREN", int(SDL_SCANCODE_KP_LEFTPAREN)), + value("DIK_NUMPAD_RIGHTPAREN", int(SDL_SCANCODE_KP_RIGHTPAREN)), + value("DIK_NUMPAD_LEFTBRACE", int(SDL_SCANCODE_KP_LEFTBRACE)), + value("DIK_NUMPAD_RIGHTBRACE", int(SDL_SCANCODE_KP_RIGHTBRACE)), + value("DIK_NUMPAD_TAB", int(SDL_SCANCODE_KP_TAB)), + value("DIK_NUMPAD_BACKSPACE", int(SDL_SCANCODE_KP_BACKSPACE)), + value("DIK_NUMPAD_A", int(SDL_SCANCODE_KP_A)), + value("DIK_NUMPAD_B", int(SDL_SCANCODE_KP_B)), + value("DIK_NUMPAD_C", int(SDL_SCANCODE_KP_C)), + value("DIK_NUMPAD_D", int(SDL_SCANCODE_KP_D)), + value("DIK_NUMPAD_E", int(SDL_SCANCODE_KP_E)), + value("DIK_NUMPAD_F", int(SDL_SCANCODE_KP_F)), + + value("DIK_NUMPAD_XOR", int(SDL_SCANCODE_KP_XOR)), + + value("DIK_NUMPAD_POWER", int(SDL_SCANCODE_KP_POWER)), + value("DIK_NUMPAD_PERCENT", int(SDL_SCANCODE_KP_PERCENT)), + + value("DIK_NUMPAD_LESS", int(SDL_SCANCODE_KP_LESS)), + value("DIK_NUMPAD_GREATER", int(SDL_SCANCODE_KP_GREATER)), + + value("DIK_NUMPAD_AMPERSAND", int(SDL_SCANCODE_KP_AMPERSAND)), + value("DIK_NUMPAD_DBLAMPERSAND", int(SDL_SCANCODE_KP_DBLAMPERSAND)), + + value("DIK_NUMPAD_VERTICALBAR", int(SDL_SCANCODE_KP_VERTICALBAR)), + value("DIK_NUMPAD_DBLVERTICALBAR", int(SDL_SCANCODE_KP_DBLVERTICALBAR)), + + value("DIK_NUMPAD_COLON", int(SDL_SCANCODE_KP_COLON)), + value("DIK_NUMPAD_HASH", int(SDL_SCANCODE_KP_HASH)), + value("DIK_NUMPAD_SPACE", int(SDL_SCANCODE_KP_SPACE)), + value("DIK_NUMPAD_AT", int(SDL_SCANCODE_KP_AT)), + value("DIK_NUMPAD_EXCLAM", int(SDL_SCANCODE_KP_EXCLAM)), + + value("DIK_NUMPAD_MEMSTORE", int(SDL_SCANCODE_KP_MEMSTORE)), + value("DIK_NUMPAD_MEMRECALL", int(SDL_SCANCODE_KP_MEMRECALL)), + value("DIK_NUMPAD_MEMCLEAR", int(SDL_SCANCODE_KP_MEMCLEAR)), + value("DIK_NUMPAD_MEMADD", int(SDL_SCANCODE_KP_MEMADD)), + value("DIK_NUMPAD_MEMSUBTRACT", int(SDL_SCANCODE_KP_MEMSUBTRACT)), + value("DIK_NUMPAD_MEMMULTIPLY", int(SDL_SCANCODE_KP_MEMMULTIPLY)), + value("DIK_NUMPAD_MEMDIVIDE", int(SDL_SCANCODE_KP_MEMDIVIDE)), + + value("DIK_NUMPAD_PLUSMINUS", int(SDL_SCANCODE_KP_PLUSMINUS)), + value("DIK_NUMPAD_CLEAR", int(SDL_SCANCODE_KP_CLEAR)), + value("DIK_NUMPAD_CLEARENTRY", int(SDL_SCANCODE_KP_CLEARENTRY)), + value("DIK_NUMPAD_BINARY", int(SDL_SCANCODE_KP_BINARY)), + value("DIK_NUMPAD_OCTAL", int(SDL_SCANCODE_KP_OCTAL)), + value("DIK_NUMPAD_DECIMAL", int(SDL_SCANCODE_KP_DECIMAL)), + value("DIK_NUMPAD_HEXADECIMAL", int(SDL_SCANCODE_KP_HEXADECIMAL)), + + value("DIK_LCONTROL", int(SDL_SCANCODE_LCTRL)), + value("DIK_LSHIFT", int(SDL_SCANCODE_LSHIFT)), + value("DIK_LMENU", int(SDL_SCANCODE_LALT)), + value("DIK_LWIN", int(SDL_SCANCODE_LGUI)), + value("DIK_RCONTROL", int(SDL_SCANCODE_RCTRL)), + value("DIK_RSHIFT", int(SDL_SCANCODE_RSHIFT)), + value("DIK_RMENU", int(SDL_SCANCODE_RALT)), + value("DIK_RWIN", int(SDL_SCANCODE_RGUI)), + + value("DIK_MODE", int(SDL_SCANCODE_MODE)), + + value("DIK_AUDIONEXT", int(SDL_SCANCODE_AUDIONEXT)), + value("DIK_AUDIOPREV", int(SDL_SCANCODE_AUDIOPREV)), + value("DIK_AUDIOSTOP", int(SDL_SCANCODE_AUDIOSTOP)), + value("DIK_AUDIOPLAY", int(SDL_SCANCODE_AUDIOPLAY)), + value("DIK_AUDIOMUTE", int(SDL_SCANCODE_AUDIOMUTE)), + + value("DIK_NUMPAD_MEDIASELECT", int(SDL_SCANCODE_MEDIASELECT)), + value("DIK_NUMPAD_WWW", int(SDL_SCANCODE_WWW)), + value("DIK_NUMPAD_MAIL", int(SDL_SCANCODE_MAIL)), + value("DIK_NUMPAD_CALCULATOR", int(SDL_SCANCODE_CALCULATOR)), + value("DIK_NUMPAD_COMPUTER", int(SDL_SCANCODE_COMPUTER)), + + value("DIK_NUMPAD_AC_SEARCH", int(SDL_SCANCODE_AC_SEARCH)), + value("DIK_NUMPAD_AC_HOME", int(SDL_SCANCODE_AC_HOME)), + value("DIK_NUMPAD_AC_BACK", int(SDL_SCANCODE_AC_BACK)), + value("DIK_NUMPAD_AC_FORWARD", int(SDL_SCANCODE_AC_FORWARD)), + value("DIK_NUMPAD_AC_STOP", int(SDL_SCANCODE_AC_STOP)), + value("DIK_NUMPAD_AC_REFRESH", int(SDL_SCANCODE_AC_REFRESH)), + value("DIK_NUMPAD_AC_BOOKMARKS", int(SDL_SCANCODE_AC_BOOKMARKS)), + + value("DIK_BRIGHTNESSDOWN", int(SDL_SCANCODE_BRIGHTNESSDOWN)), + value("DIK_BRIGHTNESSUP", int(SDL_SCANCODE_BRIGHTNESSUP)), + value("DIK_DISPLAYSWITCH", int(SDL_SCANCODE_DISPLAYSWITCH)), + + value("DIK_KBDILLUMTOGGLE)", int(SDL_SCANCODE_KBDILLUMTOGGLE)), + value("DIK_KBDILLUMDOWN", int(SDL_SCANCODE_KBDILLUMDOWN)), + value("DIK_KBDILLUMUP", int(SDL_SCANCODE_KBDILLUMUP)), + + value("DIK_EJECT", int(SDL_SCANCODE_EJECT)), + value("DIK_SLEEP", int(SDL_SCANCODE_SLEEP)), + + value("DIK_APP1", int(SDL_SCANCODE_APP1)), + value("DIK_APP2", int(SDL_SCANCODE_APP2)) + ] + ]; }); 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/player_hud_tune.cpp b/src/xrGame/player_hud_tune.cpp index 6131a3837db..898b99c558f 100644 --- a/src/xrGame/player_hud_tune.cpp +++ b/src/xrGame/player_hud_tune.cpp @@ -21,29 +21,29 @@ float _delta_rot = 0.05f; bool is_attachable_item_tuning_mode() { - return pInput->iGetAsyncKeyState(DIK_LSHIFT) || pInput->iGetAsyncKeyState(DIK_Z) || - pInput->iGetAsyncKeyState(DIK_X) || pInput->iGetAsyncKeyState(DIK_C); + return pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_Z) || + pInput->iGetAsyncKeyState(SDL_SCANCODE_X) || pInput->iGetAsyncKeyState(SDL_SCANCODE_C); } void tune_remap(const Ivector& in_values, Ivector& out_values) { - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { out_values = in_values; } - else if (pInput->iGetAsyncKeyState(DIK_Z)) + else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_Z)) { // strict by X out_values.x = in_values.y; out_values.y = 0; out_values.z = 0; } - else if (pInput->iGetAsyncKeyState(DIK_X)) + else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_X)) { // strict by Y out_values.x = 0; out_values.y = in_values.y; out_values.z = 0; } - else if (pInput->iGetAsyncKeyState(DIK_C)) + else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_C)) { // strict by Z out_values.x = 0; out_values.y = 0; @@ -314,7 +314,7 @@ void hud_draw_adjust_mode() return; LPCSTR _text = NULL; - if (pInput->iGetAsyncKeyState(DIK_LSHIFT) && hud_adj_mode) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT) && hud_adj_mode) _text = "press SHIFT+NUM 0-return 1-hud_pos 2-hud_rot 3-itm_pos 4-itm_rot 5-fire_point 6-fire_2_point " "7-shell_point " @@ -347,34 +347,34 @@ void hud_draw_adjust_mode() void hud_adjust_mode_keyb(int dik) { - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { - if (dik == DIK_NUMPAD0) + if (dik == SDL_SCANCODE_KP_0) hud_adj_mode = 0; - if (dik == DIK_NUMPAD1) + if (dik == SDL_SCANCODE_KP_1) hud_adj_mode = 1; - if (dik == DIK_NUMPAD2) + if (dik == SDL_SCANCODE_KP_2) hud_adj_mode = 2; - if (dik == DIK_NUMPAD3) + if (dik == SDL_SCANCODE_KP_3) hud_adj_mode = 3; - if (dik == DIK_NUMPAD4) + if (dik == SDL_SCANCODE_KP_4) hud_adj_mode = 4; - if (dik == DIK_NUMPAD5) + if (dik == SDL_SCANCODE_KP_5) hud_adj_mode = 5; - if (dik == DIK_NUMPAD6) + if (dik == SDL_SCANCODE_KP_6) hud_adj_mode = 6; - if (dik == DIK_NUMPAD7) + if (dik == SDL_SCANCODE_KP_7) hud_adj_mode = 7; - if (dik == DIK_NUMPAD8) + if (dik == SDL_SCANCODE_KP_8) hud_adj_mode = 8; - if (dik == DIK_NUMPAD9) + if (dik == SDL_SCANCODE_KP_9) hud_adj_mode = 9; } - if (pInput->iGetAsyncKeyState(DIK_LCONTROL)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL)) { - if (dik == DIK_NUMPAD0) + if (dik == SDL_SCANCODE_KP_0) hud_adj_item_idx = 0; - if (dik == DIK_NUMPAD1) + if (dik == SDL_SCANCODE_KP_1) hud_adj_item_idx = 1; } } diff --git a/src/xrGame/ui/ChangeWeatherDialog.cpp b/src/xrGame/ui/ChangeWeatherDialog.cpp index d9d55665bf2..44e7f824ebc 100644 --- a/src/xrGame/ui/ChangeWeatherDialog.cpp +++ b/src/xrGame/ui/ChangeWeatherDialog.cpp @@ -5,7 +5,6 @@ #include "game_cl_teamdeathmatch.h" #include "UIKickPlayer.h" #include "UIChangeMap.h" -#include #include "xrEngine/XR_IOConsole.h" #include "UIMapList.h" #include "UIGameCustom.h" @@ -46,15 +45,15 @@ bool ButtonListDialog::OnKeyboardAction(int dik, EUIMessages keyboardAction) CUIDialogWnd::OnKeyboardAction(dik, keyboardAction); if (WINDOW_KEY_PRESSED == keyboardAction) { - if (DIK_ESCAPE == dik) + if (SDL_SCANCODE_ESCAPE == dik) { OnCancel(); return true; } int btnCount = buttons.size(); - if (dik >= DIK_1 && dik <= DIK_1 - 1 + btnCount && btnCount <= 9) // handle 1..9 keys only + if (dik >= SDL_SCANCODE_1 && dik <= SDL_SCANCODE_1 - 1 + btnCount && btnCount <= 9) // handle 1..9 keys only { - OnButtonClick(dik - DIK_1); + OnButtonClick(dik - SDL_SCANCODE_1); return true; } } diff --git a/src/xrGame/ui/UIButton.h b/src/xrGame/ui/UIButton.h index 8179b9efb66..4694b661890 100644 --- a/src/xrGame/ui/UIButton.h +++ b/src/xrGame/ui/UIButton.h @@ -39,8 +39,8 @@ class CUIButton : public CUIStatic // Поведение кнопки как переключателя реализовано пока только в режиме NORMAL_PRESS void SetButtonAsSwitch(bool bAsSwitch) { m_bIsSwitch = bAsSwitch; } // Работа с акселератором - // Код акселератора берется из файла dinput.h, из DirectX SDK. - // Например: кнопка A - код 0x1E(DIK_A) + // Код акселератора берётся из файла SDL_scancode.h, из SDL2. + // Например: кнопка A - код 4 (SDL_SCANCODE_A) void SetAccelerator(int iAccel, int idx); const int GetAccelerator(int idx) const; bool IsAccelerator(int iAccel) const; diff --git a/src/xrGame/ui/UICDkey.cpp b/src/xrGame/ui/UICDkey.cpp index eb07a8517fa..1cbbf599610 100644 --- a/src/xrGame/ui/UICDkey.cpp +++ b/src/xrGame/ui/UICDkey.cpp @@ -8,7 +8,6 @@ #include "xrGameSpy/xrGameSpy_MainDefs.h" #include "player_name_modifyer.h" #include "xrGameSpy/GameSpy_GP.h" -#include #include "xrCore/os_clipboard.h" string64 gsCDKey = ""; @@ -24,9 +23,10 @@ CUICDkey::CUICDkey() void CUICDkey::assign_callbacks() { - m_editor_control->assign_callback(DIK_V, text_editor::ks_Ctrl, Callback(this, &CUICDkey::paste_from_clipboard)); m_editor_control->assign_callback( - DIK_INSERT, text_editor::ks_Shift, Callback(this, &CUICDkey::paste_from_clipboard)); + SDL_SCANCODE_V, text_editor::ks_Ctrl, Callback(this, &CUICDkey::paste_from_clipboard)); + m_editor_control->assign_callback( + SDL_SCANCODE_INSERT, text_editor::ks_Shift, Callback(this, &CUICDkey::paste_from_clipboard)); } struct inappropriate_characters diff --git a/src/xrGame/ui/UIChangeMap.cpp b/src/xrGame/ui/UIChangeMap.cpp index 80637bb631c..5efae44013c 100644 --- a/src/xrGame/ui/UIChangeMap.cpp +++ b/src/xrGame/ui/UIChangeMap.cpp @@ -77,10 +77,9 @@ void CUIChangeMap::InitChangeMap(CUIXml& xml_doc) FillUpList(); } -#include bool CUIChangeMap::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - if (dik == DIK_ESCAPE) + if (dik == SDL_SCANCODE_ESCAPE) { OnBtnCancel(); return true; diff --git a/src/xrGame/ui/UICustomEdit.cpp b/src/xrGame/ui/UICustomEdit.cpp index a5ab9752795..6008c24a73e 100644 --- a/src/xrGame/ui/UICustomEdit.cpp +++ b/src/xrGame/ui/UICustomEdit.cpp @@ -40,11 +40,11 @@ text_editor::line_edit_control const& CUICustomEdit::ec() const void CUICustomEdit::Register_callbacks() { - ec().assign_callback(DIK_ESCAPE, text_editor::ks_free, Callback(this, &CUICustomEdit::press_escape)); - ec().assign_callback(DIK_RETURN, text_editor::ks_free, Callback(this, &CUICustomEdit::press_commit)); - ec().assign_callback(DIK_NUMPADENTER, text_editor::ks_free, Callback(this, &CUICustomEdit::press_commit)); - ec().assign_callback(DIK_GRAVE, text_editor::ks_free, Callback(this, &CUICustomEdit::nothing)); - ec().assign_callback(DIK_TAB, text_editor::ks_free, Callback(this, &CUICustomEdit::press_tab)); + ec().assign_callback(SDL_SCANCODE_ESCAPE, text_editor::ks_free, Callback(this, &CUICustomEdit::press_escape)); + ec().assign_callback(SDL_SCANCODE_RETURN, text_editor::ks_free, Callback(this, &CUICustomEdit::press_commit)); + ec().assign_callback(SDL_SCANCODE_KP_ENTER, text_editor::ks_free, Callback(this, &CUICustomEdit::press_commit)); + ec().assign_callback(SDL_SCANCODE_GRAVE, text_editor::ks_free, Callback(this, &CUICustomEdit::nothing)); + ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_free, Callback(this, &CUICustomEdit::press_tab)); } void CUICustomEdit::Init(u32 max_char_count, bool number_only_mode, bool read_mode, bool fn_mode) diff --git a/src/xrGame/ui/UIDebugFonts.cpp b/src/xrGame/ui/UIDebugFonts.cpp index 1a872c8b506..fe3c357c1f0 100644 --- a/src/xrGame/ui/UIDebugFonts.cpp +++ b/src/xrGame/ui/UIDebugFonts.cpp @@ -1,7 +1,6 @@ #include "StdAfx.h" #include "UIDebugFonts.h" #include "UIDialogHolder.h" -#include "dinput.h" CUIDebugFonts::CUIDebugFonts() { @@ -22,10 +21,10 @@ void CUIDebugFonts::InitDebugFonts(Frect r) bool CUIDebugFonts::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - if (DIK_ESCAPE == dik) + if (SDL_SCANCODE_ESCAPE == dik) HideDialog(); - if (DIK_F12 == dik) + if (SDL_SCANCODE_F12 == dik) return false; return true; diff --git a/src/xrGame/ui/UIDemoPlayControl.cpp b/src/xrGame/ui/UIDemoPlayControl.cpp index 6bebf943165..30f7ecf6710 100644 --- a/src/xrGame/ui/UIDemoPlayControl.cpp +++ b/src/xrGame/ui/UIDemoPlayControl.cpp @@ -5,7 +5,6 @@ #include "UIPropertiesBox.h" #include "UIListBox.h" #include "UIListBoxItem.h" -#include #include "UIDemoPlayControl.h" #include "UICursor.h" #include "xrEngine/XR_IOConsole.h" @@ -175,7 +174,7 @@ void CUIDemoPlayControl::InitAllPlayers() bool CUIDemoPlayControl::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - if ((dik == DIK_LCONTROL) && (keyboard_action == WINDOW_KEY_RELEASED)) + if ((dik == SDL_SCANCODE_LCTRL) && (keyboard_action == WINDOW_KEY_RELEASED)) { m_last_curr_pos = GetUICursor().GetCursorPosition(); m_rewind_type->Hide(); diff --git a/src/xrGame/ui/UIEditBox.cpp b/src/xrGame/ui/UIEditBox.cpp index 95884e85dbe..82a3c9f0d01 100644 --- a/src/xrGame/ui/UIEditBox.cpp +++ b/src/xrGame/ui/UIEditBox.cpp @@ -3,7 +3,6 @@ ////////////////////////////////////////////////////////////////////// #include "stdafx.h" -#include #include "uieditbox.h" #include "UIFrameLineWnd.h" diff --git a/src/xrGame/ui/UIGameTutorial.cpp b/src/xrGame/ui/UIGameTutorial.cpp index 3eddc63d94e..b3aa13265c2 100644 --- a/src/xrGame/ui/UIGameTutorial.cpp +++ b/src/xrGame/ui/UIGameTutorial.cpp @@ -387,10 +387,10 @@ void CUISequencer::IR_OnKeyboardHold(int dik) m_pStoredInputReceiver->IR_OnKeyboardHold(dik); } -void CUISequencer::IR_OnMouseWheel(int direction) +void CUISequencer::IR_OnMouseWheel(int x, int y) { if (!GrabInput() && m_pStoredInputReceiver) - m_pStoredInputReceiver->IR_OnMouseWheel(direction); + m_pStoredInputReceiver->IR_OnMouseWheel(x, y); } void CUISequencer::IR_OnKeyboardPress(int dik) @@ -453,7 +453,9 @@ void CUISequencer::IR_OnActivate() case kACCEL: case kL_LOOKOUT: case kR_LOOKOUT: - case kWPN_FIRE: { IR_OnKeyboardPress(i); + case kWPN_FIRE: + { + IR_OnKeyboardPress(i); } break; }; diff --git a/src/xrGame/ui/UIGameTutorial.h b/src/xrGame/ui/UIGameTutorial.h index 740c16143de..d0bb13f0f70 100644 --- a/src/xrGame/ui/UIGameTutorial.h +++ b/src/xrGame/ui/UIGameTutorial.h @@ -47,7 +47,7 @@ class CUISequencer : public pureFrame, public pureRender, public IInputReceiver virtual void IR_OnKeyboardRelease(int dik); virtual void IR_OnKeyboardHold(int dik); - virtual void IR_OnMouseWheel(int direction); + virtual void IR_OnMouseWheel(int x, int y); virtual void IR_OnActivate(void); bool Persistent() { return !!m_flags.test(etsPersistent); } fastdelegate::FastDelegate0<> m_on_destroy_event; diff --git a/src/xrGame/ui/UIKickPlayer.cpp b/src/xrGame/ui/UIKickPlayer.cpp index c6a5ae15c70..fb079561ef9 100644 --- a/src/xrGame/ui/UIKickPlayer.cpp +++ b/src/xrGame/ui/UIKickPlayer.cpp @@ -83,10 +83,9 @@ void CUIKickPlayer::InitKick(CUIXml& xml_doc) m_ban_sec_label->Show(false); } -#include bool CUIKickPlayer::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - if (dik == DIK_ESCAPE) + if (dik == SDL_SCANCODE_ESCAPE) { OnBtnCancel(); return true; diff --git a/src/xrGame/ui/UILogsWnd.cpp b/src/xrGame/ui/UILogsWnd.cpp index a67d143fc79..dc8884e459c 100644 --- a/src/xrGame/ui/UILogsWnd.cpp +++ b/src/xrGame/ui/UILogsWnd.cpp @@ -309,17 +309,17 @@ bool CUILogsWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) { switch (dik) { - case DIK_UP: - case DIK_DOWN: - case DIK_PRIOR: - case DIK_NEXT: + case SDL_SCANCODE_UP: + case SDL_SCANCODE_DOWN: + case SDL_SCANCODE_PAGEUP: + case SDL_SCANCODE_PAGEDOWN: { on_scroll_keys(dik); return true; } break; - case DIK_RCONTROL: - case DIK_LCONTROL: + case SDL_SCANCODE_RCTRL: + case SDL_SCANCODE_LCTRL: { m_ctrl_press = true; return true; @@ -335,10 +335,10 @@ bool CUILogsWnd::OnKeyboardHold(int dik) { switch (dik) { - case DIK_UP: - case DIK_DOWN: - case DIK_PRIOR: - case DIK_NEXT: + case SDL_SCANCODE_UP: + case SDL_SCANCODE_DOWN: + case SDL_SCANCODE_PAGEUP: + case SDL_SCANCODE_PAGEDOWN: { on_scroll_keys(dik); return true; @@ -354,7 +354,7 @@ void CUILogsWnd::on_scroll_keys(int dik) switch (dik) { - case DIK_UP: + case SDL_SCANCODE_UP: { int orig = m_list->ScrollBar()->GetStepSize(); m_list->ScrollBar()->SetStepSize(1); @@ -362,7 +362,7 @@ void CUILogsWnd::on_scroll_keys(int dik) m_list->ScrollBar()->SetStepSize(orig); break; } - case DIK_DOWN: + case SDL_SCANCODE_DOWN: { int orig = m_list->ScrollBar()->GetStepSize(); m_list->ScrollBar()->SetStepSize(1); @@ -370,7 +370,7 @@ void CUILogsWnd::on_scroll_keys(int dik) m_list->ScrollBar()->SetStepSize(orig); break; } - case DIK_PRIOR: + case SDL_SCANCODE_PAGEUP: { if (m_ctrl_press) { @@ -380,7 +380,7 @@ void CUILogsWnd::on_scroll_keys(int dik) m_list->ScrollBar()->TryScrollDec(); break; } - case DIK_NEXT: + case SDL_SCANCODE_PAGEDOWN: { if (m_ctrl_press) { diff --git a/src/xrGame/ui/UIMMShniaga.cpp b/src/xrGame/ui/UIMMShniaga.cpp index c2f24d477fe..0aef3bed277 100644 --- a/src/xrGame/ui/UIMMShniaga.cpp +++ b/src/xrGame/ui/UIMMShniaga.cpp @@ -337,24 +337,22 @@ void CUIMMShniaga::OnBtnClick() GetMessageTarget()->SendMessage(m_selected, BUTTON_CLICKED); } -#include - bool CUIMMShniaga::OnKeyboardAction(int dik, EUIMessages keyboard_action) { if (WINDOW_KEY_PRESSED == keyboard_action) { switch (dik) { - case DIK_UP: + case SDL_SCANCODE_UP: if (m_selected_btn > 0) SelectBtn(m_selected_btn - 1); return true; - case DIK_DOWN: + case SDL_SCANCODE_DOWN: if (m_selected_btn < BtnCount() - 1) SelectBtn(m_selected_btn + 1); return true; - case DIK_RETURN: OnBtnClick(); return true; - case DIK_ESCAPE: + case SDL_SCANCODE_RETURN: OnBtnClick(); return true; + case SDL_SCANCODE_ESCAPE: if (m_page != epi_main) ShowMain(); return true; diff --git a/src/xrGame/ui/UIMPAdminMenu.cpp b/src/xrGame/ui/UIMPAdminMenu.cpp index 2804f1aedf0..980d1f95577 100644 --- a/src/xrGame/ui/UIMPAdminMenu.cpp +++ b/src/xrGame/ui/UIMPAdminMenu.cpp @@ -11,7 +11,6 @@ #include "UIMessageBox.h" #include "UIMessageBoxEx.h" #include "xrEngine/xr_ioconsole.h" -#include CUIMpAdminMenu::CUIMpAdminMenu() { @@ -102,7 +101,7 @@ void CUIMpAdminMenu::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) } bool CUIMpAdminMenu::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - if (dik == DIK_ESCAPE && keyboard_action == WINDOW_KEY_PRESSED) + if (dik == SDL_SCANCODE_ESCAPE && keyboard_action == WINDOW_KEY_PRESSED) { if (m_pActiveDialog == m_pServerAdm && m_pServerAdm->IsBackBtnShown()) m_pServerAdm->OnBackBtn(); diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp index 192f05f0eb9..73e647ceeac 100644 --- a/src/xrGame/ui/UIMainIngameWnd.cpp +++ b/src/xrGame/ui/UIMainIngameWnd.cpp @@ -2,7 +2,6 @@ #include "UIMainIngameWnd.h" #include "UIMessagesWindow.h" #include "UIZoneMap.h" -#include #include "Actor.h" #include "ActorCondition.h" #include "EntityCondition.h" diff --git a/src/xrGame/ui/UIMapDesc.cpp b/src/xrGame/ui/UIMapDesc.cpp index 17579e6e381..56f298095af 100644 --- a/src/xrGame/ui/UIMapDesc.cpp +++ b/src/xrGame/ui/UIMapDesc.cpp @@ -10,7 +10,6 @@ #include "game_cl_teamdeathmatch.h" #include "UIMapInfo.h" #include "xr_level_controller.h" -#include #include "UIStatsPlayerList.h" CUIMapDesc::CUIMapDesc() @@ -116,7 +115,7 @@ bool CUIMapDesc::OnKeyboardAction(int dik, EUIMessages keyboard_action) { if (WINDOW_KEY_RELEASED == keyboard_action) { - if (dik == DIK_TAB) + if (dik == SDL_SCANCODE_TAB) { ShowChildren(true); game_cl_mp* game = smart_cast(&Game()); @@ -127,7 +126,7 @@ bool CUIMapDesc::OnKeyboardAction(int dik, EUIMessages keyboard_action) return false; } - if (dik == DIK_TAB) + if (dik == SDL_SCANCODE_TAB) { ShowChildren(false); game_cl_mp* game = smart_cast(&Game()); @@ -140,13 +139,13 @@ bool CUIMapDesc::OnKeyboardAction(int dik, EUIMessages keyboard_action) switch (dik) { - case DIK_ESCAPE: + case SDL_SCANCODE_ESCAPE: HideDialog(); dm->OnSpectatorSelect(); return true; break; - case DIK_SPACE: - case DIK_RETURN: + case SDL_SCANCODE_SPACE: + case SDL_SCANCODE_RETURN: HideDialog(); dm->OnMapInfoAccept(); return true; diff --git a/src/xrGame/ui/UIMapWnd.cpp b/src/xrGame/ui/UIMapWnd.cpp index c9b6dd1c737..7408c19cdf6 100644 --- a/src/xrGame/ui/UIMapWnd.cpp +++ b/src/xrGame/ui/UIMapWnd.cpp @@ -364,21 +364,21 @@ bool CUIMapWnd::OnKeyboardHold(int dik) { switch (dik) { - case DIK_UP: - case DIK_DOWN: - case DIK_LEFT: - case DIK_RIGHT: + case SDL_SCANCODE_UP: + case SDL_SCANCODE_DOWN: + case SDL_SCANCODE_LEFT: + case SDL_SCANCODE_RIGHT: { Fvector2 pos_delta; pos_delta.set(0.0f, 0.0f); - if (dik == DIK_UP) + if (dik == SDL_SCANCODE_UP) pos_delta.y += m_map_move_step; - if (dik == DIK_DOWN) + if (dik == SDL_SCANCODE_DOWN) pos_delta.y -= m_map_move_step; - if (dik == DIK_LEFT) + if (dik == SDL_SCANCODE_LEFT) pos_delta.x += m_map_move_step; - if (dik == DIK_RIGHT) + if (dik == SDL_SCANCODE_RIGHT) pos_delta.x -= m_map_move_step; MoveMap(pos_delta); return true; @@ -392,7 +392,7 @@ bool CUIMapWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) { switch (dik) { - case DIK_NUMPADMINUS: + case SDL_SCANCODE_KP_MINUS: { // SetZoom(GetZoom()/1.5f); UpdateZoom(false); @@ -400,7 +400,7 @@ bool CUIMapWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) return true; } break; - case DIK_NUMPADPLUS: + case SDL_SCANCODE_KP_PLUS: { // SetZoom(GetZoom()*1.5f); UpdateZoom(true); diff --git a/src/xrGame/ui/UIMessageBoxEx.cpp b/src/xrGame/ui/UIMessageBoxEx.cpp index a2e139dfec7..8f2a26dfc87 100644 --- a/src/xrGame/ui/UIMessageBoxEx.cpp +++ b/src/xrGame/ui/UIMessageBoxEx.cpp @@ -2,7 +2,6 @@ #include "UIMessageBox.h" #include "UIMessageBoxEx.h" #include "UIDialogHolder.h" -#include CUIMessageBoxEx::CUIMessageBoxEx() { @@ -76,13 +75,13 @@ bool CUIMessageBoxEx::OnKeyboardAction(int dik, EUIMessages keyboard_action) { if (keyboard_action == WINDOW_KEY_PRESSED) { - if (dik == DIK_NUMPADENTER || dik == DIK_RETURN || dik == DIK_SPACE) + if (dik == SDL_SCANCODE_KP_ENTER || dik == SDL_SCANCODE_RETURN || dik == SDL_SCANCODE_SPACE) { m_pMessageBox->OnYesOk(); return true; /* }else - if ( dik == DIK_ESCAPE ) + if ( dik == SDL_SCANCODE_ESCAPE ) { CUIMessageBox::E_MESSAGEBOX_STYLE style = m_pMessageBox->GetBoxStyle(); if(style != CUIMessageBox::MESSAGEBOX_INFO) diff --git a/src/xrGame/ui/UIMessages.h b/src/xrGame/ui/UIMessages.h index 66f80cece85..f2b5287c4d9 100644 --- a/src/xrGame/ui/UIMessages.h +++ b/src/xrGame/ui/UIMessages.h @@ -16,6 +16,8 @@ enum EUIMessages WINDOW_MOUSE_MOVE, WINDOW_MOUSE_WHEEL_UP, WINDOW_MOUSE_WHEEL_DOWN, + WINDOW_MOUSE_WHEEL_LEFT, + WINDOW_MOUSE_WHEEL_RIGHT, WINDOW_LBUTTON_DB_CLICK, WINDOW_KEY_PRESSED, WINDOW_KEY_RELEASED, diff --git a/src/xrGame/ui/UIMpTradeWnd.cpp b/src/xrGame/ui/UIMpTradeWnd.cpp index 920500c2d87..40ee200ed59 100644 --- a/src/xrGame/ui/UIMpTradeWnd.cpp +++ b/src/xrGame/ui/UIMpTradeWnd.cpp @@ -51,7 +51,7 @@ void CUIMpTradeWnd::TryUsePreset(ETradePreset idx) void CUIMpTradeWnd::OnBtnPreset1Clicked(CUIWindow* w, void* d) { CheckDragItemToDestroy(); - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { DumpPreset(_preset_idx_1); return; @@ -63,7 +63,7 @@ void CUIMpTradeWnd::OnBtnPreset1Clicked(CUIWindow* w, void* d) void CUIMpTradeWnd::OnBtnPreset2Clicked(CUIWindow* w, void* d) { CheckDragItemToDestroy(); - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { DumpPreset(_preset_idx_2); return; @@ -74,7 +74,7 @@ void CUIMpTradeWnd::OnBtnPreset2Clicked(CUIWindow* w, void* d) void CUIMpTradeWnd::OnBtnPreset3Clicked(CUIWindow* w, void* d) { CheckDragItemToDestroy(); - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { DumpPreset(_preset_idx_3); return; @@ -86,7 +86,7 @@ void CUIMpTradeWnd::OnBtnPreset3Clicked(CUIWindow* w, void* d) void CUIMpTradeWnd::OnBtnLastSetClicked(CUIWindow* w, void* d) { CheckDragItemToDestroy(); - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { DumpPreset(_preset_idx_last); return; @@ -98,7 +98,7 @@ void xr_stdcall CUIMpTradeWnd::OnBtnPresetDefaultClicked(CUIWindow* w, void* d) { CheckDragItemToDestroy(); { - if (pInput->iGetAsyncKeyState(DIK_LSHIFT)) + if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) { DumpPreset(_preset_idx_default); return; diff --git a/src/xrGame/ui/UIMpTradeWnd_items.cpp b/src/xrGame/ui/UIMpTradeWnd_items.cpp index f0c9ea4429b..6bba4e8402a 100644 --- a/src/xrGame/ui/UIMpTradeWnd_items.cpp +++ b/src/xrGame/ui/UIMpTradeWnd_items.cpp @@ -852,8 +852,6 @@ void CUIMpTradeWnd::DumpPreset(ETradePreset idx) #endif // #ifndef MASTER_GOLD } -#include - void CUICellItemTradeMenuDraw::OnDraw(CUICellItem* cell) { Fvector2 pos; @@ -867,7 +865,7 @@ void CUICellItemTradeMenuDraw::OnDraw(CUICellItem* cell) acc = 1; string64 buff; - xr_sprintf(buff, " %d", acc - DIK_ESCAPE); + xr_sprintf(buff, " %d", acc - SDL_SCANCODE_ESCAPE); CGameFont* pFont = UI().Font().pFontLetterica16Russian; pFont->SetAligment(CGameFont::alCenter); pFont->SetColor(color_rgba(135, 123, 116, 255)); diff --git a/src/xrGame/ui/UIMpTradeWnd_misc.cpp b/src/xrGame/ui/UIMpTradeWnd_misc.cpp index 7e3ac8084f2..02fe96f09f0 100644 --- a/src/xrGame/ui/UIMpTradeWnd_misc.cpp +++ b/src/xrGame/ui/UIMpTradeWnd_misc.cpp @@ -9,19 +9,18 @@ #include "inventory_item.h" #include "PhysicsShellHolder.h" #include "Common/object_broker.h" -#include #include "UICellCustomItems.h" bool CUIMpTradeWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) { #ifdef DEBUG // for debug only - if (keyboard_action == WINDOW_KEY_PRESSED && dik == DIK_NUMPAD7) + if (keyboard_action == WINDOW_KEY_PRESSED && dik == SDL_SCANCODE_KP_7) { if (GetRank() > 0) SetRank(clampr(u32(GetRank() - 1), u32(0), u32(4))); } - if (keyboard_action == WINDOW_KEY_PRESSED && dik == DIK_NUMPAD8) + if (keyboard_action == WINDOW_KEY_PRESSED && dik == SDL_SCANCODE_KP_8) { SetRank(clampr(u32(GetRank() + 1), u32(0), u32(4))); } @@ -37,21 +36,21 @@ bool CUIMpTradeWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) if (keyboard_action == WINDOW_KEY_PRESSED) { - if (dik == DIK_Q) + if (dik == SDL_SCANCODE_Q) { OnBtnPistolAmmoClicked(NULL, NULL); } - else if (dik == DIK_W) + else if (dik == SDL_SCANCODE_W) { OnBtnRifleAmmoClicked(NULL, NULL); } - else if (dik == DIK_E) + else if (dik == SDL_SCANCODE_E) { OnBtnRifleAmmo2Clicked(NULL, NULL); } } - if (keyboard_action == WINDOW_KEY_PRESSED && dik == DIK_NUMPADPLUS) + if (keyboard_action == WINDOW_KEY_PRESSED && dik == SDL_SCANCODE_KP_PLUS) { return true; } diff --git a/src/xrGame/ui/UIMpTradeWnd_trade.cpp b/src/xrGame/ui/UIMpTradeWnd_trade.cpp index 674aaf09776..b957c51c215 100644 --- a/src/xrGame/ui/UIMpTradeWnd_trade.cpp +++ b/src/xrGame/ui/UIMpTradeWnd_trade.cpp @@ -5,7 +5,6 @@ #include "UICellItem.h" #include "UIDragDropListEx.h" #include "UICellCustomItems.h" -#include #include "game_cl_deathmatch.h" #include "game_cl_capture_the_artefact.h" @@ -54,7 +53,7 @@ bool CUIMpTradeWnd::TryToSellItem(SBuyItemInfo* sell_itm, bool do_destroy, SBuyI _new_owner->SetItem(iinfo->m_cell_item); int accel_idx = m_store_hierarchy->CurrentLevel().GetItemIdx(iinfo->m_name_sect); VERIFY(accel_idx != -1); - iinfo->m_cell_item->SetAccelerator((accel_idx > 10) ? 0 : DIK_1 + accel_idx); + iinfo->m_cell_item->SetAccelerator((accel_idx > 10) ? 0 : SDL_SCANCODE_1 + accel_idx); iinfo->m_cell_item->SetCustomDraw(new CUICellItemTradeMenuDraw(this, iinfo)); } } @@ -272,7 +271,7 @@ void CUIMpTradeWnd::RenewShopItem(const shared_str& sect_name, bool b_just_bough if (pitem->m_cell_item->OwnerList() != pList) { int accel_idx = m_store_hierarchy->CurrentLevel().GetItemIdx(sect_name); - pitem->m_cell_item->SetAccelerator((accel_idx > 9) ? 0 : DIK_1 + accel_idx); + pitem->m_cell_item->SetAccelerator((accel_idx > 9) ? 0 : SDL_SCANCODE_1 + accel_idx); pitem->m_cell_item->SetCustomDraw(new CUICellItemTradeMenuDraw(this, pitem)); pList->SetItem(pitem->m_cell_item); diff --git a/src/xrGame/ui/UIMpTradeWnd_wpn.cpp b/src/xrGame/ui/UIMpTradeWnd_wpn.cpp index 0224294ab4a..a42d4d0eb0c 100644 --- a/src/xrGame/ui/UIMpTradeWnd_wpn.cpp +++ b/src/xrGame/ui/UIMpTradeWnd_wpn.cpp @@ -18,7 +18,7 @@ void CUIMpTradeWnd::OnBtnPistolAmmoClicked(CUIWindow* w, void* d) CWeapon* wpn = smart_cast(ii); R_ASSERT(wpn); - u32 ammo_idx = (pInput->iGetAsyncKeyState(DIK_LSHIFT)) ? 1 : 0; + u32 ammo_idx = (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) ? 1 : 0; if (wpn->m_ammoTypes.size() < ammo_idx + 1) return; @@ -72,7 +72,7 @@ void CUIMpTradeWnd::OnBtnRifleAmmoClicked(CUIWindow* w, void* d) CWeapon* wpn = smart_cast(ii); R_ASSERT(wpn); - u32 ammo_idx = (pInput->iGetAsyncKeyState(DIK_LSHIFT)) ? 1 : 0; + u32 ammo_idx = (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) ? 1 : 0; if (wpn->m_ammoTypes.size() < ammo_idx + 1) return; diff --git a/src/xrGame/ui/UIServerInfo.cpp b/src/xrGame/ui/UIServerInfo.cpp index 627e522f983..e7901d494fa 100644 --- a/src/xrGame/ui/UIServerInfo.cpp +++ b/src/xrGame/ui/UIServerInfo.cpp @@ -8,7 +8,6 @@ #include "UIGameCustom.h" #include "Level.h" #include "game_cl_mp.h" -#include #include "ximage.h" #include "xmemfile.h" @@ -159,8 +158,8 @@ bool CUIServerInfo::OnKeyboardAction(int dik, EUIMessages keyboard_action) { switch (dik) { - case DIK_SPACE: - case DIK_RETURN: + case SDL_SCANCODE_SPACE: + case SDL_SCANCODE_RETURN: { OnNextBtnClick(NULL, 0); return true; diff --git a/src/xrGame/ui/UISkinSelector.cpp b/src/xrGame/ui/UISkinSelector.cpp index 983f0a7d3bd..fa6d1ce64b4 100644 --- a/src/xrGame/ui/UISkinSelector.cpp +++ b/src/xrGame/ui/UISkinSelector.cpp @@ -1,5 +1,4 @@ #include "StdAfx.h" -#include #include "UISkinSelector.h" #include "UIXmlInit.h" #include "UIAnimatedStatic.h" @@ -234,7 +233,7 @@ bool CUISkinSelectorWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) { if (WINDOW_KEY_PRESSED != keyboard_action) { - if (dik == DIK_TAB) + if (dik == SDL_SCANCODE_TAB) { ShowChildren(true); game_cl_mp* game = smart_cast(&Game()); @@ -245,7 +244,7 @@ bool CUISkinSelectorWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) return false; } - if (dik == DIK_TAB) + if (dik == SDL_SCANCODE_TAB) { ShowChildren(false); game_cl_mp* game = smart_cast(&Game()); @@ -258,9 +257,9 @@ bool CUISkinSelectorWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) if (right_border > 9) right_border = 9; - if (dik >= DIK_1 && dik < (int)right_border + DIK_1) + if (dik >= SDL_SCANCODE_1 && dik < (int)right_border + SDL_SCANCODE_1) { - int NewIndex = dik - DIK_1; + int NewIndex = dik - SDL_SCANCODE_1; // Msg("Selected %d", NewIndex); // for (u32 i=0; i #include "UISpawnWnd.h" #include "UIXmlInit.h" #include "Level.h" @@ -119,7 +118,7 @@ bool CUISpawnWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) { if (WINDOW_KEY_PRESSED != keyboard_action) { - if (dik == DIK_TAB) + if (dik == SDL_SCANCODE_TAB) { ShowChildren(true); game_cl_mp* game = smart_cast(&Game()); @@ -129,7 +128,7 @@ bool CUISpawnWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) return false; } - if (dik == DIK_TAB) + if (dik == SDL_SCANCODE_TAB) { ShowChildren(false); game_cl_mp* game = smart_cast(&Game()); @@ -142,11 +141,11 @@ bool CUISpawnWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) VERIFY(game); // game_cl_TeamDeathmatch * dm = smart_cast(&(Game())); - if (DIK_1 == dik || DIK_2 == dik) + if (SDL_SCANCODE_1 == dik || SDL_SCANCODE_2 == dik) { HideDialog(); - if (DIK_1 == dik) + if (SDL_SCANCODE_1 == dik) game->OnTeamSelect(0); else game->OnTeamSelect(1); @@ -154,15 +153,15 @@ bool CUISpawnWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action) } switch (dik) { - case DIK_ESCAPE: + case SDL_SCANCODE_ESCAPE: HideDialog(); game->OnTeamMenuBack(); return true; - case DIK_SPACE: + case SDL_SCANCODE_SPACE: HideDialog(); game->OnTeamSelect(-1); return true; - case DIK_RETURN: + case SDL_SCANCODE_RETURN: HideDialog(); if (m_pImage1->GetSelectedState()) game->OnTeamSelect(0); diff --git a/src/xrGame/ui/UISpeechMenu.cpp b/src/xrGame/ui/UISpeechMenu.cpp index 5a25b59f447..d8e8c168341 100644 --- a/src/xrGame/ui/UISpeechMenu.cpp +++ b/src/xrGame/ui/UISpeechMenu.cpp @@ -5,7 +5,6 @@ #include "UIGameCustom.h" #include "UIXmlInit.h" #include "game_cl_mp.h" -#include #include "Level.h" #include "string_table.h" @@ -57,13 +56,13 @@ void CUISpeechMenu::InitList(LPCSTR section_name) bool CUISpeechMenu::OnKeyboardAction(int dik, EUIMessages keyboard_action) { - if (dik < DIK_1 || dik > DIK_0) + if (dik < SDL_SCANCODE_1 || dik > SDL_SCANCODE_0) return CUIDialogWnd::OnKeyboardAction(dik, keyboard_action); game_cl_mp* game = smart_cast(&Game()); HideDialog(); - game->OnMessageSelected(this, static_cast(dik - DIK_1)); + game->OnMessageSelected(this, static_cast(dik - SDL_SCANCODE_1)); return true; } diff --git a/src/xrGame/ui/UITalkDialogWnd.cpp b/src/xrGame/ui/UITalkDialogWnd.cpp index e023b5d35b7..8f0936f707e 100644 --- a/src/xrGame/ui/UITalkDialogWnd.cpp +++ b/src/xrGame/ui/UITalkDialogWnd.cpp @@ -13,7 +13,6 @@ #include "Level.h" #include "Actor.h" #include "alife_registry_wrappers.h" -#include "dinput.h" #define TALK_XML "talk.xml" @@ -160,7 +159,7 @@ void CUITalkDialogWnd::AddQuestion(LPCSTR str, LPCSTR value, int number, bool b_ string16 buff; xr_sprintf(buff, "%d.", (number == 10) ? 0 : number); itm->m_num_text->SetText(buff); - itm->m_text->SetAccelerator(DIK_ESCAPE + number, 0); + itm->m_text->SetAccelerator(SDL_SCANCODE_1 - 1 + number, 0); } if (b_finalizer) { diff --git a/src/xrGame/ui/UIVotingCategory.cpp b/src/xrGame/ui/UIVotingCategory.cpp index 60129bfa5d5..bade4638313 100644 --- a/src/xrGame/ui/UIVotingCategory.cpp +++ b/src/xrGame/ui/UIVotingCategory.cpp @@ -91,21 +91,19 @@ void CUIVotingCategory::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) } } -#include - bool CUIVotingCategory::OnKeyboardAction(int dik, EUIMessages keyboard_action) { CUIDialogWnd::OnKeyboardAction(dik, keyboard_action); if (WINDOW_KEY_PRESSED == keyboard_action) { - if (DIK_ESCAPE == dik) + if (SDL_SCANCODE_ESCAPE == dik) { OnBtnCancel(); return true; } - if (dik >= DIK_1 && dik <= DIK_7) - OnBtn(dik - DIK_1); + if (dik >= SDL_SCANCODE_1 && dik <= SDL_SCANCODE_7) + OnBtn(dik - SDL_SCANCODE_1); return true; } return false; diff --git a/src/xrGame/ui/UIWindow.cpp b/src/xrGame/ui/UIWindow.cpp index 1876b1ea049..70671283282 100644 --- a/src/xrGame/ui/UIWindow.cpp +++ b/src/xrGame/ui/UIWindow.cpp @@ -305,6 +305,8 @@ bool CUIWindow::OnMouseAction(float x, float y, EUIMessages mouse_action) case WINDOW_MOUSE_MOVE: OnMouseMove(); break; case WINDOW_MOUSE_WHEEL_DOWN: OnMouseScroll(WINDOW_MOUSE_WHEEL_DOWN); break; case WINDOW_MOUSE_WHEEL_UP: OnMouseScroll(WINDOW_MOUSE_WHEEL_UP); break; + case WINDOW_MOUSE_WHEEL_LEFT: OnMouseScroll(WINDOW_MOUSE_WHEEL_LEFT); break; + case WINDOW_MOUSE_WHEEL_RIGHT: OnMouseScroll(WINDOW_MOUSE_WHEEL_RIGHT); break; case WINDOW_LBUTTON_DOWN: if (OnMouseDown(MOUSE_1)) return true; diff --git a/src/xrGame/ui/UIXmlInit.cpp b/src/xrGame/ui/UIXmlInit.cpp index 82580974ed5..c92051f691e 100644 --- a/src/xrGame/ui/UIXmlInit.cpp +++ b/src/xrGame/ui/UIXmlInit.cpp @@ -347,7 +347,6 @@ bool CUIXmlInit::InitText(CUIXml& xml_doc, LPCSTR path, int index, CUILines* pLi return true; } //////////////////////////////////////////////////////////////////////////////////////////// -extern int keyname_to_dik(LPCSTR); bool CUIXmlInit::Init3tButton(CUIXml& xml_doc, LPCSTR path, int index, CUI3tButton* pWnd) { 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..1d6a31ea8f8 100644 --- a/src/xrGame/xr_level_controller.cpp +++ b/src/xrGame/xr_level_controller.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "xrEngine/xr_ioconsole.h" #include "xrEngine/xr_input.h" #include "xrEngine/xr_ioc_cmd.h" @@ -9,72 +8,387 @@ _binding g_key_bindings[bindings_count]; _key_group g_current_keygroup = _sp; -_action actions[] = {{"left", kLEFT, _both}, {"right", kRIGHT, _both}, {"up", kUP, _both}, {"down", kDOWN, _both}, - {"jump", kJUMP, _both}, {"crouch", kCROUCH, _both}, {"accel", kACCEL, _both}, - {"sprint_toggle", kSPRINT_TOGGLE, _both}, - - {"forward", kFWD, _both}, {"back", kBACK, _both}, {"lstrafe", kL_STRAFE, _both}, {"rstrafe", kR_STRAFE, _both}, - - {"llookout", kL_LOOKOUT, _both}, {"rlookout", kR_LOOKOUT, _both}, - - {"cam_1", kCAM_1, _both}, {"cam_2", kCAM_2, _both}, {"cam_3", kCAM_3, _both}, {"cam_zoom_in", kCAM_ZOOM_IN, _both}, - {"cam_zoom_out", kCAM_ZOOM_OUT, _both}, - - {"torch", kTORCH, _both}, {"night_vision", kNIGHT_VISION, _both}, {"show_detector", kDETECTOR, _sp}, - - {"wpn_1", kWPN_1, _both}, {"wpn_2", kWPN_2, _both}, {"wpn_3", kWPN_3, _both}, {"wpn_4", kWPN_4, _both}, - {"wpn_5", kWPN_5, _both}, {"wpn_6", kWPN_6, _both}, {"artefact", kARTEFACT, _both /*_mp*/}, - {"wpn_next", kWPN_NEXT, _both}, // means next ammo type - {"wpn_fire", kWPN_FIRE, _both}, {"wpn_zoom", kWPN_ZOOM, _both}, {"wpn_zoom_inc", kWPN_ZOOM_INC, _both}, - {"wpn_zoom_dec", kWPN_ZOOM_DEC, _both}, {"wpn_reload", kWPN_RELOAD, _both}, {"wpn_func", kWPN_FUNC, _both}, - {"wpn_firemode_prev", kWPN_FIREMODE_PREV, _both}, {"wpn_firemode_next", kWPN_FIREMODE_NEXT, _both}, - - {"pause", kPAUSE, _both}, {"drop", kDROP, _both}, {"use", kUSE, _both}, {"scores", kSCORES, _both}, - {"chat", kCHAT, _mp}, {"chat_team", kCHAT_TEAM, _mp}, {"screenshot", kSCREENSHOT, _both}, {"quit", kQUIT, _both}, - {"console", kCONSOLE, _both}, {"inventory", kINVENTORY, _both}, {"buy_menu", kBUY, _mp}, {"skin_menu", kSKIN, _mp}, - {"team_menu", kTEAM, _mp}, {"active_jobs", kACTIVE_JOBS, _sp}, - - {"vote_begin", kVOTE_BEGIN, _mp}, {"show_admin_menu", kSHOW_ADMIN_MENU, _mp}, {"vote", kVOTE, _mp}, - {"vote_yes", kVOTEYES, _mp}, {"vote_no", kVOTENO, _mp}, - - {"next_slot", kNEXT_SLOT, _both}, {"prev_slot", kPREV_SLOT, _both}, - - {"speech_menu_0", kSPEECH_MENU_0, _mp}, {"speech_menu_1", kSPEECH_MENU_1, _mp}, - - {"quick_use_1", kQUICK_USE_1, _both}, {"quick_use_2", kQUICK_USE_2, _both}, {"quick_use_3", kQUICK_USE_3, _both}, - {"quick_use_4", kQUICK_USE_4, _both}, - - {"quick_save", kQUICK_SAVE, _sp}, {"quick_load", kQUICK_LOAD, _sp}, - // { "alife_command", kALIFE_CMD ,_sp}, - - {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}}; +_action actions[] = +{ + { "left", kLEFT, _both }, + { "right", kRIGHT, _both }, + { "up", kUP, _both }, + { "down", kDOWN, _both }, + { "jump", kJUMP, _both }, + { "crouch", kCROUCH, _both }, + { "accel", kACCEL, _both }, + { "sprint_toggle", kSPRINT_TOGGLE, _both }, + + { "forward", kFWD, _both }, + { "back", kBACK, _both }, + { "lstrafe", kL_STRAFE, _both }, + { "rstrafe", kR_STRAFE, _both }, + + { "llookout", kL_LOOKOUT, _both }, + { "rlookout", kR_LOOKOUT, _both }, + + { "cam_1", kCAM_1, _both }, + { "cam_2", kCAM_2, _both }, + { "cam_3", kCAM_3, _both }, + { "cam_zoom_in", kCAM_ZOOM_IN, _both }, + { "cam_zoom_out", kCAM_ZOOM_OUT, _both }, + + { "torch", kTORCH, _both }, + { "night_vision", kNIGHT_VISION, _both }, + { "show_detector", kDETECTOR, _sp }, + + { "wpn_1", kWPN_1, _both }, + { "wpn_2", kWPN_2, _both }, + { "wpn_3", kWPN_3, _both }, + { "wpn_4", kWPN_4, _both }, + { "wpn_5", kWPN_5, _both }, + { "wpn_6", kWPN_6, _both }, + { "artefact", kARTEFACT, _both /*_mp*/ }, + { "wpn_next", kWPN_NEXT, _both }, // means next ammo type + { "wpn_fire", kWPN_FIRE, _both }, + { "wpn_zoom", kWPN_ZOOM, _both }, + { "wpn_zoom_inc", kWPN_ZOOM_INC, _both }, + { "wpn_zoom_dec", kWPN_ZOOM_DEC, _both }, + { "wpn_reload", kWPN_RELOAD, _both }, + { "wpn_func", kWPN_FUNC, _both }, + { "wpn_firemode_prev", kWPN_FIREMODE_PREV, _both }, + { "wpn_firemode_next", kWPN_FIREMODE_NEXT, _both }, + + { "pause", kPAUSE, _both }, + { "drop", kDROP, _both }, + { "use", kUSE, _both }, + { "scores", kSCORES, _both }, + { "chat", kCHAT, _mp }, + { "chat_team", kCHAT_TEAM, _mp }, + { "screenshot", kSCREENSHOT, _both }, + { "quit", kQUIT, _both }, + { "console", kCONSOLE, _both }, + { "inventory", kINVENTORY, _both }, + { "buy_menu", kBUY, _mp }, + { "skin_menu", kSKIN, _mp }, + { "team_menu", kTEAM, _mp }, + { "active_jobs", kACTIVE_JOBS, _sp }, + + { "vote_begin", kVOTE_BEGIN, _mp }, + { "show_admin_menu", kSHOW_ADMIN_MENU, _mp }, + { "vote", kVOTE, _mp }, + { "vote_yes", kVOTEYES, _mp }, + { "vote_no", kVOTENO, _mp }, + + { "next_slot", kNEXT_SLOT, _both }, + { "prev_slot", kPREV_SLOT, _both }, + + { "speech_menu_0", kSPEECH_MENU_0, _mp }, + { "speech_menu_1", kSPEECH_MENU_1, _mp }, + + { "quick_use_1", kQUICK_USE_1, _both }, + { "quick_use_2", kQUICK_USE_2, _both }, + { "quick_use_3", kQUICK_USE_3, _both }, + { "quick_use_4", kQUICK_USE_4, _both }, + + { "quick_save", kQUICK_SAVE, _sp }, + { "quick_load", kQUICK_LOAD, _sp }, + //{ "alife_command", kALIFE_CMD, _sp }, + + { nullptr, kLASTACTION, _both } +}; + +_keyboard keyboards[] = +{ + { "mouse1", MOUSE_1, "Mouse 1" }, + { "mouse2", MOUSE_2, "Mouse 2" }, + { "mouse3", MOUSE_3, "Mouse 3" }, + { "mouse4", MOUSE_4, "Mouse 4" }, + { "mouse5", MOUSE_5, "Mouse 5" }, + { "mouse6", MOUSE_6, "Mouse 6" }, + { "mouse7", MOUSE_7, "Mouse 7" }, + { "mouse8", MOUSE_8, "Mouse 8" }, + + { "kUNKNOWN", SDL_SCANCODE_UNKNOWN, "Unknown" }, + + { "kA", SDL_SCANCODE_A, "A" }, + { "kB", SDL_SCANCODE_B, "B" }, + { "kC", SDL_SCANCODE_C, "C" }, + { "kD", SDL_SCANCODE_D, "D" }, + { "kE", SDL_SCANCODE_E, "E" }, + { "kF", SDL_SCANCODE_F, "F" }, + { "kG", SDL_SCANCODE_G, "G" }, + { "kH", SDL_SCANCODE_H, "H" }, + { "kI", SDL_SCANCODE_I, "I" }, + { "kJ", SDL_SCANCODE_J, "J" }, + { "kK", SDL_SCANCODE_K, "K" }, + { "kL", SDL_SCANCODE_L, "L" }, + { "kM", SDL_SCANCODE_M, "M" }, + { "kN", SDL_SCANCODE_N, "N" }, + { "kO", SDL_SCANCODE_O, "O" }, + { "kP", SDL_SCANCODE_P, "P" }, + { "kQ", SDL_SCANCODE_Q, "Q" }, + { "kR", SDL_SCANCODE_R, "R" }, + { "kS", SDL_SCANCODE_S, "S" }, + { "kT", SDL_SCANCODE_T, "T" }, + { "kU", SDL_SCANCODE_U, "U" }, + { "kV", SDL_SCANCODE_V, "V" }, + { "kW", SDL_SCANCODE_W, "W" }, + { "kX", SDL_SCANCODE_X, "X" }, + { "kY", SDL_SCANCODE_Y, "Y" }, + { "kZ", SDL_SCANCODE_Z, "Z" }, + + { "k1", SDL_SCANCODE_1, "1" }, + { "k2", SDL_SCANCODE_2, "2" }, + { "k3", SDL_SCANCODE_3, "3" }, + { "k4", SDL_SCANCODE_4, "4" }, + { "k5", SDL_SCANCODE_5, "5" }, + { "k6", SDL_SCANCODE_6, "6" }, + { "k7", SDL_SCANCODE_7, "7" }, + { "k8", SDL_SCANCODE_8, "8" }, + { "k9", SDL_SCANCODE_9, "9" }, + { "k0", SDL_SCANCODE_0, "0" }, + + { "kRETURN", SDL_SCANCODE_RETURN, "Return" }, + { "kESCAPE", SDL_SCANCODE_ESCAPE, "Escape" }, + { "kBACK", SDL_SCANCODE_BACKSPACE, "Backspace" }, + { "kTAB", SDL_SCANCODE_TAB, "Tab" }, + { "kSPACE", SDL_SCANCODE_SPACE, "Space" }, + + { "kMINUS", SDL_SCANCODE_MINUS, "Minus" }, + { "kEQUALS", SDL_SCANCODE_EQUALS, "Equals" }, + { "kLBRACKET", SDL_SCANCODE_LEFTBRACKET, "Left bracket" }, + { "kRBRACKET", SDL_SCANCODE_RIGHTBRACKET, "Right bracket" }, + { "kBACKSLASH", SDL_SCANCODE_BACKSLASH, "Backslash" }, + { "kNONUSHASH", SDL_SCANCODE_NONUSHASH, "Non US Hash" }, + + { "kSEMICOLON", SDL_SCANCODE_SEMICOLON, "Semicolon" }, + { "kAPOSTROPHE", SDL_SCANCODE_APOSTROPHE, "Apostrophe" }, + { "kGRAVE", SDL_SCANCODE_GRAVE, "Grave" }, + { "kCOMMA", SDL_SCANCODE_COMMA, "Comma" }, + { "kPERIOD", SDL_SCANCODE_PERIOD, "Period" }, + { "kSLASH", SDL_SCANCODE_SLASH, "Slash" }, + + { "kCAPITAL", SDL_SCANCODE_CAPSLOCK, "Caps Lock" }, + + { "kF1", SDL_SCANCODE_F1, "F1" }, + { "kF2", SDL_SCANCODE_F2, "F2" }, + { "kF3", SDL_SCANCODE_F3, "F3" }, + { "kF4", SDL_SCANCODE_F4, "F4" }, + { "kF5", SDL_SCANCODE_F5, "F5" }, + { "kF6", SDL_SCANCODE_F6, "F6" }, + { "kF7", SDL_SCANCODE_F7, "F7" }, + { "kF8", SDL_SCANCODE_F8, "F8" }, + { "kF9", SDL_SCANCODE_F9, "F9" }, + { "kF10", SDL_SCANCODE_F10, "F10" }, + { "kF11", SDL_SCANCODE_F11, "F11" }, + { "kF12", SDL_SCANCODE_F12, "F12" }, + + { "kPRINTSCREEN", SDL_SCANCODE_PRINTSCREEN, "Print Screen" }, + { "kSCROLL", SDL_SCANCODE_SCROLLLOCK, "Scroll Lock" }, + { "kPAUSE", SDL_SCANCODE_PAUSE, "Pause" }, + { "kINSERT", SDL_SCANCODE_INSERT, "Insert" }, + + { "kHOME", SDL_SCANCODE_HOME, "Home" }, + { "kPGUP", SDL_SCANCODE_PAGEUP, "Page Up" }, + { "kDELETE", SDL_SCANCODE_DELETE, "Delete" }, + { "kEND", SDL_SCANCODE_END, "End" }, + { "kPGDN", SDL_SCANCODE_PAGEDOWN, "Page Down" }, + + { "kRIGHT", SDL_SCANCODE_RIGHT, "Right" }, + { "kLEFT", SDL_SCANCODE_LEFT, "Left" }, + { "kDOWN", SDL_SCANCODE_DOWN, "Down" }, + { "kUP", SDL_SCANCODE_UP, "Up" }, + + { "kNUMLOCK", SDL_SCANCODE_NUMLOCKCLEAR, "Num Lock" }, + + { "kDIVIDE", SDL_SCANCODE_KP_DIVIDE, "Numpad Divide" }, + { "kMULTIPLY", SDL_SCANCODE_KP_MULTIPLY, "Numpad Multiply" }, + { "kSUBTRACT", SDL_SCANCODE_KP_MINUS, "Numpad Minus" }, + { "kADD", SDL_SCANCODE_KP_PLUS, "Numpad Plus" }, + { "kNUMPADENTER", SDL_SCANCODE_KP_ENTER, "Numpad Enter" }, + + { "kNUMPAD1", SDL_SCANCODE_KP_1, "Numpad 1" }, + { "kNUMPAD2", SDL_SCANCODE_KP_2, "Numpad 2" }, + { "kNUMPAD3", SDL_SCANCODE_KP_3, "Numpad 3" }, + { "kNUMPAD4", SDL_SCANCODE_KP_4, "Numpad 4" }, + { "kNUMPAD5", SDL_SCANCODE_KP_5, "Numpad 5" }, + { "kNUMPAD6", SDL_SCANCODE_KP_6, "Numpad 6" }, + { "kNUMPAD7", SDL_SCANCODE_KP_7, "Numpad 7" }, + { "kNUMPAD8", SDL_SCANCODE_KP_8, "Numpad 8" }, + { "kNUMPAD9", SDL_SCANCODE_KP_9, "Numpad 9" }, + { "kNUMPAD0", SDL_SCANCODE_KP_0, "Numpad 0" }, + + { "kNUMPADPERIOD", SDL_SCANCODE_KP_PERIOD, "Numpad Period" }, + { "kNONUSBACKSLASH", SDL_SCANCODE_NONUSBACKSLASH, "Non US Backslash" }, + { "kAPPLICATION", SDL_SCANCODE_APPLICATION, "Application" }, + { "kPOWER", SDL_SCANCODE_POWER, "Power" }, + { "kNUMPADEQUALS", SDL_SCANCODE_KP_EQUALS, "Numpad Equals" }, + + { "kF13", SDL_SCANCODE_F13, "F13" }, + { "kF14", SDL_SCANCODE_F14, "F14" }, + { "kF15", SDL_SCANCODE_F15, "F15" }, + { "kF16", SDL_SCANCODE_F16, "F16" }, + { "kF17", SDL_SCANCODE_F17, "F17" }, + { "kF18", SDL_SCANCODE_F18, "F18" }, + { "kF19", SDL_SCANCODE_F19, "F19" }, + { "kF20", SDL_SCANCODE_F20, "F20" }, + { "kF21", SDL_SCANCODE_F21, "F21" }, + { "kF22", SDL_SCANCODE_F22, "F22" }, + { "kF23", SDL_SCANCODE_F23, "F23" }, + { "kF24", SDL_SCANCODE_F24, "F24" }, + + { "kEXECUTE", SDL_SCANCODE_EXECUTE, "Execute" }, + { "kHELP", SDL_SCANCODE_HELP, "Help" }, + { "kMENU", SDL_SCANCODE_MENU, "Menu" }, + + { "kSELECT", SDL_SCANCODE_SELECT, "Select" }, + { "kSTOP", SDL_SCANCODE_STOP, "Stop" }, + + { "kREDO", SDL_SCANCODE_AGAIN, "Redo" }, + { "kUNDO", SDL_SCANCODE_UNDO, "Undo" }, + + { "kCUT", SDL_SCANCODE_CUT, "Cut" }, + { "kCOPY", SDL_SCANCODE_COPY, "Copy" }, + { "kPASTE", SDL_SCANCODE_PASTE, "Paste" }, + + { "kFIND", SDL_SCANCODE_FIND, "Find" }, + + { "kMUTE", SDL_SCANCODE_MUTE, "Mute" }, + { "kVOLUMEUP", SDL_SCANCODE_VOLUMEUP, "Volume Up" }, + { "kVOLUMEDOWN", SDL_SCANCODE_VOLUMEDOWN, "Volume Down" }, + + { "kNUMPADCOMMA", SDL_SCANCODE_KP_COMMA, "Numpad Comma" }, + { "kNUMPADEQUALSAS400", SDL_SCANCODE_KP_EQUALSAS400, "Equals AS400" }, + + { "kINTERNATIONAL1", SDL_SCANCODE_INTERNATIONAL1 /* Give a better name? */ }, + { "kINTERNATIONAL2", SDL_SCANCODE_INTERNATIONAL2 /* Give a better name? */ }, + { "kYEN", SDL_SCANCODE_INTERNATIONAL3, "Yen" }, + { "kINTERNATIONAL4", SDL_SCANCODE_INTERNATIONAL4 /* Give a better name? */ }, + { "kINTERNATIONAL5", SDL_SCANCODE_INTERNATIONAL5 /* Give a better name? */ }, + { "kINTERNATIONAL6", SDL_SCANCODE_INTERNATIONAL6 /* Give a better name? */ }, + { "kINTERNATIONAL7", SDL_SCANCODE_INTERNATIONAL7 /* Give a better name? */ }, + { "kINTERNATIONAL8", SDL_SCANCODE_INTERNATIONAL8 /* Give a better name? */ }, + { "kINTERNATIONAL9", SDL_SCANCODE_INTERNATIONAL9 /* Give a better name? */ }, + + { "kHANGUL", SDL_SCANCODE_LANG1, "Hangul" }, + { "kHANJA", SDL_SCANCODE_LANG2, "Hanja" }, + { "kKATAKANA", SDL_SCANCODE_LANG3, "Katakana" }, + { "kHIRAGANA", SDL_SCANCODE_LANG4, "Hiragana" }, + { "kZENHANKAKU", SDL_SCANCODE_LANG5, "Zen-Han-kaku" }, + { "kLANG6", SDL_SCANCODE_LANG6 /* Give a better name? */ }, + { "kLANG7", SDL_SCANCODE_LANG7 /* Give a better name? */ }, + { "kLANG8", SDL_SCANCODE_LANG8 /* Give a better name? */ }, + { "kLANG9", SDL_SCANCODE_LANG9 /* Give a better name? */ }, + + { "kALTERASE", SDL_SCANCODE_ALTERASE, "Alterase" }, + { "kCANCEL", SDL_SCANCODE_CANCEL, "Cancel" }, + { "kCLEAR", SDL_SCANCODE_CLEAR, "Clear" }, + { "kPRIOR", SDL_SCANCODE_PRIOR, "Prior" }, + { "kRETURN2", SDL_SCANCODE_RETURN2, "Return 2" }, + { "kSEPARATOR", SDL_SCANCODE_SEPARATOR, "Separator" }, + { "kOUT", SDL_SCANCODE_OUT, "Out" }, + { "kOPER", SDL_SCANCODE_OPER, "Oper" }, + { "kCLEARAGAIN", SDL_SCANCODE_CLEARAGAIN, "Clear Again" }, + { "kCRSEL", SDL_SCANCODE_CRSEL, "Crsel" }, + { "kEXSEL", SDL_SCANCODE_EXSEL, "Excel" }, + + { "kNUMPAD_00", SDL_SCANCODE_KP_00, "Numpad 00" }, + { "kNUMPAD_000", SDL_SCANCODE_KP_000, "Numpad 000" }, + { "kTHOUSANDSSEPARATOR", SDL_SCANCODE_THOUSANDSSEPARATOR, "Thousand Separator" }, + { "kDECIMALSEPARATOR", SDL_SCANCODE_DECIMALSEPARATOR, "Decimal Separator" }, + { "kCURRENCYUNIT", SDL_SCANCODE_CURRENCYUNIT, "Currency Unit" }, + { "kCURRENCYSUBUNIT", SDL_SCANCODE_CURRENCYSUBUNIT, "Currency Subunit" }, + { "kNUMPAD_LEFTPAREN", SDL_SCANCODE_KP_LEFTPAREN, "Numpad Left Paren" }, + { "kNUMPAD_RIGHTPAREN", SDL_SCANCODE_KP_RIGHTPAREN, "Numpad Right Paren" }, + { "kNUMPAD_LEFTBRACE", SDL_SCANCODE_KP_LEFTBRACE, "Numpad Left Brace" }, + { "kNUMPAD_RIGHTBRACE", SDL_SCANCODE_KP_RIGHTBRACE, "Numpad Right Brace" }, + { "kNUMPAD_TAB", SDL_SCANCODE_KP_TAB, "Numpad Tab" }, + { "kNUMPAD_BACKSPACE", SDL_SCANCODE_KP_BACKSPACE, "Numpad Backspace" }, + { "kNUMPAD_A", SDL_SCANCODE_KP_A, "Numpad A" }, + { "kNUMPAD_B", SDL_SCANCODE_KP_B, "Numpad B" }, + { "kNUMPAD_C", SDL_SCANCODE_KP_C, "Numpad C" }, + { "kNUMPAD_D", SDL_SCANCODE_KP_D, "Numpad D" }, + { "kNUMPAD_E", SDL_SCANCODE_KP_E, "Numpad E" }, + { "kNUMPAD_F", SDL_SCANCODE_KP_F, "Numpad F" }, + + { "kNUMPAD_XOR", SDL_SCANCODE_KP_XOR, "Numpad XOR" }, + + { "kNUMPAD_POWER", SDL_SCANCODE_KP_POWER, "Numpad Power" }, + { "kNUMPAD_PERCENT", SDL_SCANCODE_KP_PERCENT, "Numpad Percent" }, + + { "kNUMPAD_LESS", SDL_SCANCODE_KP_LESS, "Numpad Less" }, + { "kNUMPAD_GREATER", SDL_SCANCODE_KP_GREATER, "Numpad Greater" }, + + { "kNUMPAD_AMPERSAND", SDL_SCANCODE_KP_AMPERSAND, "Numpad Ampersand" }, + { "kNUMPAD_DBLAMPERSAND", SDL_SCANCODE_KP_DBLAMPERSAND, "Numpad Double Ampersand" }, + + { "kNUMPAD_VERTICALBAR", SDL_SCANCODE_KP_VERTICALBAR, "Numpad Vertical Bar" }, + { "kNUMPAD_DBLVERTICALBAR", SDL_SCANCODE_KP_DBLVERTICALBAR, "Numpad Double Vertical Bar" }, + + { "kNUMPAD_COLON", SDL_SCANCODE_KP_COLON, "Numpad Colon" }, + { "kNUMPAD_HASH", SDL_SCANCODE_KP_HASH, "Numpad Hash" }, + { "kNUMPAD_SPACE", SDL_SCANCODE_KP_SPACE, "Numpad Space" }, + { "kNUMPAD_AT", SDL_SCANCODE_KP_AT, "Numpad At" }, + { "kNUMPAD_EXCLAM", SDL_SCANCODE_KP_EXCLAM, "Numpad Exclam" }, + + { "kNUMPAD_MEMSTORE", SDL_SCANCODE_KP_MEMSTORE, "Numpad Mem Store" }, + { "kNUMPAD_MEMRECALL", SDL_SCANCODE_KP_MEMRECALL, "Numpad Mem Recall" }, + { "kNUMPAD_MEMCLEAR", SDL_SCANCODE_KP_MEMCLEAR, "Numpad Mem Clear" }, + { "kNUMPAD_MEMADD", SDL_SCANCODE_KP_MEMADD, "Numpad Mem Add" }, + { "kNUMPAD_MEMSUBTRACT", SDL_SCANCODE_KP_MEMSUBTRACT, "Numpad Mem Subtract" }, + { "kNUMPAD_MEMMULTIPLY", SDL_SCANCODE_KP_MEMMULTIPLY, "Numpad Mem Multiply" }, + { "kNUMPAD_MEMDIVIDE", SDL_SCANCODE_KP_MEMDIVIDE, "Numpad Mem Divide" }, + + { "kNUMPAD_PLUSMINUS", SDL_SCANCODE_KP_PLUSMINUS, "Numpad Plus-Minus" }, + { "kNUMPAD_CLEAR", SDL_SCANCODE_KP_CLEAR, "Numpad Clear" }, + { "kNUMPAD_CLEARENTRY", SDL_SCANCODE_KP_CLEARENTRY, "Numpad Clear Entry" }, + { "kNUMPAD_BINARY", SDL_SCANCODE_KP_BINARY, "Numpad Binary" }, + { "kNUMPAD_OCTAL", SDL_SCANCODE_KP_OCTAL, "Numpad Octal" }, + { "kNUMPAD_DECIMAL", SDL_SCANCODE_KP_DECIMAL, "Numpad Decimal" }, + { "kNUMPAD_HEXADECIMAL", SDL_SCANCODE_KP_HEXADECIMAL, "Numpad Hexadecimal" }, + + { "kLCONTROL", SDL_SCANCODE_LCTRL, "Left Ctrl" }, + { "kLSHIFT", SDL_SCANCODE_LSHIFT, "Left shift" }, + { "kLMENU", SDL_SCANCODE_LALT, "Left Alt" }, + { "kLWIN", SDL_SCANCODE_LGUI, "Left Windows" }, + { "kRCONTROL", SDL_SCANCODE_RCTRL, "Right Ctrl" }, + { "kRSHIFT", SDL_SCANCODE_RSHIFT, "Right Shift" }, + { "kRMENU", SDL_SCANCODE_RALT, "Right Alt" }, + { "kRWIN", SDL_SCANCODE_RGUI, "Right Windows" }, + + { "kMODE", SDL_SCANCODE_MODE, "Mode" }, + + { "kAUDIONEXT", SDL_SCANCODE_AUDIONEXT, "Audio Next" }, + { "kAUDIOPREV", SDL_SCANCODE_AUDIOPREV, "Audio Prev" }, + { "kAUDIOSTOP", SDL_SCANCODE_AUDIOSTOP, "Audio Stop" }, + { "kAUDIOPLAY", SDL_SCANCODE_AUDIOPLAY, "Audio Play" }, + { "kAUDIOMUTE", SDL_SCANCODE_AUDIOMUTE, "Audio Mute" }, + + { "kMEDIASELECT", SDL_SCANCODE_MEDIASELECT, "Media Select" }, + { "kWWW", SDL_SCANCODE_WWW, "WWW" }, + { "kMAIL", SDL_SCANCODE_MAIL, "Mail" }, + { "kCALCULATOR", SDL_SCANCODE_CALCULATOR, "Calculator" }, + { "kCOMPUTER", SDL_SCANCODE_COMPUTER, "My Computer" }, + + { "kNUMPAD_AC_SEARCH", SDL_SCANCODE_AC_SEARCH, "AC Search" }, + { "kNUMPAD_AC_HOME", SDL_SCANCODE_AC_HOME, "AC Home" }, + { "kNUMPAD_AC_BACK", SDL_SCANCODE_AC_BACK, "AC Back" }, + { "kNUMPAD_AC_FORWARD", SDL_SCANCODE_AC_FORWARD, "AC Forward" }, + { "kNUMPAD_AC_STOP", SDL_SCANCODE_AC_STOP, "AC Stop" }, + { "kNUMPAD_AC_REFRESH", SDL_SCANCODE_AC_REFRESH, "AC Refresh" }, + { "kNUMPAD_AC_BOOKMARKS", SDL_SCANCODE_AC_BOOKMARKS, "AC Bookmarks" }, + + { "kBRIGHTNESSDOWN", SDL_SCANCODE_BRIGHTNESSDOWN, "Brightness Down" }, + { "kBRIGHTNESSUP", SDL_SCANCODE_BRIGHTNESSUP, "Brightness Up" }, + { "kDISPLAYSWITCH", SDL_SCANCODE_DISPLAYSWITCH, "Display Switch" }, + + { "kKBDILLUMTOGGLE)", SDL_SCANCODE_KBDILLUMTOGGLE, "Illum Toogle" }, + { "kKBDILLUMDOWN", SDL_SCANCODE_KBDILLUMDOWN, "Illum Down" }, + { "kKBDILLUMUP", SDL_SCANCODE_KBDILLUMUP, "Illum Up" }, + + { "kEJECT", SDL_SCANCODE_EJECT, "Eject" }, + { "kSLEEP", SDL_SCANCODE_SLEEP, "Sleep" }, + + { "kAPP1", SDL_SCANCODE_APP1, "App 1" }, + { "kAPP2", SDL_SCANCODE_APP2, "App 2" }, + { nullptr, -1, "(null)" } +}; void initialize_bindings() { @@ -109,17 +423,18 @@ void remap_keys() { int idx = 0; string128 buff; + // Log("Keys remap:"); while (keyboards[idx].key_name) { buff[0] = 0; _keyboard& kb = keyboards[idx]; - bool res = pInput->get_dik_name(kb.dik, buff, sizeof(buff)); + const bool res = pInput->get_dik_name(kb.dik, buff, sizeof(buff)); if (res) kb.key_local_name = buff; - else + else if (kb.key_local_name.empty()) kb.key_local_name = kb.key_name; - //. Msg("[%s]-[%s]",kb.key_name, kb.key_local_name.c_str()); + // Msg("[%s]-[%s]", kb.key_name, kb.key_local_name.c_str()); ++idx; } } @@ -239,7 +554,7 @@ int get_action_dik(EGameActions _action_id, int idx) if (pbinding->m_keyboard[idx]) return pbinding->m_keyboard[idx]->dik; } - return 0; + return SDL_SCANCODE_UNKNOWN; } EGameActions get_binded_action(int _dik) diff --git a/src/xrGame/xr_level_controller.h b/src/xrGame/xr_level_controller.h index 903a8009e91..021775ecc58 100644 --- a/src/xrGame/xr_level_controller.h +++ b/src/xrGame/xr_level_controller.h @@ -2,6 +2,7 @@ #include "xrCore/xrstring.h" #include "xrCommon/xr_string.h" #include "xrCommon/xr_map.h" +#include "xrEngine/xr_input.h" // Don't remove this include enum EGameActions { @@ -123,8 +124,8 @@ EGameActions action_name_to_id(pcstr _name); _action* action_name_to_ptr(pcstr _name); extern _action actions[]; -// extern _keyboard keyboards []; -// extern xr_vector< _keyboard > keyboards; +// extern _keyboard keyboards[]; +// extern xr_vector<_keyboard> keyboards; #define bindings_count kLASTACTION struct _binding @@ -161,14 +162,3 @@ class ConsoleBindCmds void GetActionAllBinding(LPCSTR action, char* dst_buff, int dst_buff_sz); extern ConsoleBindCmds bindConsoleCmds; - -// 0xED - max vavue in DIK* enum -#define MOUSE_1 (0xED + 100) -#define MOUSE_2 (0xED + 101) -#define MOUSE_3 (0xED + 102) - -#define MOUSE_4 (0xED + 103) -#define MOUSE_5 (0xED + 104) -#define MOUSE_6 (0xED + 105) -#define MOUSE_7 (0xED + 106) -#define MOUSE_8 (0xED + 107) diff --git a/src/xrPhysics/CMakeLists.txt b/src/xrPhysics/CMakeLists.txt index 304049b0536..1e743d2e2ec 100644 --- a/src/xrPhysics/CMakeLists.txt +++ b/src/xrPhysics/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/ode/include ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include + /usr/include/SDL2 ) list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/tri-colliderknoopc/dcTriListCollider.cpp") 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/xrScriptEngine/DebugMacros.hpp b/src/xrScriptEngine/DebugMacros.hpp index 68aab2a6135..94e971058aa 100644 --- a/src/xrScriptEngine/DebugMacros.hpp +++ b/src/xrScriptEngine/DebugMacros.hpp @@ -11,7 +11,7 @@ do if (!(expr)) \ { \ string4096 assertionInfo; \ - xrDebug::GatherInfo(assertionInfo, DEBUG_INFO, #expr, nullptr, nullptr, nullptr); \ + xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, nullptr, nullptr, nullptr); \ throw assertionInfo; \ } \ \ @@ -24,7 +24,7 @@ do if (!(expr)) \ { \ string4096 assertionInfo; \ - xrDebug::GatherInfo(assertionInfo, DEBUG_INFO, #expr, msg0, nullptr, nullptr); \ + xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, msg0, nullptr, nullptr); \ throw assertionInfo; \ } \ \ @@ -37,7 +37,7 @@ do if (!(expr)) \ { \ string4096 assertionInfo; \ - xrDebug::GatherInfo(assertionInfo, DEBUG_INFO, #expr, msg0, msg1, nullptr); \ + xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, msg0, msg1, nullptr); \ throw assertionInfo; \ } \ \ diff --git a/src/xrSound/CMakeLists.txt b/src/xrSound/CMakeLists.txt index 3024805346d..0f978df0f32 100644 --- a/src/xrSound/CMakeLists.txt +++ b/src/xrSound/CMakeLists.txt @@ -10,7 +10,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../xrEngine ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/libvorbis/include - ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/libogg/include +# ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/libogg/include + ${OGG_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/openal/include ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include ) @@ -24,5 +25,4 @@ add_definitions(-DXRSOUND_EXPORTS -DdSINGLE -D_SECURE_SCL=0) add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES}) set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") -#target_link_libraries(${PROJECT_NAME} xrCore ${OGG_LIBRARIES} vorbis vorbisfile openal xrAPI xrCDB) -target_link_libraries(${PROJECT_NAME} xrCore xrAPI xrCDB) +target_link_libraries(${PROJECT_NAME} xrCore xrAPI xrCDB ${OGG_LIBRARIES}) 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