Fixed scoping rules for variables
This commit is contained in:
+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;
|
||||
|
||||
Reference in New Issue
Block a user