diff --git a/overlay_experimental/Base_Hook.h b/overlay_experimental/Base_Hook.h index 153bac6..e00404e 100644 --- a/overlay_experimental/Base_Hook.h +++ b/overlay_experimental/Base_Hook.h @@ -1,6 +1,10 @@ #ifndef __INCLUDED_BASE_HOOK_H__ #define __INCLUDED_BASE_HOOK_H__ +#include "../dll/base.h" + +#ifdef STEAM_WIN32 + #define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN #include @@ -45,4 +49,6 @@ public: } }; +#endif + #endif//__INCLUDED_BASE_HOOK_H__ \ No newline at end of file diff --git a/overlay_experimental/DX10_Hook.cpp b/overlay_experimental/DX10_Hook.cpp index 373071e..f065455 100644 --- a/overlay_experimental/DX10_Hook.cpp +++ b/overlay_experimental/DX10_Hook.cpp @@ -1,4 +1,7 @@ #include "../dll/base.h" + +#ifdef STEAM_WIN32 + #include "DX10_Hook.h" #include "Hook_Manager.h" @@ -71,6 +74,7 @@ void DX10_Hook::resetRenderState() } } +// Try to make this function and overlay's proc as short as possible or it might affect game's fps. void DX10_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain) { DXGI_SWAP_CHAIN_DESC desc; @@ -208,4 +212,6 @@ void DX10_Hook::loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain) LOAD_FUNC(ResizeBuffers); LOAD_FUNC(ResizeTarget); #undef LOAD_FUNC -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/overlay_experimental/DX10_Hook.h b/overlay_experimental/DX10_Hook.h index c345bb6..a713287 100644 --- a/overlay_experimental/DX10_Hook.h +++ b/overlay_experimental/DX10_Hook.h @@ -1,9 +1,11 @@ #ifndef __INCLUDED_DX10_HOOK_H__ #define __INCLUDED_DX10_HOOK_H__ +#include "Base_Hook.h" +#ifdef STEAM_WIN32 + #include #include "DirectX_VTables.h" -#include "Base_Hook.h" class DX10_Hook : public Base_Hook { @@ -46,4 +48,6 @@ public: void loadFunctions(ID3D10Device *pDevice, IDXGISwapChain *pSwapChain); }; +#endif//STEAM_WIN32 + #endif//__INCLUDED_DX10_HOOK_H__ \ No newline at end of file diff --git a/overlay_experimental/DX11_Hook.cpp b/overlay_experimental/DX11_Hook.cpp index 61b3f9f..782d007 100644 --- a/overlay_experimental/DX11_Hook.cpp +++ b/overlay_experimental/DX11_Hook.cpp @@ -1,4 +1,7 @@ #include "../dll/base.h" + +#ifdef STEAM_WIN32 + #include "DX11_Hook.h" #include "Hook_Manager.h" @@ -83,6 +86,7 @@ void DX11_Hook::resetRenderState() } } +// Try to make this function and overlay's proc as short as possible or it might affect game's fps. void DX11_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain) { DXGI_SWAP_CHAIN_DESC desc; @@ -227,4 +231,6 @@ void DX11_Hook::loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) LOAD_FUNC(ResizeBuffers); LOAD_FUNC(ResizeTarget); #undef LOAD_FUNC -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/overlay_experimental/DX11_Hook.h b/overlay_experimental/DX11_Hook.h index cf39514..be04502 100644 --- a/overlay_experimental/DX11_Hook.h +++ b/overlay_experimental/DX11_Hook.h @@ -1,9 +1,11 @@ #ifndef __INCLUDED_DX11_HOOK_H__ #define __INCLUDED_DX11_HOOK_H__ +#include "Base_Hook.h" +#ifdef STEAM_WIN32 + #include #include "DirectX_VTables.h" -#include "Base_Hook.h" class DX11_Hook : public Base_Hook { @@ -46,4 +48,6 @@ public: void loadFunctions(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain); }; +#endif//STEAM_WIN32 + #endif//__INCLUDED_DX11_HOOK_H__ \ No newline at end of file diff --git a/overlay_experimental/DX12_Hook.cpp b/overlay_experimental/DX12_Hook.cpp index ac3317b..799f334 100644 --- a/overlay_experimental/DX12_Hook.cpp +++ b/overlay_experimental/DX12_Hook.cpp @@ -1,4 +1,7 @@ #include "../dll/base.h" + +#ifdef STEAM_WIN32 + #include "DX12_Hook.h" #include "Hook_Manager.h" @@ -33,6 +36,7 @@ void DX12_Hook::resetRenderState() } } +// Try to make this function and overlay's proc as short as possible or it might affect game's fps. void DX12_Hook::prepareForOverlay(IDXGISwapChain* pSwapChain) { DXGI_SWAP_CHAIN_DESC desc; @@ -134,21 +138,23 @@ DX12_Hook::DX12_Hook(): { _dll = GetModuleHandle(DLL_NAME); _hooked = false; - // Hook to D3D11CreateDevice and D3D11CreateDeviceAndSwapChain so we know when it gets called. - // If its called, then DX11 will be used to render the overlay. - D3D12CreateDevice = (decltype(D3D12CreateDevice))GetProcAddress(_dll, "D3D12CreateDevice"); - BeginHook(); - HookFuncs( - std::make_pair(&(PVOID&)D3D12CreateDevice, &DX12_Hook::MyD3D12CreateDevice) - ); - EndHook(); + PRINT_DEBUG("Trying to hook DX12 but DX12_Hook is not implemented yet, please report to DEV with the game name."); + // Hook to D3D12CreateDevice and D3D12CreateDeviceAndSwapChain so we know when it gets called. + // If its called, then DX12 will be used to render the overlay. + //D3D12CreateDevice = (decltype(D3D12CreateDevice))GetProcAddress(_dll, "D3D12CreateDevice"); + // + //BeginHook(); + //HookFuncs( + // std::make_pair(&(PVOID&)D3D12CreateDevice, &DX12_Hook::MyD3D12CreateDevice) + //); + //EndHook(); } DX12_Hook::~DX12_Hook() { - PRINT_DEBUG("DX11 Hook removed\n"); + PRINT_DEBUG("DX12 Hook removed\n"); if (_hooked) resetRenderState(); @@ -181,4 +187,6 @@ void DX12_Hook::loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain) LOAD_FUNC(ResizeBuffers); LOAD_FUNC(ResizeTarget); #undef LOAD_FUNC -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/overlay_experimental/DX12_Hook.h b/overlay_experimental/DX12_Hook.h index a449101..c01acd5 100644 --- a/overlay_experimental/DX12_Hook.h +++ b/overlay_experimental/DX12_Hook.h @@ -1,9 +1,11 @@ #ifndef __INCLUDED_DX12_HOOK_H__ #define __INCLUDED_DX12_HOOK_H__ +#include "Base_Hook.h" +#ifdef STEAM_WIN32 + #include #include "DirectX_VTables.h" -#include "Base_Hook.h" class DX12_Hook : public Base_Hook { @@ -46,4 +48,5 @@ public: void loadFunctions(ID3D12Device *pDevice, IDXGISwapChain *pSwapChain); }; +#endif//STEAM_WIN32 #endif//__INCLUDED_DX12_HOOK_H__ \ No newline at end of file diff --git a/overlay_experimental/DX9_Hook.cpp b/overlay_experimental/DX9_Hook.cpp index 1579917..0affc7f 100644 --- a/overlay_experimental/DX9_Hook.cpp +++ b/overlay_experimental/DX9_Hook.cpp @@ -1,5 +1,7 @@ -#include "../dll/base.h" #include "DX9_Hook.h" + +#ifdef STEAM_WIN32 + #include "Hook_Manager.h" #include @@ -72,6 +74,7 @@ void DX9_Hook::resetRenderState() } } +// Try to make this function and overlay's proc as short as possible or it might affect game's fps. void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice) { IDirect3DSwapChain9* pSwapChain; @@ -83,6 +86,7 @@ void DX9_Hook::prepareForOverlay(IDirect3DDevice9 *pDevice) D3DDEVICE_CREATION_PARAMETERS param; pDevice->GetCreationParameters(¶m); + // Workaround to detect if we changed window. if (param.hFocusWindow != Hook_Manager::Inst().GetOverlay()->GetGameHwnd()) resetRenderState(); @@ -221,4 +225,6 @@ void DX9_Hook::loadFunctions(IDirect3DDevice9Ex* pDeviceEx) LOAD_FUNC(Present); LOAD_FUNC(PresentEx); #undef LOAD_FUNC -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/overlay_experimental/DX9_Hook.h b/overlay_experimental/DX9_Hook.h index e81d844..69470d1 100644 --- a/overlay_experimental/DX9_Hook.h +++ b/overlay_experimental/DX9_Hook.h @@ -1,9 +1,11 @@ #ifndef __INCLUDED_DX9_HOOK_H__ #define __INCLUDED_DX9_HOOK_H__ +#include "Base_Hook.h" +#ifdef STEAM_WIN32 + #include #include "DirectX_VTables.h" -#include "Base_Hook.h" class DX9_Hook : public Base_Hook { @@ -47,4 +49,6 @@ public: void loadFunctions(IDirect3DDevice9Ex *pDeviceEx); }; +#endif//STEAM_WIN32 + #endif//__INCLUDED_DX9_HOOK_H__ \ No newline at end of file diff --git a/overlay_experimental/Hook_Manager.h b/overlay_experimental/Hook_Manager.h index 5451d78..5a600af 100644 --- a/overlay_experimental/Hook_Manager.h +++ b/overlay_experimental/Hook_Manager.h @@ -1,9 +1,12 @@ #ifndef __INCLUDED_HOOK_BASE_H__ #define __INCLUDED_HOOK_BASE_H__ +#include "Base_Hook.h" + +#ifdef STEAM_WIN32 + #include #include -#include "Base_Hook.h" class Hook_Manager { @@ -42,5 +45,6 @@ public: Steam_Overlay* GetOverlay() const { return overlay; } }; +#endif//STEAM_WIN32 #endif//__INCLUDED_HOOK_BASE_H__ \ No newline at end of file diff --git a/overlay_experimental/OpenGL_Hook.cpp b/overlay_experimental/OpenGL_Hook.cpp index 6a5e813..368a07f 100644 --- a/overlay_experimental/OpenGL_Hook.cpp +++ b/overlay_experimental/OpenGL_Hook.cpp @@ -1,4 +1,7 @@ #include "../dll/base.h" + +#ifdef STEAM_WIN32 + #include "OpenGL_Hook.h" #include "Hook_Manager.h" @@ -56,6 +59,7 @@ void OpenGL_Hook::resetRenderState() } } +// Try to make this function and overlay's proc as short as possible or it might affect game's fps. void OpenGL_Hook::prepareForOverlay(HDC hDC) { HWND hWnd = WindowFromDC(hDC); @@ -146,4 +150,6 @@ void OpenGL_Hook::Create() // Register the hook to the Hook Manager Hook_Manager::Inst().AddHook(hook); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/overlay_experimental/OpenGL_Hook.h b/overlay_experimental/OpenGL_Hook.h index 1eacc9f..b32cf88 100644 --- a/overlay_experimental/OpenGL_Hook.h +++ b/overlay_experimental/OpenGL_Hook.h @@ -1,8 +1,8 @@ #ifndef __INCLUDED_OPENGL_HOOK_H__ #define __INCLUDED_OPENGL_HOOK_H__ -#include "DirectX_VTables.h" #include "Base_Hook.h" +#ifdef STEAM_WIN32 class OpenGL_Hook : public Base_Hook { @@ -38,4 +38,5 @@ public: static void Create(); // Initialize OGL Hook. }; +#endif//STEAM_WIN32 #endif//__INCLUDED_OPENGL_HOOK_H__ \ No newline at end of file diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index ef7230a..0ca30a9 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -1,5 +1,7 @@ #include "steam_overlay.h" +#ifdef STEAM_WIN32 + #include #include #include @@ -585,4 +587,12 @@ void Steam_Overlay::RunCallbacks() } has_friend_action.pop(); } -} \ No newline at end of file +} + +#else + +/* TODO: + * Add here the code for Linux overlay + */ + +#endif \ No newline at end of file diff --git a/overlay_experimental/steam_overlay.h b/overlay_experimental/steam_overlay.h index d721361..0f95031 100644 --- a/overlay_experimental/steam_overlay.h +++ b/overlay_experimental/steam_overlay.h @@ -39,6 +39,8 @@ struct Friend_Less } }; +#ifdef STEAM_WIN32 + class Steam_Overlay { Settings* settings; @@ -117,4 +119,39 @@ public: void FriendDisconnect(Friend _friend); }; +#else + +class Steam_Overlay +{ +public: + Steam_Overlay(Settings* settings, SteamCallResults* callback_results, SteamCallBacks* callbacks, RunEveryRunCB* run_every_runcb, Networking *network); + ~Steam_Overlay(); + + bool Ready() const { return false: } + + bool NeedPresent() const { return false; } + + void SetNotificationPosition(ENotificationPosition eNotificationPosition) {} + + void SetNotificationInset(int nHorizontalInset, int nVerticalInset) {} + void SetupOverlay() {} + + void HookReady(void* hWnd) {} + + void OverlayProc(int width, int height) {} + + void OpenOverlayInvite(CSteamID lobbyId) {} + void OpenOverlay(const char* pchDialog) {} + + void ShowOverlay(bool state) {} + + void SetLobbyInvite(Friend friendId, uint64 lobbyId) {} + void SetRichInvite(Friend friendId, const char* connect_str) {} + + void FriendConnect(Friend _friend) {} + void FriendDisconnect(Friend _friend) {} +}; + +#endif + #endif//__INCLUDED_STEAM_OVERLAY_H__