0

Specifying a dimension in a config file now works

This commit is contained in:
Andrew Chin
2012-01-27 20:30:58 -05:00
parent c29c983a79
commit 96602a48d4
4 changed files with 39 additions and 8 deletions

View File

@@ -296,8 +296,10 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
w = worldcache[render['worldname']]
# TODO get the correct regionset based on render['dimension']
rset = w.get_regionset(0)
rset = w.get_regionset(render['dimension'])
if rset == None: # indicates no such dimension was found:
logging.error("Sorry, you requested dimension '%s' for %s, but I couldn't find it", render['dimension'], render_name)
return 1
if (render['northdirection'] > 0):
rset = rset.rotate(render['northdirection'])
logging.debug("Using RegionSet %r", rset)
@@ -309,7 +311,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
os.mkdir(tileset_dir)
# only pass to the TileSet the options it really cares about
tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title"])
tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension"])
tset = tileset.TileSet(rset, assetMrg, tex, tileSetOpts, tileset_dir)
tilesets.append(tset)

View File

@@ -85,8 +85,9 @@ directory.
# based on the tilesets we have, group them by worlds
worlds = []
for tileset in tilesets:
if tileset.options.get('worldname_orig') not in worlds:
worlds.append(tileset.options.get('worldname_orig'))
full_name = tileset.get_persistent_data()['world']
if full_name not in worlds:
worlds.append(full_name)
dump['worlds'] = worlds
dump['map'] = dict()

View File

@@ -390,7 +390,7 @@ class TileSet(object):
path = self.options.get('name'),
base = '',
bgcolor = bgcolorformat(self.options.get('bgcolor')),
world = self.options.get('worldname_orig'),
world = self.options.get('worldname_orig') + " - " + self.options.get('dimension'),
last_rendertime = self.this_rendertime,
north_direction = 'upper-left')
print "get_persistent_data: %r" % d

View File

@@ -164,7 +164,18 @@ class World(object):
def get_regionsets(self):
return self.regionsets
def get_regionset(self, index):
return self.regionsets[index]
if type(index) == int:
return self.regionsets[index]
else: # assume a string constant
if index == "default":
return self.regionsets[0]
else:
candids = [x for x in self.regionsets if x.get_type() == index]
if len(candids) > 0:
return candids[0]
else:
return None
def get_level_dat_data(self):
# Return a copy
@@ -239,7 +250,7 @@ class RegionSet(object):
in-memory.
"""
self.regiondir = regiondir
self.regiondir = os.path.normpath(regiondir)
logging.info("Scanning regions")
@@ -265,6 +276,23 @@ class RegionSet(object):
def __repr__(self):
return "<RegionSet regiondir=%r>" % self.regiondir
def get_type(self):
"""Attempts to return a string describing the dimension represented by
this regionset. Either "nether", "end" or "overworld"
"""
# path will be normalized in __init__
if self.regiondir.endswith("/DIM-1/region"):
return "nether"
elif self.regiondir.endswith("/DIM1/region"):
return "end"
elif self.regiondir.endswith("/region"):
return "overworld"
else:
raise Exception("Woah, what kind of dimension is this! %r" % self.regiondir)
@log_other_exceptions
def get_chunk(self, x, z):
"""Returns a dictionary object representing the "Level" NBT Compound