diff options
author | Colin Noga <Tempus@chronometry.ca> | 2011-12-16 09:10:26 -0600 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2011-12-16 09:10:26 -0600 |
commit | c9107b3d393a21b1f98761016a3f0a1ac2414140 (patch) | |
tree | 01cc93426083d548a1baeb3a69fbdc0ad034c471 /src/ui.py | |
parent | 8dd9e24d1dffac3404a7c900268cbe6d2ce1e63b (diff) | |
download | koopatlas-c9107b3d393a21b1f98761016a3f0a1ac2414140.tar.gz koopatlas-c9107b3d393a21b1f98761016a3f0a1ac2414140.zip |
Tileset swapping and bits and pieces of node associated layer code
Diffstat (limited to 'src/ui.py')
-rw-r--r-- | src/ui.py | 105 |
1 files changed, 85 insertions, 20 deletions
@@ -7,6 +7,50 @@ import os import os.path +class KPPathNodeList(QtGui.QWidget): + def __init__(self): + QtGui.QWidget.__init__(self) + + self.layout = QtGui.QVBoxLayout() + self.layout.setSpacing(0) + + self.tree = QtGui.QTreeWidget() + self.layout.addWidget(self.tree) + + self.toolbar = QtGui.QToolBar() + self.layout.addWidget(self.toolbar) + + self.setupToolbar(self.toolbar) + self.setLayout(self.layout) + + + def setupToolbar(self, tb): + self.actAddFolder = tb.addAction(KP.icon('LayerNewTile'), 'Add Folder', self.addTileLayer) + self.actRemoveFolder = tb.addAction(KP.icon('LayerNewObjects'), 'Remove Folder', self.addDoodadLayer) + self.actMoveUp = tb.addAction(QtGui.QIcon(), 'Move Up', self.moveUp) + self.actMoveDown = tb.addAction(QtGui.QIcon(), 'Move Down', self.moveDown) + + + selectedLayerChanged = QtCore.pyqtSignal(KPLayer) + + @QtCore.pyqtSlot(QtCore.QModelIndex, QtCore.QModelIndex) + def handleRowChanged(self, current, previous): + self.selectedLayerChanged.emit(KP.map.layers[current.row()]) + self.setButtonStates() + + def moveUp(self): + index = self.selectedLayerIndex() + KP.map.moveLayer(index, index - 1) + KP.mainWindow.editor.viewport().update() + + def moveDown(self): + index = self.selectedLayerIndex() + KP.map.moveLayer(index, index + 2) + KP.mainWindow.editor.viewport().update() + + + + class KPLayerList(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) @@ -63,7 +107,7 @@ class KPLayerList(QtGui.QWidget): def selectedLayerIndex(self): return self.listView.selectionModel().currentIndex().row() def selectedLayer(self): - return KP.map.layers[self.listView.selectionModel().currentIndex().row()] + return KP.map.layers[self.selectedLayerIndex()] selectedLayerChanged = QtCore.pyqtSignal(KPLayer) @@ -466,8 +510,9 @@ class KPMainWindow(QtGui.QMainWindow): self.lf = l.addAction('Move Layer to Top', self.layerList.moveTop, QKeySequence("Ctrl+Shift+Up")) self.lg = l.addAction('Move Layer to Bottom', self.layerList.moveBottom, QKeySequence("Ctrl+Shift+Down")) l.addSeparator() - self.lh = l.addAction('Add Tileset...', self.moveTilesetToFolder, QKeySequence("Ctrl+Shift+T")) self.li = l.addAction('Add Doodad...', self.doodadSelector.addDoodadFromFile, QKeySequence("Ctrl+Shift+R")) + self.lh = l.addAction('Add Tileset...', self.moveTilesetToFolder, QKeySequence("Ctrl+Shift+T")) + self.lj = l.addAction('Change Tileset...', self.changeTileset, QKeySequence("Ctrl+Shift+Alt+T")) a = mb.addMenu('Animate') self.aa = a.addAction('Play Animations', self.playAnim, QKeySequence("Ctrl+P")) @@ -553,9 +598,9 @@ class KPMainWindow(QtGui.QMainWindow): - ##################### - # Slots for Widgets # - ##################### +##################### +# Slots for Widgets # +##################### @QtCore.pyqtSlot(KPLayer) def handleSelectedLayerChanged(self, layer): @@ -587,12 +632,12 @@ class KPMainWindow(QtGui.QMainWindow): self.editor.doodadToPaint = doodad - ######################## - # Slots for Menu Items # - ######################## +######################## +# Slots for Menu Items # +######################## - # File - ######################## +# File +######################## def newMap(self): if self.checkDirty(): return @@ -680,8 +725,8 @@ class KPMainWindow(QtGui.QMainWindow): ScreenshotImage.save(fn, 'PNG', 50) - # Edit - ######################## +# Edit +######################## @QtCore.pyqtSlot() def selectAll(self): @@ -696,8 +741,8 @@ class KPMainWindow(QtGui.QMainWindow): self.scene.clearSelection() - # Layers - ######################## +# Layers +######################## @QtCore.pyqtSlot() def moveTilesetToFolder(self): @@ -722,8 +767,28 @@ class KPMainWindow(QtGui.QMainWindow): KP.map.loadedTilesets[name] = KPTileset.loadFromArc(path) - # Animate - ######################## + @QtCore.pyqtSlot() + def changeTileset(self): + + layer = self.layerList.selectedLayer() + + if not isinstance(layer, KPTileLayer): + return + + + from dialogs import KPTilesetChooserDialog + + tilesetName = KPTilesetChooserDialog.run('Choose a tileset to change to') + if tilesetName is None: + return + + KPTileLayer.tileset = tilesetName + + self.objectSelector.setModel(KP.map.loadedTilesets[layer.tileset].getModel()) + + +# Animate +######################## @QtCore.pyqtSlot() def playAnim(self): @@ -834,8 +899,8 @@ class KPMainWindow(QtGui.QMainWindow): settings.setValue('AnimationPresetData', mapfile.dump([])) - # Window - ######################## +# Window +######################## @QtCore.pyqtSlot() def ZoomActual(self): @@ -893,8 +958,8 @@ class KPMainWindow(QtGui.QMainWindow): pass - # Help - ######################## +# Help +######################## @QtCore.pyqtSlot(bool) def aboutDialog(self): |