Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OpenRaider.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*!
  2. * \file include/OpenRaider.h
  3. * \brief Main Game Singleton
  4. *
  5. * \author Mongoose
  6. */
  7. #ifndef _OPENRAIDER_H_
  8. #define _OPENRAIDER_H_
  9. #include <List.h>
  10. #include <Map.h>
  11. #include <Vector.h>
  12. #include <TombRaider.h>
  13. #include <Camera.h>
  14. #include <Render.h>
  15. #include <Sound.h>
  16. #include <SDLSystem.h>
  17. #include <Network.h>
  18. #include <World.h>
  19. /*!
  20. * \brief OpenRaider key events.
  21. *
  22. * 0 event reserved for console in System.
  23. */
  24. typedef enum {
  25. OpenRaiderKey_console = 1, //!< Toggle console
  26. OpenRaiderKey_attack, //!< Attack
  27. OpenRaiderKey_forward, //!< Move forward
  28. OpenRaiderKey_left, //!< Move left
  29. OpenRaiderKey_right, //!< Move right
  30. OpenRaiderKey_backward, //!< Move backward
  31. OpenRaiderKey_jump, //!< Jump
  32. OpenRaiderKey_tiltUp, //!< Tilt camera up
  33. OpenRaiderKey_tiltDown, //!< Tilt camera down
  34. OpenRaiderKey_panLeft, //!< Pan camera left
  35. OpenRaiderKey_panRight, //!< Pan camera right
  36. OpenRaiderKey_crouch //!< Crouch
  37. } OpenRaider_KeyEvent;
  38. typedef enum {
  39. OpenRaider_ShowFPS = (1 << 0),
  40. OpenRaider_DebugMap = (1 << 1),
  41. OpenRaider_DebugModel = (1 << 2),
  42. OpenRaider_EnableSound = (1 << 3),
  43. OpenRaider_DumpTexture = (1 << 4),
  44. OpenRaider_FullScreen = (1 << 5),
  45. OpenRaider_Loading = (1 << 6)
  46. } OpenRaider_Flags;
  47. /*!
  48. * \brief Main Game Singleton
  49. */
  50. class OpenRaider : public SDLSystem {
  51. public:
  52. /*!
  53. * \brief Constructs or returns the OpenRaider Singleton
  54. * \returns OpenRaider Singleton
  55. */
  56. static OpenRaider *Instance();
  57. /*!
  58. * \brief Deconstructs an object of OpenRaider
  59. */
  60. ~OpenRaider();
  61. /*!
  62. * \brief Initialize the Game
  63. */
  64. void start();
  65. /*!
  66. * \brief Mouse motion input
  67. * \param x relative x motion
  68. * \param y relative y motion
  69. */
  70. void handleMouseMotionEvent(float x, float y);
  71. /*!
  72. * \brief Receives `Event` bound to `Cmd` from `Key` press
  73. * \param key valid keyboard code
  74. */
  75. void handleBoundKeyPressEvent(unsigned int key);
  76. /*!
  77. * \brief Receives `Event` bound to `Cmd` from `Key` release
  78. * \param key valid keyboard code
  79. */
  80. void handleBoundKeyReleaseEvent(unsigned int key);
  81. /*!
  82. * \brief Executes valid command based on keyword
  83. * \param command valid keyword optionally followed by space separated arguments
  84. * \param mode current type or resource mode
  85. */
  86. void handleCommand(char *command, unsigned int mode);
  87. /*!
  88. * \brief Receives `Key` code from text input in console mode
  89. * \param key valid keyboard code
  90. * \param mod valid modifier code
  91. */
  92. void handleConsoleKeyPressEvent(unsigned int key, unsigned int mod);
  93. /*!
  94. * \brief Executes command associated with key press, if any
  95. * \param key valid keyboard code
  96. * \param mod valid modifier code
  97. */
  98. void handleKeyPressEvent(unsigned int key, unsigned int mod);
  99. /*!
  100. * \brief Executes command associated with key release, if any
  101. * \param key valid keyboard code
  102. * \param mod valid modifier code
  103. */
  104. void handleKeyReleaseEvent(unsigned int key, unsigned int mod);
  105. void initGL();
  106. /*!
  107. * \brief Pass a time frame and render a new frame
  108. */
  109. void gameFrame();
  110. /*!
  111. * \brief Outputs message in game console
  112. * \param dump_stdout if true, also print to stdout
  113. * \param format printf() style format string
  114. */
  115. void print(bool dump_stdout, const char *format, ...);
  116. protected:
  117. /*!
  118. * \brief Constructs an object of OpenRaider
  119. */
  120. OpenRaider();
  121. private:
  122. void consoleCommand(char *cmd);
  123. void soundEvent(int type, int id, vec3_t pos, vec3_t angles);
  124. //void entityEvent(entity_t &e, RaiderEvent event);
  125. void processPakSounds();
  126. /*!
  127. * \brief Loads and positions level sounds and music.
  128. *
  129. * Sound system has to be initialized.
  130. */
  131. void initSound();
  132. /*!
  133. * \brief Generates textures or mipmaps for fonts, splash,
  134. * external particles.
  135. */
  136. void initTextures();
  137. /*!
  138. * \brief Generates tombraider textures or mipmaps for sprites,
  139. * rooms and models.
  140. */
  141. void processTextures();
  142. /*!
  143. * \brief Generates render sprite sequences
  144. */
  145. void processSprites();
  146. void processMoveables();
  147. void processMoveable(int index, int i, int *ent, List <skeletal_model_t *> &cache2, List <unsigned int> &cache, int object_id);
  148. /*!
  149. * \brief Generates render mesh and any textures needed
  150. * for the specified model.
  151. * \param index valid model index
  152. */
  153. void processModel(int index);
  154. /*!
  155. * \brief Generates render mesh and any textures needed
  156. * for the specified room
  157. * \param index valid room index
  158. */
  159. void processRoom(int index);
  160. /*!
  161. * \brief Loads validated level pak from diskfile using maplist
  162. * \param filename level pak file name
  163. */
  164. void loadLevel(char *filename);
  165. static OpenRaider *mInstance; //!< Singleton use
  166. TombRaider m_tombraider; //!< Tombraider data support
  167. Sound mSound; //!< 3d Audio support
  168. Render m_render; //!< Rendering support
  169. Camera m_camera; //!< Client camera support
  170. GLString *mText; //!< Hook to textbox like output
  171. // RC vars
  172. unsigned int mMode[8]; //!< Translate System's mode ids to OR's
  173. unsigned int m_flags; //!< Set options by flags
  174. int m_testSFX; //!< Used for mixed channel sound tests
  175. float m_mouseX, m_mouseY; //!< XY axis rotation deltas
  176. unsigned int m_texOffset; //!< Offset of TombRaider textures in list
  177. unsigned int mLevelTextureOffset;
  178. // Game vars
  179. Vector <char *> mMusicList; //!< List of game level music
  180. Vector <char *> mMapList; //!< List of game maps
  181. char m_mapName[32]; //!< Current map filename
  182. char *m_pakDir; //!< Current pak directory
  183. char *m_audioDir; //!< Current audio directory
  184. char *m_homeDir; //!< Current home directory
  185. Vector<entity_t *> mClients; //!< Player entity/clients
  186. };
  187. #endif