summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-11-21 06:03:41 +0100
committerTreeki <treeki@gmail.com>2011-11-21 06:03:41 +0100
commitb24dea2418cac600a2ec719329cfef55f8f66ef8 (patch)
treeee8acf34360c2e9d49dda5d8098cb751fa09585a /src
parent5e0804a65cefec0283bb0809c1fb18bcad4746cf (diff)
downloadkoopatlas-b24dea2418cac600a2ec719329cfef55f8f66ef8.tar.gz
koopatlas-b24dea2418cac600a2ec719329cfef55f8f66ef8.zip
fixed some pesky bugs, removed debug crap
Diffstat (limited to 'src')
-rw-r--r--src/editorui.py37
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)