Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -152,17 +152,35 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
LyViewPane::CategoryTools,
levelInspectorOptions);
ViewPaneOptions outlinerOptions;
outlinerOptions.canHaveMultipleInstances = true;
outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea;
if (GetIEditor()->IsPrefabSystemEnabled())
{
// Add the new Outliner to the Tools Menu
// this pane was originally introduced with this name, so layout settings are all saved with that name, despite the preview label being removed.
outlinerOptions.saveKeyName = "Entity Outliner (PREVIEW)";
RegisterViewPane<QComponentEntityEditorOutlinerWindow>(
LyViewPane::EntityOutliner,
LyViewPane::CategoryTools,
outlinerOptions);
ViewPaneOptions outlinerOptions;
outlinerOptions.canHaveMultipleInstances = true;
outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea;
RegisterViewPane<QEntityOutlinerWindow>(
LyViewPane::EntityOutliner,
LyViewPane::CategoryTools,
outlinerOptions);
}
else
{
// Add the Legacy Outliner to the Tools Menu
ViewPaneOptions outlinerOptions;
outlinerOptions.canHaveMultipleInstances = true;
outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea;
// this pane was originally introduced with this name, so layout settings are all saved with that name, despite the preview label being removed.
outlinerOptions.saveKeyName = "Entity Outliner (PREVIEW)";
RegisterViewPane<QComponentEntityEditorOutlinerWindow>(
LyViewPane::EntityOutliner,
LyViewPane::CategoryTools,
outlinerOptions);
}
AzToolsFramework::ViewPaneOptions options;
options.preferedDockingArea = Qt::NoDockWidgetArea;
@@ -1142,7 +1142,7 @@ void CComponentEntityObject::SetupEntityIcon()
m_hasIcon = true;
int textureId = GetIEditor()->GetIconManager()->GetIconTexture(m_icon.c_str());
m_iconTexture = GetIEditor()->GetRenderer()->EF_GetTextureByID(textureId);
m_iconTexture = GetIEditor()->GetRenderer() ? GetIEditor()->GetRenderer()->EF_GetTextureByID(textureId) : nullptr;
}
}
}
@@ -40,6 +40,7 @@
#include <AzToolsFramework/Commands/EntityStateCommand.h>
#include <AzToolsFramework/Commands/SelectionCommand.h>
#include <AzToolsFramework/Commands/SliceDetachEntityCommand.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
@@ -49,6 +50,7 @@
#include <AzToolsFramework/ToolsComponents/EditorLayerComponent.h>
#include <AzToolsFramework/ToolsComponents/EditorVisibilityComponent.h>
#include <AzToolsFramework/Undo/UndoSystem.h>
#include <AzToolsFramework/UI/EditorEntityUi/EditorEntityUiInterface.h>
#include <AzToolsFramework/UI/Layer/AddToLayerMenu.h>
#include <AzToolsFramework/UI/PropertyEditor/InstanceDataHierarchy.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
@@ -189,6 +191,15 @@ void SandboxIntegrationManager::Setup()
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_FILE_SAVE_SELECTED_SLICE, [this]() {
SaveSlice(true);
});
// Keep a reference to the interface EditorEntityUiInterface.
// This is used to register layer entities to their UI handler when the layer component is activated.
m_editorEntityUiInterface = AZ::Interface<AzToolsFramework::EditorEntityUiInterface>::Get();
AZ_Assert((m_editorEntityUiInterface != nullptr),
"SandboxIntegrationManager requires a EditorEntityUiInterface instance to be present on Setup().");
AzToolsFramework::Layers::EditorLayerComponentNotificationBus::Handler::BusConnect();
}
void SandboxIntegrationManager::SaveSlice(const bool& QuickPushToFirstLevel)
@@ -248,38 +259,46 @@ void SandboxIntegrationManager::SaveSlice(const bool& QuickPushToFirstLevel)
// This event handler is queued on main thread.
void SandboxIntegrationManager::OnCatalogAssetAdded(const AZ::Data::AssetId& assetId)
{
AZ::SliceComponent* editorRootSlice = nullptr;
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(editorRootSlice,
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
AZ_Assert(editorRootSlice, "Editor root slice missing!");
for (auto restoreItr = m_sliceAssetDeletionErrorRestoreInfos.begin(); restoreItr != m_sliceAssetDeletionErrorRestoreInfos.end(); )
bool isLegacySliceSystemEnabled = true;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
isLegacySliceSystemEnabled, &AzToolsFramework::ToolsApplicationRequests::IsLegacySliceSystemEnabled);
if (isLegacySliceSystemEnabled)
{
if (restoreItr->m_assetId == assetId)
AZ::SliceComponent* editorRootSlice = nullptr;
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(
editorRootSlice, &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice);
AZ_Assert(editorRootSlice, "Editor root slice missing!");
for (auto restoreItr = m_sliceAssetDeletionErrorRestoreInfos.begin(); restoreItr != m_sliceAssetDeletionErrorRestoreInfos.end();)
{
for (const auto& entityRestore : restoreItr->m_entityRestoreInfos)
if (restoreItr->m_assetId == assetId)
{
const AZ::EntityId& entityId = entityRestore.first;
const AZ::SliceComponent::EntityRestoreInfo& restoreInfo = entityRestore.second;
for (const auto& entityRestore : restoreItr->m_entityRestoreInfos)
{
const AZ::EntityId& entityId = entityRestore.first;
const AZ::SliceComponent::EntityRestoreInfo& restoreInfo = entityRestore.second;
AZ::Entity* entity = editorRootSlice->FindEntity(entityId);
if (entity)
{
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::RestoreSliceEntity,
entity, restoreInfo, AzToolsFramework::SliceEntityRestoreType::Detached);
}
else
{
AZ_Error("DetachSliceEntity", entity, "Unable to find previous detached entity of Id %s. Cannot undo \"Detach\" action.", entityId.ToString().c_str());
AZ::Entity* entity = editorRootSlice->FindEntity(entityId);
if (entity)
{
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::RestoreSliceEntity, entity, restoreInfo,
AzToolsFramework::SliceEntityRestoreType::Detached);
}
else
{
AZ_Error(
"DetachSliceEntity", entity, "Unable to find previous detached entity of Id %s. Cannot undo \"Detach\" action.",
entityId.ToString().c_str());
}
}
restoreItr = m_sliceAssetDeletionErrorRestoreInfos.erase(restoreItr);
}
else
{
restoreItr++;
}
restoreItr = m_sliceAssetDeletionErrorRestoreInfos.erase(restoreItr);
}
else
{
restoreItr++;
}
}
}
@@ -360,6 +379,7 @@ void SandboxIntegrationManager::GetEntitiesInSlices(
void SandboxIntegrationManager::Teardown()
{
AzToolsFramework::Layers::EditorLayerComponentNotificationBus::Handler::BusDisconnect();
AzToolsFramework::NewViewportInteractionModelEnabledRequestBus::Handler::BusDisconnect();
AzFramework::DisplayContextRequestBus::Handler::BusDisconnect();
if( m_debugDisplayBusImplementationActive)
@@ -642,8 +662,17 @@ void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, con
GetSelectedEntitiesSetWithFlattenedHierarchy(flattenedSelection);
AzToolsFramework::SetupAddToLayerMenu(menu, flattenedSelection, [this] { return ContextMenu_NewLayer(); });
SetupSliceContextMenu(menu);
if (!GetIEditor()->IsPrefabSystemEnabled())
{
SetupSliceContextMenu(menu);
}
else
{
menu->addSeparator();
// Allow handlers to append menu items to the context menu
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu, menu);
}
action = menu->addAction(QObject::tr("Duplicate"));
QObject::connect(action, &QAction::triggered, action, [this] { ContextMenu_Duplicate(); });
@@ -1382,7 +1411,16 @@ void SandboxIntegrationManager::OnSliceInstantiated(const AZ::Data::AssetId& /*s
// The second in the pair is the local instance's entity ID.
m_unsavedEntities.insert(sliceInstantEntityIdPair.second);
}
}
void SandboxIntegrationManager::OnLayerComponentActivated(AZ::EntityId entityId)
{
m_editorEntityUiInterface->RegisterEntity(entityId, m_layerUiOverrideHandler.GetHandlerId());
}
void SandboxIntegrationManager::OnLayerComponentDeactivated(AZ::EntityId entityId)
{
m_editorEntityUiInterface->UnregisterEntity(entityId);
}
void SandboxIntegrationManager::ContextMenu_NewEntity()
@@ -1422,6 +1460,7 @@ AZ::EntityId SandboxIntegrationManager::ContextMenu_NewLayer()
return AZ::EntityId();
}
m_unsavedEntities.insert(newEntityId);
return newEntityId;
}
@@ -23,7 +23,10 @@
#include <AzFramework/Viewport/DisplayContextRequestBus.h>
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/ToolsComponents/EditorLayerComponentBus.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzToolsFramework/UI/Layer/LayerUiHandler.h>
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h>
#include <AzToolsFramework/UI/Slice/SliceOverridesNotificationWindowManager.hxx>
#include <AzToolsFramework/UI/Slice/SliceOverridesNotificationWindow.hxx>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
@@ -74,6 +77,8 @@ class CHyperGraph;
namespace AzToolsFramework
{
class EditorEntityUiInterface;
namespace AssetBrowser
{
class AssetSelectionModel;
@@ -95,6 +100,7 @@ class SandboxIntegrationManager
, private AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler
, private IUndoManagerListener
, private AzToolsFramework::NewViewportInteractionModelEnabledRequestBus::Handler
, private AzToolsFramework::Layers::EditorLayerComponentNotificationBus::Handler
{
public:
@@ -314,6 +320,10 @@ private:
// Listens for Cry Undo System events.
void UndoStackFlushed() override;
// EditorLayerRequestBus...
void OnLayerComponentActivated(AZ::EntityId entityId) override;
void OnLayerComponentDeactivated(AZ::EntityId entityId) override;
private:
void SetupFileExtensionMap();
// Right click context menu when a layer is included in the selection.
@@ -369,6 +379,13 @@ private:
const AZStd::string m_defaultEntityIconLocation = "Editor/Icons/Components/Viewport/Transform.png";
bool m_debugDisplayBusImplementationActive = false;
AzToolsFramework::Prefab::PrefabIntegrationManager m_prefabIntegrationManager;
AzToolsFramework::EditorEntityUiInterface* m_editorEntityUiInterface = nullptr;
// Overrides UI styling and behavior for Layer Entities
AzToolsFramework::LayerUiHandler m_layerUiOverrideHandler;
};
//////////////////////////////////////////////////////////////////////////
@@ -20,7 +20,11 @@
#include <QStandardItem>
#endif
#if !defined(DEFINED_QMETATYPE_UUID)
#define DEFINED_QMETATYPE_UUID
Q_DECLARE_METATYPE(AZ::Uuid);
#endif
namespace Ui
{
@@ -111,4 +115,4 @@ namespace AzQtComponents
private:
SearchTypeSelector* m_selector = nullptr;
};
}
}
@@ -19,9 +19,7 @@
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.hxx>
#include <AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx>
#include <AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx>
#include <QVBoxLayout>
@@ -55,6 +53,36 @@ void QComponentEntityEditorOutlinerWindow::Init()
setCentralWidget(window);
}
QEntityOutlinerWindow::QEntityOutlinerWindow(QWidget* parent)
: QMainWindow(parent)
, m_outlinerWidget(nullptr)
{
gEnv->pSystem->GetISystemEventDispatcher()->RegisterListener(this);
Init();
}
QEntityOutlinerWindow::~QEntityOutlinerWindow()
{
gEnv->pSystem->GetISystemEventDispatcher()->RemoveListener(this);
}
void QEntityOutlinerWindow::OnSystemEvent([[maybe_unused]] ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam)
{
}
void QEntityOutlinerWindow::Init()
{
QVBoxLayout* layout = new QVBoxLayout();
m_outlinerWidget = new AzToolsFramework::EntityOutlinerWidget(nullptr);
layout->addWidget(m_outlinerWidget);
QWidget* window = new QWidget();
window->setLayout(layout);
setCentralWidget(window);
}
///////////////////////////////////////////////////////////////////////////////
// End of context menu handling
///////////////////////////////////////////////////////////////////////////////
@@ -26,6 +26,11 @@ namespace AZ
class Entity;
}
namespace AzToolsFramework
{
class EntityOutlinerWidget;
}
class OutlinerWidget;
// This is the shell class to interface between Qt and the Sandbox. All Sandbox implementation is retained in an inherited class.
@@ -60,3 +65,36 @@ public:
private:
OutlinerWidget* m_outlinerWidget;
};
// This is the shell class to interface between Qt and the Sandbox. All Sandbox implementation is retained in an inherited class.
class QEntityOutlinerWindow
: public QMainWindow
, public ISystemEventListener
{
Q_OBJECT
public:
explicit QEntityOutlinerWindow(QWidget* parent = 0);
~QEntityOutlinerWindow();
void Init();
// Used to receive events from widgets where SIGNALS aren't available or implemented yet.
// Required override.
void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
// you are required to implement this to satisfy the unregister/registerclass requirements on "AzToolsFramework::RegisterViewPane"
// make sure you pick a unique GUID
static const GUID& GetClassID()
{
// {CEE50D0E-46A8-4CB4-9C5F-DCD374A78032}
static const GUID guid =
{
0xcee50d0e, 0x46a8, 0x4cb4, { 0x9c, 0x5f, 0xdc, 0xd3, 0x74, 0xa7, 0x80, 0x32 }
};
return guid;
}
private:
AzToolsFramework::EntityOutlinerWidget* m_outlinerWidget;
};