TrackViewSequenceManager.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCEMANAGER_H
  9. #define CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCEMANAGER_H
  10. #pragma once
  11. #include "TrackViewSequence.h"
  12. #include <AzCore/Component/EntityBus.h>
  13. class CTrackViewSequenceManager
  14. : public IEditorNotifyListener
  15. , public ITrackViewSequenceManager
  16. , public AZ::EntitySystemBus::Handler
  17. {
  18. public:
  19. CTrackViewSequenceManager();
  20. ~CTrackViewSequenceManager();
  21. void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
  22. unsigned int GetCount() const { return static_cast<int>(m_sequences.size()); }
  23. void CreateSequence(QString name, SequenceType sequenceType);
  24. void DeleteSequence(CTrackViewSequence* pSequence);
  25. void RenameNode(CTrackViewAnimNode* pAnimNode, const char* newName) const;
  26. CTrackViewSequence* GetSequenceByName(QString name) const override;
  27. CTrackViewSequence* GetSequenceByEntityId(const AZ::EntityId& entityId) const override;
  28. CTrackViewSequence* GetSequenceByIndex(unsigned int index) const;
  29. CTrackViewSequence* GetSequenceByAnimSequence(IAnimSequence* pAnimSequence) const;
  30. CTrackViewAnimNodeBundle GetAllRelatedAnimNodes(AZ::EntityId entityId) const;
  31. CTrackViewAnimNode* GetActiveAnimNode(AZ::EntityId entityId) const;
  32. void AddListener(ITrackViewSequenceManagerListener* pListener) { stl::push_back_unique(m_listeners, pListener); }
  33. void RemoveListener(ITrackViewSequenceManagerListener* pListener) { stl::find_and_erase(m_listeners, pListener); }
  34. // ITrackViewSequenceManager Overrides
  35. // Callback from SequenceObject
  36. IAnimSequence* OnCreateSequenceObject(QString name, bool isLegacySequence = true, AZ::EntityId entityId = AZ::EntityId()) override;
  37. void OnDeleteSequenceEntity(const AZ::EntityId& entityId) override;
  38. void OnCreateSequenceComponent(AZStd::intrusive_ptr<IAnimSequence>& sequence) override;
  39. void OnSequenceActivated(const AZ::EntityId& entityId) override;
  40. void OnSequenceDeactivated(const AZ::EntityId& entityId) override;
  41. //~ ITrackViewSequenceManager Overrides
  42. private:
  43. void AddTrackViewSequence(CTrackViewSequence* sequenceToAdd);
  44. void RemoveSequenceInternal(CTrackViewSequence* sequence);
  45. void SortSequences();
  46. void ResumeAllSequences();
  47. void OnSequenceAdded(CTrackViewSequence* pSequence);
  48. void OnSequenceRemoved(CTrackViewSequence* pSequence);
  49. // AZ::EntitySystemBus
  50. void OnEntityNameChanged(const AZ::EntityId& entityId, const AZStd::string& name) override;
  51. void OnEntityDestruction(const AZ::EntityId& entityId) override;
  52. std::vector<ITrackViewSequenceManagerListener*> m_listeners;
  53. std::vector<std::unique_ptr<CTrackViewSequence> > m_sequences;
  54. // Set to hold sequences that existed when undo transaction began
  55. std::set<CTrackViewSequence*> m_transactionSequences;
  56. bool m_bUnloadingLevel;
  57. // Used to handle object attach/detach
  58. std::unordered_map<CTrackViewNode*, Matrix34> m_prevTransforms;
  59. };
  60. #endif // CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCEMANAGER_H