summaryrefslogtreecommitdiff
path: root/src/mapdata.py
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-03-27 23:15:51 +0200
committerTreeki <treeki@gmail.com>2012-03-27 23:15:51 +0200
commit93349b8e694ac31f0aba4f6bc25515bd5a531f7d (patch)
tree22eabb7d881efd482f5f62f526039931994066e9 /src/mapdata.py
parent8d5d27396da513fea62d99d8550923dee2f08ed8 (diff)
downloadkoopatlas-93349b8e694ac31f0aba4f6bc25515bd5a531f7d.tar.gz
koopatlas-93349b8e694ac31f0aba4f6bc25515bd5a531f7d.zip
tilesets now loaded on-demand and not part of KPMap
Diffstat (limited to '')
-rw-r--r--src/mapdata.py60
1 files changed, 2 insertions, 58 deletions
diff --git a/src/mapdata.py b/src/mapdata.py
index 7346634..8469ad4 100644
--- a/src/mapdata.py
+++ b/src/mapdata.py
@@ -51,7 +51,7 @@ class KPObject(object):
__dump_attribs__ = ('position', 'size', 'tileset', 'kind')
def _load(self, mapObj, src):
- self.kindObj = mapObj.loadedTilesets[self.tileset].objects[self.kind]
+ self.kindObj = KP.tileset(self.tileset).objects[self.kind]
self.updateCache()
def __init__(self):
@@ -262,7 +262,7 @@ class KPPathTileLayer(KPLayer):
def setTileset(self, tileset):
self.tileset = tileset
- tsObjects = KP.map.loadedTilesets[tileset]
+ tsObjects = KP.tileset(tileset)
for obj in self.objects:
obj.tileset = tileset
@@ -542,11 +542,6 @@ class KPMap(object):
self.doodadDefinitions = []
self.doodadModel = KPMap.DoodadModel(self.doodadDefinitions)
- self.tilesets = {}
- self.loadedTilesets = {}
-
- self.loadTilesets()
-
# LAYERS
class LayerModel(QtCore.QAbstractListModel):
@@ -740,55 +735,4 @@ class KPMap(object):
def derefNode(self, ref):
return self.pathLayer.nodes[ref] if (ref >= 0) else None
- # TILESETS
- def loadTilesets(self):
- import os
- from hashlib import sha256 as sha
-
- path = os.getcwd() + os.sep + 'Tilesets'
-
- if not os.path.exists(path):
- os.mkdir(path)
-
- for file in os.listdir(path):
- name = file[:-4]
-
- if file[-4:] == '.arc':
- filepath = path + os.sep + file
-
- filehandler = open(filepath)
- data = filehandler.read()
- filehandler.close()
- hash = sha(data).hexdigest()
-
- # this is a bit messy
- try:
- old_info = self.tilesets[name]
- if old_info['hash'] == hash:
- continue
- except KeyError:
- pass
-
- self.tilesets[name] = {'path': filepath, 'hash': hash}
- self.loadedTilesets[name] = KPTileset.loadFromArc(filepath)
-
-
- def reloadTileset(self, name):
- # TODO: Re-enable this when it's fixed.
- return
-
- from hashlib import sha256 as sha
-
- info = self.tilesets[name]
-
- filehandler = open(info['path'])
- data = filehandler.read()
- filehandler.close()
- hash = sha(data).hexdigest()
-
- if info['hash'] != hash:
- self.loadedTilesets[name] = KPTileset.loadFromArc(info['path'])
-
- KP.mapscene.update()
- KP.mapscene.views()[0].update()