sfxFMODEventGroup.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SFXFMODEVENTGROUP_H_
  23. #define _SFXFMODEVENTGROUP_H_
  24. #ifndef _SIMDATABLOCK_H_
  25. #include "console/simDatablock.h"
  26. #endif
  27. #ifndef _TVECTOR_H_
  28. #include "core/util/tVector.h"
  29. #endif
  30. #ifndef _CONSOLETYPES_H_
  31. #include "console/consoleTypes.h"
  32. #endif
  33. #include "fmod_event.h"
  34. class SFXFMODProject;
  35. class SFXFMODEvent;
  36. ///
  37. class SFXFMODEventGroup : public SimDataBlock
  38. {
  39. public:
  40. typedef SimDataBlock Parent;
  41. friend class SFXFMODProject;
  42. friend class SFXFMODEvent; // mHandle
  43. friend class SFXFMODEventSource; // mHandle
  44. protected:
  45. ///
  46. String mName;
  47. ///
  48. U32 mNumEvents;
  49. ///
  50. U32 mNumGroups;
  51. ///
  52. SFXFMODProject* mProject;
  53. ///
  54. SFXFMODEventGroup* mParent;
  55. ///
  56. SFXFMODEventGroup* mChildren;
  57. ///
  58. SFXFMODEventGroup* mSibling;
  59. ///
  60. SFXFMODEvent* mEvents;
  61. ///
  62. FMOD_EVENTGROUP* mHandle;
  63. ///
  64. U32 mLoadCount;
  65. /// Project ID for client net sync.
  66. S32 mParentId;
  67. /// Project ID for client net sync.
  68. S32 mProjectId;
  69. ///
  70. void _load();
  71. ///
  72. void _addEvent( SFXFMODEvent* event );
  73. ///
  74. void _addGroup( SFXFMODEventGroup* group );
  75. ///
  76. void _removeEvent( SFXFMODEvent* event );
  77. ///
  78. void _removeGroup( SFXFMODEventGroup* group );
  79. public:
  80. ///
  81. SFXFMODEventGroup();
  82. ///
  83. SFXFMODEventGroup( SFXFMODProject* project, const String& name, SFXFMODEventGroup* parent = NULL );
  84. ///
  85. SFXFMODEventGroup( SFXFMODProject* project, FMOD_EVENTGROUP* handle, SFXFMODEventGroup* parent = NULL );
  86. ~SFXFMODEventGroup();
  87. /// Create the event group object on the FMOD device.
  88. void acquire( bool recursive = false );
  89. /// Release the event group object on the FMOD device.
  90. void release();
  91. ///
  92. const String& getGroupName() const { return mName; }
  93. ///
  94. String getQualifiedName() const;
  95. ///
  96. SFXFMODProject* getProject() const { return mProject; }
  97. /// Return true if the event data for this group has been loaded.
  98. bool isDataLoaded() const;
  99. /// Load the event data for this group.
  100. ///
  101. /// @note Loading is reference-counted.
  102. bool loadData( bool samples = true, bool streams = true );
  103. ///
  104. void freeData( bool force = false );
  105. // SimDataBlock.
  106. virtual bool onAdd();
  107. virtual void onRemove();
  108. virtual bool preload( bool server, String& errorStr );
  109. virtual void packData( BitStream* stream );
  110. virtual void unpackData( BitStream* stream );
  111. static void initPersistFields();
  112. DECLARE_CONOBJECT( SFXFMODEventGroup );
  113. DECLARE_CATEGORY( "SFX FMOD" );
  114. DECLARE_DESCRIPTION( "An event group in an FMOD Designer project." );
  115. };
  116. #endif // !_SFXFMODEVENTGROUP_H_