Check visible panels in wrapper instead of imgui itself

The SDK's DX interface is much easier to expose to Dear ImGui than game/engine implementations.
This commit is contained in:
Kawe Mazidjatari 2023-01-26 20:00:52 +01:00
parent 684b1e561a
commit 938df1dd89
3 changed files with 15 additions and 4 deletions

View File

@ -25,11 +25,9 @@
// Includes of the game have to be here since this header is precompiled. // Includes of the game have to be here since this header is precompiled.
#include "string" #include "string"
#include "d3d11.h" #include "d3d11.h"
#include "public/utility/httplib.h"
// Game ImGui headers are here for mouse tracking. // Game ImGui headers are here for mouse tracking.
#include "gameui/IBrowser.h" #include "windows/id3dx.h"
#include "gameui/IConsole.h"
// Configuration flags to add in your imconfig.h file: // Configuration flags to add in your imconfig.h file:
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support. This was meaningful before <1.81 but we now load XInput dynamically so the option is now less relevant. //#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support. This was meaningful before <1.81 but we now load XInput dynamically so the option is now less relevant.
@ -186,7 +184,7 @@ void ImGui_ImplWin32_Shutdown()
static bool ImGui_ImplWin32_UpdateMouseCursor() static bool ImGui_ImplWin32_UpdateMouseCursor()
{ {
// These have to be here to prevent the mouse in-game from flickering when '::SetCursor(...)' is called. // These have to be here to prevent the mouse in-game from flickering when '::SetCursor(...)' is called.
if (g_pBrowser->m_bActivate || g_pConsole->m_bActivate) if (PanelsVisible())
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)

View File

@ -445,6 +445,15 @@ void ResetInput()
!g_pBrowser->m_bActivate && !g_pConsole->m_bActivate); !g_pBrowser->m_bActivate && !g_pConsole->m_bActivate);
} }
bool PanelsVisible()
{
if (g_pBrowser->m_bActivate || g_pConsole->m_bActivate)
{
return true;
}
return false;
}
//################################################################################# //#################################################################################
// MANAGEMENT // MANAGEMENT
//################################################################################# //#################################################################################

View File

@ -19,7 +19,9 @@ extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam
extern HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT nFlags); extern HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT nFlags);
//extern bool LoadTextureBuffer(unsigned char* image_data, const int& image_width, const int& image_height, ID3D11ShaderResourceView** out_srv); //extern bool LoadTextureBuffer(unsigned char* image_data, const int& image_width, const int& image_height, ID3D11ShaderResourceView** out_srv);
extern bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView** out_srv, int* out_width, int* out_height); extern bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView** out_srv, int* out_width, int* out_height);
extern void ResetInput(); extern void ResetInput();
extern bool PanelsVisible();
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Typedefs // Typedefs
@ -112,6 +114,7 @@ enum class DXGISwapChainVTbl : short
GetLastPresentCount = 17, GetLastPresentCount = 17,
}; };
#ifndef BUILDING_LIBIMGUI
inline CMemory p_gGameDevice; inline CMemory p_gGameDevice;
inline ID3D11Device** g_ppGameDevice = nullptr; inline ID3D11Device** g_ppGameDevice = nullptr;
@ -129,4 +132,5 @@ class VDXGI : public IDetour
virtual void Detach(void) const { } virtual void Detach(void) const { }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
}; };
#endif // !BUILDING_LIBIMGUI
#endif // !DEDICATED #endif // !DEDICATED