ImguiSystem: add method for checking if we have an active surface

This commit is contained in:
Kawe Mazidjatari 2024-11-24 13:58:36 +01:00
parent 02a0088deb
commit fd04eef1ce
4 changed files with 20 additions and 4 deletions

View File

@ -60,7 +60,7 @@ LRESULT CGame::ImguiWindowProc(HWND hWnd, UINT& uMsg, WPARAM wParam, LPARAM lPar
} }
} }
if (g_Console.IsActivated() || g_Browser.IsActivated()) if (ImguiSystem()->IsSurfaceActive())
{////////////////////////////////////////////////////////////////////////////// {//////////////////////////////////////////////////////////////////////////////
hr = ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam); hr = ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam);

View File

@ -173,6 +173,20 @@ void CImguiSystem::RenderFrame()
ImGui_ImplDX11_RenderDrawData(&m_snapshotData.DrawData); ImGui_ImplDX11_RenderDrawData(&m_snapshotData.DrawData);
} }
//-----------------------------------------------------------------------------
// Checks whether we have an active surface.
//-----------------------------------------------------------------------------
bool CImguiSystem::IsSurfaceActive() const
{
FOR_EACH_VEC(m_surfaceList, i)
{
if (m_surfaceList[i]->IsActivated())
return true;
}
return false;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Window procedure handler. // Window procedure handler.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -24,6 +24,8 @@ public:
void SampleFrame(); void SampleFrame();
void RenderFrame(); void RenderFrame();
bool IsSurfaceActive() const;
// statics: // statics:
static LRESULT MessageHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static LRESULT MessageHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

View File

@ -301,13 +301,13 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
void ResetInput() void ResetInput()
{ {
g_pInputSystem->EnableInput( // Enables the input system when both are not drawn. // Enables the input system when no imgui surface is drawn.
!g_Browser.IsActivated() && !g_Console.IsActivated()); g_pInputSystem->EnableInput(!ImguiSystem()->IsSurfaceActive());
} }
bool PanelsVisible() bool PanelsVisible()
{ {
if (g_Browser.IsActivated() || g_Console.IsActivated()) if (ImguiSystem()->IsSurfaceActive())
{ {
return true; return true;
} }