Open Source Tomb Raider Engine
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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