size, sources, levels
This commit is contained in:
parent
c4287e110c
commit
39cdf6a02f
1 changed files with 21 additions and 0 deletions
|
@ -11,6 +11,7 @@ class MapManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.main_pkg = None
|
self.main_pkg = None
|
||||||
self.pkgs = OrderedDict()
|
self.pkgs = OrderedDict()
|
||||||
|
self.levels = []
|
||||||
|
|
||||||
def add_map_dir(self, path):
|
def add_map_dir(self, path):
|
||||||
pkg = MapDataPackage(path)
|
pkg = MapDataPackage(path)
|
||||||
|
@ -22,6 +23,8 @@ class MapManager:
|
||||||
raise MapInitError('There can not be more than one root map package: tried to add '+pkg.name+', '
|
raise MapInitError('There can not be more than one root map package: tried to add '+pkg.name+', '
|
||||||
'but '+self.main_pkg.name+' was there first.')
|
'but '+self.main_pkg.name+' was there first.')
|
||||||
self.main_pkg = pkg
|
self.main_pkg = pkg
|
||||||
|
self.levels = pkg.levels
|
||||||
|
self.size = pkg.size
|
||||||
else:
|
else:
|
||||||
if pkg.extends not in self.pkgs:
|
if pkg.extends not in self.pkgs:
|
||||||
raise MapInitError('map package'+pkg.name+' extends '+pkg.exends+', which was not imported '
|
raise MapInitError('map package'+pkg.name+' extends '+pkg.exends+', which was not imported '
|
||||||
|
@ -29,6 +32,10 @@ class MapManager:
|
||||||
|
|
||||||
self.pkgs[pkg.name] = pkg
|
self.pkgs[pkg.name] = pkg
|
||||||
|
|
||||||
|
@property
|
||||||
|
def all_sources(self):
|
||||||
|
return sum((pkg.sources for pkg in self.pkgs), [])
|
||||||
|
|
||||||
|
|
||||||
class MapDataPackage:
|
class MapDataPackage:
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
@ -47,3 +54,17 @@ class MapDataPackage:
|
||||||
raise MapInitError('Map package '+path+' has no name in map.json.')
|
raise MapInitError('Map package '+path+' has no name in map.json.')
|
||||||
|
|
||||||
self.extends = data.get('extends')
|
self.extends = data.get('extends')
|
||||||
|
|
||||||
|
self.size = data.get('size')
|
||||||
|
|
||||||
|
self.sources = tuple(MapSource(self, name, source)
|
||||||
|
for name, source in data.get('sources', {}).items())
|
||||||
|
|
||||||
|
self.levels = data.get('levels')
|
||||||
|
|
||||||
|
|
||||||
|
class MapSource:
|
||||||
|
def __init__(self, pkg, name, data):
|
||||||
|
self.name = name
|
||||||
|
self.src = os.path.join(pkg.path, data['src'])
|
||||||
|
self.bounds = data['bounds']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue