Merge pull request #6144 from aws-lumberyard-dev/cgalvan/ReadOnlyEntityInspectorChanges
Updated Entity Inspector to changed behavior when an Entity has been marked as read-only.
This commit is contained in:
+52
-6
@@ -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);
|
||||
|
||||
@@ -535,10 +539,6 @@ namespace AzToolsFramework
|
||||
model->setItem(row, 0, m_comboItems[row]);
|
||||
}
|
||||
m_gui->m_statusComboBox->setModel(model);
|
||||
m_gui->m_statusComboBox->setStyleSheet("QComboBox {border: 0px; border-radius:3px; background-color:#555555; color:white}"
|
||||
"QComboBox:on {background-color:#e9e9e9; color:black; border:0px}"
|
||||
"QComboBox::down-arrow:on {image: url(:/stylesheet/img/dropdowns/black_down_arrow.png)}"
|
||||
"QComboBox::drop-down {border-radius: 3p}");
|
||||
AzQtComponents::ComboBox::addCustomCheckStateStyle(m_gui->m_statusComboBox);
|
||||
EnableEditor(true);
|
||||
m_sceneIsNew = true;
|
||||
@@ -565,6 +565,12 @@ namespace AzToolsFramework
|
||||
AZ::EntitySystemBus::Handler::BusConnect();
|
||||
EntityPropertyEditorRequestBus::Handler::BusConnect();
|
||||
EditorWindowUIRequestBus::Handler::BusConnect();
|
||||
|
||||
AzFramework::EntityContextId editorEntityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
EditorEntityContextRequestBus::BroadcastResult(
|
||||
editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
ReadOnlyEntityPublicNotificationBus::Handler::BusConnect(editorEntityContextId);
|
||||
|
||||
m_spacer = nullptr;
|
||||
|
||||
m_emptyIcon = QIcon();
|
||||
@@ -614,6 +620,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
qApp->removeEventFilter(this);
|
||||
|
||||
ReadOnlyEntityPublicNotificationBus::Handler::BusDisconnect();
|
||||
EditorWindowUIRequestBus::Handler::BusDisconnect();
|
||||
EntityPropertyEditorRequestBus::Handler::BusDisconnect();
|
||||
ToolsApplicationEvents::Bus::Handler::BusDisconnect();
|
||||
@@ -973,7 +980,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_selectionContainsReadOnlyEntity);
|
||||
|
||||
// get the name of the entity.
|
||||
auto entity = GetSelectedEntityById(entityId);
|
||||
@@ -1062,6 +1069,12 @@ namespace AzToolsFramework
|
||||
|
||||
bool EntityPropertyEditor::CanAddComponentsToSelection(const SelectionEntityTypeInfo& selectionEntityTypeInfo) const
|
||||
{
|
||||
if (m_selectionContainsReadOnlyEntity)
|
||||
{
|
||||
// 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 +1139,17 @@ namespace AzToolsFramework
|
||||
m_selectedEntityIds.clear();
|
||||
GetSelectedEntities(m_selectedEntityIds);
|
||||
|
||||
// Check if any of the selected entities are marked as read only
|
||||
m_selectionContainsReadOnlyEntity = false;
|
||||
for (const auto& entityId : m_selectedEntityIds)
|
||||
{
|
||||
if (m_readOnlyEntityPublicInterface->IsReadOnly(entityId))
|
||||
{
|
||||
m_selectionContainsReadOnlyEntity = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SourceControlFileInfo scFileInfo;
|
||||
ToolsApplicationRequests::Bus::BroadcastResult(scFileInfo, &ToolsApplicationRequests::GetSceneSourceControlInfo);
|
||||
|
||||
@@ -1681,6 +1705,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_selectionContainsReadOnlyEntity)
|
||||
{
|
||||
componentEditor->mockDisabledState(true);
|
||||
}
|
||||
|
||||
if (!componentEditor->GetPropertyEditor()->HasFilteredOutNodes() || componentEditor->GetPropertyEditor()->HasVisibleNodes())
|
||||
{
|
||||
for (AZ::Component* componentInstance : componentInstances)
|
||||
@@ -3077,6 +3107,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
m_gui->m_statusComboBox->setDisabled(m_selectionContainsReadOnlyEntity);
|
||||
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 +3335,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_selectionContainsReadOnlyEntity;
|
||||
const bool allowCopy = hasComponents && AreComponentsCopyable(componentsToEdit);
|
||||
|
||||
m_actionToDeleteComponents->setEnabled(allowRemove);
|
||||
@@ -3366,6 +3398,12 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_selectionContainsReadOnlyEntity)
|
||||
{
|
||||
// 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();
|
||||
|
||||
@@ -5727,6 +5765,14 @@ namespace AzToolsFramework
|
||||
SaveComponentEditorState();
|
||||
}
|
||||
|
||||
void EntityPropertyEditor::OnReadOnlyEntityStatusChanged(const AZ::EntityId& entityId, [[maybe_unused]] bool readOnly)
|
||||
{
|
||||
if (IsEntitySelected(entityId))
|
||||
{
|
||||
UpdateContents();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityPropertyEditor::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
|
||||
+9
@@ -29,6 +29,7 @@
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
|
||||
#include <AzQtComponents/Components/O3DEStylesheet.h>
|
||||
@@ -62,6 +63,7 @@ namespace AzToolsFramework
|
||||
class ComponentPaletteWidget;
|
||||
class ComponentModeCollectionInterface;
|
||||
struct SourceControlFileInfo;
|
||||
class ReadOnlyEntityPublicInterface;
|
||||
|
||||
namespace AssetBrowser
|
||||
{
|
||||
@@ -116,6 +118,7 @@ namespace AzToolsFramework
|
||||
, public AZ::EntitySystemBus::Handler
|
||||
, public AZ::TickBus::Handler
|
||||
, private EditorWindowUIRequestBus::Handler
|
||||
, private ReadOnlyEntityPublicNotificationBus::Handler
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
@@ -253,6 +256,9 @@ namespace AzToolsFramework
|
||||
// EditorWindowRequestBus overrides
|
||||
void SetEditorUiEnabled(bool enable) override;
|
||||
|
||||
// ReadOnlyEntityPublicNotificationBus overrides ...
|
||||
void OnReadOnlyEntityStatusChanged(const AZ::EntityId& entityId, bool readOnly) override;
|
||||
|
||||
bool IsEntitySelected(const AZ::EntityId& id) const;
|
||||
bool IsSingleEntitySelected(const AZ::EntityId& id) const;
|
||||
|
||||
@@ -623,6 +629,9 @@ namespace AzToolsFramework
|
||||
Prefab::PrefabPublicInterface* m_prefabPublicInterface = nullptr;
|
||||
bool m_prefabsAreEnabled = false;
|
||||
|
||||
ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
|
||||
bool m_selectionContainsReadOnlyEntity = false;
|
||||
|
||||
// Reordering row widgets within the RPE.
|
||||
static constexpr float MoveFadeSeconds = 0.5f;
|
||||
|
||||
|
||||
+4
-1
@@ -191,7 +191,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color:rgb(51, 51, 51)</string>
|
||||
<string notr="true">QWidget#m_darkBox { background-color:rgb(51, 51, 51) }</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="spacing">
|
||||
@@ -444,6 +444,9 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color:rgb(51, 51, 51)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user