Integrating github/staging through commit ab87ed9

This commit is contained in:
alexpete
2021-04-09 11:27:37 -07:00
parent ae62a97894
commit 1044dc3da1
1582 changed files with 29374 additions and 519051 deletions
@@ -14,6 +14,7 @@
#include <AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h>
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Input/Devices/Touch/InputDeviceTouch.h>
#include <AzFramework/Input/Mappings/InputMappingAnd.h>
#include <AzFramework/Input/Mappings/InputMappingOr.h>
@@ -21,6 +22,9 @@
#include <AzCore/Console/IConsole.h>
#include <AzCore/Interface/Interface.h>
#include <Atom/Feature/ImGui/SystemBus.h>
#include <ImGuiContextScope.h>
#include <ImGui/ImGuiPass.h>
#include <imgui/imgui.h>
using namespace AzFramework;
@@ -31,7 +35,7 @@ namespace AZ
////////////////////////////////////////////////////////////////////////////////////////////////
constexpr const char* DebugConsoleInputContext = "DebugConsoleInputContext";
const InputChannelId ToggleDebugConsoleInputChannelId("ToggleDebugConsole");
const InputChannelId ThumbstickL3AndR3InputChannelId("BothGamepadTriggers");
const InputChannelId ThumbstickL3AndR3InputChannelId("ThumbstickL3AndR3");
////////////////////////////////////////////////////////////////////////////////////////////////
AZ::Color GetColorForLogLevel(const AZ::LogLevel& logLevel)
@@ -79,6 +83,16 @@ namespace AZ
, m_maxEntriesToDisplay(maxEntriesToDisplay)
, m_maxInputHistorySize(maxInputHistorySize)
{
// The debug console is currently only supported when running the standalone launcher.
// It does function correctly when running the editor if you remove this check, but it
// conflicts with the legacy debug console that also shows at the bottom of the editor.
AZ::ApplicationTypeQuery applicationType;
AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationRequests::QueryApplicationType, applicationType);
if (!applicationType.IsGame())
{
return;
}
// Create an input mapping so that the debug console can be toggled by 'L3+R3' on a gamepad.
AZStd::shared_ptr<InputMappingAnd> inputMappingL3AndR3 = AZStd::make_shared<InputMappingAnd>(ThumbstickL3AndR3InputChannelId, m_inputContext);
inputMappingL3AndR3->AddSourceInput(InputDeviceGamepad::Button::L3);
@@ -112,33 +126,34 @@ namespace AZ
// Bind our custom log handler.
AZ::Interface<AZ::ILogger>::Get()->BindLogHandler(m_logHandler);
// Connect to receive tick events.
AZ::TickBus::Handler::BusConnect();
// Connect to receive render tick events.
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName();
AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName);
}
////////////////////////////////////////////////////////////////////////////////////////////////
DebugConsole::~DebugConsole()
{
// Disconnect to stop receiving tick events.
AZ::TickBus::Handler::BusDisconnect();
// Disconnect to stop receiving render tick events.
AZ::RPI::ViewportContextNotificationBus::Handler::BusDisconnect();
// Disconnect our custom log handler.
m_logHandler.Disconnect();
}
////////////////////////////////////////////////////////////////////////////////////////////////
int DebugConsole::GetTickOrder()
void DebugConsole::OnRenderTick()
{
return AZ::ComponentTickBus::TICK_UI;
}
////////////////////////////////////////////////////////////////////////////////////////////////
void DebugConsole::OnTick([[maybe_unused]]float deltaTime,
[[maybe_unused]]AZ::ScriptTimePoint scriptTimePoint)
{
if (m_isShowing)
if (!m_isShowing)
{
DrawDebugConsole();
return;
}
const bool continueShowing = DrawDebugConsole();
if (!continueShowing)
{
ToggleIsShowing();
}
}
@@ -148,7 +163,7 @@ namespace AZ
if (inputChannel.GetInputChannelId() == ToggleDebugConsoleInputChannelId &&
inputChannel.IsStateBegan())
{
m_isShowing = !m_isShowing;
ToggleIsShowing();
return true;
}
return false;
@@ -292,14 +307,26 @@ namespace AZ
}
////////////////////////////////////////////////////////////////////////////////////////////////
void DebugConsole::DrawDebugConsole()
bool DebugConsole::DrawDebugConsole()
{
// Get the default ImGui pass.
AZ::Render::ImGuiPass* defaultImGuiPass = nullptr;
AZ::Render::ImGuiSystemRequestBus::BroadcastResult(defaultImGuiPass, &AZ::Render::ImGuiSystemRequestBus::Events::GetDefaultImGuiPass);
if (!defaultImGuiPass)
{
return false;
}
// Create an ImGui context scope using the default ImGui pass context.
ImGui::ImGuiContextScope contextScope(defaultImGuiPass->GetContext());
// Draw the debug console in a closeable, moveable, and resizeable IMGUI window.
bool continueShowing = true;
ImGui::SetNextWindowSize(ImVec2(640, 480), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Debug Console", &m_isShowing))
if (!ImGui::Begin("Debug Console", &continueShowing))
{
ImGui::End();
return;
return false;
}
// Show a scrolling child region in which to display all debug log entires.
@@ -375,5 +402,38 @@ namespace AZ
}
ImGui::End();
return continueShowing;
}
////////////////////////////////////////////////////////////////////////////////////////////////
AzFramework::SystemCursorState GetDesiredSystemCursorState()
{
AZ::ApplicationTypeQuery applicationType;
AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationRequests::QueryApplicationType, applicationType);
return applicationType.IsEditor() ?
AzFramework::SystemCursorState::ConstrainedAndVisible :
AzFramework::SystemCursorState::UnconstrainedAndVisible;
}
////////////////////////////////////////////////////////////////////////////////////////////////
void DebugConsole::ToggleIsShowing()
{
m_isShowing = !m_isShowing;
if (m_isShowing)
{
AzFramework::InputSystemCursorRequestBus::EventResult(m_previousSystemCursorState,
AzFramework::InputDeviceMouse::Id,
&AzFramework::InputSystemCursorRequests::GetSystemCursorState);
AzFramework::InputSystemCursorRequestBus::Event(AzFramework::InputDeviceMouse::Id,
&AzFramework::InputSystemCursorRequests::SetSystemCursorState,
GetDesiredSystemCursorState());
}
else
{
AzFramework::InputSystemCursorRequestBus::Event(AzFramework::InputDeviceMouse::Id,
&AzFramework::InputSystemCursorRequests::SetSystemCursorState,
m_previousSystemCursorState);
}
}
}
@@ -12,6 +12,7 @@
#pragma once
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
#include <AzFramework/Input/Contexts/InputContext.h>
#include <AzFramework/Input/Events/InputChannelEventFilter.h>
#include <AzFramework/Input/Events/InputChannelEventListener.h>
@@ -23,6 +24,8 @@
#include <AzCore/std/containers/deque.h>
#include <AzCore/std/string/string.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
struct ImGuiInputTextCallbackData;
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -43,8 +46,8 @@ namespace AZ
//! - The '~' key on a keyboard.
//! - Both the 'L3+R3' buttons on a gamepad.
//! - The fourth finger press on a touch screen.
class DebugConsole : public AZ::TickBus::Handler
, public AzFramework::InputChannelEventListener
class DebugConsole : public AzFramework::InputChannelEventListener
, public AZ::RPI::ViewportContextNotificationBus::Handler
{
public:
////////////////////////////////////////////////////////////////////////////////////////////
@@ -67,12 +70,8 @@ namespace AZ
~DebugConsole() override;
////////////////////////////////////////////////////////////////////////////////////////////
// AZ::TickBus::Handler
int GetTickOrder() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::TickEvents::OnTick
void OnTick(float deltaTime, AZ::ScriptTimePoint scriptTimePoint) override;
//! \ref AZ::RPI::ViewportContextRequestsInterface
void OnRenderTick() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AzFramework::InputChannelEventListener::OnInputChannelEventFiltered
@@ -105,7 +104,12 @@ namespace AZ
////////////////////////////////////////////////////////////////////////////////////////////
//! Draw the debug console.
void DrawDebugConsole();
//! \return True if we should continue showing the debug console, false otherwise.
bool DrawDebugConsole();
////////////////////////////////////////////////////////////////////////////////////////////
//! Toggle whether the debug console is showing or not.
void ToggleIsShowing();
private:
////////////////////////////////////////////////////////////////////////////////////////////
@@ -115,6 +119,7 @@ namespace AZ
AZ::ILogger::LogEvent::Handler m_logHandler; //!< Handler that receives log events to display.
AzFramework::InputContext m_inputContext; //!< Input context used to open/close the console.
char m_inputBuffer[1028] = {}; //!< The character buffer used to accept text input.
AzFramework::SystemCursorState m_previousSystemCursorState; //! The last system cursor state.
int m_currentHistoryIndex = -1; //!< The current index into the input history when browsing.
int m_maxEntriesToDisplay = DefaultMaxEntriesToDisplay; //!< The maximum entries to display.
int m_maxInputHistorySize = DefaultMaxInputHistorySize; //!< The maximum input history size.
@@ -16,6 +16,11 @@
#include <AzFramework/Windowing/WindowBus.h>
#include <Atom/Feature/ImGui/ImGuiUtils.h>
#include <Atom/Feature/ImGui/SystemBus.h>
#include <Atom/RPI.Public/ViewportContext.h>
#if defined(IMGUI_ENABLED)
#include <ImGuiBus.h>
#endif
namespace AZ
{
@@ -49,16 +54,28 @@ namespace AZ
void ImguiAtomSystemComponent::Activate()
{
ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect();
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName();
AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName);
}
void ImguiAtomSystemComponent::Deactivate()
{
ImGui::OtherActiveImGuiRequestBus::Handler::BusDisconnect();
AZ::RPI::ViewportContextNotificationBus::Handler::BusDisconnect();
}
void ImguiAtomSystemComponent::RenderImGuiBuffers(const ImDrawData& drawData)
{
Render::ImGuiSystemRequestBus::Broadcast(&Render::ImGuiSystemRequests::RenderImGuiBuffersToDefaultPass, drawData);
Render::ImGuiSystemRequestBus::Broadcast(&Render::ImGuiSystemRequests::RenderImGuiBuffersToCurrentViewport, drawData);
}
void ImguiAtomSystemComponent::OnRenderTick()
{
#if defined(IMGUI_ENABLED)
ImGui::ImGuiManagerListenerBus::Broadcast(&ImGui::IImGuiManagerListener::Render);
#endif
}
}
}
@@ -17,6 +17,8 @@
#include <OtherActiveImGuiBus.h>
#include <DebugConsole.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
namespace AZ
{
namespace LYIntegration
@@ -28,6 +30,8 @@ namespace AZ
class ImguiAtomSystemComponent final
: public AZ::Component
, public ImGui::OtherActiveImGuiRequestBus::Handler
// The Imgui Gem's ImGuiManager can handle this directly when engine is fully switched to Atom Renderer
, public AZ::RPI::ViewportContextNotificationBus::Handler
{
public:
AZ_COMPONENT(ImguiAtomSystemComponent, "{D423E075-D971-435A-A9C1-57C3B0623A9B}");
@@ -43,10 +47,14 @@ namespace AZ
void Activate() override;
void Deactivate() override;
private:
// OtherActiveImGuiRequestBus overrides ...
void RenderImGuiBuffers(const ImDrawData& drawData) override;
private:
// ViewportContextNotificationBus overrides...
void OnRenderTick() override;
DebugConsole m_debugConsole;
};
} // namespace LYIntegration