diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui.py | 21 | ||||
-rw-r--r-- | src/mapdata.py | 5 | ||||
-rw-r--r-- | src/ui.py | 13 |
3 files changed, 30 insertions, 9 deletions
diff --git a/src/editorui.py b/src/editorui.py index 51b148d..4eeca1d 100644 --- a/src/editorui.py +++ b/src/editorui.py @@ -1,6 +1,12 @@ from common import * class KPMapScene(QtGui.QGraphicsScene): + def __init__(self): + QtGui.QGraphicsScene.__init__(self) + + self.currentLayer = None + + def drawBackground(self, painter, rect): painter.fillRect(rect, Qt.white) @@ -58,6 +64,21 @@ class KPMapScene(QtGui.QGraphicsScene): srcY += 1 destY += 24 + + + def setCurrentLayer(self, layer): + if self.currentLayer is not None: + self.setLayerObjectsFlag(self.currentLayer, QtGui.QGraphicsItem.ItemIsSelectable, False) + + self.currentLayer = layer + self.setLayerObjectsFlag(layer, QtGui.QGraphicsItem.ItemIsSelectable, True) + + + def setLayerObjectsFlag(self, layer, flag, value): + for obj in layer.objects: + item = obj.qtItem + if item: + item.setFlag(flag, value) class KPEditorWidget(QtGui.QGraphicsView): pass diff --git a/src/mapdata.py b/src/mapdata.py index 2b7a403..3938047 100644 --- a/src/mapdata.py +++ b/src/mapdata.py @@ -11,6 +11,7 @@ class KPObject(object): self.kind = 0 self.cache = [] self.tileset = None + self.qtItem = None def updateCache(self): self.cache = KP.map.tilesets[self.tileset].objects[self.kind].render(self.size) @@ -128,9 +129,9 @@ class KPMap(object): # TESTING CRAP import os.path if os.path.exists('/Users/Tempus'): - self.tilesets['Test'] = {'path': '/Users/Tempus/Dropbox/NEWERsmbw/Test2.arc'} + self.tilesets['Test'] = {'path': '/Users/Tempus/Dropbox/NEWERsmbw/Test3.arc'} else: - self.tilesets['Test'] = {'path': '/home/me/Dropbox/NEWERsmbw/Test2.arc'} + self.tilesets['Test'] = {'path': '/home/me/Dropbox/NEWERsmbw/Test3.arc'} self.reloadTileset('Test') @@ -38,14 +38,11 @@ class KPLayerList(QtGui.QWidget): def selectedLayer(self): return KP.map.layers[self.listView.selectionModel().currentIndex().row()] - selectedLayerChanged = QtCore.pyqtSignal(KPLayer, KPLayer) + selectedLayerChanged = QtCore.pyqtSignal(KPLayer) @QtCore.pyqtSlot(QtCore.QModelIndex, QtCore.QModelIndex) def handleRowChanged(self, current, previous): - self.selectedLayerChanged.emit( - KP.map.layers[current.row()], - ((previous.row() >= 0) and KP.map.layers[previous.row()]) or None - ) + self.selectedLayerChanged.emit(KP.map.layers[current.row()]) def addLayer(self): @@ -146,6 +143,8 @@ class KPObjectSelector(QtGui.QListView): QtGui.QListView.setModel(self, model) + model.view = self + menuList = model.groupItem().getGroupList() string = QtCore.QString(QtCore.QChar(0x25BE)) @@ -234,6 +233,8 @@ class KPMainWindow(QtGui.QMainWindow): self.layerListDock = QtGui.QDockWidget('Layers') self.layerListDock.setWidget(self.layerList) + self.layerList.selectedLayerChanged.connect(self.scene.setCurrentLayer) + self.objectSelector = KPObjectSelector() self.updateObjectSelector() self.objectSelectorDock = QtGui.QDockWidget('Objects') @@ -252,8 +253,6 @@ class KPMainWindow(QtGui.QMainWindow): tileset = KPTileset.loadFromArc('/home/me/Dropbox/NEWERsmbw/Test3.arc') self.objectSelector.setModel(tileset.getModel()) - tileset.getModel().view = self.objectSelector - |