Integrating latest 47acbe8
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ namespace ScriptCanvasDiagnostics
|
||||
public:
|
||||
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AZ::EntityId;
|
||||
using BusIdType = void*;
|
||||
|
||||
virtual void OnDebugDraw(IRenderer*) = 0;
|
||||
};
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
#include "DebugLibraryDefinition.h"
|
||||
#include "Log.h"
|
||||
#include "DrawText.h"
|
||||
#include "DrawTextNodeable.h"
|
||||
#include <ScriptCanvas/Libraries/Libraries.h>
|
||||
|
||||
namespace ScriptCanvas
|
||||
@@ -43,14 +43,14 @@ namespace ScriptCanvas
|
||||
void Debug::InitNodeRegistry(NodeRegistry& nodeRegistry)
|
||||
{
|
||||
Library::AddNodeToRegistry<Debug, Nodes::Debug::DrawTextNode>(nodeRegistry);
|
||||
Library::AddNodeToRegistry<Debug, Nodes::Debug::Log>(nodeRegistry);
|
||||
//Library::AddNodeToRegistry<Debug, Nodes::DrawTextNodeableNode>(nodeRegistry);
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::ComponentDescriptor*> Debug::GetComponentDescriptors()
|
||||
{
|
||||
return AZStd::vector<AZ::ComponentDescriptor*>({
|
||||
Nodes::Debug::DrawTextNode::CreateDescriptor(),
|
||||
Nodes::Debug::Log::CreateDescriptor(),
|
||||
// Nodes::DrawTextNodeableNode::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ScriptCanvas
|
||||
{
|
||||
if (slotId == GetSlotId("Show"))
|
||||
{
|
||||
ScriptCanvasDiagnostics::DebugDrawBus::Handler::BusConnect(GetEntityId());
|
||||
ScriptCanvasDiagnostics::DebugDrawBus::Handler::BusConnect(this);
|
||||
|
||||
m_duration = DrawTextNodeProperty::GetDuration(this);
|
||||
if (m_duration > 0.f && !AZ::TickBus::Handler::BusIsConnected())
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
#include <ScriptCanvas/CodeGen/CodeGen.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
|
||||
#include <Source/DrawText.generated.h>
|
||||
@@ -38,66 +37,21 @@ namespace ScriptCanvas
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
//! Uses the DebugDrawBus to display on-screen debug text
|
||||
class DrawTextNode
|
||||
: public Node
|
||||
, ScriptCanvasDiagnostics::DebugDrawBus::Handler
|
||||
, AZ::TickBus::Handler
|
||||
{
|
||||
public:
|
||||
ScriptCanvas_Node(DrawTextNode,
|
||||
ScriptCanvas_Node::Name("Draw Text", "Displays text on the viewport.")
|
||||
ScriptCanvas_Node::Uuid("{AA209CEC-3813-4DC2-85A9-DE8B7A905CD6}")
|
||||
ScriptCanvas_Node::Icon("Editor/Icons/ScriptCanvas/DrawText.png")
|
||||
ScriptCanvas_Node::Category("Utilities/Debug")
|
||||
ScriptCanvas_Node::Version(1));
|
||||
|
||||
// DebugDrawBus
|
||||
public:
|
||||
|
||||
SCRIPTCANVAS_NODE(DrawTextNode);
|
||||
|
||||
// DebugDrawBus...
|
||||
void OnDebugDraw(IRenderer*) override;
|
||||
//
|
||||
|
||||
// Inputs
|
||||
ScriptCanvas_In(ScriptCanvas_In::Name("Show", "Shows the debug text on the viewport"));
|
||||
ScriptCanvas_In(ScriptCanvas_In::Name("Hide", "Removed the debug text from the viewport"));
|
||||
|
||||
// Outputs
|
||||
ScriptCanvas_Out(ScriptCanvas_Out::Name("Out", ""));
|
||||
|
||||
// Properties
|
||||
ScriptCanvas_Property(AZStd::string,
|
||||
ScriptCanvas_Property::Name("Text", "The text to display on screen.")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
ScriptCanvas_PropertyWithDefaults(AZ::Vector2, AZ::Vector2(20.f, 20.f),
|
||||
ScriptCanvas_Property::Name("Position", "Position of the text on-screen in normalized coordinates [0-1].")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
ScriptCanvas_PropertyWithDefaults(AZ::Color, AZ::Color(1.f, 1.f, 1.f, 1.f),
|
||||
ScriptCanvas_Property::Name("Color", "Color of the text.")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
ScriptCanvas_PropertyWithDefaults(float, 0.f,
|
||||
ScriptCanvas_Property::Name("Duration", "If greater than zero, the text will disappear after this duration (in seconds).")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
ScriptCanvas_PropertyWithDefaults(float, 1.f,
|
||||
ScriptCanvas_Property::Name("Scale", "Scales the font size of the text.")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
ScriptCanvas_PropertyWithDefaults(bool, false,
|
||||
ScriptCanvas_Property::Name("Centered", "Centers the text around the specfied coordinates.")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
ScriptCanvas_PropertyWithDefaults(bool, false,
|
||||
ScriptCanvas_Property::Name("Editor Only", "Only displays this text if the game is being run in-editor, not on launchers.")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
|
||||
protected:
|
||||
|
||||
void OnInputSignal(const SlotId& slotId) override;
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
#include "DrawTextNodeable.h"
|
||||
|
||||
#if 0
|
||||
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <ScriptCanvas/Core/GraphBus.h>
|
||||
#include <ScriptCanvas/Utils/SerializationUtils.h>
|
||||
|
||||
#include <CryCommon/platform.h>
|
||||
#include <CryCommon/Cry_Math.h>
|
||||
#include <CryCommon/Cry_Color.h>
|
||||
|
||||
#include <CryCommon/IRenderer.h>
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
namespace Nodeables
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
DrawTextNodeable::DrawTextNodeable()
|
||||
{
|
||||
ScriptCanvasDiagnostics::SystemRequestBus::BroadcastResult(m_isEditor, &ScriptCanvasDiagnostics::SystemRequests::IsEditor);
|
||||
}
|
||||
|
||||
DrawTextNodeable::~DrawTextNodeable()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
void DrawTextNodeable::OnDeactivate()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
void DrawTextNodeable::Show(AZStd::string text, AZ::Vector2 position, AZ::Color color, float duration, float scale, Data::BooleanType centered, Data::BooleanType editorOnly)
|
||||
{
|
||||
if (text.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (editorOnly && !m_isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ScriptCanvasDiagnostics::DebugDrawBus::Handler::BusConnect(this);
|
||||
|
||||
m_text = text;
|
||||
m_position = position;
|
||||
m_color = color;
|
||||
m_duration = duration;
|
||||
m_scale = scale;
|
||||
m_centered = centered;
|
||||
m_editorOnly = editorOnly;
|
||||
|
||||
if (m_duration > 0.f && !AZ::TickBus::Handler::BusIsConnected())
|
||||
{
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTextNodeable::Hide()
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
ScriptCanvasDiagnostics::DebugDrawBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void DrawTextNodeable::OnTick(float deltaTime, AZ::ScriptTimePoint)
|
||||
{
|
||||
m_duration -= deltaTime;
|
||||
if (m_duration <= 0.f)
|
||||
{
|
||||
ScriptCanvasDiagnostics::DebugDrawBus::Handler::BusDisconnect();
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTextNodeable::OnDebugDraw(IRenderer* renderer)
|
||||
{
|
||||
if (!renderer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get correct coordinates
|
||||
float x = m_position.GetX();
|
||||
float y = m_position.GetY();
|
||||
|
||||
if (x < 1.f || y < 1.f)
|
||||
{
|
||||
int screenX, screenY, screenWidth, screenHeight;
|
||||
renderer->GetViewport(&screenX, &screenY, &screenWidth, &screenHeight);
|
||||
if (x < 1.f)
|
||||
{
|
||||
x *= (float)screenWidth;
|
||||
}
|
||||
if (y < 1.f)
|
||||
{
|
||||
y *= (float)screenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
SDrawTextInfo ti;
|
||||
ti.xscale = ti.yscale = m_scale;
|
||||
ti.flags = eDrawText_2D | eDrawText_FixedSize;
|
||||
|
||||
ti.color[0] = m_color.GetR();
|
||||
ti.color[1] = m_color.GetG();
|
||||
ti.color[2] = m_color.GetB();
|
||||
ti.color[3] = m_color.GetA();
|
||||
|
||||
ti.flags |= m_centered ? eDrawText_Center | eDrawText_CenterV : 0;
|
||||
|
||||
renderer->DrawTextQueued(Vec3(x, y, 0.5f), ti, m_text.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Source/DrawTextNodeable.generated.cpp>
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
#include <ScriptCanvas/Core/Nodeable.h>
|
||||
#include <ScriptCanvas/Core/NodeableNode.h>
|
||||
#include <ScriptCanvas/CodeGen/NodeableCodegen.h>
|
||||
|
||||
#include <ScriptCanvasDiagnosticLibrary/DebugDrawBus.h>
|
||||
#if 0
|
||||
#include <Source/DrawTextNodeable.generated.h>
|
||||
|
||||
struct IRenderer;
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Color;
|
||||
class Vector2;
|
||||
}
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
namespace Nodeables
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
class DrawTextNodeable
|
||||
: public ScriptCanvas::Nodeable
|
||||
, public ScriptCanvasDiagnostics::DebugDrawBus::Handler
|
||||
, public AZ::TickBus::Handler
|
||||
{
|
||||
NodeDefinition(DrawTextNodeable, "Draw Text", "Displays text on the viewport.",
|
||||
NodeTags::Icon("Editor/Icons/ScriptCanvas/DrawTextNode.png"),
|
||||
NodeTags::Category("Utilities/Debug"),
|
||||
NodeTags::Version(0)
|
||||
);
|
||||
|
||||
public:
|
||||
DrawTextNodeable();
|
||||
virtual ~DrawTextNodeable();
|
||||
|
||||
// TickBus
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint) override;
|
||||
|
||||
// DebugDrawBus
|
||||
void OnDebugDraw(IRenderer*) override;
|
||||
|
||||
InputMethod("Show", "Shows the debug text on the viewport")
|
||||
void Show(AZStd::string text, AZ::Vector2 position, AZ::Color color, float duration, float scale, Data::BooleanType centered, Data::BooleanType editorOnly);
|
||||
DataInput(AZStd::string, "Text", "", "The text to display on screen.", SlotTags::DisplayGroup("Show"));
|
||||
DataInput(AZ::Vector2, "Position", AZ::Vector2(20.f, 20.f), "Position of the text on-screen in normalized coordinates [0-1].", SlotTags::DisplayGroup("Show"));
|
||||
DataInput(AZ::Color, "Color", AZ::Color(1.f, 1.f, 1.f, 1.f), "Color of the text.", SlotTags::DisplayGroup("Show"));
|
||||
DataInput(float, "Duration", 0.f, "If greater than zero, the text will disappear after this duration (in seconds).", SlotTags::DisplayGroup("Show"));
|
||||
DataInput(float, "Scale", 1.f, "Scales the font size of the text.", SlotTags::DisplayGroup("Show"));
|
||||
DataInput(Data::BooleanType, "Centered", false, "Centers the text around the specfied coordinates.", SlotTags::DisplayGroup("Show"));
|
||||
DataInput(Data::BooleanType, "Editor Only", false, "Only displays this text if the game is being run in-editor, not on launchers.", SlotTags::DisplayGroup("Show"));
|
||||
|
||||
InputMethod("Hide", "Removed the debug text from the viewport")
|
||||
void Hide();
|
||||
|
||||
protected:
|
||||
void OnDeactivate() override;
|
||||
|
||||
private:
|
||||
AZStd::string m_text;
|
||||
AZ::Vector2 m_position;
|
||||
AZ::Color m_color;
|
||||
float m_duration;
|
||||
float m_scale;
|
||||
bool m_centered;
|
||||
bool m_editorOnly;
|
||||
|
||||
bool m_isEditor = false;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<ScriptCanvas Include="Source/Log.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Class Name="Log"
|
||||
QualifiedName="ScriptCanvas::Nodes::Debug::Log"
|
||||
PreferredClassName="Log"
|
||||
Uuid="{6E100241-A738-4A8B-83C2-0FD0F5A44FDB}"
|
||||
Base="ScriptCanvas::Node"
|
||||
Icon="Editor/Icons/ScriptCanvas/Log.png"
|
||||
Category="Utilities/Debug"
|
||||
Version="0"
|
||||
EditAttributes="AZ::Script::Attributes::ExcludeFrom@AZ::Script::Attributes::ExcludeFlags::All"
|
||||
GeneratePropertyFriend="True"
|
||||
Description="Logs the provided text in the debug console.">
|
||||
<In Name="In" Description="Input signal"/>
|
||||
<Out Name="Out" Description=""/>
|
||||
<Property Name="Value"
|
||||
Description="The value to log"
|
||||
Type="AZStd::string"
|
||||
IsInput="True"
|
||||
IsOutput="False" />
|
||||
</Class>
|
||||
</ScriptCanvas>
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
namespace Nodes
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
void Log::OnInputSignal([[maybe_unused]] const SlotId& slotId)
|
||||
{
|
||||
auto valueDatum = FindDatum(GetSlotId("Value"));
|
||||
if (!valueDatum)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::string text;
|
||||
if (!valueDatum->Empty())
|
||||
{
|
||||
valueDatum->ToString(text);
|
||||
}
|
||||
|
||||
if (!text.empty())
|
||||
{
|
||||
AZ_TracePrintf("Script Canvas", "%s\n", text.c_str());
|
||||
LogNotificationBus::Event(GetOwningScriptCanvasId(), &LogNotifications::LogMessage, text);
|
||||
}
|
||||
|
||||
SignalOutput(GetSlotId("Out"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ScriptCanvas/CodeGen/CodeGen.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
|
||||
#include <Source/Log.generated.h>
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
namespace Nodes
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
class Log
|
||||
: public Node
|
||||
{
|
||||
public:
|
||||
ScriptCanvas_Node(Log,
|
||||
ScriptCanvas_Node::Name("Log", "Logs the provided text in the debug console.")
|
||||
ScriptCanvas_Node::Uuid("{6E100241-A738-4A8B-83C2-0FD0F5A44FDB}")
|
||||
ScriptCanvas_Node::Icon("Editor/Icons/ScriptCanvas/Log.png")
|
||||
ScriptCanvas_Node::Category("Utilities/Debug")
|
||||
ScriptCanvas_Node::Version(0)
|
||||
ScriptCanvas_Node::Deprecated("This node has been deprecated, use the Print node instead.")
|
||||
ScriptCanvas_Node::EditAttributes(AZ::Script::Attributes::ExcludeFrom(AZ::Script::Attributes::ExcludeFlags::All))
|
||||
);
|
||||
|
||||
void OnInputSignal(const SlotId& slotId) override;
|
||||
|
||||
// Inputs
|
||||
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
|
||||
|
||||
// Outputs
|
||||
ScriptCanvas_Out(ScriptCanvas_Out::Name("Out", ""));
|
||||
|
||||
private:
|
||||
|
||||
ScriptCanvas_Property(AZStd::string,
|
||||
ScriptCanvas_Property::Name("Value", "The value to log")
|
||||
ScriptCanvas_Property::Input
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
class ScriptCanvasDiagnosticLibraryTest
|
||||
: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TEST_F(ScriptCanvasDiagnosticLibraryTest, Sanity_Pass)
|
||||
{
|
||||
EXPECT_TRUE(true);
|
||||
}
|
||||
|
||||
|
||||
AZ_UNIT_TEST_HOOK();
|
||||
-3
@@ -18,9 +18,6 @@ set(FILES
|
||||
Source/ScriptCanvasDiagnosticSystemComponent.cpp
|
||||
Source/DebugLibraryDefinition.h
|
||||
Source/DebugLibraryDefinition.cpp
|
||||
Source/Log.h
|
||||
Source/Log.cpp
|
||||
Source/Log.ScriptCanvasNode.xml
|
||||
Source/DrawText.h
|
||||
Source/DrawText.cpp
|
||||
Source/DrawText.ScriptCanvasNode.xml
|
||||
|
||||
Reference in New Issue
Block a user