Minor fixes to variable names and comments.
Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
@@ -13,26 +13,26 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/*!
|
||||
* FocusModeInterface
|
||||
* Interface to handle the Editor Focus Mode.
|
||||
*/
|
||||
//! FocusModeInterface
|
||||
//! Interface to handle the Editor Focus Mode.
|
||||
class FocusModeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(FocusModeInterface, "{437243B0-F86B-422F-B7B8-4A21CC000702}");
|
||||
|
||||
//! Sets the root entity the Editor should focus on.
|
||||
//! The Editor will only allow the user to select entities belonging to the sub-tree that has root in the entityId provided.
|
||||
//! The Editor will only allow the user to select entities that are descendants of the EntityId provided.
|
||||
//! @param entityId The entityId that will become the new focus root.
|
||||
virtual void SetFocusRoot(AZ::EntityId entityId) = 0;
|
||||
|
||||
//! Clears the Editor focus, allowing the user to select the whole level again.
|
||||
virtual void ClearFocusRoot() = 0;
|
||||
|
||||
//! Returns the entity id of the root of the current Editor focus.
|
||||
//! @return The id of the entity that is the root of the Editor focus.
|
||||
//! @return The entity id of the root of the Editor focus, or an invalid entity id if no focus is set.
|
||||
virtual AZ::EntityId GetFocusRoot() = 0;
|
||||
|
||||
//! Returns whether the entity id provided is part of the focused sub-tree.
|
||||
//! @return True if entityId belongs to the focused sub-tree, false otherwise.
|
||||
virtual bool IsInFocusSubTree(AZ::EntityId entityId) = 0;
|
||||
};
|
||||
|
||||
|
||||
+20
-20
@@ -15,6 +15,24 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
bool IsInFocusSubTree(AZ::EntityId entityId, AZ::EntityId focusRootId)
|
||||
{
|
||||
if (entityId == AZ::EntityId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entityId == focusRootId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AZ::EntityId parentId;
|
||||
AZ::TransformBus::EventResult(parentId, entityId, &AZ::TransformInterface::GetParentId);
|
||||
|
||||
return IsInFocusSubTree(parentId, focusRootId);
|
||||
}
|
||||
|
||||
FocusModeSystemComponent::~FocusModeSystemComponent()
|
||||
{
|
||||
AZ::Interface<FocusModeInterface>::Unregister(this);
|
||||
@@ -33,7 +51,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
}
|
||||
|
||||
void FocusModeSystemComponent::Reflect(AZ::ReflectContext* /*context*/)
|
||||
void FocusModeSystemComponent::Reflect([[maybe_unused]] AZ::ReflectContext* context)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,25 +87,7 @@ namespace AzToolsFramework
|
||||
return true;
|
||||
}
|
||||
|
||||
return IsInFocusSubTree_helper(entityId, m_focusRoot);
|
||||
}
|
||||
|
||||
bool FocusModeSystemComponent::IsInFocusSubTree_helper(AZ::EntityId entityId, AZ::EntityId focusRootId)
|
||||
{
|
||||
if (entityId == AZ::EntityId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entityId == focusRootId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AZ::EntityId parentId;
|
||||
AZ::TransformBus::EventResult(parentId, entityId, &AZ::TransformInterface::GetParentId);
|
||||
|
||||
return IsInFocusSubTree_helper(parentId, focusRootId);
|
||||
return AzToolsFramework::IsInFocusSubTree(entityId, m_focusRoot);
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+5
-4
@@ -15,6 +15,9 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
bool IsInFocusSubTree(AZ::EntityId entityId, AZ::EntityId focusRootId);
|
||||
|
||||
//! System Component to handle the Editor Focus Mode system
|
||||
class FocusModeSystemComponent final
|
||||
: public AZ::Component
|
||||
, private FocusModeInterface
|
||||
@@ -25,7 +28,7 @@ namespace AzToolsFramework
|
||||
FocusModeSystemComponent() = default;
|
||||
virtual ~FocusModeSystemComponent();
|
||||
|
||||
// AZ::Component...
|
||||
// AZ::Component overrides ...
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
@@ -35,14 +38,12 @@ namespace AzToolsFramework
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
|
||||
// FocusModeInterface...
|
||||
// FocusModeInterface overrides ...
|
||||
void SetFocusRoot(AZ::EntityId entityId) override;
|
||||
AZ::EntityId GetFocusRoot() override;
|
||||
bool IsInFocusSubTree(AZ::EntityId entityId) override;
|
||||
|
||||
private:
|
||||
static bool IsInFocusSubTree_helper(AZ::EntityId entityId, AZ::EntityId focusRootId);
|
||||
|
||||
AZ::EntityId m_focusRoot;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
namespace AzToolsFramework::Prefab
|
||||
{
|
||||
FocusModeInterface* PrefabFocusHandler::s_focusModeInterface = nullptr;
|
||||
InstanceEntityMapperInterface* PrefabFocusHandler::s_instanceEntityMapperInterface = nullptr;
|
||||
PrefabEditorEntityOwnershipInterface* PrefabFocusHandler::s_prefabEditorEntityOwnershipInterface = nullptr;
|
||||
|
||||
PrefabFocusHandler::~PrefabFocusHandler()
|
||||
{
|
||||
AZ::Interface<PrefabFocusInterface>::Unregister(this);
|
||||
@@ -25,23 +21,23 @@ namespace AzToolsFramework::Prefab
|
||||
|
||||
void PrefabFocusHandler::Initialize()
|
||||
{
|
||||
s_focusModeInterface = AZ::Interface<FocusModeInterface>::Get();
|
||||
m_focusModeInterface = AZ::Interface<FocusModeInterface>::Get();
|
||||
AZ_Assert(
|
||||
s_focusModeInterface,
|
||||
m_focusModeInterface,
|
||||
"Prefab - PrefabFocusHandler - "
|
||||
"Focus Mode Interface could not be found. "
|
||||
"Check that it is being correctly initialized.");
|
||||
|
||||
s_instanceEntityMapperInterface = AZ::Interface<InstanceEntityMapperInterface>::Get();
|
||||
m_instanceEntityMapperInterface = AZ::Interface<InstanceEntityMapperInterface>::Get();
|
||||
AZ_Assert(
|
||||
s_instanceEntityMapperInterface,
|
||||
m_instanceEntityMapperInterface,
|
||||
"Prefab - PrefabFocusHandler - "
|
||||
"Instance Entity Mapper Interface could not be found. "
|
||||
"Check that it is being correctly initialized.");
|
||||
|
||||
s_prefabEditorEntityOwnershipInterface = AZ::Interface<PrefabEditorEntityOwnershipInterface>::Get();
|
||||
m_prefabEditorEntityOwnershipInterface = AZ::Interface<PrefabEditorEntityOwnershipInterface>::Get();
|
||||
AZ_Assert(
|
||||
s_prefabEditorEntityOwnershipInterface,
|
||||
m_prefabEditorEntityOwnershipInterface,
|
||||
"Prefab - PrefabFocusHandler - "
|
||||
"Prefab Editor Entity Ownership Interface could not be found. "
|
||||
"Check that it is being correctly initialized.");
|
||||
@@ -51,16 +47,9 @@ namespace AzToolsFramework::Prefab
|
||||
|
||||
PrefabFocusOperationResult PrefabFocusHandler::FocusOnOwningPrefab(AZ::EntityId entityId)
|
||||
{
|
||||
InstanceOptionalReference focusedInstance;
|
||||
|
||||
if (entityId == AZ::EntityId())
|
||||
{
|
||||
focusedInstance = s_prefabEditorEntityOwnershipInterface->GetRootPrefabInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
focusedInstance = s_instanceEntityMapperInterface->FindOwningInstance(entityId);
|
||||
}
|
||||
InstanceOptionalReference focusedInstance = (entityId == AZ::EntityId())
|
||||
? m_prefabEditorEntityOwnershipInterface->GetRootPrefabInstance()
|
||||
: m_instanceEntityMapperInterface->FindOwningInstance(entityId);
|
||||
|
||||
if (!focusedInstance.has_value())
|
||||
{
|
||||
@@ -70,7 +59,7 @@ namespace AzToolsFramework::Prefab
|
||||
|
||||
m_focusedInstance = focusedInstance;
|
||||
m_focusedTemplateId = focusedInstance->get().GetTemplateId();
|
||||
s_focusModeInterface->SetFocusRoot(focusedInstance->get().GetContainerEntityId());
|
||||
m_focusModeInterface->SetFocusRoot(focusedInstance->get().GetContainerEntityId());
|
||||
|
||||
return AZ::Success();
|
||||
}
|
||||
@@ -92,7 +81,7 @@ namespace AzToolsFramework::Prefab
|
||||
return false;
|
||||
}
|
||||
|
||||
InstanceOptionalReference instance = s_instanceEntityMapperInterface->FindOwningInstance(entityId);
|
||||
InstanceOptionalReference instance = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
|
||||
|
||||
return instance.has_value() && (&instance->get() == &m_focusedInstance->get());
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace AzToolsFramework::Prefab
|
||||
{
|
||||
class InstanceEntityMapperInterface;
|
||||
|
||||
//! Handles Prefab Focus mode, determining which prefab file entity changes will target.
|
||||
class PrefabFocusHandler final
|
||||
: private PrefabFocusInterface
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace AzToolsFramework::Prefab
|
||||
|
||||
void Initialize();
|
||||
|
||||
// PrefabFocusInterface...
|
||||
// PrefabFocusInterface override ...
|
||||
PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override;
|
||||
TemplateId GetFocusedPrefabTemplateId() override;
|
||||
InstanceOptionalReference GetFocusedPrefabInstance() override;
|
||||
@@ -44,9 +45,9 @@ namespace AzToolsFramework::Prefab
|
||||
InstanceOptionalReference m_focusedInstance;
|
||||
TemplateId m_focusedTemplateId;
|
||||
|
||||
static FocusModeInterface* s_focusModeInterface;
|
||||
static InstanceEntityMapperInterface* s_instanceEntityMapperInterface;
|
||||
static PrefabEditorEntityOwnershipInterface* s_prefabEditorEntityOwnershipInterface;
|
||||
FocusModeInterface* m_focusModeInterface;
|
||||
InstanceEntityMapperInterface* m_instanceEntityMapperInterface;
|
||||
PrefabEditorEntityOwnershipInterface* m_prefabEditorEntityOwnershipInterface;
|
||||
};
|
||||
|
||||
} // namespace AzToolsFramework::Prefab
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
namespace AzToolsFramework::Prefab
|
||||
{
|
||||
typedef AZ::Outcome<void, AZStd::string> PrefabFocusOperationResult;
|
||||
using PrefabFocusOperationResult = AZ::Outcome<void, AZStd::string>;
|
||||
|
||||
/*!
|
||||
* PrefabFocusInterface
|
||||
*/
|
||||
//! Interface to handle operations related to the Prefab Focus system.
|
||||
class PrefabFocusInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(PrefabFocusInterface, "{F3CFA37B-5FD8-436A-9C30-60EB54E350E1}");
|
||||
|
||||
//! Set the focused prefab instance to the owning instance of the entityId provided
|
||||
//! Set the focused prefab instance to the owning instance of the entityId provided.
|
||||
//! @param entityId The entityId of the entity whose owning instance we want the prefab system to focus on.
|
||||
virtual PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user