summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Resources/Key.pngbin0 -> 2174 bytes
-rw-r--r--Resources/KeyArrow.pngbin0 -> 2245 bytes
-rw-r--r--Resources/LayerBack.pngbin0 -> 2468 bytes
-rw-r--r--Resources/LayerFront.pngbin0 -> 2418 bytes
-rw-r--r--Resources/LayerNewObjects.pngbin0 -> 2740 bytes
-rw-r--r--Resources/LayerNewTile.pngbin0 -> 2172 bytes
-rw-r--r--Resources/LayerObjects.pngbin0 -> 2581 bytes
-rw-r--r--Resources/LayerPath.pngbin0 -> 1458 bytes
-rw-r--r--Resources/LayerRemove.pngbin0 -> 1860 bytes
-rw-r--r--Resources/LayerTile.pngbin0 -> 2009 bytes
-rw-r--r--Resources/SecretKey.pngbin0 -> 2045 bytes
-rw-r--r--Resources/Unlock.pngbin0 -> 1875 bytes
-rw-r--r--src/editorui/editormain.py4
-rw-r--r--src/editorui/paths.py135
-rw-r--r--src/mapdata.py10
15 files changed, 133 insertions, 16 deletions
diff --git a/Resources/Key.png b/Resources/Key.png
new file mode 100644
index 0000000..2e557f4
--- /dev/null
+++ b/Resources/Key.png
Binary files differ
diff --git a/Resources/KeyArrow.png b/Resources/KeyArrow.png
new file mode 100644
index 0000000..fb09bed
--- /dev/null
+++ b/Resources/KeyArrow.png
Binary files differ
diff --git a/Resources/LayerBack.png b/Resources/LayerBack.png
new file mode 100644
index 0000000..c4f396c
--- /dev/null
+++ b/Resources/LayerBack.png
Binary files differ
diff --git a/Resources/LayerFront.png b/Resources/LayerFront.png
new file mode 100644
index 0000000..31086a6
--- /dev/null
+++ b/Resources/LayerFront.png
Binary files differ
diff --git a/Resources/LayerNewObjects.png b/Resources/LayerNewObjects.png
new file mode 100644
index 0000000..4d9c675
--- /dev/null
+++ b/Resources/LayerNewObjects.png
Binary files differ
diff --git a/Resources/LayerNewTile.png b/Resources/LayerNewTile.png
new file mode 100644
index 0000000..da29333
--- /dev/null
+++ b/Resources/LayerNewTile.png
Binary files differ
diff --git a/Resources/LayerObjects.png b/Resources/LayerObjects.png
new file mode 100644
index 0000000..797917b
--- /dev/null
+++ b/Resources/LayerObjects.png
Binary files differ
diff --git a/Resources/LayerPath.png b/Resources/LayerPath.png
new file mode 100644
index 0000000..dd325bd
--- /dev/null
+++ b/Resources/LayerPath.png
Binary files differ
diff --git a/Resources/LayerRemove.png b/Resources/LayerRemove.png
new file mode 100644
index 0000000..143fe5b
--- /dev/null
+++ b/Resources/LayerRemove.png
Binary files differ
diff --git a/Resources/LayerTile.png b/Resources/LayerTile.png
new file mode 100644
index 0000000..46f2a6b
--- /dev/null
+++ b/Resources/LayerTile.png
Binary files differ
diff --git a/Resources/SecretKey.png b/Resources/SecretKey.png
new file mode 100644
index 0000000..56b94c0
--- /dev/null
+++ b/Resources/SecretKey.png
Binary files differ
diff --git a/Resources/Unlock.png b/Resources/Unlock.png
new file mode 100644
index 0000000..e375e9a
--- /dev/null
+++ b/Resources/Unlock.png
Binary files differ
diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py
index 297ac34..8ffd034 100644
--- a/src/editorui/editormain.py
+++ b/src/editorui/editormain.py
@@ -307,8 +307,8 @@ class KPEditorWidget(QtGui.QGraphicsView):
KP.map.pathLayer.paths.append(path)
- pathitem = KPEditorPath(path)
- self.scene().addItem(pathitem)
+ pathItem = KPEditorPath(path)
+ self.scene().addItem(pathItem)
# Switch the selection to the recently drawn node, so you can keep on rolling.
diff --git a/src/editorui/paths.py b/src/editorui/paths.py
index c5a51b6..ad81fa0 100644
--- a/src/editorui/paths.py
+++ b/src/editorui/paths.py
@@ -73,7 +73,6 @@ class KPEditorNode(KPEditorItem):
self.setPalette(self.PALETTE)
-
def __init__(self, node):
KPEditorItem.__init__(self)
@@ -108,7 +107,6 @@ class KPEditorNode(KPEditorItem):
self._updatePosition()
-
@QtCore.pyqtSlot(int)
def stateChange(self, state):
@@ -145,7 +143,6 @@ class KPEditorNode(KPEditorItem):
node.level[1] = stage
-
def _updatePosition(self):
node = self._nodeRef()
x, y = node.position
@@ -162,6 +159,7 @@ class KPEditorNode(KPEditorItem):
def paint(self, painter, option, widget):
+ painter.setRenderHint(QtGui.QPainter.Antialiasing)
node = self._nodeRef()
selectionRect = None
@@ -208,8 +206,6 @@ class KPEditorNode(KPEditorItem):
self.stageProxy.hide()
-
-
def remove(self, withItem=False):
node = self._nodeRef()
layer = KP.map.pathLayer
@@ -261,6 +257,98 @@ class KPEditorNode(KPEditorItem):
class KPEditorPath(QtGui.QGraphicsLineItem):
+
+
+ class UnlockButton(QtGui.QPushButton):
+ def __init__(self, pathRef):
+ QtGui.QPushButton.__init__(self)
+
+ self.setIconSize(QtCore.QSize(32,32))
+ self.setFixedSize(64,64)
+
+ self.iconList = [QtGui.QIcon("Resources/Key.png"),
+ QtGui.QIcon("Resources/SecretKey.png")]
+
+ self.unlockIcon = QtGui.QIcon("Resources/Unlock.png")
+ self.arrowIcon = QtGui.QIcon("Resources/KeyArrow.png")
+
+ self._pathRef = pathRef
+
+ self.secret = 0
+ self.path = 0
+
+ if not hasattr(KPEditorPath.UnlockButton, 'PALETTE'):
+ KPEditorPath.UnlockButton.PALETTE = QtGui.QPalette(Qt.transparent)
+
+ self.setPalette(self.PALETTE)
+
+ self.released.connect(self.toggle)
+
+
+ def toggle(self):
+
+ path = self._pathRef()
+
+ if KP.app.keyboardModifiers() == Qt.ShiftModifier:
+ if self.secret == 1:
+ self.secret = 0
+ else:
+ self.secret = 1
+
+ path.secret = self.secret
+
+ else:
+ self.path += 1
+
+ if self.path > 2:
+ self.path = 0
+
+ path.unlocks = self.path
+
+
+ def paintEvent(self, event):
+
+ painter = QtGui.QPainter(self)
+
+ if self.path > 0:
+ painter.save()
+
+ pathItem = self._pathRef().qtItem.line()
+
+ if self.path == 1:
+ angle = pathItem.angle()
+ else:
+ angle = 180 + pathItem.angle()
+
+ painter.rotate(angle)
+ self.arrowIcon.paint(painter, self.contentsRect(), Qt.AlignCenter)
+
+ painter.restore()
+
+ if self.isDown():
+ self.iconList[self.secret].paint(painter, self.contentsRect(), Qt.AlignCenter, QtGui.QIcon.Disabled)
+ else:
+ self.iconList[self.secret].paint(painter, self.contentsRect(), Qt.AlignCenter)
+
+ else:
+ if self.isDown():
+ self.unlockIcon.paint(painter, self.contentsRect(), Qt.AlignCenter, QtGui.QIcon.Disabled)
+ else:
+ self.unlockIcon.paint(painter, self.contentsRect(), Qt.AlignCenter)
+
+ painter.end()
+
+
+ class HiddenProxy(QtGui.QGraphicsProxyWidget):
+ def __init__(self, button, parent, x, y):
+ QtGui.QGraphicsProxyWidget.__init__(self, parent)
+
+ self.setWidget(button)
+ self.setPos(x, y)
+ self.setZValue(parent.zValue()+1000)
+ self.hide()
+
+
def __init__(self, path):
QtGui.QGraphicsLineItem.__init__(self)
@@ -277,13 +365,19 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
path.qtItem = self
- self.updatePosition()
-
if not hasattr(KPEditorPath, 'PEN'):
KPEditorPath.BRUSH = QtGui.QBrush(QtGui.QColor(255, 255, 255, 140))
KPEditorPath.PEN = QtGui.QPen(KPEditorPath.BRUSH, 8, Qt.SolidLine, Qt.RoundCap)
self.setPen(KPEditorPath.PEN)
+ if not hasattr(KPEditorPath, 'SELECTION_PEN'):
+ KPEditorPath.SELECTION_PEN = QtGui.QPen(Qt.blue, 1, Qt.DotLine)
+
+ self.unlock = self.UnlockButton(self._pathRef)
+ self.unlockProxy = self.HiddenProxy(self.unlock, self, -32, -32)
+
+ self.updatePosition()
+
def updatePosition(self):
path = self._pathRef()
@@ -291,9 +385,34 @@ class KPEditorPath(QtGui.QGraphicsLineItem):
x1, y1 = path._startNodeRef().position
x2, y2 = path._endNodeRef().position
- self.setLine(QtCore.QLineF(x1+12, y1+12, x2+12, y2+12))
+ originLine = QtCore.QLineF(x1+12, y1+12, x2+12, y2+12)
+ self.setPos(originLine.pointAt(0.5))
+ dy = originLine.dy()/2
+ dx = originLine.dx()/2
+
+ self.setLine(QtCore.QLineF(-dx, -dy, dx, dy))
+ def paint(self, painter, option, widget):
+
+ painter.setRenderHint(QtGui.QPainter.Antialiasing)
+
+ painter.setPen(KPEditorPath.PEN)
+ painter.drawLine(self.line())
+
+ if self.isSelected():
+ painter.setPen(self.SELECTION_PEN)
+ painter.setBrush(QtGui.QColor(0,0,0,0))
+ painter.drawPath(self.shape())
+
+ self.unlockProxy.show()
+
+ else:
+ self.unlockProxy.hide()
+
+
+
+
def remove(self, withItem=False):
path = self._pathRef()
layer = KP.map.pathLayer
diff --git a/src/mapdata.py b/src/mapdata.py
index a50c98e..013e308 100644
--- a/src/mapdata.py
+++ b/src/mapdata.py
@@ -138,7 +138,6 @@ class KPDoodad(object):
self.size = [pixmap.width(), pixmap.height()]
-
class KPDoodadLayer(KPLayer):
def __repr__(self):
return "<KPDoodadLayer %r>" % self.name
@@ -154,13 +153,12 @@ class KPDoodadLayer(KPLayer):
item.setVisible(value)
-
class KPNodeAction(object):
def __init__(self):
pass
-class KPNode(object):
+class KPNode(object):
def __init__(self):
self.position = (0,0)
self.actions = []
@@ -177,6 +175,9 @@ class KPPath(object):
startNode.exits.append(self)
endNode.exits.append(self)
+ self.unlocks = 0 # 0 = always unlocked, 1 = unlocked from startNode, 2 = unlocked from endNode
+ self.secret = 0 # 0 = unlocks from normal exit, 1 = unlocks from secret exit
+
if cloneFrom is None:
self.animation = None
else:
@@ -225,9 +226,6 @@ class KPPathLayer(KPLayer):
item.setFlag(flag, value)
-
-
-
class KPMap(object):
def __init__(self):
self.nextLayerNumber = 1