summaryrefslogtreecommitdiff
path: root/src/editorui/editormain.py
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-11-25 03:32:29 -0600
committerColin Noga <Tempus@Spectrum-Song.local>2011-11-25 03:32:29 -0600
commitb108fc94779df34fe498b8a2b5ce6a155711455c (patch)
treee57d6bbcfdbb43ddd67621c5aa999cc7a075ba19 /src/editorui/editormain.py
parent123ae369ff7e84f75e16c1ada8f248493b35aea6 (diff)
downloadkoopatlas-b108fc94779df34fe498b8a2b5ce6a155711455c.tar.gz
koopatlas-b108fc94779df34fe498b8a2b5ce6a155711455c.zip
ANIMATIONS AND PREVIEWING ARE WORKING. They look da bomb.
Other issues: animation ui editors don't always have proper range settings, deco charatcers, steps, etc. The animation pop up is a bit unruly, tends to move around.' '
Diffstat (limited to 'src/editorui/editormain.py')
-rw-r--r--src/editorui/editormain.py92
1 files changed, 87 insertions, 5 deletions
diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py
index f25452b..4d8e1af 100644
--- a/src/editorui/editormain.py
+++ b/src/editorui/editormain.py
@@ -14,7 +14,40 @@ class KPMapScene(QtGui.QGraphicsScene):
self.currentLayer = None
KP.mapScene = self
-
+ self.playing = False
+ self.timeLines = []
+ self.ticker = QtCore.QTimeLine(100000)
+ self.ticker.setLoopCount(10)
+ self.ticker.setCurveShape(4)
+ self.ticker.setFrameRange(0,100000)
+ self.ticker.valueChanged.connect(self.thing)
+ self.ticker.setUpdateInterval
+
+
+ def playPause(self):
+ if self.playing == False:
+ self.playing = True
+ self.views()[0].setViewportUpdateMode(0)
+ self.ticker.start()
+
+ for timeline in self.timeLines:
+ timeline.start()
+ self.views()[0].update()
+
+ else:
+ self.playing = False
+ self.views()[0].setViewportUpdateMode(1)
+ self.ticker.stop()
+
+ for timeline in self.timeLines:
+ timeline.stop()
+ self.views()[0].update()
+
+
+ @QtCore.pyqtSlot(int)
+ def thing(self, value):
+ self.views()[0].update()
+
def drawBackground(self, painter, rect):
painter.fillRect(rect, QtGui.QColor(209, 218, 236))
@@ -55,13 +88,19 @@ class KPMapScene(QtGui.QGraphicsScene):
continue
for item in reversed(toDraw):
+
painter.save()
- painter.setWorldTransform(item.sceneTransform(), True)
- w, h = item._doodadRef().size
- p = item._boundingRect
- painter.drawPixmap(p.x(), p.y(), p.width(), p.height(), item.pixmap)
+
+ if self.playing == False:
+ painter.setWorldTransform(item.sceneTransform(), True)
+ p = item._boundingRect
+ painter.drawPixmap(p.x(), p.y(), p.width(), p.height(), item.pixmap)
+
+ else:
+ self.animateDoodad(painter, item)
painter.restore()
+
elif isinstance(layer, KPTileLayer):
left, top = layer.cacheBasePos
width, height = layer.cacheSize
@@ -109,6 +148,49 @@ class KPMapScene(QtGui.QGraphicsScene):
destY += 24
+ def animateDoodad(self, painter, item):
+
+ doodad = item._doodadRef()
+ animations = doodad.animations
+
+ transform = item.sceneTransform()
+ posRect = item._boundingRect.adjusted(0,0,0,0)
+
+ # Anm indexes are Looping, Interpolation, Frame Len, Type, Start Value, End Value
+ #
+ # Anm Loops are Contiguous, Loop, Reversible Loop
+ # Anm Interpolations are Linear, Sinusoidial, Cosinoidial
+ # Anm Types are X Position, Y Position, Angle, X Scale, Y Scale, Opacity
+
+ for anm in animations:
+
+ Type = anm[3]
+ Timeline = anm[6]
+
+ modifier = Timeline.currentFrame()
+
+ if Type == "X Position":
+ posRect.adjust(modifier, 0, modifier, 0)
+
+ elif Type == "Y Position":
+ posRect.adjust(0, modifier, 0, modifier)
+
+ elif Type == "Angle":
+ transform.rotate(modifier)
+
+ elif Type == "X Scale":
+ posRect.setWidth(posRect.width()*modifier/100.0)
+
+ elif Type == "Y Scale":
+ posRect.setHeight(posRect.height()*modifier/100.0)
+
+ elif Type == "Opacity":
+ painter.setOpacity(modifier/100.0)
+
+ painter.setWorldTransform(transform, True)
+ painter.drawPixmap(posRect.x(), posRect.y(), posRect.width(), posRect.height(), item.pixmap)
+
+
def setCurrentLayer(self, layer):
if self.currentLayer is not None:
self.currentLayer.setActivated(False)