summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-11-17 08:28:06 -0600
committerColin Noga <Tempus@Spectrum-Song.local>2011-11-17 08:28:06 -0600
commitfbbcc2155643c791f6d455d0bac290761e809b7c (patch)
tree0d62a27b562748a4a39321965d0fa69834309934 /src
parent68e66b16255ea2603bd323083e3b5b43280caff1 (diff)
downloadkoopatlas-fbbcc2155643c791f6d455d0bac290761e809b7c.tar.gz
koopatlas-fbbcc2155643c791f6d455d0bac290761e809b7c.zip
Prototyped some path shit
Diffstat (limited to '')
-rw-r--r--src/editorui.py86
-rw-r--r--src/mapdata.py23
2 files changed, 105 insertions, 4 deletions
diff --git a/src/editorui.py b/src/editorui.py
index 6b0815c..b7d691a 100644
--- a/src/editorui.py
+++ b/src/editorui.py
@@ -248,7 +248,6 @@ class KPEditorObject(KPEditorItem):
del obj
-
class KPEditorDoodad(QtGui.QGraphicsPixmapItem):
def __init__(self, doodad, layer):
QtGui.QGraphicsPixmapItem.__init__(self)
@@ -496,6 +495,90 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem):
del doodad
+class KPEditorNode(QtGui.QGraphicsPixmapItem):
+ def __init__(self, node, layer):
+ QtGui.QGraphicsPixmapItem.__init__(self)
+ self.setFlags(
+ self.ItemSendsGeometryChanges |
+ self.ItemIsSelectable |
+ self.ItemIsMovable
+ )
+
+class KPEditorPathSegment(QtGui.QGraphicsPathItem):
+ def __init__(self, node, layer):
+ QtGui.QGraphicsPathItem.__init__(self)
+ self.setFlags(
+ self.ItemSendsGeometryChanges |
+ self.ItemIsSelectable |
+ self.ItemIsMovable
+ )
+
+ self.path = QtGui.QPainterPath()
+ self.brush = None
+ self.pen = None
+
+ self.rotation = 0
+
+
+ def makeStraight(self, start, end):
+
+ self.path.moveTo(start)
+ self.path.addPolygon(QtGui.QPolygon([QtCore.QPointF(start.x(), start.y()-5.0),
+ QtCore.QPointF(end.x(), end.y()-5.0),
+ QtCore.QPointF(end.x(), end.y()+5.0),
+ QtCore.QPointF(start.x(), start.y()+5.0),
+ QtCore.QPointF(start.x(), start.y()-5.0)]
+
+
+ graduate = QtGui.QRadialGradiant(QtCore.QPointF((end.x()/2)-(start.x()/2), (end.y()/2)-(start.y()/2) + 16), (end.x()/2)-(start.x()/2),
+ graduate.setColorA(QColor(200, 210, 240))
+ graduate.setColorB(QColor(150, 160, 190))
+
+ self.brush = QtGui.QBrush(graduate)
+
+ self.pen = QtGui.QPen(QColor(120, 130, 160))
+ self.pen.setWidth(4)
+ self.pen.setCapStyle(Qt.RoundCap)
+ self.pen.setJoinStyle(Qt.RoundJoin)
+
+
+
+ def makeArc(self, start, end):
+
+ self.path.moveTo(start)
+ self.path.addEllipse(start.x(), start.y(), end.x()-start.x(), end.y()-start.y())
+
+ r = QtGui.QPainterPath()
+ r.addEllipse(start.x(), start.y()-4, end.x()-start.x(), end.y()-start.y()-16)
+
+ self.path.subtracted(r)
+
+
+ graduate = QtGui.QRadialGradiant(QtCore.QPointF((end.x()/2)-(start.x()/2), (end.y()/2)-(start.y()/2) + 16), (end.x()/2)-(start.x()/2),
+ graduate.setColorA(QColor(200, 210, 240))
+ graduate.setColorB(QColor(150, 160, 190))
+
+ self.brush = QtGui.QBrush(graduate)
+
+ self.pen = QtGui.QPen(QColor(120, 130, 160))
+ self.pen.setWidth(4)
+ self.pen.setCapStyle(Qt.RoundCap)
+ self.pen.setJoinStyle(Qt.RoundJoin)
+
+
+ sX = start.x()
+ sY = start.y()
+
+ eX = end.x()
+ eY = end.y()
+
+ dy = eY - sY
+ dx = eX - sX
+ rads = math.atan2(dy, dx)
+
+ self.rotate = math.degrees(rads)
+
+
class KPMapScene(QtGui.QGraphicsScene):
@@ -616,7 +699,6 @@ class KPMapScene(QtGui.QGraphicsScene):
item.setFlag(flag, value)
-
class KPEditorWidget(QtGui.QGraphicsView):
def __init__(self, scene, parent=None):
QtGui.QGraphicsView.__init__(self, scene, parent)
diff --git a/src/mapdata.py b/src/mapdata.py
index 64a8f44..3c60e53 100644
--- a/src/mapdata.py
+++ b/src/mapdata.py
@@ -160,6 +160,25 @@ class KPPath(object):
self.segments = []
+class KPPathLayer(KPLayer):
+ def __repr__(self):
+ return "<KPPathLayer %r>" % self.name
+
+ def __init__(self):
+ KPLayer.__init__(self)
+ self.nodes = []
+ self.paths = []
+
+ def _visibilityChanged(self, value):
+ for obj in self.objects:
+ item = obj.qtItem
+ if item:
+ item.setVisible(value)
+
+
+
+
+
class KPMap(object):
def __init__(self):
self.nextLayerNumber = 1
@@ -236,14 +255,14 @@ class KPMap(object):
def createNewTileLayer(self, tilesetName):
layer = KPTileLayer()
- layer.name = "Layer %d" % self.nextLayerNumber
+ layer.name = "Tilemap - Layer %d" % self.nextLayerNumber
self.nextLayerNumber += 1
layer.tileset = tilesetName
return layer
def createNewDoodadLayer(self):
layer = KPDoodadLayer()
- layer.name = "Layer %d" % self.nextLayerNumber
+ layer.name = "Doodads - Layer %d" % self.nextLayerNumber
self.nextLayerNumber += 1
return layer