From 1b0e3e2ea94b6093c777f62e8eea8c8adf0294aa Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Thu, 1 Dec 2011 00:59:42 -0600 Subject: Node type Exit was added for transitioning between maps. --- Resources/ExitWorld.png | Bin 4997 -> 5689 bytes src/editorui/editormain.py | 2 +- src/editorui/paths.py | 126 ++++++++++++++++++++++++++++++++++++++++----- src/ui.py | 5 +- 4 files changed, 117 insertions(+), 16 deletions(-) diff --git a/Resources/ExitWorld.png b/Resources/ExitWorld.png index b0940ee..d81f6f9 100644 Binary files a/Resources/ExitWorld.png and b/Resources/ExitWorld.png differ diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py index 92bfda2..b74967b 100644 --- a/src/editorui/editormain.py +++ b/src/editorui/editormain.py @@ -21,7 +21,7 @@ class KPMapScene(QtGui.QGraphicsScene): self.ticker.setCurveShape(4) self.ticker.setFrameRange(0,100000) self.ticker.valueChanged.connect(self.thing) - self.ticker.setUpdateInterval(1) + self.ticker.setUpdateInterval(16.6666666666667) def playPause(self): diff --git a/src/editorui/paths.py b/src/editorui/paths.py index fd27a9c..c1579be 100644 --- a/src/editorui/paths.py +++ b/src/editorui/paths.py @@ -66,12 +66,38 @@ class KPEditorNode(KPEditorItem): self.setRange(1, 99) - if not hasattr(KPEditorNode.LevelSlotSpinner, 'PALETTE'): - palette = QtGui.QApplication.palette(self) - palette.setColor(QtGui.QPalette.Window, Qt.transparent) - KPEditorNode.LevelSlotSpinner.PALETTE = palette + palette = self.palette() + palette.setColor(QtGui.QPalette.ButtonText, Qt.black) + palette.setColor(QtGui.QPalette.Window, Qt.transparent) - self.setPalette(self.PALETTE) + self.setPalette(palette) + + + class TransitionBox(QtGui.QComboBox): + def __init__(self): + QtGui.QComboBox.__init__(self) + + self.addItems(['Fade Out', 'Circle Wipe', 'Bowser Wipe', 'Goo Wipe Down', + 'Mario Wipe', 'Circle Wipe Slow', 'Glitchgasm']) + + palette = self.palette() + palette.setColor(QtGui.QPalette.ButtonText, Qt.black) + palette.setColor(QtGui.QPalette.Window, Qt.transparent) + + self.setPalette(palette) + + + class mapArcEdit(QtGui.QLineEdit): + def __init__(self): + QtGui.QLineEdit.__init__(self) + + self.setText('None.arc') + + palette = self.palette() + palette.setColor(QtGui.QPalette.ButtonText, Qt.black) + palette.setColor(QtGui.QPalette.Window, Qt.transparent) + + self.setPalette(palette) def __init__(self, node): @@ -105,6 +131,19 @@ class KPEditorNode(KPEditorItem): self.stage.valueChanged.connect(self.stageChange) + self.foreignID = self.LevelSlotSpinner() + self.foreignIDProxy = self.HiddenProxy(self.foreignID, self, 60, 24) + self.foreignID.valueChanged.connect(self.foreignIDChange) + + self.mapChange = self.mapArcEdit() + self.mapChangeProxy = self.HiddenProxy(self.mapChange, self, -100, 60) + self.mapChange.textEdited.connect(self.mapChangeChange) + + self.transition = self.TransitionBox() + self.transitionProxy = self.HiddenProxy(self.transition, self, -102, 24) + self.transition.currentIndexChanged.connect(self.transitionChange) + + self._updatePosition() @@ -116,6 +155,7 @@ class KPEditorNode(KPEditorItem): node.transition = 0 node.mapChange = None node.mapID = None + node.foreignID = None node.isStop = True node.level = [0,0] @@ -128,12 +168,28 @@ class KPEditorNode(KPEditorItem): pass elif state == 3: - node.isStop = False - - else: node.transition = 0 node.mapChange = 'None.arc' - node.mapID = 0 + node.foreignID = 0 + + usedIDs = [] + for nodesPicker in KP.map.pathLayer.nodes: + usedIDs.append(nodesPicker.mapID) + + i = 1 + while i in usedIDs: + i += 1 + + node.mapID = i + + self.foreignID.setValue(1) + self.mapChange.setText('None.arc') + self.transition.setCurrentIndex(0) + + + else: + node.isStop = False + self.update() @@ -152,6 +208,27 @@ class KPEditorNode(KPEditorItem): node.level[1] = stage + @QtCore.pyqtSlot(int) + def foreignIDChange(self, ID): + + node = self._nodeRef() + node.foreignID = ID + + + @QtCore.pyqtSlot(int) + def transitionChange(self, index): + + node = self._nodeRef() + node.transition = index + + + @QtCore.pyqtSlot(str) + def mapChangeChange(self, mapname): + + node = self._nodeRef() + node.mapChange = mapname + + def _updatePosition(self): node = self._nodeRef() x, y = node.position @@ -183,6 +260,19 @@ class KPEditorNode(KPEditorItem): painter.setBrush(QtGui.QColor(0, 0, 0, 0)) painter.setPen(QtGui.QColor(0, 0, 0, 0)) painter.drawPixmap(self._boundingRect.topLeft(), QtGui.QPixmap("Resources/ExitWorld.png")) + + textPath = QtGui.QPainterPath() + font = QtGui.QFont("Times", 22) + font.setStyleStrategy(QtGui.QFont.ForceOutline) + textPath.addText(-6, 3, font, str(node.mapID)) + + painter.setBrush(QtGui.QColor(140, 140, 255)) + pen = QtGui.QPen(QtGui.QColor(80, 80, 255)) + pen.setWidth(1) + pen.setStyle(Qt.SolidLine) + painter.setPen(pen) + painter.drawPath(textPath) + selectionRect = self._boundingRect.adjusted(1,5,-1,-5) elif node.isStop: @@ -200,8 +290,6 @@ class KPEditorNode(KPEditorItem): selectionRect = self._tinyRect.adjusted(-1,-1,1,1) - - if self.isSelected(): painter.setPen(self.SELECTION_PEN) painter.setBrush(QtGui.QColor(0,0,0,0)) @@ -217,11 +305,25 @@ class KPEditorNode(KPEditorItem): self.worldProxy.hide() self.stageProxy.hide() + + if node.mapChange != None: + self.foreignID.show() + self.transition.show() + self.mapChange.show() + + else: + self.foreignID.hide() + self.transition.hide() + self.mapChange.hide() + else: self.buttonProxy.hide() self.worldProxy.hide() self.stageProxy.hide() - + self.foreignID.hide() + self.transition.hide() + self.mapChange.hide() + def remove(self, withItem=False): node = self._nodeRef() diff --git a/src/ui.py b/src/ui.py index 6f9cde8..d5c5c2a 100644 --- a/src/ui.py +++ b/src/ui.py @@ -457,14 +457,13 @@ class KPMainWindow(QtGui.QMainWindow): self.doodadSelectorDock.show() elif isinstance(layer, KPTileLayer): + KP.map.reloadTileset(layer.tileset) + self.doodadSelectorDock.hide() self.objectSelectorDock.show() self.objectSelector.setModel(KP.map.loadedTilesets[layer.tileset].getModel()) - print 'Reloading ', layer.tileset - KP.map.reloadTileset(layer.tileset) - @QtCore.pyqtSlot(int, KPTileObject) def handleSelectedObjectChanged(self, index, obj): -- cgit v1.2.3