From efa8640aabb3b4df31531ecd41ed1073dda63ed2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 24 Sep 2014 17:39:36 +0200 Subject: Make MapContext keep a complete copy of the map --- src/control/MapContext.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/control/MapContext.cpp') 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 &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 &window, const Model::Map &map0) + : eventBus(eventBus0), inputHandler(inputHandler0), map(map0) { + view = std::unique_ptr(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) { -- cgit v1.2.3