sfxTrack.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  23. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  24. // Copyright (C) 2015 Faust Logic, Inc.
  25. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  26. #ifndef _SFXTRACK_H_
  27. #define _SFXTRACK_H_
  28. #ifndef _SIMDATABLOCK_H_
  29. #include "console/simDatablock.h"
  30. #endif
  31. #ifndef _CONSOLETYPES_H_
  32. #include "console/consoleTypes.h"
  33. #endif
  34. class SFXDescription;
  35. /// A datablock that describes sound data for playback.
  36. class SFXTrack : public SimDataBlock
  37. {
  38. public:
  39. typedef SimDataBlock Parent;
  40. enum
  41. {
  42. /// Maximum numbers of parameters that can be pre-assigned to tracks.
  43. MaxNumParameters = 8
  44. };
  45. protected:
  46. /// The description which controls playback settings.
  47. SFXDescription *mDescription;
  48. /// Name of the parameters to which sources playing this track should
  49. /// connect.
  50. StringTableEntry mParameters[ MaxNumParameters ];
  51. /// Overload this to disable direct instantiation of this class via script 'new'.
  52. virtual bool processArguments( S32 argc, ConsoleValue *argv );
  53. public:
  54. ///
  55. SFXTrack();
  56. ///
  57. SFXTrack( SFXDescription* description );
  58. /// Returns the description object for this sound profile.
  59. SFXDescription* getDescription() const { return mDescription; }
  60. void setDescription(SFXDescription* desc) { mDescription = desc; }
  61. ///
  62. StringTableEntry getParameter( U32 index ) const
  63. {
  64. AssertFatal( index < MaxNumParameters, "SFXTrack::getParameter() - index out of range" );
  65. return mParameters[ index ];
  66. }
  67. ///
  68. void setParameter( U32 index, const char* name );
  69. // SimDataBlock.
  70. virtual void packData( BitStream* stream );
  71. virtual void unpackData( BitStream* stream );
  72. virtual bool preload( bool server, String& errorStr );
  73. virtual bool onAdd();
  74. virtual void inspectPostApply();
  75. static void initPersistFields();
  76. DECLARE_CONOBJECT( SFXTrack );
  77. DECLARE_CATEGORY( "SFX" );
  78. DECLARE_DESCRIPTION( "Abstract base class for any kind of data that can be turned into SFXSources." );
  79. public:
  80. /*C*/ SFXTrack(const SFXTrack&, bool = false);
  81. };
  82. #endif // !_SFXTRACK_H_