Integrating up through commit 90f050496
This commit is contained in:
+1
-1
@@ -110,7 +110,7 @@ namespace ScriptCanvasEditor
|
||||
////
|
||||
|
||||
protected:
|
||||
void OnAddedToGraphCanvasGraph(const GraphCanvas::GraphId& graphId, const AZ::EntityId& scriptCanvasNodeId);
|
||||
void OnAddedToGraphCanvasGraph(const GraphCanvas::GraphId& graphId, const AZ::EntityId& scriptCanvasNodeId) override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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 "FunctionDefinitionNodeDescriptorComponent.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeTitleBus.h>
|
||||
#include <ScriptCanvas/Bus/ScriptCanvasBus.h>
|
||||
#include <ScriptCanvas/Core/NodelingBus.h>
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
|
||||
FunctionDefinitionNodeDescriptorComponent::FunctionDefinitionNodeDescriptorComponent()
|
||||
: NodelingDescriptorComponent(NodeDescriptorType::FunctionDefinitionNode)
|
||||
{
|
||||
}
|
||||
|
||||
void FunctionDefinitionNodeDescriptorComponent::Activate()
|
||||
{
|
||||
NodelingDescriptorComponent::Activate();
|
||||
|
||||
GraphCanvas::VisualNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
|
||||
void FunctionDefinitionNodeDescriptorComponent::Deactivate()
|
||||
{
|
||||
NodelingDescriptorComponent::Deactivate();
|
||||
GraphCanvas::VisualNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void FunctionDefinitionNodeDescriptorComponent::Reflect(AZ::ReflectContext* reflectContext)
|
||||
{
|
||||
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
|
||||
{
|
||||
serializeContext->Class<FunctionDefinitionNodeDescriptorComponent, NodelingDescriptorComponent>()
|
||||
->Version(1)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
bool FunctionDefinitionNodeDescriptorComponent::RenameDialog(FunctionDefinitionNodeDescriptorComponent* descriptor)
|
||||
{
|
||||
if (!descriptor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AZStd::string inBoxText{};
|
||||
AZStd::string defaultName{};
|
||||
|
||||
GraphCanvas::NodeId nodeId = descriptor->GetEntityId();
|
||||
|
||||
GraphCanvas::NodeTitleRequestBus::EventResult(defaultName, nodeId, &GraphCanvas::NodeTitleRequests::GetTitle);
|
||||
|
||||
QMainWindow* editorWindow = nullptr;
|
||||
UIRequestBus::BroadcastResult(editorWindow, &UIRequests::GetMainWindow);
|
||||
|
||||
bool accepted = false;
|
||||
QString name = QInputDialog::getText(qobject_cast<QWidget*>(editorWindow->parent()), "Name", inBoxText.c_str(), QLineEdit::Normal, defaultName.c_str(), &accepted);
|
||||
|
||||
const AZStd::string newName = name.toUtf8().data();
|
||||
|
||||
if (!name.isEmpty() && newName.compare(defaultName) != 0)
|
||||
{
|
||||
GraphCanvas::NodeTitleRequestBus::Event(nodeId, &GraphCanvas::NodeTitleRequests::SetTitle, newName);
|
||||
|
||||
|
||||
AZ::EntityId graphCanvasGraphId;
|
||||
GraphCanvas::SceneMemberRequestBus::EventResult(graphCanvasGraphId, descriptor->GetEntityId(), &GraphCanvas::SceneMemberRequests::GetScene);
|
||||
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
GeneralRequestBus::BroadcastResult(scriptCanvasId, &GeneralRequests::GetScriptCanvasId, graphCanvasGraphId);
|
||||
|
||||
ScriptCanvas::GraphScopedNodeId scopedNodeId = ScriptCanvas::GraphScopedNodeId(scriptCanvasId, descriptor->FindScriptCanvasNodeId());
|
||||
|
||||
ScriptCanvas::NodelingRequestBus::Event(scopedNodeId, &ScriptCanvas::NodelingRequests::SetDisplayName, newName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FunctionDefinitionNodeDescriptorComponent::OnMouseDoubleClick(const QGraphicsSceneMouseEvent*)
|
||||
{
|
||||
return RenameDialog(this);
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 "NodelingDescriptorComponent.h"
|
||||
|
||||
#include <Editor/GraphCanvas/Components/NodeDescriptors/NodeDescriptorComponent.h>
|
||||
|
||||
#include <ScriptCanvas/Core/NodelingBus.h>
|
||||
#include <ScriptCanvas/Core/GraphBus.h>
|
||||
#include <GraphCanvas/Components/VisualBus.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
class FunctionDefinitionNodeDescriptorComponent
|
||||
: public NodelingDescriptorComponent
|
||||
, GraphCanvas::VisualNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(FunctionDefinitionNodeDescriptorComponent, "{F433EC33-D8A7-40E0-97E7-B29C3C68323E}", NodelingDescriptorComponent);
|
||||
static void Reflect(AZ::ReflectContext* reflectContext);
|
||||
|
||||
FunctionDefinitionNodeDescriptorComponent();
|
||||
~FunctionDefinitionNodeDescriptorComponent() override = default;
|
||||
|
||||
static bool RenameDialog(FunctionDefinitionNodeDescriptorComponent* descriptor);
|
||||
|
||||
protected:
|
||||
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// GraphCanvas::VisualNotificationBus::Handler...
|
||||
bool OnMouseDoubleClick(const QGraphicsSceneMouseEvent*) override;
|
||||
/////
|
||||
};
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/Libraries/Core/ScriptEventBase.h>
|
||||
#include <ScriptCanvas/Libraries/Core/FunctionNode.h>
|
||||
#include <ScriptCanvas/Libraries/Core/FunctionCallNode.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ namespace ScriptCanvasEditor
|
||||
void OnVersionConversionEnd() override;
|
||||
////
|
||||
|
||||
// GraphCanvas::NodeNotificationBus
|
||||
// GraphCanvas::VisualNotificationBus
|
||||
bool OnMouseDoubleClick(const QGraphicsSceneMouseEvent*) override;
|
||||
//
|
||||
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
// NodeDescriptorBus::Handler
|
||||
NodeDescriptorType GetType() const override { return m_nodeDescriptorType; }
|
||||
NodeDescriptorComponent* GetDescriptorComponent() override { return this; }
|
||||
////
|
||||
|
||||
// GraphCanvas::NodeNotificationBus
|
||||
|
||||
+189
-7
@@ -11,11 +11,13 @@
|
||||
*/
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <GraphCanvas/Components/Nodes/NodeTitleBus.h>
|
||||
|
||||
#include "NodelingDescriptorComponent.h"
|
||||
|
||||
#include "ScriptCanvas/Bus/EditorScriptCanvasBus.h"
|
||||
#include "ScriptCanvas/GraphCanvas/MappingBus.h"
|
||||
#include <GraphCanvas/Components/Nodes/NodeTitleBus.h>
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/Core/Slot.h>
|
||||
#include <ScriptCanvas/Libraries/Core/Nodeling.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
@@ -35,11 +37,18 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
NodelingDescriptorComponent::NodelingDescriptorComponent()
|
||||
: NodeDescriptorComponent(NodeDescriptorType::FunctionDefinitionNode)
|
||||
NodelingDescriptorComponent::NodelingDescriptorComponent(NodeDescriptorType descriptorType)
|
||||
: NodeDescriptorComponent(descriptorType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodelingDescriptorComponent::Deactivate()
|
||||
{
|
||||
NodeDescriptorComponent::Deactivate();
|
||||
|
||||
ScriptCanvas::GraphNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void NodelingDescriptorComponent::OnNameChanged(const AZStd::string& displayName)
|
||||
{
|
||||
GraphCanvas::NodeTitleRequestBus::Event(GetEntityId(), &GraphCanvas::NodeTitleRequests::SetTitle, displayName);
|
||||
@@ -56,7 +65,180 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZStd::string displayName;
|
||||
ScriptCanvas::NodelingRequestBus::EventResult(displayName, scopedNodeId, &ScriptCanvas::NodelingRequests::GetDisplayName);
|
||||
|
||||
|
||||
OnNameChanged(displayName);
|
||||
|
||||
ScriptCanvas::GraphNotificationBus::Handler::BusConnect(scriptCanvasId);
|
||||
|
||||
}
|
||||
|
||||
ScriptCanvas::Slot* NodelingDescriptorComponent::GetSlotFromNodeling(const AZ::EntityId& connectionId)
|
||||
{
|
||||
GraphCanvas::Endpoint sourceEndpoint;
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(sourceEndpoint, connectionId, &GraphCanvas::ConnectionRequests::GetSourceEndpoint);
|
||||
|
||||
GraphCanvas::Endpoint targetEndpoint;
|
||||
GraphCanvas::ConnectionRequestBus::EventResult(targetEndpoint, connectionId, &GraphCanvas::ConnectionRequests::GetTargetEndpoint);
|
||||
|
||||
ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
AZ::EntityId scriptCanvasNodeId = FindScriptCanvasNodeId();
|
||||
ScriptCanvas::NodeRequestBus::EventResult(scriptCanvasId, scriptCanvasNodeId, &ScriptCanvas::NodeRequests::GetOwningScriptCanvasId);
|
||||
|
||||
AZStd::vector<GraphCanvas::Endpoint> endpoints = { sourceEndpoint, targetEndpoint };
|
||||
|
||||
for (auto& endpoint : endpoints)
|
||||
{
|
||||
ScriptCanvas::Endpoint scEndpoint;
|
||||
EditorGraphRequestBus::EventResult(scEndpoint, scriptCanvasId, &EditorGraphRequests::ConvertToScriptCanvasEndpoint, endpoint);
|
||||
|
||||
ScriptCanvas::Slot* slot = nullptr;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(slot, scEndpoint.GetNodeId(), &ScriptCanvas::NodeRequests::GetSlot, scEndpoint.GetSlotId());
|
||||
|
||||
if (slot)
|
||||
{
|
||||
if (azrtti_istypeof<ScriptCanvas::Nodes::Core::Internal::Nodeling>(slot->GetNode()))
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NodelingDescriptorComponent::OnConnectionComplete(const AZ::EntityId& connectionId)
|
||||
{
|
||||
|
||||
AZStd::vector< AZ::EntityId > graphCanvasSlotIds;
|
||||
GraphCanvas::NodeRequestBus::EventResult(graphCanvasSlotIds, GetEntityId(), &GraphCanvas::NodeRequests::GetSlotIds);
|
||||
|
||||
|
||||
ScriptCanvas::Slot* slot = GetSlotFromNodeling(connectionId);
|
||||
if (slot)
|
||||
{
|
||||
const auto& descriptor = slot->GetDescriptor();
|
||||
if (descriptor.IsExecution())
|
||||
{
|
||||
AZStd::vector<ScriptCanvas::Slot*> scriptSlots;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(scriptSlots, slot->GetNodeId(), &ScriptCanvas::NodeRequests::ModAllSlots);
|
||||
|
||||
if (descriptor.IsInput())
|
||||
{
|
||||
// Hide the output slot
|
||||
for (ScriptCanvas::Slot* s : scriptSlots)
|
||||
{
|
||||
if (s->IsExecution() && s->IsOutput())
|
||||
{
|
||||
// Need the GC slot Id
|
||||
|
||||
AZ::EntityId graphCanvasGraphId;
|
||||
ScriptCanvasEditor::SlotMappingRequestBus::EventResult(graphCanvasGraphId, s->GetNodeId(), &ScriptCanvasEditor::SlotMappingRequests::MapToGraphCanvasId, s->GetId());
|
||||
if (graphCanvasGraphId.IsValid())
|
||||
{
|
||||
m_removedSlotId = graphCanvasGraphId;
|
||||
//m_removedSlot = *s; // copy the slot?
|
||||
GraphCanvas::NodeRequestBus::Event(GetEntityId(), &GraphCanvas::NodeRequests::RemoveSlot, graphCanvasGraphId);
|
||||
}
|
||||
|
||||
s->SetVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the input slot
|
||||
for (ScriptCanvas::Slot* s : scriptSlots)
|
||||
{
|
||||
if (s->IsExecution() && s->IsInput())
|
||||
{
|
||||
AZ::EntityId graphCanvasGraphId;
|
||||
ScriptCanvasEditor::SlotMappingRequestBus::EventResult(graphCanvasGraphId, s->GetNodeId(), &ScriptCanvasEditor::SlotMappingRequests::MapToGraphCanvasId, s->GetId());
|
||||
if (graphCanvasGraphId.IsValid())
|
||||
{
|
||||
GraphCanvas::NodeRequestBus::Event(GetEntityId(), &GraphCanvas::NodeRequests::RemoveSlot, graphCanvasGraphId);
|
||||
}
|
||||
|
||||
s->SetVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodelingDescriptorComponent::OnDisonnectionComplete(const AZ::EntityId& connectionId)
|
||||
{
|
||||
|
||||
ScriptCanvas::Slot* slot = GetSlotFromNodeling(connectionId);
|
||||
if (slot)
|
||||
{
|
||||
const auto& descriptor = slot->GetDescriptor();
|
||||
if (descriptor.IsExecution())
|
||||
{
|
||||
AZStd::vector<ScriptCanvas::Slot*> scriptSlots;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(scriptSlots, slot->GetNodeId(), &ScriptCanvas::NodeRequests::ModAllSlots);
|
||||
|
||||
if (descriptor.IsInput())
|
||||
{
|
||||
// Hide the output slot
|
||||
for (ScriptCanvas::Slot* s : scriptSlots)
|
||||
{
|
||||
if (s->IsExecution() && s->IsOutput())
|
||||
{
|
||||
|
||||
AZ::EntityId graphCanvasGraphId;
|
||||
ScriptCanvasEditor::SlotMappingRequestBus::EventResult(graphCanvasGraphId, s->GetNodeId(), &ScriptCanvasEditor::SlotMappingRequests::MapToGraphCanvasId, s->GetId());
|
||||
if (graphCanvasGraphId.IsValid())
|
||||
{
|
||||
GraphCanvas::NodeRequestBus::Event(GetEntityId(), &GraphCanvas::NodeRequests::AddSlot, m_removedSlotId);
|
||||
}
|
||||
|
||||
s->SetVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the input slot
|
||||
for (ScriptCanvas::Slot* s : scriptSlots)
|
||||
{
|
||||
if (s->IsExecution() && s->IsInput())
|
||||
{
|
||||
|
||||
AZ::EntityId graphCanvasGraphId;
|
||||
ScriptCanvasEditor::SlotMappingRequestBus::EventResult(graphCanvasGraphId, s->GetNodeId(), &ScriptCanvasEditor::SlotMappingRequests::MapToGraphCanvasId, s->GetId());
|
||||
if (graphCanvasGraphId.IsValid())
|
||||
{
|
||||
GraphCanvas::NodeRequestBus::Event(GetEntityId(), &GraphCanvas::NodeRequests::AddSlot, graphCanvasGraphId);
|
||||
}
|
||||
|
||||
s->SetVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodelingDescriptorComponent::OnPreConnectionRemoved(const AZ::EntityId& connectionId)
|
||||
{
|
||||
ScriptCanvas::Slot* slot = GetSlotFromNodeling(connectionId);
|
||||
if (slot)
|
||||
{
|
||||
const auto& descriptor = slot->GetDescriptor();
|
||||
if (descriptor.IsExecution())
|
||||
{
|
||||
AZStd::vector<ScriptCanvas::Slot*> scriptSlots;
|
||||
ScriptCanvas::NodeRequestBus::EventResult(scriptSlots, slot->GetNodeId(), &ScriptCanvas::NodeRequests::ModAllSlots);
|
||||
|
||||
// Show all the slots
|
||||
for (ScriptCanvas::Slot* s : scriptSlots)
|
||||
{
|
||||
s->SetVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+19
-3
@@ -16,25 +16,41 @@
|
||||
#include <Editor/GraphCanvas/Components/NodeDescriptors/NodeDescriptorComponent.h>
|
||||
|
||||
#include <ScriptCanvas/Core/NodelingBus.h>
|
||||
#include <ScriptCanvas/Core/GraphBus.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
class NodelingDescriptorComponent
|
||||
: public NodeDescriptorComponent
|
||||
, public ScriptCanvas::NodelingNotificationBus::Handler
|
||||
, private ScriptCanvas::GraphNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(NodelingDescriptorComponent, "{9EFA1DA5-2CCB-4A6D-AA84-BD121C75773A}", NodeDescriptorComponent);
|
||||
static void Reflect(AZ::ReflectContext* reflectContext);
|
||||
|
||||
NodelingDescriptorComponent();
|
||||
~NodelingDescriptorComponent() = default;
|
||||
|
||||
NodelingDescriptorComponent(NodeDescriptorType descriptorType = NodeDescriptorType::FunctionDefinitionNode);
|
||||
~NodelingDescriptorComponent() override = default;
|
||||
|
||||
void Deactivate() override;
|
||||
|
||||
// NodelingNotificationBus
|
||||
void OnNameChanged(const AZStd::string& newName) override;
|
||||
////
|
||||
|
||||
// GraphCanvas::GraphNotificationBus
|
||||
void OnConnectionComplete(const AZ::EntityId& connectionId) override;
|
||||
void OnDisonnectionComplete(const AZ::EntityId& connectionId) override;
|
||||
void OnPreConnectionRemoved(const AZ::EntityId& connectionId) override;
|
||||
////
|
||||
|
||||
protected:
|
||||
void OnAddedToGraphCanvasGraph(const GraphCanvas::GraphId& graphId, const AZ::EntityId& scriptCanvasNodeId) override;
|
||||
|
||||
ScriptCanvas::Slot* GetSlotFromNodeling(const AZ::EntityId& connectionId);
|
||||
|
||||
AZ::Entity* m_slotEntity;
|
||||
ScriptCanvas::Slot* m_removedSlot;
|
||||
AZ::EntityId m_removedSlotId;
|
||||
};
|
||||
}
|
||||
|
||||
-11
@@ -193,17 +193,6 @@ namespace ScriptCanvasEditor
|
||||
if (remapVariableOutcome)
|
||||
{
|
||||
SetVariableId(remapVariableOutcome.GetValue());
|
||||
|
||||
bool runtimeGraph = false;
|
||||
EditorGraphRequestBus::EventResult(runtimeGraph, scriptCanvasId2, &EditorGraphRequests::IsRuntimeGraph);
|
||||
|
||||
ScriptCanvas::GraphVariable* variable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(variable, scriptCanvasId2, &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, remapVariableOutcome.GetValue());
|
||||
|
||||
if (variable)
|
||||
{
|
||||
variable->RemoveScope(ScriptCanvas::VariableFlags::Scope::Output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user