EditorWhiteBoxSystemComponent.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 "Asset/WhiteBoxMeshAsset.h"
  9. #include "Asset/WhiteBoxMeshAssetHandler.h"
  10. #include "EditorWhiteBoxSystemComponent.h"
  11. #include "EditorWhiteBoxComponentMode.h"
  12. #include "WhiteBoxToolApiReflection.h"
  13. #include <AzCore/Serialization/SerializeContext.h>
  14. namespace WhiteBox
  15. {
  16. void EditorWhiteBoxSystemComponent::Reflect(AZ::ReflectContext* context)
  17. {
  18. WhiteBox::Reflect(context);
  19. EditorWhiteBoxComponentMode::Reflect(context);
  20. if (auto serialize = azrtti_cast<AZ::SerializeContext*>(context))
  21. {
  22. serialize->Class<EditorWhiteBoxSystemComponent, WhiteBoxSystemComponent>()->Version(1);
  23. }
  24. }
  25. template<typename AssetHandlerT, typename AssetT>
  26. void RegisterAsset(AZStd::vector<AZStd::unique_ptr<AZ::Data::AssetHandler>>& assetHandlers)
  27. {
  28. AZ::Data::AssetCatalogRequestBus::Broadcast(
  29. &AZ::Data::AssetCatalogRequests::EnableCatalogForAsset, AZ::AzTypeInfo<AssetT>::Uuid());
  30. AZ::Data::AssetCatalogRequestBus::Broadcast(
  31. &AZ::Data::AssetCatalogRequests::AddExtension, AssetHandlerT::AssetFileExtension);
  32. assetHandlers.emplace_back(AZStd::make_unique<AssetHandlerT>());
  33. }
  34. void EditorWhiteBoxSystemComponent::OnActionContextModeRegistrationHook()
  35. {
  36. EditorWhiteBoxComponentMode::RegisterActionContextModes();
  37. }
  38. void EditorWhiteBoxSystemComponent::OnActionUpdaterRegistrationHook()
  39. {
  40. EditorWhiteBoxComponentMode::RegisterActionUpdaters();
  41. }
  42. void EditorWhiteBoxSystemComponent::OnActionRegistrationHook()
  43. {
  44. EditorWhiteBoxComponentMode::RegisterActions();
  45. }
  46. void EditorWhiteBoxSystemComponent::OnActionContextModeBindingHook()
  47. {
  48. EditorWhiteBoxComponentMode::BindActionsToModes();
  49. }
  50. void EditorWhiteBoxSystemComponent::OnMenuBindingHook()
  51. {
  52. EditorWhiteBoxComponentMode::BindActionsToMenus();
  53. }
  54. void EditorWhiteBoxSystemComponent::Activate()
  55. {
  56. WhiteBoxSystemComponent::Activate();
  57. RegisterAsset<Pipeline::WhiteBoxMeshAssetHandler, Pipeline::WhiteBoxMeshAsset>(m_assetHandlers);
  58. AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusConnect();
  59. }
  60. void EditorWhiteBoxSystemComponent::Deactivate()
  61. {
  62. AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusDisconnect();
  63. WhiteBoxSystemComponent::Deactivate();
  64. }
  65. void EditorWhiteBoxSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  66. {
  67. dependent.push_back(AZ_CRC_CE("AssetDatabaseService"));
  68. }
  69. } // namespace WhiteBox