Change notification buses to be addressed on EntityContextId, and connect the handlers to the default id. Request interfaces should not need that id as they can retrieve it from the entityId.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
monroegm-disable-blank-issue-2
Danilo Aimini 4 years ago
parent ce334f9443
commit c204aa1abe

@ -11,19 +11,28 @@
#include <AzCore/Component/EntityId.h>
#include <AzCore/EBus/EBus.h>
#include <AzFramework/Entity/EntityContext.h>
namespace AzToolsFramework
{
//! Used to notify when the editor focus changes.
class FocusModeNotifications
: public AZ::EBusTraits
{
protected:
~FocusModeNotifications() = default;
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AzFramework::EntityContextId;
//////////////////////////////////////////////////////////////////////////
//! Triggered when the editor focus is changed to a different entity.
//! @param entityId The entity the focus has been moved to.
virtual void OnEditorFocusChanged(AZ::EntityId entityId) = 0;
protected:
~FocusModeNotifications() = default;
};
using FocusModeNotificationBus = AZ::EBus<FocusModeNotifications>;

@ -96,6 +96,10 @@ namespace AzToolsFramework::Prefab
else
{
containerEntityId = AZ::EntityId();
// Clear the selection
AzToolsFramework::SelectEntities({});
}
// Focus on the descendants of the container entity

@ -17,12 +17,19 @@ namespace AzToolsFramework::Prefab
class PrefabFocusNotifications
: public AZ::EBusTraits
{
protected:
~PrefabFocusNotifications() = default;
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AzFramework::EntityContextId;
//////////////////////////////////////////////////////////////////////////
//! Triggered when the editor focus is changed to a different prefab.
virtual void OnPrefabFocusChanged() = 0;
protected:
~PrefabFocusNotifications() = default;
};
using PrefabFocusNotificationBus = AZ::EBus<PrefabFocusNotifications>;

@ -39,7 +39,12 @@ namespace AzToolsFramework
AZ_Assert((m_editorEntityFrameworkInterface != nullptr),
"EntityOutlinerTreeView requires a EditorEntityFrameworkInterface instance on Construction.");
FocusModeNotificationBus::Handler::BusConnect();
AzFramework::EntityContextId editorEntityContextId = AzFramework::EntityContextId::CreateNull();
AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(
editorEntityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
FocusModeNotificationBus::Handler::BusConnect(editorEntityContextId);
viewport()->setMouseTracking(true);
}

@ -6,15 +6,21 @@
*
*/
#include <AzToolsFramework/Prefab/PrefabFocusInterface.h>
#include <AzToolsFramework/UI/Prefab/PrefabViewportFocusPathHandler.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Prefab/PrefabFocusInterface.h>
namespace AzToolsFramework::Prefab
{
PrefabViewportFocusPathHandler::PrefabViewportFocusPathHandler()
{
// Connect to Prefab Focus Notifications
PrefabFocusNotificationBus::Handler::BusConnect();
AzFramework::EntityContextId editorEntityContextId = AzFramework::EntityContextId::CreateNull();
AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(
editorEntityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
PrefabFocusNotificationBus::Handler::BusConnect(editorEntityContextId);
}
PrefabViewportFocusPathHandler::~PrefabViewportFocusPathHandler()

Loading…
Cancel
Save