Mercurial > fife-parpg
comparison engine/core/model/structures/map.h @ 422:9d94f4676d17
Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 12 Feb 2010 06:34:50 +0000 |
parents | 7e5717105212 |
children | c9113e23b004 |
comparison
equal
deleted
inserted
replaced
421:293e812316c0 | 422:9d94f4676d17 |
---|---|
39 | 39 |
40 #include "location.h" | 40 #include "location.h" |
41 | 41 |
42 namespace FIFE { | 42 namespace FIFE { |
43 | 43 |
44 class RendererBase; | |
45 class RenderBackend; | |
46 class ImagePool; | |
47 class AnimationPool; | |
44 class Layer; | 48 class Layer; |
45 class CellGrid; | 49 class CellGrid; |
46 class Map; | 50 class Map; |
51 class Camera; | |
52 class Rect; | |
47 | 53 |
48 /** Listener interface for changes happening on map | 54 /** Listener interface for changes happening on map |
49 */ | 55 */ |
50 class MapChangeListener { | 56 class MapChangeListener { |
51 public: | 57 public: |
84 | 90 |
85 /** Construct a map | 91 /** Construct a map |
86 * To add map to model, one should call Model::addMap (otherwise | 92 * To add map to model, one should call Model::addMap (otherwise |
87 * map is not registered with the engine properly) | 93 * map is not registered with the engine properly) |
88 */ | 94 */ |
89 Map(const std::string& identifier, TimeProvider* tp_master=NULL); | 95 Map(const std::string& identifier, RenderBackend* renderbackend, |
96 const std::vector<RendererBase*>& renderers, ImagePool* imagepool, | |
97 AnimationPool* animpool, TimeProvider* tp_master=NULL); | |
90 | 98 |
91 /** Destructor | 99 /** Destructor |
92 */ | 100 */ |
93 ~Map(); | 101 ~Map(); |
94 | 102 |
162 | 170 |
163 /** Returns layers that were changed during previous update round | 171 /** Returns layers that were changed during previous update round |
164 */ | 172 */ |
165 std::vector<Layer*>& getChangedLayers() { return m_changedlayers; } | 173 std::vector<Layer*>& getChangedLayers() { return m_changedlayers; } |
166 | 174 |
175 /** Adds camera to the map. The Map takes ownership of the camera | |
176 so don't delete it. | |
177 */ | |
178 Camera* addCamera(const std::string& id, Layer *layer, | |
179 const Rect& viewport, const ExactModelCoordinate& emc); | |
180 | |
181 /** Removes a camera from the map | |
182 */ | |
183 void removeCamera(const std::string& id); | |
184 | |
185 /** Get a camera by its identifier. | |
186 */ | |
187 Camera* getCamera(const std::string& id); | |
188 | |
189 /** Get a list containing all cameras. | |
190 */ | |
191 std::vector<Camera*>& getCameras(); | |
192 | |
167 private: | 193 private: |
168 std::string m_id; | 194 std::string m_id; |
169 | 195 |
170 std::list<Layer*> m_layers; | 196 std::list<Layer*> m_layers; |
171 TimeProvider m_timeprovider; | 197 TimeProvider m_timeprovider; |
177 std::vector<MapChangeListener*> m_changelisteners; | 203 std::vector<MapChangeListener*> m_changelisteners; |
178 | 204 |
179 // holds changed layers after each update | 205 // holds changed layers after each update |
180 std::vector<Layer*> m_changedlayers; | 206 std::vector<Layer*> m_changedlayers; |
181 | 207 |
208 // holds the cameras attached to this map | |
209 std::vector<Camera*> m_cameras; | |
210 | |
211 RenderBackend* m_renderbackend; | |
212 ImagePool* m_imagepool; | |
213 AnimationPool* m_animpool; | |
214 | |
215 // holds handles to all created renderers | |
216 std::vector<RendererBase*> m_renderers; | |
217 | |
182 // true, if something was changed on map during previous update (layer change, creation, deletion) | 218 // true, if something was changed on map during previous update (layer change, creation, deletion) |
183 bool m_changed; | 219 bool m_changed; |
184 }; | 220 }; |
185 | 221 |
186 } //FIFE | 222 } //FIFE |