From 62bc7a66bb82dfdc390dec81cdfaf2e3d72711cf Mon Sep 17 00:00:00 2001 From: AMZN-daimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Tue, 20 Apr 2021 16:22:34 -0700 Subject: [PATCH] Remove the Level Inspector from Prefab mode and move behavior to Entity Inspector. (#149) * Remove Level Inspector from Prefab mode, and integrate the same behavior in the Entity Inspector * Show prefab name in level entity row of the Outliner. Allow Ui Handlers to prevent renaming. * Separate setting the prefab's template path and the container entity name. * Disable reparenting to root level * Disable the ability to rename the level entity. * Fixes as per Ram's review --- .../PrefabEditorEntityOwnershipService.cpp | 2 + .../Prefab/Instance/Instance.cpp | 8 ++- .../Prefab/Instance/Instance.h | 1 + .../Prefab/PrefabPublicHandler.cpp | 4 +- .../Prefab/PrefabSystemComponent.cpp | 1 + .../EditorEntityUiHandlerBase.cpp | 5 ++ .../EditorEntityUiHandlerBase.h | 2 + .../UI/Outliner/EntityOutlinerListModel.cpp | 44 +++++++------- .../UI/Outliner/EntityOutlinerWidget.cpp | 29 ++++++++-- .../UI/Outliner/EntityOutlinerWidget.hxx | 3 + .../UI/Prefab/LevelRootUiHandler.cpp | 20 +++++++ .../UI/Prefab/LevelRootUiHandler.h | 2 + .../PropertyEditor/EntityPropertyEditor.cpp | 57 +++++++++++++++---- .../PropertyEditor/EntityPropertyEditor.hxx | 9 +++ Code/Sandbox/Editor/QtViewPaneManager.cpp | 20 ++++++- .../ComponentEntityEditorPlugin.cpp | 17 +++--- 16 files changed, 171 insertions(+), 53 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp index 2424658ecf..cb16e0c099 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp @@ -94,6 +94,7 @@ namespace AzToolsFramework m_prefabSystemComponent->RemoveTemplate(templateId); } m_rootInstance->Reset(); + m_rootInstance->SetContainerEntityName("Level"); AzFramework::EntityOwnershipServiceNotificationBus::Event( m_entityContextId, &AzFramework::EntityOwnershipServiceNotificationBus::Events::OnEntityOwnershipServiceReset); @@ -198,6 +199,7 @@ namespace AzToolsFramework m_rootInstance->SetTemplateId(templateId); m_rootInstance->SetTemplateSourcePath(m_loaderInterface->GetRelativePathToProject(filename)); + m_rootInstance->SetContainerEntityName("Level"); m_prefabSystemComponent->PropagateTemplateChanges(templateId); return true; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp index 0a5b43482e..c1eee62dbc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp @@ -123,7 +123,11 @@ namespace AzToolsFramework void Instance::SetTemplateSourcePath(AZ::IO::PathView sourcePath) { m_templateSourcePath = sourcePath; - m_containerEntity->SetName(sourcePath.Filename().Native()); + } + + void Instance::SetContainerEntityName(AZStd::string_view containerName) + { + m_containerEntity->SetName(containerName); } bool Instance::AddEntity(AZ::Entity& entity) @@ -563,7 +567,7 @@ namespace AzToolsFramework AZ::EntityId Instance::GetContainerEntityId() const { - return m_containerEntity->GetId(); + return m_containerEntity ? m_containerEntity->GetId() : AZ::EntityId(); } bool Instance::HasContainerEntity() const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h index d1c7a4d853..186dce0f50 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.h @@ -80,6 +80,7 @@ namespace AzToolsFramework const AZ::IO::Path& GetTemplateSourcePath() const; void SetTemplateSourcePath(AZ::IO::PathView sourcePath); + void SetContainerEntityName(AZStd::string_view containerName); bool AddEntity(AZ::Entity& entity); bool AddEntity(AZ::Entity& entity, EntityAlias entityAlias); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp index 46bd924f30..772e0ae52e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp @@ -721,7 +721,7 @@ namespace AzToolsFramework InstanceOptionalReference owningInstance = m_instanceEntityMapperInterface->FindOwningInstance(entity->GetId()); AZ_Assert( owningInstance.has_value(), - "An error occored while retrieving entities and prefab instances : " + "An error occurred while retrieving entities and prefab instances : " "Owning instance of entity with id '%llu' couldn't be found", entity->GetId()); @@ -805,7 +805,7 @@ namespace AzToolsFramework { AZ_Assert( false, - "An error occored in function EntitiesBelongToSameInstance: " + "An error occurred in function EntitiesBelongToSameInstance: " "Owning instance of entity with id '%llu' couldn't be found", entityId); return false; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp index 9070630e56..54e99c9416 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp @@ -121,6 +121,7 @@ namespace AzToolsFramework } newInstance->SetTemplateSourcePath(relativeFilePath); + newInstance->SetContainerEntityName(relativeFilePath.Stem().Native()); TemplateId newTemplateId = CreateTemplateFromInstance(*newInstance); if (newTemplateId == InvalidTemplateId) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp index 98edd26f88..84266d3707 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp @@ -61,6 +61,11 @@ namespace AzToolsFramework return true; } + bool EditorEntityUiHandlerBase::CanRename(AZ::EntityId /*entityId*/) const + { + return true; + } + void EditorEntityUiHandlerBase::PaintItemBackground(QPainter* /*painter*/, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const { } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h index 7360e7ff0b..1aa5e5720f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h @@ -47,6 +47,8 @@ namespace AzToolsFramework virtual QPixmap GenerateItemIcon(AZ::EntityId entityId) const; //! Returns whether the element's lock and visibility state should be accessible in the Outliner virtual bool CanToggleLockVisibility(AZ::EntityId entityId) const; + //! Returns whether the element's name should be editable + virtual bool CanRename(AZ::EntityId entityId) const; //! Paints the background of the item in the Outliner. virtual void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index de10ae18b4..5b44594398 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -945,6 +945,12 @@ namespace AzToolsFramework return false; } + // Disable reparenting to the root level + if (!newParentId.IsValid()) + { + return false; + } + // Ignore entities not owned by the editor context. It is assumed that all entities belong // to the same context since multiple selection doesn't span across views. for (const AZ::EntityId& entityId : selectedEntityIds) @@ -974,39 +980,33 @@ namespace AzToolsFramework } } - if (newParentId.IsValid()) + bool isLayerEntity = false; + Layers::EditorLayerComponentRequestBus::EventResult( + isLayerEntity, + entityId, + &Layers::EditorLayerComponentRequestBus::Events::HasLayer); + // Layers can only have other layers as parents, or have no parent. + if (isLayerEntity) { - bool isLayerEntity = false; + bool newParentIsLayer = false; Layers::EditorLayerComponentRequestBus::EventResult( - isLayerEntity, - entityId, + newParentIsLayer, + newParentId, &Layers::EditorLayerComponentRequestBus::Events::HasLayer); - // Layers can only have other layers as parents, or have no parent. - if (isLayerEntity) + if (!newParentIsLayer) { - bool newParentIsLayer = false; - Layers::EditorLayerComponentRequestBus::EventResult( - newParentIsLayer, - newParentId, - &Layers::EditorLayerComponentRequestBus::Events::HasLayer); - if (!newParentIsLayer) - { - return false; - } + return false; } } } //Only check the entity pointer if the entity id is valid because //we want to allow dragging items to unoccupied parts of the tree to un-parent them - if (newParentId.IsValid()) + AZ::Entity* newParentEntity = nullptr; + AZ::ComponentApplicationBus::BroadcastResult(newParentEntity, &AZ::ComponentApplicationRequests::FindEntity, newParentId); + if (!newParentEntity) { - AZ::Entity* newParentEntity = nullptr; - AZ::ComponentApplicationBus::BroadcastResult(newParentEntity, &AZ::ComponentApplicationRequests::FindEntity, newParentId); - if (!newParentEntity) - { - return false; - } + return false; } //reject dragging on to yourself or your children diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp index 08fc764507..3ee8a14285 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -271,6 +272,12 @@ namespace AzToolsFramework m_listModel->Initialize(); + m_editorEntityUiInterface = AZ::Interface::Get(); + + AZ_Assert( + m_editorEntityUiInterface != nullptr, + "EntityOutlinerWidget requires a EditorEntityUiInterface instance on Initialize."); + EditorPickModeNotificationBus::Handler::BusConnect(GetEntityContextId()); EntityHighlightMessages::Bus::Handler::BusConnect(); EntityOutlinerModelNotificationBus::Handler::BusConnect(); @@ -562,7 +569,13 @@ namespace AzToolsFramework if (m_selectedEntityIds.size() == 1) { - contextMenu->addAction(m_actionToRenameSelection); + auto entityId = m_selectedEntityIds.front(); + auto entityUiHandler = m_editorEntityUiInterface->GetHandler(entityId); + + if (!entityUiHandler || entityUiHandler->CanRename(entityId)) + { + contextMenu->addAction(m_actionToRenameSelection); + } } if (m_selectedEntityIds.size() == 1) @@ -688,11 +701,17 @@ namespace AzToolsFramework if (m_selectedEntityIds.size() == 1) { - const QModelIndex proxyIndex = GetIndexFromEntityId(m_selectedEntityIds.front()); - if (proxyIndex.isValid()) + auto entityId = m_selectedEntityIds.front(); + auto entityUiHandler = m_editorEntityUiInterface->GetHandler(entityId); + + if (!entityUiHandler || entityUiHandler->CanRename(entityId)) { - m_gui->m_objectTree->setCurrentIndex(proxyIndex); - m_gui->m_objectTree->QTreeView::edit(proxyIndex); + const QModelIndex proxyIndex = GetIndexFromEntityId(entityId); + if (proxyIndex.isValid()) + { + m_gui->m_objectTree->setCurrentIndex(proxyIndex); + m_gui->m_objectTree->QTreeView::edit(proxyIndex); + } } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx index cf8c55abd1..f225bb49b8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx @@ -42,6 +42,7 @@ namespace Ui namespace AzToolsFramework { + class EditorEntityUiInterface; class EntityOutlinerListModel; class EntityOutlinerSortFilterProxyModel; @@ -193,6 +194,8 @@ namespace AzToolsFramework EntityIdSet m_entitiesToSort; EntityOutliner::DisplaySortMode m_sortMode; bool m_sortContentQueued; + + EditorEntityUiInterface* m_editorEntityUiInterface = nullptr; }; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp index 828a49ef94..7915403c0a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp @@ -50,11 +50,31 @@ namespace AzToolsFramework return QPixmap(m_levelRootIconPath); } + QString LevelRootUiHandler::GenerateItemInfoString(AZ::EntityId entityId) const + { + QString infoString; + + AZ::IO::Path path = m_prefabPublicInterface->GetOwningInstancePrefabPath(entityId); + + if (!path.empty()) + { + infoString = + QObject::tr("(%1)").arg(path.Filename().Native().data()); + } + + return infoString; + } + bool LevelRootUiHandler::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const { return false; } + bool LevelRootUiHandler::CanRename(AZ::EntityId /*entityId*/) const + { + return false; + } + void LevelRootUiHandler::PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const { if (!painter) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h index a8b2e4a4f8..19c1244040 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h @@ -34,7 +34,9 @@ namespace AzToolsFramework // EditorEntityUiHandler... QPixmap GenerateItemIcon(AZ::EntityId entityId) const override; + QString GenerateItemInfoString(AZ::EntityId entityId) const override; bool CanToggleLockVisibility(AZ::EntityId entityId) const override; + bool CanRename(AZ::EntityId entityId) const override; void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; private: diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp index 55c7fb3f65..181f5b9a9d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp @@ -310,6 +310,9 @@ namespace AzToolsFramework { initEntityPropertyEditorResources(); + m_prefabPublicInterface = AZ::Interface::Get(); + AZ_Assert(m_prefabPublicInterface != nullptr, "EntityPropertyEditor requires a PrefabPublicInterface instance on Initialize."); + setObjectName("EntityPropertyEditor"); setAcceptDrops(true); @@ -405,8 +408,6 @@ namespace AzToolsFramework CreateActions(); UpdateContents(); - m_prefabPublicInterface = AZ::Interface::Get(); - EditorEntityContextNotificationBus::Handler::BusConnect(); //forced to register global event filter with application for selection @@ -693,11 +694,38 @@ namespace AzToolsFramework m_gui->m_entityIcon->repaint(); } + EntityPropertyEditor::InspectorLayout EntityPropertyEditor::GetCurrentInspectorLayout() const + { + if (!m_prefabsAreEnabled) + { + return m_isLevelEntityEditor ? InspectorLayout::LEVEL : InspectorLayout::ENTITY; + } + + AZ::EntityId levelContainerEntityId = m_prefabPublicInterface->GetLevelInstanceContainerEntityId(); + if (AZStd::find(m_selectedEntityIds.begin(), m_selectedEntityIds.end(), levelContainerEntityId) != m_selectedEntityIds.end()) + { + if (m_selectedEntityIds.size() > 1) + { + return InspectorLayout::INVALID; + } + else + { + return InspectorLayout::LEVEL; + } + } + else + { + return InspectorLayout::ENTITY; + } + } + void EntityPropertyEditor::UpdateEntityDisplay() { UpdateStatusComboBox(); - if (m_isLevelEntityEditor) + InspectorLayout layout = GetCurrentInspectorLayout(); + + if (layout == InspectorLayout::LEVEL) { AZStd::string levelName; AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequests::GetLevelName); @@ -737,13 +765,20 @@ namespace AzToolsFramework AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); SelectionEntityTypeInfo result = SelectionEntityTypeInfo::None; - if (m_isLevelEntityEditor) + InspectorLayout layout = GetCurrentInspectorLayout(); + + if (layout == InspectorLayout::LEVEL) { // The Level Inspector should only have a list of selectable components after the // level entity itself is valid (i.e. "selected"). return selection.empty() ? SelectionEntityTypeInfo::None : SelectionEntityTypeInfo::LevelEntity; } + if (layout == InspectorLayout::INVALID) + { + return SelectionEntityTypeInfo::Mixed; + } + for (AZ::EntityId selectedEntityId : selection) { bool isLayerEntity = false; @@ -909,16 +944,18 @@ namespace AzToolsFramework } } + bool isLevelLayout = GetCurrentInspectorLayout() == InspectorLayout::LEVEL; + m_gui->m_entityDetailsLabel->setText(entityDetailsLabelText); m_gui->m_entityDetailsLabel->setVisible(entityDetailsVisible); m_gui->m_entityNameEditor->setVisible(hasEntitiesDisplayed); m_gui->m_entityNameLabel->setVisible(hasEntitiesDisplayed); m_gui->m_entityIcon->setVisible(hasEntitiesDisplayed); - m_gui->m_pinButton->setVisible(m_overrideSelectedEntityIds.empty() && hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_statusLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_statusComboBox->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_entityIdLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); - m_gui->m_entityIdText->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !m_isLevelEntityEditor); + m_gui->m_pinButton->setVisible(m_overrideSelectedEntityIds.empty() && hasEntitiesDisplayed && !m_isSystemEntityEditor); + m_gui->m_statusLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); + m_gui->m_statusComboBox->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); + m_gui->m_entityIdLabel->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); + m_gui->m_entityIdText->setVisible(hasEntitiesDisplayed && !m_isSystemEntityEditor && !isLevelLayout); bool displayComponentSearchBox = hasEntitiesDisplayed; if (hasEntitiesDisplayed) @@ -941,7 +978,7 @@ namespace AzToolsFramework UpdateEntityDisplay(); } - m_gui->m_darkBox->setVisible(displayComponentSearchBox && !m_isSystemEntityEditor && !m_isLevelEntityEditor); + m_gui->m_darkBox->setVisible(displayComponentSearchBox && !m_isSystemEntityEditor && !isLevelLayout); m_gui->m_entitySearchBox->setVisible(displayComponentSearchBox); bool displayAddComponentMenu = CanAddComponentsToSelection(selectionEntityTypeInfo); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx index fed9c55f15..677dc98277 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx @@ -521,6 +521,15 @@ namespace AzToolsFramework bool m_isSystemEntityEditor; bool m_isLevelEntityEditor = false; + enum class InspectorLayout + { + ENTITY = 0, // All selected entities are regular entities + LEVEL, // The selected entity is the level prefab container entity + INVALID // Other entities are selected alongside the level prefab container entity + }; + + InspectorLayout GetCurrentInspectorLayout() const; + // the spacer's job is to make sure that its always at the end of the list of components. QSpacerItem* m_spacer; bool m_isAlreadyQueuedRefresh; diff --git a/Code/Sandbox/Editor/QtViewPaneManager.cpp b/Code/Sandbox/Editor/QtViewPaneManager.cpp index ad33eecfee..b242f3d914 100644 --- a/Code/Sandbox/Editor/QtViewPaneManager.cpp +++ b/Code/Sandbox/Editor/QtViewPaneManager.cpp @@ -36,6 +36,8 @@ #include #include +#include + #include #include #include @@ -983,6 +985,11 @@ bool QtViewPaneManager::ClosePanesWithRollback(const QVector& panesToKe */ void QtViewPaneManager::RestoreDefaultLayout(bool resetSettings) { + // Get whether the prefab system is enabled + bool isPrefabSystemEnabled = false; + AzFramework::ApplicationRequests::Bus::BroadcastResult( + isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); + if (resetSettings) { // We're going to do something destructive (removing all of the viewpane settings). Better confirm with the user @@ -1022,7 +1029,11 @@ void QtViewPaneManager::RestoreDefaultLayout(bool resetSettings) state.viewPanes.push_back(LyViewPane::EntityInspector); state.viewPanes.push_back(LyViewPane::AssetBrowser); state.viewPanes.push_back(LyViewPane::Console); - state.viewPanes.push_back(LyViewPane::LevelInspector); + + if (!isPrefabSystemEnabled) + { + state.viewPanes.push_back(LyViewPane::LevelInspector); + } state.mainWindowState = m_defaultMainWindowState; @@ -1047,7 +1058,12 @@ void QtViewPaneManager::RestoreDefaultLayout(bool resetSettings) const QtViewPane* assetBrowserViewPane = OpenPane(LyViewPane::AssetBrowser, QtViewPane::OpenMode::UseDefaultState); const QtViewPane* entityInspectorViewPane = OpenPane(LyViewPane::EntityInspector, QtViewPane::OpenMode::UseDefaultState); const QtViewPane* consoleViewPane = OpenPane(LyViewPane::Console, QtViewPane::OpenMode::UseDefaultState); - const QtViewPane* levelInspectorPane = OpenPane(LyViewPane::LevelInspector, QtViewPane::OpenMode::UseDefaultState); + + const QtViewPane* levelInspectorPane = nullptr; + if (!isPrefabSystemEnabled) + { + levelInspectorPane = OpenPane(LyViewPane::LevelInspector, QtViewPane::OpenMode::UseDefaultState); + } // This class does all kinds of behind the scenes magic to make docking / restore work, especially with groups // so instead of doing our special default layout attach / docking right now, we want to make it happen diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp index 17face523b..e5ad2a2872 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp @@ -143,15 +143,6 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito LyViewPane::CategoryTools, pinnedInspectorOptions); - ViewPaneOptions levelInspectorOptions; - levelInspectorOptions.canHaveMultipleInstances = false; - levelInspectorOptions.preferedDockingArea = Qt::RightDockWidgetArea; - levelInspectorOptions.paneRect = QRect(50, 50, 400, 700); - RegisterViewPane( - LyViewPane::LevelInspector, - LyViewPane::CategoryTools, - levelInspectorOptions); - bool prefabSystemEnabled = false; AzFramework::ApplicationRequests::Bus::BroadcastResult(prefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); @@ -170,8 +161,14 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito } else { - // Add the Legacy Outliner to the Tools Menu + ViewPaneOptions levelInspectorOptions; + levelInspectorOptions.canHaveMultipleInstances = false; + levelInspectorOptions.preferedDockingArea = Qt::RightDockWidgetArea; + levelInspectorOptions.paneRect = QRect(50, 50, 400, 700); + RegisterViewPane( + LyViewPane::LevelInspector, LyViewPane::CategoryTools, levelInspectorOptions); + // Add the Legacy Outliner to the Tools Menu ViewPaneOptions outlinerOptions; outlinerOptions.canHaveMultipleInstances = true; outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea;