diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/editorui.py b/src/editorui.py index b05cbe2..73eaa18 100644 --- a/src/editorui.py +++ b/src/editorui.py @@ -558,16 +558,27 @@ class KPEditorNode(KPEditorItem): else: end = start2 - - joinedPath = KPPath(start, end, pathOne) - layer.paths.append(joinedPath) - item = KPEditorPath(joinedPath) - self.scene().addItem(item) - - - # whatever happened, delete the old paths anyway - for exit in node.exits: - exit.qtItem.remove(True) + # make sure no path already exists between these nodes + nope = False + + for pathToCheck in start.exits: + if pathToCheck._startNodeRef() == end: + nope = True + elif pathToCheck._endNodeRef() == end: + nope = True + + if not nope: + joinedPath = KPPath(start, end, pathOne) + layer.paths.append(joinedPath) + item = KPEditorPath(joinedPath) + self.scene().addItem(item) + + for path in (pathOne, pathTwo): + path.qtItem.remove(True) + else: + # we can't join them so just nuke them + for exit in node.exits[:]: + exit.qtItem.remove(True) if withItem: self.scene().removeItem(self) @@ -820,8 +831,6 @@ class KPEditorWidget(QtGui.QGraphicsView): self.paintBeginPosition = (x, y) elif isinstance(layer, KPPathLayer): - print "Going to paint something related to paths" - # decide what's under the mouse clicked = self.mapToScene(event.x(), event.y()) x, y = clicked.x(), clicked.y() @@ -829,7 +838,6 @@ class KPEditorWidget(QtGui.QGraphicsView): for item in itemsUnder: if isinstance(item, KPEditorNode): - print "Trying a line" # Paint a path to this node (if one is selected) sourceItem, sourceNode = None, None selected = self.scene().selectedItems() @@ -838,7 +846,6 @@ class KPEditorWidget(QtGui.QGraphicsView): if isinstance(item, KPEditorNode) and selItem != item: sourceItem = selItem sourceNode = selItem._nodeRef() - print "Got source" break if sourceItem is None: return @@ -855,7 +862,6 @@ class KPEditorWidget(QtGui.QGraphicsView): path = KPPath(sourceNode, destNode) KP.map.pathLayer.paths.append(path) - print "Done!" item = KPEditorPath(path) self.scene().addItem(item) @@ -899,7 +905,6 @@ class KPEditorWidget(QtGui.QGraphicsView): node.position = (x - 12, y - 12) KP.map.pathLayer.nodes.append(node) - print "Painting a node at %r" % (node.position,) item = KPEditorNode(node) self.scene().addItem(item) |