diff options
author | Treeki <treeki@gmail.com> | 2012-02-17 22:21:51 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-02-17 22:21:51 +0100 |
commit | c97c497d3ed019b26e66d20436b5d4ea1dfc4cd7 (patch) | |
tree | f14d81688c984c0e4a2d5f058a35aa321ea46b0b /src/ui.py | |
parent | 5db723084547343dde7c8a0e11f2ca1f7c7149f2 (diff) | |
download | koopatlas-c97c497d3ed019b26e66d20436b5d4ea1dfc4cd7.tar.gz koopatlas-c97c497d3ed019b26e66d20436b5d4ea1dfc4cd7.zip |
fixed the path node tile layer thing business
Diffstat (limited to '')
-rw-r--r-- | src/ui.py | 43 |
1 files changed, 32 insertions, 11 deletions
@@ -150,16 +150,34 @@ class KPPathNodeList(QtGui.QWidget): self.tree.addTopLevelItems(kids) def setTileset(self): + item = self.tree.currentItem() + if not isinstance(item, self.KPPathNodeItem): + return + + layer = item.layer + assoc = item.associate + name = 'path' if isinstance(item.associate, KPPath) else 'node' + from dialogs import KPTilesetChooserDialog - tilesetName = KPTilesetChooserDialog.run('Choose a tileset for the path/node layers') + tilesetName = KPTilesetChooserDialog.run('Choose a tileset for the %s layer' % name) if tilesetName is None: return - KP.map.pathNodeTileset = tilesetName + layer.setTileset(tilesetName) def addLayer(self, associate): layer = KPPathTileLayer(associate) + name = 'path' if isinstance(associate, KPPath) else 'node' + + from dialogs import KPTilesetChooserDialog + + tilesetName = None + while tilesetName is None: + tilesetName = KPTilesetChooserDialog.run('Choose a tileset for the %s layer' % name) + + layer.tileset = tilesetName + item = self.KPPathNodeItem(self.tree, layer, associate) def loadLayer(self, layer): @@ -470,7 +488,7 @@ class KPDoodadSelector(QtGui.QWidget): class KPObjectSelector(QtGui.QWidget): def __init__(self): - """Initialises the widget. Remember to call setModel() on it with a KPGroupModel + """Initialises the widget. Remember to call setTileset() on it whenever the layer changes.""" QtGui.QWidget.__init__(self) @@ -512,7 +530,7 @@ class KPObjectSelector(QtGui.QWidget): # Borrowed the signals and junk from Reggie, figure we'll need em' - # Some more signals are set in setModel + # Some more signals are set in setTileset self.listView.clicked.connect(self.handleObjReplace) self.sorterMenu.aboutToShow.connect(self.fixUpMenuSize) self.sorterMenu.triggered.connect(self.toggleTopLevel) @@ -542,12 +560,15 @@ class KPObjectSelector(QtGui.QWidget): return object - def setModel(self, model): + def setTileset(self, tileset): """Sets the model and the menu sorting list""" + model = tileset.getModel() if model == self.model: return + self.tileset = tileset + self.model = model self.listView.setModel(model) self.listView.setEnabled(True) @@ -600,7 +621,7 @@ class KPObjectSelector(QtGui.QWidget): i = current.row() object, depth = self.model.groupItem().getItem(i) - self.objChanged.emit(i, object) + self.objChanged.emit(self.tileset.objects.index(object), object) def handleObjReplace(self, index): @@ -609,7 +630,7 @@ class KPObjectSelector(QtGui.QWidget): i = current.row() object, depth = self.model.groupItem().getItem(i) - self.objReplaced.emit(i, object) + self.objReplaced.emit(self.tileset.objects.index(object), object) objChanged = QtCore.pyqtSignal(int, KPTileObject) objReplaced = QtCore.pyqtSignal(int, KPTileObject) @@ -803,7 +824,7 @@ class KPMainWindow(QtGui.QMainWindow): KP.map.reloadTileset(layer.tileset) showObjects = True - self.objectSelector.setModel(KP.map.loadedTilesets[layer.tileset].getModel()) + self.objectSelector.setTileset(KP.map.loadedTilesets[layer.tileset]) self.objectSelectorDock.setVisible(showObjects) self.doodadSelectorDock.setVisible(showDoodads) @@ -818,9 +839,9 @@ class KPMainWindow(QtGui.QMainWindow): self.scene.setCurrentLayer(layer) - KP.map.reloadTileset(KP.map.pathNodeTileset) + KP.map.reloadTileset(layer.tileset) - self.objectSelector.setModel(KP.map.loadedTilesets[KP.map.pathNodeTileset].getModel()) + self.objectSelector.setTileset(KP.map.loadedTilesets[layer.tileset]) self.objectSelectorDock.setVisible(True) self.doodadSelectorDock.setVisible(True) @@ -1000,7 +1021,7 @@ class KPMainWindow(QtGui.QMainWindow): KPTileLayer.tileset = tilesetName - self.objectSelector.setModel(KP.map.loadedTilesets[layer.tileset].getModel()) + self.objectSelector.setTileset(KP.map.loadedTilesets[layer.tileset]) # Animate |