Merge pull request #6911 from aws-lumberyard-dev/carlitosan-sc-bug-bash-4
Make SC User data slots proper, immutable variable references
This commit is contained in:
@@ -667,13 +667,12 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
|
||||
// Now that the slot has a valid type/name, we can actually promote it to a variable
|
||||
if (PromoteToVariableAction(endpoint) /*&& slot->IsVariableReference()*/)
|
||||
if (PromoteToVariableAction(endpoint, true))
|
||||
{
|
||||
ScriptCanvas::GraphVariable* variable = slot->GetVariable();
|
||||
|
||||
if (variable)
|
||||
{
|
||||
// functions 2.0 set variable scope to function
|
||||
if (variable->GetScope() != ScriptCanvas::VariableFlags::Scope::Function)
|
||||
{
|
||||
variable->SetScope(ScriptCanvas::VariableFlags::Scope::Function);
|
||||
@@ -1141,7 +1140,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (slot->IsVariableReference())
|
||||
{
|
||||
return true;
|
||||
return !slot->IsUserAdded();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1253,7 +1252,7 @@ namespace ScriptCanvasEditor
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (slot->IsVariableReference())
|
||||
if (slot->IsVariableReference() && !slot->IsUserAdded())
|
||||
{
|
||||
ScriptCanvasVariableReferenceDataInterface* dataInterface = aznew ScriptCanvasVariableReferenceDataInterface(&m_variableDataModel, GetScriptCanvasId(), scriptCanvasNodeId, scriptCanvasSlotId);
|
||||
GraphCanvas::NodePropertyDisplay* dataDisplay = nullptr;
|
||||
@@ -2081,20 +2080,20 @@ namespace ScriptCanvasEditor
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Graph::ConvertSlotToReference(const GraphCanvas::Endpoint& endpoint)
|
||||
bool Graph::ConvertSlotToReference(const GraphCanvas::Endpoint& endpoint, bool isNewSlot)
|
||||
{
|
||||
ScriptCanvas::Endpoint scEndpoint = ConvertToScriptCanvasEndpoint(endpoint);
|
||||
ScriptCanvas::Node* canvasNode = FindNode(scEndpoint.GetNodeId());
|
||||
|
||||
if (canvasNode)
|
||||
{
|
||||
return canvasNode->ConvertSlotToReference(scEndpoint.GetSlotId());
|
||||
return canvasNode->ConvertSlotToReference(scEndpoint.GetSlotId(), isNewSlot);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Graph::CanConvertSlotToReference(const GraphCanvas::Endpoint& endpoint)
|
||||
bool Graph::CanConvertSlotToReference(const GraphCanvas::Endpoint& endpoint, bool isNewSlot)
|
||||
{
|
||||
ScriptCanvas::Endpoint scEndpoint = ConvertToScriptCanvasEndpoint(endpoint);
|
||||
ScriptCanvas::Node* canvasNode = FindNode(scEndpoint.GetNodeId());
|
||||
@@ -2104,7 +2103,7 @@ namespace ScriptCanvasEditor
|
||||
ScriptCanvas::Slot* slot = canvasNode->GetSlot(scEndpoint.GetSlotId());
|
||||
if (slot)
|
||||
{
|
||||
return slot->CanConvertToReference();
|
||||
return slot->CanConvertToReference(isNewSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2170,7 +2169,7 @@ namespace ScriptCanvasEditor
|
||||
return handledEvent;
|
||||
}
|
||||
|
||||
bool Graph::CanPromoteToVariable(const GraphCanvas::Endpoint& endpoint) const
|
||||
bool Graph::CanPromoteToVariable(const GraphCanvas::Endpoint& endpoint, [[maybe_unused]] bool isNewSlot) const
|
||||
{
|
||||
ScriptCanvas::Endpoint scriptCanvasEndpoint = ConvertToScriptCanvasEndpoint(endpoint);
|
||||
auto activeSlot = FindSlot(scriptCanvasEndpoint);
|
||||
@@ -2189,7 +2188,7 @@ namespace ScriptCanvasEditor
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Graph::PromoteToVariableAction(const GraphCanvas::Endpoint& endpoint)
|
||||
bool Graph::PromoteToVariableAction(const GraphCanvas::Endpoint& endpoint, bool isNewSlot)
|
||||
{
|
||||
ScriptCanvas::Endpoint scriptCanvasEndpoint = ConvertToScriptCanvasEndpoint(endpoint);
|
||||
|
||||
@@ -2282,12 +2281,11 @@ 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, true);
|
||||
|
||||
if (addOutcome.IsSuccess())
|
||||
{
|
||||
GraphCanvas::DataSlotRequestBus::Event(endpoint.GetSlotId(), &GraphCanvas::DataSlotRequests::ConvertToReference);
|
||||
GraphCanvas::DataSlotRequestBus::Event(endpoint.GetSlotId(), &GraphCanvas::DataSlotRequests::ConvertToReference, isNewSlot);
|
||||
|
||||
activeSlot->SetVariableReference(addOutcome.GetValue());
|
||||
|
||||
@@ -2319,7 +2317,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (!targetSlot->IsVariableReference())
|
||||
{
|
||||
GraphCanvas::DataSlotRequestBus::Event(referenceTarget.GetSlotId(), &GraphCanvas::DataSlotRequests::ConvertToReference);
|
||||
GraphCanvas::DataSlotRequestBus::Event(referenceTarget.GetSlotId(), &GraphCanvas::DataSlotRequests::ConvertToReference, false);
|
||||
}
|
||||
|
||||
if (targetSlot->IsVariableReference())
|
||||
@@ -2884,7 +2882,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
for (auto graphCanvasEndpoint : referencableEndpoints)
|
||||
{
|
||||
GraphCanvas::DataSlotRequestBus::Event(graphCanvasEndpoint.GetSlotId(), &GraphCanvas::DataSlotRequests::ConvertToReference);
|
||||
GraphCanvas::DataSlotRequestBus::Event(graphCanvasEndpoint.GetSlotId(), &GraphCanvas::DataSlotRequests::ConvertToReference, false);
|
||||
|
||||
ScriptCanvas::Endpoint scriptCanvasEndpoint = ConvertToScriptCanvasEndpoint(graphCanvasEndpoint);
|
||||
|
||||
|
||||
@@ -175,12 +175,12 @@ namespace ScriptCanvasEditor
|
||||
void RemoveSlot(const GraphCanvas::Endpoint& endpoint) override;
|
||||
bool IsSlotRemovable(const GraphCanvas::Endpoint& endpoint) const override;
|
||||
|
||||
bool ConvertSlotToReference(const GraphCanvas::Endpoint& endpoint) override;
|
||||
bool CanConvertSlotToReference(const GraphCanvas::Endpoint& endpoint) override;
|
||||
bool ConvertSlotToReference(const GraphCanvas::Endpoint& endpoint, bool isNewSlot = false) override;
|
||||
bool CanConvertSlotToReference(const GraphCanvas::Endpoint& endpoint, bool isNewSlot = false) override;
|
||||
GraphCanvas::CanHandleMimeEventOutcome CanHandleReferenceMimeEvent(const GraphCanvas::Endpoint& endpoint, const QMimeData* mimeData) override;
|
||||
bool HandleReferenceMimeEvent(const GraphCanvas::Endpoint& endpoint, const QMimeData* mimeData) override;
|
||||
bool CanPromoteToVariable(const GraphCanvas::Endpoint& endpoint) const override;
|
||||
bool PromoteToVariableAction(const GraphCanvas::Endpoint& endpoint) override;
|
||||
bool CanPromoteToVariable(const GraphCanvas::Endpoint& endpoint, bool isNewSlot = false) const override;
|
||||
bool PromoteToVariableAction(const GraphCanvas::Endpoint& endpoint, bool isNewSlot = false) override;
|
||||
bool SynchronizeReferences(const GraphCanvas::Endpoint& sourceEndpoint, const GraphCanvas::Endpoint& targetEndpoint) override;
|
||||
|
||||
bool ConvertSlotToValue(const GraphCanvas::Endpoint& endpoint) override;
|
||||
|
||||
@@ -3873,7 +3873,13 @@ namespace ScriptCanvasEditor
|
||||
contextMenu.AddMenuAction(aznew ConvertReferenceToVariableNodeAction(&contextMenu));
|
||||
contextMenu.AddMenuAction(aznew ExposeSlotMenuAction(&contextMenu));
|
||||
contextMenu.AddMenuAction(aznew CreateAzEventHandlerSlotMenuAction(&contextMenu));
|
||||
contextMenu.AddMenuAction(aznew SetDataSlotTypeMenuAction(&contextMenu));
|
||||
|
||||
auto setSlotTypeAction = aznew SetDataSlotTypeMenuAction(&contextMenu);
|
||||
// Changing slot type is disabled temporarily because now that that user data slots are correctly coordinated with their reference
|
||||
// variables, their type cannot be changed. The next change will allow all variables to change their type post creation, and then
|
||||
// that will allow this action to be enabled.
|
||||
setSlotTypeAction->setEnabled(false);
|
||||
contextMenu.AddMenuAction(setSlotTypeAction);
|
||||
|
||||
return HandleContextMenu(contextMenu, slotId, screenPoint, scenePoint);
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ namespace ScriptCanvasEditor
|
||||
GraphCanvas::SlotRequestBus::EventResult(endpoint, slotId2, &GraphCanvas::SlotRequests::GetEndpoint);
|
||||
|
||||
bool promotedElement = false;
|
||||
GraphCanvas::GraphModelRequestBus::EventResult(promotedElement, graphId2, &GraphCanvas::GraphModelRequests::PromoteToVariableAction, endpoint);
|
||||
GraphCanvas::GraphModelRequestBus::EventResult(promotedElement, graphId2, &GraphCanvas::GraphModelRequests::PromoteToVariableAction, endpoint, false);
|
||||
|
||||
if (promotedElement)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user