diff --git a/overviewer.py b/overviewer.py index 3a638e5..8331bf3 100755 --- a/overviewer.py +++ b/overviewer.py @@ -125,28 +125,28 @@ else: doExit() from optparse import OptionParser -from overviewer_core import optimizeimages, world, quadtree -from overviewer_core import googlemap, rendernode +from overviewer_core import optimizeimages, world +from overviewer_core import googlemap from overviewer_core import configParser, tileset, assetmanager, dispatcher # definitions of built-in custom modes # usually because what used to be a mode became an option # for example, night mode -builtin_custom_rendermodes = { - 'night' : { - 'parent' : 'lighting', - 'label' : 'Night', - 'description' : 'like "lighting", except at night', - 'options' : {'night' : True} - }, +builtin_custom_rendermodes = {} +# 'night' : { +# 'parent' : 'lighting', +# 'label' : 'Night', +# 'description' : 'like "lighting", except at night', +# 'options' : {'night' : True} +# }, - 'smooth-night' : { - 'parent' : 'smooth-lighting', - 'label' : 'Smooth Night', - 'description' : 'like "lighting", except smooth and at night', - 'options' : {'night' : True} - }, -} +# 'smooth-night' : { +# 'parent' : 'smooth-lighting', +# 'label' : 'Smooth Night', +# 'description' : 'like "lighting", except smooth and at night', +# 'options' : {'night' : True} +# }, +# } helptext = """ %prog [OPTIONS] """ @@ -378,8 +378,8 @@ dir but you forgot to put quotes around the directory, since it contains spaces. # make sure that the textures can be found try: #textures.generate(path=options.textures_path) - # TODO(agrif): your magic goes here - textures.generate(path=None) + tex = textures.Textures() + tex.generate() except IOError, e: logging.error(str(e)) doExit(code=1, consoleMsg=False) @@ -402,7 +402,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces. # if no dimension has been specified, just use the first one # TODO support the case where a different dimension is specified - rset = w.get_regionset(2) + rset = w.get_regionset(0) logging.debug("Using RegionSet %r", rset) # create our TileSet from this RegionSet @@ -410,7 +410,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces. print "tileset_dir: %r" % tileset_dir if not os.path.exists(tileset_dir): os.mkdir(tileset_dir) - tset = tileset.TileSet(rset, assetMrg, render, tileset_dir) + tset = tileset.TileSet(rset, assetMrg, tex, render, tileset_dir) tilesets.append(tset) diff --git a/overviewer_core/tileset.py b/overviewer_core/tileset.py index fcb7f21..09f4af0 100644 --- a/overviewer_core/tileset.py +++ b/overviewer_core/tileset.py @@ -21,6 +21,8 @@ import shutil import random import functools import time +import errno +import stat from collections import namedtuple from PIL import Image @@ -378,15 +380,15 @@ class TileSet(object): self._render_rendertile(RenderTile.from_path(tilepath)) else: # A composite-tile - if len(tileset) == 0: + if len(tilepath) == 0: # The base tile dest = self.outputdir name = "base" else: # All others - dest = os.path.sep.join(self.outputdir, *(str(x) for x in tilepath[:-1])) + dest = os.path.join(self.outputdir, *(str(x) for x in tilepath[:-1])) name = str(tilepath[-1]) - self._render_compositetile(dest, base) + self._render_compositetile(dest, name) def get_persistent_data(self): """Returns a dictionary representing the persistent data of this @@ -544,7 +546,7 @@ class TileSet(object): elif rendercheck == 1: def compare_times(chunkmtime, tileobj): # Compare chunk mtime to tile mtime on disk - tile_path = tileobj.get_filepath(self.full_tiledir, self.imgformat) + tile_path = tileobj.get_filepath(self.outputdir, self.imgextension) try: tile_mtime = os.stat(tile_path)[stat.ST_MTIME] except OSError, e: @@ -750,28 +752,15 @@ class TileSet(object): """ - imgpath = tile.get_filepath(self.full_tiledir, self.imgformat) + imgpath = tile.get_filepath(self.outputdir, self.imgextension) # Calculate which chunks are relevant to this tile # This is a list of (col, row, chunkx, chunkz, chunk_mtime) chunks = list(self._get_chunks_for_tile(tile)) - region = self.regionobj - - tile_mtime = None - if check_tile: - # stat the file, we need to know if it exists and its mtime - try: - tile_mtime = os.stat(imgpath)[stat.ST_MTIME] - except OSError, e: - # ignore only if the error was "file not found" - if e.errno != errno.ENOENT: - raise - if not chunks: # No chunks were found in this tile - if not check_tile: - logging.warning("%s was requested for render, but no chunks found! This may be a bug", tile) + logging.warning("%s was requested for render, but no chunks found! This may be a bug", tile) try: os.unlink(imgpath) except OSError, e: @@ -797,9 +786,8 @@ class TileSet(object): #logging.debug("writing out worldtile {0}".format(imgpath)) # Compile this image - tileimg = Image.new("RGBA", (384, 384), self.bgcolor) + tileimg = Image.new("RGBA", (384, 384), self.options['bgcolor']) - rendermode = self.rendermode colstart = tile.col rowstart = tile.row # col colstart will get drawn on the image starting at x coordinates -(384/2) @@ -817,13 +805,13 @@ class TileSet(object): xpos, ypos, self.options['rendermode'], self.textures) # Save them - if self.imgformat == 'jpg': + if self.imgextension == 'jpg': tileimg.save(imgpath, quality=self.imgquality, subsampling=0) else: # png tileimg.save(imgpath) - if self.optimizeimg: - optimize_image(imgpath, self.imgformat, self.optimizeimg) + if self.options['optimizeimg']: + optimize_image(imgpath, self.imgextension, self.options['optimizeimg']) os.utime(imgpath, (max_chunk_mtime, max_chunk_mtime))