476e66d902
* First step of procedural prefab styling and read-only registration. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * WIP - Introduce read-only handler for procedural prefabs (not hooked up) Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Introduce read-only entity interface, handler and unit tests. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Introduce temp read-only icon, use new icon hierarchy in Outliner. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Switch from a push paradigm to a pull paradigm - handlers get to implement logic to determine if an entity should be read-only. This allows multiple systems to weigh into whether an entity is read-only. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Fixed to missing call in test Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Post-rebase fixes to class name changes Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Display a lock icon on top of the entity icon in the Entity Outliner. This icon is added programmatically, which prevents having to alter all Outliner icons and future-proofs this functionality. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Minor style changes to procedural prefabs in the Outliner (use white icon) Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Ensure cache is refreshed when the handler is created, and also whenever the focus changes. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Remove Procedural Prefab setreg that was added in the wrong place Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Remove redundant function Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Fix spacing issue caused by rebase Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Change tooltip so that it accurately says "inspect" instead of "edit" for procedural prefabs. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Address minor styling issues mentioned in PR. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
101 lines
4.7 KiB
C++
101 lines
4.7 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AzCore/Memory/SystemAllocator.h>
|
|
|
|
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
|
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
|
#include <AzToolsFramework/FocusMode/FocusModeInterface.h>
|
|
#include <AzToolsFramework/Prefab/PrefabFocusInterface.h>
|
|
#include <AzToolsFramework/Prefab/PrefabFocusPublicInterface.h>
|
|
#include <AzToolsFramework/Prefab/PrefabPublicNotificationBus.h>
|
|
#include <AzToolsFramework/Prefab/Template/Template.h>
|
|
|
|
namespace AzToolsFramework
|
|
{
|
|
class ContainerEntityInterface;
|
|
class FocusModeInterface;
|
|
class ReadOnlyEntityQueryInterface;
|
|
}
|
|
|
|
namespace AzToolsFramework::Prefab
|
|
{
|
|
class InstanceEntityMapperInterface;
|
|
|
|
//! Handles Prefab Focus mode, determining which prefab file entity changes will target.
|
|
class PrefabFocusHandler final
|
|
: public PrefabFocusPublicRequestBus::Handler
|
|
, private PrefabFocusInterface
|
|
, private PrefabPublicNotificationBus::Handler
|
|
, private EditorEntityContextNotificationBus::Handler
|
|
, private EditorEntityInfoNotificationBus::Handler
|
|
{
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(PrefabFocusHandler, AZ::SystemAllocator, 0);
|
|
|
|
PrefabFocusHandler();
|
|
~PrefabFocusHandler();
|
|
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
|
|
// PrefabFocusInterface overrides ...
|
|
void InitializeEditorInterfaces() override;
|
|
PrefabFocusOperationResult FocusOnPrefabInstanceOwningEntityId(AZ::EntityId entityId) override;
|
|
TemplateId GetFocusedPrefabTemplateId(AzFramework::EntityContextId entityContextId) const override;
|
|
InstanceOptionalReference GetFocusedPrefabInstance(AzFramework::EntityContextId entityContextId) const override;
|
|
|
|
// PrefabFocusPublicInterface and PrefabFocusPublicRequestBus overrides ...
|
|
PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override;
|
|
PrefabFocusOperationResult FocusOnParentOfFocusedPrefab(AzFramework::EntityContextId entityContextId) override;
|
|
PrefabFocusOperationResult FocusOnPathIndex(AzFramework::EntityContextId entityContextId, int index) override;
|
|
AZ::EntityId GetFocusedPrefabContainerEntityId(AzFramework::EntityContextId entityContextId) const override;
|
|
bool IsOwningPrefabBeingFocused(AZ::EntityId entityId) const override;
|
|
bool IsOwningPrefabInFocusHierarchy(AZ::EntityId entityId) const override;
|
|
const AZ::IO::Path& GetPrefabFocusPath(AzFramework::EntityContextId entityContextId) const override;
|
|
const int GetPrefabFocusPathLength(AzFramework::EntityContextId entityContextId) const override;
|
|
|
|
// EditorEntityContextNotificationBus overrides ...
|
|
void OnContextReset() override;
|
|
|
|
// EditorEntityInfoNotificationBus overrides ...
|
|
void OnEntityInfoUpdatedName(AZ::EntityId entityId, const AZStd::string& name) override;
|
|
|
|
// PrefabPublicNotifications overrides ...
|
|
void OnPrefabInstancePropagationEnd() override;
|
|
void OnPrefabTemplateDirtyFlagUpdated(TemplateId templateId, bool status) override;
|
|
|
|
private:
|
|
PrefabFocusOperationResult FocusOnPrefabInstance(InstanceOptionalReference focusedInstance);
|
|
void RefreshInstanceFocusList();
|
|
void RefreshInstanceFocusPath();
|
|
|
|
void OpenInstanceContainers(const AZStd::vector<AZ::EntityId>& instances) const;
|
|
void CloseInstanceContainers(const AZStd::vector<AZ::EntityId>& instances) const;
|
|
|
|
InstanceOptionalReference GetReferenceFromContainerEntityId(AZ::EntityId containerEntityId) const;
|
|
|
|
//! The EntityId of the prefab container entity for the instance the editor is currently focusing on.
|
|
AZ::EntityId m_focusedInstanceContainerEntityId = AZ::EntityId();
|
|
//! The templateId of the focused instance.
|
|
TemplateId m_focusedTemplateId;
|
|
//! The list of instances going from the root (index 0) to the focused instance,
|
|
//! referenced by their prefab container's EntityId.
|
|
AZStd::vector<AZ::EntityId> m_instanceFocusHierarchy;
|
|
//! A path containing the filenames of the instances in the focus hierarchy, separated with a /.
|
|
AZ::IO::Path m_instanceFocusPath;
|
|
|
|
ContainerEntityInterface* m_containerEntityInterface = nullptr;
|
|
FocusModeInterface* m_focusModeInterface = nullptr;
|
|
InstanceEntityMapperInterface* m_instanceEntityMapperInterface = nullptr;
|
|
ReadOnlyEntityQueryInterface* m_readOnlyEntityQueryInterface = nullptr;
|
|
};
|
|
|
|
} // namespace AzToolsFramework::Prefab
|