summaryrefslogtreecommitdiff
path: root/src/editorui
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-11-14 22:32:47 +0100
committerTreeki <treeki@gmail.com>2011-11-14 22:32:47 +0100
commitffc9daf57c6a3ad8377c82d811cb3bcad2421bea (patch)
tree0b415d47988588b3dab2b1cb9f8fb4e64468ebf1 /src/editorui
parent9026e559b01dc908e838775dd76e45c4a379bd66 (diff)
downloadkoopatlas-ffc9daf57c6a3ad8377c82d811cb3bcad2421bea.tar.gz
koopatlas-ffc9daf57c6a3ad8377c82d811cb3bcad2421bea.zip
created a generic KPLayer class
Diffstat (limited to '')
-rw-r--r--src/editorui.py67
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):