3
0

DebugDrawTextComponent.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #include <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include "DebugDrawTextComponent.h"
  11. namespace DebugDraw
  12. {
  13. void DebugDrawTextElement::Reflect(AZ::ReflectContext* context)
  14. {
  15. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  16. if (serializeContext)
  17. {
  18. serializeContext->Class<DebugDrawTextElement>()
  19. ->Version(0)
  20. ->Field("Text", &DebugDrawTextElement::m_text)
  21. ->Field("Color", &DebugDrawTextElement::m_color)
  22. ->Field("DrawMode", &DebugDrawTextElement::m_drawMode)
  23. ->Field("WorldLocation", &DebugDrawTextElement::m_worldLocation)
  24. ->Field("TargetEntity", &DebugDrawTextElement::m_targetEntityId)
  25. ;
  26. AZ::EditContext* editContext = serializeContext->GetEditContext();
  27. if (editContext)
  28. {
  29. editContext->Class<DebugDrawTextElement>("DebugDraw Text element settings", "Settings for DebugDraw text element.")
  30. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  31. ->Attribute(AZ::Edit::Attributes::Category, "Debugging")
  32. ->DataElement(0, &DebugDrawTextElement::m_text, "Text", "The Debug Text.")
  33. ->DataElement(0, &DebugDrawTextElement::m_color, "Color", "Text Color.")
  34. ->DataElement(0, &DebugDrawTextElement::m_drawMode, "Draw Mode", "Draw Mode Preference.")
  35. ->DataElement(AZ::Edit::UIHandlers::ComboBox, &DebugDrawTextElement::m_drawMode, "Draw Mode", "Draw Mode Preference.")
  36. ->EnumAttribute(DrawMode::OnScreen, "Screen Space")
  37. ->EnumAttribute(DrawMode::InWorld, "World Space")
  38. // Currently supports World Space placement on component owners location Or exact placement via behavior context / scripting (TBC)
  39. //->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
  40. //->DataElement(AZ::Edit::UIHandlers::Default, &DebugDrawTextElement::m_targetEntityId, "TargetEntity", "The target entity to position debug text at.")
  41. //->Attribute(AZ::Edit::Attributes::Visibility, &DebugDrawTextElement::isWorldSpace)
  42. ;
  43. }
  44. }
  45. }
  46. void DebugDrawTextComponent::Reflect(AZ::ReflectContext* context)
  47. {
  48. DebugDrawTextElement::Reflect(context);
  49. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  50. {
  51. serialize->Class<DebugDrawTextComponent, AZ::Component>()
  52. ->Version(0)
  53. ->Field("TextElement", &DebugDrawTextComponent::m_element)
  54. ;
  55. }
  56. }
  57. DebugDrawTextComponent::DebugDrawTextComponent(const DebugDrawTextElement& textElement)
  58. : m_element(textElement)
  59. {
  60. m_element.m_owningEditorComponent = AZ::InvalidComponentId;
  61. }
  62. void DebugDrawTextComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  63. {
  64. provided.push_back(AZ_CRC("DebugDrawTextService", 0xabd60a17));
  65. }
  66. void DebugDrawTextComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  67. {
  68. (void)incompatible;
  69. }
  70. void DebugDrawTextComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  71. {
  72. (void)required;
  73. }
  74. void DebugDrawTextComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  75. {
  76. (void)dependent;
  77. }
  78. void DebugDrawTextComponent::Init()
  79. {
  80. }
  81. void DebugDrawTextComponent::Activate()
  82. {
  83. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
  84. }
  85. void DebugDrawTextComponent::Deactivate()
  86. {
  87. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
  88. }
  89. } // namespace DebugDraw