Merge pull request #6232 from aws-lumberyard-dev/cgalvan/ReadOnlyPrefabWorkflowChanges

Some read-only prefab workflow updates.
This commit is contained in:
Chris Galvan
2021-12-07 19:38:54 -06:00
committed by GitHub
5 changed files with 87 additions and 16 deletions
@@ -25,6 +25,7 @@
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
#include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
#include <AzToolsFramework/Prefab/EditorPrefabComponent.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
#include <AzToolsFramework/Prefab/Instance/InstanceToTemplateInterface.h>
@@ -141,6 +142,9 @@ namespace AzToolsFramework
return;
}
m_readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get();
AZ_Assert(m_readOnlyEntityPublicInterface, "Prefab - could not get ReadOnlyEntityPublicInterface on PrefabIntegrationManager construction.");
// Get EditorEntityContextId
EditorEntityContextRequestBus::BroadcastResult(s_editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
@@ -263,6 +267,16 @@ namespace AzToolsFramework
AzFramework::ApplicationRequests::Bus::BroadcastResult(
prefabWipFeaturesEnabled, &AzFramework::ApplicationRequests::ArePrefabWipFeaturesEnabled);
bool readOnlyEntityInSelection = false;
for (const auto& entityId : selectedEntities)
{
if (m_readOnlyEntityPublicInterface->IsReadOnly(entityId))
{
readOnlyEntityInSelection = true;
break;
}
}
// Create Prefab
{
if (!selectedEntities.empty())
@@ -289,7 +303,8 @@ namespace AzToolsFramework
}
// Layers can't be in prefabs.
if (!layerInSelection)
// Also don't allow to create a prefab if any of the selected entities are read-only
if (!layerInSelection && !readOnlyEntityInSelection)
{
QAction* createAction = menu->addAction(QObject::tr("Create Prefab..."));
createAction->setToolTip(QObject::tr("Creates a prefab out of the currently selected entities."));
@@ -383,14 +398,13 @@ namespace AzToolsFramework
menu->addSeparator();
}
QAction* deleteAction = menu->addAction(QObject::tr("Delete"));
QObject::connect(deleteAction, &QAction::triggered, deleteAction, [] { ContextMenu_DeleteSelected(); });
if (selectedEntities.empty() ||
(selectedEntities.size() == 1 &&
selectedEntities[0] == s_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(s_editorEntityContextId)))
if (!selectedEntities.empty() &&
(selectedEntities.size() != 1 ||
selectedEntities[0] != s_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(s_editorEntityContextId)) &&
!readOnlyEntityInSelection)
{
deleteAction->setDisabled(true);
QAction* deleteAction = menu->addAction(QObject::tr("Delete"));
QObject::connect(deleteAction, &QAction::triggered, deleteAction, [] { ContextMenu_DeleteSelected(); });
}
// Detach Prefab
@@ -29,6 +29,7 @@
namespace AzToolsFramework
{
class ContainerEntityInterface;
class ReadOnlyEntityPublicInterface;
namespace Prefab
{
@@ -169,6 +170,8 @@ namespace AzToolsFramework
static PrefabLoaderInterface* s_prefabLoaderInterface;
static PrefabPublicInterface* s_prefabPublicInterface;
static PrefabSystemComponentInterface* s_prefabSystemComponentInterface;
ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
};
}
}