From 9dc32a0381845184d433c275fad29f5236ee9768 Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Wed, 8 Dec 2021 12:30:31 -0600 Subject: [PATCH 1/2] Additional read-only prefab workflow changes. Signed-off-by: Chris Galvan --- .../UI/Prefab/PrefabIntegrationManager.cpp | 18 ++++++++++-- .../EditorTransformComponentSelection.cpp | 29 ++++++++++++++++--- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp index d020391665..05d9f15b77 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp @@ -277,6 +277,8 @@ namespace AzToolsFramework } } + bool itemWasShown = false; + // Create Prefab { if (!selectedEntities.empty()) @@ -312,33 +314,43 @@ namespace AzToolsFramework QObject::connect(createAction, &QAction::triggered, createAction, [selectedEntities] { ContextMenu_CreatePrefab(selectedEntities); }); + + itemWasShown = true; } } } } // Instantiate Prefab + if (!readOnlyEntityInSelection) { QAction* instantiateAction = menu->addAction(QObject::tr("Instantiate Prefab...")); instantiateAction->setToolTip(QObject::tr("Instantiates a prefab file in the scene.")); QObject::connect( instantiateAction, &QAction::triggered, instantiateAction, [] { ContextMenu_InstantiatePrefab(); }); + + itemWasShown = true; } // Instantiate Procedural Prefab - if (AZ::Prefab::ProceduralPrefabAsset::UseProceduralPrefabs()) + if (AZ::Prefab::ProceduralPrefabAsset::UseProceduralPrefabs() && !readOnlyEntityInSelection) { QAction* action = menu->addAction(QObject::tr("Instantiate Procedural Prefab...")); action->setToolTip(QObject::tr("Instantiates a procedural prefab file in a prefab.")); QObject::connect( action, &QAction::triggered, action, [] { ContextMenu_InstantiateProceduralPrefab(); }); + + itemWasShown = true; } - menu->addSeparator(); + if (itemWasShown) + { + menu->addSeparator(); + } - bool itemWasShown = false; + itemWasShown = false; // Edit/Save Prefab { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index f54da3b089..0ba61202c6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -3238,13 +3238,34 @@ namespace AzToolsFramework void EditorTransformComponentSelection::PopulateEditorGlobalContextMenu( QMenu* menu, [[maybe_unused]] const AZ::Vector2& point, [[maybe_unused]] int flags) { - QAction* action = menu->addAction(QObject::tr(TogglePivotTitleRightClick)); - QObject::connect( - action, &QAction::triggered, action, - [this] + // Don't show the Toggle Pivot option if any read-only entities are in the current selection + // We need to request the selected entities instead of just using the m_selectedEntities variable + // because we filter out any read-only entities from the m_selectedEntities so that the maniuplators + // will be hidden + EntityIdList selectedEntityIds; + ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities); + + auto readOnlyEntityPublicInterface = AZ::Interface::Get(); + bool readOnlyEntityInSelection = false; + for (const auto& entityId : selectedEntityIds) + { + if (readOnlyEntityPublicInterface->IsReadOnly(entityId)) + { + readOnlyEntityInSelection = true; + break; + } + } + + if (!readOnlyEntityInSelection) + { + QAction* action = menu->addAction(QObject::tr(TogglePivotTitleRightClick)); + QObject::connect( + action, &QAction::triggered, action, + [this] { ToggleCenterPivotSelection(); }); + } } void EditorTransformComponentSelection::BeforeEntitySelectionChanged() From 1aed8392710694045247f0e597e198a39a4bd8a8 Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Wed, 8 Dec 2021 15:02:41 -0600 Subject: [PATCH 2/2] Fixed typo. Signed-off-by: Chris Galvan --- .../ViewportSelection/EditorTransformComponentSelection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index 0ba61202c6..03ab4c0f77 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -3240,7 +3240,7 @@ namespace AzToolsFramework { // Don't show the Toggle Pivot option if any read-only entities are in the current selection // We need to request the selected entities instead of just using the m_selectedEntities variable - // because we filter out any read-only entities from the m_selectedEntities so that the maniuplators + // because we filter out any read-only entities from the m_selectedEntities so that the manipulators // will be hidden EntityIdList selectedEntityIds; ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities);