UiDropdownOptionComponent.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 "UiInteractableComponent.h"
  10. #include <LyShine/Bus/UiDropdownOptionBus.h>
  11. #include <LyShine/Bus/UiInitializationBus.h>
  12. #include <LyShine/Bus/UiInteractableBus.h>
  13. #include <LyShine/UiComponentTypes.h>
  14. ////////////////////////////////////////////////////////////////////////////////////////////////////
  15. class UiDropdownOptionComponent
  16. : public AZ::Component
  17. , public UiDropdownOptionBus::Handler
  18. , public UiInitializationBus::Handler
  19. , public UiInteractableNotificationBus::Handler
  20. {
  21. public: // member functions
  22. AZ_COMPONENT(UiDropdownOptionComponent, LyShine::UiDropdownOptionComponentUuid, AZ::Component);
  23. UiDropdownOptionComponent();
  24. ~UiDropdownOptionComponent() override;
  25. // UiDropdownOptionInterface
  26. AZ::EntityId GetOwningDropdown() override;
  27. void SetOwningDropdown(AZ::EntityId owningDropdown) override;
  28. AZ::EntityId GetTextElement() override;
  29. void SetTextElement(AZ::EntityId textElement) override;
  30. AZ::EntityId GetIconElement() override;
  31. void SetIconElement(AZ::EntityId iconElement) override;
  32. // ~UiDropdownOptionInterface
  33. // UiInitializationInterface
  34. void InGamePostActivate() override;
  35. // ~UiInitializationInterface
  36. // UiInteractableNotificationBus
  37. void OnReleased() override;
  38. // ~UiInteractableNotificationBus
  39. protected: // member functions
  40. // AZ::Component
  41. void Activate() override;
  42. void Deactivate() override;
  43. // ~AZ::Component
  44. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  45. {
  46. provided.push_back(AZ_CRC("UiDropdownOptionService"));
  47. }
  48. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  49. {
  50. incompatible.push_back(AZ_CRC("UiDropdownOptionService"));
  51. }
  52. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  53. {
  54. required.push_back(AZ_CRC("UiElementService", 0x3dca7ad4));
  55. required.push_back(AZ_CRC("UiTransformService", 0x3a838e34));
  56. required.push_back(AZ_CRC("UiInteractableService", 0x1d474c98));
  57. }
  58. static void Reflect(AZ::ReflectContext* context);
  59. private: // member functions
  60. AZ_DISABLE_COPY_MOVE(UiDropdownOptionComponent);
  61. using EntityComboBoxVec = AZStd::vector< AZStd::pair< AZ::EntityId, AZStd::string > >;
  62. EntityComboBoxVec PopulateDropdownsEntityList();
  63. EntityComboBoxVec PopulateChildEntityList();
  64. private: // data
  65. AZ::EntityId m_owningDropdown;
  66. AZ::EntityId m_textElement;
  67. AZ::EntityId m_iconElement;
  68. };