From 8bcb15a12821fc137290de291ca7fc31bf31ccc0 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 7 Mar 2016 17:53:32 +0100 Subject: [PATCH] Disabled InputCommand processing while you fiddle with editor UI elements --- src/Engine/Input/InputProxy.cpp | 14 +++++++++----- src/Game/Game.cpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Engine/Input/InputProxy.cpp b/src/Engine/Input/InputProxy.cpp index 6c3591e3..295cf1c4 100644 --- a/src/Engine/Input/InputProxy.cpp +++ b/src/Engine/Input/InputProxy.cpp @@ -45,7 +45,7 @@ void InputProxy::Update(double dt) } } -void InputProxy::Process() +void InputProxy::Process(bool suppressNewEvents /*= false*/) { for (auto& pair : m_CommandHandlers) { const std::string& command = pair.first; @@ -62,8 +62,10 @@ void InputProxy::Process() e.PlayerID = -1; e.Command = command; e.Value = currentValue; - m_EventBroker->Publish(e); - //LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); + if (!suppressNewEvents || e.Value == 0) { + m_EventBroker->Publish(e); + LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); + } m_LastCommandValues[command] = currentValue; } } @@ -78,8 +80,10 @@ void InputProxy::Process() e.Value += value; } //e.Value = std::max(-1.f, std::min(e.Value, 1.f)); - m_EventBroker->Publish(e); - //LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); + if (!suppressNewEvents || e.Value == 0) { + m_EventBroker->Publish(e); + LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); + } } m_CommandQueue.clear(); } diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8f589e34..d58c89e0 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -218,7 +218,7 @@ void Game::Tick() PerformanceTimer::StartTimerAndStopPrevious("InputProxy"); m_InputProxy->Update(dt); m_EventBroker->Swap(); - m_InputProxy->Process(); + m_InputProxy->Process(ImGui::GetIO().WantCaptureKeyboard || ImGui::GetIO().WantCaptureMouse); m_EventBroker->Swap(); PerformanceTimer::StartTimerAndStopPrevious("SoundManager");