ComponentHelpers.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include "ComponentAssetHelpers.h"
  10. namespace ComponentHelpers
  11. {
  12. using EntityComponentPair = AZStd::pair<AZ::EntityId, AZ::TypeId>;
  13. QList<QAction*> CreateAddComponentActions(HierarchyWidget* hierarchy,
  14. QTreeWidgetItemRawPtrQList& selectedItems,
  15. QWidget* parent);
  16. QAction* CreateRemoveComponentsAction(QWidget* parent);
  17. void UpdateRemoveComponentsAction(QAction* action);
  18. QAction* CreateCutComponentsAction(QWidget* parent);
  19. void UpdateCutComponentsAction(QAction* action);
  20. QAction* CreateCopyComponentsAction(QWidget* parent);
  21. void UpdateCopyComponentsAction(QAction* action);
  22. QAction* CreatePasteComponentsAction(QWidget* parent);
  23. void UpdatePasteComponentsAction(QAction* action);
  24. //! Returns whether a list of components can be added to all currently selected entities
  25. bool CanAddComponentsToSelectedEntities(const AZStd::vector<AZ::TypeId>& componentTypes,
  26. EntityComponentPair* firstIncompatibleComponentType = nullptr);
  27. //! Add a list of components to all currently selected entities and assign the components a primary asset
  28. void AddComponentsWithAssetToSelectedEntities(const ComponentAssetHelpers::ComponentAssetPairs& componentAssetPairs);
  29. //! Returns whether a list of components can be added to a specified entity
  30. bool CanAddComponentsToEntity(const AZStd::vector<AZ::TypeId>& componentTypes,
  31. const AZ::EntityId& entityId,
  32. EntityComponentPair* firstIncompatibleComponentType = nullptr);
  33. //! Add a list of components to a specified entity and assign the components a primary asset
  34. void AddComponentsWithAssetToEntity(const ComponentAssetHelpers::ComponentAssetPairs& componentAssetPairs, const AZ::EntityId& entityId);
  35. struct ComponentTypeData
  36. {
  37. const AZ::SerializeContext::ClassData* classData;
  38. bool isLyShineComponent;
  39. };
  40. AZStd::vector<ComponentTypeData> GetAllComponentTypesThatCanAppearInAddComponentMenu();
  41. } // namespace ComponentHelpers