From 3bdc780bd3eaa204b1df5d5e6727a876d5967401 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 2 Dec 2011 19:07:13 +0100 Subject: a really, really big commit --- src/editorui/doodads.py | 58 +++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 43 deletions(-) (limited to 'src/editorui/doodads.py') diff --git a/src/editorui/doodads.py b/src/editorui/doodads.py index 632551d..f57502a 100644 --- a/src/editorui/doodads.py +++ b/src/editorui/doodads.py @@ -159,8 +159,8 @@ class KPEditorDoodad(KPEditorItem): itemC.setData(0.0, QtCore.Qt.EditRole) self.model.appendRow([QtGui.QStandardItem("Contiguous"), QtGui.QStandardItem("Linear"), - QtGui.QStandardItem(itemA), QtGui.QStandardItem("X Position"), - QtGui.QStandardItem(itemB), QtGui.QStandardItem(itemC)]) + itemA, QtGui.QStandardItem("X Position"), + itemB, itemC]) def remAnmItem(self): @@ -223,43 +223,10 @@ class KPEditorDoodad(KPEditorItem): rowList.append(data) - - Loop = rowList[0] - Type = rowList[3] - Curve = rowList[1] - Frames = rowList[2] - StartVal = rowList[4] - EndVal = rowList[5] - - Timeline = QtCore.QTimeLine() - - # Interpolate the correct modifier - if Curve == "Linear": - Timeline.setCurveShape(3) - elif Curve == "Sinusoidial": - Timeline.setCurveShape(4) - elif Curve == "Cosinoidial": - Timeline.setCurveShape(5) - - Timeline.setFrameRange(StartVal, EndVal) - - if Loop == "Contiguous": - Timeline.setLoopCount(1) - elif Loop == "Loop": - Timeline.setLoopCount(1000000000) # Dollars *holds pinky to corner of mouth* - elif Loop == "Reversible Loop": - Timeline.setLoopCount(1) - Timeline.finished.connect(Timeline.toggleDirection) - Timeline.finished.connect(Timeline.start) - - Timeline.setDuration(Frames/60.0*1000) # Wii goes at 60 frames per second - - rowList.append(Timeline) - KP.mapScene.timeLines.append(Timeline) - anmList.append(rowList) - + doodad.animations = anmList + doodad.setupAnimations() self.update() @@ -281,13 +248,11 @@ class KPEditorDoodad(KPEditorItem): self._doodadRef = weakref.ref(doodad) self._layerRef = weakref.ref(layer) - # TODO: refactor this to store source doodad data under KP.map - sourceItem = KP.mainWindow.doodadSelector.getDoodad(doodad.index) - self._sourceRef = weakref.ref(sourceItem) - self.resizing = None self.rotating = None + self.source = doodad.source + self._updatePixmap() self._updatePosition() self._updateSize() @@ -297,14 +262,16 @@ class KPEditorDoodad(KPEditorItem): self.setAcceptHoverEvents(True) + if len(doodad.animations) > 0: + doodad.setupAnimations() + if not hasattr(KPEditorDoodad, 'SELECTION_PEN'): KPEditorDoodad.SELECTION_PEN = QtGui.QPen(Qt.red, 1, Qt.DotLine) def _updatePixmap(self): - source = self._sourceRef() - pixmap = source.icon().pixmap(source.icon().availableSizes()[0]) + pixmap = self.source[1] self.prepareGeometryChange() w, h = pixmap.width(), pixmap.height() @@ -314,11 +281,15 @@ class KPEditorDoodad(KPEditorItem): def _updatePosition(self): # NOTE: EditorDoodads originate at the centre, not the top left like the others + self.ignoreMovement = True + doodad = self._doodadRef() x,y = doodad.position w,h = doodad.size self.setPos(x+floor(w/2.0), y+floor(h/2.0)) + self.ignoreMovement = False + def _updateSize(self): self.prepareGeometryChange() @@ -514,6 +485,7 @@ class KPEditorDoodad(KPEditorItem): layer = self._layerRef() layer.objects.remove(doodad) + doodad.cleanUpAnimations() if withItem: self.scene().removeItem(self) -- cgit v1.2.3