PropertyMotionCtrl.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "EditorDefs.h"
  9. #include "PropertyMotionCtrl.h"
  10. // AzToolsFramework
  11. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  12. #include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
  13. QWidget* MotionPropertyWidgetHandler::CreateGUI(QWidget* pParent)
  14. {
  15. AzToolsFramework::PropertyAssetCtrl* newCtrl = aznew AzToolsFramework::PropertyAssetCtrl(pParent);
  16. connect(
  17. newCtrl, &AzToolsFramework::PropertyAssetCtrl::OnAssetIDChanged, this, [newCtrl]([[maybe_unused]] AZ::Data::AssetId newAssetId) {
  18. AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
  19. &AzToolsFramework::PropertyEditorGUIMessages::Bus::Events::RequestWrite, newCtrl);
  20. AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
  21. &AzToolsFramework::PropertyEditorGUIMessages::Bus::Handler::OnEditingFinished, newCtrl);
  22. });
  23. return newCtrl;
  24. }
  25. void MotionPropertyWidgetHandler::ConsumeAttribute(
  26. [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, [[maybe_unused]] AZ::u32 attrib,
  27. [[maybe_unused]] AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
  28. {
  29. }
  30. void MotionPropertyWidgetHandler::WriteGUIValuesIntoProperty(
  31. [[maybe_unused]] size_t index, [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, property_t& instance,
  32. [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
  33. {
  34. CReflectedVarMotion val;
  35. val.m_motion = GUI->GetCurrentAssetHint();
  36. val.m_assetId = GUI->GetSelectedAssetID();
  37. instance = static_cast<property_t>(val);
  38. }
  39. bool MotionPropertyWidgetHandler::ReadValuesIntoGUI(
  40. [[maybe_unused]] size_t index, [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, const property_t& instance,
  41. [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
  42. {
  43. static const AZ::Data::AssetType emotionFXMotionAssetType(
  44. "{00494B8E-7578-4BA2-8B28-272E90680787}"); // from MotionAsset.h in EMotionFX Gem
  45. GUI->blockSignals(true);
  46. GUI->SetSelectedAssetID(instance.m_assetId);
  47. GUI->SetCurrentAssetType(emotionFXMotionAssetType);
  48. GUI->blockSignals(false);
  49. return false;
  50. }
  51. #include <Controls/ReflectedPropertyControl/moc_PropertyMotionCtrl.cpp>