diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui/editormain.py | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py index 136eee1..5575453 100644 --- a/src/editorui/editormain.py +++ b/src/editorui/editormain.py @@ -17,7 +17,7 @@ class KPMapScene(QtGui.QGraphicsScene): self.playing = False self.timeLines = [] self.ticker = QtCore.QTimeLine(100000) - self.ticker.setLoopCount(10) + self.ticker.setLoopCount(0) self.ticker.setCurveShape(4) self.ticker.setFrameRange(0,100000) self.ticker.valueChanged.connect(self.thing) @@ -25,6 +25,23 @@ class KPMapScene(QtGui.QGraphicsScene): self.grid = False + # create an item for everything in the map + for layer in KP.map.layers: + if isinstance(layer, KPTileLayer): + for obj in layer.objects: + self.addItem(KPEditorObject(obj, layer)) + elif isinstance(layer, KPDoodadLayer): + for obj in layer.objects: + self.addItem(KPEditorDoodad(obj, layer)) + elif isinstance(layer, KPPathLayer): + for node in layer.nodes: + self.addItem(KPEditorNode(node)) + + for path in layer.paths: + self.addItem(KPEditorPath(path)) + + layer.setActivated(False) + def playPause(self): if self.playing == False: @@ -247,30 +264,30 @@ class KPMapScene(QtGui.QGraphicsScene): # Anm Interpolations are Linear, Sinusoidial, Cosinoidial # Anm Types are X Position, Y Position, Angle, X Scale, Y Scale, Opacity - for anm in animations: + if len(animations) > 0: + for anm, Timeline in zip(animations, doodad.timelines): - Type = anm[3] - Timeline = anm[6] - - modifier = Timeline.currentFrame() + Type = anm[3] + + modifier = Timeline.currentFrame() - if Type == "X Position": - posRect.adjust(modifier, 0, modifier, 0) + if Type == "X Position": + posRect.adjust(modifier, 0, modifier, 0) - elif Type == "Y Position": - posRect.adjust(0, modifier, 0, modifier) + elif Type == "Y Position": + posRect.adjust(0, modifier, 0, modifier) - elif Type == "Angle": - transform.rotate(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 == "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) + elif Type == "Opacity": + painter.setOpacity(modifier/100.0) painter.setWorldTransform(transform, True) painter.drawPixmap(posRect.x(), posRect.y(), posRect.width(), posRect.height(), item.pixmap) @@ -299,11 +316,16 @@ class KPEditorWidget(QtGui.QGraphicsView): self.yScrollBar = QtGui.QScrollBar(Qt.Vertical, parent) self.setVerticalScrollBar(self.yScrollBar) + self.assignNewScene(scene) + + def assignNewScene(self, scene): + self.setScene(scene) self.centerOn(0,0) # set up stuff for painting - self.paintNext = None - self.paintNextID = None + self.objectToPaint = None + self.objectIDToPaint = None + self.doodadToPaint = None self._resetPaintVars() def _resetPaintVars(self): @@ -314,11 +336,11 @@ class KPEditorWidget(QtGui.QGraphicsView): def _tryToPaint(self, event): '''Called when a paint attempt is initiated''' - paint = self.paintNext layer = self.scene().currentLayer if not layer.visible: return if isinstance(layer, KPTileLayer): + paint = self.objectToPaint if paint is None: return clicked = self.mapToScene(event.x(), event.y()) @@ -346,6 +368,7 @@ class KPEditorWidget(QtGui.QGraphicsView): self.paintBeginPosition = (x, y) elif isinstance(layer, KPDoodadLayer): + paint = self.doodadToPaint if paint is None: return clicked = self.mapToScene(event.x(), event.y()) @@ -355,7 +378,7 @@ class KPEditorWidget(QtGui.QGraphicsView): obj = KPDoodad() obj.position = [x,y] - obj.index = self.paintNextID + obj.source = paint obj.setDefaultSize() layer.objects.append(obj) |