QGearsFLevelFile.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreTexture.h>
  17. #include "common/QGearsResource.h"
  18. #include "common/TypeDefine.h"
  19. #include "map/QGearsBackground2DFile.h"
  20. #include "map/QGearsWalkmeshFile.h"
  21. #include "data/FF7ModelListFile.h"
  22. #include "QGearsBackgroundFile.h"
  23. #include "QGearsCameraMatrixFile.h"
  24. #include "QGearsPaletteFile.h"
  25. #include "QGearsHRCFile.h"
  26. #include "QGearsTriggersFile.h"
  27. namespace QGears{
  28. // TODO: move flevel stuff to ff7 as it is ff7 related!?
  29. using FF7::ModelListFile;
  30. using FF7::ModelListFilePtr;
  31. class FLevelTextureLoader;
  32. class FLevelBackground2DLoader;
  33. /**
  34. * A flevel file.
  35. *
  36. * Flevel files are LXS compressed files containing level data in the game
  37. * PC version.
  38. */
  39. class FLevelFile : public Resource{
  40. public:
  41. /**
  42. * Constructor.
  43. *
  44. * @param creator[in] Pointer to the ResourceManager that is
  45. * creating this resource.
  46. * @param name[in] The unique name of the resource.
  47. * @param handle[in] @todo Understand and document.
  48. * @param group[in] The name of the resource group to which this
  49. * resource belong.
  50. * @param is_manual[in] True if the resource is manually loaded,
  51. * false otherwise.
  52. * @param loader[in] Pointer to a ManualResourceLoader
  53. * implementation which will be called when the Resource wishes to
  54. * load (should be supplied if is_manual is set to true). It can be
  55. * null, but the Resource will never be able to reload if anything
  56. * ever causes it to unload. Therefore provision of a proper
  57. * ManualResourceLoader instance is strongly recommended.
  58. */
  59. FLevelFile(
  60. Ogre::ResourceManager *creator, const String &name,
  61. Ogre::ResourceHandle handle, const String &group,
  62. bool is_manual = false, Ogre::ManualResourceLoader *loader = NULL
  63. );
  64. /**
  65. * Destructor.
  66. */
  67. virtual ~FLevelFile();
  68. /**
  69. * The resource type.
  70. */
  71. static const String RESOURCE_TYPE;
  72. /**
  73. * Retrieves the scripts in the level.
  74. *
  75. * @return The scripts in the level.
  76. */
  77. const std::vector<u8>& GetRawScript() const;
  78. /**
  79. * Retrieves the level background.
  80. *
  81. * @return The background file in the level.
  82. */
  83. const BackgroundFilePtr& GetBackground() const;
  84. /**
  85. * Retrieves the level cameara matrix.
  86. *
  87. * @return The camera matrix file in the level.
  88. */
  89. const CameraMatrixFilePtr& GetCameraMatrix() const;
  90. /**
  91. * Retrieves the level model list.
  92. *
  93. * @return The level model list file.
  94. */
  95. const ModelListFilePtr& GetModelList() const;
  96. /**
  97. * Retrieves the color palette for the level.
  98. *
  99. * @return The color palette file for the level.
  100. */
  101. const PaletteFilePtr& GetPalette() const;
  102. /**
  103. * Retrieves the level walkmesh.
  104. *
  105. * @return The level walkmesh file.
  106. */
  107. const WalkmeshFilePtr& GetWalkmesh() const;
  108. /**
  109. * Retrieves the level triggers.
  110. *
  111. * @return The level triggers file.
  112. */
  113. const TriggersFilePtr& GetTriggers() const;
  114. /**
  115. * Sets the scripts for the level.
  116. *
  117. * @param script_data[in] The scripts for the level.
  118. */
  119. void SetRawScript(const std::vector<u8>& script_data);
  120. /**
  121. * Sets the background for the level.
  122. *
  123. * @param background[in] The background for the level.
  124. */
  125. void SetBackground(const BackgroundFilePtr &background);
  126. /**
  127. * Sets the camera matrix for the level.
  128. *
  129. * @param camera_matrix[in] The camera matrix for the level.
  130. */
  131. void SetCameraMatrix(const CameraMatrixFilePtr &camera_matrix);
  132. /**
  133. * Sets the model list for the level.
  134. *
  135. * @param model_list[in] The model list for the level.
  136. */
  137. void SetModelList(const ModelListFilePtr &model_list);
  138. /**
  139. * Sets the color palette for the level.
  140. *
  141. * @param palette[in] The color palette for the level.
  142. */
  143. void SetPalette(const PaletteFilePtr &palette);
  144. /**
  145. * Sets the level walkmesh.
  146. *
  147. * @param walkmesh[in] The walkmesh for the level.
  148. */
  149. void SetWalkmesh(const WalkmeshFilePtr &walkmesh);
  150. /**
  151. * Sets the triggers for the level.
  152. *
  153. * @param triggers[in] The triggers for the level.
  154. */
  155. void SetTriggers(const TriggersFilePtr& triggers);
  156. /**
  157. * Retrieves the level background name.
  158. *
  159. * @return The background name.
  160. */
  161. String GetBackground2DName(void) const;
  162. /**
  163. * Retrieves the level background texture name.
  164. *
  165. * @return The background texture name.
  166. */
  167. String GetBackgroundTextureName(void) const;
  168. protected:
  169. typedef std::vector<HRCFilePtr> HRCList;
  170. typedef ModelListFile::ModelList ModelList;
  171. typedef ModelListFile::AnimationList AnimationList;
  172. /**
  173. * Background texture file names suffix.
  174. */
  175. static const String SUFFIX_BACKGROUND_TEXTURE;
  176. /**
  177. * Background file names suffix.
  178. */
  179. static const String SUFFIX_BACKGROUND_2D;
  180. /**
  181. * Loads the file.
  182. */
  183. virtual void loadImpl(void) override;
  184. /**
  185. * Loads the level models.
  186. */
  187. void LoadModels(void);
  188. /**
  189. * Loads the level animations
  190. */
  191. void LoadAnimations(
  192. const HRCFilePtr &model, const AnimationList &animations
  193. );
  194. /**
  195. * Unloads the file.
  196. */
  197. virtual void unloadImpl(void) override;
  198. /**
  199. * Calculates the size of the level.
  200. *
  201. * @return Always 0.
  202. */
  203. virtual size_t calculateSize(void) const override;
  204. /**
  205. * Retrieves the resource type.
  206. */
  207. virtual const String& GetResourceType(void) const;
  208. private:
  209. /**
  210. * The level background.
  211. */
  212. BackgroundFilePtr background_;
  213. /**
  214. * The level camera matrix.
  215. */
  216. CameraMatrixFilePtr camera_matrix_;
  217. /**
  218. * The level model list.
  219. */
  220. ModelListFilePtr model_list_;
  221. /**
  222. * The level color palette.
  223. */
  224. PaletteFilePtr palette_;
  225. /**
  226. * The level walkmesh.
  227. */
  228. WalkmeshFilePtr walkmesh_;
  229. /**
  230. * The level triggers.
  231. */
  232. TriggersFilePtr triggers_;
  233. /**
  234. * The level script data.
  235. */
  236. std::vector<u8> raw_script_;
  237. /**
  238. * The background texture loader.
  239. */
  240. FLevelTextureLoader *background_texture_loader_;
  241. /**
  242. * The background texture.
  243. */
  244. Ogre::TexturePtr background_texture_;
  245. /**
  246. * The background loader.
  247. */
  248. FLevelBackground2DLoader *background_2d_loader_;
  249. /**
  250. * The background loader.
  251. */
  252. Background2DFilePtr background_2d_;
  253. /**
  254. * The list of HRC files.
  255. *
  256. * HRC files describe bone hierarchy.
  257. */
  258. HRCList hrc_files_;
  259. };
  260. typedef Ogre::SharedPtr<FLevelFile> FLevelFilePtr;
  261. }