Fixed scoping rules for variables

This commit is contained in:
luissemp
2021-04-15 09:35:09 -07:00
parent fbe1b53617
commit 53e84b3820
16 changed files with 103 additions and 44 deletions
@@ -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;