comparison engine/core/model/model.cpp @ 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 e7a431577c95
children ea80b41c9bd7
comparison
equal deleted inserted replaced
421:293e812316c0 422:9d94f4676d17
33 #include "model/metamodel/grids/cellgrid.h" 33 #include "model/metamodel/grids/cellgrid.h"
34 #include "structures/map.h" 34 #include "structures/map.h"
35 #include "structures/layer.h" 35 #include "structures/layer.h"
36 #include "structures/instance.h" 36 #include "structures/instance.h"
37 #include "util/base/exception.h" 37 #include "util/base/exception.h"
38 #include "view/rendererbase.h"
39 #include "video/renderbackend.h"
40 #include "video/imagepool.h"
41 #include "video/animationpool.h"
38 42
39 #include "model.h" 43 #include "model.h"
40 44
41 namespace FIFE { 45 namespace FIFE {
42 46
43 Model::Model(): 47 Model::Model(RenderBackend* renderbackend, const std::vector<RendererBase*>& renderers,
48 ImagePool* imagepool, AnimationPool* animpool):
44 FifeClass(), 49 FifeClass(),
45 m_last_namespace(NULL), 50 m_last_namespace(NULL),
51 m_renderbackend(renderbackend),
52 m_renderers(renderers),
53 m_imagepool(imagepool),
54 m_animpool(animpool),
46 m_timeprovider(NULL) { 55 m_timeprovider(NULL) {
47 } 56
57 }
48 58
49 Model::~Model() { 59 Model::~Model() {
50 purge(m_maps); 60 purge(m_maps);
51 for(std::list<namespace_t>::iterator nspace = m_namespaces.begin(); nspace != m_namespaces.end(); ++nspace) 61 for(std::list<namespace_t>::iterator nspace = m_namespaces.begin(); nspace != m_namespaces.end(); ++nspace)
52 purge_map(nspace->second); 62 purge_map(nspace->second);
56 } 66 }
57 67
58 Map* Model::createMap(const std::string& identifier) { 68 Map* Model::createMap(const std::string& identifier) {
59 std::list<Map*>::const_iterator it = m_maps.begin(); 69 std::list<Map*>::const_iterator it = m_maps.begin();
60 for(; it != m_maps.end(); ++it) { 70 for(; it != m_maps.end(); ++it) {
61 if(identifier == (*it)->getId()) 71 if(identifier == (*it)->getId()) {
62 throw NameClash(identifier); 72 throw NameClash(identifier);
63 } 73 }
64 74 }
65 Map* map = new Map(identifier, &m_timeprovider); 75
76 Map* map = new Map(identifier, m_renderbackend, m_renderers, m_imagepool, m_animpool, &m_timeprovider);
66 m_maps.push_back(map); 77 m_maps.push_back(map);
67 return map; 78 return map;
68 } 79 }
69 80
70 void Model::adoptPather(AbstractPather* pather) { 81 void Model::adoptPather(AbstractPather* pather) {
103 for(; it != m_maps.end(); ++it) { 114 for(; it != m_maps.end(); ++it) {
104 if((*it)->getId() == identifier) 115 if((*it)->getId() == identifier)
105 return *it; 116 return *it;
106 } 117 }
107 118
108 throw NotFound(std::string("Tried to get non-existant map: ") + identifier + "."); 119 throw NotFound(std::string("Tried to get non-existent map: ") + identifier + ".");
109 } 120 }
110 121
111 void Model::deleteMap(Map* map) { 122 void Model::deleteMap(Map* map) {
112 std::list<Map*>::iterator it = m_maps.begin(); 123 std::list<Map*>::iterator it = m_maps.begin();
113 for(; it != m_maps.end(); ++it) { 124 for(; it != m_maps.end(); ++it) {