0

support for mixed png/jpg tilesets, and overlays with imgformat=jpg

This commit is contained in:
Aaron Griffith
2011-04-16 19:25:40 -04:00
parent 26b35906a4
commit 05c4083b7e
5 changed files with 26 additions and 24 deletions

View File

@@ -23,6 +23,7 @@ from time import strftime, gmtime
import json
import util
from chunk import overlay_rendermodes
"""
This module has routines related to generating a Google Maps-based
@@ -72,12 +73,11 @@ class MapGen(object):
raise ValueError("there must be at least one quadtree to work on")
self.destdir = quadtrees[0].destdir
self.imgformat = quadtrees[0].imgformat
self.world = quadtrees[0].world
self.p = quadtrees[0].p
for i in quadtrees:
if i.destdir != self.destdir or i.imgformat != self.imgformat or i.world != self.world:
raise ValueError("all the given quadtrees must have the same destdir")
if i.destdir != self.destdir or i.world != self.world:
raise ValueError("all the given quadtrees must have the same destdir and world")
self.quadtrees = quadtrees
@@ -85,24 +85,20 @@ class MapGen(object):
"""Writes out config.js, marker.js, and region.js
Copies web assets into the destdir"""
zoomlevel = self.p
imgformat = self.imgformat
configpath = os.path.join(util.get_program_path(), "config.js")
config = open(configpath, 'r').read()
config = config.replace(
"{maxzoom}", str(zoomlevel))
config = config.replace(
"{imgformat}", str(imgformat))
config = config.replace("{spawn_coords}",
json.dumps(list(self.world.spawn)))
# create generated map type data, from given quadtrees
# FIXME hook this into render_modes in setup.py, somehow
overlay_types = ['spawn']
maptypedata = map(lambda q: {'label' : q.rendermode.capitalize(),
'path' : q.tiledir,
'overlay' : q.rendermode in overlay_types},
'overlay' : q.rendermode in overlay_rendermodes,
'imgformat' : q.imgformat},
self.quadtrees)
config = config.replace("{maptypedata}", json.dumps(maptypedata))
@@ -114,7 +110,7 @@ class MapGen(object):
blank = Image.new("RGBA", (1,1))
tileDir = os.path.join(self.destdir, quadtree.tiledir)
if not os.path.exists(tileDir): os.mkdir(tileDir)
blank.save(os.path.join(tileDir, "blank."+self.imgformat))
blank.save(os.path.join(tileDir, "blank."+quadtree.imgformat))
# copy web assets into destdir:
mirror_dir(os.path.join(util.get_program_path(), "web_assets"), self.destdir)