Merge pull request #1265 from aws-lumberyard-dev/tomhh_stabilization-to-development
Stabilization/2106 to Development (for 2021/06/11)
This commit is contained in:
@@ -916,9 +916,6 @@ namespace AzToolsFramework
|
||||
eECMF_USE_VIEWPORT_CENTER = 0x2,
|
||||
};
|
||||
|
||||
/// Populate global edit-time context menu.
|
||||
virtual void PopulateEditorGlobalContextMenu(QMenu * /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/) {}
|
||||
|
||||
/// Populate slice portion of edit-time context menu
|
||||
virtual void PopulateEditorGlobalContextMenu_SliceSection(QMenu * /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/) {}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace AzToolsFramework
|
||||
* This is the menu that appears when right clicking the main editor window,
|
||||
* including the Entity Outliner and the Viewport.
|
||||
*/
|
||||
virtual void PopulateEditorGlobalContextMenu(QMenu* menu) const = 0;
|
||||
virtual void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) = 0;
|
||||
};
|
||||
|
||||
using EditorContextMenuBus = AZ::EBus<EditorContextMenuEvents>;
|
||||
|
||||
@@ -187,13 +187,14 @@ namespace AzToolsFramework
|
||||
return removedEntity;
|
||||
}
|
||||
|
||||
void Instance::DetachNestedEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback)
|
||||
void Instance::DetachAllEntitiesInHierarchy(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback)
|
||||
{
|
||||
callback(AZStd::move(DetachContainerEntity()));
|
||||
DetachEntities(callback);
|
||||
|
||||
for (const auto& [instanceAlias, instance] : m_nestedInstances)
|
||||
{
|
||||
instance->DetachNestedEntities(callback);
|
||||
instance->DetachAllEntitiesInHierarchy(callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,15 @@ namespace AzToolsFramework
|
||||
bool AddEntity(AZ::Entity& entity, EntityAlias entityAlias);
|
||||
AZStd::unique_ptr<AZ::Entity> DetachEntity(const AZ::EntityId& entityId);
|
||||
void DetachEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
||||
void DetachNestedEntities(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
||||
|
||||
/**
|
||||
* Detaches all entities in the instance hierarchy.
|
||||
* Includes all direct entities, all nested entities, and all container entities.
|
||||
* Note that without container entities the hierarchy that remains cannot be used further without restoring new ones.
|
||||
* @param callback A user provided callback that can be used to capture ownership and manipulate the detached entities.
|
||||
*/
|
||||
void DetachAllEntitiesInHierarchy(const AZStd::function<void(AZStd::unique_ptr<AZ::Entity>)>& callback);
|
||||
|
||||
void RemoveNestedEntities(const AZStd::function<bool(const AZStd::unique_ptr<AZ::Entity>&)>& filter);
|
||||
|
||||
void Reset();
|
||||
|
||||
+1
-5
@@ -38,11 +38,7 @@ namespace AzToolsFramework::Prefab::SpawnableUtils
|
||||
// going to be used to create clones of the entities.
|
||||
{
|
||||
AzFramework::Spawnable::EntityList& entities = spawnable.GetEntities();
|
||||
if (instance.HasContainerEntity())
|
||||
{
|
||||
entities.emplace_back(AZStd::move(instance.DetachContainerEntity()));
|
||||
}
|
||||
instance.DetachNestedEntities(
|
||||
instance.DetachAllEntitiesInHierarchy(
|
||||
[&entities](AZStd::unique_ptr<AZ::Entity> entity)
|
||||
{
|
||||
entities.emplace_back(AZStd::move(entity));
|
||||
|
||||
+1
-1
@@ -1206,7 +1206,7 @@ namespace AzToolsFramework
|
||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &EditorTransform::m_rotate, "Rotate", "Local Rotation (Relative to parent) in degrees.")->
|
||||
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
|
||||
Attribute(AZ::Edit::Attributes::Step, 1.0f)->
|
||||
Attribute(AZ::Edit::Attributes::Suffix, " deg")->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
||||
|
||||
+2
-2
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Commands/SelectionCommand.h>
|
||||
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
@@ -544,8 +545,7 @@ namespace AzToolsFramework
|
||||
QMenu* contextMenu = new QMenu(this);
|
||||
|
||||
// Populate global context menu.
|
||||
EBUS_EVENT(EditorEvents::Bus,
|
||||
PopulateEditorGlobalContextMenu,
|
||||
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu,
|
||||
contextMenu,
|
||||
AZ::Vector2::CreateZero(),
|
||||
EditorEvents::eECMF_HIDE_ENTITY_CREATION | EditorEvents::eECMF_USE_VIEWPORT_CENTER);
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ namespace AzToolsFramework
|
||||
return "Prefabs";
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu) const
|
||||
void PrefabIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, [[maybe_unused]] const AZ::Vector2& point, [[maybe_unused]] int flags)
|
||||
{
|
||||
AzToolsFramework::EntityIdList selectedEntities;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ namespace AzToolsFramework
|
||||
// EditorContextMenuBus...
|
||||
int GetMenuPosition() const override;
|
||||
AZStd::string GetMenuIdentifier() const override;
|
||||
void PopulateEditorGlobalContextMenu(QMenu* menu) const override;
|
||||
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
|
||||
|
||||
// EntityOutlinerSourceDropHandlingBus...
|
||||
void HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const override;
|
||||
|
||||
+70
@@ -1130,6 +1130,16 @@ namespace AzToolsFramework
|
||||
m_browseEdit->setAttachedButtonIcon(icon);
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetBrowseButtonEnabled(bool enabled)
|
||||
{
|
||||
m_browseEdit->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void PropertyAssetCtrl::SetBrowseButtonVisible(bool visible)
|
||||
{
|
||||
m_browseEdit->setVisible(visible);
|
||||
}
|
||||
|
||||
const QModelIndex PropertyAssetCtrl::GetSourceIndex(const QModelIndex& index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
@@ -1360,6 +1370,22 @@ namespace AzToolsFramework
|
||||
GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str()));
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("BrowseButtonEnabled"))
|
||||
{
|
||||
bool enabled = true;
|
||||
if (attrValue->Read<bool>(enabled))
|
||||
{
|
||||
GUI->SetBrowseButtonEnabled(enabled);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("BrowseButtonVisible"))
|
||||
{
|
||||
bool visible = true;
|
||||
if (attrValue->Read<bool>(visible))
|
||||
{
|
||||
GUI->SetBrowseButtonVisible(visible);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC_CE("Thumbnail"))
|
||||
{
|
||||
bool showThumbnail = false;
|
||||
@@ -1447,6 +1473,49 @@ namespace AzToolsFramework
|
||||
GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str()));
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC("EditCallback", 0xb74f2ee1))
|
||||
{
|
||||
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());
|
||||
if (func)
|
||||
{
|
||||
GUI->SetEditButtonVisible(true);
|
||||
GUI->SetEditNotifyCallback(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI->SetEditNotifyCallback(nullptr);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC("EditButton", 0x898c35dc))
|
||||
{
|
||||
GUI->SetEditButtonVisible(true);
|
||||
|
||||
AZStd::string iconPath;
|
||||
attrValue->Read<AZStd::string>(iconPath);
|
||||
|
||||
if (!iconPath.empty())
|
||||
{
|
||||
QString path(iconPath.c_str());
|
||||
|
||||
if (!QFile::exists(path))
|
||||
{
|
||||
AZ::IO::FixedMaxPathString engineRoot = AZ::Utils::GetEnginePath();
|
||||
QDir engineDir = !engineRoot.empty() ? QDir(QString(engineRoot.c_str())) : QDir::current();
|
||||
|
||||
path = engineDir.absoluteFilePath(iconPath.c_str());
|
||||
}
|
||||
|
||||
GUI->SetEditButtonIcon(QIcon(path));
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ_CRC("EditDescription", 0x9b52634a))
|
||||
{
|
||||
AZStd::string buttonTooltip;
|
||||
if (attrValue->Read<AZStd::string>(buttonTooltip))
|
||||
{
|
||||
GUI->SetEditButtonTooltip(tr(buttonTooltip.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleAssetPropertyHandlerDefault::WriteGUIValuesIntoProperty(size_t index, PropertyAssetCtrl* GUI, property_t& instance, InstanceDataNode* node)
|
||||
@@ -1476,6 +1545,7 @@ namespace AzToolsFramework
|
||||
// Set the hint in case the asset is not able to be found by assetId
|
||||
GUI->SetCurrentAssetHint(instance.GetAssetPath());
|
||||
GUI->SetSelectedAssetID(assetId, instance.GetAssetType());
|
||||
GUI->SetEditNotifyTarget(node->GetParent()->GetInstance(0));
|
||||
|
||||
GUI->blockSignals(false);
|
||||
return false;
|
||||
|
||||
+2
@@ -208,6 +208,8 @@ namespace AzToolsFramework
|
||||
void SetEditButtonIcon(const QIcon& icon);
|
||||
void SetEditButtonTooltip(QString tooltip);
|
||||
void SetBrowseButtonIcon(const QIcon& icon);
|
||||
void SetBrowseButtonEnabled(bool enabled);
|
||||
void SetBrowseButtonVisible(bool visible);
|
||||
void SetClearButtonEnabled(bool enable);
|
||||
void SetClearButtonVisible(bool visible);
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace AzToolsFramework
|
||||
virtual void AddEditMenuAction(QAction* action) = 0;
|
||||
|
||||
/// Add an action to the Editor menu.
|
||||
virtual void AddMenuAction(AZStd::string_view categoryId, QAction* action) = 0;
|
||||
virtual void AddMenuAction(AZStd::string_view categoryId, QAction* action, bool addToToolsToolbar) = 0;
|
||||
|
||||
/// (Re)populate the default EditMenu.
|
||||
/// Restore the EditMenu to its default state (the options available when first opening a level).
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "EditorContextMenu.h"
|
||||
|
||||
#include "AzToolsFramework/Viewport/ViewportMessages.h"
|
||||
#include "Editor/EditorContextMenuBus.h"
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -55,8 +56,7 @@ namespace AzToolsFramework
|
||||
|
||||
// Populate global context menu.
|
||||
const int contextMenuFlag = 0;
|
||||
EditorEvents::Bus::BroadcastReverse(
|
||||
&EditorEvents::PopulateEditorGlobalContextMenu, contextMenu.m_menu.data(),
|
||||
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu, contextMenu.m_menu.data(),
|
||||
AzFramework::Vector2FromScreenPoint(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates),
|
||||
contextMenuFlag);
|
||||
|
||||
|
||||
+20
-8
@@ -1025,6 +1025,7 @@ namespace AzToolsFramework
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
|
||||
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusConnect(entityContextId);
|
||||
EditorContextMenuBus::Handler::BusConnect();
|
||||
|
||||
CreateTransformModeSelectionCluster();
|
||||
CreateSpaceSelectionCluster();
|
||||
@@ -1045,6 +1046,7 @@ namespace AzToolsFramework
|
||||
|
||||
m_pivotOverrideFrame.Reset();
|
||||
|
||||
EditorContextMenuBus::Handler::BusConnect();
|
||||
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusDisconnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
|
||||
@@ -3126,15 +3128,25 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& /*point*/, const int /*flags*/)
|
||||
int EditorTransformComponentSelection::GetMenuPosition() const
|
||||
{
|
||||
QAction* action = menu->addAction(QObject::tr(s_togglePivotTitleRightClick));
|
||||
QObject::connect(
|
||||
action, &QAction::triggered, action,
|
||||
[this]()
|
||||
{
|
||||
ToggleCenterPivotSelection();
|
||||
});
|
||||
return aznumeric_cast<int>(EditorContextMenuOrdering::BOTTOM);
|
||||
}
|
||||
|
||||
AZStd::string EditorTransformComponentSelection::GetMenuIdentifier() const
|
||||
{
|
||||
return "Transform Component";
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::PopulateEditorGlobalContextMenu(QMenu* menu, [[maybe_unused]] const AZ::Vector2& point, [[maybe_unused]] int flags)
|
||||
{
|
||||
QAction* action = menu->addAction(QObject::tr(s_togglePivotTitleRightClick));
|
||||
QObject::connect(
|
||||
action, &QAction::triggered, action,
|
||||
[this]()
|
||||
{
|
||||
ToggleCenterPivotSelection();
|
||||
});
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::BeforeEntitySelectionChanged()
|
||||
|
||||
+7
-1
@@ -22,6 +22,7 @@
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
#include <AzToolsFramework/Commands/EntityManipulatorCommand.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
|
||||
#include <AzToolsFramework/Manipulators/BaseManipulator.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
||||
@@ -126,6 +127,7 @@ namespace AzToolsFramework
|
||||
//! Provide a suite of functionality for manipulating entities, primarily through their TransformComponent.
|
||||
class EditorTransformComponentSelection
|
||||
: public ViewportInteraction::ViewportSelectionRequests
|
||||
, public EditorContextMenuBus::Handler
|
||||
, private EditorEventsBus::Handler
|
||||
, private EditorTransformComponentSelectionRequestBus::Handler
|
||||
, private ToolsApplicationNotificationBus::Handler
|
||||
@@ -238,8 +240,12 @@ namespace AzToolsFramework
|
||||
void UndoRedoEntityManipulatorCommand(
|
||||
AZ::u8 pivotOverride, const AZ::Transform& transform, AZ::EntityId entityId) override;
|
||||
|
||||
// EditorContextMenuBus...
|
||||
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2 & point, int flags) override;
|
||||
int GetMenuPosition() const override;
|
||||
AZStd::string GetMenuIdentifier() const override;
|
||||
|
||||
// EditorEventsBus ...
|
||||
void PopulateEditorGlobalContextMenu(QMenu *menu, const AZ::Vector2& point, int flags) override;
|
||||
void OnEscape() override;
|
||||
|
||||
// ToolsApplicationNotificationBus ...
|
||||
|
||||
@@ -71,24 +71,29 @@ namespace UnitTest
|
||||
m_prefabSystemComponent->CreatePrefab({ entitiesCreated[0] }, {}, "test/path1"));
|
||||
ASSERT_TRUE(firstInstance);
|
||||
|
||||
ASSERT_TRUE(firstInstance->HasContainerEntity());
|
||||
expectedEntityNameSet.insert(firstInstance->GetContainerEntity()->get().GetName());
|
||||
|
||||
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> secondInstance(
|
||||
m_prefabSystemComponent->CreatePrefab({ entitiesCreated[1] }, MakeInstanceList(AZStd::move(firstInstance)), "test/path2"));
|
||||
ASSERT_TRUE(secondInstance);
|
||||
|
||||
ASSERT_TRUE(secondInstance->HasContainerEntity());
|
||||
expectedEntityNameSet.insert(secondInstance->GetContainerEntity()->get().GetName());
|
||||
|
||||
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> thirdInstance(
|
||||
m_prefabSystemComponent->CreatePrefab({ entitiesCreated[2] }, MakeInstanceList(AZStd::move(secondInstance)), "test/path3"));
|
||||
ASSERT_TRUE(thirdInstance);
|
||||
|
||||
ASSERT_TRUE(thirdInstance->HasContainerEntity());
|
||||
auto& containerEntity = thirdInstance->GetContainerEntity()->get();
|
||||
expectedEntityNameSet.insert(containerEntity.GetName());
|
||||
expectedEntityNameSet.insert(thirdInstance->GetContainerEntity()->get().GetName());
|
||||
|
||||
//Create Spawnable
|
||||
auto& prefabDom = m_prefabSystemComponent->FindTemplateDom(thirdInstance->GetTemplateId());
|
||||
AzFramework::Spawnable spawnable;
|
||||
AzToolsFramework::Prefab::SpawnableUtils::CreateSpawnable(spawnable, prefabDom);
|
||||
|
||||
EXPECT_EQ(spawnable.GetEntities().size() - 1, normalEntityCount); // 1 for container entity
|
||||
EXPECT_EQ(spawnable.GetEntities().size(), normalEntityCount + 3); // +1 for each container entity
|
||||
const auto& spawnableEntities = spawnable.GetEntities();
|
||||
AZStd::unordered_set<AZStd::string> actualEntityNameSet;
|
||||
|
||||
@@ -97,6 +102,6 @@ namespace UnitTest
|
||||
actualEntityNameSet.insert(spawnableEntity->GetName());
|
||||
}
|
||||
|
||||
EXPECT_EQ(expectedEntityNameSet, actualEntityNameSet);
|
||||
EXPECT_EQ(actualEntityNameSet, expectedEntityNameSet);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<Instance> convertedInstance(aznew Instance());
|
||||
ASSERT_TRUE(AzToolsFramework::Prefab::PrefabDomUtils::LoadInstanceFromPrefabDom(*convertedInstance, m_prefabDom));
|
||||
|
||||
convertedInstance->DetachNestedEntities(
|
||||
convertedInstance->DetachAllEntitiesInHierarchy(
|
||||
[this](AZStd::unique_ptr<AZ::Entity> entity)
|
||||
{
|
||||
m_runtimeEntities.emplace_back(entity.release());
|
||||
|
||||
Reference in New Issue
Block a user