hood.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. // hood.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 01/22/97 JMI Converted many m_spryAlphas/Opaques to arrays and added
  23. // a macro enum MaxLayers.
  24. //
  25. // 01/23/97 JMI Added two very non-major comments and removed a #if 0
  26. // block.
  27. //
  28. // 01/26/97 JMI Made m_imBackground public. It was the only way I could
  29. // figure to get any idea of the realm dimensions that I
  30. // needed for the editor.
  31. //
  32. // 01/26/97 JMI Added override of EditRect() that sets the rect to the
  33. // dimensions of m_pimBackground->
  34. //
  35. // 01/31/97 MJR Added GetWidth() and GetHeight().
  36. //
  37. // 02/03/97 JMI Updated default relative path used to get hood resources.
  38. //
  39. // 02/04/97 JMI Changed all resources to pointers so we can fully utilize
  40. // the RResMgr.
  41. //
  42. // 02/07/97 JMI Added m_sWorldXRot, world transformation x rotation.
  43. //
  44. // 02/13/97 JMI Changed paths for hoods to be in hoods/ instead of bg/
  45. // and also now just store the import part (like "city" instead
  46. // of "hoods/city").
  47. // Also, now gets resources for lighting effects.
  48. // Also, now sets the realm's m_phood ptr to this instance.
  49. //
  50. // 02/13/97 JMI Had to make m_pimBackground public so 3D guys could get in-
  51. // to its palette.
  52. //
  53. // 03/13/97 JMI Load now takes a version number.
  54. //
  55. // 04/09/97 BRH Added RMultiGrid to the hoods for the new type of attribute
  56. // maps. These will eventuall replace the RAttribMap but for
  57. // now they are both here so that all parts of the game
  58. // will continue to work during testing of the new attribute
  59. // map.
  60. //
  61. // 05/29/97 JMI Changed occurences of m_pHeightMap to m_pTerrainMap.
  62. // Changed occurences of m_pAttrMap to m_pLayerMap.
  63. // Also, removed occurences of m_pattribMap.
  64. //
  65. // 06/16/97 JMI Added SetPalette() which can be used to set the hood's
  66. // palette at the convenience of the Realm runner.
  67. //
  68. // 06/26/97 JMI Added read-only access to m_sWorldXRot, GetWorldRotX().
  69. //
  70. // 06/28/97 JMI Changed m_sWorldXRot to m_sRealmRotX and GetWorldRotX() and
  71. // GetRealmRotX(), and added m_sSceneRotX & GetSceneRotX().
  72. //
  73. // 07/01/97 JMI Added m_sNumInits. Some things in Init() should only be
  74. // done once (like getting the resources, adding them to
  75. // the scene, and allocating the smashatorium).
  76. //
  77. // 07/01/97 JMI Added m_sScaleAttribHeights indicating whether to scale
  78. // height values gotten via the terrain map.
  79. //
  80. // 07/09/97 JMI Added setting for which side view assets to use,
  81. // m_s2dResPathIndex. For now, only 0 or 1 are valid, but
  82. // eventually, it may be more of an index than a bool, and,
  83. // hence the name.
  84. //
  85. // 07/09/97 JMI Moved m_s2dResPathIndex from CHood to CRealm b/c of order
  86. // issues when loading.
  87. //
  88. //
  89. // 08/03/97 JRD Added ability to save 3d scale with hood
  90. //
  91. //
  92. // 08/13/97 JRD Began adding Randy's numbers to the toolbar...
  93. //
  94. // 08/17/97 JMI Added handy macro for updating hood's settings to scene's
  95. // pipeline.
  96. //
  97. ////////////////////////////////////////////////////////////////////////////////
  98. #ifndef HOOD_H
  99. #define HOOD_H
  100. #include "RSPiX.h"
  101. #ifdef PATHS_IN_INCLUDES
  102. #include "WishPiX/Spry/spry.h"
  103. #include "ORANGE/MultiGrid/MultiGrid.h"
  104. #else
  105. #include "spry.h"
  106. #include "multigrid.h"
  107. #endif
  108. #include "thing.h"
  109. // Let's just know that the Realm exists.
  110. class CRealm;
  111. // This is the hood object
  112. class CHood : public CThing
  113. {
  114. //---------------------------------------------------------------------------
  115. // Types, enums, etc.
  116. //---------------------------------------------------------------------------
  117. public:
  118. enum // Macros.
  119. {
  120. MaxLayers = 8 // Maximum number of alpha & opaque layers.
  121. };
  122. //---------------------------------------------------------------------------
  123. // Variables
  124. //---------------------------------------------------------------------------
  125. public:
  126. RMultiGrid* m_pTerrainMap; // Height layer for attribute map
  127. RMultiGrid* m_pLayerMap; // Attribute bits layer for attribue map.
  128. RImage* m_pimXRayMask; // Mask for XRayable area.
  129. RMultiAlpha* m_pmaTransparency; // Alpha tables for XRay and fire FX.
  130. RAlpha* m_pltAmbient; // Ambient lighting effect.
  131. RAlpha* m_pltSpot; // Spot lighting effect.
  132. RImage* m_pimBackground; // Main background image
  133. RImage* m_pimEmptyBar; // Bar with nothing
  134. RImage* m_pimEmptyBarSelected; // Empty with highlights
  135. RImage* m_pimFullBar; // Weap & Ammo present
  136. RImage* m_pimFullBarSelected; // Full with highlights
  137. RImage* m_pimTopBar; // Top bar
  138. RImage* m_pimNum; // Randy raster numbers (0-9)
  139. RImage* m_pimNumLite; // PowerUp
  140. RImage* m_pimNumLow; // Ammo Low
  141. RImage* m_pimNumGone; // Ammo Gone
  142. short m_sScaleAttribHeights; // TRUE, to enable scaling of attribute
  143. // map heights via the realm view angle.
  144. // FALSE, to use naked values.
  145. double m_dScale3d; // defaults to 1.0. smash is affected
  146. short m_sShadowAngle; // 0-259
  147. double m_dShadowLength; // if 0, no shadows
  148. short m_sShadowIntensity; // if 0, no shadows
  149. protected:
  150. RSpry* m_apspryAlphas[MaxLayers]; // "Alpha" layers of sprites.
  151. RSpry* m_apspryOpaques[MaxLayers]; // "Opaque" layeres of sprites.
  152. bool m_bResourcesExist; // Flags whether resources exist
  153. char m_acBaseName[RSP_MAX_PATH]; // Base name for all resources.
  154. short m_sRealmRotX; // Realm X rotation.
  155. short m_sSceneRotX; // Scene transform X rotation.
  156. short m_sNumInits; // Number of times Init() has
  157. // been called (some things
  158. // are only done on the first
  159. // call).
  160. //---------------------------------------------------------------------------
  161. // Constructor(s) / destructor
  162. //---------------------------------------------------------------------------
  163. protected:
  164. // Constructor
  165. CHood(CRealm* pRealm);
  166. public:
  167. // Destructor
  168. ~CHood();
  169. //---------------------------------------------------------------------------
  170. // Required static functions
  171. //---------------------------------------------------------------------------
  172. public:
  173. // Construct object
  174. static short Construct( // Returns 0 if successfull, non-zero otherwise
  175. CRealm* pRealm, // In: Pointer to realm this object belongs to
  176. CThing** ppNew) // Out: Pointer to new object
  177. {
  178. short sResult = 0;
  179. *ppNew = new CHood(pRealm);
  180. if (*ppNew == 0)
  181. {
  182. sResult = -1;
  183. TRACE("CHood::Construct(): Couldn't construct CHood!\n");
  184. }
  185. return sResult;
  186. }
  187. //---------------------------------------------------------------------------
  188. // Required virtual functions (implimenting them as inlines doesn't pay!)
  189. //---------------------------------------------------------------------------
  190. public:
  191. // Load object (should call base class version!)
  192. short Load( // Returns 0 if successfull, non-zero otherwise
  193. RFile* pFile, // In: File to load from
  194. bool bEditMode, // In: True for edit mode, false otherwise
  195. short sFileCount, // In: File count (unique per file, never 0)
  196. ULONG ulFileVersion); // In: Version of file format to load.
  197. // Save object (should call base class version!)
  198. short Save( // Returns 0 if successfull, non-zero otherwise
  199. RFile* pFile, // In: File to save to
  200. short sFileCount); // In: File count (unique per file, never 0)
  201. // Startup object
  202. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  203. // Shutdown object
  204. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  205. // Suspend object
  206. void Suspend(void);
  207. // Resume object
  208. void Resume(void);
  209. // Update object
  210. void Update(void);
  211. // Render object
  212. void Render(void);
  213. // Called by editor to init new object at specified position
  214. short EditNew( // Returns 0 if successfull, non-zero otherwise
  215. short sX, // In: New x coord
  216. short sY, // In: New y coord
  217. short sZ); // In: New z coord
  218. // Called by editor to modify object
  219. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  220. // Called by editor to move object to specified position
  221. short EditMove( // Returns 0 if successfull, non-zero otherwise
  222. short sX, // In: New x coord
  223. short sY, // In: New y coord
  224. short sZ); // In: New z coord
  225. // Called by editor to update object
  226. void EditUpdate(void);
  227. // Called by editor to render object
  228. void EditRender(void);
  229. // Called by editor to get the clickable pos/area of an object.
  230. virtual // If you override this, do NOT call this base class.
  231. void EditRect( // Returns nothiing.
  232. RRect* prc) // Out: Clickable pos/area of object.
  233. {
  234. // Default implementation makes the object unclickable.
  235. prc->sX = 0;
  236. prc->sY = 0;
  237. prc->sW = m_pimBackground->m_sWidth;
  238. prc->sH = m_pimBackground->m_sHeight;
  239. }
  240. //---------------------------------------------------------------------------
  241. // Hood-specific functions
  242. //---------------------------------------------------------------------------
  243. public:
  244. // Get width
  245. short GetWidth(void)
  246. { return m_pimBackground->m_sWidth; }
  247. // Get height
  248. short GetHeight(void)
  249. { return m_pimBackground->m_sHeight; }
  250. // Get realm X rotation.
  251. short GetRealmRotX(void)
  252. { return m_sRealmRotX; }
  253. // Set the hood's palette.
  254. void SetPalette(void); // Returns nothing.
  255. // Setup pipeline to hood's specifications.
  256. void SetupPipeline(void); // Returns nothing.
  257. //---------------------------------------------------------------------------
  258. // Internal functions
  259. //---------------------------------------------------------------------------
  260. protected:
  261. // Init the hood
  262. short Init(void); // Returns 0 if successfull, non-zero otherwise
  263. // Kill the hood
  264. short Kill(void); // Returns 0 if successfull, non-zero otherwise
  265. // Load object
  266. short LoadThis( // Returns 0 if successfull, non-zero otherwise
  267. RFile* pFile); // In: File to load from
  268. // Get all required resources
  269. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  270. // Free all resources
  271. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  272. };
  273. #endif //HOOD_H
  274. ////////////////////////////////////////////////////////////////////////////////
  275. // EOF
  276. ////////////////////////////////////////////////////////////////////////////////