Show detach prefab only when a single instance is selected

This commit is contained in:
srikappa
2021-05-28 02:14:28 -07:00
parent dc4a15628f
commit be6cee806d
2 changed files with 22 additions and 25 deletions
@@ -1155,19 +1155,6 @@ namespace AzToolsFramework
return AZ::Success();
}
void PrefabPublicHandler::ReplaceOldAliases(QString& stringToReplace, AZStd::string_view oldAlias, AZStd::string_view newAlias)
{
QString oldAliasQuotes = QString("\"%1\"").arg(oldAlias.data());
QString newAliasQuotes = QString("\"%1\"").arg(newAlias.data());
stringToReplace.replace(oldAliasQuotes, newAliasQuotes);
QString oldAliasPathRef = QString("/%1").arg(oldAlias.data());
QString newAliasPathRef = QString("/%1").arg(newAlias.data());
stringToReplace.replace(oldAliasPathRef, newAliasPathRef);
}
void PrefabPublicHandler::GenerateContainerEntityTransform(const EntityList& topLevelEntities,
AZ::Vector3& translation, AZ::Quaternion& rotation)
{
@@ -1418,5 +1405,18 @@ namespace AzToolsFramework
return true;
}
void PrefabPublicHandler::ReplaceOldAliases(QString& stringToReplace, AZStd::string_view oldAlias, AZStd::string_view newAlias)
{
QString oldAliasQuotes = QString("\"%1\"").arg(oldAlias.data());
QString newAliasQuotes = QString("\"%1\"").arg(newAlias.data());
stringToReplace.replace(oldAliasQuotes, newAliasQuotes);
QString oldAliasPathRef = QString("/%1").arg(oldAlias.data());
QString newAliasPathRef = QString("/%1").arg(newAlias.data());
stringToReplace.replace(oldAliasPathRef, newAliasPathRef);
}
} // namespace Prefab
} // namespace AzToolsFramework
@@ -238,24 +238,21 @@ namespace AzToolsFramework
deleteAction->setDisabled(true);
}
QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab..."));
if (selectedEntities.size() != 1)
{
detachPrefabAction->setDisabled(true);
}
else
// Detach Prefab
if (selectedEntities.size() == 1)
{
AZ::EntityId selectedEntity = selectedEntities[0];
if (s_prefabPublicInterface->IsInstanceContainerEntity(selectedEntity) &&
!s_prefabPublicInterface->IsLevelInstanceContainerEntity(selectedEntity))
{
QObject::connect(detachPrefabAction, &QAction::triggered, detachPrefabAction,
[this, selectedEntity] { ContextMenu_DetachPrefab(selectedEntity); });
}
else
{
detachPrefabAction->setDisabled(true);
QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab..."));
QObject::connect(
detachPrefabAction, &QAction::triggered, detachPrefabAction,
[this, selectedEntity]
{
ContextMenu_DetachPrefab(selectedEntity);
});
}
}
}