summaryrefslogtreecommitdiff
path: root/src/mapdata.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapdata.py')
-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()