Updated Entity Inspector to changed behavior when an Entity has been marked as read-only.
Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
+37
-2
@@ -45,6 +45,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h>
|
||||
#include <AzToolsFramework/ComponentMode/ComponentModeDelegate.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabFocusPublicInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/Slice/SliceDataFlagsCommand.h>
|
||||
@@ -497,6 +498,9 @@ namespace AzToolsFramework
|
||||
m_prefabPublicInterface = AZ::Interface<Prefab::PrefabPublicInterface>::Get();
|
||||
AZ_Assert(m_prefabPublicInterface != nullptr, "EntityPropertyEditor requires a PrefabPublicInterface instance on Initialize.");
|
||||
|
||||
m_readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get();
|
||||
AZ_Assert(m_readOnlyEntityPublicInterface != nullptr, "EntityPropertyEditor requires a ReadOnlyEntityPublicInterface instance on Initialize.");
|
||||
|
||||
setObjectName("EntityPropertyEditor");
|
||||
setAcceptDrops(true);
|
||||
|
||||
@@ -973,7 +977,7 @@ namespace AzToolsFramework
|
||||
m_gui->m_entityDetailsLabel->setVisible(false);
|
||||
|
||||
// If we're in edit mode, make the name field editable.
|
||||
m_gui->m_entityNameEditor->setReadOnly(!m_gui->m_componentListContents->isEnabled());
|
||||
m_gui->m_entityNameEditor->setReadOnly(!m_gui->m_componentListContents->isEnabled() || m_entityIsReadOnly);
|
||||
|
||||
// get the name of the entity.
|
||||
auto entity = GetSelectedEntityById(entityId);
|
||||
@@ -1062,6 +1066,12 @@ namespace AzToolsFramework
|
||||
|
||||
bool EntityPropertyEditor::CanAddComponentsToSelection(const SelectionEntityTypeInfo& selectionEntityTypeInfo) const
|
||||
{
|
||||
if (m_entityIsReadOnly)
|
||||
{
|
||||
// Can't add components if there is a read only entity in the selection
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selectionEntityTypeInfo == SelectionEntityTypeInfo::Mixed ||
|
||||
selectionEntityTypeInfo == SelectionEntityTypeInfo::None)
|
||||
{
|
||||
@@ -1126,6 +1136,17 @@ namespace AzToolsFramework
|
||||
m_selectedEntityIds.clear();
|
||||
GetSelectedEntities(m_selectedEntityIds);
|
||||
|
||||
// Check if any of the selected entities are marked as read only
|
||||
m_entityIsReadOnly = false;
|
||||
for (const auto& entityId : m_selectedEntityIds)
|
||||
{
|
||||
if (m_readOnlyEntityPublicInterface->IsReadOnly(entityId))
|
||||
{
|
||||
m_entityIsReadOnly = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SourceControlFileInfo scFileInfo;
|
||||
ToolsApplicationRequests::Bus::BroadcastResult(scFileInfo, &ToolsApplicationRequests::GetSceneSourceControlInfo);
|
||||
|
||||
@@ -1681,6 +1702,12 @@ namespace AzToolsFramework
|
||||
componentEditor->UpdateExpandability();
|
||||
componentEditor->InvalidateAll(!componentInFilter ? m_filterString.c_str() : nullptr);
|
||||
|
||||
// If we are in read only mode, then show the components as disabled
|
||||
if (m_entityIsReadOnly)
|
||||
{
|
||||
componentEditor->mockDisabledState(true);
|
||||
}
|
||||
|
||||
if (!componentEditor->GetPropertyEditor()->HasFilteredOutNodes() || componentEditor->GetPropertyEditor()->HasVisibleNodes())
|
||||
{
|
||||
for (AZ::Component* componentInstance : componentInstances)
|
||||
@@ -3077,6 +3104,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
m_gui->m_statusComboBox->setDisabled(m_entityIsReadOnly);
|
||||
m_gui->m_statusComboBox->setVisible(!m_isSystemEntityEditor && !m_isLevelEntityEditor);
|
||||
m_gui->m_statusComboBox->style()->unpolish(m_gui->m_statusComboBox);
|
||||
m_gui->m_statusComboBox->style()->polish(m_gui->m_statusComboBox);
|
||||
@@ -3304,7 +3332,8 @@ namespace AzToolsFramework
|
||||
const auto& componentsToEdit = GetSelectedComponents();
|
||||
|
||||
const bool hasComponents = !m_selectedEntityIds.empty() && !componentsToEdit.empty();
|
||||
const bool allowRemove = hasComponents && AreComponentsRemovable(componentsToEdit);
|
||||
// Don't allow components to be removed/cut/enabled/disabled if read only
|
||||
const bool allowRemove = hasComponents && AreComponentsRemovable(componentsToEdit) && !m_entityIsReadOnly;
|
||||
const bool allowCopy = hasComponents && AreComponentsCopyable(componentsToEdit);
|
||||
|
||||
m_actionToDeleteComponents->setEnabled(allowRemove);
|
||||
@@ -3366,6 +3395,12 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_entityIsReadOnly)
|
||||
{
|
||||
// Can't paste components if there is a read only entity in the selection
|
||||
return false;
|
||||
}
|
||||
|
||||
// Grab component data from clipboard, if exists
|
||||
const QMimeData* mimeData = ComponentMimeData::GetComponentMimeDataFromClipboard();
|
||||
|
||||
|
||||
+4
@@ -62,6 +62,7 @@ namespace AzToolsFramework
|
||||
class ComponentPaletteWidget;
|
||||
class ComponentModeCollectionInterface;
|
||||
struct SourceControlFileInfo;
|
||||
class ReadOnlyEntityPublicInterface;
|
||||
|
||||
namespace AssetBrowser
|
||||
{
|
||||
@@ -623,6 +624,9 @@ namespace AzToolsFramework
|
||||
Prefab::PrefabPublicInterface* m_prefabPublicInterface = nullptr;
|
||||
bool m_prefabsAreEnabled = false;
|
||||
|
||||
ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
|
||||
bool m_entityIsReadOnly = false;
|
||||
|
||||
// Reordering row widgets within the RPE.
|
||||
static constexpr float MoveFadeSeconds = 0.5f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user