Open Source Tomb Raider Engine
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OpenRaider.h 6.3KB

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