AnimGraphParameterMaskHandler.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 <EMotionFX/Source/EventHandler.h>
  9. #include <Editor/PropertyWidgets/AnimGraphParameterMaskHandler.h>
  10. #include <EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterSelectionWindow.h>
  11. #include <QHBoxLayout>
  12. #include <QMessageBox>
  13. #include <QTimer>
  14. namespace EMotionFX
  15. {
  16. AZ_CLASS_ALLOCATOR_IMPL(AnimGraphParameterMaskHandler, EditorAllocator)
  17. AnimGraphParameterMaskHandler::AnimGraphParameterMaskHandler()
  18. : QObject()
  19. , AzToolsFramework::PropertyHandler<AZStd::vector<AZStd::string>, AnimGraphParameterPicker>()
  20. , m_object(nullptr)
  21. {
  22. }
  23. AZ::u32 AnimGraphParameterMaskHandler::GetHandlerName() const
  24. {
  25. return AZ_CRC("AnimGraphParameterMask", 0x67dd0993);
  26. }
  27. QWidget* AnimGraphParameterMaskHandler::CreateGUI(QWidget* parent)
  28. {
  29. AnimGraphParameterPicker* picker = aznew AnimGraphParameterPicker(parent, false, true);
  30. connect(picker, &AnimGraphParameterPicker::ParametersChanged, this, [picker]([[maybe_unused]] const AZStd::vector<AZStd::string>& newParameters)
  31. {
  32. AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
  33. &AzToolsFramework::PropertyEditorGUIMessages::Bus::Events::RequestWrite, picker);
  34. });
  35. return picker;
  36. }
  37. void AnimGraphParameterMaskHandler::ConsumeAttribute(AnimGraphParameterPicker* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
  38. {
  39. if (attrValue)
  40. {
  41. AnimGraphNode* node = static_cast<AnimGraphNode*>(attrValue->GetInstance());
  42. m_object = azdynamic_cast<ObjectAffectedByParameterChanges*>(node);
  43. GUI->SetObjectAffectedByParameterChanges(m_object);
  44. }
  45. if (attrib == AZ::Edit::Attributes::ReadOnly)
  46. {
  47. bool value;
  48. if (attrValue->Read<bool>(value))
  49. {
  50. GUI->setEnabled(!value);
  51. }
  52. }
  53. }
  54. void AnimGraphParameterMaskHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, [[maybe_unused]] AnimGraphParameterPicker* GUI, property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
  55. {
  56. // Don't update the parameter names yet, we still need the information for constructing the command group.
  57. instance = m_object->GetParameters();
  58. }
  59. bool AnimGraphParameterMaskHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, AnimGraphParameterPicker* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
  60. {
  61. QSignalBlocker signalBlocker(GUI);
  62. GUI->InitializeParameterNames(instance);
  63. return true;
  64. }
  65. } // namespace EMotionFX