diff options
Diffstat (limited to 'src/editorui/editormain.py')
-rw-r--r-- | src/editorui/editormain.py | 92 |
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) |