summaryrefslogtreecommitdiff
path: root/src/ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.py')
-rw-r--r--src/ui.py43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/ui.py b/src/ui.py
index 56795b6..a7e71ba 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -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