diff options
Diffstat (limited to '')
-rw-r--r-- | src/editorui.py | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/src/editorui.py b/src/editorui.py index 05cb77f..7969100 100644 --- a/src/editorui.py +++ b/src/editorui.py @@ -262,50 +262,51 @@ class KPMapScene(QtGui.QGraphicsScene): for layer in reversed(KP.map.layers): if not layer.visible: continue - left, top = layer.cacheBasePos - width, height = layer.cacheSize - right, bottom = left+width, top+height + if isinstance(layer, KPTileLayer): + left, top = layer.cacheBasePos + width, height = layer.cacheSize + right, bottom = left+width, top+height - if width == 0 and height == 0: continue + if width == 0 and height == 0: continue - if right < areaLeftT: continue - if left > areaRightT: continue + if right < areaLeftT: continue + if left > areaRightT: continue - if bottom < areaTopT: continue - if top > areaBottomT: continue + if bottom < areaTopT: continue + if top > areaBottomT: continue - # decide how much of the layer we'll actually draw - drawLeft = int(max(areaLeftT, left)) - drawRight = int(min(areaRightT, right)) + # decide how much of the layer we'll actually draw + drawLeft = int(max(areaLeftT, left)) + drawRight = int(min(areaRightT, right)) - drawTop = int(max(areaTopT, top)) - drawBottom = int(min(areaBottomT, bottom)) + drawTop = int(max(areaTopT, top)) + drawBottom = int(min(areaBottomT, bottom)) - srcY = drawTop - top - destY = drawTop * 24 + srcY = drawTop - top + destY = drawTop * 24 - baseSrcX = drawLeft - left - baseDestX = drawLeft * 24 + baseSrcX = drawLeft - left + baseDestX = drawLeft * 24 - rows = layer.cache - tileset = KP.map.loadedTilesets[layer.tileset] - tileList = tileset.tiles + rows = layer.cache + tileset = KP.map.loadedTilesets[layer.tileset] + tileList = tileset.tiles - for y in xrange(drawTop, drawBottom): - srcX = baseSrcX - destX = baseDestX - row = rows[srcY] + for y in xrange(drawTop, drawBottom): + srcX = baseSrcX + destX = baseDestX + row = rows[srcY] - for x in xrange(drawLeft, drawRight): - tile = row[srcX] - if tile != -1: - painter.drawPixmap(destX, destY, tileList[tile]) - - srcX += 1 - destX += 24 + for x in xrange(drawLeft, drawRight): + tile = row[srcX] + if tile != -1: + painter.drawPixmap(destX, destY, tileList[tile]) + + srcX += 1 + destX += 24 - srcY += 1 - destY += 24 + srcY += 1 + destY += 24 def setCurrentLayer(self, layer): |