Merge branch 'main' of https://github.com/aws-lumberyard/o3de
This commit is contained in:
@@ -136,6 +136,48 @@ namespace AzToolsFramework
|
||||
return entity->GetName();
|
||||
}
|
||||
|
||||
EntityList EntityIdListToEntityList(const EntityIdList& inputEntityIds)
|
||||
{
|
||||
EntityList entities;
|
||||
entities.reserve(inputEntityIds.size());
|
||||
|
||||
for (AZ::EntityId entityId : inputEntityIds)
|
||||
{
|
||||
if (!entityId.IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto entity = GetEntityById(entityId))
|
||||
{
|
||||
entities.emplace_back(entity);
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
EntityList EntityIdSetToEntityList(const EntityIdSet& inputEntityIds)
|
||||
{
|
||||
EntityList entities;
|
||||
entities.reserve(inputEntityIds.size());
|
||||
|
||||
for (AZ::EntityId entityId : inputEntityIds)
|
||||
{
|
||||
if (!entityId.IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto entity = GetEntityById(entityId))
|
||||
{
|
||||
entities.emplace_back(entity);
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
void GetAllComponentsForEntity(const AZ::Entity* entity, AZ::Entity::ComponentArrayType& componentsOnEntity)
|
||||
{
|
||||
if (entity)
|
||||
@@ -1068,6 +1110,45 @@ namespace AzToolsFramework
|
||||
return !allEntityClonesContainer.m_entities.empty();
|
||||
}
|
||||
|
||||
EntityIdSet GetCulledEntityHierarchy(const EntityIdList& entities)
|
||||
{
|
||||
EntityIdSet culledEntities;
|
||||
|
||||
for (const AZ::EntityId& entityId : entities)
|
||||
{
|
||||
bool selectionIncludesTransformHeritage = false;
|
||||
AZ::EntityId parentEntityId = entityId;
|
||||
do
|
||||
{
|
||||
AZ::EntityId nextParentId;
|
||||
AZ::TransformBus::EventResult(
|
||||
/*result*/ nextParentId,
|
||||
/*address*/ parentEntityId,
|
||||
&AZ::TransformBus::Events::GetParentId);
|
||||
parentEntityId = nextParentId;
|
||||
if (!parentEntityId.IsValid())
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (const AZ::EntityId& parentCheck : entities)
|
||||
{
|
||||
if (parentCheck == parentEntityId)
|
||||
{
|
||||
selectionIncludesTransformHeritage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (parentEntityId.IsValid() && !selectionIncludesTransformHeritage);
|
||||
|
||||
if (!selectionIncludesTransformHeritage)
|
||||
{
|
||||
culledEntities.insert(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
return culledEntities;
|
||||
}
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
void CloneSliceEntitiesAndChildren(
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace AzToolsFramework
|
||||
|
||||
AZStd::string GetEntityName(const AZ::EntityId& entityId, const AZStd::string_view& nameOverride = {});
|
||||
|
||||
EntityList EntityIdListToEntityList(const EntityIdList& inputEntityIds);
|
||||
EntityList EntityIdSetToEntityList(const EntityIdSet& inputEntityIds);
|
||||
|
||||
template <typename... ComponentTypes>
|
||||
struct AddComponents
|
||||
{
|
||||
@@ -202,4 +205,8 @@ namespace AzToolsFramework
|
||||
/// Wrap EBus SetSelectedEntities call.
|
||||
void SelectEntities(const AzToolsFramework::EntityIdList& entities);
|
||||
|
||||
/// Return a set of entities, culling any that have an ancestor in the list.
|
||||
/// e.g. This is useful for getting a concise set of entities that need to be duplicated.
|
||||
EntityIdSet GetCulledEntityHierarchy(const EntityIdList& entities);
|
||||
|
||||
}; // namespace AzToolsFramework
|
||||
|
||||
@@ -61,8 +61,7 @@ namespace AzToolsFramework
|
||||
PrefabOperationResult PrefabPublicHandler::CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath)
|
||||
{
|
||||
// Retrieve entityList from entityIds
|
||||
EntityList inputEntityList;
|
||||
EntityIdListToEntityList(entityIds, inputEntityList);
|
||||
EntityList inputEntityList = EntityIdListToEntityList(entityIds);
|
||||
|
||||
// Find common root and top level entities
|
||||
bool entitiesHaveCommonRoot = false;
|
||||
@@ -419,8 +418,7 @@ namespace AzToolsFramework
|
||||
InstanceOptionalReference instance = GetOwnerInstanceByEntityId(entityIds[0]);
|
||||
|
||||
// Retrieve entityList from entityIds
|
||||
EntityList inputEntityList;
|
||||
EntityIdListToEntityList(entityIds, inputEntityList);
|
||||
EntityList inputEntityList = EntityIdListToEntityList(entityIds);
|
||||
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
@@ -767,18 +765,5 @@ namespace AzToolsFramework
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrefabPublicHandler::EntityIdListToEntityList(const EntityIdList& inputEntityIds, EntityList& outEntities)
|
||||
{
|
||||
outEntities.reserve(inputEntityIds.size());
|
||||
|
||||
for (AZ::EntityId entityId : inputEntityIds)
|
||||
{
|
||||
if (entityId.IsValid())
|
||||
{
|
||||
outEntities.emplace_back(GetEntityById(entityId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace AzToolsFramework
|
||||
static Instance* GetParentInstance(Instance* instance);
|
||||
static Instance* GetAncestorOfInstanceThatIsChildOfRoot(const Instance* ancestor, Instance* descendant);
|
||||
static void GenerateContainerEntityTransform(const EntityList& topLevelEntities, AZ::Vector3& translation, AZ::Quaternion& rotation);
|
||||
static void EntityIdListToEntityList(const EntityIdList& inputEntityIds, EntityList& outEntities);
|
||||
|
||||
InstanceEntityMapperInterface* m_instanceEntityMapperInterface = nullptr;
|
||||
InstanceToTemplateInterface* m_instanceToTemplateInterface = nullptr;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 <AzTest/AzTest.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class EditorEntityHelpersTest
|
||||
: public ToolsApplicationFixture
|
||||
{
|
||||
void SetUpEditorFixtureImpl() override
|
||||
{
|
||||
m_parent1 = CreateDefaultEditorEntity("Parent1");
|
||||
m_child1 = CreateDefaultEditorEntity("Child1");
|
||||
m_child2 = CreateDefaultEditorEntity("Child2");
|
||||
m_grandChild1 = CreateDefaultEditorEntity("GrandChild1");
|
||||
m_parent2 = CreateDefaultEditorEntity("Parent2");
|
||||
|
||||
AZ::TransformBus::Event(m_child1, &AZ::TransformBus::Events::SetParent, m_parent1);
|
||||
AZ::TransformBus::Event(m_child2, &AZ::TransformBus::Events::SetParent, m_parent1);
|
||||
AZ::TransformBus::Event(m_grandChild1, &AZ::TransformBus::Events::SetParent, m_child1);
|
||||
}
|
||||
|
||||
public:
|
||||
AZ::EntityId m_parent1;
|
||||
AZ::EntityId m_child1;
|
||||
AZ::EntityId m_child2;
|
||||
AZ::EntityId m_grandChild1;
|
||||
AZ::EntityId m_parent2;
|
||||
};
|
||||
|
||||
TEST_F(EditorEntityHelpersTest, EditorEntityHelpersTests_GetCulledEntityHierarchy)
|
||||
{
|
||||
AzToolsFramework::EntityIdList testEntityIds{ m_parent1, m_child1, m_child2, m_grandChild1, m_parent2 };
|
||||
|
||||
AzToolsFramework::EntityIdSet culledSet = AzToolsFramework::GetCulledEntityHierarchy(testEntityIds);
|
||||
|
||||
// There should only be two EntityIds returned (m_parent1, and m_parent2),
|
||||
// since all the others should be culled out since they have a common ancestor
|
||||
// in the list already
|
||||
using ::testing::UnorderedElementsAre;
|
||||
EXPECT_THAT(culledSet, UnorderedElementsAre(m_parent1, m_parent2));
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,9 @@ set(FILES
|
||||
Prefab/SpawnableSortEntitiesTestFixture.cpp
|
||||
Prefab/SpawnableSortEntitiesTestFixture.h
|
||||
Entity/EditorEntityContextComponentTests.cpp
|
||||
Entity/EditorEntityHelpersTests.cpp
|
||||
Entity/EditorEntitySearchComponentTests.cpp
|
||||
Entity/EditorEntitySelectionTests.cpp
|
||||
SliceStabilityTests/SliceStabilityTestFramework.h
|
||||
SliceStabilityTests/SliceStabilityTestFramework.cpp
|
||||
SliceStabilityTests/SliceStabilityCreateTests.cpp
|
||||
|
||||
@@ -670,9 +670,13 @@ void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, con
|
||||
action = menu->addAction(QObject::tr("Create layer"));
|
||||
QObject::connect(action, &QAction::triggered, [this] { ContextMenu_NewLayer(); });
|
||||
|
||||
AzToolsFramework::EntityIdList entities;
|
||||
AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(
|
||||
entities,
|
||||
&AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
SetupLayerContextMenu(menu);
|
||||
AzToolsFramework::EntityIdSet flattenedSelection;
|
||||
GetSelectedEntitiesSetWithFlattenedHierarchy(flattenedSelection);
|
||||
AzToolsFramework::EntityIdSet flattenedSelection = AzToolsFramework::GetCulledEntityHierarchy(entities);
|
||||
AzToolsFramework::SetupAddToLayerMenu(menu, flattenedSelection, [this] { return ContextMenu_NewLayer(); });
|
||||
|
||||
SetupSliceContextMenu(menu);
|
||||
@@ -1220,10 +1224,14 @@ void SandboxIntegrationManager::CloneSelection(bool& handled)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
AzToolsFramework::EntityIdSet duplicationSet;
|
||||
GetSelectedEntitiesSetWithFlattenedHierarchy(duplicationSet);
|
||||
AzToolsFramework::EntityIdList entities;
|
||||
AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(
|
||||
entities,
|
||||
&AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
if (duplicationSet.size() > 0)
|
||||
AzToolsFramework::EntityIdSet duplicationSet = AzToolsFramework::GetCulledEntityHierarchy(entities);
|
||||
|
||||
if (!duplicationSet.empty())
|
||||
{
|
||||
AZStd::unordered_set<AZ::EntityId> clonedEntities;
|
||||
handled = AzToolsFramework::CloneInstantiatedEntities(duplicationSet, clonedEntities);
|
||||
|
||||
@@ -437,5 +437,7 @@ namespace GraphCanvas
|
||||
default:
|
||||
return QGraphicsWidget::sizeHint(which, constraint);
|
||||
}
|
||||
|
||||
return QGraphicsWidget::sizeHint(which, constraint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2347,7 +2347,7 @@ namespace ScriptCanvasEditor
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string> addOutcome;
|
||||
|
||||
// #functions2 slot<->variable re-use the activeDatum, send the pointer (actually, all of the source slot information, and make a special conversion)
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(addOutcome, GetScriptCanvasId(), &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, variableDatum);
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(addOutcome, GetScriptCanvasId(), &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, variableDatum, true);
|
||||
|
||||
if (addOutcome.IsSuccess())
|
||||
{
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
ScriptCanvas::Datum datum = ScriptCanvas::Datum(entityId);
|
||||
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string > addVariableOutcome = variableManagerRequests->AddVariable(variableName, datum);
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string > addVariableOutcome = variableManagerRequests->AddVariable(variableName, datum, false);
|
||||
|
||||
if (addVariableOutcome.IsSuccess())
|
||||
{
|
||||
|
||||
@@ -578,6 +578,14 @@ namespace
|
||||
categoryPath.append(displayName.c_str());
|
||||
}
|
||||
|
||||
for (auto property : behaviorClass->m_properties)
|
||||
{
|
||||
if (property.second->m_setter)
|
||||
{
|
||||
RegisterMethod(nodePaletteModel, behaviorContext, categoryPath, behaviorClass, property.first, *property.second->m_setter, behaviorClass->IsMethodOverloaded(property.first));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto methodIter : behaviorClass->m_methods)
|
||||
{
|
||||
if (!IsExplicitOverload(*methodIter.second))
|
||||
|
||||
+1
-1
@@ -1011,7 +1011,7 @@ namespace ScriptCanvasEditor
|
||||
ScriptCanvas::Datum datum(variableType, ScriptCanvas::Datum::eOriginality::Original);
|
||||
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string> outcome = AZ::Failure(AZStd::string());
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_activeGraphIds.scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, varName, datum);
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_activeGraphIds.scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, varName, datum, false);
|
||||
|
||||
if (outcome.IsSuccess())
|
||||
{
|
||||
|
||||
+28
-1
@@ -41,6 +41,7 @@
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <ScriptCanvas/Variable/GraphVariable.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
@@ -538,7 +539,24 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
else if (index.column() == ColumnIndex::Scope)
|
||||
{
|
||||
// Scope is not changed by users
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, varId.m_identifier);
|
||||
|
||||
if (graphVariable)
|
||||
{
|
||||
QString comboBoxValue = value.toString();
|
||||
|
||||
if (!comboBoxValue.isEmpty())
|
||||
{
|
||||
AZStd::string scopeLabel = ScriptCanvas::VariableFlags::GetScopeDisplayLabel(graphVariable->GetScope());
|
||||
if (scopeLabel.compare(comboBoxValue.toUtf8().data()) != 0)
|
||||
{
|
||||
modifiedData = true;
|
||||
graphVariable->SetScope(ScriptCanvas::VariableFlags::GetScopeFromLabel(comboBoxValue.toUtf8().data()));
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestRefresh, AzToolsFramework::Refresh_EntireTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (index.column() == ColumnIndex::InitialValueSource)
|
||||
{
|
||||
@@ -607,8 +625,17 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
else if (index.column() == ColumnIndex::Scope)
|
||||
{
|
||||
ScriptCanvas::GraphScopedVariableId varId = FindScopedVariableIdForIndex(index);
|
||||
|
||||
ScriptCanvas::GraphVariable* graphVariable = nullptr;
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(graphVariable, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::FindVariableById, varId.m_identifier);
|
||||
|
||||
if (graphVariable->GetScope() != ScriptCanvas::VariableFlags::Scope::FunctionReadOnly)
|
||||
{
|
||||
itemFlags |= Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
}
|
||||
else if (index.column() == ColumnIndex::InitialValueSource)
|
||||
{
|
||||
itemFlags |= Qt::ItemIsEditable;
|
||||
|
||||
@@ -73,6 +73,8 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->variablePalette->SetActiveScene(scriptCanvasId);
|
||||
|
||||
ui->searchFilter->setClearButtonEnabled(true);
|
||||
QObject::connect(ui->searchFilter, &QLineEdit::textChanged, this, &SlotTypeSelectorWidget::OnQuickFilterChanged);
|
||||
QObject::connect(ui->slotName, &QLineEdit::returnPressed, this, &SlotTypeSelectorWidget::OnReturnPressed);
|
||||
|
||||
@@ -812,7 +812,7 @@ namespace ScriptCanvasEditor
|
||||
ScriptCanvas::Datum datum(varType, ScriptCanvas::Datum::eOriginality::Original);
|
||||
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string> outcome = AZ::Failure(AZStd::string());
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, datum);
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, datum, false);
|
||||
|
||||
AZ_Warning("VariablePanel", outcome.IsSuccess(), "Could not create new variable: %s", outcome.GetError().c_str());
|
||||
GeneralRequestBus::Broadcast(&GeneralRequests::PostUndoPoint, m_scriptCanvasId);
|
||||
|
||||
@@ -81,6 +81,8 @@ namespace ScriptCanvas
|
||||
{
|
||||
return ConstructCustomNodeIdentifier(scriptCanvasNode->RTTI_GetType());
|
||||
}
|
||||
|
||||
return NodeTypeIdentifier(0);
|
||||
}
|
||||
|
||||
NodeTypeIdentifier NodeUtils::ConstructEBusIdentifier(ScriptCanvas::EBusBusId ebusIdentifier)
|
||||
|
||||
@@ -43,20 +43,12 @@ namespace ScriptCanvas
|
||||
{
|
||||
const char* GetScopeDisplayLabel(Scope scopeType)
|
||||
{
|
||||
switch (scopeType)
|
||||
{
|
||||
case Scope::Graph:
|
||||
return "Graph";
|
||||
case Scope::Function:
|
||||
return "Function";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
return GraphVariable::s_ScopeNames[static_cast<int>(scopeType)];
|
||||
}
|
||||
|
||||
Scope GetScopeFromLabel(const char* label)
|
||||
{
|
||||
if (strcmp("Function", label) == 0)
|
||||
if (strcmp(GraphVariable::s_ScopeNames[static_cast<int>(VariableFlags::Scope::Function)], label) == 0)
|
||||
{
|
||||
return Scope::Function;
|
||||
}
|
||||
@@ -71,6 +63,7 @@ namespace ScriptCanvas
|
||||
case Scope::Graph:
|
||||
return "Variable is accessible in the entire graph.";
|
||||
case Scope::Function:
|
||||
case Scope::FunctionReadOnly:
|
||||
return "Variable is accessible only in the execution path of the function that defined it";
|
||||
default:
|
||||
return "?";
|
||||
@@ -162,6 +155,14 @@ namespace ScriptCanvas
|
||||
"From Component"
|
||||
};
|
||||
|
||||
const char* GraphVariable::s_ScopeNames[static_cast<int>(VariableFlags::Scope::COUNT)] =
|
||||
{
|
||||
"Graph",
|
||||
"Function",
|
||||
"Function",
|
||||
};
|
||||
|
||||
|
||||
void GraphVariable::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
@@ -197,6 +198,13 @@ namespace ScriptCanvas
|
||||
return choices;
|
||||
};
|
||||
|
||||
auto scopeChoices = [] {
|
||||
AZStd::vector< AZStd::pair<VariableFlags::Scope, AZStd::string>> choices;
|
||||
choices.emplace_back(AZStd::make_pair(VariableFlags::Scope::Graph, s_ScopeNames[0]));
|
||||
choices.emplace_back(AZStd::make_pair(VariableFlags::Scope::Function, s_ScopeNames[1]));
|
||||
return choices;
|
||||
};
|
||||
|
||||
editContext->Class<GraphVariable>("Variable", "Represents a Variable field within a Script Canvas Graph")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &GraphVariable::GetVisibility)
|
||||
@@ -215,8 +223,8 @@ namespace ScriptCanvas
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &GraphVariable::OnValueChanged)
|
||||
|
||||
->DataElement(AZ::Edit::UIHandlers::ComboBox, &GraphVariable::m_scope, "Scope", "Controls the scope of this variable. i.e. If this is exposed as input to this script, or output from this script, or if the variable is just locally scoped.")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &GraphVariable::GetInputControlVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::GenericValueList, &GraphVariable::GetScopes)
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, &GraphVariable::GetScopeControlVisibility)
|
||||
->Attribute(AZ::Edit::Attributes::GenericValueList, scopeChoices)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &GraphVariable::OnScopeTypedChanged)
|
||||
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &GraphVariable::m_networkProperties, "Network Properties", "Enables whether or not this value should be network synchronized")
|
||||
@@ -382,6 +390,16 @@ namespace ScriptCanvas
|
||||
m_inputControlVisibility = inputControlVisibility;
|
||||
}
|
||||
|
||||
AZ::Crc32 GraphVariable::GetScopeControlVisibility() const
|
||||
{
|
||||
if (m_scope == VariableFlags::Scope::FunctionReadOnly)
|
||||
{
|
||||
return AZ::Edit::PropertyVisibility::Hide;
|
||||
}
|
||||
|
||||
return GetInputControlVisibility();
|
||||
}
|
||||
|
||||
AZ::Crc32 GraphVariable::GetInputControlVisibility() const
|
||||
{
|
||||
return m_inputControlVisibility;
|
||||
@@ -462,6 +480,8 @@ namespace ScriptCanvas
|
||||
return m_scope == VariableFlags::Scope::Graph;
|
||||
// All graph variables are in function local scope
|
||||
case VariableFlags::Scope::Function:
|
||||
case VariableFlags::Scope::FunctionReadOnly:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,10 @@ namespace ScriptCanvas
|
||||
|
||||
enum class Scope : AZ::u8
|
||||
{
|
||||
Graph = 0,
|
||||
Function = 1,
|
||||
Graph,
|
||||
Function,
|
||||
FunctionReadOnly,
|
||||
COUNT
|
||||
};
|
||||
|
||||
enum InitialValueSource : AZ::u8
|
||||
@@ -142,6 +144,7 @@ namespace ScriptCanvas
|
||||
void SetScriptInputControlVisibility(const AZ::Crc32& inputControlVisibility);
|
||||
|
||||
AZ::Crc32 GetInputControlVisibility() const;
|
||||
AZ::Crc32 GetScopeControlVisibility() const;
|
||||
AZ::Crc32 GetScriptInputControlVisibility() const;
|
||||
AZ::Crc32 GetNetworkSettingsVisibility() const;
|
||||
AZ::Crc32 GetFunctionInputControlVisibility() const;
|
||||
@@ -181,6 +184,7 @@ namespace ScriptCanvas
|
||||
int GetSortPriority() const;
|
||||
|
||||
static const char* s_InitialValueSourceNames[VariableFlags::InitialValueSource::COUNT];
|
||||
static const char* s_ScopeNames[static_cast<int>(VariableFlags::Scope::COUNT)];
|
||||
|
||||
private:
|
||||
|
||||
|
||||
+6
-2
@@ -225,7 +225,7 @@ namespace ScriptCanvas
|
||||
}
|
||||
|
||||
// #functions2 slot<->variable add this to the graph, using the old datum
|
||||
AZ::Outcome<VariableId, AZStd::string> GraphVariableManagerComponent::AddVariable(AZStd::string_view name, const Datum& value)
|
||||
AZ::Outcome<VariableId, AZStd::string> GraphVariableManagerComponent::AddVariable(AZStd::string_view name, const Datum& value, bool functionScope)
|
||||
{
|
||||
if (FindVariable(name))
|
||||
{
|
||||
@@ -245,6 +245,10 @@ namespace ScriptCanvas
|
||||
|
||||
GraphVariable* variable = m_variableData.FindVariable(newId);
|
||||
variable->SetOwningScriptCanvasId(GetScriptCanvasId());
|
||||
if (functionScope)
|
||||
{
|
||||
variable->SetScope(VariableFlags::Scope::FunctionReadOnly);
|
||||
}
|
||||
|
||||
VariableRequestBus::MultiHandler::BusConnect(GraphScopedVariableId(m_scriptCanvasId, newId));
|
||||
GraphVariableManagerNotificationBus::Event(GetScriptCanvasId(), &GraphVariableManagerNotifications::OnVariableAddedToGraph, newId, name);
|
||||
@@ -254,7 +258,7 @@ namespace ScriptCanvas
|
||||
|
||||
AZ::Outcome<VariableId, AZStd::string> GraphVariableManagerComponent::AddVariablePair(const AZStd::pair<AZStd::string_view, Datum>& keyValuePair)
|
||||
{
|
||||
return AddVariable(keyValuePair.first, keyValuePair.second);
|
||||
return AddVariable(keyValuePair.first, keyValuePair.second, false);
|
||||
}
|
||||
|
||||
VariableValidationOutcome GraphVariableManagerComponent::IsNameValid(AZStd::string_view varName)
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ namespace ScriptCanvas
|
||||
//// GraphVariableManagerRequestBus
|
||||
AZ::Outcome<VariableId, AZStd::string> CloneVariable(const GraphVariable& variableConfiguration) override;
|
||||
AZ::Outcome<VariableId, AZStd::string> RemapVariable(const GraphVariable& variableConfiguration) override;
|
||||
AZ::Outcome<VariableId, AZStd::string> AddVariable(AZStd::string_view name, const Datum& value) override;
|
||||
AZ::Outcome<VariableId, AZStd::string> AddVariable(AZStd::string_view name, const Datum& value, bool functionScope) override;
|
||||
AZ::Outcome<VariableId, AZStd::string> AddVariablePair(const AZStd::pair<AZStd::string_view, Datum>& nameValuePair) override;
|
||||
|
||||
VariableValidationOutcome IsNameValid(AZStd::string_view key) override;
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace ScriptCanvas
|
||||
//! returns an AZ::Outcome which on success contains the VariableId and on Failure contains a string with error information
|
||||
virtual AZ::Outcome<VariableId, AZStd::string> CloneVariable(const GraphVariable& baseVariable) = 0;
|
||||
virtual AZ::Outcome<VariableId, AZStd::string> RemapVariable(const GraphVariable& variableConfiguration) = 0;
|
||||
virtual AZ::Outcome<VariableId, AZStd::string> AddVariable(AZStd::string_view key, const Datum& value) = 0;
|
||||
virtual AZ::Outcome<VariableId, AZStd::string> AddVariable(AZStd::string_view key, const Datum& value, bool functionScope) = 0;
|
||||
virtual AZ::Outcome<VariableId, AZStd::string> AddVariablePair(const AZStd::pair<AZStd::string_view, Datum>& keyValuePair) = 0;
|
||||
|
||||
virtual VariableValidationOutcome IsNameValid(AZStd::string_view variableName) = 0;
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ namespace ScriptCanvasDeveloperEditor
|
||||
ScriptCanvas::Datum datum(dataType, ScriptCanvas::Datum::eOriginality::Original);
|
||||
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string> outcome = AZ::Failure(AZStd::string());
|
||||
m_variableRequests->AddVariable(variableName, datum);
|
||||
m_variableRequests->AddVariable(variableName, datum, false);
|
||||
|
||||
++m_variableCounter;
|
||||
}
|
||||
|
||||
+2
-2
@@ -144,7 +144,7 @@ namespace ScriptCanvasDeveloper
|
||||
{
|
||||
ScriptCanvasEditor::SceneCounterRequestBus::EventResult(variableCounter, m_scriptCanvasId, &ScriptCanvasEditor::SceneCounterRequests::GetNewVariableCounter);
|
||||
|
||||
// Cribbed from VariableDockWidget. Shuld always be in sync with that.
|
||||
// From VariableDockWidget, Should always be in sync with that.
|
||||
variableName = AZStd::string::format("Variable %u", variableCounter);
|
||||
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(nameAvailable, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::IsNameAvailable, variableName);
|
||||
@@ -154,7 +154,7 @@ namespace ScriptCanvasDeveloper
|
||||
ScriptCanvas::Datum datum(m_dataType, ScriptCanvas::Datum::eOriginality::Original);
|
||||
|
||||
AZ::Outcome<ScriptCanvas::VariableId, AZStd::string> outcome = AZ::Failure(AZStd::string());
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, datum);
|
||||
ScriptCanvas::GraphVariableManagerRequestBus::EventResult(outcome, m_scriptCanvasId, &ScriptCanvas::GraphVariableManagerRequests::AddVariable, variableName, datum, false);
|
||||
|
||||
if (outcome)
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace ScriptCanvasTests
|
||||
{
|
||||
using namespace ScriptCanvas;
|
||||
AZ::Outcome<VariableId, AZStd::string> addVariableOutcome = AZ::Failure(AZStd::string());
|
||||
GraphVariableManagerRequestBus::EventResult(addVariableOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, variableName, Datum(value));
|
||||
GraphVariableManagerRequestBus::EventResult(addVariableOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, variableName, Datum(value), false);
|
||||
if (!addVariableOutcome)
|
||||
{
|
||||
AZ_Warning("Script Canvas Test", false, "%s", addVariableOutcome.GetError().data());
|
||||
|
||||
@@ -104,27 +104,27 @@ TEST_F(ScriptCanvasTestFixture, CreateVariableTest)
|
||||
auto stringArrayDatum = Datum(StringArray());
|
||||
|
||||
AZ::Outcome<VariableId, AZStd::string> addPropertyOutcome(AZ::Failure(AZStd::string("Uninitialized")));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector3", vector3Datum1);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector3", vector3Datum1, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "SecondVector3", vector3Datum2);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "SecondVector3", vector3Datum2, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector4", vector4Datum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector4", vector4Datum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "My String Array", stringArrayDatum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "My String Array", stringArrayDatum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
@@ -169,12 +169,12 @@ TEST_F(ScriptCanvasTestFixture, AddVariableFailTest)
|
||||
const AZStd::string_view propertyName = "SameName";
|
||||
|
||||
AZ::Outcome<VariableId, AZStd::string> addPropertyOutcome(AZ::Failure(AZStd::string("Uninitialized")));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, vector3Datum1);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, vector3Datum1, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, vector3Datum2);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, vector3Datum2, false);
|
||||
EXPECT_FALSE(addPropertyOutcome);
|
||||
|
||||
propertyEntity.reset();
|
||||
@@ -208,35 +208,35 @@ TEST_F(ScriptCanvasTestFixture, RemoveVariableTest)
|
||||
|
||||
size_t numVariablesAdded = 0U;
|
||||
AZ::Outcome<VariableId, AZStd::string> addPropertyOutcome(AZ::Failure(AZStd::string("Uninitialized")));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector3", vector3Datum1);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector3", vector3Datum1, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId firstVector3Id = addPropertyOutcome.GetValue();
|
||||
++numVariablesAdded;
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "SecondVector3", vector3Datum2);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "SecondVector3", vector3Datum2, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId secondVector3Id = addPropertyOutcome.GetValue();
|
||||
++numVariablesAdded;
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector4", vector4Datum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector4", vector4Datum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId firstVector4Id = addPropertyOutcome.GetValue();
|
||||
++numVariablesAdded;
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId projectionMatrixId = addPropertyOutcome.GetValue();
|
||||
++numVariablesAdded;
|
||||
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "My String Array", stringArrayDatum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "My String Array", stringArrayDatum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId stringArrayId = addPropertyOutcome.GetValue();
|
||||
@@ -294,7 +294,7 @@ TEST_F(ScriptCanvasTestFixture, RemoveVariableTest)
|
||||
{
|
||||
// Re-add removed Property
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
@@ -332,7 +332,7 @@ TEST_F(ScriptCanvasTestFixture, FindVariableTest)
|
||||
const AZStd::string_view propertyName = "StringProperty";
|
||||
|
||||
AZ::Outcome<VariableId, AZStd::string> addPropertyOutcome(AZ::Failure(AZStd::string("Uninitialized")));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, stringVariableDatum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, stringVariableDatum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId stringVariableId = addPropertyOutcome.GetValue();
|
||||
@@ -391,7 +391,7 @@ TEST_F(ScriptCanvasTestFixture, ModifyVariableTest)
|
||||
const AZStd::string_view propertyName = "StringProperty";
|
||||
|
||||
AZ::Outcome<VariableId, AZStd::string> addPropertyOutcome(AZ::Failure(AZStd::string("Uninitialized")));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, stringVariableDatum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, propertyName, stringVariableDatum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
const VariableId stringVariableId = addPropertyOutcome.GetValue();
|
||||
@@ -449,7 +449,7 @@ TEST_F(ScriptCanvasTestFixture, SerializationTest)
|
||||
auto stringArrayDatum = Datum(StringArray());
|
||||
|
||||
AZ::Outcome<VariableId, AZStd::string> addPropertyOutcome(AZ::Failure(AZStd::string("Uninitialized")));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "My String Array", stringArrayDatum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "My String Array", stringArrayDatum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
@@ -493,7 +493,7 @@ TEST_F(ScriptCanvasTestFixture, SerializationTest)
|
||||
|
||||
auto identityMatrixDatum = Datum(Data::Matrix3x3Type::CreateIdentity());
|
||||
addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized"));
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "Super Matrix Bros", identityMatrixDatum);
|
||||
GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "Super Matrix Bros", identityMatrixDatum, false);
|
||||
EXPECT_TRUE(addPropertyOutcome);
|
||||
EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user