ScummVM API documentation
Resources.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_RESOURCES_H
29 #define HPL_RESOURCES_H
30 
31 #include "hpl1/engine/system/SystemTypes.h"
32 #include "common/stablemap.h"
33 
34 #include "hpl1/engine/graphics/GPUProgram.h"
35 
36 #include "hpl1/engine/game/Updateable.h"
37 
38 class TiXmlElement;
39 
40 namespace hpl {
41 
42 class cImageEntity;
43 
44 class LowLevelResources;
45 class iLowLevelGraphics;
46 class LowLevelSystem;
47 class cSystem;
48 class iResourceManager;
49 class cFileSearcher;
50 class cImageManager;
51 class cGpuProgramManager;
52 class cTileSetManager;
53 class cImageEntityManager;
54 class cParticleManager;
55 class cSoundManager;
56 class cFontManager;
57 class cScriptManager;
58 class cTextureManager;
59 class cMaterialManager;
60 class cSoundEntityManager;
61 class cAnimationManager;
62 class cMeshManager;
63 class cVideoManager;
64 class cConfigFile;
65 class cArea2D;
66 class cSound;
67 class cMeshLoaderHandler;
68 class cScene;
69 class cGraphics;
70 class iRenderable;
71 class cWorld3D;
72 class iEntity3D;
73 class cLanguageFile;
74 class cGui;
75 
76 //-------------------------------------------------------
77 
79 public:
80  iEntity2DLoader(const tString &asName) : msName(asName) {}
81  virtual ~iEntity2DLoader() {}
82 
83  const tString &GetName() { return msName; }
84 
85  virtual void Load(cImageEntity *apImageEntity) = 0;
86 
87 protected:
88  tString msName;
89 };
90 
92 typedef tEntity2DLoaderMap::iterator tEntity2DLoaderMapIt;
93 
94 //-------------------------------------------------------
95 
97 public:
98  iArea2DLoader(const tString &asName) : msName(asName) {}
99  virtual ~iArea2DLoader() {}
100 
101  const tString &GetName() { return msName; }
102 
103  virtual void Load(cArea2D *apArea) = 0;
104 
105 protected:
106  tString msName;
107 };
108 
110 typedef tArea2DLoaderMap::iterator tArea2DLoaderMapIt;
111 
112 //-------------------------------------------------------
113 
115 public:
116  iEntity3DLoader(const tString &asName) : msName(asName) {}
117  virtual ~iEntity3DLoader() {}
118 
119  const tString &GetName() { return msName; }
120 
121  virtual iEntity3D *Load(const tString &asName, TiXmlElement *apRootElem, const cMatrixf &a_mtxTransform,
122  cWorld3D *apWorld, const tString &asFileName, bool abLoadReferences) = 0;
123 
124 protected:
125  tString msName;
126 };
127 
129 typedef tEntity3DLoaderMap::iterator tEntity3DLoaderMapIt;
130 
131 //-------------------------------------------------------
132 
134 public:
135  iArea3DLoader(const tString &asName) : msName(asName) {}
136  virtual ~iArea3DLoader() {}
137 
138  const tString &GetName() { return msName; }
139 
140  virtual iEntity3D *Load(const tString &asName, const cVector3f &avSize, const cMatrixf &a_mtxTransform, cWorld3D *apWorld) = 0;
141 
142 protected:
143  tString msName;
144 };
145 
147 typedef tArea3DLoaderMap::iterator tArea3DLoaderMapIt;
148 
149 //-------------------------------------------------------
150 
151 // Should this be made a map so you can do
152 // GetManager(tString) when getting a manager?
153 // This way you would be able to add your own resource types
154 // easily.
157 
158 //-------------------------------------------------------
159 
160 class cResources : public iUpdateable {
161 public:
162  cResources(LowLevelResources *apLowLevelResources, iLowLevelGraphics *apLowLevelGraphics);
163  virtual ~cResources();
164 
165  void Init(cGraphics *apGraphics, cSystem *apSystem, cSound *apSound, cScene *apScene, cGui *apGui);
166 
167  void Update(float afTimeStep);
168 
169  LowLevelResources *GetLowLevel();
170  cFileSearcher *GetFileSearcher();
171 
172  bool AddResourceDir(const tString &asDir, const tString &asMask = "*.*");
173  void ClearResourceDirs();
174 
175  bool SetLanguageFile(const tString &asFile);
176  const tWString &Translate(const tString &asCat, const tString &asName);
177 
178  void AddEntity2DLoader(iEntity2DLoader *apLoader);
179  iEntity2DLoader *GetEntity2DLoader(const tString &asName);
180 
181  void AddEntity3DLoader(iEntity3DLoader *apLoader, bool abSetAsDefault = false);
182  iEntity3DLoader *GetEntity3DLoader(const tString &asName);
183 
184  void AddArea3DLoader(iArea3DLoader *apLoader, bool abSetAsDefault = false);
185  iArea3DLoader *GetArea3DLoader(const tString &asName);
186 
187  void AddArea2DLoader(iArea2DLoader *apLoader);
188  iArea2DLoader *GetArea2DLoader(const tString &asName);
189 
190  bool LoadResourceDirsFile(const tString &asFile);
191 
192  cImageManager *GetImageManager() { return mpImageManager; }
193  cGpuProgramManager *GetGpuProgramManager() { return mpGpuProgramManager; }
194  cTileSetManager *GetTileSetManager() { return mpTileSetManager; }
195  cImageEntityManager *GetImageEntityManager() { return mpImageEntityManager; }
196  cParticleManager *GetParticleManager() { return mpParticleManager; }
197  cSoundManager *GetSoundManager() { return mpSoundManager; }
198  cFontManager *GetFontManager() { return mpFontManager; }
199  cScriptManager *GetScriptManager() { return mpScriptManager; }
200  cTextureManager *GetTextureManager() { return mpTextureManager; }
201  cMaterialManager *GetMaterialManager() { return mpMaterialManager; }
202  cMeshManager *GetMeshManager() { return mpMeshManager; }
203  cMeshLoaderHandler *GetMeshLoaderHandler() { return mpMeshLoaderHandler; }
204  cSoundEntityManager *GetSoundEntityManager() { return mpSoundEntityManager; }
205  cAnimationManager *GetAnimationManager() { return mpAnimationManager; }
206  cVideoManager *GetVideoManager() { return mpVideoManager; }
207 
208  LowLevelSystem *GetLowLevelSystem() { return mpLowLevelSystem; }
209 
210 private:
211  LowLevelResources *mpLowLevelResources;
212  iLowLevelGraphics *mpLowLevelGraphics;
213  LowLevelSystem *mpLowLevelSystem;
214  cFileSearcher *mpFileSearcher;
215 
216  tResourceManagerList mlstManagers;
217  cImageManager *mpImageManager;
218  cGpuProgramManager *mpGpuProgramManager;
219  cTileSetManager *mpTileSetManager;
220  cImageEntityManager *mpImageEntityManager;
221  cParticleManager *mpParticleManager;
222  cSoundManager *mpSoundManager;
223  cFontManager *mpFontManager;
224  cScriptManager *mpScriptManager;
225  cTextureManager *mpTextureManager;
226  cMaterialManager *mpMaterialManager;
227  cSoundEntityManager *mpSoundEntityManager;
228  cAnimationManager *mpAnimationManager;
229  cVideoManager *mpVideoManager;
230 
231  cLanguageFile *mpLanguageFile;
232 
233  cMeshManager *mpMeshManager;
234  cMeshLoaderHandler *mpMeshLoaderHandler;
235 
236  tEntity2DLoaderMap m_mMapEntity2DLoaders;
237  tArea2DLoaderMap m_mMapArea2DLoaders;
238 
239  tEntity3DLoaderMap m_mEntity3DLoaders;
240  iEntity3DLoader *mpDefaultEntity3DLoader;
241 
242  tArea3DLoaderMap m_mArea3DLoaders;
243  iArea3DLoader *mpDefaultArea3DLoader;
244 
245  tWString mwsEmptyString;
246 };
247 
248 } // namespace hpl
249 
250 #endif // HPL_RESOURCES_H
Definition: AI.h:36
Definition: Gui.h:73
Definition: Resources.h:96
Definition: str.h:59
Definition: ScriptManager.h:39
Definition: GpuProgramManager.h:39
Definition: MaterialManager.h:41
Definition: FontManager.h:40
Definition: SoundEntityManager.h:39
Definition: TileSetManager.h:39
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: ImageEntityManager.h:40
Definition: MeshLoaderHandler.h:50
Definition: Sound.h:40
Definition: ParticleManager.h:50
Definition: FileSearcher.h:43
Definition: low_level_resources.h:40
Definition: LanguageFile.h:64
Definition: AnimationManager.h:39
Definition: Resources.h:114
Definition: ustr.h:57
Definition: World3D.h:179
Definition: VideoManager.h:52
Definition: Resources.h:78
Definition: TextureManager.h:47
Definition: Updateable.h:35
Definition: SoundManager.h:39
Definition: low_level_system.h:95
Definition: Resources.h:160
Definition: Area2D.h:39
Definition: ImageManager.h:48
Definition: System.h:36
Definition: Entity3D.h:81
Definition: tinyxml.h:864
Definition: list_intern.h:51
Definition: Scene.h:61
Definition: Resources.h:133
Definition: MeshManager.h:39
Definition: Graphics.h:46
Definition: LowLevelGraphics.h:200
Definition: ImageEntity.h:44