SndRelay.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // SndRelay.H
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 08/11/97 JMI Stole infrastructure from SoundThing.
  23. //
  24. //////////////////////////////////////////////////////////////////////////////
  25. //
  26. // This CThing-derived class will relay sound volumes based on
  27. // DistanceToVolume() (i.e., the distance to the ear (usually the local dude))
  28. // to the selected CSoundThing.
  29. //
  30. //////////////////////////////////////////////////////////////////////////////
  31. #ifndef SNDRELAY_H
  32. #define SNDRELAY_H
  33. #include "RSPiX.h"
  34. #include "realm.h"
  35. #include "SampleMaster.h"
  36. class CSndRelay : public CThing
  37. {
  38. //---------------------------------------------------------------------------
  39. // Types, enums, etc.
  40. //---------------------------------------------------------------------------
  41. public:
  42. typedef enum
  43. {
  44. State_Happy, // La, la, la.
  45. State_Delete // Delete self next chance.
  46. } State;
  47. //---------------------------------------------------------------------------
  48. // Variables
  49. //---------------------------------------------------------------------------
  50. public:
  51. bool m_bInitiallyEnabled;
  52. CSprite2 m_sprite; // Sprite (for editor only)
  53. double m_dX; // x coord.
  54. double m_dY; // y coord.
  55. double m_dZ; // z coord.
  56. bool m_bEnabled;
  57. short m_sSuspend; // Suspend flag
  58. State m_state; // Current state.
  59. U16 m_idParent; // Parent CSoundThing.
  60. protected:
  61. static short ms_sFileCount; // File count.
  62. //---------------------------------------------------------------------------
  63. // Constructor(s) / destructor
  64. //---------------------------------------------------------------------------
  65. public:
  66. // Constructor
  67. CSndRelay(CRealm* pRealm)
  68. : CThing(pRealm, CSndRelayID)
  69. {
  70. m_bInitiallyEnabled = true;
  71. m_bEnabled = m_bInitiallyEnabled;
  72. m_sSuspend = 0;
  73. m_state = State_Happy;
  74. m_idParent = CIdBank::IdNil;
  75. }
  76. public:
  77. // Destructor
  78. ~CSndRelay()
  79. {
  80. Kill();
  81. }
  82. //---------------------------------------------------------------------------
  83. // Required static functions
  84. //---------------------------------------------------------------------------
  85. public:
  86. // Construct object
  87. static short Construct( // Returns 0 if successfull, non-zero otherwise
  88. CRealm* pRealm, // In: Pointer to realm this object belongs to
  89. CThing** ppNew) // Out: Pointer to new object
  90. {
  91. short sResult = 0;
  92. *ppNew = new CSndRelay(pRealm);
  93. if (*ppNew == 0)
  94. {
  95. sResult = -1;
  96. TRACE("CSndRelay::Construct(): Couldn't construct CSndRelay (that's a bad thing)\n");
  97. }
  98. return sResult;
  99. }
  100. //---------------------------------------------------------------------------
  101. // Required virtual functions (implimenting them as inlines doesn't pay!)
  102. //---------------------------------------------------------------------------
  103. public:
  104. // Load object (should call base class version!)
  105. short Load( // Returns 0 if successfull, non-zero otherwise
  106. RFile* pFile, // In: File to load from
  107. bool bEditMode, // In: True for edit mode, false otherwise
  108. short sFileCount, // In: File count (unique per file, never 0)
  109. ULONG ulFileVersion); // In: Version of file format to load.
  110. // Save object (should call base class version!)
  111. short Save( // Returns 0 if successfull, non-zero otherwise
  112. RFile* pFile, // In: File to save to
  113. short sFileCount); // In: File count (unique per file, never 0)
  114. // Startup object
  115. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  116. // Shutdown object
  117. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  118. // Suspend object
  119. void Suspend(void);
  120. // Resume object
  121. void Resume(void);
  122. // Update object
  123. void Update(void);
  124. // Render object
  125. void Render(void);
  126. short Setup( // Returns 0 on success.
  127. short sX, // In: New x coord
  128. short sY, // In: New y coord
  129. short sZ); // In: New z coord
  130. // Called by editor to init new object at specified position
  131. short EditNew( // Returns 0 if successfull, non-zero otherwise
  132. short sX, // In: New x coord
  133. short sY, // In: New y coord
  134. short sZ); // In: New z coord
  135. // Called by editor to modify object
  136. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  137. // Called by editor to move object to specified position
  138. short EditMove( // Returns 0 if successfull, non-zero otherwise
  139. short sX, // In: New x coord
  140. short sY, // In: New y coord
  141. short sZ); // In: New z coord
  142. // Called by editor to get the clickable pos/area of an object in 2D.
  143. virtual // Overridden here.
  144. void EditRect( // Returns nothiing.
  145. RRect* prc); // Out: Clickable pos/area of object.
  146. // Called by editor to get the hotspot of an object in 2D.
  147. virtual // Overridden here.
  148. void EditHotSpot( // Returns nothiing.
  149. short* psX, // Out: X coord of 2D hotspot relative to
  150. // EditRect() pos.
  151. short* psY); // Out: Y coord of 2D hotspot relative to
  152. // EditRect() pos.
  153. // Called by editor to update object
  154. void EditUpdate(void);
  155. // Called by editor to render object
  156. void EditRender(void);
  157. // Get the coordinates of this thing.
  158. virtual // Overriden here.
  159. double GetX(void) { return m_dX; }
  160. virtual // Overriden here.
  161. double GetY(void) { return m_dY; }
  162. virtual // Overriden here.
  163. double GetZ(void) { return m_dZ; }
  164. //---------------------------------------------------------------------------
  165. // Internal functions
  166. //---------------------------------------------------------------------------
  167. protected:
  168. // Init object
  169. short Init(void); // Returns 0 if successfull, non-zero otherwise
  170. // Kill object
  171. short Kill(void); // Returns 0 if successfull, non-zero otherwise
  172. // Process our message queue.
  173. void ProcessMessages(void);
  174. };
  175. #endif // SNDRELAY_H
  176. ////////////////////////////////////////////////////////////////////////////////
  177. // EOF
  178. ////////////////////////////////////////////////////////////////////////////////