123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <AzCore/RTTI/BehaviorContextUtilities.h>
- #include <Editor/Components/IconComponent.h>
- #include <Editor/GraphCanvas/PropertySlotIds.h>
- #include <Editor/Nodes/NodeDisplayUtils.h>
- #include <Editor/Translation/TranslationHelper.h>
- #include <GraphCanvas/Components/DynamicOrderingDynamicSlotComponent.h>
- #include <GraphCanvas/Components/MappingComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/AzEventHandlerNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/ClassMethodNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/EBusHandlerNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/EBusSenderNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/FunctionNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/GetVariableNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/NodelingDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/SetVariableNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/ScriptEventReceiverEventNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/ScriptEventReceiverNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/ScriptEventSenderNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/UserDefinedNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/NodeDescriptors/FunctionDefinitionNodeDescriptorComponent.h>
- #include <GraphCanvas/Components/Slots/SlotBus.h>
- #include <GraphCanvas/Components/Nodes/NodeTitleBus.h>
- #include <GraphCanvas/GraphCanvasBus.h>
- #include <GraphCanvas/Components/Slots/Extender/ExtenderSlotBus.h>
- #include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
- #include <ScriptCanvas/Core/Node.h>
- #include <ScriptCanvas/Libraries/Core/AzEventHandler.h>
- #include <ScriptCanvas/Libraries/Core/EBusEventHandler.h>
- #include <ScriptCanvas/Libraries/Core/FunctionDefinitionNode.h>
- #include <ScriptCanvas/Libraries/Core/FunctionCallNode.h>
- #include <ScriptCanvas/Libraries/Core/GetVariable.h>
- #include <ScriptCanvas/Libraries/Core/ReceiveScriptEvent.h>
- #include <ScriptCanvas/Libraries/Core/Method.h>
- #include <ScriptCanvas/Libraries/Core/SendScriptEvent.h>
- #include <ScriptCanvas/Libraries/Core/SetVariable.h>
- #include <Source/Translation/TranslationBus.h>
- namespace ScriptCanvasEditor::Nodes::SlotDisplayHelper
- {
- AZ::EntityId DisplayPropertySlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::VisualExtensionSlotConfiguration& propertyConfiguration);
- AZ::EntityId DisplayExtendableSlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::VisualExtensionSlotConfiguration& extenderConfiguration);
- AZ::EntityId DisplayVisualExtensionSlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::VisualExtensionSlotConfiguration& extensionConfiguration);
- }
- namespace ScriptCanvasEditor::Nodes
- {
- // Handles the creation of a node through the node configurations for most nodes.
- AZ::EntityId DisplayGeneralScriptCanvasNode(AZ::EntityId, const ScriptCanvas::Node* node, const NodeReplacementConfiguration& nodeConfiguration)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- AZ::Entity* graphCanvasEntity = nullptr;
- if (nodeConfiguration.m_nodeType == NodeType::GeneralNode)
- {
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(
- graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, nodeConfiguration.m_nodeSubStyle.c_str());
- }
- else if (nodeConfiguration.m_nodeType == NodeType::WrapperNode)
- {
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(
- graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateWrapperNode, nodeConfiguration.m_nodeSubStyle.c_str());
- }
- AZ_Assert(graphCanvasEntity, "Unable to create GraphCanvas Bus Node");
- if (graphCanvasEntity == nullptr)
- {
- return AZ::EntityId();
- }
- for (const AZ::Uuid& componentId : nodeConfiguration.m_customComponents)
- {
- graphCanvasEntity->CreateComponent(componentId);
- }
- // Apply SceneMember remapping if ScriptCanvasId is valid.
- if (nodeConfiguration.m_scriptCanvasId.IsValid())
- {
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(nodeConfiguration.m_scriptCanvasId);
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(nodeConfiguration.m_scriptCanvasId);
- }
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = nullptr;
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasEntity->GetId(), &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = node->GetEntityId();
- }
- GraphCanvas::TranslationKey key;
- key << ScriptCanvasEditor::TranslationHelper::AssetContext::CustomNodeContext << azrtti_typeid(node).ToString<AZStd::string>()
- << "details";
- GraphCanvas::TranslationRequests::Details details;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- int paramIndex = 0;
- int outputIndex = 0;
- int exeInputIndex = 0;
- int exeOutputIndex = 0;
- int dataInputIndex = 0;
- int dataOutputIndex = 0;
- // Create the GraphCanvas slots
- for (const auto& slot : node->GetSlots())
- {
- GraphCanvas::TranslationKey slotKey;
- slotKey << ScriptCanvasEditor::TranslationHelper::AssetContext::CustomNodeContext
- << azrtti_typeid(node).ToString<AZStd::string>() << "slots";
- int& index = (slot.IsData() && slot.IsInput()) ? paramIndex : outputIndex;
- if (slot.IsVisible())
- {
- AZStd::string slotKeyStr;
- if (slot.IsData())
- {
- if (slot.GetConnectionType() == ScriptCanvas::ConnectionType::Input)
- {
- slotKeyStr.append(AZStd::string::format("DataInput_%s_%d", slot.GetName().c_str(), dataInputIndex++));
- }
- else
- {
- slotKeyStr.append(AZStd::string::format("DataOutput_%s_%d", slot.GetName().c_str(), dataOutputIndex++));
- }
- }
- else
- {
- if (slot.GetConnectionType() == ScriptCanvas::ConnectionType::Input)
- {
- slotKeyStr.append(AZStd::string::format("Input_%s_%d", slot.GetName().c_str(), exeInputIndex++));
- }
- else
- {
- slotKeyStr.append(AZStd::string::format("Output_%s_%d", slot.GetName().c_str(), exeOutputIndex++));
- }
- }
- slotKey << slotKeyStr << "details";
- GraphCanvas::TranslationRequests::Details slotDetails;
- GraphCanvas::TranslationRequestBus::BroadcastResult(
- slotDetails, &GraphCanvas::TranslationRequests::GetDetails, slotKey, slotDetails);
- if (slotDetails.m_name.empty())
- {
- slotDetails.m_name = slot.GetName();
- }
- if (slotDetails.m_tooltip.empty())
- {
- slotDetails.m_tooltip = slot.GetToolTip();
- }
- AZ::EntityId graphCanvasSlotId = DisplayScriptCanvasSlot(graphCanvasEntity->GetId(), slot, index);
- GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetName, slotDetails.m_name);
- GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTooltip, slotDetails.m_tooltip);
- }
- ++index;
- }
- const auto& visualExtensions = node->GetVisualExtensions();
- for (const auto& extensionConfiguration : visualExtensions)
- {
- SlotDisplayHelper::DisplayVisualExtensionSlot(graphCanvasEntity->GetId(), extensionConfiguration);
- }
- if (details.m_name.empty())
- {
- details.m_name = node->GetNodeName();
- }
- graphCanvasEntity->SetName(AZStd::string::format("GC-Node(%s)", details.m_name.c_str()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasEntity->GetId(), &GraphCanvas::NodeTitleRequests::SetTitle, details.m_name);
- GraphCanvas::NodeTitleRequestBus::Event(
- graphCanvasEntity->GetId(), &GraphCanvas::NodeTitleRequests::SetSubTitle, details.m_category);
- if (node->GetNodeToolTip().empty()) // Old way of setting the node tooltip
- {
- // Add to the tooltip the C++ class for reference
- if (!details.m_tooltip.empty())
- {
- details.m_tooltip.append("\n");
- }
- details.m_tooltip.append(AZStd::string::format("[C++] %s", node->GetNodeTypeName().c_str()));
- GraphCanvas::NodeRequestBus::Event(graphCanvasEntity->GetId(), &GraphCanvas::NodeRequests::SetTooltip, details.m_tooltip);
- }
- else
- {
- AZStd::string toolTip = node->GetNodeToolTip();
- toolTip.append(AZStd::string::format("\n[C++] %s", node->GetNodeTypeName().c_str()));
- GraphCanvas::NodeRequestBus::Event(graphCanvasEntity->GetId(), &GraphCanvas::NodeRequests::SetTooltip, toolTip);
- }
-
- if (!nodeConfiguration.m_titlePalette.empty())
- {
- GraphCanvas::NodeTitleRequestBus::Event(
- graphCanvasEntity->GetId(), &GraphCanvas::NodeTitleRequests::SetPaletteOverride, nodeConfiguration.m_titlePalette);
- }
- EditorNodeNotificationBus::Event(
- node->GetEntityId(), &EditorNodeNotifications::OnGraphCanvasNodeDisplayed, graphCanvasEntity->GetId());
- return graphCanvasEntity->GetId();
- }
- AZ::EntityId DisplayNode(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Node* node, StyleConfiguration styleConfiguration = StyleConfiguration())
- {
- NodeReplacementConfiguration nodeConfiguration;
- nodeConfiguration.PopulateComponentDescriptors<IconComponent, UserDefinedNodeDescriptorComponent>();
- if (node->RequiresDynamicSlotOrdering())
- {
- nodeConfiguration.PopulateComponentDescriptors<DynamicOrderingDynamicSlotComponent>();
- }
- else
- {
- nodeConfiguration.PopulateComponentDescriptors<DynamicSlotComponent>();
- }
- nodeConfiguration.m_nodeSubStyle = styleConfiguration.m_nodeSubStyle;
- nodeConfiguration.m_titlePalette = styleConfiguration.m_titlePalette;
- nodeConfiguration.m_scriptCanvasId = node->GetEntityId();
- AZ::SerializeContext* serializeContext = nullptr;
- AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext);
- AZ_Assert(serializeContext, "Failed to acquire application serialize context.");
- const AZ::SerializeContext::ClassData* classData = serializeContext->FindClassData(azrtti_typeid(node));
- if (classData)
- {
- if (classData->m_editData)
- {
- const AZ::Edit::ElementData* elementData = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData);
- if (elementData)
- {
- if (auto nodeTypeAttribute = elementData->FindAttribute(ScriptCanvas::Attributes::Node::NodeType))
- {
- if (auto nodeTypeAttributeData = azdynamic_cast<const AZ::Edit::AttributeData<NodeType>*>(nodeTypeAttribute))
- {
- nodeConfiguration.m_nodeType = nodeTypeAttributeData->Get(nullptr);
- }
- }
- }
- }
- }
- return DisplayGeneralScriptCanvasNode(graphCanvasGraphId, node, nodeConfiguration);
- }
- static void ConfigureGeneralScriptCanvasEntity(const ScriptCanvas::Node* node, AZ::Entity* graphCanvasEntity, const GraphCanvas::SlotGroup& slotGroup = GraphCanvas::SlotGroups::Invalid)
- {
- if (node->RequiresDynamicSlotOrdering())
- {
- graphCanvasEntity->CreateComponent<DynamicOrderingDynamicSlotComponent>(slotGroup);
- }
- else
- {
- graphCanvasEntity->CreateComponent<DynamicSlotComponent>(slotGroup);
- }
- }
- AZ::EntityId DisplayMethodNode(AZ::EntityId, const ScriptCanvas::Nodes::Core::Method* methodNode, bool isAccessor)
- {
- AZ::EntityId graphCanvasNodeId;
- AZ::Entity* graphCanvasEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, ".method");
- AZ_Error("GraphCanvas", graphCanvasEntity, "Unable to create GraphCanvas Node");
- if (graphCanvasEntity)
- {
- graphCanvasNodeId = graphCanvasEntity->GetId();
- }
- // Add the icon component
- ConfigureGeneralScriptCanvasEntity(methodNode, graphCanvasEntity);
- graphCanvasEntity->CreateComponent<IconComponent>(ScriptCanvas::Nodes::Core::Method::RTTI_Type());
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(methodNode->GetEntityId());
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(methodNode->GetEntityId());
- switch (methodNode->GetMethodType())
- {
- case ScriptCanvas::MethodType::Event:
- graphCanvasEntity->CreateComponent<EBusSenderNodeDescriptorComponent>();
- break;
- case ScriptCanvas::MethodType::Getter:
- case ScriptCanvas::MethodType::Setter:
- case ScriptCanvas::MethodType::Free:
- case ScriptCanvas::MethodType::Member:
- graphCanvasEntity->CreateComponent<ClassMethodNodeDescriptorComponent>();
- break;
- break;
- default:
- AZ_Error("ScriptCanvas", false, "Invalid method node type, node creation failed. This node needs to be deleted.");
- break;
- }
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = nullptr;
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasNodeId, &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = methodNode->GetEntityId();
- }
- const bool isFreeMethod = (methodNode->GetMethodType() == ScriptCanvas::MethodType::Free);
- const bool isEBusSender = (methodNode->GetMethodType() == ScriptCanvas::MethodType::Event);
- const AZStd::string& className = methodNode->GetMethodClassName();
- AZStd::string methodName = methodNode->GetName();
- GraphCanvas::TranslationKey key;
- if (isAccessor)
- {
- AZ::StringFunc::Replace(methodName, "::Getter", "");
- AZ::StringFunc::Replace(methodName, "::Setter", "");
- }
- GraphCanvas::TranslationRequests::Details details;
- details.m_name = methodName;
- AZStd::string context;
- if (isFreeMethod)
- {
- context = isAccessor
- ? ScriptCanvasEditor::TranslationHelper::AssetContext::BehaviorGlobalPropertyContext
- : ScriptCanvasEditor::TranslationHelper::AssetContext::BehaviorGlobalMethodContext;
- }
- else
- {
- context = isEBusSender
- ? ScriptCanvasEditor::TranslationHelper::AssetContext::EBusSenderContext
- : ScriptCanvasEditor::TranslationHelper::AssetContext::BehaviorClassContext;
- }
- key << context << className;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key + ".details", details);
- // Set the class' name as the subtitle fallback
- details.m_subtitle = details.m_name;
- AZStd::string methodContext;
- // Get the method's text data
- GraphCanvas::TranslationRequests::Details methodDetails;
- methodDetails.m_name = methodName; // fallback
- key << "methods";
- AZStd::string updatedMethodName = "";
- if (methodNode->GetMethodType() == ScriptCanvas::MethodType::Getter || isAccessor)
- {
- updatedMethodName = "Get";
- methodContext = "Getter";
- }
- else if (methodNode->GetMethodType() == ScriptCanvas::MethodType::Setter)
- {
- updatedMethodName = "Set";
- methodContext = "Setter";
- }
- updatedMethodName.append(methodName);
- key << updatedMethodName << methodContext;
- GraphCanvas::TranslationRequestBus::BroadcastResult(methodDetails, &GraphCanvas::TranslationRequests::GetDetails, key + ".details", methodDetails);
- if (methodDetails.m_subtitle.empty())
- {
- methodDetails.m_subtitle = details.m_category.empty() ? details.m_name : details.m_category;
- }
- // Add to the tooltip the C++ class for reference
- if (!methodDetails.m_tooltip.empty())
- {
- methodDetails.m_tooltip.append("\n");
- }
- methodDetails.m_tooltip.append(AZStd::string::format("[C++] %s", className.c_str()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetDetails, methodDetails.m_name, methodDetails.m_subtitle);
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::SetTooltip, methodDetails.m_tooltip);
- int paramIndex = 0;
- int outputIndex = 0;
- int slotIndex = 0;
- auto busId = methodNode->GetBusSlotId();
- for (const auto& slot : methodNode->GetSlots())
- {
- GraphCanvas::TranslationKey slotKey = key;
- int& inputOutputIndex = slot.IsInput() ? paramIndex : outputIndex;
- const bool isBusIdSlot =
- methodNode->HasBusID() && busId == slot.GetId() && slot.GetDescriptor() == ScriptCanvas::SlotDescriptors::DataIn();
- if (slot.IsVisible())
- {
- AZ::EntityId graphCanvasSlotId = DisplayScriptCanvasSlot(graphCanvasNodeId, slot, slotIndex);
- details.m_name = slot.GetName();
- details.m_tooltip = slot.GetToolTip();
- if (isBusIdSlot)
- {
- key = ::ScriptCanvasEditor::TranslationHelper::GlobalKeys::EBusSenderIDKey;
- GraphCanvas::TranslationRequestBus::BroadcastResult(
- details, &GraphCanvas::TranslationRequests::GetDetails, key + ".details", details);
- }
- else if (slot.IsData())
- {
- key.clear();
- key << context << className << "methods" << updatedMethodName;
- if (methodNode->GetMethodType() == ScriptCanvas::MethodType::Getter || isAccessor)
- {
- key << "Getter";
- }
- else if (methodNode->GetMethodType() == ScriptCanvas::MethodType::Setter)
- {
- key << "Setter";
- }
- if (slot.IsInput())
- {
- key << "params";
- }
- else
- {
- key << "results";
- }
- key << inputOutputIndex;
- GraphCanvas::TranslationRequestBus::BroadcastResult(
- details, &GraphCanvas::TranslationRequests::GetDetails, key + ".details", details);
- }
- else
- {
- AZStd::string direction = (slot.IsInput()) ? "entry" : "exit";
- // Get the translated value for the execution slot
- key.clear();
- key << context << className << "methods" << updatedMethodName << direction << "name";
- bool success = false;
- AZStd::string result;
- GraphCanvas::TranslationRequestBus::BroadcastResult(success, &GraphCanvas::TranslationRequests::Get, key, result);
- if (success)
- {
- details.m_name = result;
- }
- key.clear();
- key << context << className << "methods" << updatedMethodName << direction << "tooltip";
- GraphCanvas::TranslationRequestBus::BroadcastResult(success, &GraphCanvas::TranslationRequests::Get, key, result);
- if (success)
- {
- details.m_tooltip = result;
- }
- }
- GraphCanvas::SlotRequestBus::Event(
- graphCanvasSlotId, &GraphCanvas::SlotRequests::SetDetails, details.m_name, details.m_tooltip);
- UpdateSlotDatumLabel(graphCanvasNodeId, slot.GetId(), details.m_name);
- }
- ++slotIndex;
- if (!isBusIdSlot && slot.IsData())
- {
- ++inputOutputIndex;
- }
- }
- // Set the name
- AZStd::string displayName = methodNode->GetName();
- graphCanvasEntity->SetName(AZStd::string::format("GC-Node(%s)", displayName.c_str()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetPaletteOverride, "MethodNodeTitlePalette");
- // Override the title if it has the Setter or Getter suffixes
- AZStd::string title;
- GraphCanvas::NodeTitleRequestBus::EventResult(title, graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::GetTitle);
- if (!title.empty())
- {
- AZ::RemovePropertyNameArtifacts(title);
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetTitle, title);
- }
- return graphCanvasNodeId;
- }
-
- AZ::EntityId DisplayEbusWrapperNode(AZ::EntityId, const ScriptCanvas::Nodes::Core::EBusEventHandler* busNode)
- {
- AZ::Entity* graphCanvasEntity = nullptr;
- AZStd::string busName = busNode->GetEBusName();
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateWrapperNode, "");
- AZ_Assert(graphCanvasEntity, "Unable to create GraphCanvas Node");
- AZ::EntityId graphCanvasNodeId = graphCanvasEntity->GetId();
- // Add the icon component
- graphCanvasEntity->CreateComponent<IconComponent>(ScriptCanvas::Nodes::Core::EBusEventHandler::RTTI_Type());
- graphCanvasEntity->CreateComponent<EBusHandlerNodeDescriptorComponent>(busName);
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(busNode->GetEntityId());
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(busNode->GetEntityId());
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = nullptr;
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasNodeId, &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = busNode->GetEntityId();
- }
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, SlotGroups::EBusConnectionSlotGroup, GraphCanvas::SlotGroupConfiguration(0));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::DataGroup, GraphCanvas::SlotGroupConfiguration(1));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::ExecutionGroup, GraphCanvas::SlotGroupConfiguration(2));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::SetDividersEnabled, false);
- AZStd::vector< ScriptCanvas::SlotId > scriptCanvasSlots = busNode->GetNonEventSlotIds();
- for (const auto& slotId : scriptCanvasSlots)
- {
- ScriptCanvas::Slot* slot = busNode->GetSlot(slotId);
- GraphCanvas::SlotGroup group = GraphCanvas::SlotGroups::Invalid;
- if (slot->GetDescriptor().IsExecution())
- {
- group = SlotGroups::EBusConnectionSlotGroup;
- }
- if (slot->IsVisible())
- {
- AZ::EntityId gcSlotId = DisplayScriptCanvasSlot(graphCanvasNodeId, (*slot), group);
- if (busNode->IsIDRequired() && slot->GetDescriptor() == ScriptCanvas::SlotDescriptors::DataIn())
- {
- GraphCanvas::TranslationKey key;
- key << ::ScriptCanvasEditor::TranslationHelper::GlobalKeys::EBusHandlerIDKey << "details";
- GraphCanvas::TranslationRequests::Details details;
- details.m_name = slot->GetName();
- details.m_tooltip = slot->GetToolTip();
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- GraphCanvas::SlotRequestBus::Event(gcSlotId, &GraphCanvas::SlotRequests::SetDetails, details.m_name, details.m_tooltip);
- }
- }
- }
- // Set the name
- graphCanvasEntity->SetName(AZStd::string::format("GC-BusNode: %s", busName.data()));
- GraphCanvas::TranslationKey key;
- key << ScriptCanvasEditor::TranslationHelper::AssetContext::EBusHandlerContext << busName << "details";
- GraphCanvas::TranslationRequests::Details details;
- details.m_name = busName;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- // Add to the tooltip the C++ class for reference
- if (!details.m_tooltip.empty())
- {
- details.m_tooltip.append("\n");
- }
- details.m_tooltip.append(AZStd::string::format("[C++] %s", busName.c_str()));
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::SetTooltip, details.m_tooltip);
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetTitle, details.m_name);
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetDefaultPalette, "HandlerWrapperNodeTitlePalette");
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplayEbusEventNode(AZ::EntityId, const AZStd::string& busName, const AZStd::string& eventName, const ScriptCanvas::EBusEventId& eventId)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- AZ::EntityId graphCanvasNodeId;
- AZ::Entity* graphCanvasEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, ".handler");
- AZ_Assert(graphCanvasEntity, "Unable to create GraphCanvas Node");
- graphCanvasNodeId = graphCanvasEntity->GetId();
- graphCanvasEntity->CreateComponent<EBusHandlerEventNodeDescriptorComponent>(busName, eventName, eventId);
- graphCanvasEntity->CreateComponent<SlotMappingComponent>();
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- AZStd::string decoratedName = AZStd::string::format("%s::%s", busName.c_str(), eventName.c_str());
- GraphCanvas::TranslationKey key;
- key << ScriptCanvasEditor::TranslationHelper::AssetContext::EBusHandlerContext << busName << "methods" << eventName << "details";
- GraphCanvas::TranslationRequests::Details details;
- details.m_name = eventName;
- details.m_subtitle = busName;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- // Set the name
- graphCanvasEntity->SetName(AZStd::string::format("GC-Node(%s)", decoratedName.c_str()));
- // Add to the tooltip the C++ class for reference
- if (!details.m_tooltip.empty())
- {
- details.m_tooltip.append("\n");
- }
- details.m_tooltip.append(AZStd::string::format("[C++] %s", busName.c_str()));
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::SetTooltip, details.m_tooltip);
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetTitle, details.m_name);
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetPaletteOverride, "HandlerNodeTitlePalette");
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplayAzEventHandlerNode(AZ::EntityId, const ScriptCanvas::Nodes::Core::AzEventHandler* azEventNode)
- {
- AZ::Entity* graphCanvasEntity{};
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, ".azeventhandler");
- AZ_Assert(graphCanvasEntity, "Unable to create GraphCanvas Node");
- AZ::EntityId graphCanvasNodeId = graphCanvasEntity->GetId();
- const ScriptCanvas::Nodes::Core::AzEventEntry& azEventEntry{ azEventNode->GetEventEntry() };
- // Add the icon component
- graphCanvasEntity->CreateComponent<IconComponent>(azrtti_typeid<ScriptCanvas::Nodes::Core::AzEventHandler>());
- graphCanvasEntity->CreateComponent<AzEventHandlerNodeDescriptorComponent>(azEventEntry.m_eventName);
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(azEventNode->GetEntityId());
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(azEventNode->GetEntityId());
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = {};
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasNodeId, &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = azEventNode->GetEntityId();
- }
- for (const ScriptCanvas::Slot& slot: azEventNode->GetSlots())
- {
- GraphCanvas::SlotGroup group = GraphCanvas::SlotGroups::Invalid;
- if (slot.IsVisible())
- {
- AZ::EntityId gcSlotId = DisplayScriptCanvasSlot(graphCanvasNodeId, slot, group);
- GraphCanvas::TranslationKey key;
- key << ScriptCanvasEditor::TranslationHelper::AssetContext::AZEventContext << azEventNode->GetNodeName() << "slots" << slot.GetName() << "details";
- GraphCanvas::TranslationRequests::Details details;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- GraphCanvas::SlotRequestBus::Event(gcSlotId, &GraphCanvas::SlotRequests::SetName, details.m_name);
- GraphCanvas::SlotRequestBus::Event(gcSlotId, &GraphCanvas::SlotRequests::SetTooltip, details.m_tooltip);;
- }
- }
- GraphCanvas::TranslationKey key;
- key << ScriptCanvasEditor::TranslationHelper::AssetContext::AZEventContext << azEventEntry.m_eventName << "details";
- GraphCanvas::TranslationRequests::Details details;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetTitle, details.m_name);
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::SetTooltip, details.m_tooltip);
- graphCanvasEntity->SetName(AZStd::string::format("GC-EventNode: %s", azEventEntry.m_eventName.c_str()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetPaletteOverride, "HandlerNodeTitlePalette");
- return graphCanvasNodeId;
- }
-
- AZ::EntityId DisplayScriptEventWrapperNode(AZ::EntityId, const ScriptCanvas::Nodes::Core::ReceiveScriptEvent* busNode)
- {
- AZ::Entity* graphCanvasEntity = nullptr;
- const AZ::Data::AssetId assetId = busNode->GetAssetId();
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateWrapperNode, "");
- AZ_Assert(graphCanvasEntity, "Unable to create GraphCanvas Node");
- AZ::EntityId graphCanvasNodeId = graphCanvasEntity->GetId();
- // Add the icon component
- ConfigureGeneralScriptCanvasEntity(busNode, graphCanvasEntity);
- graphCanvasEntity->CreateComponent<IconComponent>(ScriptCanvas::Nodes::Core::ReceiveScriptEvent::RTTI_Type());
- graphCanvasEntity->CreateComponent<ScriptEventReceiverNodeDescriptorComponent>(assetId);
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(busNode->GetEntityId());
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(busNode->GetEntityId());
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = nullptr;
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasNodeId, &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = busNode->GetEntityId();
- }
- AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset = AZ::Data::AssetManager::Instance().GetAsset<ScriptEvents::ScriptEventsAsset>(assetId, AZ::Data::AssetLoadBehavior::PreLoad);
- asset.BlockUntilLoadComplete();
- if (asset.GetStatus() == AZ::Data::AssetData::AssetStatus::Error)
- {
- return graphCanvasNodeId;
- }
- const ScriptEvents::ScriptEvent& definition = asset.Get()->m_definition;
- AZStd::string busName = definition.GetName();
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, SlotGroups::EBusConnectionSlotGroup, GraphCanvas::SlotGroupConfiguration(0));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::DataGroup, GraphCanvas::SlotGroupConfiguration(1));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::ExecutionGroup, GraphCanvas::SlotGroupConfiguration(2));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::SetDividersEnabled, false);
- AZStd::vector< ScriptCanvas::SlotId > scriptCanvasSlots = busNode->GetNonEventSlotIds();
- for (const auto& slotId : scriptCanvasSlots)
- {
- ScriptCanvas::Slot* slot = busNode->GetSlot(slotId);
- GraphCanvas::SlotGroup group = GraphCanvas::SlotGroups::Invalid;
- if (slot->GetDescriptor().IsExecution())
- {
- group = SlotGroups::EBusConnectionSlotGroup;
- }
- if (slot->IsVisible())
- {
- AZ::EntityId gcSlotId = DisplayScriptCanvasSlot(graphCanvasNodeId, (*slot), group);
- if (busNode->IsIDRequired() && slot->GetDescriptor() == ScriptCanvas::SlotDescriptors::DataIn())
- {
- GraphCanvas::TranslationKey key;
- key << ::ScriptCanvasEditor::TranslationHelper::GlobalKeys::EBusHandlerIDKey << "details";
- GraphCanvas::TranslationRequests::Details details;
- GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
- GraphCanvas::SlotRequestBus::Event(gcSlotId, &GraphCanvas::SlotRequests::SetDetails, details.m_name, details.m_tooltip);
- }
- }
- }
- // Set the name
- graphCanvasEntity->SetName(AZStd::string::format("GC-BusNode: %s", busName.data()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetDefaultPalette, "HandlerWrapperNodeTitlePalette");
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplayScriptEventNode(AZ::EntityId, const AZ::Data::AssetId assetId, const ScriptEvents::Method& methodDefinition)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- AZ::EntityId graphCanvasNodeId;
- AZ::Entity* graphCanvasEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, ".handler");
- AZ_Assert(graphCanvasEntity, "Unable to create GraphCanvas Node");
- graphCanvasNodeId = graphCanvasEntity->GetId();
- graphCanvasEntity->CreateComponent<ScriptEventReceiverEventNodeDescriptorComponent>(assetId, methodDefinition);
- graphCanvasEntity->CreateComponent<SlotMappingComponent>();
- graphCanvasEntity->CreateComponent<DynamicSlotComponent>();
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- AZStd::string eventName = methodDefinition.GetName();
- AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset = AZ::Data::AssetManager::Instance().GetAsset<ScriptEvents::ScriptEventsAsset>(assetId, AZ::Data::AssetLoadBehavior::PreLoad);
- asset.BlockUntilLoadComplete();
- const AZStd::string& busName = asset.Get()->m_definition.GetName();
- AZStd::string decoratedName = AZStd::string::format("%s::%s", busName.data(), eventName.c_str());
- // Set the name
- graphCanvasEntity->SetName(AZStd::string::format("GC-Node(%s)", decoratedName.c_str()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetPaletteOverride, "HandlerNodeTitlePalette");
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplayScriptEventSenderNode(AZ::EntityId, const ScriptCanvas::Nodes::Core::SendScriptEvent* senderNode)
- {
- AZ::EntityId graphCanvasNodeId;
- AZ::Entity* graphCanvasEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, ".method");
- AZ_Error("GraphCanvas", graphCanvasEntity, "Unable to create GraphCanvas Node");
- if (graphCanvasEntity)
- {
- graphCanvasNodeId = graphCanvasEntity->GetId();
- }
- // Add the icon component
- ConfigureGeneralScriptCanvasEntity(senderNode, graphCanvasEntity);
- graphCanvasEntity->CreateComponent<IconComponent>(ScriptCanvas::Nodes::Core::Method::RTTI_Type());
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(senderNode->GetEntityId());
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(senderNode->GetEntityId());
- graphCanvasEntity->CreateComponent<ScriptEventSenderNodeDescriptorComponent>(senderNode->GetAssetId(), senderNode->GetEventId());
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = nullptr;
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasNodeId, &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = senderNode->GetEntityId();
- }
- AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset = AZ::Data::AssetManager::Instance().GetAsset<ScriptEvents::ScriptEventsAsset>(senderNode->GetAssetId(), AZ::Data::AssetLoadBehavior::PreLoad);
- asset.BlockUntilLoadComplete();
- if (asset.GetStatus() == AZ::Data::AssetData::AssetStatus::Error)
- {
- return graphCanvasNodeId;
- }
- int paramIndex = 0;
- int outputIndex = 0;
- for (const auto& slot : senderNode->GetSlots())
- {
- int& index = (slot.IsData() && slot.IsInput()) ? paramIndex : outputIndex;
- if (slot.IsVisible())
- {
- AZ::EntityId graphCanvasSlotId = DisplayScriptCanvasSlot(graphCanvasNodeId, slot, index);
- GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetName, slot.GetName());
- GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTooltip, slot.GetToolTip());
- UpdateSlotDatumLabel(graphCanvasNodeId, slot.GetId(), slot.GetName());
- }
- ++index;
- }
- // Set the name
- AZStd::string displayName = senderNode->GetEventName();
- graphCanvasEntity->SetName(AZStd::string::format("GC-Node(%s)", displayName.c_str()));
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetPaletteOverride, "MethodNodeTitlePalette");
- return graphCanvasNodeId;
- }
- // Function Nodes
- AZ::EntityId DisplayFunctionNode(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Nodes::Core::FunctionCallNode* functionNode)
- {
- return DisplayFunctionNode(graphCanvasGraphId, const_cast<ScriptCanvas::Nodes::Core::FunctionCallNode*>(functionNode));
- }
- AZ::EntityId DisplayFunctionNode(AZ::EntityId, ScriptCanvas::Nodes::Core::FunctionCallNode* functionNode)
- {
- AZ::EntityId graphCanvasNodeId;
- AZ::Entity* graphCanvasEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(graphCanvasEntity, &GraphCanvas::GraphCanvasRequests::CreateGeneralNode, ".method");
- AZ_Error("GraphCanvas", graphCanvasEntity, "Unable to create GraphCanvas Node");
- if (graphCanvasEntity)
- {
- graphCanvasNodeId = graphCanvasEntity->GetId();
- }
- auto asset = functionNode->GetAsset();
- // Add the icon component
- ConfigureGeneralScriptCanvasEntity(functionNode, graphCanvasEntity);
- graphCanvasEntity->CreateComponent<IconComponent>(ScriptCanvas::Nodes::Core::Method::RTTI_Type());
- graphCanvasEntity->CreateComponent<SlotMappingComponent>(functionNode->GetEntityId());
- graphCanvasEntity->CreateComponent<SceneMemberMappingComponent>(functionNode->GetEntityId());
- graphCanvasEntity->CreateComponent<FunctionNodeDescriptorComponent>(functionNode->GetAssetId(), functionNode->GetName());
- graphCanvasEntity->Init();
- graphCanvasEntity->Activate();
- // Set the user data on the GraphCanvas node to be the EntityId of the ScriptCanvas node
- AZStd::any* graphCanvasUserData = nullptr;
- GraphCanvas::NodeRequestBus::EventResult(graphCanvasUserData, graphCanvasNodeId, &GraphCanvas::NodeRequests::GetUserData);
- if (graphCanvasUserData)
- {
- *graphCanvasUserData = functionNode->GetEntityId();
- }
- if (asset->GetStatus() == AZ::Data::AssetData::AssetStatus::Error)
- {
- AZ_Error("Script Canvas", false, "Script Canvas Function asset (%s) is not loaded, unable to display the node.", functionNode->GetAssetId().ToString<AZStd::string>().c_str());
- GraphCanvas::TranslationKey key;
- key = "Globals.MissingFunctionAsset.Title.details.m_name";
- bool success = false;
- AZStd::string result = "Error!";
- GraphCanvas::TranslationRequestBus::BroadcastResult(success, &GraphCanvas::TranslationRequests::Get, key = "Globals.MissingFunctionAsset.Title.details.m_name", result);
- if (success)
- {
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetTitle, result);
- }
- result = "Missing Script Canvas Function Asset";
- GraphCanvas::TranslationRequestBus::BroadcastResult(success, &GraphCanvas::TranslationRequests::Get, key = "Globals.MissingFunctionAsset.Title.details.tooltip", result);
- if (success)
- {
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetSubTitle, result);
- }
- return graphCanvasNodeId;
- }
- int paramIndex = 0;
- int outputIndex = 0;
- for (const auto& slot : functionNode->GetSlots())
- {
- int& index = (slot.IsData() && slot.IsInput()) ? paramIndex : outputIndex;
- AZ::EntityId graphCanvasSlotId = DisplayScriptCanvasSlot(graphCanvasNodeId, slot, index);
- GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetName, slot.GetName());
- GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTooltip, slot.GetToolTip());
- UpdateSlotDatumLabel(graphCanvasNodeId, slot.GetId(), slot.GetName());
- ++index;
- }
- if (asset)
- {
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetTitle, asset->m_interfaceData.m_name);
- }
- GraphCanvas::NodeTitleRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeTitleRequests::SetPaletteOverride, "MethodNodeTitlePalette");
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplayFunctionDefinitionNode(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Nodes::Core::FunctionDefinitionNode* functionDefinitionNode)
- {
- NodeReplacementConfiguration nodeConfiguration;
- nodeConfiguration.PopulateComponentDescriptors<IconComponent, FunctionDefinitionNodeDescriptorComponent>();
- if (functionDefinitionNode->RequiresDynamicSlotOrdering())
- {
- nodeConfiguration.PopulateComponentDescriptors<DynamicOrderingDynamicSlotComponent>();
- }
- else
- {
- nodeConfiguration.PopulateComponentDescriptors<DynamicSlotComponent>();
- }
- nodeConfiguration.m_nodeSubStyle = ".nodeling";
- nodeConfiguration.m_titlePalette = "NodelingTitlePalette";
- nodeConfiguration.m_scriptCanvasId = functionDefinitionNode->GetEntityId();
- AZ::SerializeContext* serializeContext = nullptr;
- AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext);
- AZ_Assert(serializeContext, "Failed to acquire application serialize context.");
- if (const AZ::SerializeContext::ClassData* classData = serializeContext->FindClassData(azrtti_typeid(functionDefinitionNode)))
- {
- ScriptCanvas::GraphScopedNodeId nodelingId;
- nodelingId.m_identifier = nodeConfiguration.m_scriptCanvasId;
- nodelingId.m_scriptCanvasId = functionDefinitionNode->GetOwningScriptCanvasId();
- if (classData->m_editData)
- {
- const AZ::Edit::ElementData* elementData = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData);
- if (elementData)
- {
- if (auto nodeTypeAttribute = elementData->FindAttribute(ScriptCanvas::Attributes::Node::NodeType))
- {
- if (auto nodeTypeAttributeData = azdynamic_cast<const AZ::Edit::AttributeData<NodeType>*>(nodeTypeAttribute))
- {
- nodeConfiguration.m_nodeType = nodeTypeAttributeData->Get(nullptr);
- }
- }
- }
- }
- }
- // Because of how the extender slots are registered, there isn't an easy way to only create one or the other based on
- // the type of nodeling, so instead they both get created and we need to remove the inapplicable one
- GraphCanvas::ConnectionType typeToRemove = (functionDefinitionNode->IsExecutionEntry()) ? GraphCanvas::CT_Input : GraphCanvas::CT_Output;
- AZ::EntityId graphCanvasNodeId = DisplayGeneralScriptCanvasNode(graphCanvasGraphId, functionDefinitionNode, nodeConfiguration);
- AZStd::vector<GraphCanvas::SlotId> extenderSlotIds, executionSlotIds;
- GraphCanvas::NodeRequestBus::EventResult(extenderSlotIds, graphCanvasNodeId, &GraphCanvas::NodeRequests::FindVisibleSlotIdsByType, typeToRemove, GraphCanvas::SlotTypes::ExtenderSlot);
- if (!extenderSlotIds.empty())
- {
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::RemoveSlot, *extenderSlotIds.begin());
- }
- GraphCanvas::NodeRequestBus::EventResult(executionSlotIds, graphCanvasNodeId, &GraphCanvas::NodeRequests::FindVisibleSlotIdsByType, typeToRemove, GraphCanvas::SlotTypes::ExecutionSlot);
- if (!executionSlotIds.empty())
- {
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::RemoveSlot, *executionSlotIds.begin());
- }
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplayNodeling(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Nodes::Core::Internal::Nodeling* nodeling)
- {
- NodeReplacementConfiguration nodeConfiguration;
- nodeConfiguration.PopulateComponentDescriptors<IconComponent, NodelingDescriptorComponent>();
- if (nodeling->RequiresDynamicSlotOrdering())
- {
- nodeConfiguration.PopulateComponentDescriptors<DynamicOrderingDynamicSlotComponent>();
- }
- else
- {
- nodeConfiguration.PopulateComponentDescriptors<DynamicSlotComponent>();
- }
- nodeConfiguration.m_nodeSubStyle = ".nodeling";
- nodeConfiguration.m_titlePalette = "NodelingTitlePalette";
- nodeConfiguration.m_scriptCanvasId = nodeling->GetEntityId();
- AZ::SerializeContext* serializeContext = nullptr;
- AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationRequests::GetSerializeContext);
- AZ_Assert(serializeContext, "Failed to acquire application serialize context.");
- const AZ::SerializeContext::ClassData* classData = serializeContext->FindClassData(azrtti_typeid(nodeling));
- if (classData)
- {
- if (classData->m_editData)
- {
- const AZ::Edit::ElementData* elementData = classData->m_editData->FindElementData(AZ::Edit::ClassElements::EditorData);
- if (elementData)
- {
- if (auto nodeTypeAttribute = elementData->FindAttribute(ScriptCanvas::Attributes::Node::NodeType))
- {
- if (auto nodeTypeAttributeData = azdynamic_cast<const AZ::Edit::AttributeData<NodeType>*>(nodeTypeAttribute))
- {
- nodeConfiguration.m_nodeType = nodeTypeAttributeData->Get(nullptr);
- }
- }
- }
- }
- }
- return DisplayGeneralScriptCanvasNode(graphCanvasGraphId, nodeling, nodeConfiguration);
- }
- AZ::EntityId DisplayGetVariableNode(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Nodes::Core::GetVariableNode* variableNode)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- NodeReplacementConfiguration nodeConfiguration;
- nodeConfiguration.PopulateComponentDescriptors<IconComponent, DynamicSlotComponent, GetVariableNodeDescriptorComponent>();
- nodeConfiguration.m_nodeSubStyle = ".getVariable";
- nodeConfiguration.m_titlePalette = "GetVariableNodeTitlePalette";
- nodeConfiguration.m_scriptCanvasId = variableNode->GetEntityId();
- AZ::EntityId graphCanvasNodeId = DisplayGeneralScriptCanvasNode(graphCanvasGraphId, variableNode, nodeConfiguration);
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::ExecutionGroup, GraphCanvas::SlotGroupConfiguration(0));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::PropertyGroup, GraphCanvas::SlotGroupConfiguration(1));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasNodeId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::DataGroup, GraphCanvas::SlotGroupConfiguration(2));
- return graphCanvasNodeId;
- }
- AZ::EntityId DisplaySetVariableNode(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Nodes::Core::SetVariableNode* variableNode)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- NodeReplacementConfiguration nodeConfiguration;
- nodeConfiguration.PopulateComponentDescriptors<IconComponent, DynamicSlotComponent, SetVariableNodeDescriptorComponent>();
- nodeConfiguration.m_nodeSubStyle = ".setVariable";
- nodeConfiguration.m_titlePalette = "SetVariableNodeTitlePalette";
- nodeConfiguration.m_scriptCanvasId = variableNode->GetEntityId();
- AZ::EntityId graphCanvasId = DisplayGeneralScriptCanvasNode(graphCanvasGraphId, variableNode, nodeConfiguration);
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::ExecutionGroup, GraphCanvas::SlotGroupConfiguration(0));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::PropertyGroup, GraphCanvas::SlotGroupConfiguration(1));
- GraphCanvas::SlotLayoutRequestBus::Event(graphCanvasId, &GraphCanvas::SlotLayoutRequests::ConfigureSlotGroup, GraphCanvas::SlotGroups::DataGroup, GraphCanvas::SlotGroupConfiguration(2));
- return graphCanvasId;
- }
- ///////////////////
- // Header Methods
- ///////////////////
- AZ::EntityId DisplayScriptCanvasNode(AZ::EntityId graphCanvasGraphId, const ScriptCanvas::Node* node)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- AZ::EntityId graphCanvasNodeId;
- if (azrtti_istypeof<ScriptCanvas::Nodes::Core::SetVariableNode>(node))
- {
- graphCanvasNodeId = DisplaySetVariableNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::SetVariableNode*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::GetVariableNode>(node))
- {
- graphCanvasNodeId = DisplayGetVariableNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::GetVariableNode*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::Method>(node))
- {
- graphCanvasNodeId = DisplayMethodNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::Method*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::EBusEventHandler>(node))
- {
- graphCanvasNodeId = DisplayEbusWrapperNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::EBusEventHandler*>(node));
- }
- else if (auto azEventHandlerNode{ azrtti_cast<const ScriptCanvas::Nodes::Core::AzEventHandler*>(node) }; azEventHandlerNode != nullptr)
- {
- graphCanvasNodeId = DisplayAzEventHandlerNode(graphCanvasGraphId, azEventHandlerNode);
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::ReceiveScriptEvent>(node))
- {
- graphCanvasNodeId = DisplayScriptEventWrapperNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::ReceiveScriptEvent*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::SendScriptEvent>(node))
- {
- graphCanvasNodeId = DisplayScriptEventSenderNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::SendScriptEvent*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::FunctionCallNode>(node))
- {
- graphCanvasNodeId = DisplayFunctionNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::FunctionCallNode*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::FunctionDefinitionNode>(node))
- {
- graphCanvasNodeId = DisplayFunctionDefinitionNode(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::FunctionDefinitionNode*>(node));
- }
- else if (azrtti_istypeof<ScriptCanvas::Nodes::Core::Internal::Nodeling>(node))
- {
- graphCanvasNodeId = DisplayNodeling(graphCanvasGraphId, static_cast<const ScriptCanvas::Nodes::Core::Internal::Nodeling*>(node));
- }
- else if (node)
- {
- if (!node->GetNodeStyle().empty())
- {
- StyleConfiguration nodeConfiguration;
- nodeConfiguration.m_nodeSubStyle = node->GetNodeStyle();
- graphCanvasNodeId = DisplayNode(graphCanvasGraphId, node, nodeConfiguration);
- }
- else
- {
- graphCanvasNodeId = DisplayNode(graphCanvasGraphId, node);
- }
- }
- return graphCanvasNodeId;
- }
- static void RegisterAndActivateGraphCanvasSlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::SlotId& slotId, AZ::Entity* slotEntity)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- if (slotEntity)
- {
- slotEntity->Init();
- slotEntity->Activate();
- // Set the user data on the GraphCanvas slot to be the SlotId of the ScriptCanvas
- AZStd::any* slotUserData = nullptr;
- GraphCanvas::SlotRequestBus::EventResult(slotUserData, slotEntity->GetId(), &GraphCanvas::SlotRequests::GetUserData);
- if (slotUserData)
- {
- *slotUserData = slotId;
- }
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::AddSlot, slotEntity->GetId());
- }
- }
- static GraphCanvas::ConnectionType ToGraphCanvasConnectionType(ScriptCanvas::ConnectionType connectionType)
- {
- GraphCanvas::ConnectionType graphCanvasConnectionType = GraphCanvas::CT_Invalid;
- switch (connectionType)
- {
- case ScriptCanvas::ConnectionType::Input:
- graphCanvasConnectionType = GraphCanvas::CT_Input;
- break;
- case ScriptCanvas::ConnectionType::Output:
- graphCanvasConnectionType = GraphCanvas::CT_Output;
- break;
- default:
- break;
- }
- return graphCanvasConnectionType;
- }
- AZ::EntityId DisplayScriptCanvasSlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::Slot& slot, int slotIndex, GraphCanvas::SlotGroup slotGroup)
- {
- if (!slot.IsVisible())
- {
- return AZ::EntityId();
- }
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- AZ::Entity* slotEntity = nullptr;
- AZ::Uuid typeId = ScriptCanvas::Data::ToAZType(slot.GetDataType());
- if (slot.IsExecution())
- {
- GraphCanvas::ExecutionSlotConfiguration executionConfiguration;
- executionConfiguration.m_name = slot.GetName();
- executionConfiguration.m_tooltip = slot.GetToolTip();
- executionConfiguration.m_slotGroup = slotGroup;
- executionConfiguration.m_isNameHidden = slot.IsNameHidden();
- if (slot.IsLatent())
- {
- executionConfiguration.m_textDecoration = u8"\U0001f552";
- executionConfiguration.m_textDecorationToolTip = "This slot will not be executed immediately.";
- }
- if (slotGroup == GraphCanvas::SlotGroups::Invalid && slot.GetDisplayGroup() != AZ::Crc32())
- {
- executionConfiguration.m_slotGroup = slot.GetDisplayGroup();
- }
- executionConfiguration.m_connectionType = ToGraphCanvasConnectionType(slot.GetConnectionType());
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(slotEntity, &GraphCanvas::GraphCanvasRequests::CreateSlot, graphCanvasNodeId, executionConfiguration);
- }
- else if (slot.IsData())
- {
- GraphCanvas::DataSlotConfiguration dataSlotConfiguration;
- dataSlotConfiguration.m_typeId = typeId;
- dataSlotConfiguration.m_dataSlotType = GraphCanvas::DataSlotType::Value;
- dataSlotConfiguration.m_name = slot.GetName();
- dataSlotConfiguration.m_tooltip = slot.GetToolTip();
- dataSlotConfiguration.m_slotGroup = slotGroup;
- dataSlotConfiguration.m_isNameHidden = slot.IsNameHidden();
- if (slot.IsLatent())
- {
- dataSlotConfiguration.m_textDecoration = u8"\U0001f552";
- dataSlotConfiguration.m_textDecorationToolTip = "This slot will not be executed immediately.";
- }
- if (slotGroup == GraphCanvas::SlotGroups::Invalid && slot.GetDisplayGroup() != AZ::Crc32())
- {
- dataSlotConfiguration.m_slotGroup = slot.GetDisplayGroup();
- }
- dataSlotConfiguration.m_connectionType = ToGraphCanvasConnectionType(slot.GetConnectionType());
- if (ScriptCanvas::Data::IsContainerType(typeId))
- {
- dataSlotConfiguration.m_dataValueType = GraphCanvas::DataValueType::Container;
- dataSlotConfiguration.m_containerTypeIds = ScriptCanvas::Data::GetContainedTypes(typeId);
- }
- switch (slot.GetDynamicDataType())
- {
- case ScriptCanvas::DynamicDataType::Container:
- dataSlotConfiguration.m_dataValueType = GraphCanvas::DataValueType::Container;
- break;
- default:
- break;
- }
- if (slot.IsVariableReference())
- {
- dataSlotConfiguration.m_dataSlotType = GraphCanvas::DataSlotType::Reference;
- }
- dataSlotConfiguration.m_canConvertTypes = slot.CanConvertTypes();
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(slotEntity, &GraphCanvas::GraphCanvasRequests::CreateSlot, graphCanvasNodeId, dataSlotConfiguration);
- }
- if (slotEntity)
- {
- GraphCanvas::TranslationKey slotKey;
- slotKey << ScriptCanvasEditor::TranslationHelper::AssetContext::CustomNodeContext << azrtti_typeid(slot.GetNode()).ToString<AZStd::string>() << "slots";
- AZStd::string slotKeyStr;
- if (slot.IsData())
- {
- slotKeyStr.append("Data");
- }
- if (slot.GetConnectionType() == ScriptCanvas::ConnectionType::Input)
- {
- slotKeyStr.append("Input_");
- }
- else
- {
- slotKeyStr.append("Output_");
- }
- slotKeyStr.append(slot.GetName());
- slotKeyStr.append(AZStd::string::format("_%d", slotIndex));
- slotKey << slotKeyStr << "details";
- GraphCanvas::TranslationRequests::Details slotDetails;
- GraphCanvas::TranslationRequestBus::BroadcastResult(slotDetails, &GraphCanvas::TranslationRequests::GetDetails, slotKey, slotDetails);
- if (slotDetails.m_name.empty())
- {
- slotDetails.m_name = slot.GetName();
- }
- if (slotDetails.m_tooltip.empty())
- {
- slotDetails.m_tooltip = slot.GetToolTip();
- }
- GraphCanvas::SlotRequestBus::Event(slotEntity->GetId(), &GraphCanvas::SlotRequests::SetName, slotDetails.m_name);
- GraphCanvas::SlotRequestBus::Event(slotEntity->GetId(), &GraphCanvas::SlotRequests::SetTooltip, slotDetails.m_tooltip);
- RegisterAndActivateGraphCanvasSlot(graphCanvasNodeId, slot.GetId(), slotEntity);
- UpdateSlotDatumLabel(graphCanvasNodeId, slot.GetId(), slot.GetName());
- return slotEntity->GetId();
- }
- else
- {
- return AZ::EntityId();
- }
- }
- }
- namespace ScriptCanvasEditor::Nodes::SlotDisplayHelper
- {
- AZ::EntityId DisplayPropertySlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::VisualExtensionSlotConfiguration& propertyConfiguration)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- GraphCanvas::SlotConfiguration graphCanvasConfiguration;
- graphCanvasConfiguration.m_name = propertyConfiguration.m_name;
- graphCanvasConfiguration.m_tooltip = propertyConfiguration.m_tooltip;
- graphCanvasConfiguration.m_slotGroup = GraphCanvas::SlotGroup(propertyConfiguration.m_displayGroup);
- graphCanvasConfiguration.m_connectionType = ToGraphCanvasConnectionType(propertyConfiguration.m_connectionType);
- AZ::Entity* slotEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(slotEntity, &GraphCanvas::GraphCanvasRequests::CreatePropertySlot, graphCanvasNodeId, propertyConfiguration.m_identifier, graphCanvasConfiguration);
- if (slotEntity)
- {
- slotEntity->Init();
- slotEntity->Activate();
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::AddSlot, slotEntity->GetId());
- }
- return slotEntity ? slotEntity->GetId() : AZ::EntityId();
- }
- AZ::EntityId DisplayExtendableSlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::VisualExtensionSlotConfiguration& extenderConfiguration)
- {
- AZ_PROFILE_FUNCTION(ScriptCanvas);
- GraphCanvas::ExtenderSlotConfiguration graphCanvasConfiguration;
- graphCanvasConfiguration.m_name = extenderConfiguration.m_name;
- graphCanvasConfiguration.m_tooltip = extenderConfiguration.m_tooltip;
- graphCanvasConfiguration.m_slotGroup = GraphCanvas::SlotGroup(extenderConfiguration.m_displayGroup);
- graphCanvasConfiguration.m_connectionType = ToGraphCanvasConnectionType(extenderConfiguration.m_connectionType);
- graphCanvasConfiguration.m_extenderId = extenderConfiguration.m_identifier;
- AZ::Entity* slotEntity = nullptr;
- GraphCanvas::GraphCanvasRequestBus::BroadcastResult(slotEntity, &GraphCanvas::GraphCanvasRequests::CreateSlot, graphCanvasNodeId, graphCanvasConfiguration);
- if (slotEntity)
- {
- slotEntity->Init();
- slotEntity->Activate();
- GraphCanvas::NodeRequestBus::Event(graphCanvasNodeId, &GraphCanvas::NodeRequests::AddSlot, slotEntity->GetId());
- }
- return slotEntity ? slotEntity->GetId() : AZ::EntityId();
- }
- AZ::EntityId DisplayVisualExtensionSlot(AZ::EntityId graphCanvasNodeId, const ScriptCanvas::VisualExtensionSlotConfiguration& extensionConfiguration)
- {
- AZ::EntityId slotId;
- switch (extensionConfiguration.m_extensionType)
- {
- case ScriptCanvas::VisualExtensionSlotConfiguration::VisualExtensionType::ExtenderSlot:
- slotId = SlotDisplayHelper::DisplayExtendableSlot(graphCanvasNodeId, extensionConfiguration);
- break;
- case ScriptCanvas::VisualExtensionSlotConfiguration::VisualExtensionType::PropertySlot:
- slotId = SlotDisplayHelper::DisplayPropertySlot(graphCanvasNodeId, extensionConfiguration);
- break;
- default:
- break;
- }
- return slotId;
- }
- }
|