summaryrefslogtreecommitdiffstats
path: root/src/control/MapContext.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-24 17:39:36 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-24 17:39:36 +0200
commitefa8640aabb3b4df31531ecd41ed1073dda63ed2 (patch)
tree151ddb75a5866784ce6b65757e0eea68aee6e05b /src/control/MapContext.cpp
parentaadcecf2022ec13d15da5d816567779740a37da7 (diff)
downloadrpgedit-efa8640aabb3b4df31531ecd41ed1073dda63ed2.tar
rpgedit-efa8640aabb3b4df31531ecd41ed1073dda63ed2.zip
Make MapContext keep a complete copy of the map
Diffstat (limited to 'src/control/MapContext.cpp')
-rw-r--r--src/control/MapContext.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp
index e3f9a49..1904db4 100644
--- a/src/control/MapContext.cpp
+++ b/src/control/MapContext.cpp
@@ -31,18 +31,15 @@ namespace RPGEdit {
namespace Control {
-MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, View::MapView *view0, const std::shared_ptr<const Model::Map> &map0)
- : eventBus(eventBus0), inputHandler(inputHandler0), view(view0), map(map0) {
- for (const Model::Entity &entity : map->getEntities())
- entities.emplace_back(new Model::Entity(entity));
+MapContext::MapContext(EventBus *eventBus0, InputHandler *inputHandler0, const std::shared_ptr<View::Window> &window, const Model::Map &map0)
+ : eventBus(eventBus0), inputHandler(inputHandler0), map(map0) {
+ view = std::unique_ptr<View::MapView>(new View::MapView(window, map.getTileset()));
- playerEntity = new Model::Entity("square");
+ map.getEntities().emplace_back("square");
+ playerEntity = &map.getEntities().back();
playerEntity->moveTo(Model::Position{8, 8});
- entities.emplace_back(playerEntity);
-
- view->updateEntities(entities);
-
+ view->updateEntities(map.getEntities());
inputHandler->registerListener(
[this] (uint16_t key, bool pressed, uint64_t time) {