diff options
Diffstat (limited to 'EditManager.cpp')
-rw-r--r-- | EditManager.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/EditManager.cpp b/EditManager.cpp index 2d743f5..9c44a27 100644 --- a/EditManager.cpp +++ b/EditManager.cpp @@ -46,7 +46,9 @@ bool EditManager::addRoom(const Room &newRoom) { room->setName(idManager.generate("room")); window->getLevel().push_back(SharedPtr<LevelObject>(room)); - selectedObject = &*window->getLevel().back(); + selectedObject = room; + + window->resetTool(); return true; } @@ -83,20 +85,23 @@ void EditManager::setHoveredVertex(Vertex *v) { window->update(); } -bool EditManager::vertexOk(const Room &newRoom, const Vertex &v) const { +bool EditManager::vertexOk(const Vertex &v, const Room *newRoom) const { Line l; for(Level::iterator room = window->getLevel().begin(); room != window->getLevel().end(); room++) { if((*room)->isOfType("Room") && ((Room*)&**room)->contains(v)) return false; } - if(newRoom.empty()) + if(!newRoom) + return true; + + if(newRoom->empty()) return true; - l.setVertex1(newRoom.back()); + l.setVertex1(newRoom->back()); l.setVertex2(v); - return lineOk(newRoom, l); + return lineOk(*newRoom, l); } bool EditManager::polygonOk(const Polygon& polygon) const { |