diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp index 3ad2dbdfb8..d82ce9ffeb 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeSystemComponent.cpp @@ -10,6 +10,7 @@ #include +#include #include namespace AzToolsFramework::FocusModeFramework @@ -53,8 +54,7 @@ namespace AzToolsFramework::FocusModeFramework { m_focusRoot = entityId; - // TODO - If m_focusRoot != AZ::EntityId(), register focus mode - // Else, unregister focus mode + // TODO - If m_focusRoot != AZ::EntityId(), activate focus mode via ViewportEditorModeTrackerInterface; else, deactivate focus mode } AZ::EntityId FocusModeSystemComponent::GetFocusRoot() diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp index a9c8c93eb0..ee663c0c3f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp @@ -49,7 +49,7 @@ namespace AzToolsFramework::Prefab AZ::Interface::Register(this); } - void PrefabFocusHandler::FocusOnOwningPrefab(AZ::EntityId entityId) + PrefabFocusOperationResult PrefabFocusHandler::FocusOnOwningPrefab(AZ::EntityId entityId) { InstanceOptionalReference focusedInstance; @@ -64,12 +64,15 @@ namespace AzToolsFramework::Prefab if (!focusedInstance.has_value()) { - // TODO - ERROR + return AZ::Failure(AZStd::string( + "Prefab Focus Handler: Couldn't find owning instance of entityId provided.")); } m_focusedInstance = focusedInstance; m_focusedTemplateId = focusedInstance->get().GetTemplateId(); s_focusModeInterface->SetFocusRoot(focusedInstance->get().GetContainerEntityId()); + + return AZ::Success(); } TemplateId PrefabFocusHandler::GetFocusedPrefabTemplateId() @@ -86,16 +89,12 @@ namespace AzToolsFramework::Prefab { if (entityId == AZ::EntityId()) { - // TODO - Warn? return false; } InstanceOptionalReference instance = s_instanceEntityMapperInterface->FindOwningInstance(entityId); - if (!instance.has_value()) - { - // TODO - ERROR - } + AZ_Assert(instance.has_value(), "PrefabFocusHandler::IsOwningPrefabBeingFocused - Could not find owning Instance of queried entity."); return (&instance->get() == &m_focusedInstance->get()); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h index 44e84dc345..bf8b6994d1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.h @@ -39,7 +39,7 @@ namespace AzToolsFramework::Prefab void Initialize(); // PrefabFocusInterface... - void FocusOnOwningPrefab(AZ::EntityId entityId) override; + PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override; TemplateId GetFocusedPrefabTemplateId() override; InstanceOptionalReference GetFocusedPrefabInstance() override; bool IsOwningPrefabBeingFocused(AZ::EntityId entityId) override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h index d18a669f51..7b867ab8d2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusInterface.h @@ -16,6 +16,8 @@ namespace AzToolsFramework::Prefab { + typedef AZ::Outcome PrefabFocusOperationResult; + /*! * PrefabFocusInterface */ @@ -24,16 +26,19 @@ namespace AzToolsFramework::Prefab public: AZ_RTTI(PrefabFocusInterface, "{F3CFA37B-5FD8-436A-9C30-60EB54E350E1}"); - // TODO - Add comment - virtual void FocusOnOwningPrefab(AZ::EntityId entityId) = 0; + //! 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; - // TODO - Add comment + //! Returns the template id of the instance the prefab system is focusing on. virtual TemplateId GetFocusedPrefabTemplateId() = 0; - // TODO - Add comment + //! Returns a reference to the instance the prefab system is focusing on. virtual InstanceOptionalReference GetFocusedPrefabInstance() = 0; - // TODO - Add comment + //! Returns whether the entity belongs to the instance that is being focused on, or one of its descendants. + //! @param entityId The entityId of the queried entity. + //! @return true if the entity belongs to the focused instance or one of its descendants, false otherwise. virtual bool IsOwningPrefabBeingFocused(AZ::EntityId entityId) = 0; };